* Error handling in ERC20 and ERC721 * Added message string for require. * Fixed solhint errors. * Updated PR as per issue #1709 * changes as per #1709 and openzeppelin forum. * Changes in require statement * Changes in require statement * build pipeline fix * Changes as per @nventuro's comment. * Update revert reason strings. * Fianal update of revert reason strings. * WIP: Updating reason strings in test cases * WIP: Added changes to ERC20 and ERC721 * Fixes linting errors in *.tes.js files * Achieved 100% code coverage * Updated the test cases with shouldFail.reverting.withMessage() * Fix package-lock. * address review comments * fix linter issues * fix remaining revert reasons
47 lines
1.2 KiB
Solidity
47 lines
1.2 KiB
Solidity
pragma solidity ^0.5.7;
|
|
|
|
/**
|
|
* @title Secondary
|
|
* @dev A Secondary contract can only be used by its primary account (the one that created it).
|
|
*/
|
|
contract Secondary {
|
|
address private _primary;
|
|
|
|
event PrimaryTransferred(
|
|
address recipient
|
|
);
|
|
|
|
/**
|
|
* @dev Sets the primary account to the one that is creating the Secondary contract.
|
|
*/
|
|
constructor () internal {
|
|
_primary = msg.sender;
|
|
emit PrimaryTransferred(_primary);
|
|
}
|
|
|
|
/**
|
|
* @dev Reverts if called from any account other than the primary.
|
|
*/
|
|
modifier onlyPrimary() {
|
|
require(msg.sender == _primary, "Secondary: caller is not the primary account");
|
|
_;
|
|
}
|
|
|
|
/**
|
|
* @return the address of the primary.
|
|
*/
|
|
function primary() public view returns (address) {
|
|
return _primary;
|
|
}
|
|
|
|
/**
|
|
* @dev Transfers contract to a new primary.
|
|
* @param recipient The address of new primary.
|
|
*/
|
|
function transferPrimary(address recipient) public onlyPrimary {
|
|
require(recipient != address(0), "Secondary: new primary is the zero address");
|
|
_primary = recipient;
|
|
emit PrimaryTransferred(_primary);
|
|
}
|
|
}
|