@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
@@ -32,7 +32,7 @@ import type {
32
32
  AccountBridge,
33
33
  DeviceId,
34
34
  } from "../../../types/bridge";
35
- import { withDevice } from "../../../hw/deviceAccess";
35
+ import { open, close } from "../../../hw";
36
36
  import signTransaction from "../../../hw/signTransaction";
37
37
  import { makeSync, makeScanAccounts } from "../../../bridge/jsHelpers";
38
38
  import { formatCurrencyUnit } from "../../../currencies";
@@ -99,63 +99,62 @@ const signOperation = ({
99
99
  transaction: Transaction;
100
100
  deviceId: DeviceId;
101
101
  }): Observable<SignOperationEvent> =>
102
- withDevice(deviceId)((transport) =>
103
- Observable.create((o) => {
104
- async function main() {
105
- const subAccount =
106
- transaction.subAccountId && account.subAccounts
107
- ? account.subAccounts.find(
108
- (sa) => sa.id === transaction.subAccountId
109
- )
110
- : null;
111
- const isContractAddressRecipient =
112
- (await fetchTronContract(transaction.recipient)) !== undefined;
113
- const fee = await getEstimatedFees(
114
- account,
115
- transaction,
116
- isContractAddressRecipient
117
- );
118
- const balance = subAccount
119
- ? subAccount.balance
120
- : BigNumber.max(0, account.spendableBalance.minus(fee));
121
- transaction.amount = transaction.useAllAmount
122
- ? balance
123
- : transaction.amount;
124
-
125
- // send trc20 to a new account is forbidden by us (because it will not activate the account)
126
- if (
127
- transaction.recipient &&
128
- transaction.mode === "send" &&
129
- subAccount &&
130
- subAccount.type === "TokenAccount" &&
131
- subAccount.token.tokenType === "trc20" &&
132
- !isContractAddressRecipient && // send trc20 to a smart contract is allowed
133
- (await fetchTronAccount(transaction.recipient)).length === 0
134
- ) {
135
- throw new TronSendTrc20ToNewAccountForbidden();
136
- }
102
+ Observable.create((o) => {
103
+ async function main() {
104
+ const subAccount =
105
+ transaction.subAccountId && account.subAccounts
106
+ ? account.subAccounts.find((sa) => sa.id === transaction.subAccountId)
107
+ : null;
108
+ const isContractAddressRecipient =
109
+ (await fetchTronContract(transaction.recipient)) !== undefined;
110
+ const fee = await getEstimatedFees(
111
+ account,
112
+ transaction,
113
+ isContractAddressRecipient
114
+ );
115
+ const balance = subAccount
116
+ ? subAccount.balance
117
+ : BigNumber.max(0, account.spendableBalance.minus(fee));
118
+ transaction.amount = transaction.useAllAmount
119
+ ? balance
120
+ : transaction.amount;
137
121
 
138
- const getPreparedTransaction = () => {
139
- switch (transaction.mode) {
140
- case "freeze":
141
- return freezeTronTransaction(account, transaction);
122
+ // send trc20 to a new account is forbidden by us (because it will not activate the account)
123
+ if (
124
+ transaction.recipient &&
125
+ transaction.mode === "send" &&
126
+ subAccount &&
127
+ subAccount.type === "TokenAccount" &&
128
+ subAccount.token.tokenType === "trc20" &&
129
+ !isContractAddressRecipient && // send trc20 to a smart contract is allowed
130
+ (await fetchTronAccount(transaction.recipient)).length === 0
131
+ ) {
132
+ throw new TronSendTrc20ToNewAccountForbidden();
133
+ }
142
134
 
143
- case "unfreeze":
144
- return unfreezeTronTransaction(account, transaction);
135
+ const getPreparedTransaction = () => {
136
+ switch (transaction.mode) {
137
+ case "freeze":
138
+ return freezeTronTransaction(account, transaction);
145
139
 
146
- case "vote":
147
- return voteTronSuperRepresentatives(account, transaction);
140
+ case "unfreeze":
141
+ return unfreezeTronTransaction(account, transaction);
148
142
 
149
- case "claimReward":
150
- return claimRewardTronTransaction(account);
143
+ case "vote":
144
+ return voteTronSuperRepresentatives(account, transaction);
151
145
 
152
- default:
153
- return createTronTransaction(account, transaction, subAccount);
154
- }
155
- };
146
+ case "claimReward":
147
+ return claimRewardTronTransaction(account);
148
+
149
+ default:
150
+ return createTronTransaction(account, transaction, subAccount);
151
+ }
152
+ };
156
153
 
157
- const preparedTransaction = await getPreparedTransaction();
154
+ const preparedTransaction = await getPreparedTransaction();
155
+ const transport = await open(deviceId);
158
156
 
157
+ try {
159
158
  o.next({
160
159
  type: "device-signature-requested",
161
160
  });
@@ -275,14 +274,16 @@ const signOperation = ({
275
274
  expirationDate: null,
276
275
  },
277
276
  });
277
+ } finally {
278
+ close(transport, deviceId);
278
279
  }
280
+ }
279
281
 
280
- main().then(
281
- () => o.complete(),
282
- (e) => o.error(e)
283
- );
284
- })
285
- );
282
+ main().then(
283
+ () => o.complete(),
284
+ (e) => o.error(e)
285
+ );
286
+ });
286
287
 
287
288
  const broadcast = async ({
288
289
  signedOperation: { signature, operation, signatureRaw },
package/src/.DS_Store DELETED
Binary file
Binary file