@alephium/ledger-app 0.1.6 → 0.1.7
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/index.d.ts +1 -0
- package/dist/src/index.js +3 -0
- package/dist/test/release.test.js +1 -1
- package/dist/test/speculos.test.js +6 -6
- package/package.json +1 -1
- package/src/index.ts +4 -0
- package/test/release.test.ts +1 -1
- package/test/speculos.test.ts +6 -6
package/dist/src/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare const HASH_LEN = 32;
|
|
|
12
12
|
export default class AlephiumApp {
|
|
13
13
|
readonly transport: Transport;
|
|
14
14
|
constructor(transport: Transport);
|
|
15
|
+
close(): Promise<void>;
|
|
15
16
|
getVersion(): Promise<string>;
|
|
16
17
|
getAccount(startPath: string, targetGroup?: number, keyType?: KeyType): Promise<readonly [Account, number]>;
|
|
17
18
|
signHash(path: string, hash: Buffer): Promise<string>;
|
package/dist/src/index.js
CHANGED
|
@@ -42,6 +42,9 @@ class AlephiumApp {
|
|
|
42
42
|
constructor(transport) {
|
|
43
43
|
this.transport = transport;
|
|
44
44
|
}
|
|
45
|
+
async close() {
|
|
46
|
+
await this.transport.close();
|
|
47
|
+
}
|
|
45
48
|
async getVersion() {
|
|
46
49
|
const response = await this.transport.send(exports.CLA, INS.GET_VERSION, 0x00, 0x00);
|
|
47
50
|
console.log(`response ${response.length} - ${response.toString('hex')}`);
|
|
@@ -21,6 +21,6 @@ describe.skip('Integration', () => {
|
|
|
21
21
|
const signature = await app.signHash(path, hash);
|
|
22
22
|
console.log(signature);
|
|
23
23
|
expect((0, web3_1.transactionVerifySignature)(hash.toString('hex'), account.publicKey, signature)).toBe(true);
|
|
24
|
-
await
|
|
24
|
+
await app.close();
|
|
25
25
|
}, 100000);
|
|
26
26
|
});
|
|
@@ -59,7 +59,7 @@ describe('sdk', () => {
|
|
|
59
59
|
const app = new src_1.default(transport);
|
|
60
60
|
const version = await app.getVersion();
|
|
61
61
|
expect(version).toBe('0.1.0');
|
|
62
|
-
await
|
|
62
|
+
await app.close();
|
|
63
63
|
});
|
|
64
64
|
it('should get public key', async () => {
|
|
65
65
|
const transport = await hw_transport_node_speculos_1.default.open({ apduPort });
|
|
@@ -67,7 +67,7 @@ describe('sdk', () => {
|
|
|
67
67
|
const [account, hdIndex] = await app.getAccount(path);
|
|
68
68
|
expect(hdIndex).toBe(pathIndex);
|
|
69
69
|
console.log(account);
|
|
70
|
-
await
|
|
70
|
+
await app.close();
|
|
71
71
|
});
|
|
72
72
|
it('should get public key for group', async () => {
|
|
73
73
|
const transport = await hw_transport_node_speculos_1.default.open({ apduPort });
|
|
@@ -78,7 +78,7 @@ describe('sdk', () => {
|
|
|
78
78
|
expect((0, web3_1.groupOfAddress)(account.address)).toBe(group);
|
|
79
79
|
expect(account.keyType).toBe('default');
|
|
80
80
|
});
|
|
81
|
-
await
|
|
81
|
+
await app.close();
|
|
82
82
|
});
|
|
83
83
|
it('should get public key for group for Schnorr signature', async () => {
|
|
84
84
|
const transport = await hw_transport_node_speculos_1.default.open({ apduPort });
|
|
@@ -86,7 +86,7 @@ describe('sdk', () => {
|
|
|
86
86
|
Array(src_1.GROUP_NUM).forEach(async (_, group) => {
|
|
87
87
|
await expect(app.getAccount(path, group, 'bip340-schnorr')).rejects.toThrow('BIP340-Schnorr is not supported yet');
|
|
88
88
|
});
|
|
89
|
-
await
|
|
89
|
+
await app.close();
|
|
90
90
|
});
|
|
91
91
|
it('should sign hash', async () => {
|
|
92
92
|
const transport = await hw_transport_node_speculos_1.default.open({ apduPort });
|
|
@@ -102,7 +102,7 @@ describe('sdk', () => {
|
|
|
102
102
|
}, 1000);
|
|
103
103
|
const signature = await app.signHash(path, hash);
|
|
104
104
|
console.log(signature);
|
|
105
|
-
await
|
|
105
|
+
await app.close();
|
|
106
106
|
expect((0, web3_1.transactionVerifySignature)(hash.toString('hex'), account.publicKey, signature)).toBe(true);
|
|
107
107
|
}, 10000);
|
|
108
108
|
it('should reject signing', async () => {
|
|
@@ -118,6 +118,6 @@ describe('sdk', () => {
|
|
|
118
118
|
await pressButton('both'); // done selection
|
|
119
119
|
}, 1000);
|
|
120
120
|
await expect(app.signHash(path, hash)).rejects.toThrow();
|
|
121
|
-
await
|
|
121
|
+
await app.close();
|
|
122
122
|
}, 10000);
|
|
123
123
|
});
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -22,6 +22,10 @@ export default class AlephiumApp {
|
|
|
22
22
|
this.transport = transport
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
async close(): Promise<void> {
|
|
26
|
+
await this.transport.close()
|
|
27
|
+
}
|
|
28
|
+
|
|
25
29
|
async getVersion(): Promise<string> {
|
|
26
30
|
const response = await this.transport.send(CLA, INS.GET_VERSION, 0x00, 0x00)
|
|
27
31
|
console.log(`response ${response.length} - ${response.toString('hex')}`)
|
package/test/release.test.ts
CHANGED
package/test/speculos.test.ts
CHANGED
|
@@ -37,7 +37,7 @@ describe('sdk', () => {
|
|
|
37
37
|
const app = new AlephiumApp(transport)
|
|
38
38
|
const version = await app.getVersion()
|
|
39
39
|
expect(version).toBe('0.1.0')
|
|
40
|
-
await
|
|
40
|
+
await app.close()
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
it('should get public key', async () => {
|
|
@@ -46,7 +46,7 @@ describe('sdk', () => {
|
|
|
46
46
|
const [account, hdIndex] = await app.getAccount(path)
|
|
47
47
|
expect(hdIndex).toBe(pathIndex)
|
|
48
48
|
console.log(account)
|
|
49
|
-
await
|
|
49
|
+
await app.close()
|
|
50
50
|
})
|
|
51
51
|
|
|
52
52
|
it('should get public key for group', async () => {
|
|
@@ -58,7 +58,7 @@ describe('sdk', () => {
|
|
|
58
58
|
expect(groupOfAddress(account.address)).toBe(group)
|
|
59
59
|
expect(account.keyType).toBe('default')
|
|
60
60
|
})
|
|
61
|
-
await
|
|
61
|
+
await app.close()
|
|
62
62
|
})
|
|
63
63
|
|
|
64
64
|
it('should get public key for group for Schnorr signature', async () => {
|
|
@@ -67,7 +67,7 @@ describe('sdk', () => {
|
|
|
67
67
|
Array(GROUP_NUM).forEach(async (_, group) => {
|
|
68
68
|
await expect(app.getAccount(path, group, 'bip340-schnorr')).rejects.toThrow('BIP340-Schnorr is not supported yet')
|
|
69
69
|
})
|
|
70
|
-
await
|
|
70
|
+
await app.close()
|
|
71
71
|
})
|
|
72
72
|
|
|
73
73
|
it('should sign hash', async () => {
|
|
@@ -86,7 +86,7 @@ describe('sdk', () => {
|
|
|
86
86
|
}, 1000)
|
|
87
87
|
const signature = await app.signHash(path, hash)
|
|
88
88
|
console.log(signature)
|
|
89
|
-
await
|
|
89
|
+
await app.close()
|
|
90
90
|
|
|
91
91
|
expect(transactionVerifySignature(hash.toString('hex'), account.publicKey, signature)).toBe(true)
|
|
92
92
|
}, 10000)
|
|
@@ -106,6 +106,6 @@ describe('sdk', () => {
|
|
|
106
106
|
await pressButton('both') // done selection
|
|
107
107
|
}, 1000)
|
|
108
108
|
await expect(app.signHash(path, hash)).rejects.toThrow()
|
|
109
|
-
await
|
|
109
|
+
await app.close()
|
|
110
110
|
}, 10000)
|
|
111
111
|
})
|