@ledgerhq/hw-app-eth 6.38.2 → 7.0.0-nightly.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,7 +14,7 @@ const getFilePath = (type: "apdu" | "message", filename: string): string => {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
// act like no message has filters
|
|
17
|
-
jest.mock("@ledgerhq/cryptoassets/data/eip712", () => ({}));
|
|
17
|
+
jest.mock("@ledgerhq/cryptoassets-evm-signatures/data/eip712", () => ({}));
|
|
18
18
|
nock.disableNetConnect();
|
|
19
19
|
|
|
20
20
|
describe("EIP712", () => {
|
|
@@ -24,7 +24,7 @@ describe("EIP712", () => {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
describe("SignEIP712Message without filters", () => {
|
|
27
|
-
|
|
27
|
+
it("should sign correctly the 0.json sample message", async () => {
|
|
28
28
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "0"), "utf-8");
|
|
29
29
|
const message = await fs.readFile(getFilePath("message", "0"), "utf-8").then(JSON.parse);
|
|
30
30
|
const transport = await openTransportReplayer(
|
|
@@ -41,7 +41,7 @@ describe("EIP712", () => {
|
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
it("should sign correctly the 1.json sample message", async () => {
|
|
45
45
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "1"), "utf-8");
|
|
46
46
|
const message = await fs.readFile(getFilePath("message", "1"), "utf-8").then(JSON.parse);
|
|
47
47
|
|
|
@@ -59,7 +59,7 @@ describe("EIP712", () => {
|
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
it("should sign correctly the 2.json sample message", async () => {
|
|
63
63
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "2"), "utf-8");
|
|
64
64
|
const message = await fs.readFile(getFilePath("message", "2"), "utf-8").then(JSON.parse);
|
|
65
65
|
|
|
@@ -77,7 +77,7 @@ describe("EIP712", () => {
|
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
it("should sign correctly the 3.json sample message", async () => {
|
|
81
81
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "3"), "utf-8");
|
|
82
82
|
const message = await fs.readFile(getFilePath("message", "3"), "utf-8").then(JSON.parse);
|
|
83
83
|
|
|
@@ -95,7 +95,7 @@ describe("EIP712", () => {
|
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
it("should sign correctly the 4.json sample message", async () => {
|
|
99
99
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "4"), "utf-8");
|
|
100
100
|
const message = await fs.readFile(getFilePath("message", "4"), "utf-8").then(JSON.parse);
|
|
101
101
|
|
|
@@ -113,7 +113,7 @@ describe("EIP712", () => {
|
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
it("should sign correctly the 5.json sample message", async () => {
|
|
117
117
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "5"), "utf-8");
|
|
118
118
|
const message = await fs.readFile(getFilePath("message", "5"), "utf-8").then(JSON.parse);
|
|
119
119
|
|
|
@@ -131,7 +131,7 @@ describe("EIP712", () => {
|
|
|
131
131
|
});
|
|
132
132
|
});
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
it("should sign correctly the 6.json sample message", async () => {
|
|
135
135
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "6"), "utf-8");
|
|
136
136
|
const message = await fs.readFile(getFilePath("message", "6"), "utf-8").then(JSON.parse);
|
|
137
137
|
|
|
@@ -149,7 +149,7 @@ describe("EIP712", () => {
|
|
|
149
149
|
});
|
|
150
150
|
});
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
it("should sign correctly the 7.json sample message", async () => {
|
|
153
153
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "7"), "utf-8");
|
|
154
154
|
const message = await fs.readFile(getFilePath("message", "7"), "utf-8").then(JSON.parse);
|
|
155
155
|
|
|
@@ -167,7 +167,7 @@ describe("EIP712", () => {
|
|
|
167
167
|
});
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
it("should sign correctly the 8.json sample message", async () => {
|
|
171
171
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "8"), "utf-8");
|
|
172
172
|
const message = await fs.readFile(getFilePath("message", "8"), "utf-8").then(JSON.parse);
|
|
173
173
|
|
|
@@ -185,7 +185,7 @@ describe("EIP712", () => {
|
|
|
185
185
|
});
|
|
186
186
|
});
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
it("should sign correctly the 9.json sample message", async () => {
|
|
189
189
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "9"), "utf-8");
|
|
190
190
|
const message = await fs.readFile(getFilePath("message", "9"), "utf-8").then(JSON.parse);
|
|
191
191
|
|
|
@@ -203,7 +203,7 @@ describe("EIP712", () => {
|
|
|
203
203
|
});
|
|
204
204
|
});
|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
it("should sign correctly the 10.json sample message", async () => {
|
|
207
207
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "10"), "utf-8");
|
|
208
208
|
const message = await fs.readFile(getFilePath("message", "10"), "utf-8").then(JSON.parse);
|
|
209
209
|
|
|
@@ -221,7 +221,7 @@ describe("EIP712", () => {
|
|
|
221
221
|
});
|
|
222
222
|
});
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
it("should sign correctly the 11.json sample message", async () => {
|
|
225
225
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "11"), "utf-8");
|
|
226
226
|
const message = await fs.readFile(getFilePath("message", "11"), "utf-8").then(JSON.parse);
|
|
227
227
|
|
|
@@ -239,7 +239,7 @@ describe("EIP712", () => {
|
|
|
239
239
|
});
|
|
240
240
|
});
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
it("should sign correctly the 12.json sample message", async () => {
|
|
243
243
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "12"), "utf-8");
|
|
244
244
|
const message = await fs.readFile(getFilePath("message", "12"), "utf-8").then(JSON.parse);
|
|
245
245
|
|
|
@@ -257,7 +257,7 @@ describe("EIP712", () => {
|
|
|
257
257
|
});
|
|
258
258
|
});
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
it("should sign correctly the 13.json sample message", async () => {
|
|
261
261
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "13"), "utf-8");
|
|
262
262
|
const message = await fs.readFile(getFilePath("message", "13"), "utf-8").then(JSON.parse);
|
|
263
263
|
|
|
@@ -275,7 +275,7 @@ describe("EIP712", () => {
|
|
|
275
275
|
});
|
|
276
276
|
});
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
it("should sign correctly the 14.json sample message (shorthand byte string => 0x3 vs 0x03)", async () => {
|
|
279
279
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "14"), "utf-8");
|
|
280
280
|
const messageShorthand = await fs
|
|
281
281
|
.readFile(getFilePath("message", "14"), "utf-8")
|
|
@@ -303,7 +303,7 @@ describe("EIP712", () => {
|
|
|
303
303
|
});
|
|
304
304
|
});
|
|
305
305
|
|
|
306
|
-
|
|
306
|
+
it("should sign correctly the 15-permit.json sample message", async () => {
|
|
307
307
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "15"), "utf-8");
|
|
308
308
|
const message = await fs
|
|
309
309
|
.readFile(getFilePath("message", "15-permit"), "utf-8")
|
|
@@ -323,7 +323,7 @@ describe("EIP712", () => {
|
|
|
323
323
|
});
|
|
324
324
|
});
|
|
325
325
|
|
|
326
|
-
|
|
326
|
+
it("should sign correctly the 16-permit2.json sample message", async () => {
|
|
327
327
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "16"), "utf-8");
|
|
328
328
|
const message = await fs
|
|
329
329
|
.readFile(getFilePath("message", "16-permit2"), "utf-8")
|
|
@@ -343,7 +343,7 @@ describe("EIP712", () => {
|
|
|
343
343
|
});
|
|
344
344
|
});
|
|
345
345
|
|
|
346
|
-
|
|
346
|
+
it("should sign correctly the 17-uniswapx.json sample message", async () => {
|
|
347
347
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "17"), "utf-8");
|
|
348
348
|
const message = await fs
|
|
349
349
|
.readFile(getFilePath("message", "17-uniswapx"), "utf-8")
|
|
@@ -363,7 +363,7 @@ describe("EIP712", () => {
|
|
|
363
363
|
});
|
|
364
364
|
});
|
|
365
365
|
|
|
366
|
-
|
|
366
|
+
it("should sign correctly the 18-1inch-fusion.json sample message", async () => {
|
|
367
367
|
const apdusBuffer = await fs.readFile(getFilePath("apdu", "18"), "utf-8");
|
|
368
368
|
const message = await fs
|
|
369
369
|
.readFile(getFilePath("message", "18-1inch-fusion"), "utf-8")
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import fs from "fs/promises";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import evms from "@ledgerhq/cryptoassets/data/evm/index";
|
|
4
|
+
import evms from "@ledgerhq/cryptoassets-evm-signatures/lib/data/evm/index";
|
|
5
5
|
import { openTransportReplayer, RecordStore } from "@ledgerhq/hw-transport-mocker";
|
|
6
6
|
import { EthAppPleaseEnableContractData } from "../../src/errors";
|
|
7
7
|
import SignatureCALEth from "../fixtures/SignatureCALEth";
|
|
8
8
|
import ledgerService from "../../src/services/ledger";
|
|
9
9
|
import Eth from "../../src/Eth";
|
|
10
|
+
import { ethers } from "ethers";
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
-
"
|
|
13
|
-
|
|
12
|
+
const transaction: ethers.Transaction = {
|
|
13
|
+
to: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
|
14
|
+
nonce: 14,
|
|
15
|
+
gasPrice: ethers.BigNumber.from("0x06a2bb7d00"),
|
|
16
|
+
gasLimit: ethers.BigNumber.from("0x01512c"),
|
|
17
|
+
value: ethers.BigNumber.from("0x00"),
|
|
18
|
+
data: "0xa9059cbb00000000000000000000000082ec3523f8a722694ca217ebfd95efbcadad77ee000000000000000000000000000000000000000000000002b5e3af16b1880000",
|
|
19
|
+
chainId: 1,
|
|
20
|
+
};
|
|
21
|
+
const txHex = ethers.utils.serializeTransaction(transaction).slice(2);
|
|
22
|
+
|
|
23
|
+
jest.mock("@ledgerhq/cryptoassets-evm-signatures/data/evm/index", () => ({
|
|
14
24
|
get signatures() {
|
|
15
25
|
return {
|
|
16
26
|
1: SignatureCALEth,
|
|
@@ -1,16 +1,27 @@
|
|
|
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
5
|
import { openTransportReplayer, RecordStore } from "@ledgerhq/hw-transport-mocker";
|
|
6
|
+
import SignatureCALEth from "../fixtures/SignatureCALEth";
|
|
5
7
|
import ledgerService from "../../src/services/ledger";
|
|
6
8
|
import Eth from "../../src/Eth";
|
|
7
9
|
|
|
8
|
-
const
|
|
9
|
-
"
|
|
10
|
+
const transaction: ethers.Transaction = {
|
|
11
|
+
to: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
|
12
|
+
nonce: 14,
|
|
13
|
+
gasPrice: ethers.BigNumber.from("0x06a2bb7d00"),
|
|
14
|
+
gasLimit: ethers.BigNumber.from("0x01512c"),
|
|
15
|
+
value: ethers.BigNumber.from("0x00"),
|
|
16
|
+
data: "0xa9059cbb00000000000000000000000082ec3523f8a722694ca217ebfd95efbcadad77ee000000000000000000000000000000000000000000000002b5e3af16b1880000",
|
|
17
|
+
chainId: 1,
|
|
18
|
+
};
|
|
19
|
+
const txHex = ethers.utils.serializeTransaction(transaction).slice(2);
|
|
10
20
|
|
|
11
21
|
describe("ERC20 dynamic cal", () => {
|
|
12
22
|
describe("ERC20 is in local CAL", () => {
|
|
13
23
|
it("should be successfully signin transaction from dynamic CAL", async () => {
|
|
24
|
+
jest.spyOn(axios, "get").mockImplementation(async () => ({ data: SignatureCALEth }));
|
|
14
25
|
const apdusBuffer = await fs.readFile(
|
|
15
26
|
path.resolve("./tests/fixtures/apdus/ERC20-OK.apdus"),
|
|
16
27
|
"utf-8",
|
|
@@ -76,4 +87,4 @@ describe("ERC20 dynamic cal", () => {
|
|
|
76
87
|
});
|
|
77
88
|
});
|
|
78
89
|
});
|
|
79
|
-
});
|
|
90
|
+
});
|
package/tests/Eth.unit.test.ts
CHANGED
|
@@ -595,11 +595,15 @@ describe("Eth app biding", () => {
|
|
|
595
595
|
});
|
|
596
596
|
});
|
|
597
597
|
|
|
598
|
+
/*
|
|
599
|
+
* if 1inch token is popular again
|
|
600
|
+
might need to put this back, starting at line 2
|
|
601
|
+
=> e00a0000680531494e4348111111111117dc0aa78b770fa6a738034120c3020000001200000001304402204623e5f1375c54a446157ae8a739204284cf053634b7abd083dc5f5d2675c4e702206ff94b4c84ba9e93f44065c38d7c92506621fa69ba04f767aa58221de8afbf17
|
|
602
|
+
<= 9000
|
|
603
|
+
*/
|
|
598
604
|
const paraswapAPDUs =
|
|
599
605
|
`=> e0120000670850617261737761701bd435f3c054b6e901b7b108a0ab7617c808677bcfc0afeb304402201c0cbe69aac517825b3a6eb5e7251e8fd57ff93a43bd3df52c7a841818eda81b022001a10cc326efaee2463fc96e7c29739c308fb8179bd2ac37303662bae4f7705c
|
|
600
606
|
<= 9000
|
|
601
|
-
=> e00a0000680531494e4348111111111117dc0aa78b770fa6a738034120c3020000001200000001304402204623e5f1375c54a446157ae8a739204284cf053634b7abd083dc5f5d2675c4e702206ff94b4c84ba9e93f44065c38d7c92506621fa69ba04f767aa58221de8afbf17
|
|
602
|
-
<= 9000
|
|
603
607
|
=> e004000096058000002c8000003c800000000000000000000000f903cd82043d8509c765240083042e73941bd435f3c054b6e901b7b108a0ab7617c808677b80b903a4cfc0afeb000000000000000000000000111111111117dc0aa78b770fa6a738034120c302000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000
|
|
604
608
|
<= 9000
|
|
605
609
|
=> e0048000960000000af10f7eb24f506cfd00000000000000000000000000000000000000000000000002a5b905b3c9fa4c00000000000000000000000000000000000000000000000002baaee8d905020a000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001c000000000000000000000
|