@daostack/upgrades
Version:
Proxy upgadable contracts based on openzeppelin-sdk
1,098 lines • 243 kB
JSON
{
"fileName": "Package.sol",
"contractName": "Package",
"source": "pragma solidity ^0.6.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../ownership/Ownable.sol\";\n\n/**\n * @title Package\n * @dev A package is composed by a set of versions, identified via semantic versioning,\n * where each version has a contract address that refers to a reusable implementation,\n * plus an optional content URI with metadata. Note that the semver identifier is restricted\n * to major, minor, and patch, as prerelease tags are not supported.\n */\ncontract Package is OpenZeppelinUpgradesOwnable {\n /**\n * @dev Emitted when a version is added to the package.\n * @param semanticVersion Name of the added version.\n * @param contractAddress Contract associated with the version.\n * @param contentURI Optional content URI with metadata of the version.\n */\n event VersionAdded(uint64[3] semanticVersion, address contractAddress, bytes contentURI);\n\n struct Version {\n uint64[3] semanticVersion;\n address contractAddress;\n bytes contentURI;\n }\n\n mapping (bytes32 => Version) internal versions;\n mapping (uint64 => bytes32) internal majorToLatestVersion;\n uint64 internal latestMajor;\n\n /**\n * @dev Returns a version given its semver identifier.\n * @param semanticVersion Semver identifier of the version.\n * @return contractAddress - Contract address and content URI for the version, or zero if not exists.\n */\n function getVersion(uint64[3] memory semanticVersion) public view returns (address contractAddress, bytes memory contentURI) {\n Version storage version = versions[semanticVersionHash(semanticVersion)];\n return (version.contractAddress, version.contentURI);\n }\n\n /**\n * @dev Returns a contract for a version given its semver identifier.\n * This method is equivalent to `getVersion`, but returns only the contract address.\n * @param semanticVersion Semver identifier of the version.\n * @return contractAddress - Contract address for the version, or zero if not exists.\n */\n function getContract(uint64[3] memory semanticVersion) public view returns (address contractAddress) {\n Version storage version = versions[semanticVersionHash(semanticVersion)];\n return version.contractAddress;\n }\n\n /**\n * @dev Adds a new version to the package. Only the Owner can add new versions.\n * Reverts if the specified semver identifier already exists.\n * Emits a `VersionAdded` event if successful.\n * @param semanticVersion Semver identifier of the version.\n * @param contractAddress Contract address for the version, must be non-zero.\n * @param contentURI Optional content URI for the version.\n */\n function addVersion(uint64[3] memory semanticVersion, address contractAddress, bytes memory contentURI) public onlyOwner {\n require(contractAddress != address(0), \"Contract address is required\");\n require(!hasVersion(semanticVersion), \"Given version is already registered in package\");\n require(!semanticVersionIsZero(semanticVersion), \"Version must be non zero\");\n\n // Register version\n bytes32 versionId = semanticVersionHash(semanticVersion);\n versions[versionId] = Version(semanticVersion, contractAddress, contentURI);\n\n // Update latest major\n uint64 major = semanticVersion[0];\n if (major > latestMajor) {\n latestMajor = semanticVersion[0];\n }\n\n // Update latest version for this major\n uint64 minor = semanticVersion[1];\n uint64 patch = semanticVersion[2];\n uint64[3] storage latestVersionForMajor = versions[majorToLatestVersion[major]].semanticVersion;\n if (semanticVersionIsZero(latestVersionForMajor) // No latest was set for this major\n || (minor > latestVersionForMajor[1]) // Or current minor is greater\n || (minor == latestVersionForMajor[1] && patch > latestVersionForMajor[2]) // Or current patch is greater\n ) {\n majorToLatestVersion[major] = versionId;\n }\n\n emit VersionAdded(semanticVersion, contractAddress, contentURI);\n }\n\n /**\n * @dev Checks whether a version is present in the package.\n * @param semanticVersion Semver identifier of the version.\n * @return true if the version is registered in this package, false otherwise.\n */\n function hasVersion(uint64[3] memory semanticVersion) public view returns (bool) {\n Version storage version = versions[semanticVersionHash(semanticVersion)];\n return address(version.contractAddress) != address(0);\n }\n\n /**\n * @dev Returns the version with the highest semver identifier registered in the package.\n * For instance, if `1.2.0`, `1.3.0`, and `2.0.0` are present, will always return `2.0.0`, regardless\n * of the order in which they were registered. Returns zero if no versions are registered.\n * @return semanticVersion Semver identifier, contract address,\n * and content URI for the version, or zero if not exists.\n */\n function getLatest() public view returns (uint64[3] memory semanticVersion, address contractAddress, bytes memory contentURI) {\n return getLatestByMajor(latestMajor);\n }\n\n /**\n * @dev Returns the version with the highest semver identifier for the given major.\n * For instance, if `1.2.0`, `1.3.0`, and `2.0.0` are present, will return `1.3.0` for major `1`,\n * regardless of the order in which they were registered. Returns zero if no versions are registered\n * for the specified major.\n * @param major Major identifier to query\n * @return semanticVersion - Semver identifier, contract address,\n * and content URI for the version, or zero if not exists.\n */\n function getLatestByMajor(uint64 major) public view returns (uint64[3] memory semanticVersion, address contractAddress, bytes memory contentURI) {\n Version storage version = versions[majorToLatestVersion[major]];\n return (version.semanticVersion, version.contractAddress, version.contentURI);\n }\n\n function semanticVersionHash(uint64[3] memory version) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(version[0], version[1], version[2]));\n }\n\n function semanticVersionIsZero(uint64[3] memory version) internal pure returns (bool) {\n return version[0] == 0 && version[1] == 0 && version[2] == 0;\n }\n}\n",
"sourcePath": "contracts/application/Package.sol",
"sourceMap": "456:5638:4:-:0;;;;;;;;;;;;;978:115:33;1021:10;1012:6;;:19;;;;;;;;;;;;;;;;;;1079:6;;;;;;;;;;;1046:40;;1075:1;1046:40;;;;;;;;;;;;978:115;456:5638:4;;;;;;;;;",
"deployedSourceMap": "456:5638:4:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1941:220;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;4121:223;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;1844:137:33;;;:::i;:::-;;1156:77;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;1476:90;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;5457:302:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4776:173;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2575:1325;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;1350:266;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2152:107:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;1941:220:4;2017:23;2048;2074:8;;;:46;2083:36;2103:15;2083:19;:36;;:::i;:::-;2074:46;;;;;;;;;;;;;;;;;;;2048:72;;2133:7;:23;;;;;;;;;;;;2126:30;;;;;1941:220;;;;;:::o;4121:223::-;4196:4;4208:23;4234:8;;;:46;4243:36;4263:15;4243:19;:36;;:::i;:::-;4234:46;;;;;;;;;;;;;;;;;;;4208:72;;4337:1;4293:46;;4301:7;:23;;;;;;;;;;;;4293:46;;;;4286:53;;;;;4121:223;;;;;:::o;1844:137:33:-;1360:9;:7;:9;;:::i;:::-;1352:18;;;;;;;;1942:1:::1;1905:40;;1926:6;;;;;;;;;;;1905:40;;;;;;;;;;;;1972:1;1955:6;;:19;;;;;;;;;;;;;;;;;;1380:1;1844:137:::0;:::o;1156:77::-;1194:7;1220:6;;;;;;;;;;;1213:13;;;;1156:77;;:::o;1476:90::-;1516:4;1553:6;;;;;;;;;;;1539:20;;:10;:20;;;1532:27;;;;1476:90;;:::o;5457:302:4:-;5518:32;;:::i;:::-;5552:23;5577;5608;5634:8;;;:37;5643:20;;;:27;5664:5;5643:27;;;;;;;;;;;;;;;;;;5634:37;;;;;;;;;;;;;;;;;;;5608:63;;5685:7;:23;;;;5710:7;:23;;;;;;;;;;;;5735:7;:18;;;;5677:77;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5457:302;;;;;;;:::o;4776:173::-;4818:32;;:::i;:::-;4852:23;4877;4915:29;4932:11;;;;;;;;;;;4915:16;:29;;:::i;:::-;4908:36;;;;;;;;4776:173;;;;:::o;2575:1325::-;1360:9:33;:7;:9;;:::i;:::-;1352:18;;;;;;;;2737:1:4::1;2710:29;;:15;:29;;;;2702:70;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2787:27;2798:15;2787:10;:27;;:::i;:::-;2786:28;2778:87;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2880:38;2902:15;2880:21;:38;;:::i;:::-;2879:39;2871:76;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2978:17;2998:36;3018:15;2998:19;:36;;:::i;:::-;2978:56;;3062:53;;;;;;;;3070:15;3062:53;;;;3087:15;3062:53;;;;;;3104:10;3062:53;;;;;3040:8;;;:19;3049:9;3040:19;;;;;;;;;;;;;;;;;;:75;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;3149:12;3164:15;3180:1;3164:18;;;;;;;;;;;;;3149:33;;3200:11;;;;;;;;;;;3192:19;;:5;:19;;;3188:72;;;3235:15;3251:1;3235:18;;;;;;;;;;;;;3221:11;;:32;;;;;;;;;;;;;;;;;;3188:72;3310:12;3325:15;3341:1;3325:18;;;;;;;;;;;;;3310:33;;3349:12;3364:15;3380:1;3364:18;;;;;;;;;;;;;3349:33;;3388:39;3430:8;;;:37;3439:20;;;:27;3460:5;3439:27;;;;;;;;;;;;;;;;;;3430:37;;;;;;;;;;;;;;;;;;;:53;;;;3388:95;;3493:44;3515:21;3493:44;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:21;:44;;:::i;:::-;:125;;;;3593:21;3615:1;3593:24;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3585:32;;:5;:32;;;3493:125;:238;;;;3670:21;3692:1;3670:24;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3661:33;;:5;:33;;;:69;;;;;3706:21;3728:1;3706:24;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3698:32;;:5;:32;;;3661:69;3493:238;3489:337;;;3810:9;3780:20;;;:27;3801:5;3780:27;;;;;;;;;;;;;;;;:39;;;;;;;;;;3489:337;3837:58;3850:15;3867;3884:10;3837:58;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1380:1:33;;;;;;2575:1325:4::0;;;;:::o;1350:266::-;1425:23;1450;1481;1507:8;;;:46;1516:36;1536:15;1516:19;:36;;:::i;:::-;1507:46;;;;;;;;;;;;;;;;;;;1481:72;;1567:7;:23;;;;;;;;;;;;1592:7;:18;;;;1559:52;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1350:266;;;;;:::o;2152:107:33:-;1360:9;:7;:9;;:::i;:::-;1352:18;;;;;;;;2224:28:::1;2243:8;2224:18;:28;;:::i;:::-;1380:1;2152:107:::0;;:::o;5763:168:4:-;5841:7;5890;5898:1;5890:10;;;;;;;;;;;;;5902:7;5910:1;5902:10;;;;;;;;;;;;;5914:7;5922:1;5914:10;;;;;;;;;;;;;5873:52;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5863:63;;;;;;5856:70;;;;5763:168;;;;:::o;5935:157::-;6015:4;6048:1;6034:7;6042:1;6034:10;;;;;;;;;;;;;:15;;;:34;;;;;6067:1;6053:7;6061:1;6053:10;;;;;;;;;;;;;:15;;;6034:34;:53;;;;;6086:1;6072:7;6080:1;6072:10;;;;;;;;;;;;;:15;;;6034:53;6027:60;;;;5935:157;;;;:::o;2403:183:33:-;2496:1;2476:22;;:8;:22;;;;2468:31;;;;;;;;2543:8;2514:38;;2535:6;;;;;;;;;;;2514:38;;;;;;;;;;;;2571:8;2562:6;;:17;;;;;;;;;;;;;;;;;;2403:183;;:::o;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint64[3]",
"name": "semanticVersion",
"type": "uint64[3]"
},
{
"indexed": false,
"internalType": "address",
"name": "contractAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes",
"name": "contentURI",
"type": "bytes"
}
],
"name": "VersionAdded",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint64[3]",
"name": "semanticVersion",
"type": "uint64[3]"
},
{
"internalType": "address",
"name": "contractAddress",
"type": "address"
},
{
"internalType": "bytes",
"name": "contentURI",
"type": "bytes"
}
],
"name": "addVersion",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint64[3]",
"name": "semanticVersion",
"type": "uint64[3]"
}
],
"name": "getContract",
"outputs": [
{
"internalType": "address",
"name": "contractAddress",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getLatest",
"outputs": [
{
"internalType": "uint64[3]",
"name": "semanticVersion",
"type": "uint64[3]"
},
{
"internalType": "address",
"name": "contractAddress",
"type": "address"
},
{
"internalType": "bytes",
"name": "contentURI",
"type": "bytes"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint64",
"name": "major",
"type": "uint64"
}
],
"name": "getLatestByMajor",
"outputs": [
{
"internalType": "uint64[3]",
"name": "semanticVersion",
"type": "uint64[3]"
},
{
"internalType": "address",
"name": "contractAddress",
"type": "address"
},
{
"internalType": "bytes",
"name": "contentURI",
"type": "bytes"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint64[3]",
"name": "semanticVersion",
"type": "uint64[3]"
}
],
"name": "getVersion",
"outputs": [
{
"internalType": "address",
"name": "contractAddress",
"type": "address"
},
{
"internalType": "bytes",
"name": "contentURI",
"type": "bytes"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint64[3]",
"name": "semanticVersion",
"type": "uint64[3]"
}
],
"name": "hasVersion",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "isOwner",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"ast": {
"absolutePath": "contracts/application/Package.sol",
"exportedSymbols": {
"Package": [
849
]
},
"id": 850,
"license": "MIT",
"nodeType": "SourceUnit",
"nodes": [
{
"id": 498,
"literals": [
"solidity",
"^",
"0.6",
".0"
],
"nodeType": "PragmaDirective",
"src": "0:23:4"
},
{
"absolutePath": "contracts/ownership/Ownable.sol",
"file": "../ownership/Ownable.sol",
"id": 499,
"nodeType": "ImportDirective",
"scope": 850,
"sourceUnit": 5785,
"src": "57:34:4",
"symbolAliases": [],
"unitAlias": ""
},
{
"abstract": false,
"baseContracts": [
{
"arguments": null,
"baseName": {
"contractScope": null,
"id": 501,
"name": "OpenZeppelinUpgradesOwnable",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 5784,
"src": "476:27:4",
"typeDescriptions": {
"typeIdentifier": "t_contract$_OpenZeppelinUpgradesOwnable_$5784",
"typeString": "contract OpenZeppelinUpgradesOwnable"
}
},
"id": 502,
"nodeType": "InheritanceSpecifier",
"src": "476:27:4"
}
],
"contractDependencies": [
5784
],
"contractKind": "contract",
"documentation": {
"id": 500,
"nodeType": "StructuredDocumentation",
"src": "93:362:4",
"text": " @title Package\n @dev A package is composed by a set of versions, identified via semantic versioning,\n where each version has a contract address that refers to a reusable implementation,\n plus an optional content URI with metadata. Note that the semver identifier is restricted\n to major, minor, and patch, as prerelease tags are not supported."
},
"fullyImplemented": true,
"id": 849,
"linearizedBaseContracts": [
849,
5784
],
"name": "Package",
"nodeType": "ContractDefinition",
"nodes": [
{
"anonymous": false,
"documentation": {
"id": 503,
"nodeType": "StructuredDocumentation",
"src": "508:262:4",
"text": " @dev Emitted when a version is added to the package.\n @param semanticVersion Name of the added version.\n @param contractAddress Contract associated with the version.\n @param contentURI Optional content URI with metadata of the version."
},
"id": 513,
"name": "VersionAdded",
"nodeType": "EventDefinition",
"parameters": {
"id": 512,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 507,
"indexed": false,
"mutability": "mutable",
"name": "semanticVersion",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 513,
"src": "792:25:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint64_$3_memory_ptr",
"typeString": "uint64[3]"
},
"typeName": {
"baseType": {
"id": 504,
"name": "uint64",
"nodeType": "ElementaryTypeName",
"src": "792:6:4",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
}
},
"id": 506,
"length": {
"argumentTypes": null,
"hexValue": "33",
"id": 505,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "799:1:4",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_3_by_1",
"typeString": "int_const 3"
},
"value": "3"
},
"nodeType": "ArrayTypeName",
"src": "792:9:4",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint64_$3_storage_ptr",
"typeString": "uint64[3]"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 509,
"indexed": false,
"mutability": "mutable",
"name": "contractAddress",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 513,
"src": "819:23:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 508,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "819:7:4",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 511,
"indexed": false,
"mutability": "mutable",
"name": "contentURI",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 513,
"src": "844:16:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes_memory_ptr",
"typeString": "bytes"
},
"typeName": {
"id": 510,
"name": "bytes",
"nodeType": "ElementaryTypeName",
"src": "844:5:4",
"typeDescriptions": {
"typeIdentifier": "t_bytes_storage_ptr",
"typeString": "bytes"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "791:70:4"
},
"src": "773:89:4"
},
{
"canonicalName": "Package.Version",
"id": 522,
"members": [
{
"constant": false,
"id": 517,
"mutability": "mutable",
"name": "semanticVersion",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 522,
"src": "887:25:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint64_$3_storage_ptr",
"typeString": "uint64[3]"
},
"typeName": {
"baseType": {
"id": 514,
"name": "uint64",
"nodeType": "ElementaryTypeName",
"src": "887:6:4",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
}
},
"id": 516,
"length": {
"argumentTypes": null,
"hexValue": "33",
"id": 515,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "894:1:4",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_3_by_1",
"typeString": "int_const 3"
},
"value": "3"
},
"nodeType": "ArrayTypeName",
"src": "887:9:4",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint64_$3_storage_ptr",
"typeString": "uint64[3]"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 519,
"mutability": "mutable",
"name": "contractAddress",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 522,
"src": "918:23:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 518,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "918:7:4",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 521,
"mutability": "mutable",
"name": "contentURI",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 522,
"src": "947:16:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes_storage_ptr",
"typeString": "bytes"
},
"typeName": {
"id": 520,
"name": "bytes",
"nodeType": "ElementaryTypeName",
"src": "947:5:4",
"typeDescriptions": {
"typeIdentifier": "t_bytes_storage_ptr",
"typeString": "bytes"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "Version",
"nodeType": "StructDefinition",
"scope": 849,
"src": "866:102:4",
"visibility": "public"
},
{
"constant": false,
"id": 526,
"mutability": "mutable",
"name": "versions",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 849,
"src": "972:46:4",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_bytes32_$_t_struct$_Version_$522_storage_$",
"typeString": "mapping(bytes32 => struct Package.Version)"
},
"typeName": {
"id": 525,
"keyType": {
"id": 523,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "981:7:4",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"nodeType": "Mapping",
"src": "972:28:4",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_bytes32_$_t_struct$_Version_$522_storage_$",
"typeString": "mapping(bytes32 => struct Package.Version)"
},
"valueType": {
"contractScope": null,
"id": 524,
"name": "Version",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 522,
"src": "992:7:4",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$522_storage_ptr",
"typeString": "struct Package.Version"
}
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 530,
"mutability": "mutable",
"name": "majorToLatestVersion",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 849,
"src": "1022:57:4",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_uint64_$_t_bytes32_$",
"typeString": "mapping(uint64 => bytes32)"
},
"typeName": {
"id": 529,
"keyType": {
"id": 527,
"name": "uint64",
"nodeType": "ElementaryTypeName",
"src": "1031:6:4",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
}
},
"nodeType": "Mapping",
"src": "1022:27:4",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_uint64_$_t_bytes32_$",
"typeString": "mapping(uint64 => bytes32)"
},
"valueType": {
"id": 528,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "1041:7:4",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 532,
"mutability": "mutable",
"name": "latestMajor",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 849,
"src": "1083:27:4",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
},
"typeName": {
"id": 531,
"name": "uint64",
"nodeType": "ElementaryTypeName",
"src": "1083:6:4",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
}
},
"value": null,
"visibility": "internal"
},
{
"body": {
"id": 558,
"nodeType": "Block",
"src": "1475:141:4",
"statements": [
{
"assignments": [
545
],
"declarations": [
{
"constant": false,
"id": 545,
"mutability": "mutable",
"name": "version",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 558,
"src": "1481:23:4",
"stateVariable": false,
"storageLocation": "storage",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$522_storage_ptr",
"typeString": "struct Package.Version"
},
"typeName": {
"contractScope": null,
"id": 544,
"name": "Version",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 522,
"src": "1481:7:4",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$522_storage_ptr",
"typeString": "struct Package.Version"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 551,
"initialValue": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"id": 546,
"name": "versions",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 526,
"src": "1507:8:4",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_bytes32_$_t_struct$_Version_$522_storage_$",
"typeString": "mapping(bytes32 => struct Package.Version storage ref)"
}
},
"id": 550,
"indexExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 548,
"name": "semanticVersion",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 537,
"src": "1536:15:4",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint64_$3_memory_ptr",
"typeString": "uint64[3] memory"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_array$_t_uint64_$3_memory_ptr",
"typeString": "uint64[3] memory"
}
],
"id": 547,
"name": "semanticVersionHash",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 820,
"src": "1516:19:4",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_array$_t_uint64_$3_memory_ptr_$returns$_t_bytes32_$",
"typeString": "function (uint64[3] memory) pure returns (bytes32)"
}
},
"id": 549,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1516:36:4",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"nodeType": "IndexAccess",
"src": "1507:46:4",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$522_storage",
"typeString": "struct Package.Version storage ref"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "1481:72:4"
},
{
"expression": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 552,
"name": "version",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 545,
"src": "1567:7:4",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$522_storage_ptr",
"typeString": "struct Package.Version storage pointer"
}
},
"id": 553,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "contractAddress",
"nodeType": "MemberAccess",
"referencedDeclaration": 519,
"src": "1567:23:4",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 554,
"name": "version",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 545,
"src": "1592:7:4",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$522_storage_ptr",
"typeString": "struct Package.Version storage pointer"
}
},
"id": 555,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "contentURI",
"nodeType": "MemberAccess",
"referencedDeclaration": 521,
"src": "1592:18:4",
"typeDescriptions": {
"typeIdentifier": "t_bytes_storage",
"typeString": "bytes storage ref"
}
}
],
"id": 556,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "1566:45:4",
"typeDescriptions": {
"typeIdentifier": "t_tuple$_t_address_$_t_bytes_storage_$",
"typeString": "tuple(address,bytes storage ref)"
}
},
"functionReturnParameters": 543,
"id": 557,
"nodeType": "Return",
"src": "1559:52:4"
}
]
},
"documentation": {
"id": 533,
"nodeType": "StructuredDocumentation",
"src": "1115:232:4",
"text": " @dev Returns a version given its semver identifier.\n @param semanticVersion Semver identifier of the version.\n @return contractAddress - Contract address and content URI for the version, or zero if not exists."
},
"functionSelector": "e30329e9",
"id": 559,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "getVersion",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 538,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 537,
"mutability": "mutable",
"name": "semanticVersion",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 559,
"src": "1370:32:4",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint64_$3_memory_ptr",
"typeString": "uint64[3]"
},
"typeName": {
"baseType": {
"id": 534,
"name": "uint64",
"nodeType": "ElementaryTypeName",
"src": "1370:6:4",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
}
},
"id": 536,
"length": {
"argumentTypes": null,
"hexValue": "33",
"id": 535,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1377:1:4",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_3_by_1",
"typeString": "int_const 3"
},
"value": "3"
},
"nodeType": "ArrayTypeName",
"src": "1370:9:4",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint64_$3_storage_ptr",
"typeString": "uint64[3]"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1369:34:4"
},
"returnParameters": {
"id": 543,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 540,
"mutability": "mutable",
"name": "contractAddress",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 559,
"src": "1425:23:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 539,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1425:7:4",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 542,
"mutability": "mutable",
"name": "contentURI",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 559,
"src": "1450:23:4",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_bytes_memory_ptr",
"typeString": "bytes"
},
"typeName": {
"id": 541,
"name": "bytes",
"nodeType": "ElementaryTypeName",
"src": "1450:5:4",
"typeDescriptions": {
"typeIdentifier": "t_bytes_storage_ptr",
"typeString": "bytes"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1424:50:4"
},
"scope": 849,
"src": "1350:266:4",
"stateMutability": "view",
"virtual": false,
"visibility": "public"
},
{
"body": {
"id": 580,
"nodeType": "Block",
"src": "2042:119:4",
"statements": [
{
"assignments": [
570
],
"declarations": [
{
"constant": false,
"id": 570,
"mutability": "mutable",
"name": "version",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 580,
"src": "2048:23:4",
"stateVariable": false,
"storageLocation": "storage",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$522_storage_ptr",
"typeString": "struct Package.Version"
},
"typeName": {
"contractScope": null,
"id": 569,
"name": "Version",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 522,
"src": "2048:7:4",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$522_storage_ptr",
"typeString": "struct Package.Version"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 576,
"initialValue": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"id": 571,
"name": "versions",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 526,
"src": "2074:8:4",
"type