UNPKG

@daostack/upgrades

Version:
796 lines (795 loc) 38.8 kB
{ "fileName": "UpgradeabilityProxy.sol", "contractName": "UpgradeabilityProxy", "source": "pragma solidity ^0.6.0;\n// SPDX-License-Identifier: MIT\n\nimport './BaseUpgradeabilityProxy.sol';\n\n/**\n * @title UpgradeabilityProxy\n * @dev Extends BaseUpgradeabilityProxy with a constructor for initializing\n * implementation and init data.\n */\ncontract UpgradeabilityProxy is BaseUpgradeabilityProxy {\n /**\n * @dev Contract constructor.\n * @param _logic Address of the initial implementation.\n * @param _data Data to send as msg.data to the implementation to initialize the proxied contract.\n * It should include the signature and the parameters of the function to be called, as described in\n * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.\n * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.\n */\n constructor(address _logic, bytes memory _data) public payable {\n assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1));\n _setImplementation(_logic);\n if(_data.length > 0) {\n (bool success,) = _logic.delegatecall(_data);\n require(success);\n }\n }\n}\n", "sourcePath": "contracts/upgradeability/UpgradeabilityProxy.sol", "sourceMap": "245:893:42:-:0;;;827:309;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;987:1;942:41;;;;;;;;;;;;;;;;;;;;;934:50;;:54;926:63;;903:86;;;810:66:36;903:19:42;;:86;;;;896:94;;;;;;996:26;1015:6;996:18;;;:26;;:::i;:::-;1046:1;1031:5;:12;:16;1028:104;;;1058:12;1075:6;:19;;1095:5;1075:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1057:44;;;1117:7;1109:16;;;;;;;;1028:104;;827:309;;;245:893;;1574:305:36;1652:57;1691:17;1652:38;;;;;:57;;:::i;:::-;1644:129;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1780:12;810:66;1795:19;;1780:34;;1851:17;1845:4;1838:31;1830:45;;;:::o;956:616:43:-;1016:4;1032:12;1531:7;1519:20;1511:28;;1564:1;1557:4;:8;1550:15;;;;;956:616;;;;;:::o;245:893:42:-;;;;;;;", "deployedSourceMap": "245:893:42:-:0;;;;;;;;;;;;514:50:39;548:11;:9;:11;;:::i;:::-;514:50;245:893:42;;459:51:39;494:11;:9;:11;;:::i;:::-;459:51;245:893:42;2075:90:39;2111:15;:13;:15;;:::i;:::-;2132:28;2142:17;:15;:17;;:::i;:::-;2132:9;:28;;:::i;:::-;2075:90;:::o;956:616:43:-;1016:4;1032:12;1531:7;1519:20;1511:28;;1564:1;1557:4;:8;1550:15;;;;;956:616;;;;;:::o;1933:47:39:-;;:::o;995:165:36:-;1054:12;1074;810:66;1089:19;;1074:34;;1145:4;1139:11;1131:19;;1123:33;;;:::o;981:743:39:-;1283:14;1280:1;1277;1264:34;1479:1;1476;1460:14;1457:1;1441:14;1434:5;1421:60;1543:16;1540:1;1537;1522:38;1575:6;1635:1;1630:38;;;;1695:16;1692:1;1685:27;1568:146;;1630:38;1649:16;1646:1;1639:27;1568:146;;1048:672;;;:::o", "abi": [ { "inputs": [ { "internalType": "address", "name": "_logic", "type": "address" }, { "internalType": "bytes", "name": "_data", "type": "bytes" } ], "stateMutability": "payable", "type": "constructor" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "implementation", "type": "address" } ], "name": "Upgraded", "type": "event" }, { "stateMutability": "payable", "type": "fallback" }, { "stateMutability": "payable", "type": "receive" } ], "ast": { "absolutePath": "contracts/upgradeability/UpgradeabilityProxy.sol", "exportedSymbols": { "UpgradeabilityProxy": [ 6753 ] }, "id": 6754, "license": "MIT", "nodeType": "SourceUnit", "nodes": [ { "id": 6702, "literals": [ "solidity", "^", "0.6", ".0" ], "nodeType": "PragmaDirective", "src": "0:23:42" }, { "absolutePath": "contracts/upgradeability/BaseUpgradeabilityProxy.sol", "file": "./BaseUpgradeabilityProxy.sol", "id": 6703, "nodeType": "ImportDirective", "scope": 6754, "sourceUnit": 6065, "src": "57:39:42", "symbolAliases": [], "unitAlias": "" }, { "abstract": false, "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 6705, "name": "BaseUpgradeabilityProxy", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 6064, "src": "277:23:42", "typeDescriptions": { "typeIdentifier": "t_contract$_BaseUpgradeabilityProxy_$6064", "typeString": "contract BaseUpgradeabilityProxy" } }, "id": 6706, "nodeType": "InheritanceSpecifier", "src": "277:23:42" } ], "contractDependencies": [ 6064, 6257 ], "contractKind": "contract", "documentation": { "id": 6704, "nodeType": "StructuredDocumentation", "src": "98:146:42", "text": " @title UpgradeabilityProxy\n @dev Extends BaseUpgradeabilityProxy with a constructor for initializing\n implementation and init data." }, "fullyImplemented": true, "id": 6753, "linearizedBaseContracts": [ 6753, 6064, 6257 ], "name": "UpgradeabilityProxy", "nodeType": "ContractDefinition", "nodes": [ { "body": { "id": 6751, "nodeType": "Block", "src": "890:246:42", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "id": 6727, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 6715, "name": "IMPLEMENTATION_SLOT", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6015, "src": "903:19:42", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 6725, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "656970313936372e70726f78792e696d706c656d656e746174696f6e", "id": 6721, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "952:30:42", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_stringliteral_360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd", "typeString": "literal_string \"eip1967.proxy.implementation\"" }, "value": "eip1967.proxy.implementation" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_stringliteral_360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd", "typeString": "literal_string \"eip1967.proxy.implementation\"" } ], "id": 6720, "name": "keccak256", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -8, "src": "942:9:42", "typeDescriptions": { "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", "typeString": "function (bytes memory) pure returns (bytes32)" } }, "id": 6722, "isConstant": false, "isLValue": false, "isPure": true, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "942:41:42", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } ], "id": 6719, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "934:7:42", "typeDescriptions": { "typeIdentifier": "t_type$_t_uint256_$", "typeString": "type(uint256)" }, "typeName": { "id": 6718, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "934:7:42", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 6723, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "934:50:42", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "-", "rightExpression": { "argumentTypes": null, "hexValue": "31", "id": 6724, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "987:1:42", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_1_by_1", "typeString": "int_const 1" }, "value": "1" }, "src": "934:54:42", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "id": 6717, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "926:7:42", "typeDescriptions": { "typeIdentifier": "t_type$_t_bytes32_$", "typeString": "type(bytes32)" }, "typeName": { "id": 6716, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "926:7:42", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 6726, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "926:63:42", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "src": "903:86:42", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" } ], "id": 6714, "name": "assert", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -3, "src": "896:6:42", "typeDescriptions": { "typeIdentifier": "t_function_assert_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" } }, "id": 6728, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "896:94:42", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 6729, "nodeType": "ExpressionStatement", "src": "896:94:42" }, { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 6731, "name": "_logic", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6709, "src": "1015:6:42", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 6730, "name": "_setImplementation", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6063, "src": "996:18:42", "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$_t_address_$returns$__$", "typeString": "function (address)" } }, "id": 6732, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "996:26:42", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 6733, "nodeType": "ExpressionStatement", "src": "996:26:42" }, { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 6737, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 6734, "name": "_data", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6711, "src": "1031:5:42", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } }, "id": 6735, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "length", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "1031:12:42", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": ">", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 6736, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1046:1:42", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "1031:16:42", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 6750, "nodeType": "IfStatement", "src": "1028:104:42", "trueBody": { "id": 6749, "nodeType": "Block", "src": "1049:83:42", "statements": [ { "assignments": [ 6739, null ], "declarations": [ { "constant": false, "id": 6739, "mutability": "mutable", "name": "success", "nodeType": "VariableDeclaration", "overrides": null, "scope": 6749, "src": "1058:12:42", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "typeName": { "id": 6738, "name": "bool", "nodeType": "ElementaryTypeName", "src": "1058:4:42", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "value": null, "visibility": "internal" }, null ], "id": 6744, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 6742, "name": "_data", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6711, "src": "1095:5:42", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } ], "expression": { "argumentTypes": null, "id": 6740, "name": "_logic", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6709, "src": "1075:6:42", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "id": 6741, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "delegatecall", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "1075:19:42", "typeDescriptions": { "typeIdentifier": "t_function_baredelegatecall_nonpayable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$", "typeString": "function (bytes memory) returns (bool,bytes memory)" } }, "id": 6743, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1075:26:42", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$_t_bool_$_t_bytes_memory_ptr_$", "typeString": "tuple(bool,bytes memory)" } }, "nodeType": "VariableDeclarationStatement", "src": "1057:44:42" }, { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 6746, "name": "success", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6739, "src": "1117:7:42", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" } ], "id": 6745, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ -18, -18 ], "referencedDeclaration": -18, "src": "1109:7:42", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" } }, "id": 6747, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1109:16:42", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 6748, "nodeType": "ExpressionStatement", "src": "1109:16:42" } ] } } ] }, "documentation": { "id": 6707, "nodeType": "StructuredDocumentation", "src": "305:519:42", "text": " @dev Contract constructor.\n @param _logic Address of the initial implementation.\n @param _data Data to send as msg.data to the implementation to initialize the proxied contract.\n It should include the signature and the parameters of the function to be called, as described in\n https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.\n This parameter is optional, if no data is given the initialization call to proxied contract will be skipped." }, "id": 6752, "implemented": true, "kind": "constructor", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 6712, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 6709, "mutability": "mutable", "name": "_logic", "nodeType": "VariableDeclaration", "overrides": null, "scope": 6752, "src": "839:14:42", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 6708, "name": "address", "nodeType": "ElementaryTypeName", "src": "839:7:42", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 6711, "mutability": "mutable", "name": "_data", "nodeType": "VariableDeclaration", "overrides": null, "scope": 6752, "src": "855:18:42", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes" }, "typeName": { "id": 6710, "name": "bytes", "nodeType": "ElementaryTypeName", "src": "855:5:42", "typeDescriptions": { "typeIdentifier": "t_bytes_storage_ptr", "typeString": "bytes" } }, "value": null, "visibility": "internal" } ], "src": "838:36:42" }, "returnParameters": { "id": 6713, "nodeType": "ParameterList", "parameters": [], "src": "890:0:42" }, "scope": 6753, "src": "827:309:42", "stateMutability": "payable", "virtual": false, "visibility": "public" } ], "scope": 6754, "src": "245:893:42" } ], "src": "0:1139:42" }, "bytecode": "0x608060405260405161045f38038061045f833981810160405260408110156100275760006000fd5b8101908080519060200190929190805160405193929190846401000000008211156100525760006000fd5b838201915060208201858111156100695760006000fd5b82518660018202830111640100000000821117156100875760006000fd5b8083526020830192505050908051906020019080838360005b838110156100bc5780820151818401525b6020810190506100a0565b50505050905090810190601f1680156100e95780820380516001836020036101000a031916815260200191505b506040526020015050505b600160405180807f656970313936372e70726f78792e696d706c656d656e746174696f6e00000000815260200150601c019050604051809103902060001c0360001b600019167f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b6000191614151561016b57fe5b61017a8261025460201b60201c565b60008151111561024c5760008273ffffffffffffffffffffffffffffffffffffffff16826040518082805190602001908083835b6020831015156101d457805182525b6020820191506020810190506020830392506101ae565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114610234576040519150601f19603f3d011682016040523d82523d6000602084013e610239565b606091505b5050905080151561024a5760006000fd5b505b5b5050610308565b610267816102ee60201b6100571760201c565b15156102be576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603b815260200180610424603b913960400191505060405180910390fd5b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b9050818155505b50565b60006000823b90506000811191505061030356505b919050565b61010d806103176000396000f3fe608060405260043610600c575b366020575b601d603063ffffffff16565b5b005b5b602d603063ffffffff16565b5b005b603c607063ffffffff16565b6054604a607363ffffffff16565b60a663ffffffff16565b5b565b60006000823b905060008111915050606b56505b919050565b5b565b600060007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b905080549150505b90565b36600060003760006000366000845af43d600060003e806000811460cc573d6000f360d1565b3d6000fd5b50505b5056fea2646970667358221220603be8d6e6555504e06c25b026b82621241c8d6d8c798438eb4aac3f39d7095d64736f6c634300060a003343616e6e6f742073657420612070726f787920696d706c656d656e746174696f6e20746f2061206e6f6e2d636f6e74726163742061646472657373", "deployedBytecode": "0x608060405260043610600c575b366020575b601d603063ffffffff16565b5b005b5b602d603063ffffffff16565b5b005b603c607063ffffffff16565b6054604a607363ffffffff16565b60a663ffffffff16565b5b565b60006000823b905060008111915050606b56505b919050565b5b565b600060007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b905080549150505b90565b36600060003760006000366000845af43d600060003e806000811460cc573d6000f360d1565b3d6000fd5b50505b5056fea2646970667358221220603be8d6e6555504e06c25b026b82621241c8d6d8c798438eb4aac3f39d7095d64736f6c634300060a0033", "compiler": { "name": "solc", "version": "0.6.10+commit.00c0fcaf.Emscripten.clang", "optimizer": {}, "evmVersion": "constantinople" } }