@ledgerhq/coin-tester-polkadot 1.5.0-nightly.20251217142347 → 1.5.0-nightly.20251219024040
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +32 -9
- package/README.md +30 -0
- package/lib/src/scenarii/AssetHub.d.ts.map +1 -1
- package/lib/src/scenarii/AssetHub.js +5 -13
- package/lib/src/scenarii/AssetHub.js.map +1 -1
- package/lib/src/scenarii/Polkadot.d.ts.map +1 -1
- package/lib/src/scenarii/Polkadot.js +5 -13
- package/lib/src/scenarii/Polkadot.js.map +1 -1
- package/lib/src/signer.d.ts +3 -0
- package/lib/src/signer.d.ts.map +1 -0
- package/lib/src/signer.js +28 -0
- package/lib/src/signer.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib-es/src/scenarii/AssetHub.d.ts.map +1 -1
- package/lib-es/src/scenarii/AssetHub.js +5 -13
- package/lib-es/src/scenarii/AssetHub.js.map +1 -1
- package/lib-es/src/scenarii/Polkadot.d.ts.map +1 -1
- package/lib-es/src/scenarii/Polkadot.js +5 -13
- package/lib-es/src/scenarii/Polkadot.js.map +1 -1
- package/lib-es/src/signer.d.ts +3 -0
- package/lib-es/src/signer.d.ts.map +1 -0
- package/lib-es/src/signer.js +25 -0
- package/lib-es/src/signer.js.map +1 -0
- package/lib-es/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -8
- package/src/scenarii/AssetHub.ts +5 -17
- package/src/scenarii/Polkadot.ts +5 -17
- package/src/scenarii.test.ts +3 -4
- package/src/signer.ts +32 -0
- package/lib/src/constants.d.ts +0 -5
- package/lib/src/constants.d.ts.map +0 -1
- package/lib/src/constants.js +0 -5
- package/lib/src/constants.js.map +0 -1
- package/lib-es/src/constants.d.ts +0 -5
- package/lib-es/src/constants.d.ts.map +0 -1
- package/lib-es/src/constants.js +0 -2
- package/lib-es/src/constants.js.map +0 -1
- package/src/constants.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-tester-polkadot",
|
|
3
|
-
"version": "1.5.0-nightly.
|
|
3
|
+
"version": "1.5.0-nightly.20251219024040",
|
|
4
4
|
"description": "Ledger Polkadot Coin Tester",
|
|
5
5
|
"main": "src/scenarii.test.ts",
|
|
6
6
|
"keywords": [
|
|
@@ -50,13 +50,12 @@
|
|
|
50
50
|
"dotenv": "^16.4.5",
|
|
51
51
|
"expect": "^27.4.6",
|
|
52
52
|
"msw": "^2.2.1",
|
|
53
|
-
"@ledgerhq/coin-
|
|
54
|
-
"@ledgerhq/coin-
|
|
55
|
-
"@ledgerhq/
|
|
56
|
-
"@ledgerhq/
|
|
57
|
-
"@ledgerhq/
|
|
58
|
-
"@ledgerhq/types-
|
|
59
|
-
"@ledgerhq/types-live": "^6.91.0-nightly.20251217142347"
|
|
53
|
+
"@ledgerhq/coin-framework": "^6.11.0-nightly.20251219024040",
|
|
54
|
+
"@ledgerhq/coin-polkadot": "^6.14.0-nightly.20251219024040",
|
|
55
|
+
"@ledgerhq/coin-tester": "^0.14.0-nightly.20251219024040",
|
|
56
|
+
"@ledgerhq/cryptoassets": "^13.35.0-nightly.20251219024040",
|
|
57
|
+
"@ledgerhq/types-cryptoassets": "^7.31.0-nightly.20251219024040",
|
|
58
|
+
"@ledgerhq/types-live": "^6.91.0-nightly.20251219024040"
|
|
60
59
|
},
|
|
61
60
|
"devDependencies": {
|
|
62
61
|
"@polkadot/util": "12.6.2",
|
package/src/scenarii/AssetHub.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
|
-
import Polkadot from "@ledgerhq/hw-app-polkadot";
|
|
3
2
|
import { cryptoWaitReady } from "@polkadot/util-crypto";
|
|
4
3
|
import { ApiPromise, Keyring, WsProvider } from "@polkadot/api";
|
|
5
4
|
import { Scenario, ScenarioTransaction } from "@ledgerhq/coin-tester/main";
|
|
6
|
-
import { killSpeculos, spawnSpeculos } from "@ledgerhq/coin-tester/signers/speculos";
|
|
7
5
|
import { formatCurrencyUnit, parseCurrencyUnit } from "@ledgerhq/coin-framework/currencies";
|
|
8
6
|
import { killChopsticksAndSidecar, spawnChopsticksAndSidecar } from "../chopsticks-sidecar";
|
|
9
7
|
import { PolkadotCoinConfig } from "@ledgerhq/coin-polkadot/config";
|
|
10
8
|
import { ExplorerExtrinsic } from "@ledgerhq/coin-polkadot";
|
|
11
|
-
import { defaultNanoApp } from "../constants";
|
|
12
9
|
import { createBridges } from "@ledgerhq/coin-polkadot/bridge/index";
|
|
13
10
|
import { makeAccount } from "../fixtures";
|
|
14
11
|
import { indexOperation } from "../indexer";
|
|
@@ -19,6 +16,7 @@ import {
|
|
|
19
16
|
PolkadotOperationExtra,
|
|
20
17
|
Transaction as PolkadotTransaction,
|
|
21
18
|
} from "@ledgerhq/coin-polkadot/types/bridge";
|
|
19
|
+
import { buildSigner } from "../signer";
|
|
22
20
|
|
|
23
21
|
type PolkadotScenarioTransaction = ScenarioTransaction<PolkadotTransaction, PolkadotAccount>;
|
|
24
22
|
|
|
@@ -243,20 +241,11 @@ const coinConfig: PolkadotCoinConfig = {
|
|
|
243
241
|
hasBeenMigrated: true,
|
|
244
242
|
};
|
|
245
243
|
|
|
246
|
-
const subscriptions: any[] = [];
|
|
247
|
-
|
|
248
244
|
export const AssetHubScenario: Scenario<PolkadotTransaction, PolkadotAccount> = {
|
|
249
245
|
name: "Polkadot AssetHub Ledger Live transactions",
|
|
250
246
|
|
|
251
247
|
setup: async () => {
|
|
252
|
-
|
|
253
|
-
spawnSpeculos(
|
|
254
|
-
`/${defaultNanoApp.firmware}/PolkadotMigration/app_${defaultNanoApp.version}.elf`,
|
|
255
|
-
),
|
|
256
|
-
spawnChopsticksAndSidecar("/coin-tester-polkadot/coin-tester-chopsticks/assethub.yml"),
|
|
257
|
-
]);
|
|
258
|
-
|
|
259
|
-
const onSignerConfirmation = getOnSpeculosConfirmation("APPROVE");
|
|
248
|
+
await spawnChopsticksAndSidecar("/coin-tester-polkadot/coin-tester-chopsticks/assethub.yml");
|
|
260
249
|
|
|
261
250
|
await cryptoWaitReady();
|
|
262
251
|
await wsProvider.connect();
|
|
@@ -265,7 +254,8 @@ export const AssetHubScenario: Scenario<PolkadotTransaction, PolkadotAccount> =
|
|
|
265
254
|
const keyring = new Keyring({ type: "sr25519" });
|
|
266
255
|
keyring.setSS58Format(0);
|
|
267
256
|
|
|
268
|
-
const
|
|
257
|
+
const signer = await buildSigner();
|
|
258
|
+
const signerContext: Parameters<typeof resolver>[0] = (_, fn) => fn(signer);
|
|
269
259
|
|
|
270
260
|
const { accountBridge, currencyBridge } = createBridges(signerContext, () => coinConfig);
|
|
271
261
|
|
|
@@ -301,7 +291,6 @@ export const AssetHubScenario: Scenario<PolkadotTransaction, PolkadotAccount> =
|
|
|
301
291
|
currencyBridge,
|
|
302
292
|
address: polkadotScenarioAccountPair.address,
|
|
303
293
|
account,
|
|
304
|
-
onSignerConfirmation,
|
|
305
294
|
};
|
|
306
295
|
},
|
|
307
296
|
getTransactions,
|
|
@@ -405,8 +394,7 @@ export const AssetHubScenario: Scenario<PolkadotTransaction, PolkadotAccount> =
|
|
|
405
394
|
unsubscribeNewBlockListener();
|
|
406
395
|
},
|
|
407
396
|
teardown: async () => {
|
|
408
|
-
subscriptions.forEach(unsub => unsub());
|
|
409
397
|
await wsProvider.disconnect();
|
|
410
|
-
await
|
|
398
|
+
await killChopsticksAndSidecar();
|
|
411
399
|
},
|
|
412
400
|
};
|
package/src/scenarii/Polkadot.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
|
-
import Polkadot from "@ledgerhq/hw-app-polkadot";
|
|
3
2
|
import { cryptoWaitReady } from "@polkadot/util-crypto";
|
|
4
3
|
import { ApiPromise, Keyring, WsProvider } from "@polkadot/api";
|
|
5
4
|
import { Scenario, ScenarioTransaction } from "@ledgerhq/coin-tester/main";
|
|
6
|
-
import { killSpeculos, spawnSpeculos } from "@ledgerhq/coin-tester/signers/speculos";
|
|
7
5
|
import { formatCurrencyUnit, parseCurrencyUnit } from "@ledgerhq/coin-framework/currencies";
|
|
8
6
|
import { killChopsticksAndSidecar, spawnChopsticksAndSidecar } from "../chopsticks-sidecar";
|
|
9
7
|
import { PolkadotCoinConfig } from "@ledgerhq/coin-polkadot/config";
|
|
10
8
|
import { ExplorerExtrinsic } from "@ledgerhq/coin-polkadot";
|
|
11
|
-
import { defaultNanoApp } from "../constants";
|
|
12
9
|
import { createBridges } from "@ledgerhq/coin-polkadot/bridge/index";
|
|
13
10
|
import { makeAccount } from "../fixtures";
|
|
14
11
|
import { indexOperation } from "../indexer";
|
|
@@ -19,6 +16,7 @@ import {
|
|
|
19
16
|
PolkadotOperationExtra,
|
|
20
17
|
Transaction as PolkadotTransaction,
|
|
21
18
|
} from "@ledgerhq/coin-polkadot/types/bridge";
|
|
19
|
+
import { buildSigner } from "../signer";
|
|
22
20
|
|
|
23
21
|
type PolkadotScenarioTransaction = ScenarioTransaction<PolkadotTransaction, PolkadotAccount>;
|
|
24
22
|
|
|
@@ -89,20 +87,11 @@ const coinConfig: PolkadotCoinConfig = {
|
|
|
89
87
|
},
|
|
90
88
|
};
|
|
91
89
|
|
|
92
|
-
const subscriptions: any[] = [];
|
|
93
|
-
|
|
94
90
|
export const PolkadotScenario: Scenario<PolkadotTransaction, PolkadotAccount> = {
|
|
95
91
|
name: "Polkadot Ledger Live transactions",
|
|
96
92
|
|
|
97
93
|
setup: async () => {
|
|
98
|
-
|
|
99
|
-
spawnSpeculos(
|
|
100
|
-
`/${defaultNanoApp.firmware}/PolkadotMigration/app_${defaultNanoApp.version}.elf`,
|
|
101
|
-
),
|
|
102
|
-
spawnChopsticksAndSidecar("/coin-tester-polkadot/coin-tester-chopsticks/polkadot.yml"),
|
|
103
|
-
]);
|
|
104
|
-
|
|
105
|
-
const onSignerConfirmation = getOnSpeculosConfirmation("APPROVE");
|
|
94
|
+
await spawnChopsticksAndSidecar("/coin-tester-polkadot/coin-tester-chopsticks/polkadot.yml");
|
|
106
95
|
|
|
107
96
|
await cryptoWaitReady();
|
|
108
97
|
await wsProvider.connect();
|
|
@@ -111,7 +100,8 @@ export const PolkadotScenario: Scenario<PolkadotTransaction, PolkadotAccount> =
|
|
|
111
100
|
const keyring = new Keyring({ type: "sr25519" });
|
|
112
101
|
keyring.setSS58Format(0);
|
|
113
102
|
|
|
114
|
-
const
|
|
103
|
+
const signer = await buildSigner();
|
|
104
|
+
const signerContext: Parameters<typeof resolver>[0] = (_, fn) => fn(signer);
|
|
115
105
|
|
|
116
106
|
const { accountBridge, currencyBridge } = createBridges(signerContext, () => coinConfig);
|
|
117
107
|
|
|
@@ -147,7 +137,6 @@ export const PolkadotScenario: Scenario<PolkadotTransaction, PolkadotAccount> =
|
|
|
147
137
|
currencyBridge,
|
|
148
138
|
address: polkadotScenarioAccountPair.address,
|
|
149
139
|
account,
|
|
150
|
-
onSignerConfirmation,
|
|
151
140
|
};
|
|
152
141
|
},
|
|
153
142
|
getTransactions,
|
|
@@ -251,8 +240,7 @@ export const PolkadotScenario: Scenario<PolkadotTransaction, PolkadotAccount> =
|
|
|
251
240
|
unsubscribeNewBlockListener();
|
|
252
241
|
},
|
|
253
242
|
teardown: async () => {
|
|
254
|
-
subscriptions.forEach(unsub => unsub());
|
|
255
243
|
await wsProvider.disconnect();
|
|
256
|
-
await
|
|
244
|
+
await killChopsticksAndSidecar();
|
|
257
245
|
},
|
|
258
246
|
};
|
package/src/scenarii.test.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import console from "console";
|
|
2
2
|
import { executeScenario } from "@ledgerhq/coin-tester/main";
|
|
3
|
-
import { killSpeculos } from "@ledgerhq/coin-tester/signers/speculos";
|
|
4
3
|
import { killChopsticksAndSidecar } from "./chopsticks-sidecar";
|
|
5
4
|
import { AssetHubScenario } from "./scenarii/AssetHub";
|
|
6
5
|
import { PolkadotScenario } from "./scenarii/Polkadot";
|
|
@@ -14,7 +13,7 @@ describe("Polkadot Deterministic Tester", () => {
|
|
|
14
13
|
await executeScenario(AssetHubScenario);
|
|
15
14
|
} catch (e) {
|
|
16
15
|
if (e != "done") {
|
|
17
|
-
await
|
|
16
|
+
await killChopsticksAndSidecar();
|
|
18
17
|
throw e;
|
|
19
18
|
}
|
|
20
19
|
}
|
|
@@ -25,7 +24,7 @@ describe("Polkadot Deterministic Tester", () => {
|
|
|
25
24
|
await executeScenario(PolkadotScenario);
|
|
26
25
|
} catch (e) {
|
|
27
26
|
if (e != "done") {
|
|
28
|
-
await
|
|
27
|
+
await killChopsticksAndSidecar();
|
|
29
28
|
throw e;
|
|
30
29
|
}
|
|
31
30
|
}
|
|
@@ -34,6 +33,6 @@ describe("Polkadot Deterministic Tester", () => {
|
|
|
34
33
|
|
|
35
34
|
["exit", "SIGINT", "SIGQUIT", "SIGTERM", "SIGUSR1", "SIGUSR2", "uncaughtException"].map(e =>
|
|
36
35
|
process.on(e, async () => {
|
|
37
|
-
await
|
|
36
|
+
await killChopsticksAndSidecar();
|
|
38
37
|
}),
|
|
39
38
|
);
|
package/src/signer.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PolkadotAddress, PolkadotSignature, PolkadotSigner } from "@ledgerhq/coin-polkadot/index";
|
|
2
|
+
import { Keyring } from "@polkadot/api";
|
|
3
|
+
import { hdLedger, encodeAddress, mnemonicGenerate } from "@polkadot/util-crypto";
|
|
4
|
+
import { Keypair } from "@polkadot/util-crypto/types";
|
|
5
|
+
|
|
6
|
+
function getAddress(keyPair: Keypair): Promise<PolkadotAddress> {
|
|
7
|
+
return Promise.resolve({
|
|
8
|
+
address: encodeAddress(keyPair.publicKey, 0),
|
|
9
|
+
pubKey: Buffer.from(keyPair.publicKey).toString("hex"),
|
|
10
|
+
return_code: 0,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function signTransaction(keyPair: Keypair, transaction: Buffer): Promise<PolkadotSignature> {
|
|
15
|
+
const keyring = new Keyring().addFromPair(keyPair);
|
|
16
|
+
return Promise.resolve({
|
|
17
|
+
signature: Buffer.from(keyring.sign(transaction, { withType: true })).toString("hex"),
|
|
18
|
+
return_code: 0,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function buildSigner(): Promise<PolkadotSigner> {
|
|
23
|
+
const seed = mnemonicGenerate(24);
|
|
24
|
+
|
|
25
|
+
const keyPair = (path: string) => hdLedger(seed, `m/${path}`);
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
getAddress: (path: string) => getAddress(keyPair(path)),
|
|
29
|
+
sign: (path: string, transaction: Uint8Array) =>
|
|
30
|
+
signTransaction(keyPair(path), Buffer.from(transaction)),
|
|
31
|
+
};
|
|
32
|
+
}
|
package/lib/src/constants.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;CAA+D,CAAC"}
|
package/lib/src/constants.js
DELETED
package/lib/src/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,EAAE,QAAQ,EAAE,OAAgB,EAAE,OAAO,EAAE,UAAmB,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;CAA+D,CAAC"}
|
package/lib-es/src/constants.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,QAAQ,EAAE,OAAgB,EAAE,OAAO,EAAE,UAAmB,EAAE,CAAC"}
|
package/src/constants.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const defaultNanoApp = { firmware: "2.5.0" as const, version: "100.0.10" as const };
|