web3 6.20.3__py3-none-any.whl → 7.0.0__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 (270) hide show
  1. ens/__init__.py +13 -2
  2. ens/_normalization.py +2 -17
  3. ens/async_ens.py +33 -21
  4. ens/base_ens.py +3 -1
  5. ens/ens.py +16 -11
  6. ens/exceptions.py +16 -29
  7. ens/specs/nf.json +1 -1
  8. ens/specs/normalization_spec.json +1 -1
  9. ens/utils.py +52 -63
  10. web3/__init__.py +20 -24
  11. web3/_utils/abi.py +115 -271
  12. web3/_utils/async_transactions.py +7 -4
  13. web3/_utils/batching.py +217 -0
  14. web3/_utils/blocks.py +6 -2
  15. web3/_utils/caching.py +128 -5
  16. web3/_utils/compat/__init__.py +2 -3
  17. web3/_utils/contract_sources/compile_contracts.py +1 -1
  18. web3/_utils/contract_sources/contract_data/arrays_contract.py +3 -3
  19. web3/_utils/contract_sources/contract_data/bytes_contracts.py +5 -5
  20. web3/_utils/contract_sources/contract_data/constructor_contracts.py +7 -7
  21. web3/_utils/contract_sources/contract_data/contract_caller_tester.py +3 -3
  22. web3/_utils/contract_sources/contract_data/emitter_contract.py +3 -3
  23. web3/_utils/contract_sources/contract_data/event_contracts.py +5 -5
  24. web3/_utils/contract_sources/contract_data/extended_resolver.py +3 -3
  25. web3/_utils/contract_sources/contract_data/fallback_function_contract.py +3 -3
  26. web3/_utils/contract_sources/contract_data/function_name_tester_contract.py +3 -3
  27. web3/_utils/contract_sources/contract_data/math_contract.py +3 -3
  28. web3/_utils/contract_sources/contract_data/offchain_lookup.py +3 -3
  29. web3/_utils/contract_sources/contract_data/offchain_resolver.py +3 -3
  30. web3/_utils/contract_sources/contract_data/panic_errors_contract.py +3 -3
  31. web3/_utils/contract_sources/contract_data/payable_tester.py +3 -3
  32. web3/_utils/contract_sources/contract_data/receive_function_contracts.py +5 -5
  33. web3/_utils/contract_sources/contract_data/reflector_contracts.py +3 -3
  34. web3/_utils/contract_sources/contract_data/revert_contract.py +3 -3
  35. web3/_utils/contract_sources/contract_data/simple_resolver.py +3 -3
  36. web3/_utils/contract_sources/contract_data/storage_contract.py +3 -3
  37. web3/_utils/contract_sources/contract_data/string_contract.py +3 -3
  38. web3/_utils/contract_sources/contract_data/tuple_contracts.py +5 -5
  39. web3/_utils/contracts.py +130 -236
  40. web3/_utils/datatypes.py +5 -1
  41. web3/_utils/decorators.py +13 -23
  42. web3/_utils/empty.py +1 -1
  43. web3/_utils/encoding.py +16 -12
  44. web3/_utils/ens.py +2 -1
  45. web3/_utils/error_formatters_utils.py +5 -3
  46. web3/_utils/events.py +66 -69
  47. web3/_utils/fee_utils.py +1 -3
  48. web3/_utils/filters.py +24 -22
  49. web3/_utils/formatters.py +2 -2
  50. web3/_utils/http.py +5 -3
  51. web3/_utils/http_session_manager.py +303 -0
  52. web3/_utils/math.py +14 -15
  53. web3/_utils/method_formatters.py +34 -36
  54. web3/_utils/module.py +2 -1
  55. web3/_utils/module_testing/__init__.py +0 -3
  56. web3/_utils/module_testing/eth_module.py +695 -643
  57. web3/_utils/module_testing/module_testing_utils.py +61 -34
  58. web3/_utils/module_testing/persistent_connection_provider.py +56 -25
  59. web3/_utils/module_testing/utils.py +258 -0
  60. web3/_utils/module_testing/web3_module.py +438 -17
  61. web3/_utils/normalizers.py +13 -11
  62. web3/_utils/rpc_abi.py +5 -32
  63. web3/_utils/threads.py +8 -7
  64. web3/_utils/transactions.py +14 -12
  65. web3/_utils/type_conversion.py +5 -1
  66. web3/_utils/validation.py +17 -17
  67. web3/auto/gethdev.py +7 -2
  68. web3/beacon/__init__.py +6 -1
  69. web3/beacon/async_beacon.py +9 -5
  70. web3/beacon/{main.py → beacon.py} +7 -5
  71. web3/contract/__init__.py +7 -0
  72. web3/contract/async_contract.py +47 -46
  73. web3/contract/base_contract.py +183 -158
  74. web3/contract/contract.py +49 -43
  75. web3/contract/utils.py +203 -59
  76. web3/datastructures.py +79 -31
  77. web3/eth/__init__.py +7 -0
  78. web3/eth/async_eth.py +39 -51
  79. web3/eth/base_eth.py +17 -10
  80. web3/eth/eth.py +30 -68
  81. web3/exceptions.py +108 -82
  82. web3/gas_strategies/time_based.py +8 -6
  83. web3/geth.py +1 -254
  84. web3/main.py +75 -122
  85. web3/manager.py +316 -146
  86. web3/method.py +38 -31
  87. web3/middleware/__init__.py +67 -89
  88. web3/middleware/attrdict.py +36 -49
  89. web3/middleware/base.py +174 -0
  90. web3/middleware/buffered_gas_estimate.py +20 -21
  91. web3/middleware/filter.py +157 -117
  92. web3/middleware/formatting.py +124 -108
  93. web3/middleware/gas_price_strategy.py +20 -32
  94. web3/middleware/names.py +29 -26
  95. web3/middleware/proof_of_authority.py +68 -0
  96. web3/middleware/pythonic.py +2 -2
  97. web3/middleware/signing.py +74 -89
  98. web3/middleware/stalecheck.py +52 -79
  99. web3/middleware/validation.py +5 -13
  100. web3/module.py +54 -10
  101. web3/providers/__init__.py +10 -6
  102. web3/providers/async_base.py +117 -39
  103. web3/providers/auto.py +3 -3
  104. web3/providers/base.py +89 -33
  105. web3/providers/eth_tester/__init__.py +5 -0
  106. web3/providers/eth_tester/defaults.py +1 -64
  107. web3/providers/eth_tester/main.py +99 -31
  108. web3/providers/eth_tester/middleware.py +45 -73
  109. web3/providers/ipc.py +42 -46
  110. web3/providers/{websocket/websocket.py → legacy_websocket.py} +32 -7
  111. web3/providers/persistent/__init__.py +22 -0
  112. web3/providers/persistent/async_ipc.py +153 -0
  113. web3/providers/{persistent.py → persistent/persistent.py} +106 -25
  114. web3/providers/persistent/persistent_connection.py +84 -0
  115. web3/providers/{websocket → persistent}/request_processor.py +94 -32
  116. web3/providers/persistent/utils.py +43 -0
  117. web3/providers/{websocket/websocket_v2.py → persistent/websocket.py} +29 -28
  118. web3/providers/rpc/__init__.py +11 -0
  119. web3/providers/rpc/async_rpc.py +171 -0
  120. web3/providers/rpc/rpc.py +179 -0
  121. web3/providers/rpc/utils.py +92 -0
  122. web3/testing.py +4 -4
  123. web3/tools/benchmark/main.py +22 -22
  124. web3/tools/benchmark/node.py +2 -8
  125. web3/tools/benchmark/reporting.py +2 -2
  126. web3/tools/benchmark/utils.py +1 -1
  127. web3/tracing.py +9 -5
  128. web3/types.py +30 -107
  129. web3/utils/__init__.py +58 -5
  130. web3/utils/abi.py +575 -10
  131. web3/utils/async_exception_handling.py +19 -7
  132. web3/utils/caching.py +32 -13
  133. web3/utils/exception_handling.py +7 -5
  134. {web3-6.20.3.dist-info → web3-7.0.0.dist-info}/LICENSE +1 -1
  135. web3-7.0.0.dist-info/METADATA +112 -0
  136. web3-7.0.0.dist-info/RECORD +167 -0
  137. {web3-6.20.3.dist-info → web3-7.0.0.dist-info}/top_level.txt +0 -1
  138. ethpm/__init__.py +0 -20
  139. ethpm/_utils/__init__.py +0 -0
  140. ethpm/_utils/backend.py +0 -93
  141. ethpm/_utils/cache.py +0 -44
  142. ethpm/_utils/chains.py +0 -119
  143. ethpm/_utils/contract.py +0 -35
  144. ethpm/_utils/deployments.py +0 -145
  145. ethpm/_utils/ipfs.py +0 -116
  146. ethpm/_utils/protobuf/__init__.py +0 -0
  147. ethpm/_utils/protobuf/ipfs_file_pb2.py +0 -33
  148. ethpm/_utils/registry.py +0 -29
  149. ethpm/assets/__init__.py +0 -0
  150. ethpm/assets/ens/v3.json +0 -1
  151. ethpm/assets/escrow/with_bytecode_v3.json +0 -1
  152. ethpm/assets/ipfs_file.proto +0 -32
  153. ethpm/assets/owned/output_v3.json +0 -1
  154. ethpm/assets/owned/with_contract_type_v3.json +0 -1
  155. ethpm/assets/registry/contracts/Authority.sol +0 -156
  156. ethpm/assets/registry/contracts/IndexedOrderedSetLib.sol +0 -106
  157. ethpm/assets/registry/contracts/PackageDB.sol +0 -225
  158. ethpm/assets/registry/contracts/PackageRegistry.sol +0 -361
  159. ethpm/assets/registry/contracts/PackageRegistryInterface.sol +0 -97
  160. ethpm/assets/registry/contracts/ReleaseDB.sol +0 -309
  161. ethpm/assets/registry/contracts/ReleaseValidator.sol +0 -152
  162. ethpm/assets/registry/solc_input.json +0 -1
  163. ethpm/assets/registry/solc_output.json +0 -1
  164. ethpm/assets/registry/v3.json +0 -1
  165. ethpm/assets/safe-math-lib/v3-strict-no-deployments.json +0 -1
  166. ethpm/assets/simple-registry/contracts/Ownable.sol +0 -63
  167. ethpm/assets/simple-registry/contracts/PackageRegistry.sol +0 -373
  168. ethpm/assets/simple-registry/contracts/PackageRegistryInterface.sol +0 -96
  169. ethpm/assets/simple-registry/solc_input.json +0 -33
  170. ethpm/assets/simple-registry/solc_output.json +0 -1
  171. ethpm/assets/simple-registry/v3.json +0 -1
  172. ethpm/assets/standard-token/output_v3.json +0 -1
  173. ethpm/assets/standard-token/with_bytecode_v3.json +0 -1
  174. ethpm/assets/vyper_registry/0.1.0.json +0 -1
  175. ethpm/assets/vyper_registry/registry.vy +0 -216
  176. ethpm/assets/vyper_registry/registry_with_delete.vy +0 -244
  177. ethpm/backends/__init__.py +0 -0
  178. ethpm/backends/base.py +0 -43
  179. ethpm/backends/http.py +0 -108
  180. ethpm/backends/ipfs.py +0 -219
  181. ethpm/backends/registry.py +0 -154
  182. ethpm/constants.py +0 -17
  183. ethpm/contract.py +0 -187
  184. ethpm/dependencies.py +0 -58
  185. ethpm/deployments.py +0 -80
  186. ethpm/ethpm-spec/examples/escrow/1.0.0-pretty.json +0 -146
  187. ethpm/ethpm-spec/examples/escrow/1.0.0.json +0 -1
  188. ethpm/ethpm-spec/examples/escrow/contracts/Escrow.sol +0 -32
  189. ethpm/ethpm-spec/examples/escrow/contracts/SafeSendLib.sol +0 -20
  190. ethpm/ethpm-spec/examples/escrow/v3-pretty.json +0 -171
  191. ethpm/ethpm-spec/examples/escrow/v3.json +0 -1
  192. ethpm/ethpm-spec/examples/owned/1.0.0-pretty.json +0 -21
  193. ethpm/ethpm-spec/examples/owned/1.0.0.json +0 -1
  194. ethpm/ethpm-spec/examples/owned/contracts/Owned.sol +0 -12
  195. ethpm/ethpm-spec/examples/owned/v3-pretty.json +0 -27
  196. ethpm/ethpm-spec/examples/owned/v3.json +0 -1
  197. ethpm/ethpm-spec/examples/piper-coin/1.0.0-pretty.json +0 -31
  198. ethpm/ethpm-spec/examples/piper-coin/1.0.0.json +0 -1
  199. ethpm/ethpm-spec/examples/piper-coin/v3-pretty.json +0 -21
  200. ethpm/ethpm-spec/examples/piper-coin/v3.json +0 -1
  201. ethpm/ethpm-spec/examples/safe-math-lib/1.0.0-pretty.json +0 -85
  202. ethpm/ethpm-spec/examples/safe-math-lib/1.0.0.json +0 -1
  203. ethpm/ethpm-spec/examples/safe-math-lib/contracts/SafeMathLib.sol +0 -24
  204. ethpm/ethpm-spec/examples/safe-math-lib/v3-pretty.json +0 -117
  205. ethpm/ethpm-spec/examples/safe-math-lib/v3.json +0 -1
  206. ethpm/ethpm-spec/examples/standard-token/1.0.0-pretty.json +0 -55
  207. ethpm/ethpm-spec/examples/standard-token/1.0.0.json +0 -1
  208. ethpm/ethpm-spec/examples/standard-token/contracts/AbstractToken.sol +0 -20
  209. ethpm/ethpm-spec/examples/standard-token/contracts/StandardToken.sol +0 -84
  210. ethpm/ethpm-spec/examples/standard-token/v3-pretty.json +0 -460
  211. ethpm/ethpm-spec/examples/standard-token/v3.json +0 -1
  212. ethpm/ethpm-spec/examples/transferable/1.0.0-pretty.json +0 -21
  213. ethpm/ethpm-spec/examples/transferable/1.0.0.json +0 -1
  214. ethpm/ethpm-spec/examples/transferable/contracts/Transferable.sol +0 -14
  215. ethpm/ethpm-spec/examples/transferable/v3-pretty.json +0 -27
  216. ethpm/ethpm-spec/examples/transferable/v3.json +0 -1
  217. ethpm/ethpm-spec/examples/wallet/1.0.0-pretty.json +0 -120
  218. ethpm/ethpm-spec/examples/wallet/1.0.0.json +0 -1
  219. ethpm/ethpm-spec/examples/wallet/contracts/Wallet.sol +0 -41
  220. ethpm/ethpm-spec/examples/wallet/v3-pretty.json +0 -181
  221. ethpm/ethpm-spec/examples/wallet/v3.json +0 -1
  222. ethpm/ethpm-spec/examples/wallet-with-send/1.0.0-pretty.json +0 -135
  223. ethpm/ethpm-spec/examples/wallet-with-send/1.0.0.json +0 -1
  224. ethpm/ethpm-spec/examples/wallet-with-send/contracts/WalletWithSend.sol +0 -18
  225. ethpm/ethpm-spec/examples/wallet-with-send/v3-pretty.json +0 -207
  226. ethpm/ethpm-spec/examples/wallet-with-send/v3.json +0 -1
  227. ethpm/ethpm-spec/spec/package.spec.json +0 -379
  228. ethpm/ethpm-spec/spec/v3.spec.json +0 -483
  229. ethpm/exceptions.py +0 -68
  230. ethpm/package.py +0 -438
  231. ethpm/tools/__init__.py +0 -4
  232. ethpm/tools/builder.py +0 -930
  233. ethpm/tools/checker.py +0 -312
  234. ethpm/tools/get_manifest.py +0 -19
  235. ethpm/uri.py +0 -141
  236. ethpm/validation/__init__.py +0 -0
  237. ethpm/validation/manifest.py +0 -146
  238. ethpm/validation/misc.py +0 -39
  239. ethpm/validation/package.py +0 -80
  240. ethpm/validation/uri.py +0 -163
  241. web3/_utils/contract_sources/contract_data/address_reflector.py +0 -29
  242. web3/_utils/miner.py +0 -88
  243. web3/_utils/module_testing/go_ethereum_personal_module.py +0 -323
  244. web3/_utils/request.py +0 -265
  245. web3/middleware/abi.py +0 -11
  246. web3/middleware/async_cache.py +0 -99
  247. web3/middleware/cache.py +0 -374
  248. web3/middleware/exception_handling.py +0 -49
  249. web3/middleware/exception_retry_request.py +0 -188
  250. web3/middleware/fixture.py +0 -190
  251. web3/middleware/geth_poa.py +0 -81
  252. web3/middleware/normalize_request_parameters.py +0 -11
  253. web3/middleware/simulate_unmined_transaction.py +0 -43
  254. web3/pm.py +0 -602
  255. web3/providers/async_rpc.py +0 -99
  256. web3/providers/rpc.py +0 -98
  257. web3/providers/websocket/__init__.py +0 -11
  258. web3/providers/websocket/websocket_connection.py +0 -42
  259. web3/tools/__init__.py +0 -4
  260. web3/tools/pytest_ethereum/__init__.py +0 -0
  261. web3/tools/pytest_ethereum/_utils.py +0 -145
  262. web3/tools/pytest_ethereum/deployer.py +0 -48
  263. web3/tools/pytest_ethereum/exceptions.py +0 -22
  264. web3/tools/pytest_ethereum/linker.py +0 -128
  265. web3/tools/pytest_ethereum/plugins.py +0 -33
  266. web3-6.20.3.dist-info/METADATA +0 -104
  267. web3-6.20.3.dist-info/RECORD +0 -283
  268. web3-6.20.3.dist-info/entry_points.txt +0 -2
  269. /web3/_utils/{function_identifiers.py → abi_element_identifiers.py} +0 -0
  270. {web3-6.20.3.dist-info → web3-7.0.0.dist-info}/WHEEL +0 -0
