@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.
Files changed (60) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/lib/modules/EIP712/index.d.ts.map +1 -1
  3. package/lib/modules/EIP712/index.js +44 -8
  4. package/lib/modules/EIP712/index.js.map +1 -1
  5. package/lib/modules/EIP712/types.d.ts +4 -0
  6. package/lib/modules/EIP712/types.d.ts.map +1 -1
  7. package/lib/services/ledger/erc20.js +1 -1
  8. package/lib/services/ledger/erc20.js.map +1 -1
  9. package/lib-es/modules/EIP712/index.d.ts.map +1 -1
  10. package/lib-es/modules/EIP712/index.js +44 -8
  11. package/lib-es/modules/EIP712/index.js.map +1 -1
  12. package/lib-es/modules/EIP712/types.d.ts +4 -0
  13. package/lib-es/modules/EIP712/types.d.ts.map +1 -1
  14. package/lib-es/services/ledger/erc20.js +1 -1
  15. package/lib-es/services/ledger/erc20.js.map +1 -1
  16. package/package.json +5 -5
  17. package/src/modules/EIP712/index.ts +63 -8
  18. package/src/modules/EIP712/types.ts +4 -0
  19. package/src/services/ledger/erc20.ts +1 -1
  20. package/tests/EIP712/filtered-signMessage.unit.test.ts +226 -138
  21. package/tests/EIP712/noFilter-signMessage.unit.test.ts +20 -20
  22. package/tests/ERC20/ERC20-CAL-KO.unit.test.ts +14 -4
  23. package/tests/ERC20/ERC20-CAL-OK.unit.test.ts +14 -3
  24. package/tests/Eth.unit.test.ts +6 -2
  25. package/tests/fixtures/CAL.ts +301 -208
  26. package/tests/fixtures/apdus/{0-filtered.apdus → 0-filtered-v1.apdus} +5 -5
  27. package/tests/fixtures/apdus/1-filtered-empty-array-1-level-v2.apdus +72 -0
  28. package/tests/fixtures/apdus/1-filtered-empty-array-2-levels-v2.apdus +68 -0
  29. package/tests/fixtures/apdus/{1-filtered.apdus → 1-filtered-v1.apdus} +8 -8
  30. package/tests/fixtures/apdus/{10-filtered.apdus → 10-filtered-v1.apdus} +4 -4
  31. package/tests/fixtures/apdus/{11-filtered.apdus → 11-filtered-v1.apdus} +9 -9
  32. package/tests/fixtures/apdus/12-filtered-v1.apdus +38 -0
  33. package/tests/fixtures/apdus/13-filtered-v1.apdus +108 -0
  34. package/tests/fixtures/apdus/14-filtered-v1.apdus +28 -0
  35. package/tests/fixtures/apdus/15-filtered-v1.apdus +6 -6
  36. package/tests/fixtures/apdus/15-filtered-v2.apdus +7 -7
  37. package/tests/fixtures/apdus/16-filtered-v1.apdus +6 -6
  38. package/tests/fixtures/apdus/16-filtered-v2.apdus +7 -7
  39. package/tests/fixtures/apdus/17-filtered-v1.apdus +164 -0
  40. package/tests/fixtures/apdus/17-filtered-v2.apdus +168 -0
  41. package/tests/fixtures/apdus/18-filtered-v1.apdus +8 -8
  42. package/tests/fixtures/apdus/18-filtered-v2.apdus +10 -10
  43. package/tests/fixtures/apdus/{2-filtered.apdus → 2-filtered-v1.apdus} +7 -7
  44. package/tests/fixtures/apdus/3-filtered-v1.apdus +60 -0
  45. package/tests/fixtures/apdus/{4-filtered.apdus → 4-filtered-v1.apdus} +5 -5
  46. package/tests/fixtures/apdus/5-filtered-v1.apdus +176 -0
  47. package/tests/fixtures/apdus/{6-filtered.apdus → 6-filtered-v1.apdus} +9 -9
  48. package/tests/fixtures/apdus/{7-filtered.apdus → 7-filtered-v1.apdus} +7 -7
  49. package/tests/fixtures/apdus/{8-filtered.apdus → 8-filtered-v1.apdus} +8 -8
  50. package/tests/fixtures/apdus/{9-filtered.apdus → 9-filtered-v1.apdus} +8 -8
  51. package/tests/fixtures/apdus/ERC20-KO.apdus +1 -1
  52. package/tests/fixtures/apdus/ERC20-OK.apdus +3 -3
  53. package/tests/fixtures/apdus/version-1.12.0.apdus +2 -0
  54. package/tests/fixtures/messages/1-empty-array-1-level.json +79 -0
  55. package/tests/fixtures/messages/1-empty-array-2-levels.json +74 -0
  56. package/tests/fixtures/apdus/12-filtered.apdus +0 -38
  57. package/tests/fixtures/apdus/13-filtered.apdus +0 -108
  58. package/tests/fixtures/apdus/17-filtered.apdus +0 -0
  59. package/tests/fixtures/apdus/3-filtered.apdus +0 -60
  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
- test("should sign correctly the 0.json sample message", async () => {
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: "8a540510e13b0f2b11a451275716d29e08caad07e89a1c84964782fb5e1ad788",
41
- s: "64a0de235b270fbe81e8e40688f4a9f9ad9d283d690552c9331d7773ceafa513",
46
+ r: "b1a7312afb06c47b56d25475bdfdf37d907c84e6c1143825f85136062e941ff7",
47
+ s: "759c2298e0dba1792facd2e579eda48109e4640f4227575bf60db9b06f6e78c8",
42
48
  v: 28,
43
49
  });
44
50
  });
45
51
 
46
- test("should sign correctly the 1.json sample message", async () => {
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
- test("should sign correctly the 2.json sample message", async () => {
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: "5e729ca9970c6436cfb23d50b93c5674aa87adeed4010d89a8e9926732e012fa",
77
- s: "5bb260889e3bacdb322c46343bc38366b0456d36b16a452317f1361cd9ed9e9b",
78
- v: 28,
82
+ r: "1539547ae7cf8ebcd3eabfb57cd2b1fb7775ce757c3f4a307c7425d35b7bfff7",
83
+ s: "47248cb61e554c1f90af6331d9c9e51cbb8655667514194f509abe097a032319",
84
+ v: 27,
79
85
  });
80
86
  });
81
87
 
82
- test("should sign correctly the 3.json sample message", async () => {
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: "a032f358f76041e239d34a449d859742d79ede0705e294552e68c6f6345cd9a6",
95
- s: "5d14e1607eca346db7a1b4ded81c8dcc82821a8f2ceb24803b611095cf68d320",
96
- v: 28,
100
+ r: "5677fec212710c03127cc58c2b0ce31885f6147bc807cdd94de1343c1396d452",
101
+ s: "6624ddd7e50c1185f91d80ce4ef7adc96adb8c73e74cd8cb5087a44d3a134c8f",
102
+ v: 27,
97
103
  });
98
104
  });
99
105
 
100
- test("should sign correctly the 4.json sample message", async () => {
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: "c5de7830122a8f8cb769bc22b5c1a1ff56e5afa820125b6d67ac681361409946",
113
- s: "1bf9da83833f445e80a5aa1b04afe62b66f8210cf4ce77281d98dc9596af3294",
114
- v: 27,
118
+ r: "341bca1c0dfd805d4befc21500084424dbe559c7aafd78d8fb461c0c76dfea1d",
119
+ s: "33ebb7b6fe0691961cd8b263faac20ecbbdcaef3febb57eb76614cad629080ea",
120
+ v: 28,
115
121
  });
116
122
  });
117
123
 
