Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format 'from' and 'to' fields to checksum addresses in RECEIPT_FORMAT… #1562

Merged
merged 1 commit into from Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/1562.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make 'from' and 'to' fields checksum addresses in returned transaction receipts
4 changes: 4 additions & 0 deletions tests/integration/test_ethereum_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ def test_eth_chainId(self, web3):
assert is_integer(chain_id)
assert chain_id == 61

@pytest.mark.xfail(raises=KeyError, reason="ethereum tester doesn't return 'to' key")
def test_eth_getTransactionReceipt_mined(self, web3, block_with_txn, mined_txn_hash):
super().test_eth_getTransactionReceipt_mined(web3, block_with_txn, mined_txn_hash)


class TestEthereumTesterVersionModule(VersionModuleTest):
pass
Expand Down
2 changes: 2 additions & 0 deletions web3/_utils/method_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ def apply_list_to_array_formatter(formatter: Any) -> Callable[..., Any]:
'contractAddress': apply_formatter_if(is_not_null, to_checksum_address),
'logs': apply_list_to_array_formatter(log_entry_formatter),
'logsBloom': to_hexbytes(256),
'from': apply_formatter_if(is_not_null, to_checksum_address),
'to': apply_formatter_if(is_address, to_checksum_address),
}


Expand Down
3 changes: 3 additions & 0 deletions web3/_utils/module_testing/eth_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,9 @@ def test_eth_getTransactionReceipt_mined(
assert receipt['blockHash'] == block_with_txn['hash']
assert receipt['transactionIndex'] == 0
assert receipt['transactionHash'] == HexBytes(mined_txn_hash)
assert is_checksum_address(receipt['to'])
assert receipt['from'] is not None
assert is_checksum_address(receipt['from'])

def test_eth_getTransactionReceipt_unmined(
self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress
Expand Down