diff --git a/src/helpers/eip1271.ts b/src/helpers/eip1271.ts index 1001bc8..398686b 100644 --- a/src/helpers/eip1271.ts +++ b/src/helpers/eip1271.ts @@ -29,6 +29,36 @@ const spec = { ], }; +// support for older eip1271 implementations +const spec_oldVersion = { + magicValue: "0x20c13b0b", + abi: [ + { + constant: true, + inputs: [ + { + name: "_hash", + type: "bytes", + }, + { + name: "_sig", + type: "bytes", + }, + ], + name: "isValidSignature", + outputs: [ + { + name: "magicValue", + type: "bytes4", + }, + ], + payable: false, + stateMutability: "view", + type: "function", + }, + ], +}; + async function isValidSignature( address: string, sig: string, @@ -44,6 +74,18 @@ async function isValidSignature( sig, ); } catch (e) { + // if failed is latest then it might be older implementation + if (magicValue === eip1271.spec.magicValue) { + return isValidSignature( + address, + sig, + data, + provider, + spec_oldVersion.abi, // old spec version abi + spec_oldVersion.magicValue, // old spec version magicValue + ); + } + return false; } return returnValue.toLowerCase() === magicValue.toLowerCase();