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

Don't encode addresses as checksums with web3 #5700

Merged
merged 1 commit into from
Jan 20, 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
18 changes: 8 additions & 10 deletions raiden/network/proxies/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ def allowance(
self, owner: Address, spender: Address, block_identifier: BlockSpecification
) -> TokenAmount:
return TokenAmount(
self.proxy.contract.functions.allowance(
to_checksum_address(owner), to_checksum_address(spender)
).call(block_identifier=block_identifier)
self.proxy.contract.functions.allowance(owner, spender).call(
block_identifier=block_identifier
)
)

def approve(self, allowed_address: Address, allowance: TokenAmount) -> None:
Expand Down Expand Up @@ -93,15 +93,15 @@ def approve(self, allowed_address: Address, allowance: TokenAmount) -> None:
checking_block = self.client.get_checking_block()
error_prefix = "Call to approve will fail"
gas_limit = self.proxy.estimate_gas(
checking_block, "approve", to_checksum_address(allowed_address), allowance
checking_block, "approve", allowed_address, allowance
)

if gas_limit:
error_prefix = "Call to approve failed"
gas_limit = safe_gas_limit(gas_limit)
log_details["gas_limit"] = gas_limit
transaction_hash = self.proxy.transact(
"approve", gas_limit, to_checksum_address(allowed_address), allowance
"approve", gas_limit, allowed_address, allowance
)

receipt = self.client.poll(transaction_hash)
Expand Down Expand Up @@ -173,7 +173,7 @@ def balance_of(
self, address: Address, block_identifier: BlockSpecification = "latest"
) -> Balance:
""" Return the balance of `address`. """
return self.proxy.contract.functions.balanceOf(to_checksum_address(address)).call(
return self.proxy.contract.functions.balanceOf(address).call(
block_identifier=block_identifier
)

Expand Down Expand Up @@ -220,17 +220,15 @@ def transfer(self, to_address: Address, amount: TokenAmount) -> None:

with log_transaction(log, "transfer", log_details):
checking_block = self.client.get_checking_block()
gas_limit = self.proxy.estimate_gas(
checking_block, "transfer", to_checksum_address(to_address), amount
)
gas_limit = self.proxy.estimate_gas(checking_block, "transfer", to_address, amount)
failed_receipt = None

if gas_limit is not None:
gas_limit = safe_gas_limit(gas_limit)
log_details["gas_limit"] = gas_limit

transaction_hash = self.proxy.transact(
"transfer", gas_limit, to_checksum_address(to_address), amount
"transfer", gas_limit, to_address, amount
)

receipt = self.client.poll(transaction_hash)
Expand Down
8 changes: 3 additions & 5 deletions raiden/network/proxies/token_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,7 @@ def _detail_participant(
raise_if_invalid_address_pair(detail_for, partner)

data = self.proxy.contract.functions.getChannelParticipantInfo(
channel_identifier=channel_identifier,
participant=to_checksum_address(detail_for),
partner=to_checksum_address(partner),
channel_identifier=channel_identifier, participant=detail_for, partner=partner
).call(block_identifier=block_identifier)

return ParticipantDetails(
Expand Down Expand Up @@ -492,8 +490,8 @@ def _detail_channel(

channel_data = self.proxy.contract.functions.getChannelInfo(
channel_identifier=channel_identifier,
participant1=to_checksum_address(participant1),
participant2=to_checksum_address(participant2),
participant1=participant1,
participant2=participant2,
).call(block_identifier=block_identifier)

return ChannelData(
Expand Down
6 changes: 3 additions & 3 deletions raiden/network/proxies/token_network_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def get_token_network(
"""
typecheck(token_address, T_TargetAddress)

address = self.proxy.contract.functions.token_to_token_networks(
to_checksum_address(token_address)
).call(block_identifier=block_identifier)
address = self.proxy.contract.functions.token_to_token_networks(token_address).call(
block_identifier=block_identifier
)
address = to_canonical_address(address)

if address == NULL_ADDRESS_BYTES:
Expand Down
16 changes: 4 additions & 12 deletions raiden/network/proxies/user_deposit.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,7 @@ def _init(
) -> None:
checking_block = self.client.get_checking_block()
gas_limit = self.proxy.estimate_gas(
checking_block,
"init",
to_checksum_address(monitoring_service_address),
to_checksum_address(one_to_n_address),
checking_block, "init", monitoring_service_address, one_to_n_address
)

if not gas_limit:
Expand Down Expand Up @@ -232,10 +229,7 @@ def _init(
log_details["gas_limit"] = gas_limit

transaction_hash = self.proxy.transact(
"init",
gas_limit,
to_checksum_address(monitoring_service_address),
to_checksum_address(one_to_n_address),
"init", gas_limit, monitoring_service_address, one_to_n_address
)

receipt = self.client.poll(transaction_hash)
Expand Down Expand Up @@ -379,9 +373,7 @@ def _deposit(
token.approve(allowed_address=Address(self.address), allowance=amount_to_deposit)

checking_block = self.client.get_checking_block()
gas_limit = self.proxy.estimate_gas(
checking_block, "deposit", to_checksum_address(beneficiary), total_deposit
)
gas_limit = self.proxy.estimate_gas(checking_block, "deposit", beneficiary, total_deposit)

if not gas_limit:
failed_at = self.proxy.rpc_client.get_block("latest")
Expand Down Expand Up @@ -444,7 +436,7 @@ def _deposit(
log_details["gas_limit"] = gas_limit

transaction_hash = self.proxy.transact(
"deposit", gas_limit, to_checksum_address(beneficiary), total_deposit
"deposit", gas_limit, beneficiary, total_deposit
)

receipt = self.client.poll(transaction_hash)
Expand Down