Skip to content

Commit

Permalink
Merge pull request #233 from polywrap/nerfzael/eth-address-fixes
Browse files Browse the repository at this point in the history
ETH address fixes
  • Loading branch information
cbrzn authored Apr 16, 2024
2 parents 92d08a9 + 78214b0 commit 624c189
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
4 changes: 2 additions & 2 deletions autotx/tests/agents/token/test_swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def test_auto_tx_swap_multiple_2(configuration, auto_tx):
(_, _, _, manager) = configuration
web3 = load_w3()
network_info = NetworkInfo(web3.eth.chain_id)
usdc_address = ETHAddress(network_info.tokens["usdc"], web3)
wbtc_address = ETHAddress(network_info.tokens["wbtc"], web3)
usdc_address = ETHAddress(network_info.tokens["usdc"])
wbtc_address = ETHAddress(network_info.tokens["wbtc"])

prompt = "Sell ETH for 1000 USDC and then sell 500 USDC for WBTC"
usdc_balance = manager.balance_of(usdc_address)
Expand Down
9 changes: 3 additions & 6 deletions autotx/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from dotenv import load_dotenv

from autotx.utils.ethereum.helpers.swap_from_eoa import swap
from autotx.utils.logging.Logger import Logger
load_dotenv()

from autotx.agents.ResearchTokensAgent import ResearchTokensAgent
Expand All @@ -15,7 +14,6 @@
from autotx.utils.ethereum.networks import NetworkInfo
from autotx.utils.ethereum.eth_address import ETHAddress
from autotx.utils.ethereum.helpers.get_dev_account import get_dev_account
from autotx.utils.ethereum.uniswap.swap import build_swap_transaction

import pytest
from autotx.AutoTx import AutoTx, Config
Expand All @@ -26,7 +24,6 @@
send_native,
transfer_erc20,
)
from gnosis.eth import EthereumClient

@pytest.fixture(autouse=True)
def start_and_stop_local_fork():
Expand Down Expand Up @@ -76,8 +73,8 @@ def usdc(configuration) -> ETHAddress:
chain_id = client.w3.eth.chain_id
network_info = NetworkInfo(chain_id)

eth_address = ETHAddress(network_info.tokens["eth"], client.w3)
usdc_address = ETHAddress(network_info.tokens["usdc"], client.w3)
eth_address = ETHAddress(network_info.tokens["eth"])
usdc_address = ETHAddress(network_info.tokens["usdc"])

amount = 100

Expand All @@ -92,6 +89,6 @@ def test_accounts(configuration) -> list[ETHAddress]:
(_, _, client, _) = configuration

# Create 10 random test accounts
accounts = [ETHAddress(Account.create().address, client.w3) for _ in range(10)]
accounts = [ETHAddress(Account.create().address) for _ in range(10)]

return accounts
16 changes: 8 additions & 8 deletions autotx/tests/integration/test_swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def test_swap(configuration):
(user, _, client, _) = configuration

network_info = NetworkInfo(client.w3.eth.chain_id)
weth_address = ETHAddress(network_info.tokens["weth"], client.w3)
wbtc_address = ETHAddress(network_info.tokens["wbtc"], client.w3)
weth_address = ETHAddress(network_info.tokens["weth"])
wbtc_address = ETHAddress(network_info.tokens["wbtc"])

user_addr = ETHAddress(user.address, client.w3)
user_addr = ETHAddress(user.address)

balance = get_erc20_balance(client.w3, wbtc_address, user_addr)
assert balance == 0
Expand Down Expand Up @@ -46,10 +46,10 @@ def test_swap_recieve_native(configuration):
(user, _, client, _) = configuration

network_info = NetworkInfo(client.w3.eth.chain_id)
eth_address = ETHAddress(network_info.tokens["eth"], client.w3)
usdc_address = ETHAddress(network_info.tokens["usdc"], client.w3)
eth_address = ETHAddress(network_info.tokens["eth"])
usdc_address = ETHAddress(network_info.tokens["usdc"])

user_addr = ETHAddress(user.address, client.w3)
user_addr = ETHAddress(user.address)

balance = get_native_balance(client.w3, user_addr)
assert int(balance) == 9989
Expand Down Expand Up @@ -104,8 +104,8 @@ def test_swap_through_safe(configuration):
(_, _, client, manager) = configuration

network_info = NetworkInfo(client.w3.eth.chain_id)
weth_address = ETHAddress(network_info.tokens["weth"], client.w3)
usdc_address = ETHAddress(network_info.tokens["usdc"], client.w3)
weth_address = ETHAddress(network_info.tokens["weth"])
usdc_address = ETHAddress(network_info.tokens["usdc"])

balance = manager.balance_of(usdc_address)
assert balance == 0
Expand Down
1 change: 0 additions & 1 deletion autotx/utils/ethereum/build_transfer_erc20.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from eth_typing import ChecksumAddress
from web3 import Web3
from web3.types import TxParams, Wei

Expand Down
1 change: 0 additions & 1 deletion autotx/utils/ethereum/eth_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from autotx.utils.ethereum.networks import MAINNET_DEFAULT_RPC


class ETHAddress:
hex: ChecksumAddress
ens_domain: str | None
Expand Down

0 comments on commit 624c189

Please sign in to comment.