@ledgerhq/live-common 21.36.3 → 21.36.4

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.
Files changed (39) hide show
  1. package/lib/bridge/jsHelpers.d.ts.map +1 -1
  2. package/lib/bridge/jsHelpers.js +245 -238
  3. package/lib/bridge/jsHelpers.js.map +1 -1
  4. package/lib/families/bitcoin/js-signOperation.d.ts.map +1 -1
  5. package/lib/families/bitcoin/js-signOperation.js +139 -130
  6. package/lib/families/bitcoin/js-signOperation.js.map +1 -1
  7. package/lib/families/bitcoin/wallet-btc/storage/index.d.ts.map +1 -1
  8. package/lib/families/bitcoin/wallet-btc/storage/index.js +1 -2
  9. package/lib/families/bitcoin/wallet-btc/storage/index.js.map +1 -1
  10. package/lib/families/crypto_org/js-signOperation.d.ts.map +1 -1
  11. package/lib/families/crypto_org/js-signOperation.js +62 -55
  12. package/lib/families/crypto_org/js-signOperation.js.map +1 -1
  13. package/lib/families/elrond/js-signOperation.d.ts.map +1 -1
  14. package/lib/families/elrond/js-signOperation.js +50 -43
  15. package/lib/families/elrond/js-signOperation.js.map +1 -1
  16. package/lib/families/polkadot/js-signOperation.d.ts.map +1 -1
  17. package/lib/families/polkadot/js-signOperation.js +61 -54
  18. package/lib/families/polkadot/js-signOperation.js.map +1 -1
  19. package/lib/families/ripple/bridge/js.d.ts.map +1 -1
  20. package/lib/families/ripple/bridge/js.js +313 -299
  21. package/lib/families/ripple/bridge/js.js.map +1 -1
  22. package/lib/families/stellar/js-signOperation.d.ts.map +1 -1
  23. package/lib/families/stellar/js-signOperation.js +51 -44
  24. package/lib/families/stellar/js-signOperation.js.map +1 -1
  25. package/lib/families/tron/bridge/js.d.ts.map +1 -1
  26. package/lib/families/tron/bridge/js.js +167 -159
  27. package/lib/families/tron/bridge/js.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/bridge/jsHelpers.ts +213 -213
  30. package/src/families/bitcoin/js-signOperation.ts +17 -14
  31. package/src/families/bitcoin/wallet-btc/storage/index.ts +1 -4
  32. package/src/families/crypto_org/js-signOperation.ts +16 -12
  33. package/src/families/elrond/js-signOperation.ts +14 -10
  34. package/src/families/polkadot/js-signOperation.ts +61 -61
  35. package/src/families/ripple/bridge/js.ts +260 -257
  36. package/src/families/stellar/js-signOperation.ts +14 -10
  37. package/src/families/tron/bridge/js.ts +58 -57
  38. package/src/.DS_Store +0 -0
  39. package/src/data/flags/.DS_Store +0 -0
@@ -1,16 +1,16 @@
1
1
  import { BigNumber } from "bignumber.js";
2
2
  import { Observable } from "rxjs";
3
- import { utils } from "@crypto-com/chain-jslib";
4
3
  import { FeeNotLoaded } from "@ledgerhq/errors";
5
- import CryptoOrgApp from "@ledgerhq/hw-app-cosmos";
6
4
  import {
7
5
  CryptoOrgWrongSignatureHeader,
8
6
  CryptoOrgSignatureSize,
9
7
  } from "./errors";
10
8
  import type { Transaction } from "./types";
11
9
  import type { Account, Operation, SignOperationEvent } from "../../types";
10
+ import { open, close } from "../../hw";
12
11
  import { encodeOperationId } from "../../operation";
13
- import { withDevice } from "../../hw/deviceAccess";
12
+ import CryptoOrgApp from "@ledgerhq/hw-app-cosmos";
13
+ import { utils } from "@crypto-com/chain-jslib";
14
14
  import { buildTransaction } from "./js-buildTransaction";
15
15
  import { isTestNet } from "./logic";
16
16
 
@@ -104,9 +104,11 @@ const signOperation = ({
104
104
  deviceId: any;
105
105
  transaction: Transaction;
106
106
  }): Observable<SignOperationEvent> =>
107
- withDevice(deviceId)((transport) =>
108
- Observable.create((o) => {
109
- async function main() {
107
+ Observable.create((o) => {
108
+ async function main() {
109
+ const transport = await open(deviceId);
110
+
111
+ try {
110
112
  o.next({
111
113
  type: "device-signature-requested",
112
114
  });
@@ -163,13 +165,15 @@ const signOperation = ({
163
165
  },
164
166
  });
165
167
  }
168
+ } finally {
169
+ close(transport, deviceId);
166
170
  }
171
+ }
167
172
 
168
- main().then(
169
- () => o.complete(),
170
- (e) => o.error(e)
171
- );
172
- })
173
- );
173
+ main().then(
174
+ () => o.complete(),
175
+ (e) => o.error(e)
176
+ );
177
+ });
174
178
 
175
179
  export default signOperation;
@@ -3,7 +3,7 @@ import { Observable } from "rxjs";
3
3
  import { FeeNotLoaded } from "@ledgerhq/errors";
4
4
  import type { Transaction } from "./types";
5
5
  import type { Account, Operation, SignOperationEvent } from "../../types";
6
- import { withDevice } from "../../hw/deviceAccess";
6
+ import { open, close } from "../../hw";
7
7
  import { encodeOperationId } from "../../operation";