@@ -1,225 +0,0 @@
1
- pragma solidity ^0.4.24;
2
- pragma experimental "v0.5.0";
3
-
4
- import {IndexedOrderedSetLib} from "./IndexedOrderedSetLib.sol";
5
- import {Authorized} from "./Authority.sol";
6
-
7
-
8
- /// @title Database contract for a package index package data.
9
- /// @author Tim Coulter <tim.coulter@consensys.net>, Piper Merriam <pipermerriam@gmail.com>
10
- contract PackageDB is Authorized {
11
- using IndexedOrderedSetLib for IndexedOrderedSetLib.IndexedOrderedSet;
12
-
13
- struct Package {
14
- bool exists;
15
- uint createdAt;
16
- uint updatedAt;
17
- string name;
18
- address owner;
19
- }
20
-
21
- // Package Data: (nameHash => value)
22
- mapping (bytes32 => Package) _recordedPackages;
23
- IndexedOrderedSetLib.IndexedOrderedSet _allPackageNameHashes;
24
-
25
- // Events
26
- event PackageReleaseAdd(bytes32 indexed nameHash, bytes32 indexed releaseHash);
27
- event PackageReleaseRemove(bytes32 indexed nameHash, bytes32 indexed releaseHash);
28
- event PackageCreate(bytes32 indexed nameHash);
29
- event PackageDelete(bytes32 indexed nameHash, string reason);
30
- event PackageOwnerUpdate(bytes32 indexed nameHash, address indexed oldOwner, address indexed newOwner);
31
-
32
- /*
33
- * Modifiers
34
- */
35
- modifier onlyIfPackageExists(bytes32 nameHash) {
36
- require(packageExists(nameHash), "escape:PackageDB:package-not-found");
37
- _;
38
- }
39
-
40
- //
41
- // +-------------+
42
- // | Write API |
43
- // +-------------+
44
- //
45
-
46
- /// @dev Creates or updates a release for a package. Returns success.
47
- /// @param name Package name
48
- function setPackage(string name)
49
- public
50
- auth
51
- returns (bool)
52
- {
53
- // Hash the name and the version for storing data
54
- bytes32 nameHash = hashName(name);
55
-
56
- Package storage package = _recordedPackages[nameHash];
57
-
58
- // Mark the package as existing if it isn't already tracked.
59
- if (!packageExists(nameHash)) {
60
-
61
- // Set package data
62
- package.exists = true;
63
- package.createdAt = block.timestamp; // solium-disable-line security/no-block-members
64
- package.name = name;
65
-
66
- // Add the nameHash to the list of all package nameHashes.
67
- _allPackageNameHashes.add(nameHash);
68
-
69
- emit PackageCreate(nameHash);
70
- }
71
-
72
- package.updatedAt = block.timestamp; // solium-disable-line security/no-block-members
73
-
74
- return true;
75
- }
76
-
77
- /// @dev Removes a package from the package db. Packages with existing releases may not be removed. Returns success.
78
- /// @param nameHash The name hash of a package.
79
- function removePackage(bytes32 nameHash, string reason)
80
- public
81
- auth
82
- onlyIfPackageExists(nameHash)
83
- returns (bool)
84
- {
85
- emit PackageDelete(nameHash, reason);
86
-
87
- delete _recordedPackages[nameHash];
88
- _allPackageNameHashes.remove(nameHash);
89
-
90
- return true;
91
- }
92
-
93
- /// @dev Sets the owner of a package to the provided address. Returns success.
94
- /// @param nameHash The name hash of a package.
95
- /// @param newPackageOwner The address of the new owner.
96
- function setPackageOwner(bytes32 nameHash, address newPackageOwner)
97
- public
98
- auth
99
- onlyIfPackageExists(nameHash)
100
- returns (bool)
101
- {
102
- emit PackageOwnerUpdate(nameHash, _recordedPackages[nameHash].owner, newPackageOwner);
103
-
104
- _recordedPackages[nameHash].owner = newPackageOwner;
105
- _recordedPackages[nameHash].updatedAt = block.timestamp; // solium-disable-line security/no-block-members
106
-
107
- return true;
108
- }
109
-
110
- //
111
- // +------------+
112
- // | Read API |
113
- // +------------+
114
- //
115
-
116
- /// @dev Query the existence of a package with the given name. Returns boolean indicating whether the package exists.
117
- /// @param nameHash The name hash of a package.
118
- function packageExists(bytes32 nameHash)
119
- public
120
- view
121
- returns (bool)
122
- {
123
- return _recordedPackages[nameHash].exists;
124
- }
125
-
126
- /// @dev Return the total number of packages
127
- function getNumPackages()
128
- public
129
- view
130
- returns (uint)
131
- {
132
- return _allPackageNameHashes.size();
133
- }
134
-
135
- /// @dev Returns package namehash at the provided index from the set of all known name hashes.
136
- /// @param idx The index of the package name hash to retrieve.
137
- function getPackageNameHash(uint idx)
138
- public
139
- view
140
- returns (bytes32)
141
- {
142
- return _allPackageNameHashes.get(idx);
143
- }
144
-
145
- /// @dev Returns information about the package.
146
- /// @param nameHash The name hash to look up.
147
- function getPackageData(bytes32 nameHash)
148
- public
149
- view
150
- onlyIfPackageExists(nameHash)
151
- returns (
152
- address packageOwner,
153
- uint createdAt,
154
- uint updatedAt
155
- )
156
- {
157
- Package storage package = _recordedPackages[nameHash];
158
- return (package.owner, package.createdAt, package.updatedAt);
159
- }
160
-
161
- /// @dev Returns the package name for the given namehash
162
- /// @param nameHash The name hash to look up.
163
- function getPackageName(bytes32 nameHash)
164
- public
165
- view
166
- onlyIfPackageExists(nameHash)
167
- returns (string)
168
- {
169
- return _recordedPackages[nameHash].name;
170
- }
171
-
172
- /// @dev Returns a slice of the array of all package hashes for the named package.
173
- /// @param offset The starting index for the slice.
174
- /// @param limit The length of the slice
175
- function getAllPackageIds(uint _offset, uint limit)
176
- public
177
- view
178
- returns (
179
- bytes32[] packageIds,
180
- uint offset
181
- )
182
- {
183
- bytes32[] memory hashes; // Array of package ids to return
184
- uint cursor = _offset; // Index counter to traverse DB array
185
- uint remaining; // Counter to collect `limit` packages
186
- uint totalPackages = getNumPackages(); // Total number of packages in registry
187
-
188
- // Is request within range?
189
- if (cursor < totalPackages){
190
-
191
- // Get total remaining records
192
- remaining = totalPackages - cursor;
193
-
194
- // Number of records to collect is lesser of `remaining` and `limit`
195
- if (remaining > limit ){
196
- remaining = limit;
197
- }
198
-
199
- // Allocate return array
200
- hashes = new bytes32[](remaining);
201
-
202
- // Collect records. (IndexedOrderedSet manages deletions.)
203
- while(remaining > 0){
204
- bytes32 hash = getPackageNameHash(cursor);
205
- hashes[remaining - 1] = hash;
206
- remaining--;
207
- cursor++;
208
- }
209
- }
210
- return (hashes, cursor);
211
- }
212
-
213
- /*
214
- * Hash Functions
215
- */
216
- /// @dev Returns name hash for a given package name.
217
- /// @param name Package name
218
- function hashName(string name)
219
- public
220
- pure
221
- returns (bytes32)
222
- {
223
- return keccak256(abi.encodePacked(name));
224
- }
225
- }
@@ -1,361 +0,0 @@
1
- pragma solidity ^0.4.24;
2
- pragma experimental "v0.5.0";
3
-
4
-
5
- import {PackageDB} from "./PackageDB.sol";
6
- import {ReleaseDB} from "./ReleaseDB.sol";
7
- import {ReleaseValidator} from "./ReleaseValidator.sol";
8
- import {PackageRegistryInterface} from "./PackageRegistryInterface.sol";
9
- import {Authorized} from "./Authority.sol";
10
-
11
-
12
- /// @title Database contract for a package index.
13
- /// @author Tim Coulter <tim.coulter@consensys.net>, Piper Merriam <pipermerriam@gmail.com>
14
- contract PackageRegistry is Authorized, PackageRegistryInterface {
15
- PackageDB private packageDb;
16
- ReleaseDB private releaseDb;
17
- ReleaseValidator private releaseValidator;
18
-
19
- // Events
20
- event VersionRelease(string packageName, string version, string manifestURI);
21
- event PackageTransfer(address indexed oldOwner, address indexed newOwner);
22
-
23
- //
24
- // Administrative API
25
- //
26
- /// @dev Sets the address of the PackageDb contract.
27
- /// @param newPackageDb The address to set for the PackageDb.
28
- function setPackageDb(address newPackageDb)
29
- public
30
- auth
31
- returns (bool)
32
- {
33
- packageDb = PackageDB(newPackageDb);
34
- return true;
35
- }
36
-
37
- /// @dev Sets the address of the ReleaseDb contract.
38
- /// @param newReleaseDb The address to set for the ReleaseDb.
39
- function setReleaseDb(address newReleaseDb)
40
- public
41
- auth
42
- returns (bool)
43
- {
44
- releaseDb = ReleaseDB(newReleaseDb);
45
- return true;
46
- }
47
-
48
- /// @dev Sets the address of the ReleaseValidator contract.
49
- /// @param newReleaseValidator The address to set for the ReleaseValidator.
50
- function setReleaseValidator(address newReleaseValidator)
51
- public
52
- auth
53
- returns (bool)
54
- {
55
- releaseValidator = ReleaseValidator(newReleaseValidator);
56
- return true;
57
- }
58
-
59
- //
60
- // +-------------+
61
- // | Write API |
62
- // +-------------+
63
- //
64
- /// @dev Creates a a new release for the named package. If this is the first release for the given package then this will also assign msg.sender as the owner of the package. Returns success.
65
- /// @notice Will create a new release the given package with the given release information.
66
- /// @param packageName Package name
67
- /// @param version Version string (ex: '1.0.0')
68
- /// @param manifestURI The URI for the release manifest for this release.
69
- function release(
70
- string packageName,
71
- string version,
72
- string manifestURI
73
- )
74
- public
75
- auth
76
- returns (bytes32 releaseId)
77
- {
78
- require(address(packageDb) != 0x0, "escape:PackageIndex:package-db-not-set");
79
- require(address(releaseDb) != 0x0, "escape:PackageIndex:release-db-not-set");
80
- require(address(releaseValidator) != 0x0, "escape:PackageIndex:release-validator-not-set");
81
-
82
- bytes32 versionHash = releaseDb.hashVersion(version);
83
-
84
- // If the version for this release is not in the version database, populate
85
- // it. This must happen prior to validation to ensure that the version is
86
- // present in the releaseDb.
87
- if (!releaseDb.versionExists(versionHash)) {
88
- releaseDb.setVersion(version);
89
- }
90
-
91
- // Run release validator. This method reverts with an error message string
92
- // on failure.
93
- releaseValidator.validateRelease(
94
- packageDb,
95
- releaseDb,
96
- msg.sender,
97
- packageName,
98
- version,
99
- manifestURI
100
- );
101
-
102
- // Compute hashes
103
- bool _packageExists = packageExists(packageName);
104
-
105
- // Both creates the package if it is new as well as updating the updatedAt
106
- // timestamp on the package.
107
- packageDb.setPackage(packageName);
108
-
109
- bytes32 nameHash = packageDb.hashName(packageName);
110
-
111
- // If the package does not yet exist create it and set the owner
112
- if (!_packageExists) {
113
- packageDb.setPackageOwner(nameHash, msg.sender);
114
- }
115
-
116
- // Create the release and add it to the list of package release hashes.
117
- releaseDb.setRelease(nameHash, versionHash, manifestURI);
118
-
119
- // Log the release.
120
- releaseId = releaseDb.hashRelease(nameHash, versionHash);
121
- emit VersionRelease(packageName, version, manifestURI);
122
-
123
- return releaseId;
124
- }
125
-
126
- /// @dev Transfers package ownership to the provider new owner address.
127
- /// @notice Will transfer ownership of this package to the provided new owner address.
128
- /// @param name Package name
129
- /// @param newPackageOwner The address of the new owner.
130
- function transferPackageOwner(string name, address newPackageOwner)
131
- public
132
- auth
133
- returns (bool)
134
- {
135
- if (isPackageOwner(name, msg.sender)) {
136
- // Only the package owner may transfer package ownership.
137
- return false;
138
- }
139
-
140
- // Lookup the current owner
141
- address packageOwner;
142
- (packageOwner,,,) = getPackageData(name);
143
-
144
- // Log the transfer
145
- emit PackageTransfer(packageOwner, newPackageOwner);
146
-
147
- // Update the owner.
148
- packageDb.setPackageOwner(packageDb.hashName(name), newPackageOwner);
149
-
150
- return true;
151
- }
152
-
153
- //
154
- // +------------+
155
- // | Read API |
156
- // +------------+
157
- //
158
-
159
- /// @dev Returns the address of the packageDb
160
- function getPackageDb()
161
- public
162
- view
163
- returns (address)
164
- {
165
- return address(packageDb);
166
- }
167
-
168
- /// @dev Returns the address of the releaseDb
169
- function getReleaseDb()
170
- public
171
- view
172
- returns (address)
173
- {
174
- return address(releaseDb);
175
- }
176
-
177
- /// @dev Returns the address of the releaseValidator
178
- function getReleaseValidator()
179
- public
180
- view
181
- returns (address)
182
- {
183
- return address(releaseValidator);
184
- }
185
-
186
- /// @dev Query the existence of a package with the given name. Returns boolean indicating whether the package exists.
187
- /// @param name Package name
188
- function packageExists(string name)
189
- public
190
- view
191
- returns (bool)
192
- {
193
- return packageDb.packageExists(packageDb.hashName(name));
194
- }
195
-
196
- /// @dev Query the existence of a release at the provided version for the named package. Returns boolean indicating whether such a release exists.
197
- /// @param name Package name
198
- /// @param version Version string (ex: '1.0.0')
199
- function releaseExists(
200
- string name,
201
- string version
202
- )
203
- public
204
- view
205
- returns (bool)
206
- {
207
- bytes32 nameHash = packageDb.hashName(name);
208
- bytes32 versionHash = releaseDb.hashVersion(version);
209
- return releaseDb.releaseExists(releaseDb.hashRelease(nameHash, versionHash));
210
- }
211
-
212
- /// @dev Returns a slice of the array of all package hashes for the named package.
213
- /// @param offset The starting index for the slice.
214
- /// @param limit The length of the slice
215
- function getAllPackageIds(uint offset, uint limit)
216
- public
217
- view
218
- returns(
219
- bytes32[] packageIds,
220
- uint pointer
221
- )
222
- {
223
- return packageDb.getAllPackageIds(offset, limit);
224
- }
225
-
226
- /// @dev Retrieves the name for the given name hash.
227
- /// @param packageId The name hash of package to lookup the name for.
228
- function getPackageName(bytes32 packageId)
229
- public
230
- view
231
- returns (string packageName)
232
- {
233
- return packageDb.getPackageName(packageId);
234
- }
235
-
236
- /// @dev Returns the package data.
237
- /// @param name Package name
238
- function getPackageData(string name)
239
- public
240
- view
241
- returns (
242
- address packageOwner,
243
- uint createdAt,
244
- uint numReleases,
245
- uint updatedAt
246
- )
247
- {
248
- bytes32 nameHash = packageDb.hashName(name);
249
- (packageOwner, createdAt, updatedAt) = packageDb.getPackageData(nameHash);
250
- numReleases = releaseDb.getNumReleasesForNameHash(nameHash);
251
- return (packageOwner, createdAt, numReleases, updatedAt);
252
- }
253
-
254
- /// @dev Returns the release data for the release associated with the given release hash.
255
- /// @param releaseId The release hash.
256
- function getReleaseData(bytes32 releaseId)
257
- public
258
- view
259
- returns (
260
- string packageName,
261
- string version,
262
- string manifestURI
263
- )
264
- {
265
- bytes32 versionHash;
266
- bytes32 nameHash;
267
- (nameHash,versionHash, ,) = releaseDb.getReleaseData(releaseId);
268
-
269
- packageName = packageDb.getPackageName(nameHash);
270
- version = releaseDb.getVersion(versionHash);
271
- manifestURI = releaseDb.getManifestURI(releaseId);
272
-
273
- return (packageName, version, manifestURI);
274
- }
275
-
276
- /// @dev Returns a slice of the array of all package hashes for the named package.
277
- /// @param offset The starting index for the slice.
278
- /// @param limit The length of the slice
279
- function getAllReleaseIds(string packageName, uint offset, uint limit)
280
- public
281
- view
282
- returns (
283
- bytes32[] releaseIds,
284
- uint pointer
285
- )
286
- {
287
- bytes32 nameHash = packageDb.hashName(packageName);
288
- return releaseDb.getAllReleaseIds(nameHash, offset, limit);
289
- }
290
-
291
- /// @dev Returns release id that *would* be generated for a name and version pair on `release`.
292
- /// @param packageName Package name
293
- /// @param version Version string (ex: '1.0.0')
294
- function generateReleaseId(string packageName, string version)
295
- public
296
- view
297
- returns (bytes32 releaseId)
298
- {
299
- bytes32 nameHash = packageDb.hashName(packageName);
300
- bytes32 versionHash = releaseDb.hashVersion(version);
301
- return keccak256(abi.encodePacked(nameHash, versionHash));
302
- }
303
-
304
- /// @dev Returns the release id for a given name and version pair if present on registry.
305
- /// @param packageName Package name
306
- /// @param version Version string(ex: '1.0.0')
307
- function getReleaseId(string packageName, string version)
308
- public
309
- view
310
- returns (bytes32 releaseId)
311
- {
312
- releaseId = generateReleaseId(packageName, version);
313
- bool _releaseExists = releaseDb.releaseExists(releaseId);
314
- if (!_releaseExists) {
315
- return 0;
316
- }
317
- return releaseId;
318
- }
319
-
320
- /// @dev Returns the number of packages stored on the registry
321
- function numPackageIds()
322
- public
323
- view
324
- returns (uint totalCount)
325
- {
326
- return packageDb.getNumPackages();
327
- }
328
-
329
- /// @dev Returns the number of releases for a given package name on the registry
330
- /// @param packageName Package name
331
- function numReleaseIds(string packageName)
332
- public
333
- view
334
- returns (uint totalCount)
335
- {
336
- bool _packageExists = packageExists(packageName);
337
- if (!_packageExists) {
338
- return 0;
339
- }
340
- bytes32 nameHash = packageDb.hashName(packageName);
341
- return releaseDb.getNumReleasesForNameHash(nameHash);
342
- }
343
-
344
- //
345
- // +----------------+
346
- // | Internal API |
347
- // +----------------+
348
- //
349
- /// @dev Returns boolean whether the provided address is the package owner
350
- /// @param name The name of the package
351
- /// @param _address The address to check
352
- function isPackageOwner(string name, address _address)
353
- internal
354
- view
355
- returns (bool)
356
- {
357
- address packageOwner;
358
- (packageOwner,,,) = getPackageData(name);
359
- return (packageOwner != _address);
360
- }
361
- }
@@ -1,97 +0,0 @@
1
- pragma solidity ^0.4.24;
2
- pragma experimental "v0.5.0";
3
-
4
-
5
- /// @title EIP 1319 Smart Contract Package Registry Interface
6
- /// @author Piper Merriam <pipermerriam@gmail.com>, Christopher Gewecke <christophergewecke@gmail.com>
7
- contract PackageRegistryInterface {
8
-
9
- //
10
- // +-------------+
11
- // | Write API |
12
- // +-------------+
13
- //
14
-
15
- /// @dev Creates a a new release for the named package.
16
- /// @notice Will create a new release the given package with the given release information.
17
- /// @param packageName Package name
18
- /// @param version Version string (ex: 1.0.0)
19
- /// @param manifestURI The URI for the release manifest for this release.
20
- function release(
21
- string packageName,
22
- string version,
23
- string manifestURI
24
- )
25
- public
26
- returns (bytes32 releaseId);
27
-
28
- //
29
- // +------------+
30
- // | Read API |
31
- // +------------+
32
- //
33
-
34
- /// @dev Returns the string name of the package associated with a package id
35
- /// @param packageId The package id to look up
36
- function getPackageName(bytes32 packageId)
37
- public
38
- view
39
- returns (string packageName);
40
-
41
- /// @dev Returns a slice of the array of all package ids for the named package.
42
- /// @param offset The starting index for the slice.
43
- /// @param limit The length of the slice
44
- function getAllPackageIds(uint offset, uint limit)
45
- public
46
- view
47
- returns (
48
- bytes32[] packageIds,
49
- uint pointer
50
- );
51
-
52
- /// @dev Returns a slice of the array of all release hashes for the named package.
53
- /// @param packageName Package name
54
- /// @param offset The starting index for the slice.
55
- /// @param limit The length of the slice
56
- function getAllReleaseIds(string packageName, uint offset, uint limit)
57
- public
58
- view
59
- returns (
60
- bytes32[] releaseIds,
61
- uint pointer
62
- );
63
-
64
- /// @dev Returns the package data for a release.
65
- /// @param releaseId Release id
66
- function getReleaseData(bytes32 releaseId)
67
- public
68
- view
69
- returns (
70
- string packageName,
71
- string version,
72
- string manifestURI
73
- );
74
-
75
- // @dev Returns release id that *would* be generated for a name and version pair on `release`.
76
- // @param packageName Package name
77
- // @param version Version string (ex: '1.0.0')
78
- function generateReleaseId(string packageName, string version)
79
- public
80
- view
81
- returns (bytes32 releaseId);
82
-
83
- /// @dev Returns the release id for a given name and version pair if present on registry.
84
- /// @param packageName Package name
85
- /// @param version Version string(ex: '1.0.0')
86
- function getReleaseId(string packageName, string version)
87
- public
88
- view
89
- returns (bytes32 releaseId);
90
-
91
- /// @dev Returns the number of packages stored on the registry
92
- function numPackageIds() public view returns (uint totalCount);
93
-
94
- /// @dev Returns the number of releases for a given package name on the registry
95
- /// @param packageName Package name
96
- function numReleaseIds(string packageName) public view returns (uint totalCount);
97
- }