Skip to content

Commit

Permalink
Fix issue with non checksummed addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Giacomo Licari committed Jan 29, 2024
1 parent 8b44690 commit 5091cc7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions api/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ def ask():

amount_wei = w3.to_wei(amount, 'ether')
try:
# convert to checksum address
recipient = w3.to_checksum_address(recipient)

if token_address == 'native':
tx_hash = claim_native(w3, app.config['FAUCET_ADDRESS'], recipient, amount_wei)
else:
Expand Down
11 changes: 10 additions & 1 deletion api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
from conftest import api_prefix
# from mock import patch
from temp_env_var import TEMP_ENV_VARS, NATIVE_TRANSFER_TX_HASH, TOKEN_TRANSFER_TX_HASH, ZERO_ADDRESS, CAPTCHA_TEST_RESPONSE_TOKEN, NATIVE_TOKEN_AMOUNT, NATIVE_TOKEN_ADDRESS, ERC20_TOKEN_ADDRESS
from temp_env_var import TEMP_ENV_VARS, NATIVE_TRANSFER_TX_HASH, TOKEN_TRANSFER_TX_HASH, ZERO_ADDRESS, CAPTCHA_TEST_RESPONSE_TOKEN, NATIVE_TOKEN_AMOUNT, NATIVE_TOKEN_ADDRESS, ERC20_TOKEN_AMOUNT, ERC20_TOKEN_ADDRESS


class BaseTest:
Expand Down Expand Up @@ -82,6 +82,15 @@ def test_ask_route_parameters(self, client):
})
assert response.status_code == 400

response = client.post(api_prefix + '/ask', json={
'captcha': CAPTCHA_TEST_RESPONSE_TOKEN,
'chainId': TEMP_ENV_VARS['FAUCET_CHAIN_ID'],
'amount': ERC20_TOKEN_AMOUNT,
'recipient': '0x00000123',
'tokenAddress': ERC20_TOKEN_ADDRESS
})
assert response.status_code == 400

# missing token address, should return 400
response = client.post(api_prefix + '/ask', json={
'captcha': CAPTCHA_TEST_RESPONSE_TOKEN,
Expand Down

0 comments on commit 5091cc7

Please sign in to comment.