@ledgerhq/live-common 34.45.0-nightly.2 → 34.45.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/__tests__/test-helpers/bridge.d.ts.map +1 -1
- package/lib/__tests__/test-helpers/bridge.js +1 -3
- package/lib/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib/bridge/generic-alpaca/accountBridge.d.ts +1 -1
- package/lib/bridge/generic-alpaca/accountBridge.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/accountBridge.js.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.d.ts +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.js +2 -4
- package/lib/bridge/generic-alpaca/alpaca/index.js.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +4 -4
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +10 -10
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib/bridge/generic-alpaca/broadcast.d.ts +1 -1
- package/lib/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/broadcast.js.map +1 -1
- package/lib/bridge/generic-alpaca/createTransaction.d.ts +9 -17
- package/lib/bridge/generic-alpaca/createTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/createTransaction.js +10 -36
- package/lib/bridge/generic-alpaca/createTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/currencyBridge.d.ts +1 -1
- package/lib/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/currencyBridge.js.map +1 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts +1 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.js +0 -9
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.js +37 -66
- package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js +15 -27
- package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts +1 -5
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.js +5 -28
- package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.d.ts +1 -1
- package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js +13 -64
- package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib/bridge/generic-alpaca/signer/index.d.ts +1 -1
- package/lib/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signer/index.js +5 -38
- package/lib/bridge/generic-alpaca/signer/index.js.map +1 -1
- package/lib/bridge/generic-alpaca/signer/signTransaction.d.ts +0 -2
- package/lib/bridge/generic-alpaca/signer/signTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signer/signTransaction.js +1 -8
- package/lib/bridge/generic-alpaca/signer/signTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/signer/types.d.ts +0 -3
- package/lib/bridge/generic-alpaca/signer/types.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js +46 -70
- package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js +1 -1
- package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/tests/signOperation.test.js +22 -25
- package/lib/bridge/generic-alpaca/tests/signOperation.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/utils.d.ts +1 -36
- package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.js +14 -130
- package/lib/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib/bridge/generic-alpaca/utils.test.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/{tests/utils.test.js → utils.test.js} +1 -1
- package/lib/bridge/generic-alpaca/utils.test.js.map +1 -0
- package/lib/bridge/impl.d.ts.map +1 -1
- package/lib/bridge/impl.js +4 -5
- package/lib/bridge/impl.js.map +1 -1
- package/lib/e2e/enum/Account.js +4 -4
- package/lib/e2e/enum/Account.js.map +1 -1
- package/lib/e2e/enum/AppInfos.d.ts +1 -1
- package/lib/e2e/enum/AppInfos.d.ts.map +1 -1
- package/lib/e2e/enum/AppInfos.js +1 -1
- package/lib/e2e/enum/AppInfos.js.map +1 -1
- package/lib/e2e/enum/Currency.d.ts.map +1 -1
- package/lib/e2e/enum/Currency.js +3 -3
- package/lib/e2e/enum/Currency.js.map +1 -1
- package/lib/e2e/speculos.js +2 -2
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/exchange/index.d.ts.map +1 -1
- package/lib/exchange/index.js +0 -1
- package/lib/exchange/index.js.map +1 -1
- package/lib/families/canton/bridge.integration.test.d.ts +2 -0
- package/lib/families/canton/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/canton/bridge.integration.test.js +7 -0
- package/lib/families/canton/bridge.integration.test.js.map +1 -0
- package/lib/families/stellar/bridge/logic.d.ts +1 -1
- package/lib/families/stellar/bridge/logic.d.ts.map +1 -1
- package/lib/families/stellar/bridge/logic.js +1 -1
- package/lib/families/stellar/bridge/logic.js.map +1 -1
- package/lib/families/stellar/bridge/mock.js +2 -2
- package/lib/families/stellar/bridge/mock.js.map +1 -1
- package/lib/families/stellar/setup.d.ts +6 -3
- package/lib/families/stellar/setup.d.ts.map +1 -1
- package/lib/families/stellar/setup.js +12 -3
- package/lib/families/stellar/setup.js.map +1 -1
- package/lib/families/xrp/bridge/mock.js +2 -2
- package/lib/families/xrp/bridge/mock.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +2 -4
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/generated/bridge/js.d.ts +1 -0
- package/lib/generated/bridge/js.d.ts.map +1 -1
- package/lib/generated/bridge/js.js +14 -12
- package/lib/generated/bridge/js.js.map +1 -1
- package/lib/generated/transaction.d.ts +1 -1
- package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.js +14 -229
- package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.js.map +1 -1
- package/lib/modularDrawer/enums.d.ts +1 -0
- package/lib/modularDrawer/enums.d.ts.map +1 -1
- package/lib/modularDrawer/enums.js +1 -0
- package/lib/modularDrawer/enums.js.map +1 -1
- package/lib/modularDrawer/useModularDrawerVisibility.d.ts +1 -7
- package/lib/modularDrawer/useModularDrawerVisibility.d.ts.map +1 -1
- package/lib/modularDrawer/useModularDrawerVisibility.js +2 -18
- package/lib/modularDrawer/useModularDrawerVisibility.js.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.d.ts.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.js +1 -3
- package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/accountBridge.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/accountBridge.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/accountBridge.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.js +2 -4
- package/lib-es/bridge/generic-alpaca/alpaca/index.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +4 -4
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +10 -10
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/broadcast.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/broadcast.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/createTransaction.d.ts +9 -17
- package/lib-es/bridge/generic-alpaca/createTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/createTransaction.js +9 -35
- package/lib-es/bridge/generic-alpaca/createTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/currencyBridge.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js +0 -9
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.js +37 -66
- package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +15 -27
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts +1 -5
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js +4 -26
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js +13 -61
- package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/index.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/index.js +6 -39
- package/lib-es/bridge/generic-alpaca/signer/index.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.d.ts +0 -2
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.js +0 -6
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/types.d.ts +0 -3
- package/lib-es/bridge/generic-alpaca/signer/types.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js +46 -70
- package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js +1 -1
- package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/tests/signOperation.test.js +22 -25
- package/lib-es/bridge/generic-alpaca/tests/signOperation.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts +1 -36
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js +14 -130
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.test.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/{tests/utils.test.js → utils.test.js} +1 -1
- package/lib-es/bridge/generic-alpaca/utils.test.js.map +1 -0
- package/lib-es/bridge/impl.d.ts.map +1 -1
- package/lib-es/bridge/impl.js +4 -5
- package/lib-es/bridge/impl.js.map +1 -1
- package/lib-es/e2e/enum/Account.js +4 -4
- package/lib-es/e2e/enum/Account.js.map +1 -1
- package/lib-es/e2e/enum/AppInfos.d.ts +1 -1
- package/lib-es/e2e/enum/AppInfos.d.ts.map +1 -1
- package/lib-es/e2e/enum/AppInfos.js +1 -1
- package/lib-es/e2e/enum/AppInfos.js.map +1 -1
- package/lib-es/e2e/enum/Currency.d.ts.map +1 -1
- package/lib-es/e2e/enum/Currency.js +3 -3
- package/lib-es/e2e/enum/Currency.js.map +1 -1
- package/lib-es/e2e/speculos.js +2 -2
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/exchange/index.d.ts.map +1 -1
- package/lib-es/exchange/index.js +0 -1
- package/lib-es/exchange/index.js.map +1 -1
- package/lib-es/families/canton/bridge.integration.test.d.ts +2 -0
- package/lib-es/families/canton/bridge.integration.test.d.ts.map +1 -0
- package/lib-es/families/canton/bridge.integration.test.js +5 -0
- package/lib-es/families/canton/bridge.integration.test.js.map +1 -0
- package/lib-es/families/stellar/bridge/logic.d.ts +1 -1
- package/lib-es/families/stellar/bridge/logic.d.ts.map +1 -1
- package/lib-es/families/stellar/bridge/logic.js +1 -1
- package/lib-es/families/stellar/bridge/logic.js.map +1 -1
- package/lib-es/families/stellar/bridge/mock.js +2 -2
- package/lib-es/families/stellar/bridge/mock.js.map +1 -1
- package/lib-es/families/stellar/setup.d.ts +6 -3
- package/lib-es/families/stellar/setup.d.ts.map +1 -1
- package/lib-es/families/stellar/setup.js +10 -2
- package/lib-es/families/stellar/setup.js.map +1 -1
- package/lib-es/families/xrp/bridge/mock.js +2 -2
- package/lib-es/families/xrp/bridge/mock.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +2 -4
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/generated/bridge/js.d.ts +1 -0
- package/lib-es/generated/bridge/js.d.ts.map +1 -1
- package/lib-es/generated/bridge/js.js +2 -0
- package/lib-es/generated/bridge/js.js.map +1 -1
- package/lib-es/generated/transaction.d.ts +1 -1
- package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.js +14 -229
- package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.js.map +1 -1
- package/lib-es/modularDrawer/enums.d.ts +1 -0
- package/lib-es/modularDrawer/enums.d.ts.map +1 -1
- package/lib-es/modularDrawer/enums.js +1 -0
- package/lib-es/modularDrawer/enums.js.map +1 -1
- package/lib-es/modularDrawer/useModularDrawerVisibility.d.ts +1 -7
- package/lib-es/modularDrawer/useModularDrawerVisibility.d.ts.map +1 -1
- package/lib-es/modularDrawer/useModularDrawerVisibility.js +2 -18
- package/lib-es/modularDrawer/useModularDrawerVisibility.js.map +1 -1
- package/package.json +70 -71
- package/src/__tests__/test-helpers/bridge.ts +1 -3
- package/src/bridge/generic-alpaca/accountBridge.ts +4 -1
- package/src/bridge/generic-alpaca/alpaca/index.ts +2 -7
- package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +22 -17
- package/src/bridge/generic-alpaca/broadcast.ts +4 -1
- package/src/bridge/generic-alpaca/createTransaction.ts +18 -48
- package/src/bridge/generic-alpaca/currencyBridge.ts +1 -1
- package/src/bridge/generic-alpaca/estimateMaxSpendable.ts +4 -13
- package/src/bridge/generic-alpaca/getAccountShape.ts +46 -84
- package/src/bridge/generic-alpaca/getTransactionStatus.ts +22 -46
- package/src/bridge/generic-alpaca/prepareTransaction.ts +7 -41
- package/src/bridge/generic-alpaca/signOperation.ts +18 -85
- package/src/bridge/generic-alpaca/signer/index.ts +7 -43
- package/src/bridge/generic-alpaca/signer/signTransaction.ts +0 -11
- package/src/bridge/generic-alpaca/signer/types.ts +0 -1
- package/src/bridge/generic-alpaca/tests/estimateMaxSpendable.test.ts +47 -72
- package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +1 -1
- package/src/bridge/generic-alpaca/tests/signOperation.test.ts +26 -28
- package/src/bridge/generic-alpaca/{tests/utils.test.ts → utils.test.ts} +1 -1
- package/src/bridge/generic-alpaca/utils.ts +18 -158
- package/src/bridge/impl.ts +4 -5
- package/src/e2e/enum/Account.ts +4 -4
- package/src/e2e/enum/AppInfos.ts +1 -1
- package/src/e2e/enum/Currency.ts +13 -3
- package/src/e2e/speculos.ts +2 -2
- package/src/exchange/index.ts +0 -1
- package/src/families/canton/bridge.integration.test.ts +6 -0
- package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +2009 -202
- package/src/families/stellar/bridge/logic.ts +1 -1
- package/src/families/stellar/bridge/mock.ts +2 -2
- package/src/families/stellar/setup.ts +22 -2
- package/src/families/xrp/bridge/mock.ts +2 -2
- package/src/featureFlags/defaultFeatures.ts +2 -4
- package/src/generated/bridge/js.ts +2 -0
- package/src/modularDrawer/__test__/useModularDrawerVisibility.test.ts +14 -345
- package/src/modularDrawer/enums.ts +1 -0
- package/src/modularDrawer/useModularDrawerVisibility.ts +2 -26
- package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts +0 -17
- package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts.map +0 -1
- package/lib/bridge/generic-alpaca/buildSubAccounts.js +0 -75
- package/lib/bridge/generic-alpaca/buildSubAccounts.js.map +0 -1
- package/lib/bridge/generic-alpaca/tests/utils.test.d.ts.map +0 -1
- package/lib/bridge/generic-alpaca/tests/utils.test.js.map +0 -1
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts +0 -17
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts.map +0 -1
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.js +0 -65
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.js.map +0 -1
- package/lib-es/bridge/generic-alpaca/tests/utils.test.d.ts.map +0 -1
- package/lib-es/bridge/generic-alpaca/tests/utils.test.js.map +0 -1
- package/src/bridge/generic-alpaca/buildSubAccounts.ts +0 -110
- /package/lib/bridge/generic-alpaca/{tests/utils.test.d.ts → utils.test.d.ts} +0 -0
- /package/lib-es/bridge/generic-alpaca/{tests/utils.test.d.ts → utils.test.d.ts} +0 -0
@@ -1,56 +1,23 @@
|
|
1
1
|
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
2
2
|
import { Account, Operation, OperationType, TransactionCommon } from "@ledgerhq/types-live";
|
3
|
-
import BigNumber from "bignumber.js";
|
4
|
-
import { fromBigNumberToBigInt } from "@ledgerhq/coin-framework/utils";
|
5
3
|
import {
|
6
4
|
Balance,
|
7
5
|
Operation as CoreOperation,
|
8
6
|
TransactionIntent,
|
9
7
|
} from "@ledgerhq/coin-framework/api/types";
|
8
|
+
import BigNumber from "bignumber.js";
|
9
|
+
import { fromBigNumberToBigInt } from "@ledgerhq/coin-framework/utils";
|
10
10
|
|
11
11
|
export function extractBalance(balances: Balance[], type: string): Balance {
|
12
|
-
return (
|
13
|
-
balances.find(balance => balance.asset.type === type) ?? {
|
14
|
-
asset: { type },
|
15
|
-
value: 0n,
|
16
|
-
}
|
17
|
-
);
|
12
|
+
return balances.find(balance => balance.asset.type === type) ?? { asset: { type }, value: 0n };
|
18
13
|
}
|
19
14
|
|
20
15
|
export function adaptCoreOperationToLiveOperation(accountId: string, op: CoreOperation): Operation {
|
21
|
-
|
22
|
-
|
23
|
-
const extra: {
|
24
|
-
assetReference?: string;
|
25
|
-
assetOwner?: string;
|
26
|
-
assetAmount?: string | undefined;
|
27
|
-
ledgerOpType?: string | undefined;
|
28
|
-
memo?: string | undefined;
|
29
|
-
} = {};
|
30
|
-
|
31
|
-
if (op.details?.ledgerOpType !== undefined) {
|
32
|
-
extra.ledgerOpType = op.details.ledgerOpType as string;
|
33
|
-
}
|
34
|
-
|
35
|
-
if (op.details?.assetAmount !== undefined) {
|
36
|
-
extra.assetAmount = op.details.assetAmount as string;
|
37
|
-
}
|
38
|
-
|
39
|
-
if (op.asset?.type !== "native") {
|
40
|
-
extra.assetReference =
|
41
|
-
"assetReference" in (op.asset ?? {}) ? (op.asset as any).assetReference : "";
|
42
|
-
extra.assetOwner = "assetOwner" in (op.asset ?? {}) ? (op.asset as any).assetOwner : "";
|
43
|
-
}
|
44
|
-
if (op.details?.memo) {
|
45
|
-
extra.memo = op.details.memo as string;
|
46
|
-
}
|
47
|
-
const res = {
|
48
|
-
id: extra.ledgerOpType
|
49
|
-
? encodeOperationId(accountId, op.tx.hash, extra.ledgerOpType)
|
50
|
-
: encodeOperationId(accountId, op.tx.hash, op.type),
|
16
|
+
return {
|
17
|
+
id: encodeOperationId(accountId, op.tx.hash, op.type),
|
51
18
|
hash: op.tx.hash,
|
52
19
|
accountId,
|
53
|
-
type:
|
20
|
+
type: op.type as OperationType,
|
54
21
|
value: new BigNumber(op.value.toString()),
|
55
22
|
fee: new BigNumber(op.tx.fees.toString()),
|
56
23
|
blockHash: op.tx.block.hash,
|
@@ -59,94 +26,21 @@ export function adaptCoreOperationToLiveOperation(accountId: string, op: CoreOpe
|
|
59
26
|
recipients: op.recipients,
|
60
27
|
date: op.tx.date,
|
61
28
|
transactionSequenceNumber: op.details?.sequence as number,
|
62
|
-
|
63
|
-
extra,
|
29
|
+
extra: {},
|
64
30
|
};
|
65
|
-
|
66
|
-
return res;
|
67
31
|
}
|
68
32
|
|
69
|
-
/**
|
70
|
-
* Converts a transaction object into a `TransactionIntent` object, which is used to represent
|
71
|
-
* the intent of a transaction in a standardized format.
|
72
|
-
*
|
73
|
-
* @template MemoType - The type of memo supported by the transaction, defaults to `MemoNotSupported`.
|
74
|
-
*
|
75
|
-
* @param account - The account initiating the transaction. Contains details such as the sender's address.
|
76
|
-
* @param transaction - The transaction object containing details about the operation to be performed.
|
77
|
-
* - `assetOwner` (optional): The issuer of the asset, if applicable.
|
78
|
-
* - `assetReference` (optional): The code of the asset, if applicable.
|
79
|
-
* - `mode` (optional): The mode of the transaction, e.g., "changetrust" or "send".
|
80
|
-
* - `fees` (optional): The fees associated with the transaction.
|
81
|
-
* - `memoType` (optional): The type of memo to attach to the transaction.
|
82
|
-
* - `memoValue` (optional): The value of the memo to attach to the transaction.
|
83
|
-
*
|
84
|
-
* @returns A `TransactionIntent` object containing the standardized representation of the transaction.
|
85
|
-
* - Includes details such as type, sender, recipient, amount, fees, asset, and an optional memo.
|
86
|
-
* - If `assetReference` and `assetOwner` are provided, the asset is represented as a token.
|
87
|
-
* - If `memoType` and `memoValue` are provided, a memo is included; otherwise, a default memo of type "NO_MEMO" is added.
|
88
|
-
*
|
89
|
-
* @throws An error if the transaction mode is unsupported.
|
90
|
-
*/
|
91
33
|
export function transactionToIntent(
|
92
34
|
account: Account,
|
93
|
-
transaction: TransactionCommon
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
fees?: bigint | null | undefined;
|
98
|
-
memoType?: string;
|
99
|
-
memoValue?: string;
|
100
|
-
useAllAmount?: boolean;
|
101
|
-
},
|
102
|
-
): TransactionIntent<any> & { memo?: { type: string; value?: string } } {
|
103
|
-
let transactionType = "Payment"; // NOTE: assuming payment by default here, can be changed based on transaction.mode
|
104
|
-
if (transaction.mode) {
|
105
|
-
switch (transaction.mode) {
|
106
|
-
case "changeTrust":
|
107
|
-
transactionType = "changeTrust";
|
108
|
-
break;
|
109
|
-
case "send":
|
110
|
-
transactionType = "send";
|
111
|
-
break;
|
112
|
-
default:
|
113
|
-
throw new Error(`Unsupported transaction mode: ${transaction.mode}`);
|
114
|
-
}
|
115
|
-
}
|
116
|
-
const res: TransactionIntent & { memo?: { type: string; value?: string } } = {
|
117
|
-
fees: transaction?.fees ? transaction.fees : null,
|
118
|
-
type: transactionType,
|
35
|
+
transaction: TransactionCommon,
|
36
|
+
): TransactionIntent<any> {
|
37
|
+
return {
|
38
|
+
type: "Payment",
|
119
39
|
sender: account.freshAddress,
|
120
40
|
recipient: transaction.recipient,
|
121
41
|
amount: fromBigNumberToBigInt(transaction.amount, BigInt(0)),
|
122
|
-
asset: { type: "native"
|
123
|
-
useAllAmount: !!transaction.useAllAmount,
|
42
|
+
asset: { type: "native" },
|
124
43
|
};
|
125
|
-
if (transaction.assetReference && transaction.assetOwner) {
|
126
|
-
const { subAccountId } = transaction;
|
127
|
-
const { subAccounts } = account;
|
128
|
-
|
129
|
-
const tokenAccount = !subAccountId
|
130
|
-
? null
|
131
|
-
: subAccounts && subAccounts.find(ta => ta.id === subAccountId);
|
132
|
-
|
133
|
-
res.asset = {
|
134
|
-
type: tokenAccount?.token.tokenType ?? "token",
|
135
|
-
assetReference: transaction.assetReference,
|
136
|
-
name: tokenAccount?.token.name ?? transaction.assetReference, // NOTE: for stellar, assetReference = tokenAccount.name, this is futureproofing
|
137
|
-
unit: account.currency.units[0],
|
138
|
-
assetOwner: transaction.assetOwner,
|
139
|
-
};
|
140
|
-
}
|
141
|
-
if (transaction.memoType && transaction.memoValue) {
|
142
|
-
res.memo = {
|
143
|
-
type: transaction.memoType,
|
144
|
-
value: transaction.memoValue,
|
145
|
-
};
|
146
|
-
} else {
|
147
|
-
res.memo = { type: "NO_MEMO" };
|
148
|
-
}
|
149
|
-
return res;
|
150
44
|
}
|
151
45
|
|
152
46
|
export const buildOptimisticOperation = (
|
@@ -154,17 +48,12 @@ export const buildOptimisticOperation = (
|
|
154
48
|
transaction: TransactionCommon,
|
155
49
|
sequenceNumber?: number,
|
156
50
|
): Operation => {
|
157
|
-
|
158
|
-
|
159
|
-
const { subAccountId } = transaction;
|
160
|
-
const { subAccounts } = account;
|
161
|
-
|
162
|
-
const operation: Operation = {
|
163
|
-
id: encodeOperationId(account.id, "", type),
|
51
|
+
return {
|
52
|
+
id: encodeOperationId(account.id, "", "OUT"),
|
164
53
|
hash: "",
|
165
|
-
type:
|
166
|
-
value:
|
167
|
-
fee:
|
54
|
+
type: "OUT",
|
55
|
+
value: transaction.amount,
|
56
|
+
fee: transaction["fees"] ?? BigNumber(0),
|
168
57
|
blockHash: null,
|
169
58
|
blockHeight: null,
|
170
59
|
senders: [account.freshAddress.toString()],
|
@@ -172,35 +61,6 @@ export const buildOptimisticOperation = (
|
|
172
61
|
transactionSequenceNumber: sequenceNumber ?? 0,
|
173
62
|
accountId: account.id,
|
174
63
|
date: new Date(),
|
175
|
-
extra: {
|
176
|
-
ledgerOpType: type,
|
177
|
-
blockTime: new Date(),
|
178
|
-
index: "0",
|
179
|
-
},
|
64
|
+
extra: {},
|
180
65
|
};
|
181
|
-
|
182
|
-
const tokenAccount = !subAccountId
|
183
|
-
? null
|
184
|
-
: subAccounts && subAccounts.find(ta => ta.id === subAccountId);
|
185
|
-
if (tokenAccount && subAccountId) {
|
186
|
-
operation.subOperations = [
|
187
|
-
{
|
188
|
-
id: `${subAccountId}--OUT`,
|
189
|
-
hash: "",
|
190
|
-
type: "OUT",
|
191
|
-
value: transaction.useAllAmount ? tokenAccount.balance : transaction.amount,
|
192
|
-
fee: new BigNumber(0),
|
193
|
-
blockHash: null,
|
194
|
-
blockHeight: null,
|
195
|
-
senders: [account.freshAddress],
|
196
|
-
recipients: [transaction.recipient],
|
197
|
-
accountId: subAccountId,
|
198
|
-
date: new Date(),
|
199
|
-
extra: {
|
200
|
-
ledgerOpType: type,
|
201
|
-
},
|
202
|
-
},
|
203
|
-
];
|
204
|
-
}
|
205
|
-
return operation;
|
206
66
|
};
|
package/src/bridge/impl.ts
CHANGED
@@ -26,12 +26,11 @@ import { getCryptoAssetsStore, setCryptoAssetsStore } from "./crypto-assets";
|
|
26
26
|
|
27
27
|
const alpacaized = {
|
28
28
|
xrp: true,
|
29
|
-
stellar: true,
|
30
29
|
};
|
31
30
|
|
32
31
|
// let accountBridgeInstance: AccountBridge<any> | null = null;
|
33
32
|
const bridgeCache: Record<string, AccountBridge<any>> = {};
|
34
|
-
|
33
|
+
let currencyBridgeInstance: CurrencyBridge | null = null;
|
35
34
|
|
36
35
|
export const getCurrencyBridge = (currency: CryptoCurrency): CurrencyBridge => {
|
37
36
|
if (getEnv("MOCK")) {
|
@@ -43,10 +42,10 @@ export const getCurrencyBridge = (currency: CryptoCurrency): CurrencyBridge => {
|
|
43
42
|
}
|
44
43
|
|
45
44
|
if (alpacaized[currency.family]) {
|
46
|
-
if (!
|
47
|
-
|
45
|
+
if (!currencyBridgeInstance) {
|
46
|
+
currencyBridgeInstance = getAlpacaCurrencyBridge(currency.family, "local");
|
48
47
|
}
|
49
|
-
return
|
48
|
+
return currencyBridgeInstance;
|
50
49
|
}
|
51
50
|
|
52
51
|
const jsBridge = jsBridges[currency.family];
|
package/src/e2e/enum/Account.ts
CHANGED
@@ -94,25 +94,25 @@ export class Account {
|
|
94
94
|
|
95
95
|
static readonly BSC_1 = new Account(
|
96
96
|
Currency.BSC,
|
97
|
-
"
|
97
|
+
"Binance Smart Chain 1",
|
98
98
|
"0x4BE2E2B8872AA298D6d123b9211B53E41f611566",
|
99
99
|
0,
|
100
100
|
);
|
101
101
|
static readonly BSC_BUSD_1 = new Account(
|
102
102
|
Currency.BSC_BUSD,
|
103
|
-
"
|
103
|
+
"Binance Smart Chain 1",
|
104
104
|
"0x4BE2E2B8872AA298D6d123b9211B53E41f611566",
|
105
105
|
0,
|
106
106
|
);
|
107
107
|
static readonly BSC_BUSD_2 = new Account(
|
108
108
|
Currency.BSC_BUSD,
|
109
|
-
"
|
109
|
+
"Binance Smart Chain 2",
|
110
110
|
"0xa1baa625c5E6A9304cB7AcD86d2fee6B710eC3eB",
|
111
111
|
1,
|
112
112
|
);
|
113
113
|
static readonly BSC_SHIBA = new Account(
|
114
114
|
Currency.BSC_SHIBA,
|
115
|
-
"
|
115
|
+
"Binance Smart Chain 1",
|
116
116
|
"0x4BE2E2B8872AA298D6d123b9211B53E41f611566",
|
117
117
|
0,
|
118
118
|
);
|
package/src/e2e/enum/AppInfos.ts
CHANGED
@@ -43,7 +43,7 @@ export class AppInfos {
|
|
43
43
|
|
44
44
|
static readonly POLYGON = new AppInfos("Polygon");
|
45
45
|
|
46
|
-
static readonly
|
46
|
+
static readonly BINANCE_SMART_CHAIN = new AppInfos("Binance Smart Chain");
|
47
47
|
|
48
48
|
static readonly TON = new AppInfos("Ton");
|
49
49
|
|
package/src/e2e/enum/Currency.ts
CHANGED
@@ -63,7 +63,12 @@ export class Currency {
|
|
63
63
|
static readonly ATOM = new Currency("Cosmos", "ATOM", "cosmos", AppInfos.COSMOS);
|
64
64
|
static readonly XTZ = new Currency("Tezos", "XTZ", "tezos", AppInfos.TEZOS);
|
65
65
|
static readonly POL = new Currency("Polygon", "POL", "polygon", AppInfos.POLYGON);
|
66
|
-
static readonly BSC = new Currency(
|
66
|
+
static readonly BSC = new Currency(
|
67
|
+
"Binance Smart Chain",
|
68
|
+
"BNB",
|
69
|
+
"bsc",
|
70
|
+
AppInfos.BINANCE_SMART_CHAIN,
|
71
|
+
);
|
67
72
|
static readonly TON = new Currency("TON", "TON", "ton", AppInfos.TON);
|
68
73
|
static readonly ETH_USDT = new Currency(
|
69
74
|
"Tether USD",
|
@@ -93,9 +98,14 @@ export class Currency {
|
|
93
98
|
"Binance-Peg BUSD Token",
|
94
99
|
"BUSD",
|
95
100
|
"bsc",
|
96
|
-
AppInfos.
|
101
|
+
AppInfos.BINANCE_SMART_CHAIN,
|
102
|
+
);
|
103
|
+
static readonly BSC_SHIBA = new Currency(
|
104
|
+
"Shiba Inu",
|
105
|
+
"SHIB",
|
106
|
+
"bsc",
|
107
|
+
AppInfos.BINANCE_SMART_CHAIN,
|
97
108
|
);
|
98
|
-
static readonly BSC_SHIBA = new Currency("Shiba Inu", "SHIB", "bsc", AppInfos.BNB_CHAIN);
|
99
109
|
static readonly POL_DAI = new Currency(
|
100
110
|
"(PoS) Dai Stablecoin",
|
101
111
|
"DAI",
|
package/src/e2e/speculos.ts
CHANGED
@@ -260,7 +260,7 @@ export const specs: Specs = {
|
|
260
260
|
},
|
261
261
|
dependency: "",
|
262
262
|
},
|
263
|
-
|
263
|
+
Binance_Smart_Chain: {
|
264
264
|
currency: getCryptoCurrencyById("bsc"),
|
265
265
|
appQuery: {
|
266
266
|
model: getSpeculosModel(),
|
@@ -620,7 +620,7 @@ export async function goToSettings() {
|
|
620
620
|
|
621
621
|
const APP_LABEL_MAP = new Map<AppInfos, [string, string]>([
|
622
622
|
[AppInfos.ETHEREUM, [DeviceLabels.VERIFY_ETHEREUM, DeviceLabels.CONFIRM]],
|
623
|
-
[AppInfos.
|
623
|
+
[AppInfos.BINANCE_SMART_CHAIN, [DeviceLabels.VERIFY_BSC, DeviceLabels.CONFIRM]],
|
624
624
|
[AppInfos.POLYGON, [DeviceLabels.VERIFY_POLYGON, DeviceLabels.CONFIRM]],
|
625
625
|
[AppInfos.SOLANA, [DeviceLabels.PUBKEY, DeviceLabels.APPROVE]],
|
626
626
|
[AppInfos.POLKADOT, [DeviceLabels.PLEASE_REVIEW, DeviceLabels.CAPS_APPROVE]],
|
package/src/exchange/index.ts
CHANGED