@ledgerhq/live-common 34.54.0-nightly.20251204135727 → 34.54.0-nightly.20251205111238
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/broadcast.js +3 -3
- package/lib/bridge/generic-alpaca/broadcast.js.map +1 -1
- package/lib/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/currencyBridge.js +1 -3
- package/lib/bridge/generic-alpaca/currencyBridge.js.map +1 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.js +2 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.js +16 -7
- package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js +16 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.js +38 -4
- package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js +18 -2
- package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib/bridge/generic-alpaca/signer/Eth.d.ts +2 -0
- package/lib/bridge/generic-alpaca/signer/Eth.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signer/Eth.js +8 -1
- package/lib/bridge/generic-alpaca/signer/Eth.js.map +1 -1
- package/lib/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signer/index.js +7 -0
- package/lib/bridge/generic-alpaca/signer/index.js.map +1 -1
- package/lib/bridge/generic-alpaca/types.d.ts +4 -0
- package/lib/bridge/generic-alpaca/types.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.js +11 -3
- package/lib/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib/bridge/impl.d.ts.map +1 -1
- package/lib/bridge/impl.js +14 -3
- package/lib/bridge/impl.js.map +1 -1
- package/lib/currencies/helpers.d.ts +1 -0
- package/lib/currencies/helpers.d.ts.map +1 -1
- package/lib/currencies/helpers.js +7 -1
- package/lib/currencies/helpers.js.map +1 -1
- package/lib/families/canton/config.d.ts.map +1 -1
- package/lib/families/canton/config.js +4 -4
- package/lib/families/canton/config.js.map +1 -1
- package/lib/families/celo/setup.d.ts.map +1 -1
- package/lib/families/celo/setup.js +11 -0
- package/lib/families/celo/setup.js.map +1 -1
- package/lib/families/evm/bridge/mock.d.ts +1 -0
- package/lib/families/evm/bridge/mock.d.ts.map +1 -1
- package/lib/families/evm/bridge/mock.js +12 -0
- package/lib/families/evm/bridge/mock.js.map +1 -1
- package/lib/families/evm/setup.d.ts +1 -4
- package/lib/families/evm/setup.d.ts.map +1 -1
- package/lib/families/evm/setup.js +1 -8
- package/lib/families/evm/setup.js.map +1 -1
- package/lib/families/evm/walletApiAdapter.d.ts +7 -0
- package/lib/families/evm/walletApiAdapter.d.ts.map +1 -1
- package/lib/families/evm/walletApiAdapter.js +36 -2
- package/lib/families/evm/walletApiAdapter.js.map +1 -1
- package/lib/families/stacks/constants.d.ts +1 -1
- package/lib/families/stacks/constants.d.ts.map +1 -1
- package/lib/families/stacks/constants.js +1 -1
- package/lib/families/stacks/constants.js.map +1 -1
- package/lib/generated/bridge/js.d.ts +0 -1
- package/lib/generated/bridge/js.d.ts.map +1 -1
- package/lib/generated/bridge/js.js +30 -32
- package/lib/generated/bridge/js.js.map +1 -1
- package/lib/generated/bridge/mock.d.ts +1 -0
- package/lib/generated/bridge/mock.d.ts.map +1 -1
- package/lib/operation.d.ts.map +1 -1
- package/lib/operation.js +7 -2
- package/lib/operation.js.map +1 -1
- package/lib/wallet-api/constants.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/broadcast.js +3 -3
- package/lib-es/bridge/generic-alpaca/broadcast.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/currencyBridge.js +1 -3
- package/lib-es/bridge/generic-alpaca/currencyBridge.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js +2 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.js +16 -7
- package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +16 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js +38 -4
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js +18 -2
- package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/Eth.d.ts +2 -0
- package/lib-es/bridge/generic-alpaca/signer/Eth.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/Eth.js +4 -0
- package/lib-es/bridge/generic-alpaca/signer/Eth.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/index.js +7 -0
- package/lib-es/bridge/generic-alpaca/signer/index.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/types.d.ts +4 -0
- package/lib-es/bridge/generic-alpaca/types.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js +11 -3
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib-es/bridge/impl.d.ts.map +1 -1
- package/lib-es/bridge/impl.js +14 -3
- package/lib-es/bridge/impl.js.map +1 -1
- package/lib-es/currencies/helpers.d.ts +1 -0
- package/lib-es/currencies/helpers.d.ts.map +1 -1
- package/lib-es/currencies/helpers.js +5 -0
- package/lib-es/currencies/helpers.js.map +1 -1
- package/lib-es/families/canton/config.d.ts.map +1 -1
- package/lib-es/families/canton/config.js +4 -4
- package/lib-es/families/canton/config.js.map +1 -1
- package/lib-es/families/celo/setup.d.ts.map +1 -1
- package/lib-es/families/celo/setup.js +11 -0
- package/lib-es/families/celo/setup.js.map +1 -1
- package/lib-es/families/evm/bridge/mock.d.ts +1 -0
- package/lib-es/families/evm/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/evm/bridge/mock.js +12 -0
- package/lib-es/families/evm/bridge/mock.js.map +1 -1
- package/lib-es/families/evm/setup.d.ts +1 -4
- package/lib-es/families/evm/setup.d.ts.map +1 -1
- package/lib-es/families/evm/setup.js +2 -8
- package/lib-es/families/evm/setup.js.map +1 -1
- package/lib-es/families/evm/walletApiAdapter.d.ts +7 -0
- package/lib-es/families/evm/walletApiAdapter.d.ts.map +1 -1
- package/lib-es/families/evm/walletApiAdapter.js +30 -1
- package/lib-es/families/evm/walletApiAdapter.js.map +1 -1
- package/lib-es/families/stacks/constants.d.ts +1 -1
- package/lib-es/families/stacks/constants.d.ts.map +1 -1
- package/lib-es/families/stacks/constants.js +1 -1
- package/lib-es/families/stacks/constants.js.map +1 -1
- package/lib-es/generated/bridge/js.d.ts +0 -1
- package/lib-es/generated/bridge/js.d.ts.map +1 -1
- package/lib-es/generated/bridge/js.js +0 -2
- package/lib-es/generated/bridge/js.js.map +1 -1
- package/lib-es/generated/bridge/mock.d.ts +1 -0
- package/lib-es/generated/bridge/mock.d.ts.map +1 -1
- package/lib-es/operation.d.ts.map +1 -1
- package/lib-es/operation.js +7 -2
- package/lib-es/operation.js.map +1 -1
- package/lib-es/wallet-api/constants.d.ts +1 -1
- package/package.json +57 -57
- package/src/bridge/generic-alpaca/broadcast.ts +6 -3
- package/src/bridge/generic-alpaca/currencyBridge.ts +1 -3
- package/src/bridge/generic-alpaca/estimateMaxSpendable.ts +2 -1
- package/src/bridge/generic-alpaca/getAccountShape.ts +24 -12
- package/src/bridge/generic-alpaca/getTransactionStatus.ts +16 -1
- package/src/bridge/generic-alpaca/prepareTransaction.ts +44 -10
- package/src/bridge/generic-alpaca/signOperation.ts +18 -2
- package/src/bridge/generic-alpaca/signer/Eth.ts +5 -1
- package/src/bridge/generic-alpaca/signer/index.ts +7 -0
- package/src/bridge/generic-alpaca/tests/getAccountShape.test.ts +2 -2
- package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +32 -0
- package/src/bridge/generic-alpaca/types.ts +4 -0
- package/src/bridge/generic-alpaca/utils.test.ts +1 -0
- package/src/bridge/generic-alpaca/utils.ts +14 -3
- package/src/bridge/impl.ts +16 -3
- package/src/currencies/helpers.test.ts +10 -1
- package/src/currencies/helpers.ts +6 -0
- package/src/families/canton/config.ts +5 -4
- package/src/families/celo/setup.ts +12 -0
- package/src/families/evm/bridge/mock.ts +14 -0
- package/src/families/evm/setup.ts +3 -22
- package/src/families/evm/walletApiAdapter.ts +33 -1
- package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +57 -11
- package/src/families/stacks/__snapshots__/bridge.integration.test.ts.snap +1537 -18
- package/src/families/stacks/__tests__/sync.integration.test.ts +2 -2
- package/src/families/stacks/constants.ts +1 -1
- package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +9 -9
- package/src/generated/bridge/js.ts +0 -2
- package/src/operation.ts +10 -2
|
@@ -72,6 +72,7 @@ export function adaptCoreOperationToLiveOperation(accountId: string, op: CoreOpe
|
|
|
72
72
|
parentRecipients?: string[];
|
|
73
73
|
ledgerOpType?: string | undefined;
|
|
74
74
|
memo?: string | undefined;
|
|
75
|
+
internal?: boolean;
|
|
75
76
|
} = {};
|
|
76
77
|
|
|
77
78
|
if (op.details?.ledgerOpType !== undefined) {
|
|
@@ -106,6 +107,11 @@ export function adaptCoreOperationToLiveOperation(accountId: string, op: CoreOpe
|
|
|
106
107
|
if (op.details?.memo) {
|
|
107
108
|
extra.memo = op.details.memo as string;
|
|
108
109
|
}
|
|
110
|
+
|
|
111
|
+
if (op.details?.internal === true) {
|
|
112
|
+
extra.internal = op.details?.internal;
|
|
113
|
+
}
|
|
114
|
+
|
|
109
115
|
const bnFees = new BigNumber(op.tx.fees.toString());
|
|
110
116
|
const hasFailed = op.tx.failed;
|
|
111
117
|
|
|
@@ -214,6 +220,7 @@ export function transactionToIntent(
|
|
|
214
220
|
transaction.nonce !== null && transaction.nonce !== undefined
|
|
215
221
|
? BigInt(transaction.nonce.toString())
|
|
216
222
|
: undefined,
|
|
223
|
+
sponsored: transaction.sponsored,
|
|
217
224
|
};
|
|
218
225
|
if (transaction.assetReference && transaction.assetOwner) {
|
|
219
226
|
const { subAccountId } = transaction;
|
|
@@ -265,8 +272,11 @@ function toGenericTransactionRaw(transaction: GenericTransaction): GenericTransa
|
|
|
265
272
|
family: transaction.family,
|
|
266
273
|
};
|
|
267
274
|
|
|
268
|
-
|
|
269
|
-
|
|
275
|
+
const booleanFieldsToPropagate = ["useAllAmount", "sponsored"] as const;
|
|
276
|
+
for (const field of booleanFieldsToPropagate) {
|
|
277
|
+
if (field in transaction) {
|
|
278
|
+
raw[field] = transaction[field];
|
|
279
|
+
}
|
|
270
280
|
}
|
|
271
281
|
|
|
272
282
|
const stringFieldsToPropagate = [
|
|
@@ -296,6 +306,7 @@ function toGenericTransactionRaw(transaction: GenericTransaction): GenericTransa
|
|
|
296
306
|
"gasPrice",
|
|
297
307
|
"maxFeePerGas",
|
|
298
308
|
"maxPriorityFeePerGas",
|
|
309
|
+
"additionalFees",
|
|
299
310
|
] as const;
|
|
300
311
|
for (const field of bigNumberFieldsToPropagate) {
|
|
301
312
|
if (field in transaction) {
|
|
@@ -407,7 +418,7 @@ export const buildOptimisticOperation = (
|
|
|
407
418
|
hash: "",
|
|
408
419
|
type,
|
|
409
420
|
value: transaction.useAllAmount ? tokenAccount.balance : transaction.amount,
|
|
410
|
-
fee: new BigNumber(
|
|
421
|
+
fee: new BigNumber(fees.toString()),
|
|
411
422
|
blockHash: null,
|
|
412
423
|
blockHeight: null,
|
|
413
424
|
senders: [account.freshAddress],
|
package/src/bridge/impl.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { AddressesSanctionedError } from "@ledgerhq/coin-framework/sanction/erro
|
|
|
23
23
|
// Removed: stores are now managed globally by @ledgerhq/cryptoassets/cal-client/store
|
|
24
24
|
|
|
25
25
|
const alpacaized = {
|
|
26
|
+
evm: true,
|
|
26
27
|
xrp: true,
|
|
27
28
|
stellar: true,
|
|
28
29
|
tezos: true,
|
|
@@ -35,7 +36,13 @@ const currencyBridgeCache: Record<string, CurrencyBridge> = {};
|
|
|
35
36
|
export const getCurrencyBridge = (currency: CryptoCurrency): CurrencyBridge => {
|
|
36
37
|
if (getEnv("MOCK")) {
|
|
37
38
|
const mockBridge = mockBridges[currency.family];
|
|
38
|
-
|
|
39
|
+
// TODO Remove once we delete mock bridges tests
|
|
40
|
+
if (mockBridge) {
|
|
41
|
+
if (typeof mockBridge.loadCoinConfig === "function") {
|
|
42
|
+
mockBridge.loadCoinConfig();
|
|
43
|
+
}
|
|
44
|
+
return mockBridge.currencyBridge;
|
|
45
|
+
}
|
|
39
46
|
throw new CurrencyNotSupported("no mock implementation available for currency " + currency.id, {
|
|
40
47
|
currencyName: currency.id,
|
|
41
48
|
});
|
|
@@ -85,13 +92,19 @@ export function getAccountBridgeByFamily(family: string, accountId?: string): Ac
|
|
|
85
92
|
|
|
86
93
|
if (type === "mock") {
|
|
87
94
|
const mockBridge = mockBridges[family];
|
|
88
|
-
|
|
95
|
+
// TODO Remove once we delete mock bridges tests
|
|
96
|
+
if (mockBridge) {
|
|
97
|
+
if (typeof mockBridge.loadCoinConfig === "function") {
|
|
98
|
+
mockBridge.loadCoinConfig();
|
|
99
|
+
}
|
|
100
|
+
return wrapAccountBridge(mockBridge.accountBridge);
|
|
101
|
+
}
|
|
89
102
|
}
|
|
90
103
|
}
|
|
91
104
|
|
|
92
105
|
if (alpacaized[family]) {
|
|
93
106
|
if (!bridgeCache[family]) {
|
|
94
|
-
bridgeCache[family] = getAlpacaAccountBridge(family, "local");
|
|
107
|
+
bridgeCache[family] = wrapAccountBridge(getAlpacaAccountBridge(family, "local"));
|
|
95
108
|
}
|
|
96
109
|
return bridgeCache[family];
|
|
97
110
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../__tests__/test-helpers/setup";
|
|
2
|
-
import { isCryptoCurrency } from "./helpers";
|
|
2
|
+
import { isCryptoCurrency, getFamilyByCurrencyId } from "./helpers";
|
|
3
3
|
import { listCryptoCurrencies } from ".";
|
|
4
4
|
|
|
5
5
|
describe("Currencies helpers", () => {
|
|
@@ -10,4 +10,13 @@ describe("Currencies helpers", () => {
|
|
|
10
10
|
expect(isCryptoCurrency(currency)).toBeTruthy();
|
|
11
11
|
});
|
|
12
12
|
});
|
|
13
|
+
|
|
14
|
+
test("getFamilyByCurrencyId returns correct family for a known currency id", () => {
|
|
15
|
+
expect(getFamilyByCurrencyId("bitcoin")).toBe("bitcoin");
|
|
16
|
+
expect(getFamilyByCurrencyId("ethereum")).toBe("evm");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("getFamilyByCurrencyId returns undefined for an unknown currency id", () => {
|
|
20
|
+
expect(getFamilyByCurrencyId("unknown_currency_id")).toBeUndefined();
|
|
21
|
+
});
|
|
13
22
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Currency, CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
|
+
import { findCryptoCurrencyById } from "@ledgerhq/cryptoassets";
|
|
2
3
|
|
|
3
4
|
export function isCryptoCurrency(currency: Currency): currency is CryptoCurrency {
|
|
4
5
|
return currency.type === "CryptoCurrency";
|
|
@@ -15,3 +16,8 @@ export function isUTXOCompliant(currencyFamily: string): boolean {
|
|
|
15
16
|
export type CurrencyFilters = {
|
|
16
17
|
currencies?: string[];
|
|
17
18
|
};
|
|
19
|
+
|
|
20
|
+
export function getFamilyByCurrencyId(currencyId: string): CryptoCurrency["family"] | undefined {
|
|
21
|
+
const currency = findCryptoCurrencyById(currencyId);
|
|
22
|
+
return currency?.family;
|
|
23
|
+
}
|
|
@@ -23,9 +23,9 @@ export const cantonConfig: Record<string, ConfigInfo> = {
|
|
|
23
23
|
status: {
|
|
24
24
|
type: "active",
|
|
25
25
|
},
|
|
26
|
-
nodeUrl: "https://canton-gateway.api.live.ledger.com/v1/node/ledger-live-devnet",
|
|
26
|
+
nodeUrl: "https://canton-gateway-devnet.api.live.ledger-test.com/v1/node/ledger-live-devnet",
|
|
27
27
|
nodeId: "ledger-live-devnet",
|
|
28
|
-
gatewayUrl: "https://canton-gateway.api.live.ledger-test.com",
|
|
28
|
+
gatewayUrl: "https://canton-gateway-devnet.api.live.ledger-test.com",
|
|
29
29
|
minReserve: 0,
|
|
30
30
|
useGateway: true,
|
|
31
31
|
networkType: "devnet",
|
|
@@ -39,9 +39,10 @@ export const cantonConfig: Record<string, ConfigInfo> = {
|
|
|
39
39
|
status: {
|
|
40
40
|
type: "active",
|
|
41
41
|
},
|
|
42
|
-
nodeUrl:
|
|
42
|
+
nodeUrl:
|
|
43
|
+
"https://canton-gateway-testnet.api.live.ledger-test.com/v1/node/ledger-live-testnet",
|
|
43
44
|
nodeId: "ledger-live-testnet",
|
|
44
|
-
gatewayUrl: "https://canton-gateway.api.live.ledger-test.com",
|
|
45
|
+
gatewayUrl: "https://canton-gateway-testnet.api.live.ledger-test.com",
|
|
45
46
|
minReserve: 0,
|
|
46
47
|
nativeInstrumentId: "Amulet",
|
|
47
48
|
useGateway: true,
|
|
@@ -10,9 +10,21 @@ import { CreateSigner, createResolver, executeWithSigner } from "../../bridge/se
|
|
|
10
10
|
import type { Resolver } from "../../hw/getAddress/types";
|
|
11
11
|
import { Transaction, CeloAccount } from "./types";
|
|
12
12
|
import { CeloSigner } from "@ledgerhq/coin-celo/signer";
|
|
13
|
+
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
|
|
14
|
+
import { createApi as createEvmApi } from "@ledgerhq/coin-evm/api/index";
|
|
15
|
+
import { getCurrencyConfiguration } from "../../config";
|
|
16
|
+
import type { EvmConfigInfo } from "@ledgerhq/coin-evm/config";
|
|
13
17
|
|
|
14
18
|
const createSigner: CreateSigner<CeloSigner> = (transport: Transport) => new Celo(transport);
|
|
15
19
|
|
|
20
|
+
// NOTE Create an unused instance of EVM API with Celo configuration.
|
|
21
|
+
// It has the side effect of initializing the EVM coin config as well as injecting
|
|
22
|
+
// the input Celo config.
|
|
23
|
+
// TODO Remove this hack while deleting the Celo bridge
|
|
24
|
+
const getCurrencyConfig = () => {
|
|
25
|
+
return { info: getCurrencyConfiguration<EvmConfigInfo>(getCryptoCurrencyById("celo")) };
|
|
26
|
+
};
|
|
27
|
+
createEvmApi(getCurrencyConfig, "celo");
|
|
16
28
|
const bridge: Bridge<Transaction, CeloAccount> = createBridges(executeWithSigner(createSigner));
|
|
17
29
|
|
|
18
30
|
const resolver: Resolver = createResolver(createSigner, CeloResolver);
|
|
@@ -17,6 +17,9 @@ import {
|
|
|
17
17
|
} from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
18
18
|
import { getGasLimit } from "@ledgerhq/coin-evm/utils";
|
|
19
19
|
import { getTypedTransaction } from "@ledgerhq/coin-evm/transaction";
|
|
20
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
21
|
+
import { getCurrencyConfiguration } from "../../../config";
|
|
22
|
+
import { EvmConfigInfo, setCoinConfig } from "@ledgerhq/coin-evm/config";
|
|
20
23
|
const receive = makeAccountBridgeReceive();
|
|
21
24
|
const defaultGetFees = (_a, t: any) => (t.gasPrice || new BigNumber(0)).times(getGasLimit(t));
|
|
22
25
|
|
|
@@ -110,6 +113,16 @@ const prepareTransaction = async (_a, t) => {
|
|
|
110
113
|
return typedTransaction;
|
|
111
114
|
};
|
|
112
115
|
|
|
116
|
+
let isConfigLoaded = false;
|
|
117
|
+
const loadCoinConfig = () => {
|
|
118
|
+
if (!isConfigLoaded) {
|
|
119
|
+
setCoinConfig((currency: CryptoCurrency) => {
|
|
120
|
+
isConfigLoaded = true;
|
|
121
|
+
return { info: getCurrencyConfiguration<EvmConfigInfo>(currency) };
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
113
126
|
const accountBridge: AccountBridge<Transaction> = {
|
|
114
127
|
createTransaction,
|
|
115
128
|
updateTransaction,
|
|
@@ -131,4 +144,5 @@ const currencyBridge: CurrencyBridge = {
|
|
|
131
144
|
export default {
|
|
132
145
|
currencyBridge,
|
|
133
146
|
accountBridge,
|
|
147
|
+
loadCoinConfig,
|
|
134
148
|
};
|
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
// Goal of this file is to inject all necessary device/signer dependency to coin-modules
|
|
2
2
|
|
|
3
|
-
import { createBridges } from "@ledgerhq/coin-evm/bridge/js";
|
|
4
3
|
import makeCliTools from "@ledgerhq/coin-evm/cli-transaction";
|
|
5
4
|
import evmResolver from "@ledgerhq/coin-evm/hw-getAddress";
|
|
6
5
|
import { prepareMessageToSign, signMessage } from "@ledgerhq/coin-evm/hw-signMessage";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
CreateSigner,
|
|
10
|
-
createMessageSigner,
|
|
11
|
-
createResolver,
|
|
12
|
-
executeWithSigner,
|
|
13
|
-
} from "../../bridge/setup";
|
|
6
|
+
import { CreateSigner, createMessageSigner, createResolver } from "../../bridge/setup";
|
|
14
7
|
import { Resolver } from "../../hw/getAddress/types";
|
|
15
8
|
import Transport from "@ledgerhq/hw-transport";
|
|
16
|
-
import type { Bridge } from "@ledgerhq/types-live";
|
|
17
|
-
import { getCurrencyConfiguration } from "../../config";
|
|
18
|
-
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
19
|
-
import { EvmConfigInfo } from "@ledgerhq/coin-evm/config";
|
|
20
9
|
import { type DeviceManagementKit } from "@ledgerhq/device-management-kit";
|
|
21
10
|
import { DmkSignerEth, LegacySignerEth } from "@ledgerhq/live-signer-evm";
|
|
22
11
|
import { EvmSigner } from "@ledgerhq/coin-evm/types/signer";
|
|
12
|
+
|
|
23
13
|
const createSigner: CreateSigner<EvmSigner> = (transport: Transport) => {
|
|
24
14
|
if (isDmkTransport(transport)) {
|
|
25
15
|
return new DmkSignerEth(transport.dmk, transport.sessionId);
|
|
@@ -39,15 +29,6 @@ const isDmkTransport = (
|
|
|
39
29
|
);
|
|
40
30
|
};
|
|
41
31
|
|
|
42
|
-
const getCurrencyConfig = (currency: CryptoCurrency) => {
|
|
43
|
-
return { info: getCurrencyConfiguration<EvmConfigInfo>(currency) };
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const bridge: Bridge<EvmTransaction> = createBridges(
|
|
47
|
-
executeWithSigner(createSigner),
|
|
48
|
-
getCurrencyConfig,
|
|
49
|
-
);
|
|
50
|
-
|
|
51
32
|
const messageSigner = {
|
|
52
33
|
prepareMessageToSign,
|
|
53
34
|
signMessage: createMessageSigner(createSigner, signMessage),
|
|
@@ -57,4 +38,4 @@ const resolver: Resolver = createResolver(createSigner, evmResolver);
|
|
|
57
38
|
|
|
58
39
|
const cliTools = makeCliTools();
|
|
59
40
|
|
|
60
|
-
export {
|
|
41
|
+
export { cliTools, resolver, messageSigner };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createTransaction } from "@ledgerhq/coin-evm/bridge/createTransaction";
|
|
2
1
|
import { Transaction } from "@ledgerhq/coin-evm/types/index";
|
|
3
2
|
import { EthereumTransaction as WalletAPIEthereumTransaction } from "@ledgerhq/wallet-api-core";
|
|
4
3
|
import {
|
|
@@ -6,9 +5,42 @@ import {
|
|
|
6
5
|
ConvertToLiveTransaction,
|
|
7
6
|
GetWalletAPITransactionSignFlowInfos,
|
|
8
7
|
} from "../../wallet-api/types";
|
|
8
|
+
import BigNumber from "bignumber.js";
|
|
9
|
+
import { AccountLike } from "@ledgerhq/types-live";
|
|
10
|
+
import { DEFAULT_GAS_LIMIT, DEFAULT_NONCE } from "@ledgerhq/coin-evm/utils";
|
|
9
11
|
|
|
10
12
|
const CAN_EDIT_FEES = true;
|
|
11
13
|
|
|
14
|
+
const getChainId = (account: AccountLike): number => {
|
|
15
|
+
if (account.type === "Account") {
|
|
16
|
+
return account.currency.ethereumLikeInfo?.chainId || 0;
|
|
17
|
+
}
|
|
18
|
+
if (account.type === "TokenAccount") {
|
|
19
|
+
return account.token.parentCurrency.ethereumLikeInfo?.chainId || 0;
|
|
20
|
+
}
|
|
21
|
+
return 0;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* EVM Transaction factory.
|
|
26
|
+
* By default the transaction is an EIP-1559 transaction.
|
|
27
|
+
* @see prepareTransaction that will make sure it's compatible or not
|
|
28
|
+
*/
|
|
29
|
+
export const createTransaction: (account: AccountLike) => Transaction = account => ({
|
|
30
|
+
family: "evm",
|
|
31
|
+
mode: "send",
|
|
32
|
+
amount: new BigNumber(0),
|
|
33
|
+
useAllAmount: false,
|
|
34
|
+
recipient: "",
|
|
35
|
+
maxFeePerGas: new BigNumber(0),
|
|
36
|
+
maxPriorityFeePerGas: new BigNumber(0),
|
|
37
|
+
gasLimit: DEFAULT_GAS_LIMIT,
|
|
38
|
+
nonce: DEFAULT_NONCE,
|
|
39
|
+
chainId: getChainId(account),
|
|
40
|
+
feesStrategy: "medium",
|
|
41
|
+
type: 2,
|
|
42
|
+
});
|
|
43
|
+
|
|
12
44
|
const areFeesProvided: AreFeesProvided<WalletAPIEthereumTransaction> = tx =>
|
|
13
45
|
!!((tx.gasLimit && tx.gasPrice) || (tx.gasLimit && tx.maxFeePerGas && tx.maxPriorityFeePerGas));
|
|
14
46
|
|
|
@@ -3,26 +3,26 @@
|
|
|
3
3
|
exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
|
|
4
4
|
[
|
|
5
5
|
{
|
|
6
|
-
"balance": "
|
|
6
|
+
"balance": "31414973242",
|
|
7
7
|
"currencyId": "hedera",
|
|
8
8
|
"derivationMode": "hederaBip44",
|
|
9
9
|
"freshAddress": "0.0.1040977",
|
|
10
10
|
"freshAddressPath": "44/3030",
|
|
11
11
|
"hederaResources": {
|
|
12
12
|
"delegation": {
|
|
13
|
-
"delegated": "
|
|
13
|
+
"delegated": "31414973242",
|
|
14
14
|
"nodeId": 0,
|
|
15
|
-
"pendingReward": "
|
|
15
|
+
"pendingReward": "2274774",
|
|
16
16
|
},
|
|
17
17
|
"isAutoTokenAssociationEnabled": false,
|
|
18
18
|
"maxAutomaticTokenAssociations": 0,
|
|
19
19
|
},
|
|
20
20
|
"id": "js:2:hedera:0.0.1040977:hederaBip44",
|
|
21
21
|
"index": 0,
|
|
22
|
-
"operationsCount":
|
|
22
|
+
"operationsCount": 55,
|
|
23
23
|
"pendingOperations": [],
|
|
24
24
|
"seedIdentifier": "9e92a312233d5fd6b5a723875aeea2cea81a8e48ffc00341cff6dffcfd3ab7f2",
|
|
25
|
-
"spendableBalance": "
|
|
25
|
+
"spendableBalance": "31414973242",
|
|
26
26
|
"subAccounts": [],
|
|
27
27
|
"swapHistory": [],
|
|
28
28
|
"syncHash": "0x43decf71",
|
|
@@ -62,26 +62,26 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
|
|
|
62
62
|
"type": "TokenAccountRaw",
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
|
-
"balance": "
|
|
65
|
+
"balance": "100226095",
|
|
66
66
|
"currencyId": "hedera",
|
|
67
67
|
"derivationMode": "hederaBip44",
|
|
68
68
|
"freshAddress": "0.0.7305122",
|
|
69
69
|
"freshAddressPath": "44/3030",
|
|
70
70
|
"hederaResources": {
|
|
71
71
|
"delegation": {
|
|
72
|
-
"delegated": "
|
|
72
|
+
"delegated": "100226095",
|
|
73
73
|
"nodeId": 0,
|
|
74
|
-
"pendingReward": "
|
|
74
|
+
"pendingReward": "3288",
|
|
75
75
|
},
|
|
76
76
|
"isAutoTokenAssociationEnabled": false,
|
|
77
77
|
"maxAutomaticTokenAssociations": 0,
|
|
78
78
|
},
|
|
79
79
|
"id": "js:2:hedera:0.0.7305122:hederaBip44",
|
|
80
80
|
"index": 1,
|
|
81
|
-
"operationsCount":
|
|
81
|
+
"operationsCount": 22,
|
|
82
82
|
"pendingOperations": [],
|
|
83
83
|
"seedIdentifier": "9e92a312233d5fd6b5a723875aeea2cea81a8e48ffc00341cff6dffcfd3ab7f2",
|
|
84
|
-
"spendableBalance": "
|
|
84
|
+
"spendableBalance": "100226095",
|
|
85
85
|
"subAccounts": [],
|
|
86
86
|
"swapHistory": [],
|
|
87
87
|
"syncHash": "0x43decf71",
|
|
@@ -182,7 +182,7 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 1`] = `
|
|
|
182
182
|
"delegation": {
|
|
183
183
|
"delegated": "100000000",
|
|
184
184
|
"nodeId": 7,
|
|
185
|
-
"pendingReward": "
|
|
185
|
+
"pendingReward": "150678",
|
|
186
186
|
},
|
|
187
187
|
"isAutoTokenAssociationEnabled": false,
|
|
188
188
|
"maxAutomaticTokenAssociations": 0,
|
|
@@ -1365,6 +1365,29 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 2`] = `
|
|
|
1365
1365
|
"type": "IN",
|
|
1366
1366
|
"value": "8289627",
|
|
1367
1367
|
},
|
|
1368
|
+
{
|
|
1369
|
+
"accountId": "js:2:hedera:0.0.1040977:hederaBip44",
|
|
1370
|
+
"blockHash": null,
|
|
1371
|
+
"blockHeight": 10,
|
|
1372
|
+
"extra": {
|
|
1373
|
+
"consensusTimestamp": "1764748857.858276000",
|
|
1374
|
+
"pagingToken": "1764748857.858276000",
|
|
1375
|
+
"transactionId": "0.0.1040977-1764748842-778719139",
|
|
1376
|
+
},
|
|
1377
|
+
"fee": "67757",
|
|
1378
|
+
"hasFailed": false,
|
|
1379
|
+
"hash": "XkIZpbgw_xScxbeqg-GvVZhuWkvNU_bvWglFXQ2aXRf3irK8RSUHsBvUZ80OMa52",
|
|
1380
|
+
"id": "js:2:hedera:0.0.1040977:hederaBip44-XkIZpbgw_xScxbeqg-GvVZhuWkvNU_bvWglFXQ2aXRf3irK8RSUHsBvUZ80OMa52-OUT",
|
|
1381
|
+
"recipients": [
|
|
1382
|
+
"0.0.7305122",
|
|
1383
|
+
"0.0.3",
|
|
1384
|
+
],
|
|
1385
|
+
"senders": [
|
|
1386
|
+
"0.0.1040977",
|
|
1387
|
+
],
|
|
1388
|
+
"type": "OUT",
|
|
1389
|
+
"value": "100067757",
|
|
1390
|
+
},
|
|
1368
1391
|
{
|
|
1369
1392
|
"accountId": "js:2:hedera:0.0.1040977:hederaBip44",
|
|
1370
1393
|
"blockHash": null,
|
|
@@ -1982,6 +2005,29 @@ exports[`hedera currency bridge scanAccounts hedera seed 1 2`] = `
|
|
|
1982
2005
|
"type": "OUT",
|
|
1983
2006
|
"value": "8485224",
|
|
1984
2007
|
},
|
|
2008
|
+
{
|
|
2009
|
+
"accountId": "js:2:hedera:0.0.7305122:hederaBip44",
|
|
2010
|
+
"blockHash": null,
|
|
2011
|
+
"blockHeight": 10,
|
|
2012
|
+
"extra": {
|
|
2013
|
+
"consensusTimestamp": "1764748857.858276000",
|
|
2014
|
+
"pagingToken": "1764748857.858276000",
|
|
2015
|
+
"transactionId": "0.0.1040977-1764748842-778719139",
|
|
2016
|
+
},
|
|
2017
|
+
"fee": "67757",
|
|
2018
|
+
"hasFailed": false,
|
|
2019
|
+
"hash": "XkIZpbgw_xScxbeqg-GvVZhuWkvNU_bvWglFXQ2aXRf3irK8RSUHsBvUZ80OMa52",
|
|
2020
|
+
"id": "js:2:hedera:0.0.7305122:hederaBip44-XkIZpbgw_xScxbeqg-GvVZhuWkvNU_bvWglFXQ2aXRf3irK8RSUHsBvUZ80OMa52-IN",
|
|
2021
|
+
"recipients": [
|
|
2022
|
+
"0.0.7305122",
|
|
2023
|
+
"0.0.3",
|
|
2024
|
+
],
|
|
2025
|
+
"senders": [
|
|
2026
|
+
"0.0.1040977",
|
|
2027
|
+
],
|
|
2028
|
+
"type": "IN",
|
|
2029
|
+
"value": "100000000",
|
|
2030
|
+
},
|
|
1985
2031
|
{
|
|
1986
2032
|
"accountId": "js:2:hedera:0.0.7305122:hederaBip44",
|
|
1987
2033
|
"blockHash": null,
|