8
8
  import Elrond from "./hw-app-elrond";
9
9
  import { buildTransaction } from "./js-buildTransaction";
@@ -48,9 +48,11 @@ const signOperation = ({
48
48
  deviceId: any;
49
49
  transaction: Transaction;
50
50
  }): Observable<SignOperationEvent> =>
51
- withDevice(deviceId)((transport) =>
52
- Observable.create((o) => {
53
- async function main() {
51
+ Observable.create((o) => {
52
+ async function main() {
53
+ const transport = await open(deviceId);
54
+
55
+ try {
54
56
  if (!transaction.fees) {
55
57
  throw new FeeNotLoaded();
56
58
  }
@@ -87,13 +89,15 @@ const signOperation = ({
87
89
  expirationDate: null,
88
90
  },
89
91
  });
92
+ } finally {
93
+ close(transport, deviceId);
90
94
  }
95
+ }
91
96
 
92
- main().then(
93
- () => o.complete(),
94
- (e) => o.error(e)
95
- );
96
- })
97
- );
97
+ main().then(
98
+ () => o.complete(),
99
+ (e) => o.error(e)
100
+ );
101
+ });
98
102
 
99
103
  export default signOperation;
@@ -11,7 +11,7 @@ import type {
11
11
  OperationType,
12
12
  SignOperationEvent,
13
13
  } from "../../types";
14
- import { withDevice } from "../../hw/deviceAccess";
14
+ import { open, close } from "../../hw";
15
15
  import { encodeOperationId } from "../../operation";
16
16
  import { buildTransaction } from "./js-buildTransaction";
17
17
  import { calculateAmount, getNonce, isFirstBond } from "./logic";
@@ -157,69 +157,69 @@ const signOperation = ({
157
157
  deviceId: any;
158
158
  transaction: Transaction;
159
159
  }): Observable<SignOperationEvent> =>
160
- withDevice(deviceId)(
161
- (transport) =>
162
- new Observable((o) => {
163
- async function main() {
164
- o.next({
165
- type: "device-signature-requested",
166
- });
160
+ new Observable((o) => {
161
+ async function main() {
162
+ const transport = await open(deviceId);
167
163
 
168
- if (!transaction.fees) {
169
- throw new FeeNotLoaded();
170
- }
171
-
172
- // Ensure amount is filled when useAllAmount
173
- const transactionToSign = {
174
- ...transaction,
175
- amount: calculateAmount({
176
- a: account,
177
- t: transaction,
178
- }),
179
- };
180
- const { unsigned, registry } = await buildTransaction(
181
- account,
182
- transactionToSign,
183
- true
184
- );
185
- const payload = registry
186
- .createType("ExtrinsicPayload", unsigned, {
187
- version: unsigned.version,
188
- })
189
- .toU8a({
190
- method: true,
191
- });
192
- // Sign by device
193
- const polkadot = new Polkadot(transport);
194
- // FIXME: the type of payload Uint8Array is not compatible with the signature of sign which accept a string
195
- const r = await polkadot.sign(
196
- account.freshAddressPath,
197
- payload as any
198
- );
199
- const signed = await signExtrinsic(unsigned, r.signature, registry);
200
- o.next({
201
- type: "device-signature-granted",
202
- });
203
- const operation = buildOptimisticOperation(
204
- account,
205
- transactionToSign,
206
- transactionToSign.fees ?? new BigNumber(0)
207
- );
208
- o.next({
209
- type: "signed",
210
- signedOperation: {
211
- operation,
212
- signature: signed,
213
- expirationDate: null,
214
- },
215
- });
164
+ try {
165
+ o.next({
166
+ type: "device-signature-requested",
167
+ });
168
+
169
+ if (!transaction.fees) {
170
+ throw new FeeNotLoaded();
216
171
  }
217
172
 
218
- main().then(
219
- () => o.complete(),
220
- (e) => o.error(e)
173
+ // Ensure amount is filled when useAllAmount
174
+ const transactionToSign = {
175
+ ...transaction,
176
+ amount: calculateAmount({
177
+ a: account,
178
+ t: transaction,
179
+ }),
180
+ };
181
+ const { unsigned, registry } = await buildTransaction(
182
+ account,
183
+ transactionToSign,
184
+ true
221
185
  );
222
- })
223
- );
186
+ const payload = registry
187
+ .createType("ExtrinsicPayload", unsigned, {
188
+ version: unsigned.version,
189
+ })
190
+ .toU8a({
191
+ method: true,
192
+ });
193
+ // Sign by device
194
+ const polkadot = new Polkadot(transport);
195
+ // FIXME: the type of payload Uint8Array is not compatible with the signature of sign which accept a string
196
+ const r = await polkadot.sign(account.freshAddressPath, payload as any);
197
+ const signed = await signExtrinsic(unsigned, r.signature, registry);
198
+ o.next({
199
+ type: "device-signature-granted",
200
+ });
201
+ const operation = buildOptimisticOperation(
202
+ account,
203
+ transactionToSign,
204
+ transactionToSign.fees ?? new BigNumber(0)
205
+ );
206
+ o.next({
207
+ type: "signed",
208
+ signedOperation: {
209
+ operation,
210
+ signature: signed,
211
+ expirationDate: null,
212
+ },
213
+ });
214
+ } finally {
215
+ close(transport, deviceId);
216
+ }
217
+ }
218
+
219
+ main().then(
220
+ () => o.complete(),
221
+ (e) => o.error(e)
222
+ );
223
+ });
224
224
 
225
225
  export default signOperation;