This repository was archived by the owner on Sep 23, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,36 @@ const spec = {
29
29
] ,
30
30
} ;
31
31
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
+
32
62
async function isValidSignature (
33
63
address : string ,
34
64
sig : string ,
@@ -44,6 +74,18 @@ async function isValidSignature(
44
74
sig ,
45
75
) ;
46
76
} 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
+
47
89
return false ;
48
90
}
49
91
return returnValue . toLowerCase ( ) === magicValue . toLowerCase ( ) ;
You can’t perform that action at this time.
0 commit comments