web3 7.0.0b1__py3-none-any.whl → 7.0.0b3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. ens/async_ens.py +6 -8
  2. ens/ens.py +6 -6
  3. ens/utils.py +18 -16
  4. web3/_utils/abi.py +9 -15
  5. web3/_utils/events.py +15 -6
  6. web3/_utils/math.py +12 -14
  7. web3/_utils/method_formatters.py +7 -0
  8. web3/_utils/module_testing/eth_module.py +67 -6
  9. web3/_utils/module_testing/module_testing_utils.py +2 -2
  10. web3/_utils/request.py +1 -1
  11. web3/_utils/rpc_abi.py +1 -0
  12. web3/_utils/transactions.py +4 -0
  13. web3/contract/base_contract.py +1 -1
  14. web3/datastructures.py +7 -7
  15. web3/eth/async_eth.py +20 -2
  16. web3/eth/eth.py +13 -1
  17. web3/exceptions.py +11 -0
  18. web3/main.py +4 -30
  19. web3/manager.py +12 -13
  20. web3/middleware/__init__.py +9 -8
  21. web3/module.py +1 -1
  22. web3/providers/async_base.py +6 -6
  23. web3/providers/base.py +8 -8
  24. web3/providers/eth_tester/main.py +16 -20
  25. web3/providers/ipc.py +1 -1
  26. web3/providers/legacy_websocket.py +1 -1
  27. web3/providers/persistent/persistent.py +2 -2
  28. web3/providers/persistent/request_processor.py +3 -5
  29. web3/tools/benchmark/main.py +2 -2
  30. web3/types.py +4 -0
  31. web3/utils/caching.py +2 -4
  32. {web3-7.0.0b1.dist-info → web3-7.0.0b3.dist-info}/METADATA +3 -9
  33. web3-7.0.0b3.dist-info/RECORD +168 -0
  34. {web3-7.0.0b1.dist-info → web3-7.0.0b3.dist-info}/WHEEL +1 -1
  35. {web3-7.0.0b1.dist-info → web3-7.0.0b3.dist-info}/top_level.txt +0 -1
  36. ethpm/__init__.py +0 -20
  37. ethpm/_utils/__init__.py +0 -0
  38. ethpm/_utils/backend.py +0 -93
  39. ethpm/_utils/cache.py +0 -44
  40. ethpm/_utils/chains.py +0 -119
  41. ethpm/_utils/contract.py +0 -35
  42. ethpm/_utils/deployments.py +0 -145
  43. ethpm/_utils/ipfs.py +0 -116
  44. ethpm/_utils/protobuf/__init__.py +0 -0
  45. ethpm/_utils/protobuf/ipfs_file_pb2.py +0 -33
  46. ethpm/_utils/registry.py +0 -29
  47. ethpm/assets/__init__.py +0 -0
  48. ethpm/assets/ens/v3.json +0 -1
  49. ethpm/assets/escrow/with_bytecode_v3.json +0 -1
  50. ethpm/assets/ipfs_file.proto +0 -32
  51. ethpm/assets/owned/output_v3.json +0 -1
  52. ethpm/assets/owned/with_contract_type_v3.json +0 -1
  53. ethpm/assets/registry/contracts/Authority.sol +0 -156
  54. ethpm/assets/registry/contracts/IndexedOrderedSetLib.sol +0 -106
  55. ethpm/assets/registry/contracts/PackageDB.sol +0 -225
  56. ethpm/assets/registry/contracts/PackageRegistry.sol +0 -361
  57. ethpm/assets/registry/contracts/PackageRegistryInterface.sol +0 -97
  58. ethpm/assets/registry/contracts/ReleaseDB.sol +0 -309
  59. ethpm/assets/registry/contracts/ReleaseValidator.sol +0 -152
  60. ethpm/assets/registry/solc_input.json +0 -1
  61. ethpm/assets/registry/solc_output.json +0 -1
  62. ethpm/assets/registry/v3.json +0 -1
  63. ethpm/assets/safe-math-lib/v3-strict-no-deployments.json +0 -1
  64. ethpm/assets/simple-registry/contracts/Ownable.sol +0 -63
  65. ethpm/assets/simple-registry/contracts/PackageRegistry.sol +0 -373
  66. ethpm/assets/simple-registry/contracts/PackageRegistryInterface.sol +0 -96
  67. ethpm/assets/simple-registry/solc_input.json +0 -33
  68. ethpm/assets/simple-registry/solc_output.json +0 -1
  69. ethpm/assets/simple-registry/v3.json +0 -1
  70. ethpm/assets/standard-token/output_v3.json +0 -1
  71. ethpm/assets/standard-token/with_bytecode_v3.json +0 -1
  72. ethpm/assets/vyper_registry/0.1.0.json +0 -1
  73. ethpm/assets/vyper_registry/registry.vy +0 -216
  74. ethpm/assets/vyper_registry/registry_with_delete.vy +0 -244
  75. ethpm/backends/__init__.py +0 -0
  76. ethpm/backends/base.py +0 -43
  77. ethpm/backends/http.py +0 -108
  78. ethpm/backends/ipfs.py +0 -219
  79. ethpm/backends/registry.py +0 -154
  80. ethpm/constants.py +0 -17
  81. ethpm/contract.py +0 -187
  82. ethpm/dependencies.py +0 -58
  83. ethpm/deployments.py +0 -80
  84. ethpm/ethpm-spec/examples/escrow/1.0.0-pretty.json +0 -146
  85. ethpm/ethpm-spec/examples/escrow/1.0.0.json +0 -1
  86. ethpm/ethpm-spec/examples/escrow/contracts/Escrow.sol +0 -32
  87. ethpm/ethpm-spec/examples/escrow/contracts/SafeSendLib.sol +0 -20
  88. ethpm/ethpm-spec/examples/escrow/v3-pretty.json +0 -171
  89. ethpm/ethpm-spec/examples/escrow/v3.json +0 -1
  90. ethpm/ethpm-spec/examples/owned/1.0.0-pretty.json +0 -21
  91. ethpm/ethpm-spec/examples/owned/1.0.0.json +0 -1
  92. ethpm/ethpm-spec/examples/owned/contracts/Owned.sol +0 -12
  93. ethpm/ethpm-spec/examples/owned/v3-pretty.json +0 -27
  94. ethpm/ethpm-spec/examples/owned/v3.json +0 -1
  95. ethpm/ethpm-spec/examples/piper-coin/1.0.0-pretty.json +0 -31
  96. ethpm/ethpm-spec/examples/piper-coin/1.0.0.json +0 -1
  97. ethpm/ethpm-spec/examples/piper-coin/v3-pretty.json +0 -21
  98. ethpm/ethpm-spec/examples/piper-coin/v3.json +0 -1
  99. ethpm/ethpm-spec/examples/safe-math-lib/1.0.0-pretty.json +0 -85
  100. ethpm/ethpm-spec/examples/safe-math-lib/1.0.0.json +0 -1
  101. ethpm/ethpm-spec/examples/safe-math-lib/contracts/SafeMathLib.sol +0 -24
  102. ethpm/ethpm-spec/examples/safe-math-lib/v3-pretty.json +0 -117
  103. ethpm/ethpm-spec/examples/safe-math-lib/v3.json +0 -1
  104. ethpm/ethpm-spec/examples/standard-token/1.0.0-pretty.json +0 -55
  105. ethpm/ethpm-spec/examples/standard-token/1.0.0.json +0 -1
  106. ethpm/ethpm-spec/examples/standard-token/contracts/AbstractToken.sol +0 -20
  107. ethpm/ethpm-spec/examples/standard-token/contracts/StandardToken.sol +0 -84
  108. ethpm/ethpm-spec/examples/standard-token/v3-pretty.json +0 -460
  109. ethpm/ethpm-spec/examples/standard-token/v3.json +0 -1
  110. ethpm/ethpm-spec/examples/transferable/1.0.0-pretty.json +0 -21
  111. ethpm/ethpm-spec/examples/transferable/1.0.0.json +0 -1
  112. ethpm/ethpm-spec/examples/transferable/contracts/Transferable.sol +0 -14
  113. ethpm/ethpm-spec/examples/transferable/v3-pretty.json +0 -27
  114. ethpm/ethpm-spec/examples/transferable/v3.json +0 -1
  115. ethpm/ethpm-spec/examples/wallet/1.0.0-pretty.json +0 -120
  116. ethpm/ethpm-spec/examples/wallet/1.0.0.json +0 -1
  117. ethpm/ethpm-spec/examples/wallet/contracts/Wallet.sol +0 -41
  118. ethpm/ethpm-spec/examples/wallet/v3-pretty.json +0 -181
  119. ethpm/ethpm-spec/examples/wallet/v3.json +0 -1
  120. ethpm/ethpm-spec/examples/wallet-with-send/1.0.0-pretty.json +0 -135
  121. ethpm/ethpm-spec/examples/wallet-with-send/1.0.0.json +0 -1
  122. ethpm/ethpm-spec/examples/wallet-with-send/contracts/WalletWithSend.sol +0 -18
  123. ethpm/ethpm-spec/examples/wallet-with-send/v3-pretty.json +0 -207
  124. ethpm/ethpm-spec/examples/wallet-with-send/v3.json +0 -1
  125. ethpm/ethpm-spec/spec/package.spec.json +0 -379
  126. ethpm/ethpm-spec/spec/v3.spec.json +0 -483
  127. ethpm/exceptions.py +0 -68
  128. ethpm/package.py +0 -438
  129. ethpm/tools/__init__.py +0 -4
  130. ethpm/tools/builder.py +0 -930
  131. ethpm/tools/checker.py +0 -312
  132. ethpm/tools/get_manifest.py +0 -19
  133. ethpm/uri.py +0 -141
  134. ethpm/validation/__init__.py +0 -0
  135. ethpm/validation/manifest.py +0 -146
  136. ethpm/validation/misc.py +0 -39
  137. ethpm/validation/package.py +0 -80
  138. ethpm/validation/uri.py +0 -163
  139. web3/pm.py +0 -602
  140. web3/tools/__init__.py +0 -4
  141. web3/tools/pytest_ethereum/__init__.py +0 -0
  142. web3/tools/pytest_ethereum/_utils.py +0 -145
  143. web3/tools/pytest_ethereum/deployer.py +0 -48
  144. web3/tools/pytest_ethereum/exceptions.py +0 -22
  145. web3/tools/pytest_ethereum/linker.py +0 -128
  146. web3/tools/pytest_ethereum/plugins.py +0 -33
  147. web3-7.0.0b1.dist-info/RECORD +0 -280
  148. web3-7.0.0b1.dist-info/entry_points.txt +0 -2
  149. {web3-7.0.0b1.dist-info → web3-7.0.0b3.dist-info}/LICENSE +0 -0
