@ledgerhq/live-common 21.22.1 → 21.23.0
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/account/formatters.d.ts.map +1 -1
- package/lib/account/formatters.js +1 -0
- package/lib/account/formatters.js.map +1 -1
- package/lib/account/support.d.ts.map +1 -1
- package/lib/account/support.js +1 -0
- package/lib/account/support.js.map +1 -1
- package/lib/data/icons/react/sol.js +4 -2
- package/lib/data/icons/react/sol.js.map +1 -1
- package/lib/data/icons/reactNative/sol.js +4 -2
- package/lib/data/icons/reactNative/sol.js.map +1 -1
- package/lib/derivation.d.ts.map +1 -1
- package/lib/derivation.js +0 -3
- package/lib/derivation.js.map +1 -1
- package/lib/env.d.ts +5 -10
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +0 -5
- package/lib/env.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/families/algorand/account.d.ts.map +1 -1
- package/lib/families/algorand/account.js +0 -4
- package/lib/families/algorand/account.js.map +1 -1
- package/lib/families/algorand/api/algodv2.d.ts +5 -0
- package/lib/families/algorand/api/algodv2.d.ts.map +1 -0
- package/lib/families/algorand/api/algodv2.js +118 -0
- package/lib/families/algorand/api/algodv2.js.map +1 -0
- package/lib/families/algorand/api/algodv2.types.d.ts +24 -0
- package/lib/families/algorand/api/algodv2.types.d.ts.map +1 -0
- package/lib/families/algorand/api/algodv2.types.js +3 -0
- package/lib/families/algorand/api/algodv2.types.js.map +1 -0
- package/lib/families/algorand/api/index.d.ts +5 -0
- package/lib/families/algorand/api/index.d.ts.map +1 -0
- package/lib/families/algorand/api/index.js +17 -0
- package/lib/families/algorand/api/index.js.map +1 -0
- package/lib/families/algorand/api/indexer.d.ts +3 -0
- package/lib/families/algorand/api/indexer.d.ts.map +1 -0
- package/lib/families/algorand/api/indexer.js +134 -0
- package/lib/families/algorand/api/indexer.js.map +1 -0
- package/lib/families/algorand/api/indexer.types.d.ts +35 -0
- package/lib/families/algorand/api/indexer.types.d.ts.map +1 -0
- package/lib/families/algorand/api/indexer.types.js +10 -0
- package/lib/families/algorand/api/indexer.types.js.map +1 -0
- package/lib/families/algorand/bridge/js.d.ts +8 -0
- package/lib/families/algorand/bridge/js.d.ts.map +1 -0
- package/lib/families/algorand/bridge/js.js +85 -0
- package/lib/families/algorand/bridge/js.js.map +1 -0
- package/lib/families/algorand/bridge/libcore.d.ts +3 -3
- package/lib/families/algorand/bridge/libcore.d.ts.map +1 -1
- package/lib/families/algorand/bridge/libcore.js.map +1 -1
- package/lib/families/algorand/bridge/mock.d.ts +2 -2
- package/lib/families/algorand/bridge/mock.d.ts.map +1 -1
- package/lib/families/algorand/bridge/mock.js.map +1 -1
- package/lib/families/algorand/buildTransaction.d.ts +8 -0
- package/lib/families/algorand/buildTransaction.d.ts.map +1 -0
- package/lib/families/algorand/buildTransaction.js +101 -0
- package/lib/families/algorand/buildTransaction.js.map +1 -0
- package/lib/families/algorand/cli-transaction.js +1 -1
- package/lib/families/algorand/cli-transaction.js.map +1 -1
- package/lib/families/algorand/deviceTransactionConfig.d.ts +2 -2
- package/lib/families/algorand/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/families/algorand/deviceTransactionConfig.js +0 -13
- package/lib/families/algorand/deviceTransactionConfig.js.map +1 -1
- package/lib/families/algorand/hw-getAddress.d.ts.map +1 -1
- package/lib/families/algorand/hw-getAddress.js +2 -24
- package/lib/families/algorand/hw-getAddress.js.map +1 -1
- package/lib/families/algorand/js-broadcast.d.ts +9 -0
- package/lib/families/algorand/js-broadcast.d.ts.map +1 -0
- package/lib/families/algorand/js-broadcast.js +63 -0
- package/lib/families/algorand/js-broadcast.js.map +1 -0
- package/lib/families/algorand/js-estimateMaxSpendable.d.ts +9 -0
- package/lib/families/algorand/js-estimateMaxSpendable.d.ts.map +1 -0
- package/lib/families/algorand/js-estimateMaxSpendable.js +89 -0
- package/lib/families/algorand/js-estimateMaxSpendable.js.map +1 -0
- package/lib/families/algorand/js-getFeesForTransaction.d.ts +5 -0
- package/lib/families/algorand/js-getFeesForTransaction.d.ts.map +1 -0
- package/lib/families/algorand/js-getFeesForTransaction.js +69 -0
- package/lib/families/algorand/js-getFeesForTransaction.js.map +1 -0
- package/lib/families/algorand/js-getTransactionStatus.d.ts +11 -0
- package/lib/families/algorand/js-getTransactionStatus.d.ts.map +1 -0
- package/lib/families/algorand/js-getTransactionStatus.js +201 -0
- package/lib/families/algorand/js-getTransactionStatus.js.map +1 -0
- package/lib/families/algorand/js-prepareTransaction.d.ts +5 -0
- package/lib/families/algorand/js-prepareTransaction.d.ts.map +1 -0
- package/lib/families/algorand/js-prepareTransaction.js +101 -0
- package/lib/families/algorand/js-prepareTransaction.js.map +1 -0
- package/lib/families/algorand/js-signOperation.d.ts +10 -0
- package/lib/families/algorand/js-signOperation.d.ts.map +1 -0
- package/lib/families/algorand/js-signOperation.js +164 -0
- package/lib/families/algorand/js-signOperation.js.map +1 -0
- package/lib/families/algorand/js-synchronization.d.ts +10 -0
- package/lib/families/algorand/js-synchronization.d.ts.map +1 -0
- package/lib/families/algorand/js-synchronization.js +411 -0
- package/lib/families/algorand/js-synchronization.js.map +1 -0
- package/lib/families/algorand/libcore-buildTransaction.d.ts +2 -2
- package/lib/families/algorand/libcore-buildTransaction.d.ts.map +1 -1
- package/lib/families/algorand/libcore-getFeesForTransaction.d.ts +4 -4
- package/lib/families/algorand/libcore-getFeesForTransaction.d.ts.map +1 -1
- package/lib/families/algorand/libcore-getFeesForTransaction.js +2 -2
- package/lib/families/algorand/libcore-getFeesForTransaction.js.map +1 -1
- package/lib/families/algorand/libcore-postBuildAccount.d.ts.map +1 -1
- package/lib/families/algorand/libcore-postBuildAccount.js +5 -11
- package/lib/families/algorand/libcore-postBuildAccount.js.map +1 -1
- package/lib/families/algorand/libcore-signOperation.d.ts +2 -2
- package/lib/families/algorand/libcore-signOperation.d.ts.map +1 -1
- package/lib/families/algorand/libcore-signOperation.js.map +1 -1
- package/lib/families/algorand/logic.d.ts +10 -0
- package/lib/families/algorand/logic.d.ts.map +1 -1
- package/lib/families/algorand/logic.js +79 -1
- package/lib/families/algorand/logic.js.map +1 -1
- package/lib/families/algorand/mock.d.ts.map +1 -1
- package/lib/families/algorand/mock.js +4 -11
- package/lib/families/algorand/mock.js.map +1 -1
- package/lib/families/algorand/serialization.js +4 -4
- package/lib/families/algorand/serialization.js.map +1 -1
- package/lib/families/algorand/specs.d.ts +2 -2
- package/lib/families/algorand/specs.d.ts.map +1 -1
- package/lib/families/algorand/specs.js +8 -16
- package/lib/families/algorand/specs.js.map +1 -1
- package/lib/families/algorand/speculos-deviceActions.d.ts +2 -2
- package/lib/families/algorand/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/algorand/speculos-deviceActions.js +4 -0
- package/lib/families/algorand/speculos-deviceActions.js.map +1 -1
- package/lib/families/algorand/test-dataset.d.ts +2 -2
- package/lib/families/algorand/test-dataset.d.ts.map +1 -1
- package/lib/families/algorand/test-dataset.js +1 -2
- package/lib/families/algorand/test-dataset.js.map +1 -1
- package/lib/families/algorand/tokens.d.ts.map +1 -1
- package/lib/families/algorand/tokens.js.map +1 -1
- package/lib/families/algorand/transaction.d.ts +5 -5
- package/lib/families/algorand/transaction.d.ts.map +1 -1
- package/lib/families/algorand/transaction.js.map +1 -1
- package/lib/families/algorand/types.d.ts +7 -5
- package/lib/families/algorand/types.d.ts.map +1 -1
- package/lib/families/algorand/types.js.map +1 -1
- package/lib/families/bitcoin/js-prepareTransaction.d.ts.map +1 -1
- package/lib/families/bitcoin/js-prepareTransaction.js +3 -2
- package/lib/families/bitcoin/js-prepareTransaction.js.map +1 -1
- package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
- package/lib/families/bitcoin/js-synchronisation.js +3 -2
- package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/decred.js +3 -4
- package/lib/families/bitcoin/wallet-btc/crypto/decred.js.map +1 -1
- package/lib/generated/bridge/js.d.ts +4 -0
- package/lib/generated/bridge/js.d.ts.map +1 -1
- package/lib/generated/bridge/js.js +26 -24
- package/lib/generated/bridge/js.js.map +1 -1
- package/lib/generated/bridge/libcore.d.ts +1 -1
- package/lib/generated/bridge/mock.d.ts +1 -1
- package/lib/generated/specs.d.ts +1 -1
- package/lib/generated/speculos-deviceActions.d.ts +1 -1
- package/lib/generated/test-dataset.d.ts +1 -1
- package/lib/generated/transaction.d.ts +3 -3
- package/lib/libcore/buildAccount/index.d.ts.map +1 -1
- package/lib/libcore/buildAccount/index.js +0 -1
- package/lib/libcore/buildAccount/index.js.map +1 -1
- package/lib/mock/account.js +21 -21
- package/lib/mock/account.js.map +1 -1
- package/lib/types/operation.d.ts +1 -1
- package/lib/types/operation.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/__tests__/__snapshots__/all.libcore.ts.snap +0 -107
- package/src/account/formatters.ts +1 -0
- package/src/account/support.ts +1 -0
- package/src/data/icons/react/sol.tsx +1 -1
- package/src/data/icons/reactNative/sol.tsx +1 -1
- package/src/data/icons/svg/SOL.svg +1 -3
- package/src/derivation.ts +0 -2
- package/src/env.ts +0 -5
- package/src/families/algorand/account.ts +0 -9
- package/src/families/algorand/api/algodv2.ts +68 -0
- package/src/families/algorand/api/algodv2.types.ts +27 -0
- package/src/families/algorand/api/index.ts +4 -0
- package/src/families/algorand/api/indexer.ts +99 -0
- package/src/families/algorand/api/indexer.types.ts +41 -0
- package/src/families/algorand/bridge/js.ts +46 -0
- package/src/families/algorand/bridge/libcore.ts +4 -4
- package/src/families/algorand/bridge/mock.ts +3 -3
- package/src/families/algorand/buildTransaction.ts +100 -0
- package/src/families/algorand/cli-transaction.ts +1 -1
- package/src/families/algorand/deviceTransactionConfig.ts +2 -16
- package/src/families/algorand/hw-getAddress.ts +1 -10
- package/src/families/algorand/js-broadcast.ts +17 -0
- package/src/families/algorand/js-estimateMaxSpendable.ts +51 -0
- package/src/families/algorand/js-getFeesForTransaction.ts +25 -0
- package/src/families/algorand/js-getTransactionStatus.ts +178 -0
- package/src/families/algorand/js-prepareTransaction.ts +42 -0
- package/src/families/algorand/js-signOperation.ts +145 -0
- package/src/families/algorand/js-synchronization.ts +433 -0
- package/src/families/algorand/libcore-buildTransaction.ts +2 -2
- package/src/families/algorand/libcore-getFeesForTransaction.ts +4 -4
- package/src/families/algorand/libcore-postBuildAccount.ts +2 -7
- package/src/families/algorand/libcore-signOperation.ts +2 -2
- package/src/families/algorand/logic.ts +47 -0
- package/src/families/algorand/mock.ts +2 -12
- package/src/families/algorand/serialization.ts +4 -4
- package/src/families/algorand/specs.ts +16 -22
- package/src/families/algorand/speculos-deviceActions.ts +87 -82
- package/src/families/algorand/test-dataset.ts +5 -6
- package/src/families/algorand/tokens.ts +1 -0
- package/src/families/algorand/transaction.ts +13 -4
- package/src/families/algorand/types.ts +10 -5
- package/src/families/bitcoin/js-prepareTransaction.ts +3 -2
- package/src/families/bitcoin/js-synchronisation.ts +3 -2
- package/src/families/bitcoin/wallet-btc/crypto/decred.ts +3 -4
- package/src/generated/bridge/js.ts +3 -0
- package/src/libcore/buildAccount/index.ts +1 -2
- package/src/mock/account.ts +27 -27
- package/src/types/operation.ts +9 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import expect from "expect";
|
|
2
2
|
import invariant from "invariant";
|
|
3
|
-
import type {
|
|
3
|
+
import type { AlgorandTransaction } from "./types";
|
|
4
4
|
import { getCryptoCurrencyById, parseCurrencyUnit } from "../../currencies";
|
|
5
5
|
import { isAccountEmpty } from "../../account";
|
|
6
6
|
import { pickSiblings } from "../../bot/specs";
|
|
@@ -12,18 +12,9 @@ import { listTokensForCryptoCurrency } from "../../currencies";
|
|
|
12
12
|
import { extractTokenId } from "./tokens";
|
|
13
13
|
import { DeviceModelId } from "@ledgerhq/devices";
|
|
14
14
|
const currency = getCryptoCurrencyById("algorand");
|
|
15
|
-
// Minimum fees
|
|
16
|
-
const minFees = parseCurrencyUnit(currency.units[0], "0.001");
|
|
17
15
|
// Minimum balance required for a new non-ASA account
|
|
18
16
|
const minBalanceNewAccount = parseCurrencyUnit(currency.units[0], "0.1");
|
|
19
17
|
|
|
20
|
-
// Spendable balance for a non-ASA account
|
|
21
|
-
const getSpendableBalance = (maxSpendable) => {
|
|
22
|
-
maxSpendable = maxSpendable.minus(minFees);
|
|
23
|
-
invariant(maxSpendable.gt(0), "Spendable balance is too low");
|
|
24
|
-
return maxSpendable;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
18
|
// Ensure that, when the recipient corresponds to an empty account,
|
|
28
19
|
// the amount to send is greater or equal to the required minimum
|
|
29
20
|
// balance for such a recipient
|
|
@@ -74,7 +65,7 @@ const getRandomAssetId = (account) => {
|
|
|
74
65
|
return sample(diff);
|
|
75
66
|
};
|
|
76
67
|
|
|
77
|
-
const algorand: AppSpec<
|
|
68
|
+
const algorand: AppSpec<AlgorandTransaction> = {
|
|
78
69
|
name: "Algorand",
|
|
79
70
|
currency,
|
|
80
71
|
appQuery: {
|
|
@@ -86,11 +77,11 @@ const algorand: AppSpec<Transaction> = {
|
|
|
86
77
|
name: "move ~50%",
|
|
87
78
|
maxRun: 2,
|
|
88
79
|
transaction: ({ account, siblings, bridge, maxSpendable }) => {
|
|
89
|
-
|
|
80
|
+
invariant(maxSpendable.gt(0), "Spendable balance is too low");
|
|
90
81
|
const sibling = pickSiblings(siblings, 4);
|
|
91
82
|
const recipient = sibling.freshAddress;
|
|
92
83
|
const transaction = bridge.createTransaction(account);
|
|
93
|
-
const amount =
|
|
84
|
+
const amount = maxSpendable
|
|
94
85
|
.div(1.9 + 0.2 * Math.random())
|
|
95
86
|
.integerValue();
|
|
96
87
|
checkSendableToEmptyAccount(amount, sibling);
|
|
@@ -119,10 +110,10 @@ const algorand: AppSpec<Transaction> = {
|
|
|
119
110
|
name: "send max",
|
|
120
111
|
maxRun: 1,
|
|
121
112
|
transaction: ({ account, siblings, bridge, maxSpendable }) => {
|
|
122
|
-
|
|
113
|
+
invariant(maxSpendable.gt(0), "Spendable balance is too low");
|
|
123
114
|
const sibling = pickSiblings(siblings, 4);
|
|
124
115
|
// Send the full spendable balance
|
|
125
|
-
const amount =
|
|
116
|
+
const amount = maxSpendable;
|
|
126
117
|
checkSendableToEmptyAccount(amount, sibling);
|
|
127
118
|
return {
|
|
128
119
|
transaction: bridge.createTransaction(account),
|
|
@@ -147,7 +138,7 @@ const algorand: AppSpec<Transaction> = {
|
|
|
147
138
|
name: "send ASA ~50%",
|
|
148
139
|
maxRun: 2,
|
|
149
140
|
transaction: ({ account, siblings, bridge, maxSpendable }) => {
|
|
150
|
-
invariant(maxSpendable.gt(
|
|
141
|
+
invariant(maxSpendable.gt(0), "Spendable balance is too low");
|
|
151
142
|
const subAccount = sample(getAssetsWithBalance(account));
|
|
152
143
|
invariant(
|
|
153
144
|
subAccount && subAccount.type === "TokenAccount",
|
|
@@ -161,7 +152,7 @@ const algorand: AppSpec<Transaction> = {
|
|
|
161
152
|
const amount = subAccount.balance
|
|
162
153
|
.div(1.9 + 0.2 * Math.random())
|
|
163
154
|
.integerValue();
|
|
164
|
-
const updates: Array<Partial<
|
|
155
|
+
const updates: Array<Partial<AlgorandTransaction>> = [
|
|
165
156
|
{
|
|
166
157
|
mode,
|
|
167
158
|
subAccountId: subAccount.id,
|
|
@@ -196,10 +187,13 @@ const algorand: AppSpec<Transaction> = {
|
|
|
196
187
|
name: "opt-In ASA available",
|
|
197
188
|
maxRun: 1,
|
|
198
189
|
transaction: ({ account, bridge, maxSpendable }) => {
|
|
199
|
-
// maxSpendable is expected to be greater than 100,000 micro-Algos
|
|
190
|
+
// maxSpendable is expected to be greater than 100,000 micro-Algos
|
|
200
191
|
// corresponding to the requirement that the main account will have
|
|
201
192
|
// one more ASA after the opt-in; its minimum balance is updated accordingly
|
|
202
|
-
invariant(
|
|
193
|
+
invariant(
|
|
194
|
+
maxSpendable.gt(new BigNumber(100000)),
|
|
195
|
+
"Spendable balance is too low"
|
|
196
|
+
);
|
|
203
197
|
const transaction = bridge.createTransaction(account);
|
|
204
198
|
const mode = "optIn";
|
|
205
199
|
const assetId = getRandomAssetId(account);
|
|
@@ -207,7 +201,7 @@ const algorand: AppSpec<Transaction> = {
|
|
|
207
201
|
? account.subAccounts.find((a) => a.id.includes(assetId as string))
|
|
208
202
|
: null;
|
|
209
203
|
invariant(!subAccount, "already opt-in");
|
|
210
|
-
const updates: Array<Partial<
|
|
204
|
+
const updates: Array<Partial<AlgorandTransaction>> = [
|
|
211
205
|
{
|
|
212
206
|
mode,
|
|
213
207
|
},
|
|
@@ -241,10 +235,10 @@ const algorand: AppSpec<Transaction> = {
|
|
|
241
235
|
invariant(rewards && rewards.gt(0), "No pending rewards");
|
|
242
236
|
// Ensure that the rewards can effectively be claimed
|
|
243
237
|
// (fees have to be paid in order to claim the rewards)
|
|
244
|
-
invariant(maxSpendable.gt(
|
|
238
|
+
invariant(maxSpendable.gt(0), "Spendable balance is too low");
|
|
245
239
|
const transaction = bridge.createTransaction(account);
|
|
246
240
|
const mode = "claimReward";
|
|
247
|
-
const updates: Array<Partial<
|
|
241
|
+
const updates: Array<Partial<AlgorandTransaction>> = [
|
|
248
242
|
{
|
|
249
243
|
mode,
|
|
250
244
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DeviceAction } from "../../bot/types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { AlgorandTransaction } from "./types";
|
|
3
3
|
import { formatCurrencyUnit, findTokenById } from "../../currencies";
|
|
4
4
|
import { deviceActionFlow } from "../../bot/specs";
|
|
5
5
|
import { extractTokenId, addPrefixToken } from "./tokens";
|
|
@@ -11,88 +11,93 @@ const expectedAmount = ({ account, status }) =>
|
|
|
11
11
|
disableRounding: true,
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
const acceptTransaction: DeviceAction<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
title: "Asset xfer",
|
|
24
|
-
button: "Rr",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
title: "Payment",
|
|
28
|
-
button: "Rr",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
title: "Fee",
|
|
32
|
-
button: "Rr",
|
|
33
|
-
expectedValue: ({ account, status }) =>
|
|
34
|
-
formatCurrencyUnit(account.unit, status.estimatedFees, {
|
|
35
|
-
disableRounding: true,
|
|
36
|
-
}),
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
title: "Asset ID",
|
|
40
|
-
button: "Rr",
|
|
41
|
-
expectedValue: ({ transaction }) => {
|
|
42
|
-
const id = transaction.assetId
|
|
43
|
-
? extractTokenId(transaction.assetId)
|
|
44
|
-
: transaction.subAccountId
|
|
45
|
-
? extractTokenId(transaction.subAccountId)
|
|
46
|
-
: "";
|
|
47
|
-
const token = findTokenById(addPrefixToken(id));
|
|
48
|
-
return token ? displayTokenValue(token) : `#${id}`;
|
|
14
|
+
const acceptTransaction: DeviceAction<AlgorandTransaction, any> =
|
|
15
|
+
deviceActionFlow({
|
|
16
|
+
steps: [
|
|
17
|
+
{
|
|
18
|
+
title: "Txn Type",
|
|
19
|
+
button: "Rr",
|
|
20
|
+
expectedValue: ({ transaction }) =>
|
|
21
|
+
transaction.subAccountId ? "Asset xfer" : "Payment",
|
|
49
22
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
23
|
+
{
|
|
24
|
+
title: "Asset xfer",
|
|
25
|
+
button: "Rr",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
title: "Payment",
|
|
29
|
+
button: "Rr",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: "Fee",
|
|
33
|
+
button: "Rr",
|
|
34
|
+
expectedValue: ({ account, status }) =>
|
|
35
|
+
formatCurrencyUnit(account.unit, status.estimatedFees, {
|
|
36
|
+
disableRounding: true,
|
|
37
|
+
}),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: "Asset ID",
|
|
41
|
+
button: "Rr",
|
|
42
|
+
expectedValue: ({ transaction }) => {
|
|
43
|
+
const id = transaction.assetId
|
|
44
|
+
? extractTokenId(transaction.assetId)
|
|
45
|
+
: transaction.subAccountId
|
|
46
|
+
? extractTokenId(transaction.subAccountId)
|
|
47
|
+
: "";
|
|
48
|
+
const token = findTokenById(addPrefixToken(id));
|
|
49
|
+
return token ? displayTokenValue(token) : `#${id}`;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
title: "Asset amt",
|
|
54
|
+
button: "Rr",
|
|
55
|
+
expectedValue: ({ transaction, status }) =>
|
|
56
|
+
transaction.mode === "optIn" ? "0" : status.amount.toString(),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
title: "Sender",
|
|
60
|
+
button: "Rr",
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
title: "Receiver",
|
|
64
|
+
button: "Rr",
|
|
65
|
+
expectedValue: ({ transaction }) => transaction.recipient,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
title: "Asset dst",
|
|
69
|
+
button: "Rr",
|
|
70
|
+
expectedValue: ({ transaction }) => transaction.recipient,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
title: "Amount",
|
|
74
|
+
button: "Rr",
|
|
75
|
+
expectedValue: ({ account, status, transaction }) =>
|
|
76
|
+
transaction.mode === "claimReward"
|
|
77
|
+
? "0"
|
|
78
|
+
: expectedAmount({
|
|
79
|
+
account,
|
|
80
|
+
status,
|
|
81
|
+
}),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
title: "Sign",
|
|
85
|
+
button: "LRlr",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
title: "Review",
|
|
89
|
+
button: "Rr",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
title: "Genesis ID",
|
|
93
|
+
button: "Rr",
|
|
94
|
+
}, // Only on testnet
|
|
95
|
+
{
|
|
96
|
+
title: "Genesis hash",
|
|
97
|
+
button: "Rr",
|
|
98
|
+
}, // Only on testnet
|
|
99
|
+
],
|
|
100
|
+
});
|
|
96
101
|
export default {
|
|
97
102
|
acceptTransaction,
|
|
98
103
|
};
|
|
@@ -6,19 +6,18 @@ import {
|
|
|
6
6
|
NotEnoughBalanceBecauseDestinationNotCreated,
|
|
7
7
|
} from "@ledgerhq/errors";
|
|
8
8
|
import { AlgorandASANotOptInInRecipient } from "../../errors";
|
|
9
|
-
import type {
|
|
9
|
+
import type { AlgorandTransaction } from "./types";
|
|
10
10
|
// const notCreatedAlgorandAddress =
|
|
11
11
|
// "ZBILW5BPM7AQU54YQZICSGS4J7KJ2XV6OC3DFUQ7BB4DVLYKKUEVWDDBGM";
|
|
12
|
-
const dataset: DatasetTest<
|
|
12
|
+
const dataset: DatasetTest<AlgorandTransaction> = {
|
|
13
13
|
implementations: ["libcore"],
|
|
14
14
|
// test disabled. FIXME ctx LL-5485
|
|
15
15
|
currencies: {} || {
|
|
16
16
|
algorand: {
|
|
17
17
|
FIXME_ignoreAccountFields: [
|
|
18
|
-
"algorandResources.rewards", // We cant keep track of this since it's always
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"spendableBalance", // same since the rewards are included here
|
|
18
|
+
"algorandResources.rewards", // We cant keep track of this since it's always moving
|
|
19
|
+
"balance", // Rewards are included, same as above
|
|
20
|
+
"spendableBalance", // Same since the rewards are included here too
|
|
22
21
|
],
|
|
23
22
|
scanAccounts: [
|
|
24
23
|
{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { AlgorandTransaction, AlgorandTransactionRaw } from "./types";
|
|
3
3
|
import {
|
|
4
4
|
fromTransactionCommonRaw,
|
|
5
5
|
toTransactionCommonRaw,
|
|
@@ -8,7 +8,14 @@ import type { Account } from "../../types";
|
|
|
8
8
|
import { getAccountUnit } from "../../account";
|
|
9
9
|
import { formatCurrencyUnit } from "../../currencies";
|
|
10
10
|
export const formatTransaction = (
|
|
11
|
-
{
|
|
11
|
+
{
|
|
12
|
+
mode,
|
|
13
|
+
subAccountId,
|
|
14
|
+
amount,
|
|
15
|
+
recipient,
|
|
16
|
+
fees,
|
|
17
|
+
useAllAmount,
|
|
18
|
+
}: AlgorandTransaction,
|
|
12
19
|
mainAccount: Account
|
|
13
20
|
): string => {
|
|
14
21
|
const account =
|
|
@@ -41,7 +48,9 @@ export const formatTransaction = (
|
|
|
41
48
|
}`;
|
|
42
49
|
};
|
|
43
50
|
|
|
44
|
-
const fromTransactionRaw = (
|
|
51
|
+
const fromTransactionRaw = (
|
|
52
|
+
tr: AlgorandTransactionRaw
|
|
53
|
+
): AlgorandTransaction => {
|
|
45
54
|
const common = fromTransactionCommonRaw(tr);
|
|
46
55
|
return {
|
|
47
56
|
...common,
|
|
@@ -53,7 +62,7 @@ const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
|
|
|
53
62
|
};
|
|
54
63
|
};
|
|
55
64
|
|
|
56
|
-
const toTransactionRaw = (t:
|
|
65
|
+
const toTransactionRaw = (t: AlgorandTransaction): AlgorandTransactionRaw => {
|
|
57
66
|
const common = toTransactionCommonRaw(t);
|
|
58
67
|
return {
|
|
59
68
|
...common,
|
|
@@ -95,34 +95,39 @@ declare class CoreAlgorandOperation {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
export type CoreCurrencySpecifics = Record<string, never>;
|
|
98
|
+
|
|
98
99
|
export type AlgorandResources = {
|
|
99
100
|
rewards: BigNumber;
|
|
100
|
-
|
|
101
|
+
// Ledger Live only supports a limited list of ASA (defined here https://github.com/LedgerHQ/ledgerjs/blob/master/packages/cryptoassets/data/asa.js)
|
|
102
|
+
// This is the actual number of ASA opted-in for the Algo account
|
|
103
|
+
nbAssets: number;
|
|
101
104
|
};
|
|
102
105
|
export type AlgorandResourcesRaw = {
|
|
103
106
|
rewards: string;
|
|
104
|
-
|
|
107
|
+
nbAssets: number;
|
|
105
108
|
};
|
|
106
|
-
export type AlgorandOperationMode = "send" | "optIn" | "claimReward"
|
|
109
|
+
export type AlgorandOperationMode = "send" | "optIn" | "claimReward";
|
|
107
110
|
export type {
|
|
108
111
|
CoreAlgorandOperation,
|
|
109
112
|
CoreAlgorandAccount,
|
|
110
113
|
CoreAlgorandTransaction,
|
|
111
114
|
};
|
|
112
|
-
export type
|
|
115
|
+
export type AlgorandTransaction = TransactionCommon & {
|
|
113
116
|
family: "algorand";
|
|
114
117
|
mode: AlgorandOperationMode;
|
|
115
118
|
fees: BigNumber | null | undefined;
|
|
116
119
|
assetId: string | null | undefined;
|
|
117
120
|
memo: string | null | undefined;
|
|
118
121
|
};
|
|
119
|
-
export type
|
|
122
|
+
export type AlgorandTransactionRaw = TransactionCommonRaw & {
|
|
120
123
|
family: "algorand";
|
|
121
124
|
mode: AlgorandOperationMode;
|
|
122
125
|
fees: string | null | undefined;
|
|
123
126
|
assetId: string | null | undefined;
|
|
124
127
|
memo: string | null | undefined;
|
|
125
128
|
};
|
|
129
|
+
export type Transaction = AlgorandTransaction;
|
|
130
|
+
export type TransactionRaw = AlgorandTransactionRaw;
|
|
126
131
|
export type AlgorandOperation = Operation & {
|
|
127
132
|
extra: AlgorandExtraTxInfo;
|
|
128
133
|
};
|
|
@@ -18,8 +18,9 @@ const prepareTransaction = async (
|
|
|
18
18
|
const feePerByte = inferFeePerByte(t, networkInfo);
|
|
19
19
|
|
|
20
20
|
if (
|
|
21
|
-
t.networkInfo === networkInfo &&
|
|
22
|
-
|
|
21
|
+
(t.networkInfo === networkInfo &&
|
|
22
|
+
(feePerByte === t.feePerByte || feePerByte.eq(t.feePerByte || 0))) ||
|
|
23
|
+
t.feesStrategy === "custom"
|
|
23
24
|
) {
|
|
24
25
|
// nothing changed
|
|
25
26
|
return t;
|
|
@@ -140,8 +140,9 @@ const mapTxToOperations = (
|
|
|
140
140
|
if (!accountAddresses.includes(output.address)) {
|
|
141
141
|
// The output doesn't belong to this account
|
|
142
142
|
if (
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
accountInputs.length > 0 && // It's a SEND operation
|
|
144
|
+
(tx.outputs.length === 1 || // The transaction has only 1 output
|
|
145
|
+
output.output_index < changeOutputIndex) // The output isn't the change output
|
|
145
146
|
) {
|
|
146
147
|
recipients.push(
|
|
147
148
|
syncReplaceAddress
|
|
@@ -60,12 +60,11 @@ class BIP32 {
|
|
|
60
60
|
hmacSHA512(key, data) {
|
|
61
61
|
return createHmac("sha512", key).update(data).digest();
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return createHash("rmd160").update(sha256Hash).digest();
|
|
63
|
+
hashSHA256(buffer) {
|
|
64
|
+
return createHash("sha256").update(buffer).digest();
|
|
66
65
|
}
|
|
67
66
|
fingerprint() {
|
|
68
|
-
return this.
|
|
67
|
+
return this.hashSHA256(this.pk()).slice(0, 4);
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
toBase58() {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import algorand from "../../families/algorand/bridge/js";
|
|
2
|
+
|
|
1
3
|
import bitcoin from "../../families/bitcoin/bridge/js";
|
|
2
4
|
|
|
3
5
|
import crypto_org from "../../families/crypto_org/bridge/js";
|
|
@@ -24,6 +26,7 @@ import tron from "../../families/tron/bridge/js";
|
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
export default {
|
|
29
|
+
algorand,
|
|
27
30
|
bitcoin,
|
|
28
31
|
crypto_org,
|
|
29
32
|
elrond,
|
|
@@ -228,8 +228,7 @@ export async function buildAccount({
|
|
|
228
228
|
used: false,
|
|
229
229
|
balance,
|
|
230
230
|
balanceHistory,
|
|
231
|
-
spendableBalance: balance,
|
|
232
|
-
// FIXME need libcore concept
|
|
231
|
+
spendableBalance: balance, // FIXME need libcore concept
|
|
233
232
|
blockHeight,
|
|
234
233
|
currency,
|
|
235
234
|
unit: currency.units[0],
|
package/src/mock/account.ts
CHANGED
|
@@ -396,6 +396,32 @@ export function genAccount(
|
|
|
396
396
|
balanceHistoryCache: emptyHistoryCache,
|
|
397
397
|
};
|
|
398
398
|
|
|
399
|
+
if (
|
|
400
|
+
["ethereum", "ethereum_ropsten", "tron", "algorand"].includes(currency.id)
|
|
401
|
+
) {
|
|
402
|
+
const tokenCount =
|
|
403
|
+
typeof opts.subAccountsCount === "number"
|
|
404
|
+
? opts.subAccountsCount
|
|
405
|
+
: rng.nextInt(0, 8);
|
|
406
|
+
const all = listTokensForCryptoCurrency(account.currency).filter((t) =>
|
|
407
|
+
hardcodedMarketcap.includes(t.id)
|
|
408
|
+
);
|
|
409
|
+
const compoundReadyTokens = all.filter(findCompoundToken);
|
|
410
|
+
const notCompoundReadyTokens = all.filter((a) => !findCompoundToken(a));
|
|
411
|
+
// favorize the generation of compound tokens
|
|
412
|
+
const tokens = compoundReadyTokens
|
|
413
|
+
.concat(
|
|
414
|
+
// from random index
|
|
415
|
+
notCompoundReadyTokens.slice(
|
|
416
|
+
rng.nextInt(Math.floor(notCompoundReadyTokens.length / 2))
|
|
417
|
+
)
|
|
418
|
+
)
|
|
419
|
+
.slice(0, tokenCount);
|
|
420
|
+
account.subAccounts = tokens.map((token, i) =>
|
|
421
|
+
genTokenAccount(i, account, token)
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
|
|
399
425
|
if (currency.id === "cosmos") {
|
|
400
426
|
account.cosmosResources = {
|
|
401
427
|
// TODO variation in these
|
|
@@ -419,7 +445,7 @@ export function genAccount(
|
|
|
419
445
|
if (currency.family === "algorand") {
|
|
420
446
|
account.algorandResources = {
|
|
421
447
|
rewards: new BigNumber(0),
|
|
422
|
-
|
|
448
|
+
nbAssets: account.subAccounts?.length ?? 0,
|
|
423
449
|
};
|
|
424
450
|
}
|
|
425
451
|
|
|
@@ -437,32 +463,6 @@ export function genAccount(
|
|
|
437
463
|
};
|
|
438
464
|
}
|
|
439
465
|
|
|
440
|
-
if (
|
|
441
|
-
["ethereum", "ethereum_ropsten", "tron", "algorand"].includes(currency.id)
|
|
442
|
-
) {
|
|
443
|
-
const tokenCount =
|
|
444
|
-
typeof opts.subAccountsCount === "number"
|
|
445
|
-
? opts.subAccountsCount
|
|
446
|
-
: rng.nextInt(0, 8);
|
|
447
|
-
const all = listTokensForCryptoCurrency(account.currency).filter((t) =>
|
|
448
|
-
hardcodedMarketcap.includes(t.id)
|
|
449
|
-
);
|
|
450
|
-
const compoundReadyTokens = all.filter(findCompoundToken);
|
|
451
|
-
const notCompoundReadyTokens = all.filter((a) => !findCompoundToken(a));
|
|
452
|
-
// favorize the generation of compound tokens
|
|
453
|
-
const tokens = compoundReadyTokens
|
|
454
|
-
.concat(
|
|
455
|
-
// from random index
|
|
456
|
-
notCompoundReadyTokens.slice(
|
|
457
|
-
rng.nextInt(Math.floor(notCompoundReadyTokens.length / 2))
|
|
458
|
-
)
|
|
459
|
-
)
|
|
460
|
-
.slice(0, tokenCount);
|
|
461
|
-
account.subAccounts = tokens.map((token, i) =>
|
|
462
|
-
genTokenAccount(i, account, token)
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
466
|
account.operations = Array(operationsSize)
|
|
467
467
|
.fill(null)
|
|
468
468
|
.reduce((ops: Operation[]) => {
|
package/src/types/operation.ts
CHANGED
|
@@ -7,14 +7,17 @@ export type OperationType =
|
|
|
7
7
|
| "NONE"
|
|
8
8
|
| "CREATE"
|
|
9
9
|
| "REVEAL"
|
|
10
|
+
// COSMOS
|
|
10
11
|
| "DELEGATE"
|
|
11
12
|
| "UNDELEGATE"
|
|
12
13
|
| "REDELEGATE"
|
|
13
14
|
| "REWARD"
|
|
14
|
-
|
|
15
|
+
// TRON
|
|
16
|
+
| "FEES"
|
|
15
17
|
| "FREEZE"
|
|
16
18
|
| "UNFREEZE"
|
|
17
|
-
|
|
19
|
+
// POLKADOT
|
|
20
|
+
| "VOTE"
|
|
18
21
|
| "REWARD_PAYOUT"
|
|
19
22
|
| "BOND"
|
|
20
23
|
| "UNBOND"
|
|
@@ -22,13 +25,15 @@ export type OperationType =
|
|
|
22
25
|
| "SET_CONTROLLER"
|
|
23
26
|
| "SLASH"
|
|
24
27
|
| "NOMINATE"
|
|
25
|
-
| "CHILL"
|
|
28
|
+
| "CHILL"
|
|
29
|
+
// COMPOUND TYPE OPERATIONS
|
|
26
30
|
| "SUPPLY"
|
|
27
31
|
| "REDEEM"
|
|
28
32
|
| "APPROVE"
|
|
33
|
+
// ALGORAND
|
|
29
34
|
| "OPT_IN"
|
|
30
35
|
| "OPT_OUT"
|
|
31
|
-
|
|
36
|
+
// NFT
|
|
32
37
|
| "NFT_IN"
|
|
33
38
|
| "NFT_OUT";
|
|
34
39
|
export type Operation = {
|