@openzeppelin/upgrades
Version:
JavaScript library for the OpenZeppelin smart contract platform
1,061 lines (1,060 loc) • 235 kB
JSON
{
"fileName": "Package.sol",
"contractName": "Package",
"source": "pragma solidity ^0.5.0;\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 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 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 Semver identifier, contract address, 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 Semver identifier, contract address, 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": "424:5570:4:-;;;989:10:33;980:6;;:19;;;;;;;;;;;;;;;;;;1047:6;;;;;;;;;;;1014:40;;1043:1;1014:40;;;;;;;;;;;;424:5570:4;;;;;;",
"deployedSourceMap": "424:5570:4:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;424:5570:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1875:220;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1875:220:4;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;93:3;85:6;81:16;74:27;137:4;133:9;126:4;121:3;117:14;113:30;106:37;;169:3;161:6;157:16;147:26;;1875:220:4;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;4062:223;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;4062:223:4;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;93:3;85:6;81:16;74:27;137:4;133:9;126:4;121:3;117:14;113:30;106:37;;169:3;161:6;157:16;147:26;;4062:223:4;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;1812:137:33;;;:::i;:::-;;1124:77;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;1444:90;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;5356:303:4;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;5356:303:4;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;5356:303:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;5356:303:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4697:173;;;:::i;:::-;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;4697:173:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;4697:173:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2510:1331;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;2510:1331:4;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;93:3;85:6;81:16;74:27;137:4;133:9;126:4;121:3;117:14;113:30;106:37;;169:3;161:6;157:16;147:26;;2510:1331:4;;;;;;;;;;;;;;;;;;;;;;;;;;;21:11:-1;8;5:28;2:2;;;46:1;43;36:12;2:2;2510:1331:4;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;2510:1331:4;;;;;;100:9:-1;95:1;81:12;77:20;67:8;63:35;60:50;39:11;25:12;22:29;11:107;8:2;;;131:1;128;121:12;8:2;2510:1331:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;93:3;85:6;81:16;74:27;137:4;133:9;126:4;121:3;117:14;113:30;106:37;;169:3;161:6;157:16;147:26;;2510:1331:4;;;;;;;;;;;;;;;:::i;:::-;;1301:267;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1301:267:4;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;93:3;85:6;81:16;74:27;137:4;133:9;126:4;121:3;117:14;113:30;106:37;;169:3;161:6;157:16;147:26;;1301:267:4;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;1301:267:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2120:107:33;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;2120:107:33;;;;;;;;;;;;;;;;;;;:::i;:::-;;1875:220:4;1951:23;1982;2008:8;:46;2017:36;2037:15;2017:19;:36::i;:::-;2008:46;;;;;;;;;;;1982:72;;2067:7;:23;;;;;;;;;;;;2060:30;;;1875:220;;;:::o;4062:223::-;4137:4;4149:23;4175:8;:46;4184:36;4204:15;4184:19;:36::i;:::-;4175:46;;;;;;;;;;;4149:72;;4278:1;4234:46;;4242:7;:23;;;;;;;;;;;;4234:46;;;;4227:53;;;4062:223;;;:::o;1812:137:33:-;1328:9;:7;:9::i;:::-;1320:18;;;;;;;;1910:1;1873:40;;1894:6;;;;;;;;;;;1873:40;;;;;;;;;;;;1940:1;1923:6;;:19;;;;;;;;;;;;;;;;;;1812:137::o;1124:77::-;1162:7;1188:6;;;;;;;;;;;1181:13;;1124:77;:::o;1444:90::-;1484:4;1521:6;;;;;;;;;;;1507:20;;:10;:20;;;1500:27;;1444:90;:::o;5356:303:4:-;5417:32;;:::i;:::-;5451:23;5476;5507;5533:8;:37;5542:20;:27;5563:5;5542:27;;;;;;;;;;;;;;;;5533:37;;;;;;;;;;;5507:63;;5584:7;:23;;5609:7;:23;;;;;;;;;;;;5634:7;:18;;5576:77;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5356:303;;;;;:::o;4697:173::-;4739:32;;:::i;:::-;4773:23;4798;4836:29;4853:11;;;;;;;;;;;4836:16;:29::i;:::-;4829:36;;;;;;4697:173;;;:::o;2510:1331::-;1328:9:33;:7;:9::i;:::-;1320:18;;;;;;;;2672:1:4;2645:29;;:15;:29;;;;2637:70;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2722:27;2733:15;2722:10;:27::i;:::-;2721:28;2713:87;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2815:38;2837:15;2815:21;:38::i;:::-;2814:39;2806:76;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2913:17;2933:36;2953:15;2933:19;:36::i;:::-;2913:56;;2997:53;;;;;;;;;3005:15;2997:53;;;;3022:15;2997:53;;;;;;3039:10;2997:53;;;2975:8;:19;2984:9;2975:19;;;;;;;;;;;:75;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;3088:12;3103:15;3119:1;3103:18;;;;;;;;;;;;;3088:33;;3139:11;;;;;;;;;;;3131:19;;:5;:19;;;3127:72;;;3174:15;3190:1;3174:18;;;;;;;;;;;;;3160:11;;:32;;;;;;;;;;;;;;;;;;3127:72;3249:12;3264:15;3280:1;3264:18;;;;;;;;;;;;;3249:33;;3288:12;3303:15;3319:1;3303:18;;;;;;;;;;;;;3288:33;;3327:39;3369:8;:37;3378:20;:27;3399:5;3378:27;;;;;;;;;;;;;;;;3369:37;;;;;;;;;;;:53;;3327:95;;3432:44;3454:21;3432:44;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:21;:44::i;:::-;:125;;;;3532:21;3554:1;3532:24;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3524:32;;:5;:32;;;3432:125;:239;;;;3610:21;3632:1;3610:24;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3601:33;;:5;:33;;;:69;;;;;3646:21;3668:1;3646:24;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3638:32;;:5;:32;;;3601:69;3432:239;3428:339;;;3751:9;3721:20;:27;3742:5;3721:27;;;;;;;;;;;;;;;:39;;;;3428:339;3778:58;3791:15;3808;3825:10;3778:58;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;3778:58:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;3778:58:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1348:1:33;;;;;2510:1331:4;;;:::o;1301:267::-;1376:23;1401;1432;1458:8;:46;1467:36;1487:15;1467:19;:36::i;:::-;1458:46;;;;;;;;;;;1432:72;;1518:7;:23;;;;;;;;;;;;1543:7;:18;;1510:52;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1301:267;;;:::o;2120:107:33:-;1328:9;:7;:9::i;:::-;1320:18;;;;;;;;2192:28;2211:8;2192:18;:28::i;:::-;2120:107;:::o;5663:168:4:-;5741:7;5790;5798:1;5790:10;;;;;;;;;;;;;5802:7;5810:1;5802:10;;;;;;;;;;;;;5814:7;5822:1;5814:10;;;;;;;;;;;;;5773:52;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;49:4:-1;39:7;30;26:21;22:32;13:7;6:49;5773:52:4;;;5763:63;;;;;;5756:70;;5663:168;;;:::o;5835:157::-;5915:4;5948:1;5934:7;5942:1;5934:10;;;;;;;;;;;;;:15;;;:34;;;;;5967:1;5953:7;5961:1;5953:10;;;;;;;;;;;;;:15;;;5934:34;:53;;;;;5986:1;5972:7;5980:1;5972:10;;;;;;;;;;;;;:15;;;5934:53;5927:60;;5835:157;;;:::o;2371:183:33:-;2464:1;2444:22;;:8;:22;;;;2436:31;;;;;;;;2511:8;2482:38;;2503:6;;;;;;;;;;;2482:38;;;;;;;;;;;;2539:8;2530:6;;:17;;;;;;;;;;;;;;;;;;2371:183;:::o;424:5570:4:-;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;148:4;140:6;136:17;126:27;;0:157;424:5570:4;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o",
"abi": [
{
"constant": true,
"inputs": [
{
"name": "semanticVersion",
"type": "uint64[3]"
}
],
"name": "getContract",
"outputs": [
{
"name": "contractAddress",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "semanticVersion",
"type": "uint64[3]"
}
],
"name": "hasVersion",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "owner",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "isOwner",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "major",
"type": "uint64"
}
],
"name": "getLatestByMajor",
"outputs": [
{
"name": "semanticVersion",
"type": "uint64[3]"
},
{
"name": "contractAddress",
"type": "address"
},
{
"name": "contentURI",
"type": "bytes"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getLatest",
"outputs": [
{
"name": "semanticVersion",
"type": "uint64[3]"
},
{
"name": "contractAddress",
"type": "address"
},
{
"name": "contentURI",
"type": "bytes"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "semanticVersion",
"type": "uint64[3]"
},
{
"name": "contractAddress",
"type": "address"
},
{
"name": "contentURI",
"type": "bytes"
}
],
"name": "addVersion",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "semanticVersion",
"type": "uint64[3]"
}
],
"name": "getVersion",
"outputs": [
{
"name": "contractAddress",
"type": "address"
},
{
"name": "contentURI",
"type": "bytes"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "semanticVersion",
"type": "uint64[3]"
},
{
"indexed": false,
"name": "contractAddress",
"type": "address"
},
{
"indexed": false,
"name": "contentURI",
"type": "bytes"
}
],
"name": "VersionAdded",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
}
],
"ast": {
"absolutePath": "contracts/application/Package.sol",
"exportedSymbols": {
"Package": [
793
]
},
"id": 794,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 454,
"literals": [
"solidity",
"^",
"0.5",
".0"
],
"nodeType": "PragmaDirective",
"src": "0:23:4"
},
{
"absolutePath": "contracts/ownership/Ownable.sol",
"file": "../ownership/Ownable.sol",
"id": 455,
"nodeType": "ImportDirective",
"scope": 794,
"sourceUnit": 5494,
"src": "25:34:4",
"symbolAliases": [],
"unitAlias": ""
},
{
"baseContracts": [
{
"arguments": null,
"baseName": {
"contractScope": null,
"id": 456,
"name": "OpenZeppelinUpgradesOwnable",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 5493,
"src": "444:27:4",
"typeDescriptions": {
"typeIdentifier": "t_contract$_OpenZeppelinUpgradesOwnable_$5493",
"typeString": "contract OpenZeppelinUpgradesOwnable"
}
},
"id": 457,
"nodeType": "InheritanceSpecifier",
"src": "444:27:4"
}
],
"contractDependencies": [
5493
],
"contractKind": "contract",
"documentation": "@title Package\n@dev A package is composed by a set of versions, identified via semantic versioning,\nwhere each version has a contract address that refers to a reusable implementation,\nplus an optional content URI with metadata. Note that the semver identifier is restricted\nto major, minor, and patch, as prerelease tags are not supported.",
"fullyImplemented": true,
"id": 793,
"linearizedBaseContracts": [
793,
5493
],
"name": "Package",
"nodeType": "ContractDefinition",
"nodes": [
{
"anonymous": false,
"documentation": "@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": 467,
"name": "VersionAdded",
"nodeType": "EventDefinition",
"parameters": {
"id": 466,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 461,
"indexed": false,
"name": "semanticVersion",
"nodeType": "VariableDeclaration",
"scope": 467,
"src": "760:25:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint64_$3_memory_ptr",
"typeString": "uint64[3]"
},
"typeName": {
"baseType": {
"id": 458,
"name": "uint64",
"nodeType": "ElementaryTypeName",
"src": "760:6:4",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
}
},
"id": 460,
"length": {
"argumentTypes": null,
"hexValue": "33",
"id": 459,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "767:1:4",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": null,
"typeString": null
},
"value": "3"
},
"nodeType": "ArrayTypeName",
"src": "760:9:4",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint64_$3_storage_ptr",
"typeString": "uint64[3]"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 463,
"indexed": false,
"name": "contractAddress",
"nodeType": "VariableDeclaration",
"scope": 467,
"src": "787:23:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 462,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "787:7:4",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 465,
"indexed": false,
"name": "contentURI",
"nodeType": "VariableDeclaration",
"scope": 467,
"src": "812:16:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes_memory_ptr",
"typeString": "bytes"
},
"typeName": {
"id": 464,
"name": "bytes",
"nodeType": "ElementaryTypeName",
"src": "812:5:4",
"typeDescriptions": {
"typeIdentifier": "t_bytes_storage_ptr",
"typeString": "bytes"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "759:70:4"
},
"src": "741:89:4"
},
{
"canonicalName": "Package.Version",
"id": 476,
"members": [
{
"constant": false,
"id": 471,
"name": "semanticVersion",
"nodeType": "VariableDeclaration",
"scope": 476,
"src": "855:25:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint64_$3_storage_ptr",
"typeString": "uint64[3]"
},
"typeName": {
"baseType": {
"id": 468,
"name": "uint64",
"nodeType": "ElementaryTypeName",
"src": "855:6:4",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
}
},
"id": 470,
"length": {
"argumentTypes": null,
"hexValue": "33",
"id": 469,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "862:1:4",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": null,
"typeString": null
},
"value": "3"
},
"nodeType": "ArrayTypeName",
"src": "855:9:4",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint64_$3_storage_ptr",
"typeString": "uint64[3]"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 473,
"name": "contractAddress",
"nodeType": "VariableDeclaration",
"scope": 476,
"src": "886:23:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 472,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "886:7:4",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 475,
"name": "contentURI",
"nodeType": "VariableDeclaration",
"scope": 476,
"src": "915:16:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes_storage_ptr",
"typeString": "bytes"
},
"typeName": {
"id": 474,
"name": "bytes",
"nodeType": "ElementaryTypeName",
"src": "915:5:4",
"typeDescriptions": {
"typeIdentifier": "t_bytes_storage_ptr",
"typeString": "bytes"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "Version",
"nodeType": "StructDefinition",
"scope": 793,
"src": "834:103:4",
"visibility": "public"
},
{
"constant": false,
"id": 480,
"name": "versions",
"nodeType": "VariableDeclaration",
"scope": 793,
"src": "941:46:4",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_bytes32_$_t_struct$_Version_$476_storage_$",
"typeString": "mapping(bytes32 => struct Package.Version)"
},
"typeName": {
"id": 479,
"keyType": {
"id": 477,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "950:7:4",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"nodeType": "Mapping",
"src": "941:28:4",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_bytes32_$_t_struct$_Version_$476_storage_$",
"typeString": "mapping(bytes32 => struct Package.Version)"
},
"valueType": {
"contractScope": null,
"id": 478,
"name": "Version",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 476,
"src": "961:7:4",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$476_storage_ptr",
"typeString": "struct Package.Version"
}
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 484,
"name": "majorToLatestVersion",
"nodeType": "VariableDeclaration",
"scope": 793,
"src": "991:57:4",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_uint64_$_t_bytes32_$",
"typeString": "mapping(uint64 => bytes32)"
},
"typeName": {
"id": 483,
"keyType": {
"id": 481,
"name": "uint64",
"nodeType": "ElementaryTypeName",
"src": "1000:6:4",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
}
},
"nodeType": "Mapping",
"src": "991:27:4",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_uint64_$_t_bytes32_$",
"typeString": "mapping(uint64 => bytes32)"
},
"valueType": {
"id": 482,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "1010:7:4",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 486,
"name": "latestMajor",
"nodeType": "VariableDeclaration",
"scope": 793,
"src": "1052:27:4",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
},
"typeName": {
"id": 485,
"name": "uint64",
"nodeType": "ElementaryTypeName",
"src": "1052:6:4",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
}
},
"value": null,
"visibility": "internal"
},
{
"body": {
"id": 511,
"nodeType": "Block",
"src": "1426:142:4",
"statements": [
{
"assignments": [
498
],
"declarations": [
{
"constant": false,
"id": 498,
"name": "version",
"nodeType": "VariableDeclaration",
"scope": 511,
"src": "1432:23:4",
"stateVariable": false,
"storageLocation": "storage",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$476_storage_ptr",
"typeString": "struct Package.Version"
},
"typeName": {
"contractScope": null,
"id": 497,
"name": "Version",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 476,
"src": "1432:7:4",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$476_storage_ptr",
"typeString": "struct Package.Version"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 504,
"initialValue": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"id": 499,
"name": "versions",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 480,
"src": "1458:8:4",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_bytes32_$_t_struct$_Version_$476_storage_$",
"typeString": "mapping(bytes32 => struct Package.Version storage ref)"
}
},
"id": 503,
"indexExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 501,
"name": "semanticVersion",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 490,
"src": "1487: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": 500,
"name": "semanticVersionHash",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 764,
"src": "1467: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": 502,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1467:36:4",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"nodeType": "IndexAccess",
"src": "1458:46:4",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$476_storage",
"typeString": "struct Package.Version storage ref"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "1432:72:4"
},
{
"expression": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 505,
"name": "version",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 498,
"src": "1518:7:4",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$476_storage_ptr",
"typeString": "struct Package.Version storage pointer"
}
},
"id": 506,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "contractAddress",
"nodeType": "MemberAccess",
"referencedDeclaration": 473,
"src": "1518:23:4",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 507,
"name": "version",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 498,
"src": "1543:7:4",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$476_storage_ptr",
"typeString": "struct Package.Version storage pointer"
}
},
"id": 508,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "contentURI",
"nodeType": "MemberAccess",
"referencedDeclaration": 475,
"src": "1543:18:4",
"typeDescriptions": {
"typeIdentifier": "t_bytes_storage",
"typeString": "bytes storage ref"
}
}
],
"id": 509,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "1517:45:4",
"typeDescriptions": {
"typeIdentifier": "t_tuple$_t_address_$_t_bytes_storage_$",
"typeString": "tuple(address,bytes storage ref)"
}
},
"functionReturnParameters": 496,
"id": 510,
"nodeType": "Return",
"src": "1510:52:4"
}
]
},
"documentation": "@dev Returns a version given its semver identifier.\n@param semanticVersion Semver identifier of the version.\n@return Contract address and content URI for the version, or zero if not exists.",
"id": 512,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "getVersion",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 491,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 490,
"name": "semanticVersion",
"nodeType": "VariableDeclaration",
"scope": 512,
"src": "1321:32:4",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint64_$3_memory_ptr",
"typeString": "uint64[3]"
},
"typeName": {
"baseType": {
"id": 487,
"name": "uint64",
"nodeType": "ElementaryTypeName",
"src": "1321:6:4",
"typeDescriptions": {
"typeIdentifier": "t_uint64",
"typeString": "uint64"
}
},
"id": 489,
"length": {
"argumentTypes": null,
"hexValue": "33",
"id": 488,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1328:1:4",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": null,
"typeString": null
},
"value": "3"
},
"nodeType": "ArrayTypeName",
"src": "1321:9:4",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_uint64_$3_storage_ptr",
"typeString": "uint64[3]"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1320:34:4"
},
"returnParameters": {
"id": 496,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 493,
"name": "contractAddress",
"nodeType": "VariableDeclaration",
"scope": 512,
"src": "1376:23:4",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 492,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1376:7:4",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 495,
"name": "contentURI",
"nodeType": "VariableDeclaration",
"scope": 512,
"src": "1401:23:4",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_bytes_memory_ptr",
"typeString": "bytes"
},
"typeName": {
"id": 494,
"name": "bytes",
"nodeType": "ElementaryTypeName",
"src": "1401:5:4",
"typeDescriptions": {
"typeIdentifier": "t_bytes_storage_ptr",
"typeString": "bytes"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1375:50:4"
},
"scope": 793,
"src": "1301:267:4",
"stateMutability": "view",
"superFunction": null,
"visibility": "public"
},
{
"body": {
"id": 532,
"nodeType": "Block",
"src": "1976:119:4",
"statements": [
{
"assignments": [
522
],
"declarations": [
{
"constant": false,
"id": 522,
"name": "version",
"nodeType": "VariableDeclaration",
"scope": 532,
"src": "1982:23:4",
"stateVariable": false,
"storageLocation": "storage",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$476_storage_ptr",
"typeString": "struct Package.Version"
},
"typeName": {
"contractScope": null,
"id": 521,
"name": "Version",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 476,
"src": "1982:7:4",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Version_$476_storage_ptr",
"typeString": "struct Package.Version"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 528,
"initialValue": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"id": 523,
"name": "versions",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 480,
"src": "2008:8:4",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_bytes32_$_t_struct$_Version_$476_storage_$",
"typeString": "mapping(bytes32 => struct Package.Version storage ref)"
}
},
"id": 527,
"indexExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 525,
"name": "semanticVersion",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 516,