@@ -1 +0,0 @@
1
- {"compilers":[{"contractTypes":["SafeMathLib"],"name":"solc","settings":{"optimize":false},"version":"0.4.24+commit.e67f0147.Emscripten.clang"}],"contractTypes":{"SafeMathLib":{"abi":[{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeSub","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeAdd","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"}],"deploymentBytecode":{"bytecode":"0x610145610030600b82828239805160001a6073146000811461002057610022565bfe5b5030600052607381538281f3007300000000000000000000000000000000000000003014608060405260043610610063576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063a293d1e814610068578063e6cb9013146100a6575b600080fd5b61009060048036038101908080359060200190929190803590602001909291905050506100e4565b6040518082815260200191505060405180910390f35b6100ce60048036038101908080359060200190929190803590602001909291905050506100fd565b6040518082815260200191505060405180910390f35b60008282111515156100f257fe5b818303905092915050565b6000818301905082811015151561011057fe5b809050929150505600a165627a7a72305820ac19b530c9fab4716b26d7706467f9a30d5542de1ac898dc56c67ff65ebe9bd50029"},"devdoc":{"author":"Piper Merriam <pipermerriam@gmail.com>","methods":{"safeAdd(uint256,uint256)":{"details":"Adds a and b, throwing an error if the operation would cause an overflow.","params":{"a":"The first number to add","b":"The second number to add"}},"safeSub(uint256,uint256)":{"details":"Subtracts b from a, throwing an error if the operation would cause an underflow.","params":{"a":"The number to be subtracted from","b":"The amount that should be subtracted"}}},"title":"Safe Math Library"},"runtimeBytecode":{"bytecode":"0x73a66a05d6ab5c1c955f4d2c3fcc166ae6300b452b3014608060405260043610610063576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063a293d1e814610068578063e6cb9013146100a6575b600080fd5b61009060048036038101908080359060200190929190803590602001909291905050506100e4565b6040518082815260200191505060405180910390f35b6100ce60048036038101908080359060200190929190803590602001909291905050506100fd565b6040518082815260200191505060405180910390f35b60008282111515156100f257fe5b818303905092915050565b6000818301905082811015151561011057fe5b809050929150505600a165627a7a72305820ac19b530c9fab4716b26d7706467f9a30d5542de1ac898dc56c67ff65ebe9bd50029"},"sourceId":"contracts/SafeMathLib.sol"}},"manifest":"ethpm/3","name":"safe-math-lib","sources":{"contracts/SafeMathLib.sol":{"installPath":"./contracts/SafeMathLib.sol","type":"solidity","urls":["ipfs://QmNQeuwMDGJ7UiLaRjwzAoekcaKLp9TjiqeFdovj3syN1n"]}},"version":"1.0.0"}
@@ -1,63 +0,0 @@
1
- pragma solidity ^0.5.0;
2
-
3
- /**
4
- * @dev Contract module which provides a basic access control mechanism, where
5
- * there is an account (an owner) that can be granted exclusive access to
6
- * specific functions.
7
- *
8
- * This module is used through inheritance. It will make available the modifier
9
- * `onlyOwner`, which can be applied to your functions to restrict their use to
10
- * the owner.
11
- */
12
- contract Ownable {
13
- address private _owner;
14
-
15
- event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
16
-
17
- /**
18
- * @dev Initializes the contract setting the deployer as the initial owner.
19
- */
20
- constructor () internal {
21
- _owner = msg.sender;
22
- emit OwnershipTransferred(address(0), _owner);
23
- }
24
-
25
- /**
26
- * @dev Returns the address of the current owner.
27
- */
28
- function owner() public view returns (address) {
29
- return _owner;
30
- }
31
-
32
- /**
33
- * @dev Throws if called by any account other than the owner.
34
- */
35
- modifier onlyOwner() {
36
- require(isOwner(), "Ownable: caller is not the owner");
37
- _;
38
- }
39
-
40
- /**
41
- * @dev Returns true if the caller is the current owner.
42
- */
43
- function isOwner() public view returns (bool) {
44
- return msg.sender == _owner;
45
- }
46
-
47
- /**
48
- * @dev Transfers ownership of the contract to a new account (`newOwner`).
49
- * Can only be called by the current owner.
50
- */
51
- function transferOwnership(address newOwner) public onlyOwner {
52
- _transferOwnership(newOwner);
53
- }
54
-
55
- /**
56
- * @dev Transfers ownership of the contract to a new account (`newOwner`).
57
- */
58
- function _transferOwnership(address newOwner) internal {
59
- require(newOwner != address(0), "Ownable: new owner is the zero address");
60
- emit OwnershipTransferred(_owner, newOwner);
61
- _owner = newOwner;
62
- }
63
- }
@@ -1,373 +0,0 @@
1
- pragma solidity >=0.5.10;
2
-
3
- import {PackageRegistryInterface} from "./PackageRegistryInterface.sol";
4
- import {Ownable} from "./Ownable.sol";
5
-
6
- /// @title Contract for an ERC1319 Registry, adapted from ethpm/escape-truffle
7
- /// @author Nick Gheorghita <nickg@ethereum.org>
8
- contract PackageRegistry is PackageRegistryInterface, Ownable {
9
- struct Package {
10
- bool exists;
11
- uint createdAt;
12
- uint updatedAt;
13
- uint releaseCount;
14
- string name;
15
- }
16
-
17
- struct Release {
18
- bool exists;
19
- uint createdAt;
20
- bytes32 packageId;
21
- string version;
22
- string manifestURI;
23
- }
24
-
25
- mapping (bytes32 => Package) public packages;
26
- mapping (bytes32 => Release) public releases;
27
-
28
- // package_id#release_count => release_id
29
- mapping (bytes32 => bytes32) packageReleaseIndex;
30
- // Total package number (int128) => package_id (bytes32)
31
- mapping (uint => bytes32) allPackageIds;
32
- // Total release number (int128) => release_id (bytes32)
33
- mapping (uint => bytes32) allReleaseIds;
34
- // Total number of packages in registry
35
- uint public packageCount;
36
- // Total number of releases in registry
37
- uint public releaseCount;
38
-
39
- // Events
40
- event VersionRelease(string packageName, string version, string manifestURI);
41
- event PackageTransfer(address indexed oldOwner, address indexed newOwner);
42
-
43
- // Modifiers
44
- modifier onlyIfPackageExists(string memory packageName) {
45
- require(packageExists(packageName), "package-does-not-exist");
46
- _;
47
- }
48
-
49
- modifier onlyIfReleaseExists(string memory packageName, string memory version) {
50
- require (releaseExists(packageName, version), "release-does-not-exist");
51
- _;
52
- }
53
-
54
- //
55
- // ===============
56
- // | Write API |
57
- // ===============
58
- //
59
-
60
- /// @dev Creates a new release for the named package. If this is the first release for the given
61
- /// package then this will also create and store the package. Returns releaseID if successful.
62
- /// @notice Will create a new release the given package with the given release information.
63
- /// @param packageName Package name
64
- /// @param version Version string (ex: '1.0.0')
65
- /// @param manifestURI The URI for the release manifest for this release.
66
- function release(
67
- string memory packageName,
68
- string memory version,
69
- string memory manifestURI
70
- )
71
- public
72
- onlyOwner
73
- returns (bytes32)
74
- {
75
- validatePackageName(packageName);
76
- validateStringIdentifier(version);
77
- validateStringIdentifier(manifestURI);
78
-
79
- // Compute hashes
80
- bytes32 packageId = generatePackageId(packageName);
81
- bytes32 releaseId = generateReleaseId(packageName, version);
82
- Package storage package = packages[packageId];
83
-
84
- // If the package does not yet exist create it
85
- if (package.exists == false) {
86
- package.exists = true;
87
- package.createdAt = block.timestamp;
88
- package.updatedAt = block.timestamp;
89
- package.name = packageName;
90
- package.releaseCount = 0;
91
- allPackageIds[packageCount] = packageId;
92
- packageCount++;
93
- } else {
94
- package.updatedAt = block.timestamp;
95
- }
96
- cutRelease(packageId, releaseId, packageName, version, manifestURI);
97
- return releaseId;
98
- }
99
-
100
- function cutRelease(
101
- bytes32 packageId,
102
- bytes32 releaseId,
103
- string memory packageName,
104
- string memory version,
105
- string memory manifestURI
106
- )
107
- private
108
- {
109
- Release storage newRelease = releases[releaseId];
110
- require(newRelease.exists == false, "release-already-exists");
111
-
112
- // Store new release data
113
- newRelease.exists = true;
114
- newRelease.createdAt = block.timestamp;
115
- newRelease.packageId = packageId;
116
- newRelease.version = version;
117
- newRelease.manifestURI = manifestURI;
118
-
119
- releases[releaseId] = newRelease;
120
- allReleaseIds[releaseCount] = releaseId;
121
- releaseCount++;
122
-
123
- // Update package's release count
124
- Package storage package = packages[packageId];
125
- bytes32 packageReleaseId = generatePackageReleaseId(packageId, package.releaseCount);
126
- packageReleaseIndex[packageReleaseId] = releaseId;
127
- package.releaseCount++;
128
-
129
- // Log the release.
130
- emit VersionRelease(packageName, version, manifestURI);
131
- }
132
-
133
- //
134
- // ==============
135
- // | Read API |
136
- // ==============
137
- //
138
-
139
- /// @dev Returns the string name of the package associated with a package id
140
- /// @param packageId The package id to look up
141
- function getPackageName(bytes32 packageId)
142
- public
143
- view
144
- returns (string memory packageName)
145
- {
146
- Package memory targetPackage = packages[packageId];
147
- require (targetPackage.exists == true, "package-does-not-exist");
148
- return targetPackage.name;
149
- }
150
-
151
- /// @dev Returns a slice of the array of all package ids for the named package.
152
- /// @param offset The starting index for the slice.
153
- /// @param limit The length of the slice
154
- function getAllPackageIds(uint offset, uint limit)
155
- public
156
- view
157
- returns (
158
- bytes32[] memory packageIds,
159
- uint pointer
160
- )
161
- {
162
- bytes32[] memory hashes; // Array of package ids to return
163
- uint cursor = offset; // Index counter to traverse DB array
164
- uint remaining; // Counter to collect `limit` packages
165
-
166
- // Is request within range?
167
- if (cursor < packageCount){
168
-
169
- // Get total remaining records
170
- remaining = packageCount - cursor;
171
-
172
- // Number of records to collect is lesser of `remaining` and `limit`
173
- if (remaining > limit ){
174
- remaining = limit;
175
- }
176
-
177
- // Allocate return array
178
- hashes = new bytes32[](remaining);
179
-
180
- // Collect records.
181
- while(remaining > 0){
182
- bytes32 hash = allPackageIds[cursor];
183
- hashes[remaining - 1] = hash;
184
- remaining--;
185
- cursor++;
186
- }
187
- }
188
- return (hashes, cursor);
189
- }
190
-
191
- /// @dev Returns a slice of the array of all release hashes for the named package.
192
- /// @param packageName Package name
193
- /// @param offset The starting index for the slice.
194
- /// @param limit The length of the slice
195
- function getAllReleaseIds(string memory packageName, uint offset, uint limit)
196
- public
197
- view
198
- onlyIfPackageExists(packageName)
199
- returns (
200
- bytes32[] memory releaseIds,
201
- uint pointer
202
- )
203
- {
204
- bytes32 packageId = generatePackageId(packageName);
205
- Package storage package = packages[packageId];
206
- bytes32[] memory hashes; // Release ids to return
207
- uint cursor = offset; // Index counter to traverse DB array
208
- uint remaining; // Counter to collect `limit` packages
209
- uint numPackageReleases = package.releaseCount; // Total number of packages in registry
210
-
211
- // Is request within range?
212
- if (cursor < numPackageReleases){
213
-
214
- // Get total remaining records
215
- remaining = numPackageReleases - cursor;
216
-
217
- // Number of records to collect is lesser of `remaining` and `limit`
218
- if (remaining > limit ){
219
- remaining = limit;
220
- }
221
-
222
- // Allocate return array
223
- hashes = new bytes32[](remaining);
224
-
225
- // Collect records.
226
- while(remaining > 0){
227
- bytes32 packageReleaseId = generatePackageReleaseId(packageId, cursor);
228
- bytes32 hash = packageReleaseIndex[packageReleaseId];
229
- hashes[remaining - 1] = hash;
230
- remaining--;
231
- cursor++;
232
- }
233
- }
234
- return (hashes, cursor);
235
- }
236
-
237
-
238
- /// @dev Returns the package data for a release.
239
- /// @param releaseId Release id
240
- function getReleaseData(bytes32 releaseId)
241
- public
242
- view
243
- returns (
244
- string memory packageName, string memory version,
245
- string memory manifestURI
246
- )
247
- {
248
- Release memory targetRelease = releases[releaseId];
249
- Package memory targetPackage = packages[targetRelease.packageId];
250
- return (targetPackage.name, targetRelease.version, targetRelease.manifestURI);
251
- }
252
-
253
- /// @dev Returns the release id for a given name and version pair if present on registry.
254
- /// @param packageName Package name
255
- /// @param version Version string(ex: '1.0.0')
256
- function getReleaseId(string memory packageName, string memory version)
257
- public
258
- view
259
- onlyIfPackageExists(packageName)
260
- onlyIfReleaseExists(packageName, version)
261
- returns (bytes32 releaseId)
262
- {
263
- return generateReleaseId(packageName, version);
264
- }
265
-
266
- /// @dev Returns the number of packages stored on the registry
267
- function numPackageIds() public view returns (uint totalCount)
268
- {
269
- return packageCount;
270
- }
271
-
272
- /// @dev Returns the number of releases for a given package name on the registry
273
- /// @param packageName Package name
274
- function numReleaseIds(string memory packageName)
275
- public
276
- view
277
- onlyIfPackageExists(packageName)
278
- returns (uint totalCount)
279
- {
280
- bytes32 packageId = generatePackageId(packageName);
281
- Package storage package = packages[packageId];
282
- return package.releaseCount;
283
- }
284
-
285
- /// @dev Returns a bool indicating whether the given release exists in this registry.
286
- /// @param packageName Package Name
287
- /// @param version version
288
- function releaseExists(string memory packageName, string memory version)
289
- public
290
- view
291
- onlyIfPackageExists(packageName)
292
- returns (bool)
293
- {
294
- bytes32 releaseId = generateReleaseId(packageName, version);
295
- Release storage targetRelease = releases[releaseId];
296
- return targetRelease.exists;
297
- }
298
-
299
- /// @dev Returns a bool indicating whether the given package exists in this registry.
300
- /// @param packageName Package Name
301
- function packageExists(string memory packageName) public view returns (bool) {
302
- bytes32 packageId = generatePackageId(packageName);
303
- return packages[packageId].exists;
304
- }
305
-
306
- //
307
- // ====================
308
- // | Hash Functions |
309
- // ====================
310
- //
311
-
312
- /// @dev Returns name hash for a given package name.
313
- /// @param name Package name
314
- function generatePackageId(string memory name)
315
- public
316
- pure
317
- returns (bytes32)
318
- {
319
- return keccak256(abi.encodePacked(name));
320
- }
321
-
322
- // @dev Returns release id that *would* be generated for a name and version pair on `release`.
323
- // @param packageName Package name
324
- // @param version Version string (ex: '1.0.0')
325
- function generateReleaseId(
326
- string memory packageName,
327
- string memory version
328
- )
329
- public
330
- view
331
- returns (bytes32)
332
- {
333
- return keccak256(abi.encodePacked(packageName, version));
334
- }
335
-
336
- function generatePackageReleaseId(
337
- bytes32 packageId,
338
- uint packageReleaseCount
339
- )
340
- private
341
- pure
342
- returns (bytes32)
343
- {
344
- return keccak256(abi.encodePacked(packageId, packageReleaseCount));
345
- }
346
-
347
-
348
- //
349
- // ================
350
- // | Validation |
351
- // ================
352
- //
353
-
354
- /// @dev Returns boolean whether the provided package name is valid.
355
- /// @param name The name of the package.
356
- function validatePackageName(string memory name)
357
- public
358
- pure
359
- returns (bool)
360
- {
361
- require (bytes(name).length > 2 && bytes(name).length < 255, "invalid-package-name");
362
- }
363
-
364
- /// @dev Returns boolean whether the input string has a length
365
- /// @param value The string to validate.
366
- function validateStringIdentifier(string memory value)
367
- public
368
- pure
369
- returns (bool)
370
- {
371
- require (bytes(value).length != 0, "invalid-string-identifier");
372
- }
373
- }
@@ -1,96 +0,0 @@
1
- pragma solidity >=0.5.10;
2
-
3
-
4
- /// @title EIP 1319 Smart Contract Package Registry Interface
5
- /// @author Piper Merriam <pipermerriam@gmail.com>, Christopher Gewecke <christophergewecke@gmail.com>
6
- contract PackageRegistryInterface {
7
-
8
- //
9
- // +-------------+
10
- // | Write API |
11
- // +-------------+
12
- //
13
-
14
- /// @dev Creates a a new release for the named package.
15
- /// @notice Will create a new release the given package with the given release information.
16
- /// @param packageName Package name
17
- /// @param version Version string (ex: 1.0.0)
18
- /// @param manifestURI The URI for the release manifest for this release.
19
- function release(
20
- string memory packageName,
21
- string memory version,
22
- string memory manifestURI
23
- )
24
- public
25
- returns (bytes32 releaseId);
26
-
27
- //
28
- // +------------+
29
- // | Read API |
30
- // +------------+
31
- //
32
-
33
- /// @dev Returns the string name of the package associated with a package id
34
- /// @param packageId The package id to look up
35
- function getPackageName(bytes32 packageId)
36
- public
37
- view
38
- returns (string memory packageName);
39
-
40
- /// @dev Returns a slice of the array of all package ids for the named package.
41
- /// @param offset The starting index for the slice.
42
- /// @param limit The length of the slice
43
- function getAllPackageIds(uint offset, uint limit)
44
- public
45
- view
46
- returns (
47
- bytes32[] memory packageIds,
48
- uint pointer
49
- );
50
-
51
- /// @dev Returns a slice of the array of all release hashes for the named package.
52
- /// @param packageName Package name
53
- /// @param offset The starting index for the slice.
54
- /// @param limit The length of the slice
55
- function getAllReleaseIds(string memory packageName, uint offset, uint limit)
56
- public
57
- view
58
- returns (
59
- bytes32[] memory releaseIds,
60
- uint pointer
61
- );
62
-
63
- /// @dev Returns the package data for a release.
64
- /// @param releaseId Release id
65
- function getReleaseData(bytes32 releaseId)
66
- public
67
- view
68
- returns (
69
- string memory packageName,
70
- string memory version,
71
- string memory manifestURI
72
- );
73
-
74
- // @dev Returns release id that *would* be generated for a name and version pair on `release`.
75
- // @param packageName Package name
76
- // @param version Version string (ex: '1.0.0')
77
- function generateReleaseId(string memory packageName, string memory version)
78
- public
79
- view
80
- returns (bytes32 releaseId);
81
-
82
- /// @dev Returns the release id for a given name and version pair if present on registry.
83
- /// @param packageName Package name
84
- /// @param version Version string(ex: '1.0.0')
85
- function getReleaseId(string memory packageName, string memory version)
86
- public
87
- view
88
- returns (bytes32 releaseId);
89
-
90
- /// @dev Returns the number of packages stored on the registry
91
- function numPackageIds() public view returns (uint totalCount);
92
-
93
- /// @dev Returns the number of releases for a given package name on the registry
94
- /// @param packageName Package name
95
- function numReleaseIds(string memory packageName) public view returns (uint totalCount);
96
- }
@@ -1,33 +0,0 @@
1
- {
2
- "language": "Solidity",
3
- "settings": {
4
- "outputSelection": {
5
- "*": {
6
- "*": [
7
- "abi",
8
- "evm.bytecode.object",
9
- "evm.deployedBytecode",
10
- "metadata",
11
- "devdoc"
12
- ]
13
- }
14
- }
15
- },
16
- "sources": {
17
- "PackageRegistryInterface.sol": {
18
- "urls": [
19
- "/Users/nickgheorghita/ethereum/ethpm-cli/projects/simple-registry/contracts/PackageRegistryInterface.sol"
20
- ]
21
- },
22
- "PackageRegistry.sol": {
23
- "urls": [
24
- "/Users/nickgheorghita/ethereum/ethpm-cli/projects/simple-registry/contracts/PackageRegistry.sol"
25
- ]
26
- },
27
- "Ownable.sol": {
28
- "urls": [
29
- "/Users/nickgheorghita/ethereum/ethpm-cli/projects/simple-registry/contracts/Ownable.sol"
30
- ]
31
- }
32
- }
33
- }