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

TypeError: Unknown kwargs: ['from'] when calling account.sign_transaction #18

Open
penandlim opened this issue Jan 15, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@penandlim
Copy link

Environment information

  • ape and plugin versions:
$ ape --version
0.8.24
$ ape plugins list
Third-party Plugins
  aws          0.8.0a3
  etherscan    0.8.4
  foundry      0.8.7
  infura       0.8.4
  tokens       0.8.3
  • Python Version: 3.11.10
  • OS: osx

What went wrong?

When signing a transaction with the aws account, it raises TypeError like below

File "/home/ubuntu/.local/lib/python3.11/site-packages/ape_ethereum/multicall/handlers.py", line 294, in __call__
    return self.handler(self.calls, **txn_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/.local/lib/python3.11/site-packages/ape/contracts/base.py", line 428, in __call__
    return contract_transaction(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/.local/lib/python3.11/site-packages/ape/contracts/base.py", line 361, in __call__
    return kwargs["sender"].call(txn, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/.local/lib/python3.11/site-packages/ape/api/accounts.py", line 180, in call
    signed_txn = self.sign_transaction(txn, **signer_options)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/.local/lib/python3.11/site-packages/ape_aws/accounts.py", line 94, in sign_transaction
    unsigned_txn = serializable_unsigned_transaction_from_dict(txn.model_dump()).hash()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/.local/lib/python3.11/site-packages/eth_account/_utils/typed_transactions/typed_transaction.py", line 139, in hash
    return self.transaction.hash()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/.local/lib/python3.11/site-packages/eth_account/_utils/typed_transactions/dynamic_fee_transaction.py", line 210, in hash
    rlp_serializer.from_dict(rlp_structured_txn_without_sig_fields),  # type: ignore  # noqa: E501
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/.local/lib/python3.11/site-packages/eth_rlp/main.py", line 74, in from_dict
    return cls(**field_dict)
           ^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/.local/lib/python3.11/site-packages/rlp/sedes/serializable.py", line 191, in __init__
    field_values = merge_kwargs_to_args(args, kwargs, self._meta.field_names)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/.local/lib/python3.11/site-packages/eth_utils/functional.py", line 47, in inner
    return callback(fn(*args, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/.local/lib/python3.11/site-packages/rlp/sedes/serializable.py", line 60, in merge_kwargs_to_args
    validate_args_and_kwargs(args, kwargs, arg_names, allow_missing=allow_missing)
  File "/home/ubuntu/.local/lib/python3.11/site-packages/rlp/sedes/serializable.py", line 51, in validate_args_and_kwargs
    raise TypeError(f"Unknown kwargs: {sorted(unknown_kwargs)}")

How can it be fixed?

Removing the from field from the model_dump before passing it to serializable_unsigned_transaction_from_dict seems to solve this for me.

https://github.com/ApeWorX/ape-aws/blob/main/ape_aws/accounts.py#L94

        dump = txn.model_dump()
        # remove the key value pair of "from"
        dump.pop("from", None)
        unsigned_txn = serializable_unsigned_transaction_from_dict(dump).hash()
@penandlim penandlim added the bug Something isn't working label Jan 15, 2025
Copy link

linear bot commented Jan 15, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant