ApeWorX / ape-optimism

Optimism network provider plugin for the Ape Framework
https://www.apeworx.io/
Apache License 2.0
9 stars 9 forks source link

DEFAULT_TRANSACTION_TYPE Missing #26

Closed solarthesis closed 9 months ago

solarthesis commented 9 months ago

Environment information

$ ape --version
# ...copy and paste result of above command here...
0.7.7

$ ape plugins list
# ...copy and paste result of above command here...
Installed Plugins
  alchemy      0.7.1
  etherscan    0.7.0
  foundry      0.7.1
  optimism     0.7.1
  safe         0.7.0b1.dev2+g5b61087
  solidity     0.7.1

What went wrong?

Please include information like:

When trying to withdraw eth having weth in a gnosis safe:

with networks.optimism.mainnet.use_default_provider():            
    #fetch safe
    testSafe = "0xMYSAFE"
    accounts.containers["safe"].delete_account("test-safe")
    accounts.containers["safe"].save_account(address=testSafe,alias="test-safe")
    safe = accounts.load("test-safe")
    #fetch deployer
    deployer = accounts.load("test-deployer")
    deployer.set_autosign(True,passphrase=passphrase)
    #setup test tx
    txn = multisend.MultiSend()            
    address = '0x4200000000000000000000000000000000000006'
    abi = '''[{"constant":false,"inputs":[{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]'''
    apeContract = Contract(address=address,abi=abi)
    txn.add(apeContract.withdraw,1000)
    txn(sender=safe,type=2,gas=0,submit=False)

I get the below error

runcell(0, '/home/thesis/repos/monitor_ape/utils/testkit.py')

runcell(1, '/home/thesis/repos/monitor_ape/utils/testkit.py')
WARNING: Danger! This account will now sign any transaction it's given.
Traceback (most recent call last):

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/utils/basemodel.py:302 in __getattr__
    res = super().__getattribute__(name)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_ethereum/ecosystem.py:337 in default_transaction_type
    ecosystem_default = network.config.DEFAULT_TRANSACTION_TYPE

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/api/config.py:58 in __getattr__
    return super().__getattribute__(attr_name)

AttributeError: 'OptimismConfig' object has no attribute 'DEFAULT_TRANSACTION_TYPE'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File ~/repos/monitor_ape/utils/testkit.py:277
    self.run_test_multisend()

  File ~/repos/monitor_ape/utils/testkit.py:270 in run_test_multisend
    txn(sender=safe,type=2,gas=0,submit=False)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_safe/multisend.py:220 in __call__
    return self.handler(b"".join(self.encoded_calls), **txn_kwargs)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/contracts/base.py:354 in __call__
    return contract_transaction(*args, **kwargs)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/contracts/base.py:288 in __call__
    return kwargs["sender"].call(txn, **kwargs)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/contextlib.py:79 in inner
    return func(*args, **kwds)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_safe/accounts.py:529 in call
    return super().call(txn, **call_kwargs)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/api/accounts.py:152 in call
    signed_txn = self.sign_transaction(txn, **signer_options)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_safe/accounts.py:657 in sign_transaction
    sigs_by_signer = self._all_approvals(safe_tx)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_safe/accounts.py:560 in _all_approvals
    approvals.update(self._contract_approvals(safe_tx))

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_safe/accounts.py:548 in _contract_approvals
    safe_tx_hash = self.contract.getTransactionHash(*safe_tx_exec_args)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/contracts/base.py:198 in __call__
    return ContractCall(

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/contracts/base.py:98 in __call__
    txn = self.serialize_transaction(*args, **kwargs)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/contracts/base.py:93 in serialize_transaction
    return self.provider.network.ecosystem.encode_transaction(

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_ethereum/ecosystem.py:721 in encode_transaction
    txn = self.create_transaction(receiver=address, **kwargs)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_ethereum/ecosystem.py:791 in create_transaction
    version = self.default_transaction_type

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/utils/basemodel.py:335 in __getattr__
    raise attr_err from base_err

ApeAttributeError: 'OptimismConfig' object has no attribute 'DEFAULT_TRANSACTION_TYPE'

How can it be fixed?

Fill this in if you have ideas on how the bug could be fixed. I am not sure i tried including type=2, still doesn't work, only happens when staging a transaction and committing to to the gnosis safe plugin https://github.com/ApeWorX/ape-safe/pull/31

linear[bot] commented 9 months ago

APE-1671 DEFAULT_TRANSACTION_TYPE Missing

antazoey commented 9 months ago

optimism 0.7.1

This was fixed in 0.7.2! :)

solarthesis commented 9 months ago

indeed, i tested out the multisend functionality with 0.7.2 and it works fine :pray: