@ledgerhq/hw-app-eth 7.0.0-nightly.2 → 7.0.0-nightly.20251120135143

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 (134) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/.unimportedrc.json +3 -28
  3. package/CHANGELOG.md +994 -17
  4. package/README.md +100 -0
  5. package/jest.config.ts +18 -0
  6. package/lib/Eth.d.ts +3 -18
  7. package/lib/Eth.d.ts.map +1 -1
  8. package/lib/Eth.js +160 -198
  9. package/lib/Eth.js.map +1 -1
  10. package/lib/errors.d.ts +3 -0
  11. package/lib/errors.d.ts.map +1 -1
  12. package/lib/errors.js +2 -1
  13. package/lib/errors.js.map +1 -1
  14. package/lib/modules/Domains/index.js +6 -15
  15. package/lib/modules/Domains/index.js.map +1 -1
  16. package/lib/modules/EIP712/index.d.ts.map +1 -1
  17. package/lib/modules/EIP712/index.js +112 -125
  18. package/lib/modules/EIP712/index.js.map +1 -1
  19. package/lib/modules/EIP712/types.d.ts +1 -0
  20. package/lib/modules/EIP712/types.d.ts.map +1 -1
  21. package/lib/modules/EIP712/utils.d.ts +1 -0
  22. package/lib/modules/EIP712/utils.d.ts.map +1 -1
  23. package/lib/modules/EIP712/utils.js +14 -24
  24. package/lib/modules/EIP712/utils.js.map +1 -1
  25. package/lib/modules/Uniswap/constants.d.ts.map +1 -1
  26. package/lib/modules/Uniswap/constants.js +1 -0
  27. package/lib/modules/Uniswap/constants.js.map +1 -1
  28. package/lib/modules/Uniswap/decoders.d.ts.map +1 -1
  29. package/lib/modules/Uniswap/decoders.js +8 -3
  30. package/lib/modules/Uniswap/decoders.js.map +1 -1
  31. package/lib/modules/Uniswap/index.d.ts +2 -1
  32. package/lib/modules/Uniswap/index.d.ts.map +1 -1
  33. package/lib/modules/Uniswap/index.js +11 -20
  34. package/lib/modules/Uniswap/index.js.map +1 -1
  35. package/lib/modules/Uniswap/types.d.ts +1 -1
  36. package/lib/modules/Uniswap/types.d.ts.map +1 -1
  37. package/lib/services/ledger/contracts.js +4 -13
  38. package/lib/services/ledger/contracts.js.map +1 -1
  39. package/lib/services/ledger/erc20.d.ts +2 -1
  40. package/lib/services/ledger/erc20.d.ts.map +1 -1
  41. package/lib/services/ledger/erc20.js +16 -32
  42. package/lib/services/ledger/erc20.js.map +1 -1
  43. package/lib/services/ledger/index.d.ts.map +1 -1
  44. package/lib/services/ledger/index.js +34 -32
  45. package/lib/services/ledger/index.js.map +1 -1
  46. package/lib/services/ledger/loadConfig.d.ts.map +1 -1
  47. package/lib/services/ledger/loadConfig.js +7 -1
  48. package/lib/services/ledger/loadConfig.js.map +1 -1
  49. package/lib/services/ledger/nfts.js +9 -19
  50. package/lib/services/ledger/nfts.js.map +1 -1
  51. package/lib/services/types.d.ts +3 -0
  52. package/lib/services/types.d.ts.map +1 -1
  53. package/lib/utils.d.ts +56 -9
  54. package/lib/utils.d.ts.map +1 -1
  55. package/lib/utils.js +175 -81
  56. package/lib/utils.js.map +1 -1
  57. package/lib-es/Eth.d.ts +3 -18
  58. package/lib-es/Eth.d.ts.map +1 -1
  59. package/lib-es/Eth.js +160 -198
  60. package/lib-es/Eth.js.map +1 -1
  61. package/lib-es/errors.d.ts +3 -0
  62. package/lib-es/errors.d.ts.map +1 -1
  63. package/lib-es/errors.js +1 -0
  64. package/lib-es/errors.js.map +1 -1
  65. package/lib-es/modules/Domains/index.js +6 -15
  66. package/lib-es/modules/Domains/index.js.map +1 -1
  67. package/lib-es/modules/EIP712/index.d.ts.map +1 -1
  68. package/lib-es/modules/EIP712/index.js +112 -125
  69. package/lib-es/modules/EIP712/index.js.map +1 -1
  70. package/lib-es/modules/EIP712/types.d.ts +1 -0
  71. package/lib-es/modules/EIP712/types.d.ts.map +1 -1
  72. package/lib-es/modules/EIP712/utils.d.ts +1 -0
  73. package/lib-es/modules/EIP712/utils.d.ts.map +1 -1
  74. package/lib-es/modules/EIP712/utils.js +14 -24
  75. package/lib-es/modules/EIP712/utils.js.map +1 -1
  76. package/lib-es/modules/Uniswap/constants.d.ts.map +1 -1
  77. package/lib-es/modules/Uniswap/constants.js +1 -0
  78. package/lib-es/modules/Uniswap/constants.js.map +1 -1
  79. package/lib-es/modules/Uniswap/decoders.d.ts.map +1 -1
  80. package/lib-es/modules/Uniswap/decoders.js +8 -3
  81. package/lib-es/modules/Uniswap/decoders.js.map +1 -1
  82. package/lib-es/modules/Uniswap/index.d.ts +2 -1
  83. package/lib-es/modules/Uniswap/index.d.ts.map +1 -1
  84. package/lib-es/modules/Uniswap/index.js +11 -20
  85. package/lib-es/modules/Uniswap/index.js.map +1 -1
  86. package/lib-es/modules/Uniswap/types.d.ts +1 -1
  87. package/lib-es/modules/Uniswap/types.d.ts.map +1 -1
  88. package/lib-es/services/ledger/contracts.js +4 -13
  89. package/lib-es/services/ledger/contracts.js.map +1 -1
  90. package/lib-es/services/ledger/erc20.d.ts +2 -1
  91. package/lib-es/services/ledger/erc20.d.ts.map +1 -1
  92. package/lib-es/services/ledger/erc20.js +16 -32
  93. package/lib-es/services/ledger/erc20.js.map +1 -1
  94. package/lib-es/services/ledger/index.d.ts.map +1 -1
  95. package/lib-es/services/ledger/index.js +34 -32
  96. package/lib-es/services/ledger/index.js.map +1 -1
  97. package/lib-es/services/ledger/loadConfig.d.ts.map +1 -1
  98. package/lib-es/services/ledger/loadConfig.js +7 -1
  99. package/lib-es/services/ledger/loadConfig.js.map +1 -1
  100. package/lib-es/services/ledger/nfts.js +9 -19
  101. package/lib-es/services/ledger/nfts.js.map +1 -1
  102. package/lib-es/services/types.d.ts +3 -0
  103. package/lib-es/services/types.d.ts.map +1 -1
  104. package/lib-es/utils.d.ts +56 -9
  105. package/lib-es/utils.d.ts.map +1 -1
  106. package/lib-es/utils.js +148 -81
  107. package/lib-es/utils.js.map +1 -1
  108. package/package.json +19 -15
  109. package/src/Eth.ts +51 -82
  110. package/src/errors.ts +3 -0
  111. package/src/modules/EIP712/index.ts +17 -4
  112. package/src/modules/Uniswap/constants.ts +1 -0
  113. package/src/modules/Uniswap/decoders.ts +10 -3
  114. package/src/modules/Uniswap/index.ts +9 -8
  115. package/src/modules/Uniswap/types.ts +2 -1
  116. package/src/services/ledger/erc20.ts +16 -19
  117. package/src/services/ledger/index.ts +50 -22
  118. package/src/services/ledger/loadConfig.ts +4 -1
  119. package/src/services/ledger/nfts.ts +1 -1
  120. package/src/services/types.ts +12 -0
  121. package/src/utils.ts +170 -85
  122. package/tests/EIP712/filtered-signMessage.unit.test.ts +28 -116
  123. package/tests/EIP712/noFilter-signMessage.unit.test.ts +0 -2
  124. package/tests/ERC20/ERC20-CAL-KO.unit.test.ts +14 -25
  125. package/tests/ERC20/ERC20-CAL-OK.unit.test.ts +15 -10
  126. package/tests/Eth.unit.test.ts +242 -314
  127. package/tests/Uniswap/decoders.unit.test.ts +10 -0
  128. package/tests/Uniswap/index.unit.test.ts +17 -26
  129. package/tests/fixtures/messages/15-permit.json +3 -3
  130. package/tests/fixtures/messages/16-permit2.json +3 -3
  131. package/tests/fixtures/messages/17-uniswapx.json +5 -5
  132. package/tests/fixtures/utils.ts +17 -18
  133. package/tests/ledgerService.unit.test.ts +5 -7
  134. package/tests/utils.unit.test.ts +341 -0
@@ -14,14 +14,6 @@ const getFilePath = (type: "apdu" | "message", filename: string): string => {
14
14
  }
15
15
  };
16
16
 
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
- }));
25
17
  nock.disableNetConnect();
26
18
 
27
19
  describe("EIP712", () => {
@@ -39,7 +31,7 @@ describe("EIP712", () => {
39
31
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
40
32
  );
41
33
 
42
- const eth = new Eth(transport);
34
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
43
35
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
44
36
 
45
37
  expect(result).toEqual({
@@ -57,7 +49,7 @@ describe("EIP712", () => {
57
49
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
58
50
  );
59
51
 
60
- const eth = new Eth(transport);
52
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
61
53
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
62
54
 
63
55
  expect(result).toEqual({
@@ -75,7 +67,7 @@ describe("EIP712", () => {
75
67
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
76
68
  );
77
69
 
78
- const eth = new Eth(transport);
70
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
79
71
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
80
72
 
81
73
  expect(result).toEqual({
@@ -93,7 +85,7 @@ describe("EIP712", () => {
93
85
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
94
86
  );
95
87
 
96
- const eth = new Eth(transport);
88
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
97
89
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
98
90
 
99
91
  expect(result).toEqual({
@@ -111,7 +103,7 @@ describe("EIP712", () => {
111
103
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
112
104
  );
113
105
 
114
- const eth = new Eth(transport);
106
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
115
107
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
116
108
 
117
109
  expect(result).toEqual({
@@ -129,7 +121,7 @@ describe("EIP712", () => {
129
121
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
130
122
  );
131
123
 
132
- const eth = new Eth(transport);
124
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
133
125
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
134
126
 
135
127
  expect(result).toEqual({
@@ -147,7 +139,7 @@ describe("EIP712", () => {
147
139
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
148
140
  );
149
141
 
150
- const eth = new Eth(transport);
142
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
151
143
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
152
144
 
153
145
  expect(result).toEqual({
@@ -165,7 +157,7 @@ describe("EIP712", () => {
165
157
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
166
158
  );
167
159
 
168
- const eth = new Eth(transport);
160
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
169
161
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
170
162
 
171
163
  expect(result).toEqual({
@@ -183,7 +175,7 @@ describe("EIP712", () => {
183
175
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
184
176
  );
185
177
 
186
- const eth = new Eth(transport);
178
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
187
179
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
188
180
 
189
181
  expect(result).toEqual({
@@ -201,7 +193,7 @@ describe("EIP712", () => {
201
193
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
202
194
  );
203
195
 
204
- const eth = new Eth(transport);
196
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
205
197
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
206
198
 
207
199
  expect(result).toEqual({
@@ -219,7 +211,7 @@ describe("EIP712", () => {
219
211
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
220
212
  );
221
213
 
222
- const eth = new Eth(transport);
214
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
223
215
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
224
216
 
225
217
  expect(result).toEqual({
@@ -237,7 +229,7 @@ describe("EIP712", () => {
237
229
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
238
230
  );
239
231
 
240
- const eth = new Eth(transport);
232
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
241
233
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
242
234
 
243
235
  expect(result).toEqual({
@@ -255,7 +247,7 @@ describe("EIP712", () => {
255
247
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
256
248
  );
257
249
 
258
- const eth = new Eth(transport);
250
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
259
251
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
260
252
 
261
253
  expect(result).toEqual({
@@ -273,7 +265,7 @@ describe("EIP712", () => {
273
265
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
274
266
  );
275
267
 
276
- const eth = new Eth(transport);
268
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
277
269
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
278
270
 
279
271
  expect(result).toEqual({
@@ -291,7 +283,7 @@ describe("EIP712", () => {
291
283
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
292
284
  );
293
285
 
294
- const eth = new Eth(transport);
286
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
295
287
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
296
288
 
297
289
  expect(result).toEqual({
@@ -309,7 +301,7 @@ describe("EIP712", () => {
309
301
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
310
302
  );
311
303
 
312
- const eth = new Eth(transport);
304
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
313
305
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
314
306
 
315
307
  expect(result).toEqual({
@@ -329,7 +321,7 @@ describe("EIP712", () => {
329
321
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
330
322
  );
331
323
 
332
- const eth = new Eth(transport);
324
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
333
325
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
334
326
 
335
327
  expect(result).toEqual({
@@ -349,7 +341,7 @@ describe("EIP712", () => {
349
341
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
350
342
  );
351
343
 
352
- const eth = new Eth(transport);
344
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
353
345
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
354
346
 
355
347
  expect(result).toEqual({
@@ -369,7 +361,7 @@ describe("EIP712", () => {
369
361
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
370
362
  );
371
363
 
372
- const eth = new Eth(transport);
364
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
373
365
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
374
366
 
375
367
  expect(result).toEqual({
@@ -389,7 +381,7 @@ describe("EIP712", () => {
389
381
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
390
382
  );
391
383
 
392
- const eth = new Eth(transport);
384
+ const eth = new Eth(transport, "w0w", { calServiceURL: "http://mock-cal-service", staticEIP712SignaturesV1: v1, staticEIP712SignaturesV2: v2 });
393
385
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
394
386
 
395
387
  expect(result).toEqual({
@@ -401,92 +393,6 @@ describe("EIP712", () => {
401
393
  });
402
394
 
403
395
  describe("SignEIP712Message with filters v2", () => {
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
- });
409
-
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);
415
-
416
- const transport = await openTransportReplayer(
417
- RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
418
- );
419
-
420
- const eth = new Eth(transport);
421
- const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
422
-
423
- expect(result).toEqual({
424
- r: "9573c40857d73d28b43120231886cf4199b1456e00da8887a508d576b6985a6f",
425
- s: "18515302ca7809f9d36b95c8ea91509b602adc3c1653be0255ac5726969307bd",
426
- v: 28,
427
- });
428
- });
429
-
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);
435
-
436
- const transport = await openTransportReplayer(
437
- RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
438
- );
439
-
440
- const eth = new Eth(transport);
441
- const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
442
-
443
- expect(result).toEqual({
444
- r: "ce7c4941157899c0db37c4363c773d919c896ddef669c878e856573659bb3655",
445
- s: "0fed0222b941702c2fd5611ac13ac0217ed889586a56b047b0d5bf0566edbbb7",
446
- v: 27,
447
- });
448
- });
449
-
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);
455
-
456
- const transport = await openTransportReplayer(
457
- RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
458
- );
459
-
460
- const eth = new Eth(transport);
461
- const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
462
-
463
- expect(result).toEqual({
464
- r: "63e951154de94e9f81ecefa38c0f11c2e4a9bfbaa3524b6c9744161211d6cc3b",
465
- s: "62480171ceb1f39f2c41ff06a2ecd483c0faaaf459063b278c09803b8bef3e4d",
466
- v: 27,
467
- });
468
- });
469
-
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);
475
-
476
- const transport = await openTransportReplayer(
477
- RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
478
- );
479
-
480
- const eth = new Eth(transport);
481
- const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
482
-
483
- expect(result).toEqual({
484
- r: "6f07ba3bb7fa9369ee9b5e4cc3bdc8545d75e3527fa242a5e4d23ead9d232af8",
485
- s: "412a55401fe955b996125682ad0a47277d3ce1b314ee3962956ae643b71166cb",
486
- v: 27,
487
- });
488
- });
489
- });
490
396
  describe("from version 1.12.0", () => {
491
397
  let nanoAppVersionApdus;
492
398
  beforeAll(async () => {
@@ -506,7 +412,10 @@ describe("EIP712", () => {
506
412
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
507
413
  );
508
414
 
509
- const eth = new Eth(transport);
415
+ const eth = new Eth(transport, "w0w", {
416
+ staticEIP712SignaturesV1: v1,
417
+ staticEIP712SignaturesV2: v2,
418
+ });
510
419
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
511
420
 
512
421
  expect(result).toEqual({
@@ -529,7 +438,10 @@ describe("EIP712", () => {
529
438
  RecordStore.fromString(nanoAppVersionApdus + apdusBuffer),
530
439
  );
531
440
 
532
- const eth = new Eth(transport);
441
+ const eth = new Eth(transport, "w0w", {
442
+ staticEIP712SignaturesV1: v1,
443
+ staticEIP712SignaturesV2: v2,
444
+ });
533
445
  const result = await eth.signEIP712Message("44'/60'/0'/0/0", message);
534
446
 
535
447
  expect(result).toEqual({
@@ -13,8 +13,6 @@ const getFilePath = (type: "apdu" | "message", filename: string): string => {
13
13
  }
14
14
  };
15
15
 
16
- // act like no message has filters
17
- jest.mock("@ledgerhq/cryptoassets-evm-signatures/data/eip712", () => ({}));
18
16
  nock.disableNetConnect();
19
17
 
20
18
  describe("EIP712", () => {
@@ -1,32 +1,24 @@
1
+ import path from "path";
1
2
  import axios from "axios";
2
3
  import fs from "fs/promises";
3
- import path from "path";
4
- import evms from "@ledgerhq/cryptoassets-evm-signatures/lib/data/evm/index";
4
+ import { BigNumber } from "@ethersproject/bignumber";
5
5
  import { openTransportReplayer, RecordStore } from "@ledgerhq/hw-transport-mocker";
6
+ import { serialize as serializeTransaction, type Transaction } from "@ethersproject/transactions";
6
7
  import { EthAppPleaseEnableContractData } from "../../src/errors";
7
8
  import SignatureCALEth from "../fixtures/SignatureCALEth";
8
9
  import ledgerService from "../../src/services/ledger";
9
10
  import Eth from "../../src/Eth";
10
- import { ethers } from "ethers";
11
11
 
12
- const transaction: ethers.Transaction = {
12
+ const transaction: Transaction = {
13
13
  to: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
14
14
  nonce: 14,
15
- gasPrice: ethers.BigNumber.from("0x06a2bb7d00"),
16
- gasLimit: ethers.BigNumber.from("0x01512c"),
17
- value: ethers.BigNumber.from("0x00"),
15
+ gasPrice: BigNumber.from("0x06a2bb7d00"),
16
+ gasLimit: BigNumber.from("0x01512c"),
17
+ value: BigNumber.from("0x00"),
18
18
  data: "0xa9059cbb00000000000000000000000082ec3523f8a722694ca217ebfd95efbcadad77ee000000000000000000000000000000000000000000000002b5e3af16b1880000",
19
19
  chainId: 1,
20
20
  };
21
- const txHex = ethers.utils.serializeTransaction(transaction).slice(2);
22
-
23
- jest.mock("@ledgerhq/cryptoassets-evm-signatures/data/evm/index", () => ({
24
- get signatures() {
25
- return {
26
- 1: SignatureCALEth,
27
- };
28
- },
29
- }));
21
+ const txHex = serializeTransaction(transaction).slice(2);
30
22
 
31
23
  describe("ERC20 dynamic cal", () => {
32
24
  beforeEach(() => {
@@ -35,9 +27,6 @@ describe("ERC20 dynamic cal", () => {
35
27
 
36
28
  describe("ERC20 is not in local CAL", () => {
37
29
  it("shouldn't break if the dynamic CAL is malformed", async () => {
38
- jest.spyOn(evms, "signatures", "get").mockReturnValueOnce({
39
- 1: "",
40
- } as any);
41
30
  jest.spyOn(axios, "get").mockImplementationOnce(async () => ({ data: { 123: "ok" } })); // malformed response. Should be a string but here returning an object imcompatible w/ buffer.from
42
31
  const apdusBuffer = await fs.readFile(
43
32
  path.resolve("./tests/fixtures/apdus/ERC20-KO.apdus"),
@@ -66,10 +55,6 @@ describe("ERC20 dynamic cal", () => {
66
55
  });
67
56
 
68
57
  it("should ask for blind sign if not in dynamic & local CAL", async () => {
69
- jest.spyOn(evms, "signatures", "get").mockReturnValueOnce({
70
- 1: "",
71
- } as any);
72
-
73
58
  const apdusBuffer = await fs.readFile(
74
59
  path.resolve("./tests/fixtures/apdus/ERC20-KO.apdus"),
75
60
  "utf-8",
@@ -103,7 +88,11 @@ describe("ERC20 dynamic cal", () => {
103
88
  );
104
89
  const transport = await openTransportReplayer(RecordStore.fromString(`${apdusBuffer}`));
105
90
  const resolutionConfig = { erc20: true };
106
- const resolution = await ledgerService.resolveTransaction(txHex, {}, resolutionConfig);
91
+ const resolution = await ledgerService.resolveTransaction(
92
+ txHex,
93
+ { staticERC20Signatures: { 1: SignatureCALEth } },
94
+ resolutionConfig,
95
+ );
107
96
  const eth = new Eth(transport);
108
97
  const result = await eth.signTransaction("44'/60'/0'/0/0", txHex, resolution);
109
98
 
@@ -112,6 +101,6 @@ describe("ERC20 dynamic cal", () => {
112
101
  r: "006c000371dc04c5752287a9901b1fac4b069eb1410173db39c407ae725e4a6e",
113
102
  s: "4f445c94cc869f01e194478a3b876052716ae7676247664acec371b6e6ad16e4",
114
103
  });
115
- });
104
+ }, 10e3);
116
105
  });
117
106
  });
@@ -1,22 +1,23 @@
1
1
  import axios from "axios";
2
2
  import path from "path";
3
3
  import fs from "fs/promises";
4
- import { ethers } from "ethers";
4
+ import { BigNumber } from "@ethersproject/bignumber";
5
5
  import { openTransportReplayer, RecordStore } from "@ledgerhq/hw-transport-mocker";
6
+ import { serialize as serializeTransaction, type Transaction } from "@ethersproject/transactions";
6
7
  import SignatureCALEth from "../fixtures/SignatureCALEth";
7
8
  import ledgerService from "../../src/services/ledger";
8
9
  import Eth from "../../src/Eth";
9
10
 
10
- const transaction: ethers.Transaction = {
11
+ const transaction: Transaction = {
11
12
  to: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
12
13
  nonce: 14,
13
- gasPrice: ethers.BigNumber.from("0x06a2bb7d00"),
14
- gasLimit: ethers.BigNumber.from("0x01512c"),
15
- value: ethers.BigNumber.from("0x00"),
14
+ gasPrice: BigNumber.from("0x06a2bb7d00"),
15
+ gasLimit: BigNumber.from("0x01512c"),
16
+ value: BigNumber.from("0x00"),
16
17
  data: "0xa9059cbb00000000000000000000000082ec3523f8a722694ca217ebfd95efbcadad77ee000000000000000000000000000000000000000000000002b5e3af16b1880000",
17
18
  chainId: 1,
18
19
  };
19
- const txHex = ethers.utils.serializeTransaction(transaction).slice(2);
20
+ const txHex = serializeTransaction(transaction).slice(2);
20
21
 
21
22
  describe("ERC20 dynamic cal", () => {
22
23
  describe("ERC20 is in local CAL", () => {
@@ -28,7 +29,11 @@ describe("ERC20 dynamic cal", () => {
28
29
  );
29
30
  const transport = await openTransportReplayer(RecordStore.fromString(`${apdusBuffer}`));
30
31
  const resolutionConfig = { erc20: true };
31
- const resolution = await ledgerService.resolveTransaction(txHex, {}, resolutionConfig);
32
+ const resolution = await ledgerService.resolveTransaction(
33
+ txHex,
34
+ { staticERC20Signatures: { 1: SignatureCALEth } },
35
+ resolutionConfig,
36
+ );
32
37
  const eth = new Eth(transport);
33
38
  const result = await eth.signTransaction("44'/60'/0'/0/0", txHex, resolution);
34
39
 
@@ -48,7 +53,7 @@ describe("ERC20 dynamic cal", () => {
48
53
  const resolutionConfig = { erc20: true };
49
54
  const resolution = await ledgerService.resolveTransaction(
50
55
  txHex,
51
- { cryptoassetsBaseURL: "notworking" },
56
+ { cryptoassetsBaseURL: "notworking", staticERC20Signatures: { 1: SignatureCALEth } },
52
57
  resolutionConfig,
53
58
  );
54
59
 
@@ -72,7 +77,7 @@ describe("ERC20 dynamic cal", () => {
72
77
  const resolutionConfig = { erc20: true };
73
78
  const resolution = await ledgerService.resolveTransaction(
74
79
  txHex,
75
- { cryptoassetsBaseURL: "working" },
80
+ { cryptoassetsBaseURL: "working", staticERC20Signatures: { 1: SignatureCALEth } },
76
81
  resolutionConfig,
77
82
  );
78
83
 
@@ -87,4 +92,4 @@ describe("ERC20 dynamic cal", () => {
87
92
  });
88
93
  });
89
94
  });
90
- });
95
+ });