|
83 | 83 | )
|
84 | 84 | from grants.utils import (
|
85 | 85 | 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, |
87 | 87 | )
|
88 | 88 | from marketing.mails import grant_cancellation, new_grant_flag_admin
|
89 | 89 | from marketing.models import ImageDropZone, Keyword, Stat
|
@@ -2956,8 +2956,12 @@ def verify_signature(signature, message, expected_address):
|
2956 | 2956 | message_hash = defunct_hash_message(text=message)
|
2957 | 2957 | recovered_address = w3.eth.account.recoverHash(message_hash, signature=signature)
|
2958 | 2958 | 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") |
2961 | 2965 | try:
|
2962 | 2966 | if txHash != '':
|
2963 | 2967 | receipt = w3.eth.getTransactionReceipt(txHash)
|
|
0 commit comments