diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d893212..09419ab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - python-version: ["3.7.x", "3.8.x", "3.9.x"] + python-version: ["3.7.x", "3.8.x", "3.9.x", "3.10.x", "3.11.x"] steps: - uses: actions/checkout@v2 diff --git a/setup.cfg b/setup.cfg index 5c21dd7..69f5456 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,7 +19,7 @@ packages = find: include_package_data = True python_requires = >=3.7 install_requires = - web3 + web3 >= 6.0.0 [options.packages.find] where = src diff --git a/src/predeployed_generator/contract_generator.py b/src/predeployed_generator/contract_generator.py index c76db89..999927d 100644 --- a/src/predeployed_generator/contract_generator.py +++ b/src/predeployed_generator/contract_generator.py @@ -118,7 +118,12 @@ def get_meta(self) -> dict: # private - def _generate(self, storage: Storage = None, balance: int = 0, nonce: int = 0) -> Account: + def _generate( + self, + storage: Optional[Storage] = None, + balance: int = 0, + nonce: int = 0 + ) -> Account: """Produce smart contract allocation object. It consists of fields 'code', 'balance', 'nonce' and 'storage' @@ -197,14 +202,14 @@ def calculate_mapping_value_slot( else: raise TypeError(f'{key_type} is unknown key type') - return int.from_bytes(w3.solidityKeccak([key_type, 'uint256'], [key, slot]), 'big') + return int.from_bytes(w3.solidity_keccak([key_type, 'uint256'], [key, slot]), 'big') @staticmethod def calculate_array_value_slot(slot: int, index: int) -> int: """Calculate slot in smart contract storage where value of the array in the index is stored """ - return int.from_bytes(w3.solidityKeccak(['uint256'], [slot]), 'big') + index + return int.from_bytes(w3.solidity_keccak(['uint256'], [slot]), 'big') + index @staticmethod def next_slot(previous_slot: int) -> int: diff --git a/src/predeployed_generator/openzeppelin/transparent_upgradeable_proxy_generator.py b/src/predeployed_generator/openzeppelin/transparent_upgradeable_proxy_generator.py index d1d9b8d..b23d03b 100644 --- a/src/predeployed_generator/openzeppelin/transparent_upgradeable_proxy_generator.py +++ b/src/predeployed_generator/openzeppelin/transparent_upgradeable_proxy_generator.py @@ -19,13 +19,13 @@ class TransparentUpgradeableProxyGenerator(OpenzeppelinContractGenerator): ARTIFACT_FILENAME = 'TransparentUpgradeableProxy.json' META_FILENAME = 'TransparentUpgradeableProxy.meta.json' ROLLBACK_SLOT = int.from_bytes( - w3.solidityKeccak(['string'], ['eip1967.proxy.rollback']), + w3.solidity_keccak(['string'], ['eip1967.proxy.rollback']), byteorder='big') - 1 IMPLEMENTATION_SLOT = int.from_bytes( - w3.solidityKeccak(['string'], ['eip1967.proxy.implementation']), + w3.solidity_keccak(['string'], ['eip1967.proxy.implementation']), byteorder='big') - 1 ADMIN_SLOT = int.from_bytes( - w3.solidityKeccak(['string'], ['eip1967.proxy.admin']), + w3.solidity_keccak(['string'], ['eip1967.proxy.admin']), byteorder='big') - 1 @staticmethod diff --git a/src/predeployed_generator/upgradeable_contract_generator.py b/src/predeployed_generator/upgradeable_contract_generator.py index 1a153cb..6645062 100644 --- a/src/predeployed_generator/upgradeable_contract_generator.py +++ b/src/predeployed_generator/upgradeable_contract_generator.py @@ -65,7 +65,7 @@ def generate_allocation( proxy_admin_address = kwargs.pop('proxy_admin_address') implementation_address = kwargs.pop( 'implementation_address', - w3.toChecksumAddress(w3.solidityKeccak(['address'], [contract_address])[:20])) + w3.to_checksum_address(w3.solidity_keccak(['address'], [contract_address])[:20])) return { contract_address: super().generate( @@ -75,4 +75,4 @@ def generate_allocation( balance=balance, nonce=nonce), # pylint: disable=W0212 - implementation_address: self.implementation_generator._generate(storage=None)} + implementation_address: self.implementation_generator._generate()} diff --git a/test/test_access_control_enumerable_generator.py b/test/test_access_control_enumerable_generator.py index 5335cbf..e93b93e 100644 --- a/test/test_access_control_enumerable_generator.py +++ b/test/test_access_control_enumerable_generator.py @@ -26,7 +26,7 @@ def test_default_admin_role(self, tmpdir): genesis = self.prepare_genesis() with self.run_geth(tmpdir, genesis): - assert w3.isConnected() + assert w3.is_connected() test_contract = w3.eth.contract(address=self.CONTRACT_ADDRESS, abi=self.get_test_contract_abi()) assert test_contract.functions.getRoleMemberCount(CustomContractGenerator.DEFAULT_ADMIN_ROLE).call() == 1 @@ -38,7 +38,7 @@ def test_tester_role(self, tmpdir): genesis = self.prepare_genesis() with self.run_geth(tmpdir, genesis): - assert w3.isConnected() + assert w3.is_connected() test_contract = w3.eth.contract(address=self.CONTRACT_ADDRESS, abi=self.get_test_contract_abi()) assert test_contract.functions.getRoleMemberCount(CustomContractGenerator.TESTER_ROLE).call() == 2 diff --git a/test/test_contract_generator.py b/test/test_contract_generator.py index 93abb8d..c19f882 100644 --- a/test/test_contract_generator.py +++ b/test/test_contract_generator.py @@ -29,7 +29,7 @@ def test_short_string(self, tmpdir): genesis = self.prepare_genesis() with self.run_geth(tmpdir, genesis): - assert w3.isConnected() + assert w3.is_connected() test_contract = w3.eth.contract(address=self.CONTRACT_ADDRESS, abi=self.get_test_contract_abi()) assert test_contract.functions.shortString().call() == 'short string' @@ -39,7 +39,7 @@ def test_long_string(self, tmpdir): genesis = self.prepare_genesis() with self.run_geth(tmpdir, genesis): - assert w3.isConnected() + assert w3.is_connected() test_contract = w3.eth.contract(address=self.CONTRACT_ADDRESS, abi=self.get_test_contract_abi()) assert test_contract.functions.longString().call() == ' '.join(['very'] * 32) + ' long string' @@ -49,7 +49,7 @@ def test_bytes32(self, tmpdir): genesis = self.prepare_genesis() with self.run_geth(tmpdir, genesis): - assert w3.isConnected() + assert w3.is_connected() test_contract = w3.eth.contract(address=self.CONTRACT_ADDRESS, abi=self.get_test_contract_abi()) assert test_contract.functions.bytes32Value().call() == CustomContractGenerator.TESTER_ROLE @@ -59,7 +59,7 @@ def test_addresses_array(self, tmpdir): genesis = self.prepare_genesis() with self.run_geth(tmpdir, genesis): - assert w3.isConnected() + assert w3.is_connected() test_contract = w3.eth.contract(address=self.CONTRACT_ADDRESS, abi=self.get_test_contract_abi()) assert test_contract.functions.testers(0).call() == self.TESTER_ADDRESS diff --git a/test/test_proxy_admin_generator.py b/test/test_proxy_admin_generator.py index 2f0d12c..da8854f 100644 --- a/test/test_proxy_admin_generator.py +++ b/test/test_proxy_admin_generator.py @@ -16,7 +16,7 @@ def test_owner(self, tmpdir): proxy_admin_address = '0xd200000000000000000000000000000000000001' generator = ProxyAdminGenerator() with self.run_geth(tmpdir, self.generate_genesis({proxy_admin_address: generator.generate(owner_address=owner_address)})): - assert w3.isConnected() + assert w3.is_connected() proxy_admin = w3.eth.contract(address=proxy_admin_address, abi=self.get_proxy_admin_abi()) assert proxy_admin.functions.owner().call() == owner_address diff --git a/test/test_transparent_upgradeable_proxy_generator.py b/test/test_transparent_upgradeable_proxy_generator.py index 77afe17..9c738e9 100644 --- a/test/test_transparent_upgradeable_proxy_generator.py +++ b/test/test_transparent_upgradeable_proxy_generator.py @@ -40,7 +40,7 @@ def test_admin(self, tmpdir): genesis = self.prepare_genesis() with self.run_geth(tmpdir, genesis): - assert w3.isConnected() + assert w3.is_connected() proxy_admin = w3.eth.contract(address=self.PROXY_ADMIN_ADDRESS, abi=self.get_proxy_admin_abi()) assert proxy_admin.functions.getProxyAdmin(self.PROXY_ADDRESS).call() == self.PROXY_ADMIN_ADDRESS @@ -50,7 +50,7 @@ def test_implementation(self, tmpdir): genesis = self.prepare_genesis() with self.run_geth(tmpdir, genesis): - assert w3.isConnected() + assert w3.is_connected() proxy_admin = w3.eth.contract(address=self.PROXY_ADMIN_ADDRESS, abi=self.get_proxy_admin_abi()) assert proxy_admin.functions.getProxyImplementation(self.PROXY_ADDRESS).call() == self.IMPLEMENTATION_ADDRESS diff --git a/test/test_upgradeable_contract_generator.py b/test/test_upgradeable_contract_generator.py index e3747f3..659cbef 100644 --- a/test/test_upgradeable_contract_generator.py +++ b/test/test_upgradeable_contract_generator.py @@ -41,7 +41,7 @@ def test_admin(self, tmpdir): genesis = self.prepare_genesis() with self.run_geth(tmpdir, genesis): - assert w3.isConnected() + assert w3.is_connected() proxy_admin = w3.eth.contract(address=self.PROXY_ADMIN_ADDRESS, abi=self.get_proxy_admin_abi()) assert proxy_admin.functions.getProxyAdmin(self.PROXY_ADDRESS).call() == self.PROXY_ADMIN_ADDRESS @@ -51,7 +51,7 @@ def test_implementation(self, tmpdir): genesis = self.prepare_genesis() with self.run_geth(tmpdir, genesis): - assert w3.isConnected() + assert w3.is_connected() proxy_admin = w3.eth.contract(address=self.PROXY_ADMIN_ADDRESS, abi=self.get_proxy_admin_abi()) assert proxy_admin.functions.getProxyImplementation(self.PROXY_ADDRESS).call() == self.IMPLEMENTATION_ADDRESS @@ -71,7 +71,7 @@ def test_default_implementation_address(self, tmpdir): }) with self.run_geth(tmpdir, genesis): - assert w3.isConnected() + assert w3.is_connected() proxy_admin = w3.eth.contract(address=self.PROXY_ADMIN_ADDRESS, abi=self.get_proxy_admin_abi()) assert proxy_admin.functions.getProxyImplementation(self.PROXY_ADDRESS).call() == self.PROXY_ADDRESS_HASH @@ -81,7 +81,7 @@ def test_owner(self, tmpdir): genesis = self.prepare_genesis() with self.run_geth(tmpdir, genesis): - assert w3.isConnected() + assert w3.is_connected() proxy_admin = w3.eth.contract(address=self.PROXY_ADDRESS, abi=self.get_proxy_admin_abi()) assert proxy_admin.functions.owner().call() == self.OWNER_ADDRESS @@ -112,7 +112,7 @@ def test_balance_and_nonce(self, tmpdir): }) with self.run_geth(tmpdir, genesis): - assert w3.isConnected() + assert w3.is_connected() assert w3.eth.get_balance(self.PROXY_ADDRESS) == balance assert w3.eth.get_transaction_count(self.PROXY_ADDRESS) == nonce diff --git a/test/tools/custom_contract_generator.py b/test/tools/custom_contract_generator.py index 2074c4c..8184236 100644 --- a/test/tools/custom_contract_generator.py +++ b/test/tools/custom_contract_generator.py @@ -10,7 +10,7 @@ class CustomContractGenerator(AccessControlEnumerableGenerator): CONTRACT_NAME = 'TestContract' DEFAULT_ADMIN_ROLE = (0).to_bytes(32, 'big') - TESTER_ROLE = w3.solidityKeccak(['string'], ['TESTER_ROLE']) + TESTER_ROLE = w3.solidity_keccak(['string'], ['TESTER_ROLE']) # ---------- storage ---------- # --------Initializable--------