Skip to content

Commit

Permalink
support EIP712Message
Browse files Browse the repository at this point in the history
  • Loading branch information
z80dev committed Aug 22, 2023
1 parent 2f90696 commit 621dc85
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ape_accounts/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any, Iterator, Optional

import click
from eip712.messages import EIP712Message
from eth_account import Account as EthAccount
from eth_account.messages import encode_defunct
from eth_utils import to_bytes
Expand Down Expand Up @@ -122,8 +123,11 @@ def delete(self):

def sign_message(self, msg: Any, **signer_options) -> Optional[MessageSignature]:
if isinstance(msg, str):
# Convert to SignableMessage for handling below
# Convert str to SignableMessage for handling below
msg = encode_defunct(text=msg)
elif isinstance(msg, EIP712Message):
# Convert EIP712Message to SignableMessage for handling below
msg = msg.signable_message
if isinstance(msg, SignableMessage):
user_approves = self.__autosign or click.confirm(f"{msg}\n\nSign: ")
if not user_approves:
Expand Down

0 comments on commit 621dc85

Please sign in to comment.