118
- test("should sign correctly the 5.json sample message", async () => {
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: "23c178dc4b78a8c6b6fc87c295927673b22862f7fbabebbeaa9b546e47c241a3",
131
- s: "3efa002b0409d9538ad73638baa7dbe4d2dd760f278c84fbce81ff2c06dee3d5",
136
+ r: "e42c7fad36f615a566be673ecbd0542f83addf76ffa97af30acda06b3443ceca",
137
+ s: "72ca3cd5b3c9790e2a199c9d03342db7be374794d8bbffa2c4cb2aa1a16389e1",
132
138
  v: 28,
133
139
  });
134
140
  });
135
141
 
136
- test("should sign correctly the 6.json sample message", async () => {
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: "0e178627d230e134ade95f4d828050bb5906d42605c085d9512ca0cb80efa3b0",
149
- s: "20e280cee0a50fa349a1d95708419f29ae03d34d25edd71a5faffdcfe7935251",
154
+ r: "d10f6b61205cf5c5ec45735d7f7186afb7e454212102883caf9b6fd2ebdf9fd3",
155
+ s: "2d9c1af9ded7ddb0237c0b67b6a1a2c98fc73af8ff0bf6c43b356a79bbc929f3",
150
156
  v: 27,
151
157
  });
152
158
  });
153
159
 
154
- test("should sign correctly the 7.json sample message", async () => {
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: "9d94c45d9fed0c7804c8acae6a51c1f955e26f9b97dbb0bb086ec432f6890c05",
167
- s: "63484ac40b7cf6d71f6764625a6eb5204554efc16fcb4990011ae9801dd5362d",
172
+ r: "df9e8b6b94a196b5b5608d8a83ad5479f050bbdfb301d4d3f4e2bfb30497fd44",
173
+ s: "1bd7074ce7035305a091b2f9994854fec0ceb2b11cf2620b93b76c1723029f6f",
168
174
  v: 27,
169
175
  });
170
176
  });
171
177
 
172
- test("should sign correctly the 8.json sample message", async () => {
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: "72cd1152bbd5513ebfc9cd2550395de96597bcfde23e79650caae9197f4da51a",
185
- s: "630f3daba6843aa7cb4f14af72648c0a40e1a96bb33e9f46288333b00662cac7",
186
- v: 27,
190
+ r: "59adf8ab1d0e87d2623747eac10d5ef23d0145d7f30e2960cba3503b28add2d3",
191
+ s: "109f81625ca7a9bb448fa58325b2f08d7f7141b14a20e363d7ea10a9483b780d",
192
+ v: 28,
187
193
  });
188
194
  });
189
195
 
190
- test("should sign correctly the 9.json sample message", async () => {
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: "b1e40db9bd432986de0013a55d0564a1bfc232fb25b3c3da19db3d867df2d551",
203
- s: "6941ad66c0ec9100f3676a4f61761509c1345fe73df16d84053420008c8d73b7",
208
+ r: "87698ac1d846331b4b393417353dd20c60b9401a407d76db52fb9e45844aab30",
209
+ s: "11b09b38be74fbf2cb5851470d4f70bf0cccaf1bea00ff28e16ca914deba15ce",
204
210
  v: 28,
205
211
  });
206
212
  });
207
213
 
208
- test("should sign correctly the 10.json sample message", async () => {
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: "bd1a1bd027e9922fba0b5f298791c70074c4fa5564b024833e885872cc6a187c",
221
- s: "256485b3fba419e3454006353d2de19390f0c2fc11dc819cf297bc3b7aa6a005",
222
- v: 27,
226
+ r: "aaa9e17e5cb7d8a7d0ecc832a883254599909d8123d846aa6f3f63f47ab78704",
227
+ s: "2b7e6adaeb26906e6577efa04c1733a19169ee2747020b73f8f309ca8c2ccc1f",
228
+ v: 28,
223
229
  });
224
230
  });
225
231
 
