@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,24 +1,19 @@
|
|
1
1
|
import { createApi as createXrpApi } from "@ledgerhq/coin-xrp/api/index";
|
2
|
-
import { createApi as createStellarApi } from "@ledgerhq/coin-stellar/api/index";
|
3
2
|
import { getCurrencyConfiguration } from "../../../config";
|
4
3
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
5
4
|
import { getNetworkAlpacaApi } from "./network/network-alpaca";
|
6
5
|
import { Api } from "@ledgerhq/coin-framework/api/types";
|
7
6
|
import { XrpCoinConfig } from "@ledgerhq/coin-xrp/config";
|
8
|
-
import { StellarCoinConfig } from "@ledgerhq/coin-stellar/config";
|
9
7
|
|
10
|
-
export function getAlpacaApi(network, kind): Api<any> {
|
8
|
+
export function getAlpacaApi(network: string, kind: "local" | "remote"): Api<any> {
|
11
9
|
if (kind === "local") {
|
12
10
|
switch (network) {
|
13
11
|
case "ripple":
|
14
12
|
case "xrp":
|
15
13
|
return createXrpApi(
|
16
14
|
getCurrencyConfiguration<XrpCoinConfig>(getCryptoCurrencyById("ripple")),
|
17
|
-
) as Api<any>; // FIXME: createXrpApi returns a strongly typed Api<XrpSender>, fix Api<any> to allow it
|
18
|
-
case "stellar":
|
19
|
-
return createStellarApi(
|
20
|
-
getCurrencyConfiguration<StellarCoinConfig>(getCryptoCurrencyById("stellar")),
|
21
15
|
) as Api<any>;
|
16
|
+
// as unknown as Api<any>; // FIXME: createXrpApi returns a strongly typed Api<XrpSender>, fix Api<any> to allow it
|
22
17
|
}
|
23
18
|
}
|
24
19
|
return getNetworkAlpacaApi(network) satisfies Partial<Api<any>> as Api<any>;
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import
|
1
|
+
import {
|
2
|
+
Account,
|
2
3
|
Balance,
|
3
4
|
Block,
|
4
5
|
BlockInfo,
|
@@ -6,9 +7,10 @@ import type {
|
|
6
7
|
FeeEstimation,
|
7
8
|
Pagination,
|
8
9
|
TransactionIntent,
|
10
|
+
Transaction,
|
9
11
|
TransactionValidation,
|
12
|
+
AccountInfo,
|
10
13
|
Api,
|
11
|
-
AssetInfo,
|
12
14
|
Cursor,
|
13
15
|
Page,
|
14
16
|
Stake,
|
@@ -16,7 +18,7 @@ import type {
|
|
16
18
|
} from "@ledgerhq/coin-framework/api/index";
|
17
19
|
import network from "@ledgerhq/live-network";
|
18
20
|
|
19
|
-
function adaptOp
|
21
|
+
function adaptOp(backendOp: any): Operation<any> {
|
20
22
|
const { date } = backendOp.tx;
|
21
23
|
const newDate = new Date(date);
|
22
24
|
|
@@ -29,7 +31,7 @@ function adaptOp<T extends AssetInfo>(backendOp: Operation<T>): Operation<T> {
|
|
29
31
|
|
30
32
|
const ALPACA_URL = "http://0.0.0.0:3000";
|
31
33
|
|
32
|
-
const buildBroadcast = networkFamily =>
|
34
|
+
const buildBroadcast = (networkFamily: string) =>
|
33
35
|
async function broadcast(signedOperation: string): Promise<string> {
|
34
36
|
const { data } = await network<
|
35
37
|
{
|
@@ -48,7 +50,7 @@ const buildBroadcast = networkFamily =>
|
|
48
50
|
return data.transactionIdentifier;
|
49
51
|
};
|
50
52
|
|
51
|
-
const buildCombine = networkFamily =>
|
53
|
+
const buildCombine = (networkFamily: string) =>
|
52
54
|
async function combine(tx: string, signature: string, pubKey?: string): Promise<string> {
|
53
55
|
const { data } = await network<
|
54
56
|
{
|
@@ -67,7 +69,7 @@ const buildCombine = networkFamily =>
|
|
67
69
|
return data.signedTransaction;
|
68
70
|
};
|
69
71
|
|
70
|
-
const buildEstimateFees = networkFamily =>
|
72
|
+
const buildEstimateFees = (networkFamily: string) =>
|
71
73
|
async function estimateFees(intent: TransactionIntent<any>): Promise<FeeEstimation> {
|
72
74
|
const { data } = await network<{ fee: string }, unknown>({
|
73
75
|
method: "POST",
|
@@ -84,8 +86,11 @@ const buildEstimateFees = networkFamily =>
|
|
84
86
|
};
|
85
87
|
};
|
86
88
|
|
87
|
-
const buildValidateIntent = networkFamily =>
|
88
|
-
async function validateIntent(
|
89
|
+
const buildValidateIntent = (networkFamily: string) =>
|
90
|
+
async function validateIntent(
|
91
|
+
account: Account,
|
92
|
+
transaction: Transaction,
|
93
|
+
): Promise<TransactionValidation> {
|
89
94
|
const { data } = await network<
|
90
95
|
{
|
91
96
|
errors: Record<string, Error>;
|
@@ -100,6 +105,7 @@ const buildValidateIntent = networkFamily =>
|
|
100
105
|
url: `${ALPACA_URL}/${networkFamily}/transaction/validate`,
|
101
106
|
data: {
|
102
107
|
transaction,
|
108
|
+
account,
|
103
109
|
},
|
104
110
|
});
|
105
111
|
return data;
|
@@ -116,14 +122,13 @@ const buildGetBalance = (networkFamily: string) =>
|
|
116
122
|
{
|
117
123
|
value: BigInt(data.value),
|
118
124
|
asset: data.asset,
|
119
|
-
locked: BigInt(data?.locked ?? "0"),
|
120
125
|
},
|
121
126
|
];
|
122
127
|
};
|
123
128
|
|
124
|
-
const
|
125
|
-
async function
|
126
|
-
const { data } = await network<
|
129
|
+
const buildGetAccountInfo = (networkFamily: string) =>
|
130
|
+
async function getBalance(address: string): Promise<AccountInfo> {
|
131
|
+
const { data } = await network<AccountInfo, unknown>({
|
127
132
|
method: "GET",
|
128
133
|
url: `${ALPACA_URL}/${networkFamily}/account/${address}/info`,
|
129
134
|
});
|
@@ -131,10 +136,10 @@ const buildGetSequence = (networkFamily: string) =>
|
|
131
136
|
return data;
|
132
137
|
};
|
133
138
|
|
134
|
-
const buildListOperations = networkFamily =>
|
139
|
+
const buildListOperations = (networkFamily: string) =>
|
135
140
|
async function listOperations(
|
136
141
|
address: string,
|
137
|
-
pagination: Pagination
|
142
|
+
pagination: Pagination,
|
138
143
|
): Promise<[Operation<any>[], string]> {
|
139
144
|
const { data } = await network<{ operations: Operation<any>[] }, unknown>({
|
140
145
|
method: "GET",
|
@@ -146,7 +151,7 @@ const buildListOperations = networkFamily =>
|
|
146
151
|
return [data.operations.map(op => adaptOp(op)), ""];
|
147
152
|
};
|
148
153
|
|
149
|
-
const buildLastBlock = networkFamily =>
|
154
|
+
const buildLastBlock = (networkFamily: string) =>
|
150
155
|
async function lastBlock(): Promise<BlockInfo> {
|
151
156
|
const { data } = await network<any, unknown>({
|
152
157
|
method: "GET",
|
@@ -159,7 +164,7 @@ const buildLastBlock = networkFamily =>
|
|
159
164
|
};
|
160
165
|
};
|
161
166
|
|
162
|
-
const buildCraftTransaction = networkFamily =>
|
167
|
+
const buildCraftTransaction = (networkFamily: string) =>
|
163
168
|
async function craftTransaction(intent: TransactionIntent<any>): Promise<string> {
|
164
169
|
const { data } = await network<any, unknown>({
|
165
170
|
method: "POST",
|
@@ -181,7 +186,7 @@ export const getNetworkAlpacaApi = (networkFamily: string) =>
|
|
181
186
|
validateIntent: buildValidateIntent(networkFamily),
|
182
187
|
estimateFees: buildEstimateFees(networkFamily),
|
183
188
|
getBalance: buildGetBalance(networkFamily),
|
184
|
-
|
189
|
+
getAccountInfo: buildGetAccountInfo(networkFamily),
|
185
190
|
listOperations: buildListOperations(networkFamily),
|
186
191
|
lastBlock: buildLastBlock(networkFamily),
|
187
192
|
craftTransaction: buildCraftTransaction(networkFamily),
|
@@ -2,7 +2,10 @@ import { AccountBridge, TransactionCommon } from "@ledgerhq/types-live";
|
|
2
2
|
import { patchOperationWithHash } from "../../operation";
|
3
3
|
import { getAlpacaApi } from "./alpaca";
|
4
4
|
|
5
|
-
export const genericBroadcast: (
|
5
|
+
export const genericBroadcast: (
|
6
|
+
network: string,
|
7
|
+
kind: "local" | "remote",
|
8
|
+
) => AccountBridge<TransactionCommon>["broadcast"] =
|
6
9
|
(network, kind) =>
|
7
10
|
async ({ signedOperation: { signature, operation } }) => {
|
8
11
|
const hash = await getAlpacaApi(network, kind).broadcast(signature);
|
@@ -1,57 +1,27 @@
|
|
1
|
-
import { Account,
|
1
|
+
import { Account, TransactionCommon } from "@ledgerhq/types-live";
|
2
2
|
import BigNumber from "bignumber.js";
|
3
3
|
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
4
4
|
|
5
|
-
export enum NetworkCongestionLevel {
|
6
|
-
LOW = "LOW",
|
7
|
-
MEDIUM = "MEDIUM",
|
8
|
-
HIGH = "HIGH",
|
9
|
-
}
|
10
|
-
|
11
5
|
export type NetworkInfo = {
|
12
|
-
|
6
|
+
family: "xrp";
|
7
|
+
serverFee: BigNumber;
|
8
|
+
baseReserve: BigNumber;
|
13
9
|
};
|
14
10
|
|
15
|
-
export function createTransaction(account: Account
|
11
|
+
export function createTransaction(account: Account): TransactionCommon & {
|
16
12
|
family: string;
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
memoValue?: string | null;
|
22
|
-
mode?: "send" | "changeTrust";
|
23
|
-
assetReference?: string;
|
24
|
-
assetOwner?: string;
|
25
|
-
networkInfo?: NetworkInfo | null;
|
13
|
+
fee: BigNumber | null | undefined;
|
14
|
+
networkInfo: NetworkInfo | null | undefined;
|
15
|
+
tag: number | null | undefined;
|
16
|
+
feeCustomUnit: Unit | null | undefined;
|
26
17
|
} {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
fees: null,
|
37
|
-
tag: undefined,
|
38
|
-
feeCustomUnit: null, // NOTE: XRP does not use custom units for fees anymore
|
39
|
-
};
|
40
|
-
case "stellar":
|
41
|
-
return {
|
42
|
-
family: currency.family,
|
43
|
-
amount: new BigNumber(0),
|
44
|
-
fees: null,
|
45
|
-
recipient: "",
|
46
|
-
memoValue: null,
|
47
|
-
memoType: null,
|
48
|
-
useAllAmount: false,
|
49
|
-
mode: "send",
|
50
|
-
assetReference: "",
|
51
|
-
assetOwner: "",
|
52
|
-
networkInfo: null,
|
53
|
-
};
|
54
|
-
default:
|
55
|
-
throw new Error(`Unsupported currency family: ${currency.family}`);
|
56
|
-
}
|
18
|
+
return {
|
19
|
+
family: account.currency.family,
|
20
|
+
amount: BigNumber(0),
|
21
|
+
recipient: "",
|
22
|
+
fee: null,
|
23
|
+
tag: undefined,
|
24
|
+
networkInfo: null,
|
25
|
+
feeCustomUnit: null,
|
26
|
+
};
|
57
27
|
}
|
@@ -3,7 +3,7 @@ import { CurrencyBridge } from "@ledgerhq/types-live";
|
|
3
3
|
import { genericGetAccountShape } from "./getAccountShape";
|
4
4
|
import { getSigner } from "./signer";
|
5
5
|
|
6
|
-
export function getAlpacaCurrencyBridge(network: string, kind:
|
6
|
+
export function getAlpacaCurrencyBridge(network: string, kind: "local" | "remote"): CurrencyBridge {
|
7
7
|
return {
|
8
8
|
preload: () => Promise.resolve({}),
|
9
9
|
hydrate: () => {
|
@@ -6,30 +6,21 @@ import { transactionToIntent } from "./utils";
|
|
6
6
|
import BigNumber from "bignumber.js";
|
7
7
|
|
8
8
|
export function genericEstimateMaxSpendable(
|
9
|
-
network,
|
10
|
-
kind,
|
9
|
+
network: string,
|
10
|
+
kind: "local" | "remote",
|
11
11
|
): AccountBridge<any>["estimateMaxSpendable"] {
|
12
12
|
return async ({ account, parentAccount, transaction }) => {
|
13
|
-
if (account.type === "TokenAccount") {
|
14
|
-
return account.spendableBalance;
|
15
|
-
}
|
16
13
|
const mainAccount = getMainAccount(account, parentAccount);
|
14
|
+
|
17
15
|
const draftTransaction = {
|
18
16
|
...createTransaction(account as any),
|
19
17
|
...transaction,
|
20
18
|
amount: mainAccount.spendableBalance,
|
21
|
-
useAllAmount: true,
|
22
|
-
fees: transaction?.fees ? BigInt(transaction.fees.toString()) : 0n,
|
23
19
|
};
|
24
20
|
const fees = await getAlpacaApi(network, kind).estimateFees(
|
25
21
|
transactionToIntent(mainAccount, draftTransaction),
|
26
22
|
);
|
27
|
-
|
28
|
-
transactionToIntent(account, { ...draftTransaction }),
|
29
|
-
);
|
30
|
-
if (network === "stellar") {
|
31
|
-
return amount > 0 ? new BigNumber(amount.toString()) : new BigNumber(0);
|
32
|
-
}
|
23
|
+
|
33
24
|
const bnFee = BigNumber(fees.value.toString());
|
34
25
|
return BigNumber.max(0, account.spendableBalance.minus(bnFee));
|
35
26
|
};
|
@@ -3,97 +3,59 @@ import { GetAccountShape, mergeOps } from "@ledgerhq/coin-framework/bridge/jsHel
|
|
3
3
|
import BigNumber from "bignumber.js";
|
4
4
|
import { getAlpacaApi } from "./alpaca";
|
5
5
|
import { adaptCoreOperationToLiveOperation, extractBalance } from "./utils";
|
6
|
-
import { inferSubOperations } from "@ledgerhq/coin-framework/serialization";
|
7
|
-
import { findToken } from "./buildSubAccounts";
|
8
|
-
import { buildSubAccounts, OperationCommon } from "./buildSubAccounts";
|
9
6
|
|
10
|
-
export function genericGetAccountShape(network: string, kind:
|
11
|
-
return async
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
export function genericGetAccountShape(network: string, kind: "local" | "remote"): GetAccountShape {
|
8
|
+
return async info => {
|
9
|
+
try {
|
10
|
+
const { address, initialAccount, currency, derivationMode } = info;
|
11
|
+
const accountId = encodeAccountId({
|
12
|
+
type: "js",
|
13
|
+
version: "2",
|
14
|
+
currencyId: currency.id,
|
15
|
+
xpubOrAddress: address,
|
16
|
+
derivationMode,
|
17
|
+
});
|
18
|
+
|
19
|
+
const blockInfo = await getAlpacaApi(network, kind).lastBlock();
|
20
|
+
|
21
|
+
const balances = await getAlpacaApi(network, kind).getBalance(address);
|
22
|
+
const nativeBalance = extractBalance(balances, "native");
|
23
|
+
const balance = BigNumber(nativeBalance.value.toString());
|
24
|
+
|
25
|
+
let spendableBalance: BigNumber;
|
26
|
+
if (nativeBalance.locked) {
|
27
|
+
spendableBalance = BigNumber.max(
|
28
|
+
balance.minus(BigNumber(nativeBalance.locked.toString())),
|
29
|
+
BigNumber(0),
|
30
|
+
);
|
31
|
+
} else {
|
32
|
+
spendableBalance = initialAccount?.spendableBalance || balance;
|
19
33
|
}
|
20
|
-
|
21
|
-
|
22
|
-
const accountId = encodeAccountId({
|
23
|
-
type: "js",
|
24
|
-
version: "2",
|
25
|
-
currencyId: currency.id,
|
26
|
-
xpubOrAddress: address,
|
27
|
-
derivationMode,
|
28
|
-
});
|
29
|
-
|
30
|
-
const blockInfo = await alpacaApi.lastBlock();
|
31
|
-
const balanceRes = await alpacaApi.getBalance(address);
|
32
|
-
const nativeAsset = extractBalance(balanceRes, "native");
|
33
|
-
|
34
|
-
const assetsBalance = balanceRes
|
35
|
-
.filter(b => b.asset.type !== "native")
|
36
|
-
.filter(b => findToken(currency, b));
|
37
|
-
|
38
|
-
const nativeBalance = BigInt(nativeAsset?.value ?? "0");
|
39
|
-
|
40
|
-
const spendableBalance = BigInt(nativeBalance - BigInt(nativeAsset?.locked ?? "0"));
|
34
|
+
const oldOperations = initialAccount?.operations || [];
|
41
35
|
|
42
|
-
|
43
|
-
const lastPagingToken = oldOps[0]?.extra?.pagingToken || "";
|
36
|
+
const blockHeight = oldOperations.length ? (oldOperations[0].blockHeight ?? 0) + 1 : 0;
|
44
37
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
paginationParams.lastPagingToken = lastPagingToken;
|
49
|
-
}
|
50
|
-
|
51
|
-
const [newCoreOps] = await alpacaApi.listOperations(address, paginationParams);
|
52
|
-
const newOps = newCoreOps.map(op =>
|
53
|
-
adaptCoreOperationToLiveOperation(accountId, op),
|
54
|
-
) as OperationCommon[];
|
55
|
-
const mergedOps = mergeOps(oldOps, newOps) as OperationCommon[];
|
56
|
-
|
57
|
-
const assetOperations: OperationCommon[] = [];
|
58
|
-
mergedOps.forEach(operation => {
|
59
|
-
if (
|
60
|
-
operation?.extra?.assetReference &&
|
61
|
-
operation?.extra?.assetOwner &&
|
62
|
-
!["OPT_IN", "OPT_OUT"].includes(operation.type)
|
63
|
-
) {
|
64
|
-
assetOperations.push(operation);
|
65
|
-
}
|
66
|
-
});
|
38
|
+
const [newOperations] = await getAlpacaApi(network, kind).listOperations(address, {
|
39
|
+
minHeight: blockHeight,
|
40
|
+
});
|
67
41
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
assetsBalance,
|
73
|
-
syncConfig,
|
74
|
-
operations: assetOperations,
|
75
|
-
}) || [];
|
76
|
-
|
77
|
-
const operationsWithSubs = mergedOps.map(op => {
|
78
|
-
const subOperations = inferSubOperations(op.hash, subAccounts);
|
42
|
+
const operations = mergeOps(
|
43
|
+
oldOperations,
|
44
|
+
newOperations.map(op => adaptCoreOperationToLiveOperation(accountId, op)),
|
45
|
+
);
|
79
46
|
|
80
47
|
return {
|
81
|
-
|
82
|
-
|
48
|
+
id: accountId,
|
49
|
+
xpub: address,
|
50
|
+
blockHeight: operations.length === 0 ? 0 : blockInfo.height || initialAccount?.blockHeight,
|
51
|
+
balance,
|
52
|
+
spendableBalance,
|
53
|
+
operations,
|
54
|
+
operationsCount: operations.length,
|
83
55
|
};
|
84
|
-
})
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
xpub: address,
|
89
|
-
blockHeight:
|
90
|
-
operationsWithSubs.length === 0 ? 0 : blockInfo.height || initialAccount?.blockHeight,
|
91
|
-
balance: new BigNumber(nativeBalance.toString()),
|
92
|
-
spendableBalance: new BigNumber(spendableBalance.toString()),
|
93
|
-
operations: operationsWithSubs,
|
94
|
-
subAccounts,
|
95
|
-
operationsCount: operationsWithSubs.length,
|
96
|
-
};
|
97
|
-
return res;
|
56
|
+
} catch (e) {
|
57
|
+
console.error("Error in getAccountShape", e);
|
58
|
+
throw e;
|
59
|
+
}
|
98
60
|
};
|
99
61
|
}
|
@@ -1,62 +1,38 @@
|
|
1
1
|
import { AccountBridge, TransactionCommon } from "@ledgerhq/types-live";
|
2
|
-
import { AccountAwaitingSendPendingOperations } from "@ledgerhq/errors";
|
3
2
|
import BigNumber from "bignumber.js";
|
4
3
|
import { getAlpacaApi } from "./alpaca";
|
5
|
-
import { transactionToIntent } from "./utils";
|
6
4
|
|
7
5
|
// => alpaca validateIntent
|
8
6
|
export function genericGetTransactionStatus(
|
9
|
-
network,
|
10
|
-
kind,
|
7
|
+
network: string,
|
8
|
+
kind: "local" | "remote",
|
11
9
|
): AccountBridge<any>["getTransactionStatus"] {
|
12
|
-
return async (
|
13
|
-
account
|
14
|
-
transaction: TransactionCommon & {
|
15
|
-
fees: BigNumber | null | undefined;
|
16
|
-
assetReference?: string;
|
17
|
-
assetOwner?: string;
|
18
|
-
mode?: string;
|
19
|
-
subAccountId?: string;
|
20
|
-
memoType?: string;
|
21
|
-
memoValue?: string;
|
22
|
-
},
|
23
|
-
) => {
|
10
|
+
return async (account, transaction: TransactionCommon & { fees: BigNumber }) => {
|
11
|
+
const { freshAddress, balance, currency } = account;
|
24
12
|
const alpacaApi = getAlpacaApi(network, kind);
|
25
|
-
const
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
if (alpacaApi.getChainSpecificRules) {
|
39
|
-
const chainSpecificValidation = alpacaApi.getChainSpecificRules();
|
40
|
-
if (chainSpecificValidation.getTransactionStatus.throwIfPendingOperation) {
|
41
|
-
if (account.pendingOperations.length > 0) {
|
42
|
-
throw new AccountAwaitingSendPendingOperations();
|
43
|
-
}
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
const { errors, warnings, estimatedFees, amount, totalSpent } = await alpacaApi.validateIntent(
|
48
|
-
transactionToIntent(account, draftTransaction),
|
13
|
+
const { errors, warnings } = await alpacaApi.validateIntent(
|
14
|
+
{
|
15
|
+
currencyName: currency.name,
|
16
|
+
address: freshAddress,
|
17
|
+
balance: BigInt(balance.toString()),
|
18
|
+
currencyUnit: currency.units[0],
|
19
|
+
},
|
20
|
+
{
|
21
|
+
type: "PAYMENT", // NOTE: assuming payment by default here
|
22
|
+
recipient: transaction.recipient,
|
23
|
+
amount: BigInt(transaction.amount?.toString() ?? "0"),
|
24
|
+
fee: BigInt(transaction.fees?.toString() ?? "0"),
|
25
|
+
},
|
49
26
|
);
|
50
27
|
|
28
|
+
const estimatedFees = transaction.fees || new BigNumber(0);
|
29
|
+
|
51
30
|
return Promise.resolve({
|
52
31
|
errors,
|
53
32
|
warnings,
|
54
|
-
estimatedFees
|
55
|
-
|
56
|
-
|
57
|
-
: transaction.fees,
|
58
|
-
amount: transaction.amount.eq(0) ? new BigNumber(amount.toString()) : transaction.amount,
|
59
|
-
totalSpent: new BigNumber(totalSpent.toString()),
|
33
|
+
estimatedFees,
|
34
|
+
amount: transaction.amount,
|
35
|
+
totalSpent: transaction.amount.plus(transaction.fees),
|
60
36
|
});
|
61
37
|
};
|
62
38
|
}
|
@@ -2,7 +2,6 @@ import { Account, AccountBridge, TransactionCommon } from "@ledgerhq/types-live"
|
|
2
2
|
import { getAlpacaApi } from "./alpaca";
|
3
3
|
import { transactionToIntent } from "./utils";
|
4
4
|
import BigNumber from "bignumber.js";
|
5
|
-
import { NetworkInfo } from "./createTransaction";
|
6
5
|
|
7
6
|
function bnEq(a: BigNumber | null | undefined, b: BigNumber | null | undefined): boolean {
|
8
7
|
return !a && !b ? true : !a || !b ? false : a.eq(b);
|
@@ -10,51 +9,18 @@ function bnEq(a: BigNumber | null | undefined, b: BigNumber | null | undefined):
|
|
10
9
|
|
11
10
|
export function genericPrepareTransaction(
|
12
11
|
network: string,
|
13
|
-
kind,
|
12
|
+
kind: "local" | "remote",
|
14
13
|
): AccountBridge<TransactionCommon, Account, any, any>["prepareTransaction"] {
|
15
|
-
return async (
|
16
|
-
account,
|
17
|
-
transaction: TransactionCommon & {
|
18
|
-
fees: BigNumber | null | undefined;
|
19
|
-
assetReference?: string;
|
20
|
-
assetOwner?: string;
|
21
|
-
subAccountId?: string;
|
22
|
-
networkInfo?: NetworkInfo | null;
|
23
|
-
},
|
24
|
-
) => {
|
25
|
-
const [assetReference, assetOwner] = getAssetInfos(transaction);
|
14
|
+
return async (account, transaction: TransactionCommon & { fees: BigNumber }) => {
|
26
15
|
const fees = await getAlpacaApi(network, kind).estimateFees(
|
27
|
-
transactionToIntent(account,
|
28
|
-
...transaction,
|
29
|
-
fees: transaction.fees ? BigInt(transaction.fees.toString()) : 0n,
|
30
|
-
}),
|
16
|
+
transactionToIntent(account, transaction),
|
31
17
|
);
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
if (!bnEq(transaction.fees, new BigNumber(fees.value.toString()))) {
|
37
|
-
return {
|
38
|
-
...transaction,
|
39
|
-
fees: new BigNumber(fees.value.toString()),
|
40
|
-
assetReference,
|
41
|
-
assetOwner,
|
42
|
-
networkInfo: {
|
43
|
-
fees: new BigNumber(fees.value.toString()),
|
44
|
-
},
|
45
|
-
};
|
18
|
+
const bnFee = BigNumber(fees.value.toString());
|
19
|
+
|
20
|
+
if (!bnEq(transaction.fees, bnFee)) {
|
21
|
+
return { ...transaction, fees: bnFee };
|
46
22
|
}
|
47
23
|
|
48
24
|
return transaction;
|
49
25
|
};
|
50
26
|
}
|
51
|
-
|
52
|
-
export function getAssetInfos(
|
53
|
-
tr: TransactionCommon & { assetReference?: string; assetOwner?: string },
|
54
|
-
): string[] {
|
55
|
-
if (tr.subAccountId) {
|
56
|
-
const assetString = tr.subAccountId.split("+")[1];
|
57
|
-
return assetString.split(":");
|
58
|
-
}
|
59
|
-
return [tr.assetReference || "", tr.assetOwner || ""];
|
60
|
-
}
|