-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProxyRegistry.json
146 lines (146 loc) · 15 KB
/
ProxyRegistry.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
{
"address": "0xA2c5533E7Ab2954eacE778CEC88104c756457AF6",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "factory_",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "build",
"outputs": [
{
"internalType": "address payable",
"name": "proxy",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "build",
"outputs": [
{
"internalType": "address payable",
"name": "proxy",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "proxies",
"outputs": [
{
"internalType": "contract DSProxy",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
],
"transactionHash": "0xa784276747cc252e4fa1964b3f34416d20248b8727a5253138dc42038c92d4ed",
"receipt": {
"to": null,
"from": "0x595b85b4A418e3B8df897D02F5BD49167D00862F",
"contractAddress": "0xA2c5533E7Ab2954eacE778CEC88104c756457AF6",
"transactionIndex": 0,
"gasUsed": "213780",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0x15add037f1b975a4a0dcc1889caf322c32bb4c6dcf01bd313163e11bb08677cb",
"transactionHash": "0xa784276747cc252e4fa1964b3f34416d20248b8727a5253138dc42038c92d4ed",
"logs": [],
"blockNumber": 8091142,
"cumulativeGasUsed": "213780",
"status": 1,
"byzantium": true
},
"args": [
"0x308a694c2bB024a2Cd8cCCB80eFd170761482886"
],
"numDeployments": 1,
"solcInputHash": "a86e93456cfbb956ab843adb2133c9fc",
"metadata": "{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"factory_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"build\",\"outputs\":[{\"internalType\":\"address payable\",\"name\":\"proxy\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"build\",\"outputs\":[{\"internalType\":\"address payable\",\"name\":\"proxy\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"proxies\",\"outputs\":[{\"internalType\":\"contract DSProxy\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/deploy/DSProxyContract.sol\":\"ProxyRegistry\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":20},\"remappings\":[]},\"sources\":{\"contracts/deploy/DSProxyContract.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\npragma solidity 0.6.12;\\n\\ninterface DSAuthority {\\n function canCall(\\n address src,\\n address dst,\\n bytes4 sig\\n ) external view returns (bool);\\n}\\n\\ncontract DSAuthEvents {\\n event LogSetAuthority(address indexed authority);\\n event LogSetOwner(address indexed owner);\\n}\\n\\ncontract DSAuth is DSAuthEvents {\\n DSAuthority public authority;\\n address public owner;\\n\\n constructor() public {\\n owner = msg.sender;\\n emit LogSetOwner(msg.sender);\\n }\\n\\n function setOwner(address owner_) public auth {\\n owner = owner_;\\n emit LogSetOwner(owner);\\n }\\n\\n function setAuthority(DSAuthority authority_) public auth {\\n authority = authority_;\\n emit LogSetAuthority(address(authority));\\n }\\n\\n modifier auth() {\\n require(isAuthorized(msg.sender, msg.sig), \\\"ds-auth-unauthorized\\\");\\n _;\\n }\\n\\n function isAuthorized(address src, bytes4 sig) internal view returns (bool) {\\n if (src == address(this)) {\\n return true;\\n } else if (src == owner) {\\n return true;\\n } else if (authority == DSAuthority(0)) {\\n return false;\\n } else {\\n return authority.canCall(src, address(this), sig);\\n }\\n }\\n}\\n\\ncontract DSNote {\\n event LogNote(bytes4 indexed sig, address indexed guy, bytes32 indexed foo, bytes32 indexed bar, uint wad, bytes fax) anonymous;\\n\\n modifier note() {\\n bytes32 foo;\\n bytes32 bar;\\n uint wad;\\n\\n assembly {\\n foo := calldataload(4)\\n bar := calldataload(36)\\n wad := callvalue()\\n }\\n\\n _;\\n\\n emit LogNote(msg.sig, msg.sender, foo, bar, wad, msg.data);\\n }\\n}\\n\\n// DSProxy\\n// Allows code execution using a persistant identity This can be very\\n// useful to execute a sequence of atomic actions. Since the owner of\\n// the proxy can be changed, this allows for dynamic ownership models\\n// i.e. a multisig\\ncontract DSProxy is DSAuth, DSNote {\\n DSProxyCache public cache; // global cache for contracts\\n\\n constructor(address _cacheAddr) public {\\n setCache(_cacheAddr);\\n }\\n\\n fallback() external payable {}\\n\\n // use the proxy to execute calldata _data on contract _code\\n function execute(\\n bytes memory _code,\\n bytes memory _data,\\n bool bools\\n ) public payable returns (address target, bytes memory response) {\\n target = cache.read(_code);\\n if (target == address(0)) {\\n // deploy contract & store its address in cache\\n target = cache.write(_code);\\n }\\n\\n response = execute(target, _data);\\n }\\n\\n function execute(address _target, bytes memory _data) public payable auth note returns (bytes memory response) {\\n require(_target != address(0), \\\"ds-proxy-target-address-required\\\");\\n\\n // call contract in current context\\n assembly {\\n let succeeded := delegatecall(sub(gas(), 5000), _target, add(_data, 0x20), mload(_data), 0, 0)\\n let size := returndatasize()\\n\\n response := mload(0x40)\\n mstore(0x40, add(response, and(add(add(size, 0x20), 0x1f), not(0x1f))))\\n mstore(response, size)\\n returndatacopy(add(response, 0x20), 0, size)\\n\\n switch iszero(succeeded)\\n case 1 {\\n // throw if delegatecall failed\\n revert(add(response, 0x20), size)\\n }\\n }\\n }\\n\\n //set new cache\\n function setCache(address _cacheAddr) public auth note returns (bool) {\\n require(_cacheAddr != address(0), \\\"ds-proxy-cache-address-required\\\");\\n cache = DSProxyCache(_cacheAddr); // overwrite cache\\n return true;\\n }\\n}\\n\\n// DSProxyFactory\\n// This factory deploys new proxy instances through build()\\n// Deployed proxy addresses are logged\\ncontract DSProxyFactory {\\n event Created(address indexed sender, address indexed owner, address proxy, address cache);\\n mapping(address => bool) public isProxy;\\n DSProxyCache public cache;\\n\\n constructor() public {\\n cache = new DSProxyCache();\\n }\\n\\n // deploys a new proxy instance\\n // sets owner of proxy to caller\\n function build() public returns (address payable proxy) {\\n proxy = build(msg.sender);\\n }\\n\\n // deploys a new proxy instance\\n // sets custom owner of proxy\\n function build(address owner) public returns (address payable proxy) {\\n proxy = address(new DSProxy(address(cache)));\\n emit Created(msg.sender, owner, address(proxy), address(cache));\\n DSProxy(proxy).setOwner(owner);\\n isProxy[proxy] = true;\\n }\\n}\\n\\n// DSProxyCache\\n// This global cache stores addresses of contracts previously deployed\\n// by a proxy. This saves gas from repeat deployment of the same\\n// contracts and eliminates blockchain bloat.\\n\\n// By default, all proxies deployed from the same factory store\\n// contracts in the same cache. The cache a proxy instance uses can be\\n// changed. The cache uses the sha3 hash of a contract's bytecode to\\n// lookup the address\\ncontract DSProxyCache {\\n mapping(bytes32 => address) cache;\\n\\n function read(bytes memory _code) public view returns (address) {\\n bytes32 hash = keccak256(_code);\\n return cache[hash];\\n }\\n\\n function write(bytes memory _code) public returns (address target) {\\n assembly {\\n target := create(0, add(_code, 0x20), mload(_code))\\n switch iszero(extcodesize(target))\\n case 1 {\\n // throw if contract failed to deploy\\n revert(0, 0)\\n }\\n }\\n bytes32 hash = keccak256(_code);\\n cache[hash] = target;\\n }\\n}\\n\\n// ProxyRegistry\\n// This Registry deploys new proxy instances through DSProxyFactory.build(address) and keeps a registry of owner => proxy\\ncontract ProxyRegistry {\\n mapping(address => DSProxy) public proxies;\\n DSProxyFactory factory;\\n\\n constructor(address factory_) public {\\n factory = DSProxyFactory(factory_);\\n }\\n\\n // deploys a new proxy instance\\n // sets owner of proxy to caller\\n function build() public returns (address payable proxy) {\\n proxy = build(msg.sender);\\n }\\n\\n // deploys a new proxy instance\\n // sets custom owner of proxy\\n function build(address owner) public returns (address payable proxy) {\\n require(proxies[owner] == DSProxy(0) || proxies[owner].owner() != owner); // Not allow new proxy if the user already has one and remains being the owner\\n proxy = factory.build(owner);\\n proxies[owner] = DSProxy(proxy);\\n }\\n}\\n\",\"keccak256\":\"0xe721f09114fbc8e46639e77be091457c0288ee1aaefa389bda2388c027fc0346\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}",
"bytecode": "0x608060405234801561001057600080fd5b506040516102dd3803806102dd8339818101604052602081101561003357600080fd5b5051600180546001600160a01b0319166001600160a01b0390921691909117905561027a806100636000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80638e1a55fc14610046578063c45527911461006a578063f3701da214610090575b600080fd5b61004e6100b6565b604080516001600160a01b039092168252519081900360200190f35b61004e6004803603602081101561008057600080fd5b50356001600160a01b03166100c6565b61004e600480360360208110156100a657600080fd5b50356001600160a01b03166100e1565b60006100c1336100e1565b905090565b6000602081905290815260409020546001600160a01b031681565b6001600160a01b03818116600090815260208190526040812054909116158061018d57506001600160a01b0380831660008181526020818152604091829020548251638da5cb5b60e01b8152925193941692638da5cb5b926004808201939291829003018186803b15801561015557600080fd5b505afa158015610169573d6000803e3d6000fd5b505050506040513d602081101561017f57600080fd5b50516001600160a01b031614155b61019657600080fd5b600154604080516379b80ed160e11b81526001600160a01b0385811660048301529151919092169163f3701da29160248083019260209291908290030181600087803b1580156101e557600080fd5b505af11580156101f9573d6000803e3d6000fd5b505050506040513d602081101561020f57600080fd5b50516001600160a01b03928316600090815260208190526040902080546001600160a01b03191693821693909317909255509056fea264697066735822122022b4a60cf39e966455af17b9c54215eea08b1dc9f6c3585a76fab54b7a9e0e4364736f6c634300060c0033",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80638e1a55fc14610046578063c45527911461006a578063f3701da214610090575b600080fd5b61004e6100b6565b604080516001600160a01b039092168252519081900360200190f35b61004e6004803603602081101561008057600080fd5b50356001600160a01b03166100c6565b61004e600480360360208110156100a657600080fd5b50356001600160a01b03166100e1565b60006100c1336100e1565b905090565b6000602081905290815260409020546001600160a01b031681565b6001600160a01b03818116600090815260208190526040812054909116158061018d57506001600160a01b0380831660008181526020818152604091829020548251638da5cb5b60e01b8152925193941692638da5cb5b926004808201939291829003018186803b15801561015557600080fd5b505afa158015610169573d6000803e3d6000fd5b505050506040513d602081101561017f57600080fd5b50516001600160a01b031614155b61019657600080fd5b600154604080516379b80ed160e11b81526001600160a01b0385811660048301529151919092169163f3701da29160248083019260209291908290030181600087803b1580156101e557600080fd5b505af11580156101f9573d6000803e3d6000fd5b505050506040513d602081101561020f57600080fd5b50516001600160a01b03928316600090815260208190526040902080546001600160a01b03191693821693909317909255509056fea264697066735822122022b4a60cf39e966455af17b9c54215eea08b1dc9f6c3585a76fab54b7a9e0e4364736f6c634300060c0033",
"libraries": {},
"devdoc": {
"kind": "dev",
"methods": {},
"version": 1
},
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
},
"storageLayout": {
"storage": [
{
"astId": 435,
"contract": "contracts/deploy/DSProxyContract.sol:ProxyRegistry",
"label": "proxies",
"offset": 0,
"slot": "0",
"type": "t_mapping(t_address,t_contract(DSProxy)299)"
},
{
"astId": 437,
"contract": "contracts/deploy/DSProxyContract.sol:ProxyRegistry",
"label": "factory",
"offset": 0,
"slot": "1",
"type": "t_contract(DSProxyFactory)387"
}
],
"types": {
"t_address": {
"encoding": "inplace",
"label": "address",
"numberOfBytes": "20"
},
"t_contract(DSProxy)299": {
"encoding": "inplace",
"label": "contract DSProxy",
"numberOfBytes": "20"
},
"t_contract(DSProxyFactory)387": {
"encoding": "inplace",
"label": "contract DSProxyFactory",
"numberOfBytes": "20"
},
"t_mapping(t_address,t_contract(DSProxy)299)": {
"encoding": "mapping",
"key": "t_address",
"label": "mapping(address => contract DSProxy)",
"numberOfBytes": "32",
"value": "t_contract(DSProxy)299"
}
}
}
}