226
- test("should sign correctly the 11.json sample message", async () => {
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: "d0259bc5208c369532c6161486d7533966d382fc725bcb781a190c0f1a53f771",
239
- s: "7ebbf21c5569d2d2a480615d529b431d3b0dfce863f723d21e3370e860a8965c",
244
+ r: "cce2e63aaac6a5f9a74684d8fdddcbc7f3b27aa17235bfab89226821ead933b6",
245
+ s: "3f3c93977abcc3f8cc9a3dc1ecc02dbca14aca1a6ecb2fb6ca3d7c713ace1ec4",
240
246
  v: 28,
241
247
  });
242
248
  });
243
249
 
244
- test("should sign correctly the 12.json sample message", async () => {
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: "4aef3aaff62fa0731f4e661c4dbb92a48f8c12d7225219fad74b55ef2ad0045b",
257
- s: "46d7e01804c33a99c4dc7dd7b2ac5e63d07ee4641b01cd3a598cc91d74bbe3e0",
258
- v: 28,
262
+ r: "7be1671577753c13bfd1da8b234b6df8484daf47351c2366637fd291dd4aa4d9",
263
+ s: "1a7ffbb01dc8a64e9ee97d19b8f154e9eecbe0b1bfb9dcfa781a65e474573963",
264
+ v: 27,
259
265
  });
260
266
  });
261
267
 
262
- test("should sign correctly the 13.json sample message", async () => {
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: "daf758e25d9d7769adcab19c4d64953983d29fb44041e0ba4263a9d4686a3de3",
275
- s: "03c52a566b18568ba71576e768ed321a6a90605365fe9766387db3bd24bebe96",
280
+ r: "fde9bc1860bae0b867b66176ca654578530edf97771c714cc7bb146943443ef3",
281
+ s: "06f92884f1de6fe75c4a650b0fe88d0c185af9943a95dc1c4b3045ae0f81edfe",
276
282
  v: 28,
277
283
  });
278
284
  });
279
285
 
