@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.
@@ -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 transport.close();
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 transport.close();
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 transport.close();
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 transport.close();
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 transport.close();
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 transport.close();
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 transport.close();
121
+ await app.close();
122
122
  }, 10000);
123
123
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/ledger-app",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "license": "GPL",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "exports": {
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')}`)
@@ -23,6 +23,6 @@ describe.skip('Integration', () => {
23
23
  console.log(signature)
24
24
  expect(transactionVerifySignature(hash.toString('hex'), account.publicKey, signature)).toBe(true)
25
25
 
26
- await transport.close()
26
+ await app.close()
27
27
  }, 100000)
28
28
  })
@@ -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 transport.close()
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 transport.close()
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 transport.close()
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 transport.close()
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 transport.close()
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 transport.close()
109
+ await app.close()
110
110
  }, 10000)
111
111
  })