ApeWorX / ape

The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
https://apeworx.io
Apache License 2.0
872 stars 133 forks source link

`ape_accounts.TestAccount` does not support `.sign_message` for `eip712.EIP712Message` types #1961

Closed fubuloubu closed 6 months ago

fubuloubu commented 6 months ago

Environment information

$ ape --version
0.7.7

$ ape plugins list
Installed Plugins
  ens          0.7.0
  etherscan    0.7.0
  foundry      0.7.0
  infura       0.7.0
  ledger       0.7.0
  optimism     0.7.3
  safe         0.7.0b2.dev6+g20a5330
  solidity     0.7.0
  tokens       0.7.0
$ cat ape-config.yaml
contracts_folder: tests/contracts

plugins:
  - name: foundry
  - name: solidity
  - name: etherscan
  - name: alchemy

ethereum:
  mainnet:
    default_provider: alchemy
  local:
    default_provider: foundry

dependencies:
  - name: openzeppelin
    github: OpenZeppelin/openzeppelin-contracts
    version: 3.4.0
  - name: safe-contracts
    npm: "@gnosis.pm/safe-contracts"
    version: 1.3.0
    config_override:
      solidity:
        version: 0.7.6
      compile:
        exclude:
          - "test/*"
          - "interfaces/*"

solidity:
  import_remapping:
    - "@openzeppelin/contracts=openzeppelin/v3.4.0"
    - "@gnosis=safe-contracts/v1.3.0"

foundry:
  fork:
      ethereum:
        mainnet:
          upstream_provider: alchemy
          block_number: 15776634
        goerli:
          upstream_provider: alchemy
          block_number: 7849922
        sepolia:
          upstream_provider: alchemy
          block_number: 3091950

What went wrong?

When working on https://github.com/ApeWorX/ape-safe/pull/41 I noticed that unlike ape_accounts.KeyfileAccount, ape_ledger.LedgerAccount, ape_trezor.TrezorAccount, or ape_frame.FrameAccount, the default built-in test accounts do not allow signing eip712.EIP712Message struct types, for which I had to monkeypatch this behavior to maintain a consistent interface in the feature I was working on.

How can it be fixed?

Add handling for eip712.EIP712Message signing

linear[bot] commented 6 months ago

APE-1708 `ape_accounts.TestAccount` does not support `.sign_message` for `eip712.EIP712Message` types