280
- test.skip("should sign correctly the 14.json but there is no filters for it", () => {
281
- // no filters for this one
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
- test.skip("should sign correctly the 14bis.json but there is no filters for it", () => {
285
- // no filters for this one
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
- test("should sign correctly the 15-permit.json sample message", async () => {
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
- test("should sign correctly the 16-permit2.json sample message", async () => {
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
- test.skip("should sign correctly the 17-uniswapx.json sample message", async () => {
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: "daf758e25d9d7769adcab19c4d64953983d29fb44041e0ba4263a9d4686a3de3",
343
- s: "03c52a566b18568ba71576e768ed321a6a90605365fe9766387db3bd24bebe96",
344
- v: 28,
376
+ r: "63e951154de94e9f81ecefa38c0f11c2e4a9bfbaa3524b6c9744161211d6cc3b",
377
+ s: "62480171ceb1f39f2c41ff06a2ecd483c0faaaf459063b278c09803b8bef3e4d",
378
+ v: 27,
345
379
  });
346
380
  });
347
381
 
348
- test("should sign correctly the 18-1inch-fusion.json sample message", async () => {
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
- let nanoAppVersionApdus;
371
- beforeAll(async () => {
372
- nanoAppVersionApdus = await fs.readFile(getFilePath("apdu", "version-1.11.1"), "utf-8");
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
- test("should sign correctly the 15-permit.json sample message", async () => {
376
- const apdusBuffer = await fs.readFile(getFilePath("apdu", "15-filtered-v2"), "utf-8");
377
- const message = await fs
378
- .readFile(getFilePath("message", "15-permit"), "utf-8")
379
- .then(JSON.parse);
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
- const transport = await openTransportReplayer(
382
- RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
383
- );
416
+ const transport = await openTransportReplayer(
417
+ RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
418
+ );
384
419
 
385
- const eth = new Eth(transport);
386
- const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
420
+ const eth = new Eth(transport);
421
+ const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
387
422
 
388
- expect(result).toEqual({
389
- r: "9573c40857d73d28b43120231886cf4199b1456e00da8887a508d576b6985a6f",
390
- s: "18515302ca7809f9d36b95c8ea91509b602adc3c1653be0255ac5726969307bd",
391
- v: 28,
423
+ expect(result).toEqual({
424
+ r: "9573c40857d73d28b43120231886cf4199b1456e00da8887a508d576b6985a6f",
425
+ s: "18515302ca7809f9d36b95c8ea91509b602adc3c1653be0255ac5726969307bd",
426
+ v: 28,
427
+ });
392
428
  });
393
- });
394
429
 
395
- test("should sign correctly the 16-permit2.json sample message", async () => {
396
- const apdusBuffer = await fs.readFile(getFilePath("apdu", "16-filtered-v2"), "utf-8");
397
- const message = await fs
398
- .readFile(getFilePath("message", "16-permit2"), "utf-8")
399
- .then(JSON.parse);
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
- const transport = await openTransportReplayer(
402
- RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
403
- );
436
+ const transport = await openTransportReplayer(
437
+ RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
438
+ );
404
439
 
405
- const eth = new Eth(transport);
406
- const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
440
+ const eth = new Eth(transport);
441
+ const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
407
442
 
408
- expect(result).toEqual({
409
- r: "ce7c4941157899c0db37c4363c773d919c896ddef669c878e856573659bb3655",
410
- s: "0fed0222b941702c2fd5611ac13ac0217ed889586a56b047b0d5bf0566edbbb7",
411
- v: 27,
443
+ expect(result).toEqual({
444
+ r: "ce7c4941157899c0db37c4363c773d919c896ddef669c878e856573659bb3655",
445
+ s: "0fed0222b941702c2fd5611ac13ac0217ed889586a56b047b0d5bf0566edbbb7",
446
+ v: 27,
447
+ });
412
448
  });
413
- });
414
449
 
415
- test.skip("should sign correctly the 17-uniswapx.json sample message", async () => {
416
- const apdusBuffer = await fs.readFile(getFilePath("apdu", "17-filtered-v2"), "utf-8");
417
- const message = await fs
418
- .readFile(getFilePath("message", "17-uniswapx"), "utf-8")
419
- .then(JSON.parse);
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
- const transport = await openTransportReplayer(
422
- RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
423
- );
456
+ const transport = await openTransportReplayer(
457
+ RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
458
+ );
424
459
 
425
- const eth = new Eth(transport);
426
- const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
460
+ const eth = new Eth(transport);
461
+ const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
427
462
 
428
- expect(result).toEqual({
429
- r: "daf758e25d9d7769adcab19c4d64953983d29fb44041e0ba4263a9d4686a3de3",
430
- s: "03c52a566b18568ba71576e768ed321a6a90605365fe9766387db3bd24bebe96",
431
- v: 28,
463
+ expect(result).toEqual({
464
+ r: "63e951154de94e9f81ecefa38c0f11c2e4a9bfbaa3524b6c9744161211d6cc3b",
465
+ s: "62480171ceb1f39f2c41ff06a2ecd483c0faaaf459063b278c09803b8bef3e4d",
466
+ v: 27,
467
+ });
432
468
  });
433
- });
434
469
 
435
- test("should sign correctly the 18-1inch-fusion.json sample message", async () => {
436
- const apdusBuffer = await fs.readFile(getFilePath("apdu", "18-filtered-v2"), "utf-8");
437
- const message = await fs
438
- .readFile(getFilePath("message", "18-1inch-fusion"), "utf-8")
439
- .then(JSON.parse);
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
- const transport = await openTransportReplayer(
442
- RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
443
- );
476
+ const transport = await openTransportReplayer(
477
+ RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
478
+ );
444
479
 
445
- const eth = new Eth(transport);
446
- const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
480
+ const eth = new Eth(transport);
481
+ const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
447
482
 
448
- expect(result).toEqual({
449
- r: "6f07ba3bb7fa9369ee9b5e4cc3bdc8545d75e3527fa242a5e4d23ead9d232af8",
450
- s: "412a55401fe955b996125682ad0a47277d3ce1b314ee3962956ae643b71166cb",
451
- v: 27,
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
  });