Registry change ownership after build()

This commit is contained in:
Sowmayjain 2019-03-20 01:50:40 +05:30
parent ea51cfdee9
commit 15281e8335
2 changed files with 18 additions and 5 deletions

View File

@ -122,7 +122,8 @@ contract WalletRegistry is LogicRegistry {
*/
function build(address owner) public returns (UserWallet proxy) {
require(proxies[owner] == UserWallet(0), "multiple-proxy-per-user-not-allowed");
proxy = new UserWallet(owner);
proxy = new UserWallet();
proxy.setOwnerOnce(owner);
emit Created(msg.sender, owner, address(proxy));
proxies[owner] = proxy;
}

View File

@ -25,12 +25,12 @@ interface AddressRegistryInterface {
/**
* @title Address Record
* @title Address Registry Record
*/
contract AddressRecord {
/**
* @dev address registry of system, logic and proxy addresses
* @dev address registry of system, logic and wallet addresses
*/
address public registry;
@ -111,6 +111,18 @@ contract UserAuth is AddressRecord {
emit LogSetOwner(owner, msg.sender);
}
/**
* @dev sets owner and function is only be called once by registry on build()
* and this hack verifiy the contract on etherscan automatically
* as no dynamic owner address is sent in the constructor
* @param _owner is the new owner of this contract wallet
*/
function setOwnerOnce(address _owner) public auth {
require(msg.sender == registry, "permission-denied");
owner = _owner;
emit LogSetOwner(owner, msg.sender);
}
/**
* @dev checks if called by owner or contract itself
* @param src is the address initiating the call
@ -288,9 +300,9 @@ contract UserWallet is UserManager, UserNote {
* @dev sets the "address registry", owner's last activity, owner's active period and initial owner
* @param _owner initial owner of the contract
*/
constructor(address _owner) public {
constructor() public {
registry = msg.sender;
owner = _owner;
owner = msg.sender; // will be changed in initial call itself
lastActivity = block.timestamp;
activePeriod = 30 days; // default on deployment and changeable afterwards
}