web3 7.0.0b1__py3-none-any.whl → 7.7.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.
- ens/__init__.py +13 -2
- ens/_normalization.py +4 -4
- ens/async_ens.py +31 -21
- ens/base_ens.py +3 -1
- ens/contract_data.py +2 -2
- ens/ens.py +14 -11
- ens/exceptions.py +16 -29
- ens/specs/nf.json +1 -1
- ens/specs/normalization_spec.json +1 -1
- ens/utils.py +33 -41
- web3/__init__.py +23 -12
- web3/_utils/abi.py +162 -274
- web3/_utils/async_transactions.py +34 -20
- web3/_utils/batching.py +217 -0
- web3/_utils/blocks.py +6 -2
- web3/_utils/caching/__init__.py +12 -0
- web3/_utils/caching/caching_utils.py +433 -0
- web3/_utils/caching/request_caching_validation.py +287 -0
- web3/_utils/compat/__init__.py +2 -3
- web3/_utils/contract_sources/compile_contracts.py +1 -1
- web3/_utils/contract_sources/contract_data/ambiguous_function_contract.py +42 -0
- web3/_utils/contract_sources/contract_data/arrays_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/bytes_contracts.py +5 -5
- web3/_utils/contract_sources/contract_data/constructor_contracts.py +7 -7
- web3/_utils/contract_sources/contract_data/contract_caller_tester.py +3 -3
- web3/_utils/contract_sources/contract_data/emitter_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/event_contracts.py +50 -5
- web3/_utils/contract_sources/contract_data/extended_resolver.py +3 -3
- web3/_utils/contract_sources/contract_data/fallback_function_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/function_name_tester_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/math_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/offchain_lookup.py +3 -3
- web3/_utils/contract_sources/contract_data/offchain_resolver.py +3 -3
- web3/_utils/contract_sources/contract_data/panic_errors_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/payable_tester.py +3 -3
- web3/_utils/contract_sources/contract_data/receive_function_contracts.py +5 -5
- web3/_utils/contract_sources/contract_data/reflector_contracts.py +3 -3
- web3/_utils/contract_sources/contract_data/revert_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/simple_resolver.py +3 -3
- web3/_utils/contract_sources/contract_data/storage_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/string_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/tuple_contracts.py +5 -5
- web3/_utils/contracts.py +172 -220
- web3/_utils/datatypes.py +5 -1
- web3/_utils/decorators.py +6 -1
- web3/_utils/empty.py +1 -1
- web3/_utils/encoding.py +16 -12
- web3/_utils/error_formatters_utils.py +5 -3
- web3/_utils/events.py +78 -72
- web3/_utils/fee_utils.py +1 -3
- web3/_utils/filters.py +24 -22
- web3/_utils/formatters.py +2 -2
- web3/_utils/http.py +8 -2
- web3/_utils/http_session_manager.py +314 -0
- web3/_utils/math.py +14 -15
- web3/_utils/method_formatters.py +161 -34
- web3/_utils/module.py +2 -1
- web3/_utils/module_testing/__init__.py +3 -2
- web3/_utils/module_testing/eth_module.py +736 -583
- web3/_utils/module_testing/go_ethereum_debug_module.py +128 -0
- web3/_utils/module_testing/module_testing_utils.py +81 -24
- web3/_utils/module_testing/persistent_connection_provider.py +702 -220
- web3/_utils/module_testing/utils.py +114 -33
- web3/_utils/module_testing/web3_module.py +438 -17
- web3/_utils/normalizers.py +13 -11
- web3/_utils/rpc_abi.py +10 -22
- web3/_utils/threads.py +8 -7
- web3/_utils/transactions.py +32 -25
- web3/_utils/type_conversion.py +5 -1
- web3/_utils/validation.py +20 -17
- web3/beacon/__init__.py +5 -0
- web3/beacon/api_endpoints.py +3 -0
- web3/beacon/async_beacon.py +29 -6
- web3/beacon/beacon.py +24 -6
- web3/contract/__init__.py +7 -0
- web3/contract/async_contract.py +285 -82
- web3/contract/base_contract.py +556 -258
- web3/contract/contract.py +295 -84
- web3/contract/utils.py +251 -55
- web3/datastructures.py +56 -41
- web3/eth/__init__.py +7 -0
- web3/eth/async_eth.py +89 -69
- web3/eth/base_eth.py +7 -3
- web3/eth/eth.py +43 -66
- web3/exceptions.py +158 -83
- web3/gas_strategies/time_based.py +8 -6
- web3/geth.py +53 -184
- web3/main.py +77 -43
- web3/manager.py +368 -101
- web3/method.py +43 -15
- web3/middleware/__init__.py +26 -8
- web3/middleware/attrdict.py +12 -22
- web3/middleware/base.py +55 -2
- web3/middleware/filter.py +45 -23
- web3/middleware/formatting.py +6 -3
- web3/middleware/names.py +4 -1
- web3/middleware/signing.py +15 -6
- web3/middleware/stalecheck.py +2 -1
- web3/module.py +62 -26
- web3/providers/__init__.py +21 -0
- web3/providers/async_base.py +93 -38
- web3/providers/base.py +85 -40
- web3/providers/eth_tester/__init__.py +5 -0
- web3/providers/eth_tester/defaults.py +2 -55
- web3/providers/eth_tester/main.py +57 -35
- web3/providers/eth_tester/middleware.py +16 -17
- web3/providers/ipc.py +42 -18
- web3/providers/legacy_websocket.py +27 -2
- web3/providers/persistent/__init__.py +7 -0
- web3/providers/persistent/async_ipc.py +61 -121
- web3/providers/persistent/persistent.py +324 -17
- web3/providers/persistent/persistent_connection.py +54 -5
- web3/providers/persistent/request_processor.py +136 -56
- web3/providers/persistent/subscription_container.py +56 -0
- web3/providers/persistent/subscription_manager.py +233 -0
- web3/providers/persistent/websocket.py +29 -92
- web3/providers/rpc/__init__.py +5 -0
- web3/providers/rpc/async_rpc.py +73 -18
- web3/providers/rpc/rpc.py +73 -30
- web3/providers/rpc/utils.py +1 -13
- web3/scripts/install_pre_releases.py +33 -0
- web3/scripts/parse_pygeth_version.py +16 -0
- web3/testing.py +4 -4
- web3/tracing.py +9 -5
- web3/types.py +141 -74
- web3/utils/__init__.py +64 -5
- web3/utils/abi.py +790 -10
- web3/utils/address.py +8 -0
- web3/utils/async_exception_handling.py +20 -11
- web3/utils/caching.py +34 -4
- web3/utils/exception_handling.py +9 -12
- web3/utils/subscriptions.py +285 -0
- {web3-7.0.0b1.dist-info → web3-7.7.0.dist-info}/LICENSE +1 -1
- web3-7.7.0.dist-info/METADATA +130 -0
- web3-7.7.0.dist-info/RECORD +171 -0
- {web3-7.0.0b1.dist-info → web3-7.7.0.dist-info}/WHEEL +1 -1
- {web3-7.0.0b1.dist-info → web3-7.7.0.dist-info}/top_level.txt +0 -1
- ethpm/__init__.py +0 -20
- ethpm/_utils/__init__.py +0 -0
- ethpm/_utils/backend.py +0 -93
- ethpm/_utils/cache.py +0 -44
- ethpm/_utils/chains.py +0 -119
- ethpm/_utils/contract.py +0 -35
- ethpm/_utils/deployments.py +0 -145
- ethpm/_utils/ipfs.py +0 -116
- ethpm/_utils/protobuf/__init__.py +0 -0
- ethpm/_utils/protobuf/ipfs_file_pb2.py +0 -33
- ethpm/_utils/registry.py +0 -29
- ethpm/assets/__init__.py +0 -0
- ethpm/assets/ens/v3.json +0 -1
- ethpm/assets/escrow/with_bytecode_v3.json +0 -1
- ethpm/assets/ipfs_file.proto +0 -32
- ethpm/assets/owned/output_v3.json +0 -1
- ethpm/assets/owned/with_contract_type_v3.json +0 -1
- ethpm/assets/registry/contracts/Authority.sol +0 -156
- ethpm/assets/registry/contracts/IndexedOrderedSetLib.sol +0 -106
- ethpm/assets/registry/contracts/PackageDB.sol +0 -225
- ethpm/assets/registry/contracts/PackageRegistry.sol +0 -361
- ethpm/assets/registry/contracts/PackageRegistryInterface.sol +0 -97
- ethpm/assets/registry/contracts/ReleaseDB.sol +0 -309
- ethpm/assets/registry/contracts/ReleaseValidator.sol +0 -152
- ethpm/assets/registry/solc_input.json +0 -1
- ethpm/assets/registry/solc_output.json +0 -1
- ethpm/assets/registry/v3.json +0 -1
- ethpm/assets/safe-math-lib/v3-strict-no-deployments.json +0 -1
- ethpm/assets/simple-registry/contracts/Ownable.sol +0 -63
- ethpm/assets/simple-registry/contracts/PackageRegistry.sol +0 -373
- ethpm/assets/simple-registry/contracts/PackageRegistryInterface.sol +0 -96
- ethpm/assets/simple-registry/solc_input.json +0 -33
- ethpm/assets/simple-registry/solc_output.json +0 -1
- ethpm/assets/simple-registry/v3.json +0 -1
- ethpm/assets/standard-token/output_v3.json +0 -1
- ethpm/assets/standard-token/with_bytecode_v3.json +0 -1
- ethpm/assets/vyper_registry/0.1.0.json +0 -1
- ethpm/assets/vyper_registry/registry.vy +0 -216
- ethpm/assets/vyper_registry/registry_with_delete.vy +0 -244
- ethpm/backends/__init__.py +0 -0
- ethpm/backends/base.py +0 -43
- ethpm/backends/http.py +0 -108
- ethpm/backends/ipfs.py +0 -219
- ethpm/backends/registry.py +0 -154
- ethpm/constants.py +0 -17
- ethpm/contract.py +0 -187
- ethpm/dependencies.py +0 -58
- ethpm/deployments.py +0 -80
- ethpm/ethpm-spec/examples/escrow/1.0.0-pretty.json +0 -146
- ethpm/ethpm-spec/examples/escrow/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/escrow/contracts/Escrow.sol +0 -32
- ethpm/ethpm-spec/examples/escrow/contracts/SafeSendLib.sol +0 -20
- ethpm/ethpm-spec/examples/escrow/v3-pretty.json +0 -171
- ethpm/ethpm-spec/examples/escrow/v3.json +0 -1
- ethpm/ethpm-spec/examples/owned/1.0.0-pretty.json +0 -21
- ethpm/ethpm-spec/examples/owned/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/owned/contracts/Owned.sol +0 -12
- ethpm/ethpm-spec/examples/owned/v3-pretty.json +0 -27
- ethpm/ethpm-spec/examples/owned/v3.json +0 -1
- ethpm/ethpm-spec/examples/piper-coin/1.0.0-pretty.json +0 -31
- ethpm/ethpm-spec/examples/piper-coin/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/piper-coin/v3-pretty.json +0 -21
- ethpm/ethpm-spec/examples/piper-coin/v3.json +0 -1
- ethpm/ethpm-spec/examples/safe-math-lib/1.0.0-pretty.json +0 -85
- ethpm/ethpm-spec/examples/safe-math-lib/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/safe-math-lib/contracts/SafeMathLib.sol +0 -24
- ethpm/ethpm-spec/examples/safe-math-lib/v3-pretty.json +0 -117
- ethpm/ethpm-spec/examples/safe-math-lib/v3.json +0 -1
- ethpm/ethpm-spec/examples/standard-token/1.0.0-pretty.json +0 -55
- ethpm/ethpm-spec/examples/standard-token/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/standard-token/contracts/AbstractToken.sol +0 -20
- ethpm/ethpm-spec/examples/standard-token/contracts/StandardToken.sol +0 -84
- ethpm/ethpm-spec/examples/standard-token/v3-pretty.json +0 -460
- ethpm/ethpm-spec/examples/standard-token/v3.json +0 -1
- ethpm/ethpm-spec/examples/transferable/1.0.0-pretty.json +0 -21
- ethpm/ethpm-spec/examples/transferable/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/transferable/contracts/Transferable.sol +0 -14
- ethpm/ethpm-spec/examples/transferable/v3-pretty.json +0 -27
- ethpm/ethpm-spec/examples/transferable/v3.json +0 -1
- ethpm/ethpm-spec/examples/wallet/1.0.0-pretty.json +0 -120
- ethpm/ethpm-spec/examples/wallet/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/wallet/contracts/Wallet.sol +0 -41
- ethpm/ethpm-spec/examples/wallet/v3-pretty.json +0 -181
- ethpm/ethpm-spec/examples/wallet/v3.json +0 -1
- ethpm/ethpm-spec/examples/wallet-with-send/1.0.0-pretty.json +0 -135
- ethpm/ethpm-spec/examples/wallet-with-send/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/wallet-with-send/contracts/WalletWithSend.sol +0 -18
- ethpm/ethpm-spec/examples/wallet-with-send/v3-pretty.json +0 -207
- ethpm/ethpm-spec/examples/wallet-with-send/v3.json +0 -1
- ethpm/ethpm-spec/spec/package.spec.json +0 -379
- ethpm/ethpm-spec/spec/v3.spec.json +0 -483
- ethpm/exceptions.py +0 -68
- ethpm/package.py +0 -438
- ethpm/tools/__init__.py +0 -4
- ethpm/tools/builder.py +0 -930
- ethpm/tools/checker.py +0 -312
- ethpm/tools/get_manifest.py +0 -19
- ethpm/uri.py +0 -141
- ethpm/validation/__init__.py +0 -0
- ethpm/validation/manifest.py +0 -146
- ethpm/validation/misc.py +0 -39
- ethpm/validation/package.py +0 -80
- ethpm/validation/uri.py +0 -163
- web3/_utils/caching.py +0 -155
- web3/_utils/contract_sources/contract_data/address_reflector.py +0 -29
- web3/_utils/module_testing/go_ethereum_personal_module.py +0 -300
- web3/_utils/request.py +0 -265
- web3/pm.py +0 -602
- web3/tools/__init__.py +0 -4
- web3/tools/benchmark/__init__.py +0 -0
- web3/tools/benchmark/main.py +0 -185
- web3/tools/benchmark/node.py +0 -126
- web3/tools/benchmark/reporting.py +0 -39
- web3/tools/benchmark/utils.py +0 -69
- web3/tools/pytest_ethereum/__init__.py +0 -0
- web3/tools/pytest_ethereum/_utils.py +0 -145
- web3/tools/pytest_ethereum/deployer.py +0 -48
- web3/tools/pytest_ethereum/exceptions.py +0 -22
- web3/tools/pytest_ethereum/linker.py +0 -128
- web3/tools/pytest_ethereum/plugins.py +0 -33
- web3-7.0.0b1.dist-info/METADATA +0 -114
- web3-7.0.0b1.dist-info/RECORD +0 -280
- web3-7.0.0b1.dist-info/entry_points.txt +0 -2
- /web3/_utils/{function_identifiers.py → abi_element_identifiers.py} +0 -0
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
# Vyper Reference Implementation of ERC1319
|
|
2
|
-
|
|
3
|
-
# Structs
|
|
4
|
-
struct Package:
|
|
5
|
-
exists: bool
|
|
6
|
-
createdAt: timestamp
|
|
7
|
-
updatedAt: timestamp
|
|
8
|
-
name: bytes32
|
|
9
|
-
releaseCount: int128
|
|
10
|
-
|
|
11
|
-
struct Release:
|
|
12
|
-
exists: bool
|
|
13
|
-
createdAt: timestamp
|
|
14
|
-
packageId: bytes32
|
|
15
|
-
version: bytes32
|
|
16
|
-
uri: bytes[1000]
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
# Events
|
|
20
|
-
VersionRelease: event({_package: indexed(bytes32), _version: bytes32, _uri: bytes[1000]})
|
|
21
|
-
|
|
22
|
-
owner: public(address)
|
|
23
|
-
|
|
24
|
-
# Package Data: (package_id => value)
|
|
25
|
-
packages: public(map(bytes32, Package))
|
|
26
|
-
|
|
27
|
-
# Release Data: (release_id => value)
|
|
28
|
-
releases: public(map(bytes32, Release))
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
# package_id#release_count => release_id
|
|
32
|
-
packageReleaseIndex: map(bytes32, bytes32)
|
|
33
|
-
# Total number of packages in registry
|
|
34
|
-
packageCount: public(int128)
|
|
35
|
-
# Total number of releases in registry
|
|
36
|
-
releaseCount: public(int128)
|
|
37
|
-
# Total package number (int128) => package_id (bytes32)
|
|
38
|
-
packageIds: map(int128, bytes32)
|
|
39
|
-
# Total release number (int128) => release_id (bytes32)
|
|
40
|
-
releaseIds: map(int128, bytes32)
|
|
41
|
-
|
|
42
|
-
EMPTY_BYTES: bytes32
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
@public
|
|
46
|
-
def __init__():
|
|
47
|
-
self.owner = msg.sender
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@public
|
|
51
|
-
def transferOwner(newOwner: address):
|
|
52
|
-
assert self.owner == msg.sender
|
|
53
|
-
self.owner = newOwner
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
@public
|
|
57
|
-
def getReleaseId(packageName: bytes32, version: bytes32) -> bytes32:
|
|
58
|
-
releaseConcat: bytes[64] = concat(packageName, version)
|
|
59
|
-
releaseId: bytes32 = sha3(releaseConcat)
|
|
60
|
-
assert self.releases[releaseId].exists
|
|
61
|
-
return releaseId
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@public
|
|
65
|
-
def generateReleaseId(packageName: bytes32, version: bytes32) -> bytes32:
|
|
66
|
-
releaseConcat: bytes[64] = concat(packageName, version)
|
|
67
|
-
releaseId: bytes32 = sha3(releaseConcat)
|
|
68
|
-
return releaseId
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
@public
|
|
72
|
-
def getPackageName(packageId: bytes32) -> bytes32:
|
|
73
|
-
assert self.packages[packageId].exists
|
|
74
|
-
return self.packages[packageId].name
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
@public
|
|
78
|
-
def getPackageData(packageName: bytes32) -> (bytes32, bytes32, int128):
|
|
79
|
-
packageId: bytes32 = sha3(packageName)
|
|
80
|
-
assert self.packages[packageId].exists
|
|
81
|
-
return (
|
|
82
|
-
self.packages[packageId].name,
|
|
83
|
-
packageId,
|
|
84
|
-
self.packages[packageId].releaseCount,
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
@public
|
|
89
|
-
def numPackageIds() -> int128:
|
|
90
|
-
return self.packageCount
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
@public
|
|
94
|
-
def numReleaseIds(packageName: bytes32) -> int128:
|
|
95
|
-
packageId: bytes32 = sha3(packageName)
|
|
96
|
-
assert self.packages[packageId].exists
|
|
97
|
-
return self.packages[packageId].releaseCount
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
@public
|
|
101
|
-
def getAllPackageIds(
|
|
102
|
-
offset: uint256, length: uint256
|
|
103
|
-
) -> (bytes32, bytes32, bytes32, bytes32, bytes32):
|
|
104
|
-
offset_int: int128 = convert(offset, int128)
|
|
105
|
-
length_int: int128 = convert(length, int128)
|
|
106
|
-
assert length_int == 5
|
|
107
|
-
assert offset_int <= self.packageCount
|
|
108
|
-
ids: bytes32[5]
|
|
109
|
-
for idx in range(offset_int, offset_int + 4):
|
|
110
|
-
if idx <= self.packageCount:
|
|
111
|
-
packageId: bytes32 = self.packageIds[idx]
|
|
112
|
-
ids[(idx - offset_int)] = packageId
|
|
113
|
-
else:
|
|
114
|
-
ids[(idx - offset_int)] = self.EMPTY_BYTES
|
|
115
|
-
return (ids[0], ids[1], ids[2], ids[3], ids[4])
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
@private
|
|
119
|
-
def generatePackageReleaseId(packageId: bytes32, count: int128) -> bytes32:
|
|
120
|
-
countBytes: bytes32 = convert(count, bytes32)
|
|
121
|
-
packageReleaseTag: bytes[64] = concat(packageId, countBytes)
|
|
122
|
-
packageReleaseId: bytes32 = sha3(packageReleaseTag)
|
|
123
|
-
return packageReleaseId
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
@public
|
|
127
|
-
def getAllReleaseIds(
|
|
128
|
-
packageName: bytes32, offset: uint256, length: uint256
|
|
129
|
-
) -> (bytes32, bytes32, bytes32, bytes32, bytes32):
|
|
130
|
-
offset_int: int128 = convert(offset, int128)
|
|
131
|
-
length_int: int128 = convert(length, int128)
|
|
132
|
-
assert length_int == 5
|
|
133
|
-
packageId: bytes32 = sha3(packageName)
|
|
134
|
-
assert self.packages[packageId].exists
|
|
135
|
-
assert offset_int <= self.packages[packageId].releaseCount
|
|
136
|
-
ids: bytes32[5]
|
|
137
|
-
for idx in range(offset_int, offset_int + 4):
|
|
138
|
-
if idx <= self.packages[packageId].releaseCount:
|
|
139
|
-
packageReleaseId: bytes32 = self.generatePackageReleaseId(
|
|
140
|
-
packageId, (idx + 1)
|
|
141
|
-
)
|
|
142
|
-
releaseId: bytes32 = self.packageReleaseIndex[packageReleaseId]
|
|
143
|
-
ids[(idx - offset_int)] = releaseId
|
|
144
|
-
else:
|
|
145
|
-
ids[(idx - offset_int)] = self.EMPTY_BYTES
|
|
146
|
-
return (ids[0], ids[1], ids[2], ids[3], ids[4])
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
@public
|
|
150
|
-
def getReleaseData(releaseId: bytes32) -> (bytes32, bytes32, bytes[1000]):
|
|
151
|
-
assert self.releases[releaseId].exists
|
|
152
|
-
packageId: bytes32 = self.releases[releaseId].packageId
|
|
153
|
-
return (
|
|
154
|
-
self.packages[packageId].name,
|
|
155
|
-
self.releases[releaseId].version,
|
|
156
|
-
self.releases[releaseId].uri,
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
@private
|
|
161
|
-
def cutRelease(
|
|
162
|
-
releaseId: bytes32,
|
|
163
|
-
packageId: bytes32,
|
|
164
|
-
version: bytes32,
|
|
165
|
-
uri: bytes[1000],
|
|
166
|
-
name: bytes32,
|
|
167
|
-
):
|
|
168
|
-
self.releases[releaseId] = Release({
|
|
169
|
-
exists: True,
|
|
170
|
-
createdAt: block.timestamp,
|
|
171
|
-
packageId: packageId,
|
|
172
|
-
version: version,
|
|
173
|
-
uri: uri,
|
|
174
|
-
})
|
|
175
|
-
self.packages[packageId].releaseCount += 1
|
|
176
|
-
self.releaseIds[self.releaseCount] = releaseId
|
|
177
|
-
self.releaseCount += 1
|
|
178
|
-
packageReleaseId: bytes32 = self.generatePackageReleaseId(
|
|
179
|
-
packageId, self.packages[packageId].releaseCount
|
|
180
|
-
)
|
|
181
|
-
self.packageReleaseIndex[packageReleaseId] = releaseId
|
|
182
|
-
log.VersionRelease(name, version, uri)
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
@public
|
|
186
|
-
def release(packageName: bytes32, version: bytes32, manifestURI: bytes[1000]):
|
|
187
|
-
assert packageName != self.EMPTY_BYTES
|
|
188
|
-
assert version != self.EMPTY_BYTES
|
|
189
|
-
assert len(manifestURI) > 0
|
|
190
|
-
assert self.owner == msg.sender
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
packageId: bytes32 = sha3(packageName)
|
|
194
|
-
releaseId: bytes32 = self.generateReleaseId(packageName, version)
|
|
195
|
-
|
|
196
|
-
if self.packages[packageId].exists == True:
|
|
197
|
-
self.packages[packageId] = Package({
|
|
198
|
-
exists: True,
|
|
199
|
-
createdAt: self.packages[packageId].createdAt,
|
|
200
|
-
updatedAt: block.timestamp,
|
|
201
|
-
name: packageName,
|
|
202
|
-
releaseCount: self.packages[packageId].releaseCount,
|
|
203
|
-
})
|
|
204
|
-
assert self.releases[releaseId].exists == False
|
|
205
|
-
self.cutRelease(releaseId, packageId, version, manifestURI, packageName)
|
|
206
|
-
else:
|
|
207
|
-
self.packages[packageId] = Package({
|
|
208
|
-
exists: True,
|
|
209
|
-
createdAt: block.timestamp,
|
|
210
|
-
updatedAt: block.timestamp,
|
|
211
|
-
name: packageName,
|
|
212
|
-
releaseCount: 0,
|
|
213
|
-
})
|
|
214
|
-
self.packageIds[self.packageCount] = packageId
|
|
215
|
-
self.packageCount += 1
|
|
216
|
-
self.cutRelease(releaseId, packageId, version, manifestURI, packageName)
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
# Vyper Reference Implementation of ERC1319 - with delete
|
|
2
|
-
# Once all the releaseIds of a package are deleted - package namespace is permanently unavailable
|
|
3
|
-
|
|
4
|
-
# Structs
|
|
5
|
-
struct Package:
|
|
6
|
-
exists: bool
|
|
7
|
-
createdAt: timestamp
|
|
8
|
-
updatedAt: timestamp
|
|
9
|
-
name: bytes32
|
|
10
|
-
releaseCount: int128
|
|
11
|
-
|
|
12
|
-
struct Release:
|
|
13
|
-
exists: bool
|
|
14
|
-
createdAt: timestamp
|
|
15
|
-
packageId: bytes32
|
|
16
|
-
version: bytes32
|
|
17
|
-
uri: bytes[1000]
|
|
18
|
-
|
|
19
|
-
# Events
|
|
20
|
-
VersionRelease: event({_package: indexed(bytes32), _version: bytes32, _uri: bytes[1000]})
|
|
21
|
-
|
|
22
|
-
owner: public(address)
|
|
23
|
-
|
|
24
|
-
# Package Data: (package_id => value)
|
|
25
|
-
packages: public(map(bytes32, Package))
|
|
26
|
-
|
|
27
|
-
# Release Data: (release_id => value)
|
|
28
|
-
releases: public(map(bytes32, Release))
|
|
29
|
-
|
|
30
|
-
# package_id#release_count => release_id
|
|
31
|
-
packageReleaseIndex: map(bytes32, bytes32)
|
|
32
|
-
# Total number of packages in registry
|
|
33
|
-
totalPackageCount: public(int128)
|
|
34
|
-
activePackageCount: public(int128)
|
|
35
|
-
# Total number of releases in registry
|
|
36
|
-
totalReleaseCount: public(int128)
|
|
37
|
-
activeReleaseCount: public(int128)
|
|
38
|
-
# Total package number (int128) => package_id (bytes32)
|
|
39
|
-
packageIds: map(int128, bytes32)
|
|
40
|
-
# Total release number (int128) => release_id (bytes32)
|
|
41
|
-
releaseIds: map(int128, bytes32)
|
|
42
|
-
|
|
43
|
-
EMPTY_BYTES: bytes32
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
@public
|
|
47
|
-
def __init__():
|
|
48
|
-
self.owner = msg.sender
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
@public
|
|
52
|
-
def transferOwner(newOwner: address):
|
|
53
|
-
assert self.owner == msg.sender
|
|
54
|
-
self.owner = newOwner
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
@public
|
|
58
|
-
def getReleaseId(packageName: bytes32, version: bytes32) -> bytes32:
|
|
59
|
-
releaseConcat: bytes[64] = concat(packageName, version)
|
|
60
|
-
releaseId: bytes32 = sha3(releaseConcat)
|
|
61
|
-
assert self.releases[releaseId].exists
|
|
62
|
-
return releaseId
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
@public
|
|
66
|
-
def generateReleaseId(packageName: bytes32, version: bytes32) -> bytes32:
|
|
67
|
-
releaseConcat: bytes[64] = concat(packageName, version)
|
|
68
|
-
releaseId: bytes32 = sha3(releaseConcat)
|
|
69
|
-
return releaseId
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
@public
|
|
73
|
-
def getPackageName(packageId: bytes32) -> bytes32:
|
|
74
|
-
assert self.packages[packageId].exists
|
|
75
|
-
return self.packages[packageId].name
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
@public
|
|
79
|
-
def getPackageData(packageName: bytes32) -> (bytes32, bytes32, int128):
|
|
80
|
-
packageId: bytes32 = sha3(packageName)
|
|
81
|
-
assert self.packages[packageId].exists
|
|
82
|
-
return (
|
|
83
|
-
self.packages[packageId].name,
|
|
84
|
-
packageId,
|
|
85
|
-
self.packages[packageId].releaseCount,
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
@public
|
|
90
|
-
def numPackageIds() -> int128:
|
|
91
|
-
return self.activePackageCount
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
@public
|
|
95
|
-
def numReleaseIds(packageName: bytes32) -> int128:
|
|
96
|
-
packageId: bytes32 = sha3(packageName)
|
|
97
|
-
assert self.packages[packageId].exists
|
|
98
|
-
return self.packages[packageId].releaseCount
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
@public
|
|
102
|
-
def getAllPackageIds(
|
|
103
|
-
offset: uint256, length: uint256
|
|
104
|
-
) -> (bytes32, bytes32, bytes32, bytes32, bytes32):
|
|
105
|
-
offset_int: int128 = convert(offset, int128)
|
|
106
|
-
length_int: int128 = convert(length, int128)
|
|
107
|
-
assert length_int == 5
|
|
108
|
-
assert offset_int <= self.activePackageCount
|
|
109
|
-
ids: bytes32[5]
|
|
110
|
-
for idx in range(offset_int, offset_int + 4):
|
|
111
|
-
if idx <= self.activePackageCount:
|
|
112
|
-
packageId: bytes32 = self.packageIds[idx]
|
|
113
|
-
if self.packages[packageId].exists:
|
|
114
|
-
ids[(idx - offset_int)] = packageId
|
|
115
|
-
else:
|
|
116
|
-
ids[(idx - offset_int)] = self.EMPTY_BYTES
|
|
117
|
-
else:
|
|
118
|
-
ids[(idx - offset_int)] = self.EMPTY_BYTES
|
|
119
|
-
return (ids[0], ids[1], ids[2], ids[3], ids[4])
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
@private
|
|
123
|
-
def generatePackageReleaseId(packageId: bytes32, count: int128) -> bytes32:
|
|
124
|
-
countBytes: bytes32 = convert(count, bytes32)
|
|
125
|
-
packageReleaseTag: bytes[64] = concat(packageId, countBytes)
|
|
126
|
-
packageReleaseId: bytes32 = sha3(packageReleaseTag)
|
|
127
|
-
return packageReleaseId
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
@public
|
|
131
|
-
def getAllReleaseIds(
|
|
132
|
-
packageName: bytes32, offset: uint256, length: uint256
|
|
133
|
-
) -> (bytes32, bytes32, bytes32, bytes32, bytes32):
|
|
134
|
-
offset_int: int128 = convert(offset, int128)
|
|
135
|
-
length_int: int128 = convert(length, int128)
|
|
136
|
-
assert length_int == 5
|
|
137
|
-
packageId: bytes32 = sha3(packageName)
|
|
138
|
-
assert self.packages[packageId].exists
|
|
139
|
-
assert offset_int <= self.packages[packageId].releaseCount
|
|
140
|
-
ids: bytes32[5]
|
|
141
|
-
for idx in range(offset_int, offset_int + 4):
|
|
142
|
-
if idx <= self.packages[packageId].releaseCount:
|
|
143
|
-
packageReleaseId: bytes32 = self.generatePackageReleaseId(
|
|
144
|
-
packageId, (idx + 1)
|
|
145
|
-
)
|
|
146
|
-
releaseId: bytes32 = self.packageReleaseIndex[packageReleaseId]
|
|
147
|
-
if self.releases[releaseId].exists:
|
|
148
|
-
ids[(idx - offset_int)] = releaseId
|
|
149
|
-
else:
|
|
150
|
-
ids[(idx - offset_int)] = self.EMPTY_BYTES
|
|
151
|
-
else:
|
|
152
|
-
ids[(idx - offset_int)] = self.EMPTY_BYTES
|
|
153
|
-
return (ids[0], ids[1], ids[2], ids[3], ids[4])
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
@public
|
|
157
|
-
def getReleaseData(releaseId: bytes32) -> (bytes32, bytes32, bytes[1000]):
|
|
158
|
-
assert self.releases[releaseId].exists
|
|
159
|
-
packageId: bytes32 = self.releases[releaseId].packageId
|
|
160
|
-
return (
|
|
161
|
-
self.packages[packageId].name,
|
|
162
|
-
self.releases[releaseId].version,
|
|
163
|
-
self.releases[releaseId].uri,
|
|
164
|
-
)
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
@private
|
|
168
|
-
def cutRelease(
|
|
169
|
-
releaseId: bytes32,
|
|
170
|
-
packageId: bytes32,
|
|
171
|
-
version: bytes32,
|
|
172
|
-
uri: bytes[1000],
|
|
173
|
-
name: bytes32,
|
|
174
|
-
):
|
|
175
|
-
assert self.releases[releaseId].createdAt == 0
|
|
176
|
-
self.releases[releaseId] = Release({
|
|
177
|
-
exists: True,
|
|
178
|
-
createdAt: block.timestamp,
|
|
179
|
-
packageId: packageId,
|
|
180
|
-
version: version,
|
|
181
|
-
uri: uri,
|
|
182
|
-
})
|
|
183
|
-
self.packages[packageId].releaseCount += 1
|
|
184
|
-
self.releaseIds[self.totalReleaseCount] = releaseId
|
|
185
|
-
self.totalReleaseCount += 1
|
|
186
|
-
self.activeReleaseCount += 1
|
|
187
|
-
packageReleaseId: bytes32 = self.generatePackageReleaseId(
|
|
188
|
-
packageId, self.packages[packageId].releaseCount
|
|
189
|
-
)
|
|
190
|
-
self.packageReleaseIndex[packageReleaseId] = releaseId
|
|
191
|
-
log.VersionRelease(name, version, uri)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
@public
|
|
195
|
-
def release(packageName: bytes32, version: bytes32, manifestURI: bytes[1000]):
|
|
196
|
-
assert packageName != self.EMPTY_BYTES
|
|
197
|
-
assert version != self.EMPTY_BYTES
|
|
198
|
-
assert len(manifestURI) > 0
|
|
199
|
-
assert self.owner == msg.sender
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
packageId: bytes32 = sha3(packageName)
|
|
203
|
-
releaseId: bytes32 = self.generateReleaseId(packageName, version)
|
|
204
|
-
|
|
205
|
-
if self.packages[packageId].exists == True:
|
|
206
|
-
self.packages[packageId] = Package({
|
|
207
|
-
exists: True,
|
|
208
|
-
createdAt: self.packages[packageId].createdAt,
|
|
209
|
-
updatedAt: block.timestamp,
|
|
210
|
-
name: packageName,
|
|
211
|
-
releaseCount: self.packages[packageId].releaseCount,
|
|
212
|
-
})
|
|
213
|
-
self.cutRelease(releaseId, packageId, version, manifestURI, packageName)
|
|
214
|
-
else:
|
|
215
|
-
assert self.packages[packageId].createdAt == 0
|
|
216
|
-
self.packages[packageId] = Package({
|
|
217
|
-
exists: True,
|
|
218
|
-
createdAt: block.timestamp,
|
|
219
|
-
updatedAt: block.timestamp,
|
|
220
|
-
name: packageName,
|
|
221
|
-
releaseCount: 0,
|
|
222
|
-
})
|
|
223
|
-
self.packageIds[self.totalPackageCount] = packageId
|
|
224
|
-
self.totalPackageCount += 1
|
|
225
|
-
self.activePackageCount += 1
|
|
226
|
-
self.cutRelease(releaseId, packageId, version, manifestURI, packageName)
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
@public
|
|
230
|
-
def deleteReleaseId(releaseId: bytes32):
|
|
231
|
-
assert self.owner == msg.sender
|
|
232
|
-
assert self.releases[releaseId].exists
|
|
233
|
-
packageId: bytes32 = self.releases[releaseId].packageId
|
|
234
|
-
assert self.packages[packageId].exists
|
|
235
|
-
assert self.packages[packageId].releaseCount > 0
|
|
236
|
-
if self.packages[packageId].releaseCount == 1:
|
|
237
|
-
self.packages[packageId].releaseCount = 0
|
|
238
|
-
self.packages[packageId].exists = False
|
|
239
|
-
self.activePackageCount -= 1
|
|
240
|
-
self.activeReleaseCount -= 1
|
|
241
|
-
else:
|
|
242
|
-
self.packages[packageId].releaseCount -= 1
|
|
243
|
-
self.activeReleaseCount -= 1
|
|
244
|
-
self.releases[releaseId].exists = False
|
ethpm/backends/__init__.py
DELETED
|
File without changes
|
ethpm/backends/base.py
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
from abc import (
|
|
2
|
-
ABC,
|
|
3
|
-
abstractmethod,
|
|
4
|
-
)
|
|
5
|
-
from typing import (
|
|
6
|
-
Union,
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
from eth_typing import (
|
|
10
|
-
URI,
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class BaseURIBackend(ABC):
|
|
15
|
-
"""
|
|
16
|
-
Generic backend that all URI backends are subclassed from.
|
|
17
|
-
|
|
18
|
-
All subclasses must implement:
|
|
19
|
-
can_resolve_uri, can_translate_uri, fetch_uri_contents
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
@abstractmethod
|
|
23
|
-
def can_resolve_uri(self, uri: URI) -> bool:
|
|
24
|
-
"""
|
|
25
|
-
Return a bool indicating whether this backend class can
|
|
26
|
-
resolve the given URI to it's contents.
|
|
27
|
-
"""
|
|
28
|
-
pass
|
|
29
|
-
|
|
30
|
-
@abstractmethod
|
|
31
|
-
def can_translate_uri(self, uri: URI) -> bool:
|
|
32
|
-
"""
|
|
33
|
-
Return a bool indicating whether this backend class can
|
|
34
|
-
translate the given URI to a corresponding content-addressed URI.
|
|
35
|
-
"""
|
|
36
|
-
pass
|
|
37
|
-
|
|
38
|
-
@abstractmethod
|
|
39
|
-
def fetch_uri_contents(self, uri: URI) -> Union[bytes, URI]:
|
|
40
|
-
"""
|
|
41
|
-
Fetch the contents stored at a URI.
|
|
42
|
-
"""
|
|
43
|
-
pass
|
ethpm/backends/http.py
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import base64
|
|
2
|
-
import json
|
|
3
|
-
from typing import (
|
|
4
|
-
Tuple,
|
|
5
|
-
)
|
|
6
|
-
from urllib import (
|
|
7
|
-
parse,
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
from eth_typing import (
|
|
11
|
-
URI,
|
|
12
|
-
)
|
|
13
|
-
from eth_utils import (
|
|
14
|
-
is_text,
|
|
15
|
-
)
|
|
16
|
-
import requests
|
|
17
|
-
|
|
18
|
-
from ethpm.backends.base import (
|
|
19
|
-
BaseURIBackend,
|
|
20
|
-
)
|
|
21
|
-
from ethpm.constants import (
|
|
22
|
-
GITHUB_API_AUTHORITY,
|
|
23
|
-
)
|
|
24
|
-
from ethpm.exceptions import (
|
|
25
|
-
CannotHandleURI,
|
|
26
|
-
)
|
|
27
|
-
from ethpm.validation.uri import (
|
|
28
|
-
validate_blob_uri_contents,
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class GithubOverHTTPSBackend(BaseURIBackend):
|
|
33
|
-
"""
|
|
34
|
-
Base class for all URIs pointing to a content-addressed Github URI.
|
|
35
|
-
"""
|
|
36
|
-
|
|
37
|
-
def can_resolve_uri(self, uri: URI) -> bool:
|
|
38
|
-
return is_valid_content_addressed_github_uri(uri)
|
|
39
|
-
|
|
40
|
-
def can_translate_uri(self, uri: URI) -> bool:
|
|
41
|
-
"""
|
|
42
|
-
GithubOverHTTPSBackend uri's must resolve to a valid manifest,
|
|
43
|
-
and cannot translate to another content-addressed URI.
|
|
44
|
-
"""
|
|
45
|
-
return False
|
|
46
|
-
|
|
47
|
-
def fetch_uri_contents(self, uri: URI) -> bytes:
|
|
48
|
-
if not self.can_resolve_uri(uri):
|
|
49
|
-
raise CannotHandleURI(f"GithubOverHTTPSBackend cannot resolve {uri}.")
|
|
50
|
-
|
|
51
|
-
response = requests.get(uri)
|
|
52
|
-
response.raise_for_status()
|
|
53
|
-
contents = json.loads(response.content)
|
|
54
|
-
if contents["encoding"] != "base64":
|
|
55
|
-
raise CannotHandleURI(
|
|
56
|
-
"Expected contents returned from Github to be base64 encoded, "
|
|
57
|
-
f"instead received {contents['encoding']}."
|
|
58
|
-
)
|
|
59
|
-
decoded_contents = base64.b64decode(contents["content"])
|
|
60
|
-
validate_blob_uri_contents(decoded_contents, uri)
|
|
61
|
-
return decoded_contents
|
|
62
|
-
|
|
63
|
-
@property
|
|
64
|
-
def base_uri(self) -> str:
|
|
65
|
-
return GITHUB_API_AUTHORITY
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
def is_valid_content_addressed_github_uri(uri: URI) -> bool:
|
|
69
|
-
"""
|
|
70
|
-
Returns a bool indicating whether the given uri conforms to this scheme.
|
|
71
|
-
https://api.github.com/repos/:owner/:repo/git/blobs/:file_sha
|
|
72
|
-
"""
|
|
73
|
-
return is_valid_github_uri(uri, ("/repos/", "/git/", "/blobs/"))
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def is_valid_api_github_uri(uri: URI) -> bool:
|
|
77
|
-
"""
|
|
78
|
-
Returns a bool indicating whether the given uri conforms to this scheme.
|
|
79
|
-
https://api.github.com/repos/:owner/:repo/contents/:path/:to/:file
|
|
80
|
-
"""
|
|
81
|
-
return is_valid_github_uri(uri, ("/repos/", "/contents/"))
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def is_valid_github_uri(uri: URI, expected_path_terms: Tuple[str, ...]) -> bool:
|
|
85
|
-
"""
|
|
86
|
-
Return a bool indicating whether or not the URI fulfills the following specs
|
|
87
|
-
Valid Github URIs *must*:
|
|
88
|
-
- Have 'https' scheme
|
|
89
|
-
- Have 'api.github.com' authority
|
|
90
|
-
- Have a path that contains all "expected_path_terms"
|
|
91
|
-
"""
|
|
92
|
-
if not is_text(uri):
|
|
93
|
-
return False
|
|
94
|
-
|
|
95
|
-
parsed = parse.urlparse(uri)
|
|
96
|
-
path, scheme, authority = parsed.path, parsed.scheme, parsed.netloc
|
|
97
|
-
if not all((path, scheme, authority)):
|
|
98
|
-
return False
|
|
99
|
-
|
|
100
|
-
if any(term for term in expected_path_terms if term not in path):
|
|
101
|
-
return False
|
|
102
|
-
|
|
103
|
-
if scheme != "https":
|
|
104
|
-
return False
|
|
105
|
-
|
|
106
|
-
if authority != GITHUB_API_AUTHORITY:
|
|
107
|
-
return False
|
|
108
|
-
return True
|