@daostack/upgrades
Version:
Proxy upgadable contracts based on openzeppelin-sdk
663 lines (662 loc) • 31.8 kB
JSON
{
"fileName": "ZosUpgradeabilityProxy.sol",
"contractName": "ZosUpgradeabilityProxy",
"source": "pragma solidity ^0.6.0;\n// SPDX-License-Identifier: MIT\n\nimport './ZosBaseUpgradeabilityProxy.sol';\n\n/**\n * @title UpgradeabilityProxy\n * @dev Extends BaseUpgradeabilityProxy with a constructor for initializing\n * implementation and init data.\n */\ncontract ZosUpgradeabilityProxy is ZosBaseUpgradeabilityProxy {\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 == keccak256(\"org.zeppelinos.proxy.implementation\"));\n _setImplementation(_logic);\n if(_data.length > 0) {\n (bool success,) = _logic.delegatecall(_data);\n require(success);\n }\n } \n}\n",
"sourcePath": "contracts/mocks/zos/ZosUpgradeabilityProxy.sol",
"sourceMap": "248:886:32:-:0;;;836:294;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;935:48;;;;;;;;;;;;;;;;;;;912:71;;;826:66:29;912:19:32;;:71;;;;905:79;;;;;;990:26;1009:6;990:18;;;:26;;:::i;:::-;1040:1;1025:5;:12;:16;1022:104;;;1052:12;1069:6;:19;;1089:5;1069:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1051:44;;;1111:7;1103:16;;;;;;;;1022:104;;836:294;;;248:886;;1590:305:29;1668:57;1707:17;1668:38;;;;;:57;;:::i;:::-;1660:129;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1796:12;826:66;1811:19;;1796:34;;1867:17;1861:4;1854:31;1846: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;248:886:32:-;;;;;;;",
"deployedSourceMap": "248:886:32:-:0;;;;;;;;;;;;514:50:39;548:11;:9;:11;;:::i;:::-;514:50;248:886:32;;459:51:39;494:11;:9;:11;;:::i;:::-;459:51;248:886:32;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;1011:165:29:-;1070:12;1090;826:66;1105:19;;1090:34;;1161:4;1155:11;1147:19;;1139: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/mocks/zos/ZosUpgradeabilityProxy.sol",
"exportedSymbols": {
"ZosUpgradeabilityProxy": [
5663
]
},
"id": 5664,
"license": "MIT",
"nodeType": "SourceUnit",
"nodes": [
{
"id": 5620,
"literals": [
"solidity",
"^",
"0.6",
".0"
],
"nodeType": "PragmaDirective",
"src": "0:23:32"
},
{
"absolutePath": "contracts/mocks/zos/ZosBaseUpgradeabilityProxy.sol",
"file": "./ZosBaseUpgradeabilityProxy.sol",
"id": 5621,
"nodeType": "ImportDirective",
"scope": 5664,
"sourceUnit": 5494,
"src": "57:42:32",
"symbolAliases": [],
"unitAlias": ""
},
{
"abstract": false,
"baseContracts": [
{
"arguments": null,
"baseName": {
"contractScope": null,
"id": 5623,
"name": "ZosBaseUpgradeabilityProxy",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 5493,
"src": "283:26:32",
"typeDescriptions": {
"typeIdentifier": "t_contract$_ZosBaseUpgradeabilityProxy_$5493",
"typeString": "contract ZosBaseUpgradeabilityProxy"
}
},
"id": 5624,
"nodeType": "InheritanceSpecifier",
"src": "283:26:32"
}
],
"contractDependencies": [
5493,
6257
],
"contractKind": "contract",
"documentation": {
"id": 5622,
"nodeType": "StructuredDocumentation",
"src": "101:146:32",
"text": " @title UpgradeabilityProxy\n @dev Extends BaseUpgradeabilityProxy with a constructor for initializing\n implementation and init data."
},
"fullyImplemented": true,
"id": 5663,
"linearizedBaseContracts": [
5663,
5493,
6257
],
"name": "ZosUpgradeabilityProxy",
"nodeType": "ContractDefinition",
"nodes": [
{
"body": {
"id": 5661,
"nodeType": "Block",
"src": "899:231:32",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"id": 5637,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 5633,
"name": "IMPLEMENTATION_SLOT",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5444,
"src": "912:19:32",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "6f72672e7a657070656c696e6f732e70726f78792e696d706c656d656e746174696f6e",
"id": 5635,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "945:37:32",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3",
"typeString": "literal_string \"org.zeppelinos.proxy.implementation\""
},
"value": "org.zeppelinos.proxy.implementation"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_stringliteral_7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3",
"typeString": "literal_string \"org.zeppelinos.proxy.implementation\""
}
],
"id": 5634,
"name": "keccak256",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": -8,
"src": "935:9:32",
"typeDescriptions": {
"typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$",
"typeString": "function (bytes memory) pure returns (bytes32)"
}
},
"id": 5636,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "935:48:32",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"src": "912:71:32",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
}
],
"id": 5632,
"name": "assert",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": -3,
"src": "905:6:32",
"typeDescriptions": {
"typeIdentifier": "t_function_assert_pure$_t_bool_$returns$__$",
"typeString": "function (bool) pure"
}
},
"id": 5638,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "905:79:32",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 5639,
"nodeType": "ExpressionStatement",
"src": "905:79:32"
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 5641,
"name": "_logic",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5627,
"src": "1009:6:32",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"id": 5640,
"name": "_setImplementation",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5492,
"src": "990:18:32",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_nonpayable$_t_address_$returns$__$",
"typeString": "function (address)"
}
},
"id": 5642,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "990:26:32",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 5643,
"nodeType": "ExpressionStatement",
"src": "990:26:32"
},
{
"condition": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 5647,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 5644,
"name": "_data",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5629,
"src": "1025:5:32",
"typeDescriptions": {
"typeIdentifier": "t_bytes_memory_ptr",
"typeString": "bytes memory"
}
},
"id": 5645,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "length",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "1025:12:32",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": ">",
"rightExpression": {
"argumentTypes": null,
"hexValue": "30",
"id": 5646,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1040:1:32",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"src": "1025:16:32",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": null,
"id": 5660,
"nodeType": "IfStatement",
"src": "1022:104:32",
"trueBody": {
"id": 5659,
"nodeType": "Block",
"src": "1043:83:32",
"statements": [
{
"assignments": [
5649,
null
],
"declarations": [
{
"constant": false,
"id": 5649,
"mutability": "mutable",
"name": "success",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5659,
"src": "1052:12:32",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 5648,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "1052:4:32",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"value": null,
"visibility": "internal"
},
null
],
"id": 5654,
"initialValue": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 5652,
"name": "_data",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5629,
"src": "1089:5:32",
"typeDescriptions": {
"typeIdentifier": "t_bytes_memory_ptr",
"typeString": "bytes memory"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bytes_memory_ptr",
"typeString": "bytes memory"
}
],
"expression": {
"argumentTypes": null,
"id": 5650,
"name": "_logic",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5627,
"src": "1069:6:32",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"id": 5651,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "delegatecall",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "1069:19:32",
"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": 5653,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1069:26:32",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_tuple$_t_bool_$_t_bytes_memory_ptr_$",
"typeString": "tuple(bool,bytes memory)"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "1051:44:32"
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 5656,
"name": "success",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 5649,
"src": "1111:7:32",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
}
],
"id": 5655,
"name": "require",
"nodeType": "Identifier",
"overloadedDeclarations": [
-18,
-18
],
"referencedDeclaration": -18,
"src": "1103:7:32",
"typeDescriptions": {
"typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$",
"typeString": "function (bool) pure"
}
},
"id": 5657,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1103:16:32",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 5658,
"nodeType": "ExpressionStatement",
"src": "1103:16:32"
}
]
}
}
]
},
"documentation": {
"id": 5625,
"nodeType": "StructuredDocumentation",
"src": "314:519:32",
"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": 5662,
"implemented": true,
"kind": "constructor",
"modifiers": [],
"name": "",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 5630,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 5627,
"mutability": "mutable",
"name": "_logic",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5662,
"src": "848:14:32",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 5626,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "848:7:32",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 5629,
"mutability": "mutable",
"name": "_data",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5662,
"src": "864:18:32",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_bytes_memory_ptr",
"typeString": "bytes"
},
"typeName": {
"id": 5628,
"name": "bytes",
"nodeType": "ElementaryTypeName",
"src": "864:5:32",
"typeDescriptions": {
"typeIdentifier": "t_bytes_storage_ptr",
"typeString": "bytes"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "847:36:32"
},
"returnParameters": {
"id": 5631,
"nodeType": "ParameterList",
"parameters": [],
"src": "899:0:32"
},
"scope": 5663,
"src": "836:294:32",
"stateMutability": "payable",
"virtual": false,
"visibility": "public"
}
],
"scope": 5664,
"src": "248:886:32"
}
],
"src": "0:1135:32"
},
"bytecode": "0x6080604052604051610459380380610459833981810160405260408110156100275760006000fd5b8101908080519060200190929190805160405193929190846401000000008211156100525760006000fd5b838201915060208201858111156100695760006000fd5b82518660018202830111640100000000821117156100875760006000fd5b8083526020830192505050908051906020019080838360005b838110156100bc5780820151818401525b6020810190506100a0565b50505050905090810190601f1680156100e95780820380516001836020036101000a031916815260200191505b506040526020015050505b60405180806103fb6023913960230190506040518091039020600019167f7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c360001b6000191614151561014257fe5b6101518261022b60201b60201c565b6000815111156102235760008273ffffffffffffffffffffffffffffffffffffffff16826040518082805190602001908083835b6020831015156101ab57805182525b602082019150602081019050602083039250610185565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461020b576040519150601f19603f3d011682016040523d82523d6000602084013e610210565b606091505b505090508015156102215760006000fd5b505b5b50506102df565b61023e816102c560201b6100571760201c565b1515610295576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603b81526020018061041e603b913960400191505060405180910390fd5b60007f7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c360001b9050818155505b50565b60006000823b9050600081119150506102da56505b919050565b61010d806102ee6000396000f3fe608060405260043610600c575b366020575b601d603063ffffffff16565b5b005b5b602d603063ffffffff16565b5b005b603c607063ffffffff16565b6054604a607363ffffffff16565b60a663ffffffff16565b5b565b60006000823b905060008111915050606b56505b919050565b5b565b600060007f7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c360001b905080549150505b90565b36600060003760006000366000845af43d600060003e806000811460cc573d6000f360d1565b3d6000fd5b50505b5056fea2646970667358221220a90f70baa9f805b973e4ebcffb5aae67b0c48091e0361fe45f23a90f490156e164736f6c634300060a00336f72672e7a657070656c696e6f732e70726f78792e696d706c656d656e746174696f6e43616e6e6f742073657420612070726f787920696d706c656d656e746174696f6e20746f2061206e6f6e2d636f6e74726163742061646472657373",
"deployedBytecode": "0x608060405260043610600c575b366020575b601d603063ffffffff16565b5b005b5b602d603063ffffffff16565b5b005b603c607063ffffffff16565b6054604a607363ffffffff16565b60a663ffffffff16565b5b565b60006000823b905060008111915050606b56505b919050565b5b565b600060007f7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c360001b905080549150505b90565b36600060003760006000366000845af43d600060003e806000811460cc573d6000f360d1565b3d6000fd5b50505b5056fea2646970667358221220a90f70baa9f805b973e4ebcffb5aae67b0c48091e0361fe45f23a90f490156e164736f6c634300060a0033",
"compiler": {
"name": "solc",
"version": "0.6.10+commit.00c0fcaf.Emscripten.clang",
"optimizer": {},
"evmVersion": "constantinople"
}
}