Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
geb-proxy-registry/src/GebProxyRegistry.sol
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
32 lines (26 sloc)
1.06 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.6.7; | |
import 'ds-proxy/proxy.sol'; | |
// This Registry deploys new proxy instances through DSProxyFactory.build(address) and keeps a registry of owner => proxy | |
contract GebProxyRegistry { | |
mapping(address => DSProxy) public proxies; | |
DSProxyFactory factory; | |
// --- Events --- | |
event Build(address usr, address proxy); | |
constructor(address factory_) public { | |
factory = DSProxyFactory(factory_); | |
} | |
// deploys a new proxy instance | |
// sets owner of proxy to caller | |
function build() public returns (address payable proxy) { | |
proxy = build(msg.sender); | |
emit Build(msg.sender, proxy); | |
} | |
// deploys a new proxy instance | |
// sets custom owner of proxy | |
function build(address owner) public returns (address payable proxy) { | |
require(proxies[owner] == DSProxy(0) || proxies[owner].owner() != owner); // Not allow new proxy if the user already has one and remains being the owner | |
proxy = factory.build(owner); | |
proxies[owner] = DSProxy(proxy); | |
emit Build(owner, proxy); | |
} | |
} |