Skip to content
This repository was archived by the owner on Sep 23, 2024. It is now read-only.

added support for older eip1271 implementations #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/helpers/eip1271.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
Expand Down