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,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
|
-
}
|
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
pragma solidity ^0.4.24;
|
|
2
|
-
pragma experimental "v0.5.0";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {IndexedOrderedSetLib} from "./IndexedOrderedSetLib.sol";
|
|
6
|
-
import {Authorized} from "./Authority.sol";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/// @title Database contract for a package index.
|
|
10
|
-
/// @author Tim Coulter <tim.coulter@consensys.net>, Piper Merriam <pipermerriam@gmail.com>
|
|
11
|
-
contract ReleaseDB is Authorized {
|
|
12
|
-
using IndexedOrderedSetLib for IndexedOrderedSetLib.IndexedOrderedSet;
|
|
13
|
-
|
|
14
|
-
struct Release {
|
|
15
|
-
bool exists;
|
|
16
|
-
uint createdAt;
|
|
17
|
-
uint updatedAt;
|
|
18
|
-
bytes32 nameHash;
|
|
19
|
-
bytes32 versionHash;
|
|
20
|
-
string manifestURI;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Release Data: (releaseId => value)
|
|
24
|
-
mapping (bytes32 => Release) _recordedReleases;
|
|
25
|
-
mapping (bytes32 => bool) _removedReleases;
|
|
26
|
-
IndexedOrderedSetLib.IndexedOrderedSet _allReleaseIds;
|
|
27
|
-
mapping (bytes32 => IndexedOrderedSetLib.IndexedOrderedSet) _releaseIdsByNameHash;
|
|
28
|
-
|
|
29
|
-
// Version Data: (versionHash => value)
|
|
30
|
-
mapping (bytes32 => string) _recordedVersions;
|
|
31
|
-
mapping (bytes32 => bool) _versionExists;
|
|
32
|
-
|
|
33
|
-
// Events
|
|
34
|
-
event ReleaseCreate(bytes32 indexed releaseId);
|
|
35
|
-
event ReleaseUpdate(bytes32 indexed releaseId);
|
|
36
|
-
event ReleaseDelete(bytes32 indexed releaseId, string reason);
|
|
37
|
-
|
|
38
|
-
/*
|
|
39
|
-
* Modifiers
|
|
40
|
-
*/
|
|
41
|
-
modifier onlyIfVersionExists(bytes32 versionHash) {
|
|
42
|
-
require(versionExists(versionHash), "escape:ReleaseDB:version-not-found");
|
|
43
|
-
_;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
modifier onlyIfReleaseExists(bytes32 releaseId) {
|
|
47
|
-
require(releaseExists(releaseId), "escape:ReleaseDB:release-not-found");
|
|
48
|
-
_;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
// +-------------+
|
|
53
|
-
// | Write API |
|
|
54
|
-
// +-------------+
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
/// @dev Creates or updates a release for a package. Returns success.
|
|
58
|
-
/// @param nameHash The name hash of the package.
|
|
59
|
-
/// @param versionHash The version hash for the release version.
|
|
60
|
-
/// @param manifestURI The URI for the release manifest for this release.
|
|
61
|
-
function setRelease(
|
|
62
|
-
bytes32 nameHash,
|
|
63
|
-
bytes32 versionHash,
|
|
64
|
-
string manifestURI
|
|
65
|
-
)
|
|
66
|
-
public
|
|
67
|
-
auth
|
|
68
|
-
returns (bool)
|
|
69
|
-
{
|
|
70
|
-
bytes32 releaseId = hashRelease(nameHash, versionHash);
|
|
71
|
-
|
|
72
|
-
Release storage release = _recordedReleases[releaseId];
|
|
73
|
-
|
|
74
|
-
// If this is a new version push it onto the array of version hashes for
|
|
75
|
-
// this package.
|
|
76
|
-
if (release.exists) {
|
|
77
|
-
emit ReleaseUpdate(releaseId);
|
|
78
|
-
} else {
|
|
79
|
-
// Populate the basic release data.
|
|
80
|
-
release.exists = true;
|
|
81
|
-
release.createdAt = block.timestamp; // solium-disable-line security/no-block-members
|
|
82
|
-
release.nameHash = nameHash;
|
|
83
|
-
release.versionHash = versionHash;
|
|
84
|
-
|
|
85
|
-
// Push the release hash into the array of all release hashes.
|
|
86
|
-
_allReleaseIds.add(releaseId);
|
|
87
|
-
_releaseIdsByNameHash[nameHash].add(releaseId);
|
|
88
|
-
|
|
89
|
-
emit ReleaseCreate(releaseId);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Record the last time the release was updated.
|
|
93
|
-
release.updatedAt = block.timestamp; // solium-disable-line security/no-block-members
|
|
94
|
-
|
|
95
|
-
// Save the release manifest URI
|
|
96
|
-
release.manifestURI = manifestURI;
|
|
97
|
-
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/// @dev Removes a release from a package. Returns success.
|
|
102
|
-
/// @param releaseId The release hash to be removed
|
|
103
|
-
/// @param reason Explanation for why the removal happened.
|
|
104
|
-
function removeRelease(bytes32 releaseId, string reason)
|
|
105
|
-
public
|
|
106
|
-
auth
|
|
107
|
-
onlyIfReleaseExists(releaseId)
|
|
108
|
-
returns (bool)
|
|
109
|
-
{
|
|
110
|
-
bytes32 nameHash;
|
|
111
|
-
bytes32 versionHash;
|
|
112
|
-
|
|
113
|
-
(nameHash, versionHash,,) = getReleaseData(releaseId);
|
|
114
|
-
|
|
115
|
-
// Zero out the release data.
|
|
116
|
-
delete _recordedReleases[releaseId];
|
|
117
|
-
delete _recordedVersions[versionHash];
|
|
118
|
-
|
|
119
|
-
// Remove the release hash from the list of all release hashes
|
|
120
|
-
_allReleaseIds.remove(releaseId);
|
|
121
|
-
_releaseIdsByNameHash[nameHash].remove(releaseId);
|
|
122
|
-
|
|
123
|
-
// Add the release hash to the map of removed releases
|
|
124
|
-
_removedReleases[releaseId] = true;
|
|
125
|
-
|
|
126
|
-
// Log the removal.
|
|
127
|
-
emit ReleaseDelete(releaseId, reason);
|
|
128
|
-
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
/// @dev Adds the given version to the local version database. Returns the versionHash for the provided version.
|
|
134
|
-
/// @param version Version string (ex: '1.0.0')
|
|
135
|
-
function setVersion(string version)
|
|
136
|
-
public
|
|
137
|
-
auth
|
|
138
|
-
returns (bytes32)
|
|
139
|
-
{
|
|
140
|
-
bytes32 versionHash = hashVersion(version);
|
|
141
|
-
|
|
142
|
-
if (!_versionExists[versionHash]) {
|
|
143
|
-
_recordedVersions[versionHash] = version;
|
|
144
|
-
_versionExists[versionHash] = true;
|
|
145
|
-
}
|
|
146
|
-
return versionHash;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
//
|
|
150
|
-
// +------------+
|
|
151
|
-
// | Read API |
|
|
152
|
-
// +------------+
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
/// @dev Returns a slice of the array of all releases hashes for the named package.
|
|
156
|
-
/// @param offset The starting index for the slice.
|
|
157
|
-
/// @param limit The length of the slice
|
|
158
|
-
function getAllReleaseIds(bytes32 nameHash, uint _offset, uint limit)
|
|
159
|
-
public
|
|
160
|
-
view
|
|
161
|
-
returns (
|
|
162
|
-
bytes32[] releaseIds,
|
|
163
|
-
uint offset
|
|
164
|
-
)
|
|
165
|
-
{
|
|
166
|
-
bytes32[] memory hashes; // Release ids to return
|
|
167
|
-
uint cursor = _offset; // Index counter to traverse DB array
|
|
168
|
-
uint remaining; // Counter to collect `limit` packages
|
|
169
|
-
uint totalReleases = getNumReleasesForNameHash(nameHash); // Total number of packages in registry
|
|
170
|
-
|
|
171
|
-
// Is request within range?
|
|
172
|
-
if (cursor < totalReleases){
|
|
173
|
-
|
|
174
|
-
// Get total remaining records
|
|
175
|
-
remaining = totalReleases - cursor;
|
|
176
|
-
|
|
177
|
-
// Number of records to collect is lesser of `remaining` and `limit`
|
|
178
|
-
if (remaining > limit ){
|
|
179
|
-
remaining = limit;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Allocate return array
|
|
183
|
-
hashes = new bytes32[](remaining);
|
|
184
|
-
|
|
185
|
-
// Collect records. (IndexedOrderedSet manages deletions.)
|
|
186
|
-
while(remaining > 0){
|
|
187
|
-
bytes32 hash = getReleaseIdForNameHash(nameHash, cursor);
|
|
188
|
-
hashes[remaining - 1] = hash;
|
|
189
|
-
remaining--;
|
|
190
|
-
cursor++;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return (hashes, cursor);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/// @dev Get the total number of releases
|
|
197
|
-
/// @param nameHash the name hash to lookup.
|
|
198
|
-
function getNumReleasesForNameHash(bytes32 nameHash)
|
|
199
|
-
public
|
|
200
|
-
view
|
|
201
|
-
returns (uint)
|
|
202
|
-
{
|
|
203
|
-
return _releaseIdsByNameHash[nameHash].size();
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/// @dev Release hash for a Package at a given index
|
|
207
|
-
/// @param nameHash the name hash to lookup.
|
|
208
|
-
/// @param idx The index of the release hash to retrieve.
|
|
209
|
-
function getReleaseIdForNameHash(bytes32 nameHash, uint idx)
|
|
210
|
-
public
|
|
211
|
-
view
|
|
212
|
-
returns (bytes32)
|
|
213
|
-
{
|
|
214
|
-
return _releaseIdsByNameHash[nameHash].get(idx);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/// @dev Query the existence of a release at the provided version for a package. Returns boolean indicating whether such a release exists.
|
|
218
|
-
/// @param releaseId The release hash to query.
|
|
219
|
-
function releaseExists(bytes32 releaseId)
|
|
220
|
-
public
|
|
221
|
-
view
|
|
222
|
-
returns (bool)
|
|
223
|
-
{
|
|
224
|
-
return _recordedReleases[releaseId].exists;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/// @dev Query the past existence of a release at the provided version for a package. Returns boolean indicating whether such a release ever existed.
|
|
228
|
-
/// @param releaseHash The release hash to query.
|
|
229
|
-
function releaseExisted(bytes32 releaseHash)
|
|
230
|
-
public
|
|
231
|
-
view
|
|
232
|
-
returns (bool)
|
|
233
|
-
{
|
|
234
|
-
return _removedReleases[releaseHash];
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/// @dev Query the existence of the provided version in the recorded versions. Returns boolean indicating whether such a version exists.
|
|
238
|
-
/// @param versionHash the version hash to check.
|
|
239
|
-
function versionExists(bytes32 versionHash)
|
|
240
|
-
public
|
|
241
|
-
view
|
|
242
|
-
returns (bool)
|
|
243
|
-
{
|
|
244
|
-
return _versionExists[versionHash];
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/// @dev Returns the releaseData for the given release has a package.
|
|
248
|
-
/// @param releaseId The release hash.
|
|
249
|
-
function getReleaseData(bytes32 releaseId)
|
|
250
|
-
public
|
|
251
|
-
view
|
|
252
|
-
onlyIfReleaseExists(releaseId)
|
|
253
|
-
returns (
|
|
254
|
-
bytes32 nameHash,
|
|
255
|
-
bytes32 versionHash,
|
|
256
|
-
uint createdAt,
|
|
257
|
-
uint updatedAt
|
|
258
|
-
)
|
|
259
|
-
{
|
|
260
|
-
Release storage release = _recordedReleases[releaseId];
|
|
261
|
-
return (release.nameHash, release.versionHash, release.createdAt, release.updatedAt);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/// @dev Returns string version identifier from the version of the given release hash.
|
|
265
|
-
/// @param versionHash the version hash
|
|
266
|
-
function getVersion(bytes32 versionHash)
|
|
267
|
-
public
|
|
268
|
-
view
|
|
269
|
-
onlyIfVersionExists(versionHash)
|
|
270
|
-
returns (string)
|
|
271
|
-
{
|
|
272
|
-
return _recordedVersions[versionHash];
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/// @dev Returns the URI of the release manifest for the given release hash.
|
|
276
|
-
/// @param releaseId Release hash
|
|
277
|
-
function getManifestURI(bytes32 releaseId)
|
|
278
|
-
public
|
|
279
|
-
view
|
|
280
|
-
onlyIfReleaseExists(releaseId)
|
|
281
|
-
returns (string)
|
|
282
|
-
{
|
|
283
|
-
return _recordedReleases[releaseId].manifestURI;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/*
|
|
287
|
-
* Hash Functions
|
|
288
|
-
*/
|
|
289
|
-
/// @dev Returns version hash for the given semver version.
|
|
290
|
-
/// @param version Version string
|
|
291
|
-
function hashVersion(string version)
|
|
292
|
-
public
|
|
293
|
-
pure
|
|
294
|
-
returns (bytes32)
|
|
295
|
-
{
|
|
296
|
-
return keccak256(abi.encodePacked(version));
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/// @dev Returns release hash for the given release
|
|
300
|
-
/// @param nameHash The name hash of the package name.
|
|
301
|
-
/// @param versionHash The version hash for the release version.
|
|
302
|
-
function hashRelease(bytes32 nameHash, bytes32 versionHash)
|
|
303
|
-
public
|
|
304
|
-
pure
|
|
305
|
-
returns (bytes32)
|
|
306
|
-
{
|
|
307
|
-
return keccak256(abi.encodePacked(nameHash, versionHash));
|
|
308
|
-
}
|
|
309
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
pragma solidity ^0.4.24;
|
|
2
|
-
pragma experimental "v0.5.0";
|
|
3
|
-
|
|
4
|
-
import {PackageDB} from "./PackageDB.sol";
|
|
5
|
-
import {ReleaseDB} from "./ReleaseDB.sol";
|
|
6
|
-
|
|
7
|
-
/// @title Database contract for a package index.
|
|
8
|
-
/// @author Piper Merriam <pipermerriam@gmail.com>
|
|
9
|
-
contract ReleaseValidator {
|
|
10
|
-
/// @dev Runs validation on all of the data needed for releasing a package. Returns success.
|
|
11
|
-
/// @param packageDb The address of the PackageDB
|
|
12
|
-
/// @param releaseDb The address of the ReleaseDB
|
|
13
|
-
/// @param callerAddress The address which is attempting to create the release.
|
|
14
|
-
/// @param name The name of the package.
|
|
15
|
-
/// @param version The version string of the package (ex: `1.0.0`)
|
|
16
|
-
/// @param manifestURI The URI of the release manifest.
|
|
17
|
-
function validateRelease(
|
|
18
|
-
PackageDB packageDb,
|
|
19
|
-
ReleaseDB releaseDb,
|
|
20
|
-
address callerAddress,
|
|
21
|
-
string name,
|
|
22
|
-
string version,
|
|
23
|
-
string manifestURI
|
|
24
|
-
)
|
|
25
|
-
public
|
|
26
|
-
view
|
|
27
|
-
returns (bool)
|
|
28
|
-
{
|
|
29
|
-
if (address(packageDb) == 0x0){
|
|
30
|
-
// packageDb address is null
|
|
31
|
-
revert("escape:ReleaseValidator:package-db-not-set");
|
|
32
|
-
} else if (address(releaseDb) == 0x0){
|
|
33
|
-
// releaseDb address is null
|
|
34
|
-
revert("escape:ReleaseValidator:release-db-not-set");
|
|
35
|
-
} else if (!validateAuthorization(packageDb, callerAddress, name)) {
|
|
36
|
-
// package exists and msg.sender is not the owner not the package owner.
|
|
37
|
-
revert("escape:ReleaseValidator:caller-not-authorized");
|
|
38
|
-
} else if (!validateIsNewRelease(packageDb, releaseDb, name, version)) {
|
|
39
|
-
// this version has already been released.
|
|
40
|
-
revert("escape:ReleaseValidator:version-previously-published");
|
|
41
|
-
} else if (!validatePackageName(packageDb, name)) {
|
|
42
|
-
// invalid package name.
|
|
43
|
-
revert("escape:ReleaseValidator:invalid-package-name");
|
|
44
|
-
} else if (!validateStringIdentifier(manifestURI)) {
|
|
45
|
-
// disallow empty release manifest URI
|
|
46
|
-
revert("escape:ReleaseValidator:invalid-manifest-uri");
|
|
47
|
-
} else if (!validateStringIdentifier(version)) {
|
|
48
|
-
// disallow version 0.0.0
|
|
49
|
-
revert("escape:ReleaseValidator:invalid-release-version");
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/// @dev Validate whether the callerAddress is authorized to make this release.
|
|
55
|
-
/// @param packageDb The address of the PackageDB
|
|
56
|
-
/// @param callerAddress The address which is attempting to create the release.
|
|
57
|
-
/// @param name The name of the package.
|
|
58
|
-
function validateAuthorization(
|
|
59
|
-
PackageDB packageDb,
|
|
60
|
-
address callerAddress,
|
|
61
|
-
string name
|
|
62
|
-
)
|
|
63
|
-
public
|
|
64
|
-
view
|
|
65
|
-
returns (bool)
|
|
66
|
-
{
|
|
67
|
-
bytes32 nameHash = packageDb.hashName(name);
|
|
68
|
-
if (!packageDb.packageExists(nameHash)) {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
address packageOwner;
|
|
72
|
-
|
|
73
|
-
(packageOwner,,) = packageDb.getPackageData(nameHash);
|
|
74
|
-
|
|
75
|
-
if (packageOwner == callerAddress) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/// @dev Validate that the version being released has not already been released.
|
|
82
|
-
/// @param packageDb The address of the PackageDB
|
|
83
|
-
/// @param releaseDb The address of the ReleaseDB
|
|
84
|
-
/// @param name The name of the package.
|
|
85
|
-
/// @param version The version string for the release
|
|
86
|
-
function validateIsNewRelease(
|
|
87
|
-
PackageDB packageDb,
|
|
88
|
-
ReleaseDB releaseDb,
|
|
89
|
-
string name,
|
|
90
|
-
string version
|
|
91
|
-
)
|
|
92
|
-
public
|
|
93
|
-
view
|
|
94
|
-
returns (bool)
|
|
95
|
-
{
|
|
96
|
-
bytes32 nameHash = packageDb.hashName(name);
|
|
97
|
-
bytes32 versionHash = releaseDb.hashVersion(version);
|
|
98
|
-
bytes32 releaseHash = releaseDb.hashRelease(nameHash, versionHash);
|
|
99
|
-
return !releaseDb.releaseExists(releaseHash) && !releaseDb.releaseExisted(releaseHash);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
uint constant DIGIT_0 = uint(bytes1("0"));
|
|
103
|
-
uint constant DIGIT_9 = uint(bytes1("9"));
|
|
104
|
-
uint constant LETTER_a = uint(bytes1("a"));
|
|
105
|
-
uint constant LETTER_z = uint(bytes1("z"));
|
|
106
|
-
bytes1 constant DASH = bytes1("-");
|
|
107
|
-
|
|
108
|
-
/// @dev Returns boolean whether the provided package name is valid.
|
|
109
|
-
/// @param packageDb The address of the PackageDB
|
|
110
|
-
/// @param name The name of the package.
|
|
111
|
-
function validatePackageName(PackageDB packageDb, string name)
|
|
112
|
-
public
|
|
113
|
-
view
|
|
114
|
-
returns (bool)
|
|
115
|
-
{
|
|
116
|
-
bytes32 nameHash = packageDb.hashName(name);
|
|
117
|
-
|
|
118
|
-
if (packageDb.packageExists(nameHash)) {
|
|
119
|
-
// existing names are always valid.
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (bytes(name).length < 2 || bytes(name).length > 255) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
for (uint i = 0; i < bytes(name).length; i++) {
|
|
127
|
-
if (bytes(name)[i] == DASH && i > 0) {
|
|
128
|
-
continue;
|
|
129
|
-
} else if (i > 0 && uint(bytes(name)[i]) >= DIGIT_0 && uint(bytes(name)[i]) <= DIGIT_9) {
|
|
130
|
-
continue;
|
|
131
|
-
} else if (uint(bytes(name)[i]) >= LETTER_a && uint(bytes(name)[i]) <= LETTER_z) {
|
|
132
|
-
continue;
|
|
133
|
-
} else {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/// @dev Returns boolean whether the input string has a length
|
|
141
|
-
/// @param value The string to validate.
|
|
142
|
-
function validateStringIdentifier(string value)
|
|
143
|
-
public
|
|
144
|
-
pure
|
|
145
|
-
returns (bool)
|
|
146
|
-
{
|
|
147
|
-
if (bytes(value).length == 0) {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
return true;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"language": "Solidity", "settings": {"outputSelection": {"*": {"*": ["abi", "evm.bytecode.object", "evm.deployedBytecode", "metadata", "devdoc"]}}}, "sources": {"PackageRegistryInterface.sol": {"urls": ["/Users/nickgheorghita/ethereum/ethpm-cli/projects/registry/contracts/PackageRegistryInterface.sol"]}, "PackageRegistry.sol": {"urls": ["/Users/nickgheorghita/ethereum/ethpm-cli/projects/registry/contracts/PackageRegistry.sol"]}, "PackageDB.sol": {"urls": ["/Users/nickgheorghita/ethereum/ethpm-cli/projects/registry/contracts/PackageDB.sol"]}, "ReleaseDB.sol": {"urls": ["/Users/nickgheorghita/ethereum/ethpm-cli/projects/registry/contracts/ReleaseDB.sol"]}, "Authority.sol": {"urls": ["/Users/nickgheorghita/ethereum/ethpm-cli/projects/registry/contracts/Authority.sol"]}, "ReleaseValidator.sol": {"urls": ["/Users/nickgheorghita/ethereum/ethpm-cli/projects/registry/contracts/ReleaseValidator.sol"]}, "IndexedOrderedSetLib.sol": {"urls": ["/Users/nickgheorghita/ethereum/ethpm-cli/projects/registry/contracts/IndexedOrderedSetLib.sol"]}}}
|