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

Commit 61335b5

Browse files
committed
added support for older eip1271 implementations
1 parent 9cca9bb commit 61335b5

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/helpers/eip1271.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,36 @@ const spec = {
2929
],
3030
};
3131

32+
// support for older eip1271 implementations
33+
const spec_oldVersion = {
34+
magicValue: "0x20c13b0b",
35+
abi: [
36+
{
37+
constant: true,
38+
inputs: [
39+
{
40+
name: "_hash",
41+
type: "bytes",
42+
},
43+
{
44+
name: "_sig",
45+
type: "bytes",
46+
},
47+
],
48+
name: "isValidSignature",
49+
outputs: [
50+
{
51+
name: "magicValue",
52+
type: "bytes4",
53+
},
54+
],
55+
payable: false,
56+
stateMutability: "view",
57+
type: "function",
58+
},
59+
],
60+
};
61+
3262
async function isValidSignature(
3363
address: string,
3464
sig: string,
@@ -44,6 +74,18 @@ async function isValidSignature(
4474
sig,
4575
);
4676
} catch (e) {
77+
// if failed is latest then it might be older implementation
78+
if (magicValue === eip1271.spec.magicValue) {
79+
return isValidSignature(
80+
address,
81+
sig,
82+
data,
83+
provider,
84+
spec_oldVersion.abi, // old spec version abi
85+
spec_oldVersion.magicValue, // old spec version magicValue
86+
);
87+
}
88+
4789
return false;
4890
}
4991
return returnValue.toLowerCase() === magicValue.toLowerCase();

0 commit comments

Comments
 (0)