@ledgerhq/hw-app-eth 6.38.2 → 7.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/lib/modules/EIP712/index.d.ts.map +1 -1
- package/lib/modules/EIP712/index.js +44 -8
- package/lib/modules/EIP712/index.js.map +1 -1
- package/lib/modules/EIP712/types.d.ts +4 -0
- package/lib/modules/EIP712/types.d.ts.map +1 -1
- package/lib/services/ledger/erc20.js +1 -1
- package/lib/services/ledger/erc20.js.map +1 -1
- package/lib-es/modules/EIP712/index.d.ts.map +1 -1
- package/lib-es/modules/EIP712/index.js +44 -8
- package/lib-es/modules/EIP712/index.js.map +1 -1
- package/lib-es/modules/EIP712/types.d.ts +4 -0
- package/lib-es/modules/EIP712/types.d.ts.map +1 -1
- package/lib-es/services/ledger/erc20.js +1 -1
- package/lib-es/services/ledger/erc20.js.map +1 -1
- package/package.json +5 -5
- package/src/modules/EIP712/index.ts +63 -8
- package/src/modules/EIP712/types.ts +4 -0
- package/src/services/ledger/erc20.ts +1 -1
- package/tests/EIP712/filtered-signMessage.unit.test.ts +226 -138
- package/tests/EIP712/noFilter-signMessage.unit.test.ts +20 -20
- package/tests/ERC20/ERC20-CAL-KO.unit.test.ts +14 -4
- package/tests/ERC20/ERC20-CAL-OK.unit.test.ts +14 -3
- package/tests/Eth.unit.test.ts +6 -2
- package/tests/fixtures/CAL.ts +301 -208
- package/tests/fixtures/apdus/{0-filtered.apdus → 0-filtered-v1.apdus} +5 -5
- package/tests/fixtures/apdus/1-filtered-empty-array-1-level-v2.apdus +72 -0
- package/tests/fixtures/apdus/1-filtered-empty-array-2-levels-v2.apdus +68 -0
- package/tests/fixtures/apdus/{1-filtered.apdus → 1-filtered-v1.apdus} +8 -8
- package/tests/fixtures/apdus/{10-filtered.apdus → 10-filtered-v1.apdus} +4 -4
- package/tests/fixtures/apdus/{11-filtered.apdus → 11-filtered-v1.apdus} +9 -9
- package/tests/fixtures/apdus/12-filtered-v1.apdus +38 -0
- package/tests/fixtures/apdus/13-filtered-v1.apdus +108 -0
- package/tests/fixtures/apdus/14-filtered-v1.apdus +28 -0
- package/tests/fixtures/apdus/15-filtered-v1.apdus +6 -6
- package/tests/fixtures/apdus/15-filtered-v2.apdus +7 -7
- package/tests/fixtures/apdus/16-filtered-v1.apdus +6 -6
- package/tests/fixtures/apdus/16-filtered-v2.apdus +7 -7
- package/tests/fixtures/apdus/17-filtered-v1.apdus +164 -0
- package/tests/fixtures/apdus/17-filtered-v2.apdus +168 -0
- package/tests/fixtures/apdus/18-filtered-v1.apdus +8 -8
- package/tests/fixtures/apdus/18-filtered-v2.apdus +10 -10
- package/tests/fixtures/apdus/{2-filtered.apdus → 2-filtered-v1.apdus} +7 -7
- package/tests/fixtures/apdus/3-filtered-v1.apdus +60 -0
- package/tests/fixtures/apdus/{4-filtered.apdus → 4-filtered-v1.apdus} +5 -5
- package/tests/fixtures/apdus/5-filtered-v1.apdus +176 -0
- package/tests/fixtures/apdus/{6-filtered.apdus → 6-filtered-v1.apdus} +9 -9
- package/tests/fixtures/apdus/{7-filtered.apdus → 7-filtered-v1.apdus} +7 -7
- package/tests/fixtures/apdus/{8-filtered.apdus → 8-filtered-v1.apdus} +8 -8
- package/tests/fixtures/apdus/{9-filtered.apdus → 9-filtered-v1.apdus} +8 -8
- package/tests/fixtures/apdus/ERC20-KO.apdus +1 -1
- package/tests/fixtures/apdus/ERC20-OK.apdus +3 -3
- package/tests/fixtures/apdus/version-1.12.0.apdus +2 -0
- package/tests/fixtures/messages/1-empty-array-1-level.json +79 -0
- package/tests/fixtures/messages/1-empty-array-2-levels.json +74 -0
- package/tests/fixtures/apdus/12-filtered.apdus +0 -38
- package/tests/fixtures/apdus/13-filtered.apdus +0 -108
- package/tests/fixtures/apdus/17-filtered.apdus +0 -0
- package/tests/fixtures/apdus/3-filtered.apdus +0 -60
- package/tests/fixtures/apdus/5-filtered.apdus +0 -176
|
@@ -14,8 +14,14 @@ const getFilePath = (type: "apdu" | "message", filename: string): string => {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
jest.mock("@ledgerhq/cryptoassets/data/eip712", () => v1);
|
|
18
|
-
jest.mock("@ledgerhq/cryptoassets/data/eip712_v2", () => v2);
|
|
17
|
+
jest.mock("@ledgerhq/cryptoassets-evm-signatures/data/eip712", () => v1);
|
|
18
|
+
jest.mock("@ledgerhq/cryptoassets-evm-signatures/data/eip712_v2", () => v2);
|
|
19
|
+
jest.mock("@ledgerhq/cryptoassets-evm-signatures/data/evm/index", () => ({
|
|
20
|
+
signatures: {
|
|
21
|
+
1: "AAAAZwRVU0RDoLhpkcYhizbB0Z1KLp6wzjYG60gAAAAGAAAAATBEAiBT0S5lTL5ipustFl3sP7dsPLF2QWaAyaXg3iWQsLnNigIgUEdqFpFVhGEAxiwzjHZ5FC0GD/VU92W8nBjTHrsy42AAAABoBFdFVEjAKqo5siP+jQoOXE8n6tkIPHVswgAAABIAAAABMEUCIQDGNSQY0A9zJrjwtmxxxdCfMG4OzgBJPLqeqOoXe0pI7QIgZGYxocaD2s6sFSA355FC7owyjNN8g6eOy4BeE44/Ovc=",
|
|
22
|
+
137: "AAAAZwRVU0RDJ5G8ofLeRmHtiKMMmaepRJqoQXQAAAAGAAAAiTBEAiBjxSGrC/C4mPSUtg6cVMGpgokwZmVNpdnc0rkfhL2c1gIgD+CqcDL9MWCffzbolbi1oWATL/5P3F1YWPvrLGaLG00AAABnBFdFVEh86yP9a8Ct1Z5irCVXgnDP8bn2GQAAABIAAACJMEQCIFBR0vbDO+KtsBq864UEM6P8+6U9jtZ80MCzRJi9MCpsAiAiSy+Re8z4tNPMwJh778qv04NadWUdQK8kfzY2EkC+WgAAAGkGV01BVElDDVALHY6O8x4hyZ0duaZETTrfEnAAAAASAAAAiTBEAiAzUzhabCGosL5APk2DKlMgGkrJxI8WmHeZ0xNKbrSHGQIgQIeT1ugsoIZD7J/5HZf6WmJ9yG/CRdvi88LrccoM9Bc=",
|
|
23
|
+
},
|
|
24
|
+
}));
|
|
19
25
|
nock.disableNetConnect();
|
|
20
26
|
|
|
21
27
|
describe("EIP712", () => {
|
|
@@ -25,8 +31,8 @@ describe("EIP712", () => {
|
|
|
25
31
|
nanoAppVersionApdus = await fs.readFile(getFilePath("apdu", "version-1.0.0"), "utf-8");
|
|
26
32
|
});
|
|
27
33
|
|
|
28
|
-
|
|
29
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "0-filtered"), "utf-8");
|
|
34
|
+
it("should sign correctly the 0.json sample message", async () => {
|
|
35
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "0-filtered-v1"), "utf-8");
|
|
30
36
|
const message = await fs.readFile(getFilePath("message", "0"), "utf-8").then(JSON.parse);
|
|
31
37
|
|
|
32
38
|
const transport = await openTransportReplayer(
|
|
@@ -37,14 +43,14 @@ describe("EIP712", () => {
|
|
|
37
43
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
38
44
|
|
|
39
45
|
expect(result).toEqual({
|
|
40
|
-
r: "
|
|
41
|
-
s: "
|
|
46
|
+
r: "b1a7312afb06c47b56d25475bdfdf37d907c84e6c1143825f85136062e941ff7",
|
|
47
|
+
s: "759c2298e0dba1792facd2e579eda48109e4640f4227575bf60db9b06f6e78c8",
|
|
42
48
|
v: 28,
|
|
43
49
|
});
|
|
44
50
|
});
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "1-filtered"), "utf-8");
|
|
52
|
+
it("should sign correctly the 1.json sample message", async () => {
|
|
53
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "1-filtered-v1"), "utf-8");
|
|
48
54
|
const message = await fs.readFile(getFilePath("message", "1"), "utf-8").then(JSON.parse);
|
|
49
55
|
|
|
50
56
|
const transport = await openTransportReplayer(
|
|
@@ -55,14 +61,14 @@ describe("EIP712", () => {
|
|
|
55
61
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
56
62
|
|
|
57
63
|
expect(result).toEqual({
|
|
64
|
+
r: "ea66f747173762715751c889fea8722acac3fc35db2c226d37a2e58815398f64",
|
|
65
|
+
s: "52d8ba9153de9255da220ffd36762c0b027701a3b5110f0a765f94b16a9dfb55",
|
|
58
66
|
v: 28,
|
|
59
|
-
r: "66ab3c335fa92801af51551371a95a898a6d862bae2087e0d4074cedb48f9d93",
|
|
60
|
-
s: "71aac1298822efc8b86b5d4618e7b0b91d73813b150645118414f40d06b2465a",
|
|
61
67
|
});
|
|
62
68
|
});
|
|
63
69
|
|
|
64
|
-
|
|
65
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "2-filtered"), "utf-8");
|
|
70
|
+
it("should sign correctly the 2.json sample message", async () => {
|
|
71
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "2-filtered-v1"), "utf-8");
|
|
66
72
|
const message = await fs.readFile(getFilePath("message", "2"), "utf-8").then(JSON.parse);
|
|
67
73
|
|
|
68
74
|
const transport = await openTransportReplayer(
|
|
@@ -73,14 +79,14 @@ describe("EIP712", () => {
|
|
|
73
79
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
74
80
|
|
|
75
81
|
expect(result).toEqual({
|
|
76
|
-
r: "
|
|
77
|
-
s: "
|
|
78
|
-
v:
|
|
82
|
+
r: "1539547ae7cf8ebcd3eabfb57cd2b1fb7775ce757c3f4a307c7425d35b7bfff7",
|
|
83
|
+
s: "47248cb61e554c1f90af6331d9c9e51cbb8655667514194f509abe097a032319",
|
|
84
|
+
v: 27,
|
|
79
85
|
});
|
|
80
86
|
});
|
|
81
87
|
|
|
82
|
-
|
|
83
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "3-filtered"), "utf-8");
|
|
88
|
+
it("should sign correctly the 3.json sample message", async () => {
|
|
89
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "3-filtered-v1"), "utf-8");
|
|
84
90
|
const message = await fs.readFile(getFilePath("message", "3"), "utf-8").then(JSON.parse);
|
|
85
91
|
|
|
86
92
|
const transport = await openTransportReplayer(
|
|
@@ -91,14 +97,14 @@ describe("EIP712", () => {
|
|
|
91
97
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
92
98
|
|
|
93
99
|
expect(result).toEqual({
|
|
94
|
-
r: "
|
|
95
|
-
s: "
|
|
96
|
-
v:
|
|
100
|
+
r: "5677fec212710c03127cc58c2b0ce31885f6147bc807cdd94de1343c1396d452",
|
|
101
|
+
s: "6624ddd7e50c1185f91d80ce4ef7adc96adb8c73e74cd8cb5087a44d3a134c8f",
|
|
102
|
+
v: 27,
|
|
97
103
|
});
|
|
98
104
|
});
|
|
99
105
|
|
|
100
|
-
|
|
101
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "4-filtered"), "utf-8");
|
|
106
|
+
it("should sign correctly the 4.json sample message", async () => {
|
|
107
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "4-filtered-v1"), "utf-8");
|
|
102
108
|
const message = await fs.readFile(getFilePath("message", "4"), "utf-8").then(JSON.parse);
|
|
103
109
|
|
|
104
110
|
const transport = await openTransportReplayer(
|
|
@@ -109,14 +115,14 @@ describe("EIP712", () => {
|
|
|
109
115
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
110
116
|
|
|
111
117
|
expect(result).toEqual({
|
|
112
|
-
r: "
|
|
113
|
-
s: "
|
|
114
|
-
v:
|
|
118
|
+
r: "341bca1c0dfd805d4befc21500084424dbe559c7aafd78d8fb461c0c76dfea1d",
|
|
119
|
+
s: "33ebb7b6fe0691961cd8b263faac20ecbbdcaef3febb57eb76614cad629080ea",
|
|
120
|
+
v: 28,
|
|
115
121
|
});
|
|
116
122
|
});
|
|
117
123
|
|
|
118
|
-
|
|
119
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "5-filtered"), "utf-8");
|
|
124
|
+
it("should sign correctly the 5.json sample message", async () => {
|
|
125
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "5-filtered-v1"), "utf-8");
|
|
120
126
|
const message = await fs.readFile(getFilePath("message", "5"), "utf-8").then(JSON.parse);
|
|
121
127
|
|
|
122
128
|
const transport = await openTransportReplayer(
|
|
@@ -127,14 +133,14 @@ describe("EIP712", () => {
|
|
|
127
133
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
128
134
|
|
|
129
135
|
expect(result).toEqual({
|
|
130
|
-
r: "
|
|
131
|
-
s: "
|
|
136
|
+
r: "e42c7fad36f615a566be673ecbd0542f83addf76ffa97af30acda06b3443ceca",
|
|
137
|
+
s: "72ca3cd5b3c9790e2a199c9d03342db7be374794d8bbffa2c4cb2aa1a16389e1",
|
|
132
138
|
v: 28,
|
|
133
139
|
});
|
|
134
140
|
});
|
|
135
141
|
|
|
136
|
-
|
|
137
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "6-filtered"), "utf-8");
|
|
142
|
+
it("should sign correctly the 6.json sample message", async () => {
|
|
143
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "6-filtered-v1"), "utf-8");
|
|
138
144
|
const message = await fs.readFile(getFilePath("message", "6"), "utf-8").then(JSON.parse);
|
|
139
145
|
|
|
140
146
|
const transport = await openTransportReplayer(
|
|
@@ -145,14 +151,14 @@ describe("EIP712", () => {
|
|
|
145
151
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
146
152
|
|
|
147
153
|
expect(result).toEqual({
|
|
148
|
-
r: "
|
|
149
|
-
s: "
|
|
154
|
+
r: "d10f6b61205cf5c5ec45735d7f7186afb7e454212102883caf9b6fd2ebdf9fd3",
|
|
155
|
+
s: "2d9c1af9ded7ddb0237c0b67b6a1a2c98fc73af8ff0bf6c43b356a79bbc929f3",
|
|
150
156
|
v: 27,
|
|
151
157
|
});
|
|
152
158
|
});
|
|
153
159
|
|
|
154
|
-
|
|
155
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "7-filtered"), "utf-8");
|
|
160
|
+
it("should sign correctly the 7.json sample message", async () => {
|
|
161
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "7-filtered-v1"), "utf-8");
|
|
156
162
|
const message = await fs.readFile(getFilePath("message", "7"), "utf-8").then(JSON.parse);
|
|
157
163
|
|
|
158
164
|
const transport = await openTransportReplayer(
|
|
@@ -163,14 +169,14 @@ describe("EIP712", () => {
|
|
|
163
169
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
164
170
|
|
|
165
171
|
expect(result).toEqual({
|
|
166
|
-
r: "
|
|
167
|
-
s: "
|
|
172
|
+
r: "df9e8b6b94a196b5b5608d8a83ad5479f050bbdfb301d4d3f4e2bfb30497fd44",
|
|
173
|
+
s: "1bd7074ce7035305a091b2f9994854fec0ceb2b11cf2620b93b76c1723029f6f",
|
|
168
174
|
v: 27,
|
|
169
175
|
});
|
|
170
176
|
});
|
|
171
177
|
|
|
172
|
-
|
|
173
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "8-filtered"), "utf-8");
|
|
178
|
+
it("should sign correctly the 8.json sample message", async () => {
|
|
179
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "8-filtered-v1"), "utf-8");
|
|
174
180
|
const message = await fs.readFile(getFilePath("message", "8"), "utf-8").then(JSON.parse);
|
|
175
181
|
|
|
176
182
|
const transport = await openTransportReplayer(
|
|
@@ -181,14 +187,14 @@ describe("EIP712", () => {
|
|
|
181
187
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
182
188
|
|
|
183
189
|
expect(result).toEqual({
|
|
184
|
-
r: "
|
|
185
|
-
s: "
|
|
186
|
-
v:
|
|
190
|
+
r: "59adf8ab1d0e87d2623747eac10d5ef23d0145d7f30e2960cba3503b28add2d3",
|
|
191
|
+
s: "109f81625ca7a9bb448fa58325b2f08d7f7141b14a20e363d7ea10a9483b780d",
|
|
192
|
+
v: 28,
|
|
187
193
|
});
|
|
188
194
|
});
|
|
189
195
|
|
|
190
|
-
|
|
191
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "9-filtered"), "utf-8");
|
|
196
|
+
it("should sign correctly the 9.json sample message", async () => {
|
|
197
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "9-filtered-v1"), "utf-8");
|
|
192
198
|
const message = await fs.readFile(getFilePath("message", "9"), "utf-8").then(JSON.parse);
|
|
193
199
|
|
|
194
200
|
const transport = await openTransportReplayer(
|
|
@@ -199,14 +205,14 @@ describe("EIP712", () => {
|
|
|
199
205
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
200
206
|
|
|
201
207
|
expect(result).toEqual({
|
|
202
|
-
r: "
|
|
203
|
-
s: "
|
|
208
|
+
r: "87698ac1d846331b4b393417353dd20c60b9401a407d76db52fb9e45844aab30",
|
|
209
|
+
s: "11b09b38be74fbf2cb5851470d4f70bf0cccaf1bea00ff28e16ca914deba15ce",
|
|
204
210
|
v: 28,
|
|
205
211
|
});
|
|
206
212
|
});
|
|
207
213
|
|
|
208
|
-
|
|
209
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "10-filtered"), "utf-8");
|
|
214
|
+
it("should sign correctly the 10.json sample message", async () => {
|
|
215
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "10-filtered-v1"), "utf-8");
|
|
210
216
|
const message = await fs.readFile(getFilePath("message", "10"), "utf-8").then(JSON.parse);
|
|
211
217
|
|
|
212
218
|
const transport = await openTransportReplayer(
|
|
@@ -217,14 +223,14 @@ describe("EIP712", () => {
|
|
|
217
223
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
218
224
|
|
|
219
225
|
expect(result).toEqual({
|
|
220
|
-
r: "
|
|
221
|
-
s: "
|
|
222
|
-
v:
|
|
226
|
+
r: "aaa9e17e5cb7d8a7d0ecc832a883254599909d8123d846aa6f3f63f47ab78704",
|
|
227
|
+
s: "2b7e6adaeb26906e6577efa04c1733a19169ee2747020b73f8f309ca8c2ccc1f",
|
|
228
|
+
v: 28,
|
|
223
229
|
});
|
|
224
230
|
});
|
|
225
231
|
|
|
226
|
-
|
|
227
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "11-filtered"), "utf-8");
|
|
232
|
+
it("should sign correctly the 11.json sample message", async () => {
|
|
233
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "11-filtered-v1"), "utf-8");
|
|
228
234
|
const message = await fs.readFile(getFilePath("message", "11"), "utf-8").then(JSON.parse);
|
|
229
235
|
|
|
230
236
|
const transport = await openTransportReplayer(
|
|
@@ -235,14 +241,14 @@ describe("EIP712", () => {
|
|
|
235
241
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
236
242
|
|
|
237
243
|
expect(result).toEqual({
|
|
238
|
-
r: "
|
|
239
|
-
s: "
|
|
244
|
+
r: "cce2e63aaac6a5f9a74684d8fdddcbc7f3b27aa17235bfab89226821ead933b6",
|
|
245
|
+
s: "3f3c93977abcc3f8cc9a3dc1ecc02dbca14aca1a6ecb2fb6ca3d7c713ace1ec4",
|
|
240
246
|
v: 28,
|
|
241
247
|
});
|
|
242
248
|
});
|
|
243
249
|
|
|
244
|
-
|
|
245
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "12-filtered"), "utf-8");
|
|
250
|
+
it("should sign correctly the 12.json sample message", async () => {
|
|
251
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "12-filtered-v1"), "utf-8");
|
|
246
252
|
const message = await fs.readFile(getFilePath("message", "12"), "utf-8").then(JSON.parse);
|
|
247
253
|
|
|
248
254
|
const transport = await openTransportReplayer(
|
|
@@ -253,14 +259,14 @@ describe("EIP712", () => {
|
|
|
253
259
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
254
260
|
|
|
255
261
|
expect(result).toEqual({
|
|
256
|
-
r: "
|
|
257
|
-
s: "
|
|
258
|
-
v:
|
|
262
|
+
r: "7be1671577753c13bfd1da8b234b6df8484daf47351c2366637fd291dd4aa4d9",
|
|
263
|
+
s: "1a7ffbb01dc8a64e9ee97d19b8f154e9eecbe0b1bfb9dcfa781a65e474573963",
|
|
264
|
+
v: 27,
|
|
259
265
|
});
|
|
260
266
|
});
|
|
261
267
|
|
|
262
|
-
|
|
263
|
-
const apdusBuffer = await fs.readFile(getFilePath("apdu", "13-filtered"), "utf-8");
|
|
268
|
+
it("should sign correctly the 13.json sample message", async () => {
|
|
269
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "13-filtered-v1"), "utf-8");
|
|
264
270
|
const message = await fs.readFile(getFilePath("message", "13"), "utf-8").then(JSON.parse);
|
|
265
271
|
|
|
266
272
|
const transport = await openTransportReplayer(
|
|
@@ -271,21 +277,49 @@ describe("EIP712", () => {
|
|
|
271
277
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
272
278
|
|
|
273
279
|
expect(result).toEqual({
|
|
274
|
-
r: "
|
|
275
|
-
s: "
|
|
280
|
+
r: "fde9bc1860bae0b867b66176ca654578530edf97771c714cc7bb146943443ef3",
|
|
281
|
+
s: "06f92884f1de6fe75c4a650b0fe88d0c185af9943a95dc1c4b3045ae0f81edfe",
|
|
276
282
|
v: 28,
|
|
277
283
|
});
|
|
278
284
|
});
|
|
279
285
|
|
|
280
|
-
|
|
281
|
-
|
|
286
|
+
it("should sign correctly the 14.json sample message", async () => {
|
|
287
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "14-filtered-v1"), "utf-8");
|
|
288
|
+
const message = await fs.readFile(getFilePath("message", "14"), "utf-8").then(JSON.parse);
|
|
289
|
+
|
|
290
|
+
const transport = await openTransportReplayer(
|
|
291
|
+
RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
const eth = new Eth(transport);
|
|
295
|
+
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
296
|
+
|
|
297
|
+
expect(result).toEqual({
|
|
298
|
+
r: "55ad4a9295fd8e64082f751f19f158db34de2a9072c0b348483ca4a303cf0cb0",
|
|
299
|
+
s: "69d732a52e29963a23d7c6ca032e46ae452cc2e3d9487952567ae4bffd14e237",
|
|
300
|
+
v: 28,
|
|
301
|
+
});
|
|
282
302
|
});
|
|
283
303
|
|
|
284
|
-
|
|
285
|
-
|
|
304
|
+
it("should sign correctly the 14bis.json sample message and have the same APDUs as 14.json", async () => {
|
|
305
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "14-filtered-v1"), "utf-8");
|
|
306
|
+
const message = await fs.readFile(getFilePath("message", "14bis"), "utf-8").then(JSON.parse);
|
|
307
|
+
|
|
308
|
+
const transport = await openTransportReplayer(
|
|
309
|
+
RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
const eth = new Eth(transport);
|
|
313
|
+
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
314
|
+
|
|
315
|
+
expect(result).toEqual({
|
|
316
|
+
r: "55ad4a9295fd8e64082f751f19f158db34de2a9072c0b348483ca4a303cf0cb0",
|
|
317
|
+
s: "69d732a52e29963a23d7c6ca032e46ae452cc2e3d9487952567ae4bffd14e237",
|
|
318
|
+
v: 28,
|
|
319
|
+
});
|
|
286
320
|
});
|
|
287
321
|
|
|
288
|
-
|
|
322
|
+
it("should sign correctly the 15-permit.json sample message", async () => {
|
|
289
323
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "15-filtered-v1"), "utf-8");
|
|
290
324
|
const message = await fs
|
|
291
325
|
.readFile(getFilePath("message", "15-permit"), "utf-8")
|
|
@@ -305,7 +339,7 @@ describe("EIP712", () => {
|
|
|
305
339
|
});
|
|
306
340
|
});
|
|
307
341
|
|
|
308
|
-
|
|
342
|
+
it("should sign correctly the 16-permit2.json sample message", async () => {
|
|
309
343
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "16-filtered-v1"), "utf-8");
|
|
310
344
|
const message = await fs
|
|
311
345
|
.readFile(getFilePath("message", "16-permit2"), "utf-8")
|
|
@@ -325,7 +359,7 @@ describe("EIP712", () => {
|
|
|
325
359
|
});
|
|
326
360
|
});
|
|
327
361
|
|
|
328
|
-
|
|
362
|
+
it("should sign correctly the 17-uniswapx.json sample message", async () => {
|
|
329
363
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "17-filtered-v1"), "utf-8");
|
|
330
364
|
const message = await fs
|
|
331
365
|
.readFile(getFilePath("message", "17-uniswapx"), "utf-8")
|
|
@@ -339,13 +373,13 @@ describe("EIP712", () => {
|
|
|
339
373
|
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
340
374
|
|
|
341
375
|
expect(result).toEqual({
|
|
342
|
-
r: "
|
|
343
|
-
s: "
|
|
344
|
-
v:
|
|
376
|
+
r: "63e951154de94e9f81ecefa38c0f11c2e4a9bfbaa3524b6c9744161211d6cc3b",
|
|
377
|
+
s: "62480171ceb1f39f2c41ff06a2ecd483c0faaaf459063b278c09803b8bef3e4d",
|
|
378
|
+
v: 27,
|
|
345
379
|
});
|
|
346
380
|
});
|
|
347
381
|
|
|
348
|
-
|
|
382
|
+
it("should sign correctly the 18-1inch-fusion.json sample message", async () => {
|
|
349
383
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "18-filtered-v1"), "utf-8");
|
|
350
384
|
const message = await fs
|
|
351
385
|
.readFile(getFilePath("message", "18-1inch-fusion"), "utf-8")
|
|
@@ -367,88 +401,142 @@ describe("EIP712", () => {
|
|
|
367
401
|
});
|
|
368
402
|
|
|
369
403
|
describe("SignEIP712Message with filters v2", () => {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
404
|
+
describe("from version 1.11.1", () => {
|
|
405
|
+
let nanoAppVersionApdus;
|
|
406
|
+
beforeAll(async () => {
|
|
407
|
+
nanoAppVersionApdus = await fs.readFile(getFilePath("apdu", "version-1.11.1"), "utf-8");
|
|
408
|
+
});
|
|
374
409
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
410
|
+
it("should sign correctly the 15-permit.json sample message", async () => {
|
|
411
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "15-filtered-v2"), "utf-8");
|
|
412
|
+
const message = await fs
|
|
413
|
+
.readFile(getFilePath("message", "15-permit"), "utf-8")
|
|
414
|
+
.then(JSON.parse);
|
|
380
415
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
416
|
+
const transport = await openTransportReplayer(
|
|
417
|
+
RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
|
|
418
|
+
);
|
|
384
419
|
|
|
385
|
-
|
|
386
|
-
|
|
420
|
+
const eth = new Eth(transport);
|
|
421
|
+
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
387
422
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
423
|
+
expect(result).toEqual({
|
|
424
|
+
r: "9573c40857d73d28b43120231886cf4199b1456e00da8887a508d576b6985a6f",
|
|
425
|
+
s: "18515302ca7809f9d36b95c8ea91509b602adc3c1653be0255ac5726969307bd",
|
|
426
|
+
v: 28,
|
|
427
|
+
});
|
|
392
428
|
});
|
|
393
|
-
});
|
|
394
429
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
430
|
+
it("should sign correctly the 16-permit2.json sample message", async () => {
|
|
431
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "16-filtered-v2"), "utf-8");
|
|
432
|
+
const message = await fs
|
|
433
|
+
.readFile(getFilePath("message", "16-permit2"), "utf-8")
|
|
434
|
+
.then(JSON.parse);
|
|
400
435
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
436
|
+
const transport = await openTransportReplayer(
|
|
437
|
+
RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
|
|
438
|
+
);
|
|
404
439
|
|
|
405
|
-
|
|
406
|
-
|
|
440
|
+
const eth = new Eth(transport);
|
|
441
|
+
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
407
442
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
443
|
+
expect(result).toEqual({
|
|
444
|
+
r: "ce7c4941157899c0db37c4363c773d919c896ddef669c878e856573659bb3655",
|
|
445
|
+
s: "0fed0222b941702c2fd5611ac13ac0217ed889586a56b047b0d5bf0566edbbb7",
|
|
446
|
+
v: 27,
|
|
447
|
+
});
|
|
412
448
|
});
|
|
413
|
-
});
|
|
414
449
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
450
|
+
it("should sign correctly the 17-uniswapx.json sample message", async () => {
|
|
451
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "17-filtered-v2"), "utf-8");
|
|
452
|
+
const message = await fs
|
|
453
|
+
.readFile(getFilePath("message", "17-uniswapx"), "utf-8")
|
|
454
|
+
.then(JSON.parse);
|
|
420
455
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
456
|
+
const transport = await openTransportReplayer(
|
|
457
|
+
RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
|
|
458
|
+
);
|
|
424
459
|
|
|
425
|
-
|
|
426
|
-
|
|
460
|
+
const eth = new Eth(transport);
|
|
461
|
+
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
427
462
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
463
|
+
expect(result).toEqual({
|
|
464
|
+
r: "63e951154de94e9f81ecefa38c0f11c2e4a9bfbaa3524b6c9744161211d6cc3b",
|
|
465
|
+
s: "62480171ceb1f39f2c41ff06a2ecd483c0faaaf459063b278c09803b8bef3e4d",
|
|
466
|
+
v: 27,
|
|
467
|
+
});
|
|
432
468
|
});
|
|
433
|
-
});
|
|
434
469
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
470
|
+
it("should sign correctly the 18-1inch-fusion.json sample message", async () => {
|
|
471
|
+
const apdusBuffer = await fs.readFile(getFilePath("apdu", "18-filtered-v2"), "utf-8");
|
|
472
|
+
const message = await fs
|
|
473
|
+
.readFile(getFilePath("message", "18-1inch-fusion"), "utf-8")
|
|
474
|
+
.then(JSON.parse);
|
|
440
475
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
476
|
+
const transport = await openTransportReplayer(
|
|
477
|
+
RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
|
|
478
|
+
);
|
|
444
479
|
|
|
445
|
-
|
|
446
|
-
|
|
480
|
+
const eth = new Eth(transport);
|
|
481
|
+
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
447
482
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
483
|
+
expect(result).toEqual({
|
|
484
|
+
r: "6f07ba3bb7fa9369ee9b5e4cc3bdc8545d75e3527fa242a5e4d23ead9d232af8",
|
|
485
|
+
s: "412a55401fe955b996125682ad0a47277d3ce1b314ee3962956ae643b71166cb",
|
|
486
|
+
v: 27,
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
});
|
|
490
|
+
describe("from version 1.12.0", () => {
|
|
491
|
+
let nanoAppVersionApdus;
|
|
492
|
+
beforeAll(async () => {
|
|
493
|
+
nanoAppVersionApdus = await fs.readFile(getFilePath("apdu", "version-1.12.0"), "utf-8");
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
it("should sign correctly the 1-empty-array-1-level.json sample message", async () => {
|
|
497
|
+
const apdusBuffer = await fs.readFile(
|
|
498
|
+
getFilePath("apdu", "1-filtered-empty-array-1-level-v2"),
|
|
499
|
+
"utf-8",
|
|
500
|
+
);
|
|
501
|
+
const message = await fs
|
|
502
|
+
.readFile(getFilePath("message", "1-empty-array-1-level"), "utf-8")
|
|
503
|
+
.then(JSON.parse);
|
|
504
|
+
|
|
505
|
+
const transport = await openTransportReplayer(
|
|
506
|
+
RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
|
|
507
|
+
);
|
|
508
|
+
|
|
509
|
+
const eth = new Eth(transport);
|
|
510
|
+
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
511
|
+
|
|
512
|
+
expect(result).toEqual({
|
|
513
|
+
r: "d564c78ed10b539ca83410d9deca79fdaaa250ad53c4dc41433ba55d02a26d25",
|
|
514
|
+
s: "50d3ed7f9c66b3f2c60ffb9b6c696b8f06cd88cafe4ae8371642ab7771827c3a",
|
|
515
|
+
v: 27,
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
it("should sign correctly the 1-empty-array-2-levels.json sample message", async () => {
|
|
520
|
+
const apdusBuffer = await fs.readFile(
|
|
521
|
+
getFilePath("apdu", "1-filtered-empty-array-2-levels-v2"),
|
|
522
|
+
"utf-8",
|
|
523
|
+
);
|
|
524
|
+
const message = await fs
|
|
525
|
+
.readFile(getFilePath("message", "1-empty-array-2-levels"), "utf-8")
|
|
526
|
+
.then(JSON.parse);
|
|
527
|
+
|
|
528
|
+
const transport = await openTransportReplayer(
|
|
529
|
+
RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
const eth = new Eth(transport);
|
|
533
|
+
const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
|
|
534
|
+
|
|
535
|
+
expect(result).toEqual({
|
|
536
|
+
r: "4217052c28965d9d1cdba00a65b5d9a18c41e0ea60161cd5f3b0ccffd2d4a536",
|
|
537
|
+
s: "589c87ae016194d0981925d203d203390e6f706e270a7b4ba579a106539ade08",
|
|
538
|
+
v: 28,
|
|
539
|
+
});
|
|
452
540
|
});
|
|
453
541
|
});
|
|
454
542
|
});
|