@alephium/ledger-app 0.5.1 → 0.5.2
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/dist/src/ledger-app.d.ts +1 -1
- package/dist/src/ledger-app.js +2 -2
- package/dist/test/wallet.test.js +17 -40
- package/package.json +1 -1
- package/src/ledger-app.ts +1 -1
- package/test/wallet.test.ts +1 -1
package/dist/src/ledger-app.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare enum INS {
|
|
|
11
11
|
}
|
|
12
12
|
export declare const GROUP_NUM = 4;
|
|
13
13
|
export declare const HASH_LEN = 32;
|
|
14
|
-
export
|
|
14
|
+
export declare class AlephiumApp {
|
|
15
15
|
readonly transport: Transport;
|
|
16
16
|
constructor(transport: Transport);
|
|
17
17
|
close(): Promise<void>;
|
package/dist/src/ledger-app.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.HASH_LEN = exports.GROUP_NUM = exports.INS = exports.CLA = void 0;
|
|
26
|
+
exports.AlephiumApp = exports.HASH_LEN = exports.GROUP_NUM = exports.INS = exports.CLA = void 0;
|
|
27
27
|
const web3_1 = require("@alephium/web3");
|
|
28
28
|
const hw_transport_1 = require("@ledgerhq/hw-transport");
|
|
29
29
|
const serde = __importStar(require("./serde"));
|
|
@@ -103,7 +103,7 @@ class AlephiumApp {
|
|
|
103
103
|
return decodeSignature(response);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
exports.
|
|
106
|
+
exports.AlephiumApp = AlephiumApp;
|
|
107
107
|
function decodeSignature(response) {
|
|
108
108
|
// Decode signature: https://bitcoin.stackexchange.com/a/12556
|
|
109
109
|
const rLen = response.slice(3, 4)[0];
|
package/dist/test/wallet.test.js
CHANGED
|
@@ -1,32 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const ledger_app_1 =
|
|
6
|
+
const ledger_app_1 = require("../src/ledger-app");
|
|
30
7
|
const web3_1 = require("@alephium/web3");
|
|
31
8
|
const web3_test_1 = require("@alephium/web3-test");
|
|
32
9
|
const web3_wallet_1 = require("@alephium/web3-wallet");
|
|
@@ -56,14 +33,14 @@ describe('ledger wallet', () => {
|
|
|
56
33
|
}
|
|
57
34
|
it('should get version', async () => {
|
|
58
35
|
const transport = await (0, utils_1.createTransport)();
|
|
59
|
-
const app = new ledger_app_1.
|
|
36
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
60
37
|
const version = await app.getVersion();
|
|
61
38
|
expect(version).toBe('0.4.0');
|
|
62
39
|
await app.close();
|
|
63
40
|
});
|
|
64
41
|
it('should get public key', async () => {
|
|
65
42
|
const transport = await (0, utils_1.createTransport)();
|
|
66
|
-
const app = new ledger_app_1.
|
|
43
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
67
44
|
const [account, hdIndex] = await app.getAccount(path);
|
|
68
45
|
expect(hdIndex).toBe(pathIndex);
|
|
69
46
|
console.log(account);
|
|
@@ -71,7 +48,7 @@ describe('ledger wallet', () => {
|
|
|
71
48
|
});
|
|
72
49
|
it('should get public key and confirm address', async () => {
|
|
73
50
|
const transport = await (0, utils_1.createTransport)();
|
|
74
|
-
const app = new ledger_app_1.
|
|
51
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
75
52
|
(0, utils_1.approveAddress)();
|
|
76
53
|
const [account, hdIndex] = await app.getAccount(path, undefined, undefined, true);
|
|
77
54
|
expect(hdIndex).toBe(pathIndex);
|
|
@@ -80,7 +57,7 @@ describe('ledger wallet', () => {
|
|
|
80
57
|
}, 30000);
|
|
81
58
|
it('should get public key for group', async () => {
|
|
82
59
|
const transport = await (0, utils_1.createTransport)();
|
|
83
|
-
const app = new ledger_app_1.
|
|
60
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
84
61
|
for (let group = 0; group < ledger_app_1.GROUP_NUM; group++) {
|
|
85
62
|
const [account, hdIndex] = await app.getAccount(path, group);
|
|
86
63
|
expect(hdIndex >= pathIndex).toBe(true);
|
|
@@ -91,7 +68,7 @@ describe('ledger wallet', () => {
|
|
|
91
68
|
});
|
|
92
69
|
it('should get public key for group for Schnorr signature', async () => {
|
|
93
70
|
const transport = await (0, utils_1.createTransport)();
|
|
94
|
-
const app = new ledger_app_1.
|
|
71
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
95
72
|
for (let group = 0; group < ledger_app_1.GROUP_NUM; group++) {
|
|
96
73
|
await expect(app.getAccount(path, group, 'bip340-schnorr')).rejects.toThrow('BIP340-Schnorr is not supported yet');
|
|
97
74
|
}
|
|
@@ -99,7 +76,7 @@ describe('ledger wallet', () => {
|
|
|
99
76
|
});
|
|
100
77
|
it('should sign hash', async () => {
|
|
101
78
|
const transport = await (0, utils_1.createTransport)();
|
|
102
|
-
const app = new ledger_app_1.
|
|
79
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
103
80
|
const [account] = await app.getAccount(path);
|
|
104
81
|
console.log(account);
|
|
105
82
|
const hash = Buffer.from(blakejs_1.default.blake2b(Buffer.from([0, 1, 2, 3, 4]), undefined, 32));
|
|
@@ -111,7 +88,7 @@ describe('ledger wallet', () => {
|
|
|
111
88
|
}, 10000);
|
|
112
89
|
it('should transfer alph to one address', async () => {
|
|
113
90
|
const transport = await (0, utils_1.createTransport)();
|
|
114
|
-
const app = new ledger_app_1.
|
|
91
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
115
92
|
const [testAccount] = await app.getAccount(path);
|
|
116
93
|
await transferToAddress(testAccount.address);
|
|
117
94
|
const buildTxResult = await nodeProvider.transactions.postTransactionsBuild({
|
|
@@ -137,7 +114,7 @@ describe('ledger wallet', () => {
|
|
|
137
114
|
}, 120000);
|
|
138
115
|
it('should transfer alph to multiple addresses', async () => {
|
|
139
116
|
const transport = await (0, utils_1.createTransport)();
|
|
140
|
-
const app = new ledger_app_1.
|
|
117
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
141
118
|
const [testAccount] = await app.getAccount(path);
|
|
142
119
|
await transferToAddress(testAccount.address);
|
|
143
120
|
const buildTxResult = await nodeProvider.transactions.postTransactionsBuild({
|
|
@@ -167,7 +144,7 @@ describe('ledger wallet', () => {
|
|
|
167
144
|
}, 120000);
|
|
168
145
|
it('should transfer alph to multisig address', async () => {
|
|
169
146
|
const transport = await (0, utils_1.createTransport)();
|
|
170
|
-
const app = new ledger_app_1.
|
|
147
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
171
148
|
const [testAccount] = await app.getAccount(path);
|
|
172
149
|
await transferToAddress(testAccount.address);
|
|
173
150
|
const multiSigAddress = 'X3KYVteDjsKuUP1F68Nv9iEUecnnkMuwjbC985AnA6MvciDFJ5bAUEso2Sd7sGrwZ5rfNLj7Rp4n9XjcyzDiZsrPxfhNkPYcDm3ce8pQ9QasNFByEufMi3QJ3cS9Vk6cTpqNcq';
|
|
@@ -194,7 +171,7 @@ describe('ledger wallet', () => {
|
|
|
194
171
|
}, 120000);
|
|
195
172
|
it('should transfer token to multisig address', async () => {
|
|
196
173
|
const transport = await (0, utils_1.createTransport)();
|
|
197
|
-
const app = new ledger_app_1.
|
|
174
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
198
175
|
const [testAccount] = await app.getAccount(path);
|
|
199
176
|
await transferToAddress(testAccount.address);
|
|
200
177
|
const tokenInfo = await (0, web3_test_1.mintToken)(testAccount.address, 2222222222222222222222222n);
|
|
@@ -259,7 +236,7 @@ describe('ledger wallet', () => {
|
|
|
259
236
|
}
|
|
260
237
|
it('should transfer token with metadata', async () => {
|
|
261
238
|
const transport = await (0, utils_1.createTransport)();
|
|
262
|
-
const app = new ledger_app_1.
|
|
239
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
263
240
|
const [testAccount] = await app.getAccount(path);
|
|
264
241
|
await transferToAddress(testAccount.address);
|
|
265
242
|
const toAddress = '1BmVCLrjttchZMW7i6df7mTdCKzHpy38bgDbVL1GqV6P7';
|
|
@@ -288,7 +265,7 @@ describe('ledger wallet', () => {
|
|
|
288
265
|
}, 120000);
|
|
289
266
|
it('should reject tx if the metadata version is invalid', async () => {
|
|
290
267
|
const transport = await (0, utils_1.createTransport)();
|
|
291
|
-
const app = new ledger_app_1.
|
|
268
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
292
269
|
const [testAccount] = await app.getAccount(path);
|
|
293
270
|
await transferToAddress(testAccount.address);
|
|
294
271
|
const toAddress = '1BmVCLrjttchZMW7i6df7mTdCKzHpy38bgDbVL1GqV6P7';
|
|
@@ -306,7 +283,7 @@ describe('ledger wallet', () => {
|
|
|
306
283
|
}, 120000);
|
|
307
284
|
it('should transfer from multiple inputs', async () => {
|
|
308
285
|
const transport = await (0, utils_1.createTransport)();
|
|
309
|
-
const app = new ledger_app_1.
|
|
286
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
310
287
|
const [testAccount] = await app.getAccount(path);
|
|
311
288
|
for (let i = 0; i < 20; i += 1) {
|
|
312
289
|
await transferToAddress(testAccount.address, web3_1.ONE_ALPH);
|
|
@@ -344,7 +321,7 @@ describe('ledger wallet', () => {
|
|
|
344
321
|
}
|
|
345
322
|
it('should test external inputs', async () => {
|
|
346
323
|
const transport = await (0, utils_1.createTransport)();
|
|
347
|
-
const app = new ledger_app_1.
|
|
324
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
348
325
|
const [testAccount] = await app.getAccount(path);
|
|
349
326
|
const { account: newAccount, unlockScript: unlockScript0 } = getAccount(testAccount.group);
|
|
350
327
|
for (let i = 0; i < 2; i += 1) {
|
|
@@ -401,7 +378,7 @@ describe('ledger wallet', () => {
|
|
|
401
378
|
}, 120000);
|
|
402
379
|
it('should test self transfer tx', async () => {
|
|
403
380
|
const transport = await (0, utils_1.createTransport)();
|
|
404
|
-
const app = new ledger_app_1.
|
|
381
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
405
382
|
const [testAccount] = await app.getAccount(path);
|
|
406
383
|
await transferToAddress(testAccount.address);
|
|
407
384
|
const buildTxResult = await nodeProvider.transactions.postTransactionsBuild({
|
|
@@ -427,7 +404,7 @@ describe('ledger wallet', () => {
|
|
|
427
404
|
}, 12000);
|
|
428
405
|
it('should test script execution tx', async () => {
|
|
429
406
|
const transport = await (0, utils_1.createTransport)();
|
|
430
|
-
const app = new ledger_app_1.
|
|
407
|
+
const app = new ledger_app_1.AlephiumApp(transport);
|
|
431
408
|
const [testAccount] = await app.getAccount(path);
|
|
432
409
|
await transferToAddress(testAccount.address);
|
|
433
410
|
const buildTxResult = await nodeProvider.contracts.postContractsUnsignedTxDeployContract({
|
package/package.json
CHANGED
package/src/ledger-app.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const HASH_LEN = 32
|
|
|
20
20
|
// The maximum payload size is 255: https://github.com/LedgerHQ/ledger-live/blob/develop/libs/ledgerjs/packages/hw-transport/src/Transport.ts#L261
|
|
21
21
|
const MAX_PAYLOAD_SIZE = 255
|
|
22
22
|
|
|
23
|
-
export
|
|
23
|
+
export class AlephiumApp {
|
|
24
24
|
readonly transport: Transport
|
|
25
25
|
|
|
26
26
|
constructor(transport: Transport) {
|
package/test/wallet.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import AlephiumApp,
|
|
1
|
+
import { AlephiumApp, GROUP_NUM } from '../src/ledger-app'
|
|
2
2
|
import { ALPH_TOKEN_ID, Address, DUST_AMOUNT, NodeProvider, ONE_ALPH, binToHex, codec, groupOfAddress, node, sleep, transactionVerifySignature, waitForTxConfirmation, web3 } from '@alephium/web3'
|
|
3
3
|
import { getSigner, mintToken, transfer } from '@alephium/web3-test'
|
|
4
4
|
import { PrivateKeyWallet } from '@alephium/web3-wallet'
|