Skip to content

Commit d95b0bc

Browse files
authored
Allow smart contract wallets to sign correctly (EIP-1271) for grant ingesting (#10614)
1 parent bbe1093 commit d95b0bc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

app/grants/views.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
)
8484
from grants.utils import (
8585
emoji_codes, generate_collection_thumbnail, generate_img_thumbnail_helper, get_clr_rounds_metadata, get_user_code,
86-
is_grant_team_member, sync_payout, toggle_user_sybil,
86+
is_grant_team_member, is_valid_eip_1271_signature, sync_payout, toggle_user_sybil,
8787
)
8888
from marketing.mails import grant_cancellation, new_grant_flag_admin
8989
from marketing.models import ImageDropZone, Keyword, Stat
@@ -2956,8 +2956,12 @@ def verify_signature(signature, message, expected_address):
29562956
message_hash = defunct_hash_message(text=message)
29572957
recovered_address = w3.eth.account.recoverHash(message_hash, signature=signature)
29582958
if recovered_address.lower() != expected_address.lower():
2959-
raise Exception("Signature could not be verified")
2960-
2959+
# The signature could still be valid if the wallet is a contract and supports EIP-1271
2960+
logger.info("Signatures didn't match from recoverHash(), trying EIP-1271 support")
2961+
if not is_valid_eip_1271_signature(w3, w3.toChecksumAddress(expected_address), message_hash, signature):
2962+
raise Exception("Signature could not be verified")
2963+
else:
2964+
logger.info("EIP-1271 signature verified")
29612965
try:
29622966
if txHash != '':
29632967
receipt = w3.eth.getTransactionReceipt(txHash)

0 commit comments

Comments
 (0)