@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.
- package/lib/bridge/jsHelpers.d.ts.map +1 -1
- package/lib/bridge/jsHelpers.js +245 -238
- package/lib/bridge/jsHelpers.js.map +1 -1
- package/lib/families/bitcoin/js-signOperation.d.ts.map +1 -1
- package/lib/families/bitcoin/js-signOperation.js +139 -130
- package/lib/families/bitcoin/js-signOperation.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/storage/index.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/storage/index.js +1 -2
- package/lib/families/bitcoin/wallet-btc/storage/index.js.map +1 -1
- package/lib/families/crypto_org/js-signOperation.d.ts.map +1 -1
- package/lib/families/crypto_org/js-signOperation.js +62 -55
- package/lib/families/crypto_org/js-signOperation.js.map +1 -1
- package/lib/families/elrond/js-signOperation.d.ts.map +1 -1
- package/lib/families/elrond/js-signOperation.js +50 -43
- package/lib/families/elrond/js-signOperation.js.map +1 -1
- package/lib/families/polkadot/js-signOperation.d.ts.map +1 -1
- package/lib/families/polkadot/js-signOperation.js +61 -54
- package/lib/families/polkadot/js-signOperation.js.map +1 -1
- package/lib/families/ripple/bridge/js.d.ts.map +1 -1
- package/lib/families/ripple/bridge/js.js +313 -299
- package/lib/families/ripple/bridge/js.js.map +1 -1
- package/lib/families/stellar/js-signOperation.d.ts.map +1 -1
- package/lib/families/stellar/js-signOperation.js +51 -44
- package/lib/families/stellar/js-signOperation.js.map +1 -1
- package/lib/families/tron/bridge/js.d.ts.map +1 -1
- package/lib/families/tron/bridge/js.js +167 -159
- package/lib/families/tron/bridge/js.js.map +1 -1
- package/package.json +1 -1
- package/src/bridge/jsHelpers.ts +213 -213
- package/src/families/bitcoin/js-signOperation.ts +17 -14
- package/src/families/bitcoin/wallet-btc/storage/index.ts +1 -4
- package/src/families/crypto_org/js-signOperation.ts +16 -12
- package/src/families/elrond/js-signOperation.ts +14 -10
- package/src/families/polkadot/js-signOperation.ts +61 -61
- package/src/families/ripple/bridge/js.ts +260 -257
- package/src/families/stellar/js-signOperation.ts +14 -10
- package/src/families/tron/bridge/js.ts +58 -57
- package/src/.DS_Store +0 -0
- 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 {
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
144
|
-
|
|
135
|
+
const getPreparedTransaction = () => {
|
|
136
|
+
switch (transaction.mode) {
|
|
137
|
+
case "freeze":
|
|
138
|
+
return freezeTronTransaction(account, transaction);
|
|
145
139
|
|
|
146
|
-
|
|
147
|
-
|
|
140
|
+
case "unfreeze":
|
|
141
|
+
return unfreezeTronTransaction(account, transaction);
|
|
148
142
|
|
|
149
|
-
|
|
150
|
-
|
|
143
|
+
case "vote":
|
|
144
|
+
return voteTronSuperRepresentatives(account, transaction);
|
|
151
145
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
146
|
+
case "claimReward":
|
|
147
|
+
return claimRewardTronTransaction(account);
|
|
148
|
+
|
|
149
|
+
default:
|
|
150
|
+
return createTronTransaction(account, transaction, subAccount);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
156
153
|
|
|
157
|
-
|
|
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
|
-
|
|
281
|
-
|
|
282
|
-
|
|
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
|
package/src/data/flags/.DS_Store
DELETED
|
Binary file
|