smart-contract/contracts/Beta/Registry.sol
2019-03-21 03:34:02 +05:30

26 lines
726 B
Solidity

pragma solidity ^0.5.0;
import "./UserWallet.sol";
/**
* @title User Wallet Registry
*/
contract WalletRegistry {
event Created(address indexed sender, address indexed owner, address proxy);
mapping(address => UserWallet) public proxies;
/**
* @dev deploys a new proxy instance and sets custom owner of proxy
* Throws if the owner already have a UserWallet
*/
function build() public returns (UserWallet proxy) {
require(proxies[msg.sender] == UserWallet(0), "multiple-proxy-per-user-not-allowed");
proxy = new UserWallet();
proxy.setOwner(msg.sender);
emit Created(msg.sender, msg.sender, address(proxy));
proxies[msg.sender] = proxy;
}
}