@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
@@ -12,69 +12,12 @@ import { buildOptimisticOperation, transactionToIntent } from "./utils";
|
|
12
12
|
import { FeeNotLoaded } from "@ledgerhq/errors";
|
13
13
|
import { Result } from "@ledgerhq/coin-framework/derivation";
|
14
14
|
import { MapMemo, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
|
15
|
-
import { StellarMemo } from "@ledgerhq/coin-stellar/types/bridge";
|
16
|
-
import BigNumber from "bignumber.js";
|
17
15
|
|
18
|
-
/**
|
19
|
-
* Applies memo information to transaction intent
|
20
|
-
* Handles both destination tags (XRP-like) and Stellar-style memos
|
21
|
-
*/
|
22
|
-
function applyMemoToIntent(
|
23
|
-
transactionIntent: TransactionIntent<any>,
|
24
|
-
transaction: TransactionCommon,
|
25
|
-
): TransactionIntent<any> {
|
26
|
-
// Handle destination tag memo (for XRP-like chains)
|
27
|
-
if (transaction["tag"]) {
|
28
|
-
const txWithMemoTag = transactionIntent as TransactionIntent<MapMemo<string, string>>;
|
29
|
-
const txMemo = String(transaction["tag"]);
|
30
|
-
|
31
|
-
txWithMemoTag.memo = {
|
32
|
-
type: "map",
|
33
|
-
memos: new Map(),
|
34
|
-
};
|
35
|
-
txWithMemoTag.memo.memos.set("destinationTag", txMemo);
|
36
|
-
|
37
|
-
return txWithMemoTag;
|
38
|
-
}
|
39
|
-
|
40
|
-
// Handle Stellar-style memo
|
41
|
-
if (transaction["memoType"] && transaction["memoValue"]) {
|
42
|
-
const txWithMemo = transactionIntent as TransactionIntent<StellarMemo>;
|
43
|
-
const txMemoType = String(transaction["memoType"]);
|
44
|
-
const txMemoValue = String(transaction["memoValue"]);
|
45
|
-
|
46
|
-
txWithMemo.memo = {
|
47
|
-
type: txMemoType as "NO_MEMO" | "MEMO_TEXT" | "MEMO_ID" | "MEMO_HASH" | "MEMO_RETURN",
|
48
|
-
value: txMemoValue,
|
49
|
-
};
|
50
|
-
|
51
|
-
return txWithMemo;
|
52
|
-
}
|
53
|
-
|
54
|
-
return transactionIntent;
|
55
|
-
}
|
56
|
-
|
57
|
-
/**
|
58
|
-
* Enriches transaction intent with memo and asset information
|
59
|
-
*/
|
60
|
-
function enrichTransactionIntent(
|
61
|
-
transactionIntent: TransactionIntent<any>,
|
62
|
-
transaction: TransactionCommon,
|
63
|
-
publicKey: string,
|
64
|
-
): TransactionIntent<any> {
|
65
|
-
// Set sender public key
|
66
|
-
transactionIntent.senderPublicKey = publicKey;
|
67
|
-
|
68
|
-
// Apply memo information
|
69
|
-
transactionIntent = applyMemoToIntent(transactionIntent, transaction);
|
70
|
-
|
71
|
-
return transactionIntent;
|
72
|
-
}
|
73
16
|
/**
|
74
17
|
* Sign Transaction with Ledger hardware
|
75
18
|
*/
|
76
19
|
export const genericSignOperation =
|
77
|
-
(network, kind) =>
|
20
|
+
(network: string, kind: "local" | "remote") =>
|
78
21
|
(signerContext: SignerContext<any>): AccountBridge<TransactionCommon>["signOperation"] =>
|
79
22
|
({
|
80
23
|
account,
|
@@ -87,40 +30,30 @@ export const genericSignOperation =
|
|
87
30
|
}): Observable<SignOperationEvent> =>
|
88
31
|
new Observable(o => {
|
89
32
|
async function main() {
|
90
|
-
// NOTE: checking field that's not inside TransactionCommon, improve
|
91
33
|
if (!transaction["fees"]) throw new FeeNotLoaded();
|
92
|
-
|
93
|
-
if (transaction["useAllAmount"]) {
|
94
|
-
const draftTransaction = {
|
95
|
-
recipient: transaction.recipient,
|
96
|
-
amount: transaction.amount ?? 0,
|
97
|
-
fees: fees,
|
98
|
-
useAllAmount: !!transaction.useAllAmount,
|
99
|
-
assetReference: transaction?.["assetReference"] || "",
|
100
|
-
assetOwner: transaction?.["assetOwner"] || "",
|
101
|
-
subAccountId: transaction.subAccountId || "",
|
102
|
-
};
|
103
|
-
const { amount } = await getAlpacaApi(network, kind).validateIntent(
|
104
|
-
transactionToIntent(account, draftTransaction),
|
105
|
-
);
|
106
|
-
transaction.amount = new BigNumber(amount.toString());
|
107
|
-
}
|
34
|
+
|
108
35
|
const signedInfo = await signerContext(deviceId, async signer => {
|
109
36
|
const derivationPath = account.freshAddressPath;
|
37
|
+
|
110
38
|
const { publicKey } = (await signer.getAddress(derivationPath)) as Result;
|
111
39
|
|
112
|
-
|
40
|
+
const transactionIntent = transactionToIntent(account, transaction);
|
113
41
|
transactionIntent.senderPublicKey = publicKey;
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
42
|
+
// NOTE: is setting the memo here instead of transactionToIntent sensible?
|
43
|
+
const txWithMemo = transactionIntent as TransactionIntent<MapMemo<string, string>>;
|
44
|
+
if (transaction["tag"]) {
|
45
|
+
const txMemo = String(transaction["tag"]);
|
46
|
+
txWithMemo.memo = {
|
47
|
+
type: "map",
|
48
|
+
memos: new Map(),
|
49
|
+
};
|
50
|
+
txWithMemo.memo.memos.set("destinationTag", txMemo);
|
51
|
+
}
|
52
|
+
|
53
|
+
const accountInfo = await getAlpacaApi(network, kind).getAccountInfo(
|
120
54
|
transactionIntent.sender,
|
121
55
|
);
|
122
|
-
transactionIntent.sequence =
|
123
|
-
|
56
|
+
transactionIntent.sequence = accountInfo.sequence;
|
124
57
|
/* Craft unsigned blob via Alpaca */
|
125
58
|
const unsigned: string = await getAlpacaApi(network, kind).craftTransaction(
|
126
59
|
transactionIntent,
|
@@ -143,8 +76,8 @@ export const genericSignOperation =
|
|
143
76
|
signedInfo.txnSig,
|
144
77
|
signedInfo.publicKey,
|
145
78
|
);
|
146
|
-
const operation = buildOptimisticOperation(account, transaction, signedInfo.sequence);
|
147
79
|
|
80
|
+
const operation = buildOptimisticOperation(account, transaction, signedInfo.sequence);
|
148
81
|
// NOTE: we set the transactionSequenceNumber before on the operation
|
149
82
|
// now that we create it in craftTransaction, we might need to return it back from craftTransaction also
|
150
83
|
o.next({
|
@@ -1,15 +1,12 @@
|
|
1
1
|
import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
|
2
2
|
import xrpGetAddress from "@ledgerhq/coin-xrp/signer/getAddress";
|
3
|
-
import stellarGetAddress from "@ledgerhq/coin-stellar/signer/getAddress";
|
4
3
|
import { CreateSigner, executeWithSigner } from "../../setup";
|
5
4
|
import Xrp from "@ledgerhq/hw-app-xrp";
|
6
|
-
import Stellar from "@ledgerhq/hw-app-str";
|
7
5
|
|
8
6
|
import Transport from "@ledgerhq/hw-transport";
|
9
|
-
import { signTransaction
|
7
|
+
import { signTransaction } from "./signTransaction";
|
10
8
|
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
11
9
|
import { SignTransactionOptions } from "./types";
|
12
|
-
import { StrKey } from "@stellar/stellar-sdk";
|
13
10
|
|
14
11
|
export type AlpacaSigner = {
|
15
12
|
getAddress: GetAddressFn;
|
@@ -18,50 +15,17 @@ export type AlpacaSigner = {
|
|
18
15
|
context: SignerContext<any>;
|
19
16
|
};
|
20
17
|
|
21
|
-
|
22
|
-
return new Xrp(transport);
|
23
|
-
};
|
24
|
-
const signerContextXrp = executeWithSigner(createSignerXrp);
|
25
|
-
|
26
|
-
const createSignerStellar: CreateSigner<Stellar> = (transport: Transport) => {
|
27
|
-
const stellar = new Stellar(transport);
|
28
|
-
const originalSignTransaction = stellar.signTransaction;
|
29
|
-
// Return the original Stellar instance with overridden methods
|
30
|
-
return Object.assign(stellar, {
|
31
|
-
signTransaction: async (path: string, transaction: string) => {
|
32
|
-
const unsignedPayload: Buffer = Buffer.from(transaction, "base64");
|
33
|
-
const { signature } = await originalSignTransaction(path, unsignedPayload);
|
34
|
-
return signature.toString("base64");
|
35
|
-
},
|
36
|
-
getAddress: async (path: string, verify?: boolean) => {
|
37
|
-
const { rawPublicKey } = await stellar.getPublicKey(path, verify);
|
38
|
-
const publicKey = StrKey.encodeEd25519PublicKey(rawPublicKey);
|
39
|
-
return {
|
40
|
-
path,
|
41
|
-
address: publicKey,
|
42
|
-
publicKey: publicKey,
|
43
|
-
};
|
44
|
-
},
|
45
|
-
});
|
46
|
-
};
|
47
|
-
|
48
|
-
const signerContextStellar = executeWithSigner(createSignerStellar);
|
49
|
-
|
50
|
-
export function getSigner(network): AlpacaSigner {
|
18
|
+
export function getSigner(network: string): AlpacaSigner {
|
51
19
|
switch (network) {
|
52
20
|
case "ripple":
|
53
21
|
case "xrp": {
|
54
|
-
|
55
|
-
|
56
|
-
signTransaction: signTransaction(signerContextXrp),
|
57
|
-
context: signerContextXrp,
|
22
|
+
const createSigner: CreateSigner<Xrp> = (transport: Transport) => {
|
23
|
+
return new Xrp(transport);
|
58
24
|
};
|
59
|
-
}
|
60
|
-
case "stellar": {
|
61
25
|
return {
|
62
|
-
getAddress:
|
63
|
-
signTransaction:
|
64
|
-
context:
|
26
|
+
getAddress: xrpGetAddress(executeWithSigner(createSigner)),
|
27
|
+
signTransaction: signTransaction(executeWithSigner(createSigner)),
|
28
|
+
context: executeWithSigner(createSigner),
|
65
29
|
};
|
66
30
|
}
|
67
31
|
}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
2
2
|
import { XrpSigner } from "@ledgerhq/coin-xrp/index";
|
3
3
|
import { SignTransactionOptions } from "./types";
|
4
|
-
import { StellarSigner } from "@ledgerhq/coin-stellar/types/signer";
|
5
4
|
|
6
5
|
export const signTransaction = (signerContext: SignerContext<XrpSigner>) => {
|
7
6
|
return async (deviceId: string, { path, rawTxHex }: SignTransactionOptions) => {
|
@@ -12,13 +11,3 @@ export const signTransaction = (signerContext: SignerContext<XrpSigner>) => {
|
|
12
11
|
return signedTx;
|
13
12
|
};
|
14
13
|
};
|
15
|
-
|
16
|
-
export const stellarSignTransaction = (signerContext: SignerContext<StellarSigner>) => {
|
17
|
-
return async (deviceId: string, { path, transaction }: SignTransactionOptions) => {
|
18
|
-
const signedTx = await signerContext(deviceId, signer =>
|
19
|
-
signer.signTransaction(path, transaction),
|
20
|
-
);
|
21
|
-
|
22
|
-
return signedTx.signature.toString("base64"); // It should return a Buffer
|
23
|
-
};
|
24
|
-
};
|
@@ -11,91 +11,66 @@ jest.mock("../alpaca", () => ({
|
|
11
11
|
const mockedGetAlpacaApi = alpaca.getAlpacaApi as jest.Mock;
|
12
12
|
|
13
13
|
// Dummy data
|
14
|
-
const
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
freshAddress: "r123",
|
22
|
-
pendingOperations: [],
|
23
|
-
},
|
24
|
-
{
|
25
|
-
id: "js:2:stellar:s123:",
|
26
|
-
type: "Account",
|
27
|
-
spendableBalance: new BigNumber(50000000),
|
28
|
-
balance: new BigNumber(60000000),
|
29
|
-
currency: {
|
30
|
-
id: "stellar",
|
31
|
-
family: "stellar",
|
32
|
-
name: "Stellar",
|
33
|
-
units: [{ name: "XLM", magnitude: 7 }],
|
34
|
-
},
|
35
|
-
freshAddress: "s123",
|
36
|
-
pendingOperations: [],
|
37
|
-
},
|
38
|
-
] as unknown as Account[];
|
14
|
+
const dummyAccount = {
|
15
|
+
id: "js:2:ripple:r123:",
|
16
|
+
type: "Account", // <-- this is mandatory for getMainAccount to work
|
17
|
+
spendableBalance: new BigNumber(50000000),
|
18
|
+
currency: { id: "ripple", name: "XRP", units: [{ name: "XRP", magnitude: 6 }] },
|
19
|
+
freshAddress: "r123",
|
20
|
+
} as unknown as Account;
|
39
21
|
|
40
|
-
|
41
|
-
|
42
|
-
|
22
|
+
describe("genericEstimateMaxSpendable", () => {
|
23
|
+
afterEach(() => {
|
24
|
+
jest.clearAllMocks();
|
25
|
+
});
|
43
26
|
|
44
|
-
|
45
|
-
|
27
|
+
it("subtracts estimated fee from spendable balance", async () => {
|
28
|
+
mockedGetAlpacaApi.mockReturnValue({
|
29
|
+
estimateFees: jest.fn().mockResolvedValue({ value: 10000n }), // 0.01 XRP
|
46
30
|
});
|
47
31
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
}
|
53
|
-
|
54
|
-
const estimate = genericEstimateMaxSpendable(currencyName, "local");
|
55
|
-
const result = await estimate({
|
56
|
-
account: dummyAccount,
|
57
|
-
parentAccount: null,
|
58
|
-
transaction: {},
|
59
|
-
});
|
60
|
-
|
61
|
-
expect(result.toString()).toBe("49990000");
|
32
|
+
const estimate = genericEstimateMaxSpendable("xrp", "local");
|
33
|
+
const result = await estimate({
|
34
|
+
account: dummyAccount,
|
35
|
+
parentAccount: null,
|
36
|
+
transaction: {},
|
62
37
|
});
|
63
38
|
|
64
|
-
|
65
|
-
|
66
|
-
...dummyAccount,
|
67
|
-
spendableBalance: new BigNumber(5000),
|
68
|
-
};
|
39
|
+
expect(result.toString()).toBe("49990000"); // 50_000_000 - 10_000
|
40
|
+
});
|
69
41
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
42
|
+
it("returns 0 if fee is higher than spendable", async () => {
|
43
|
+
const poorAccount = {
|
44
|
+
...dummyAccount,
|
45
|
+
spendableBalance: new BigNumber(5000), // very low
|
46
|
+
};
|
74
47
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
parentAccount: null,
|
79
|
-
transaction: {},
|
80
|
-
});
|
48
|
+
mockedGetAlpacaApi.mockReturnValue({
|
49
|
+
estimateFees: jest.fn().mockResolvedValue({ value: 10000n }),
|
50
|
+
});
|
81
51
|
|
82
|
-
|
52
|
+
const estimate = genericEstimateMaxSpendable("xrp", "local");
|
53
|
+
const result = await estimate({
|
54
|
+
account: poorAccount,
|
55
|
+
parentAccount: null,
|
56
|
+
transaction: {},
|
83
57
|
});
|
84
58
|
|
85
|
-
|
86
|
-
|
87
|
-
estimateFees: jest.fn().mockResolvedValue({ value: 0n }),
|
88
|
-
validateIntent: jest.fn().mockResolvedValue({ amount: 50000000n }),
|
89
|
-
});
|
59
|
+
expect(result.toString()).toBe("0");
|
60
|
+
});
|
90
61
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
transaction: {},
|
96
|
-
});
|
62
|
+
it("returns full spendable balance if fee is 0", async () => {
|
63
|
+
mockedGetAlpacaApi.mockReturnValue({
|
64
|
+
estimateFees: jest.fn().mockResolvedValue({ value: 0n }),
|
65
|
+
});
|
97
66
|
|
98
|
-
|
67
|
+
const estimate = genericEstimateMaxSpendable("xrp", "local");
|
68
|
+
const result = await estimate({
|
69
|
+
account: dummyAccount,
|
70
|
+
parentAccount: null,
|
71
|
+
transaction: {},
|
99
72
|
});
|
73
|
+
|
74
|
+
expect(result.toString()).toBe("50000000");
|
100
75
|
});
|
101
76
|
});
|
@@ -47,7 +47,7 @@ describe("genericPrepareTransaction", () => {
|
|
47
47
|
expect((result as any).fees.toString()).toBe(newFee.toString());
|
48
48
|
expect(transactionToIntent).toHaveBeenCalledWith(
|
49
49
|
account,
|
50
|
-
expect.objectContaining(
|
50
|
+
expect.objectContaining(baseTransaction),
|
51
51
|
);
|
52
52
|
});
|
53
53
|
|
@@ -13,8 +13,9 @@ jest.mock("../utils", () => ({
|
|
13
13
|
buildOptimisticOperation: jest.fn(),
|
14
14
|
transactionToIntent: jest.fn(),
|
15
15
|
}));
|
16
|
+
|
16
17
|
describe("genericSignOperation", () => {
|
17
|
-
const
|
18
|
+
const network = "xrp";
|
18
19
|
const kind = "local";
|
19
20
|
|
20
21
|
const mockSignerContext = jest.fn();
|
@@ -54,7 +55,6 @@ describe("genericSignOperation", () => {
|
|
54
55
|
craftTransaction: jest.fn().mockResolvedValue(unsignedTx),
|
55
56
|
getAccountInfo: jest.fn().mockResolvedValue(pubKey),
|
56
57
|
combine: jest.fn().mockResolvedValue(signedTx),
|
57
|
-
getSequence: jest.fn().mockResolvedValue(1),
|
58
58
|
});
|
59
59
|
|
60
60
|
(transactionToIntent as jest.Mock).mockReturnValue(txIntent);
|
@@ -65,35 +65,33 @@ describe("genericSignOperation", () => {
|
|
65
65
|
mockSignerContext.mockImplementation(async (_deviceId, cb) => cb(mockSigner));
|
66
66
|
});
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
},
|
83
|
-
});
|
84
|
-
|
85
|
-
expect(transactionToIntent).toHaveBeenCalledWith(account, transaction);
|
86
|
-
expect(txIntent.memo.memos.get("destinationTag")).toBe("1234");
|
68
|
+
it("emits full sign operation flow", async () => {
|
69
|
+
const signOperation = genericSignOperation(network, kind)(mockSignerContext);
|
70
|
+
const observable = signOperation({ account, transaction, deviceId });
|
71
|
+
|
72
|
+
const events = await lastValueFrom(observable.pipe(toArray()));
|
73
|
+
|
74
|
+
expect(events[0]).toEqual({ type: "device-signature-requested" });
|
75
|
+
expect(events[1]).toEqual({ type: "device-signature-granted" });
|
76
|
+
expect(events[2]).toEqual({
|
77
|
+
type: "signed",
|
78
|
+
signedOperation: {
|
79
|
+
operation: { id: "mock-op" },
|
80
|
+
signature: signedTx,
|
81
|
+
},
|
87
82
|
});
|
88
83
|
|
89
|
-
|
90
|
-
|
91
|
-
|
84
|
+
expect(transactionToIntent).toHaveBeenCalledWith(account, transaction);
|
85
|
+
expect(txIntent.memo.memos.get("destinationTag")).toBe("1234");
|
86
|
+
});
|
92
87
|
|
93
|
-
|
94
|
-
|
88
|
+
it("throws FeeNotLoaded if fees are missing", async () => {
|
89
|
+
const txWithoutFees = { ...transaction };
|
90
|
+
delete txWithoutFees.fees;
|
95
91
|
|
96
|
-
|
97
|
-
});
|
92
|
+
const signOperation = genericSignOperation(network, kind)(mockSignerContext);
|
93
|
+
const observable = signOperation({ account, transaction: txWithoutFees, deviceId });
|
94
|
+
|
95
|
+
await expect(observable.toPromise()).rejects.toThrow(FeeNotLoaded);
|
98
96
|
});
|
99
97
|
});
|