Files
openzeppelin-contracts/contracts/ownership/Secondary.sol
Nicolás Venturo 89835152ce GSN compatibility (#1880)
* switch to using Context internally

* add context import

* Add smoke test to make sure enabling GSN support works

* Update test/GSN/ERC721GSNRecipientMock.test.js

Co-Authored-By: Francisco Giordano <frangio.1@gmail.com>

* Upgrade truffle

* add missing awaits

* Revert "Upgrade truffle"

This reverts commit f9b0ba9019.
2019-08-15 16:40:34 +02:00

53 lines
1.3 KiB
Solidity

pragma solidity ^0.5.2;
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "../GSN/Context.sol";
/**
* @title Secondary
* @dev A Secondary contract can only be used by its primary account (the one that created it)
*/
contract Secondary is Initializable, Context {
address private _primary;
event PrimaryTransferred(
address recipient
);
/**
* @dev Sets the primary account to the one that is creating the Secondary contract.
*/
function initialize(address sender) public initializer {
_primary = sender;
emit PrimaryTransferred(_primary);
}
/**
* @dev Reverts if called from any account other than the primary.
*/
modifier onlyPrimary() {
require(_msgSender() == _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));
_primary = recipient;
emit PrimaryTransferred(_primary);
}
uint256[50] private ______gap;
}