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