diff --git a/VERSION b/VERSION index 7d2ed7c7..cd57a8b9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.1.4 +2.1.5 diff --git a/requirements.txt b/requirements.txt index 05c9b8ee..f748eb9e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -skale.py==5.8dev4 +skale.py==6.0dev0 diff --git a/tests/docker_test.py b/tests/docker_test.py index 412301fb..4ce6ff8b 100644 --- a/tests/docker_test.py +++ b/tests/docker_test.py @@ -51,8 +51,8 @@ def make_tx(w3, wallet, failed=False): number = 3 if failed else 4 return tester.functions.setOnlyEven( number - ).buildTransaction({ - 'gasPrice': w3.eth.gasPrice, + ).build_transaction({ + 'gasPrice': w3.eth.gas_price, 'gas': DEFAULT_GAS, 'from': wallet.address }) diff --git a/tests/processor_test.py b/tests/processor_test.py index af6f48cd..48be47a5 100644 --- a/tests/processor_test.py +++ b/tests/processor_test.py @@ -31,8 +31,8 @@ def make_tx(w3, wallet, failed=False): number = 3 if failed else 4 return tester.functions.setOnlyEven( number - ).buildTransaction({ - 'gasPrice': w3.eth.gasPrice, + ).build_transaction({ + 'gasPrice': w3.eth.gas_price, 'gas': DEFAULT_GAS, 'from': wallet.address }) diff --git a/tests/transaction_test.py b/tests/transaction_test.py index d8a67b49..3c9bff44 100644 --- a/tests/transaction_test.py +++ b/tests/transaction_test.py @@ -13,6 +13,7 @@ def test_sample_tx(): fee={'gas_price': 1000000000}, gas=22000, nonce=3, + method='createNode', source=None, tx_hash=None, data={'test': 1} @@ -23,7 +24,7 @@ def test_sample_tx(): assert not tx.is_sent() dumped_tx = tx.to_bytes() - expected = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "maxFeePerGas": null, "maxPriorityFeePerGas": null, "multiplier": 1.2, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "tx_id": "1232321332132131331321", "value": 1}' # noqa + expected = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "maxFeePerGas": null, "maxPriorityFeePerGas": null, "meta": null, "method": "createNode", "multiplier": 1.2, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "tx_id": "1232321332132131331321", "value": 1}' # noqa assert dumped_tx == expected loaded_tx = Tx.from_bytes(tx.tx_id.encode('utf-8'), dumped_tx) @@ -99,38 +100,48 @@ def test_tx_from_bytes(): with pytest.raises(InvalidFormatError): Tx.from_bytes(tx_id, b'') - before_eip_1559 = b'{"attempts": 0, "status": "PROPOSED", "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "nonce": 3, "score": 1, "sent_ts": null, "to": "0x1", "tx_hash": null, "value": 1}' # noqa + before_eip_1559 = b'{"attempts": 0, "status": "PROPOSED", "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "meta": null, "method": null, "nonce": 3, "score": 1, "sent_ts": null, "to": "0x1", "tx_hash": null, "value": 1}' # noqa tx = Tx.from_bytes(tx_id, before_eip_1559) # sorted before_eip_1559 incuding eip_1559 fields - expected = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "maxFeePerGas": null, "maxPriorityFeePerGas": null, "multiplier": 1.2, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "tx_id": "tx-1232321332132131331321", "value": 1}' # noqa + expected = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "maxFeePerGas": null, "maxPriorityFeePerGas": null, "meta": null, "method": null, "multiplier": 1.2, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "tx_id": "tx-1232321332132131331321", "value": 1}' # noqa assert tx.to_bytes() == expected - missing_field_tx_id = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "maxFeePerGas": null, "maxPriorityFeePerGas": null, "multiplier": 1.2, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "value": 1}' # noqa + missing_field_tx_id = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "maxFeePerGas": null, "maxPriorityFeePerGas": null, "meta": null, "method": null, "multiplier": 1.2, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "value": 1}' # noqa tx = Tx.from_bytes(tx_id, missing_field_tx_id) # Same as missing_field_tx_id but with tx id - expected = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "maxFeePerGas": null, "maxPriorityFeePerGas": null, "multiplier": 1.2, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "tx_id": "tx-1232321332132131331321", "value": 1}' # noqa + expected = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "maxFeePerGas": null, "maxPriorityFeePerGas": null, "meta": null, "method": null, "multiplier": 1.2, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "tx_id": "tx-1232321332132131331321", "value": 1}' # noqa assert tx.to_bytes() == expected - missing_field_status = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "maxFeePerGas": 1000000000, "maxPriorityFeePerGas": 1000000000, "hashes": [], "nonce": 3, "score": 1, "sent_ts": null, "to": "0x1", "tx_hash": null, "value": 1}' # noqa + missing_field_status = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "maxFeePerGas": 1000000000, "maxPriorityFeePerGas": 1000000000, "hashes": [], "meta": null, "method": null, "nonce": 3, "score": 1, "sent_ts": null, "to": "0x1", "tx_hash": null, "value": 1}' # noqa with pytest.raises(InvalidFormatError): Tx.from_bytes(tx_id, missing_field_status) - missing_field_to = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "maxFeePerGas": 1000000000, "maxPriorityFeePerGas": 1000000000, "from": null, "gas": 22000, "hashes": [], "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "tx_hash": null, "value": 1}' # noqa + missing_field_to = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "maxFeePerGas": 1000000000, "maxPriorityFeePerGas": 1000000000, "from": null, "gas": 22000, "hashes": [], "meta": null, "method": null, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "tx_hash": null, "value": 1}' # noqa with pytest.raises(InvalidFormatError): Tx.from_bytes(tx_id, missing_field_to) - missing_field_hash = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "maxFeePerGas": 1000000000, "maxPriorityFeePerGas": 1000000000, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "value": 1}' # noqa + missing_field_hash = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "maxFeePerGas": 1000000000, "maxPriorityFeePerGas": 1000000000, "meta": null, "method": null, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "value": 1}' # noqa tx = Tx.from_bytes(tx_id, missing_field_hash) assert tx.hashes == [] - with_type = b'{"attempts": 0, "type": "0x0", "status": "PROPOSED", "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "nonce": 3, "score": 1, "sent_ts": null, "to": "0x1", "tx_hash": null, "value": 1}' # noqa + with_type = b'{"attempts": 0, "type": "0x0", "status": "PROPOSED", "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "meta": null, "method": null, "nonce": 3, "score": 1, "sent_ts": null, "to": "0x1", "tx_hash": null, "value": 1}' # noqa tx = Tx.from_bytes(tx_id, with_type) - expected = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "maxFeePerGas": null, "maxPriorityFeePerGas": null, "multiplier": 1.2, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "tx_id": "tx-1232321332132131331321", "value": 1}' # noqa + expected = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "maxFeePerGas": null, "maxPriorityFeePerGas": null, "meta": null, "method": null, "multiplier": 1.2, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "tx_id": "tx-1232321332132131331321", "value": 1}' # noqa tx.to_bytes() == expected + with_method_and_meta = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "maxFeePerGas": null, "maxPriorityFeePerGas": null, "meta": {"chain": "test"}, "method": "createNode", "multiplier": 1.2, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "tx_id": "tx-1232321332132131331321", "value": 1}' # noqa + tx = Tx.from_bytes(tx_id, with_method_and_meta) + assert tx.to_bytes() == with_method_and_meta + + missing_method_and_meta = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "maxFeePerGas": null, "maxPriorityFeePerGas": null, "multiplier": 1.2, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "tx_id": "tx-1232321332132131331321", "value": 1}' # noqa + expected = b'{"attempts": 0, "chainId": null, "data": {"test": 1}, "from": null, "gas": 22000, "gasPrice": 1000000000, "hashes": [], "maxFeePerGas": null, "maxPriorityFeePerGas": null, "meta": null, "method": null, "multiplier": 1.2, "nonce": 3, "score": 1, "sent_ts": null, "status": "PROPOSED", "to": "0x1", "tx_hash": null, "tx_id": "tx-1232321332132131331321", "value": 1}' # noqa + tx = Tx.from_bytes(tx_id, missing_method_and_meta) + actual = tx.to_bytes() + assert actual == expected + def test_is_sent_by_ima(): tx = Tx( diff --git a/tests/utils/account.py b/tests/utils/account.py index 8894fe34..2c167461 100644 --- a/tests/utils/account.py +++ b/tests/utils/account.py @@ -19,11 +19,11 @@ def send_eth( 'to': address, 'value': amount, 'gas': 8000000, - 'gasPrice': w3.eth.gasPrice + 'gasPrice': w3.eth.gas_price } signed_txn = wallet.sign(tx) - h = w3.eth.sendRawTransaction(signed_txn.rawTransaction) - w3.eth.waitForTransactionReceipt(h, timeout=60) + h = w3.eth.send_raw_transaction(signed_txn.rawTransaction) + w3.eth.wait_for_transaction_receipt(h, timeout=60) def generate_address(w3: Web3) -> str: diff --git a/transaction_manager/eth.py b/transaction_manager/eth.py index b7d1e0eb..54d493c8 100644 --- a/transaction_manager/eth.py +++ b/transaction_manager/eth.py @@ -86,7 +86,7 @@ def chain_id(self) -> int: return self.w3.eth.chain_id def get_balance(self, address: str) -> int: - checksum_addres = self.w3.toChecksumAddress(address) + checksum_addres = self.w3.to_checksum_address(address) return self.w3.eth.get_balance(checksum_addres) TX_ATTRS = [ @@ -190,7 +190,7 @@ def send_tx(self, signed_tx: Dict) -> str: return tx_hash def get_nonce(self, address: str) -> int: - checksum_addres = self.w3.toChecksumAddress(address) + checksum_addres = self.w3.to_checksum_address(address) return self.w3.eth.get_transaction_count(checksum_addres) def wait_for_blocks( diff --git a/transaction_manager/structures.py b/transaction_manager/structures.py index 3750be3d..09c9ecce 100644 --- a/transaction_manager/structures.py +++ b/transaction_manager/structures.py @@ -76,6 +76,8 @@ class Tx: data: Optional[Dict] = None tx_hash: Optional[str] = None sent_ts: Optional[int] = None + method: Optional[str] = None + meta: Optional[Dict] = None MAPPED_ATTR = { 'chainId': 'chain_id',