@ledgerhq/live-common 34.40.0 → 34.41.0-nightly.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/e2e/enum/Provider.d.ts +3 -0
- package/lib/e2e/enum/Provider.d.ts.map +1 -1
- package/lib/e2e/enum/Provider.js +3 -0
- package/lib/e2e/enum/Provider.js.map +1 -1
- package/lib/e2e/index.d.ts +0 -2
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/exchange/error.d.ts +1 -0
- package/lib/exchange/error.d.ts.map +1 -1
- package/lib/exchange/error.js +11 -1
- package/lib/exchange/error.js.map +1 -1
- package/lib/exchange/swap/api/v5/actions.d.ts +3 -0
- package/lib/exchange/swap/api/v5/actions.d.ts.map +1 -0
- package/lib/exchange/swap/api/v5/actions.js +36 -0
- package/lib/exchange/swap/api/v5/actions.js.map +1 -0
- package/lib/exchange/swap/getCompleteSwapHistory.js +1 -1
- package/lib/exchange/swap/getCompleteSwapHistory.js.map +1 -1
- package/lib/exchange/swap/postSwapState.d.ts.map +1 -1
- package/lib/exchange/swap/postSwapState.js +19 -9
- package/lib/exchange/swap/postSwapState.js.map +1 -1
- package/lib/exchange/swap/setBroadcastTransaction.d.ts +3 -2
- package/lib/exchange/swap/setBroadcastTransaction.d.ts.map +1 -1
- package/lib/exchange/swap/setBroadcastTransaction.js +4 -2
- package/lib/exchange/swap/setBroadcastTransaction.js.map +1 -1
- package/lib/exchange/swap/transactionStrategies.d.ts +25 -0
- package/lib/exchange/swap/transactionStrategies.d.ts.map +1 -0
- package/lib/exchange/swap/transactionStrategies.js +152 -0
- package/lib/exchange/swap/transactionStrategies.js.map +1 -0
- package/lib/exchange/swap/types.d.ts +59 -0
- package/lib/exchange/swap/types.d.ts.map +1 -1
- package/lib/families/cardano/signerSerializer.js +4 -2
- package/lib/families/cardano/signerSerializer.js.map +1 -1
- package/lib/families/evm/bridge/mock.js +2 -2
- package/lib/families/evm/platformAdapter.js +2 -2
- package/lib/families/evm/platformAdapter.js.map +1 -1
- package/lib/families/evm/platformAdapter.test.js +4 -4
- package/lib/families/evm/platformAdapter.test.js.map +1 -1
- package/lib/families/evm/react.js +1 -1
- package/lib/families/evm/react.js.map +1 -1
- package/lib/families/evm/react.test.js +2 -2
- package/lib/families/evm/react.test.js.map +1 -1
- package/lib/families/evm/walletApiAdapter.js +1 -1
- package/lib/families/evm/walletApiAdapter.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +1 -1
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/useFeature.d.ts +1 -1
- package/lib/featureFlags/useFeature.d.ts.map +1 -1
- package/lib/hw/extractOnboardingState.d.ts.map +1 -1
- package/lib/hw/extractOnboardingState.js +8 -6
- package/lib/hw/extractOnboardingState.js.map +1 -1
- package/lib/hw/extractOnboardingState.test.js +7 -0
- package/lib/hw/extractOnboardingState.test.js.map +1 -1
- package/lib/mock/account.d.ts.map +1 -1
- package/lib/mock/account.js +1 -0
- package/lib/mock/account.js.map +1 -1
- package/lib/wallet-api/Exchange/server.d.ts +29 -10
- package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib/wallet-api/Exchange/server.js +204 -7
- package/lib/wallet-api/Exchange/server.js.map +1 -1
- package/lib/wallet-api/Exchange/server.test.js +3 -1
- package/lib/wallet-api/Exchange/server.test.js.map +1 -1
- package/lib/wallet-api/useDappLogic.js +2 -2
- package/lib-es/e2e/enum/Provider.d.ts +3 -0
- package/lib-es/e2e/enum/Provider.d.ts.map +1 -1
- package/lib-es/e2e/enum/Provider.js +3 -0
- package/lib-es/e2e/enum/Provider.js.map +1 -1
- package/lib-es/e2e/index.d.ts +0 -2
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/exchange/error.d.ts +1 -0
- package/lib-es/exchange/error.d.ts.map +1 -1
- package/lib-es/exchange/error.js +9 -0
- package/lib-es/exchange/error.js.map +1 -1
- package/lib-es/exchange/swap/api/v5/actions.d.ts +3 -0
- package/lib-es/exchange/swap/api/v5/actions.d.ts.map +1 -0
- package/lib-es/exchange/swap/api/v5/actions.js +29 -0
- package/lib-es/exchange/swap/api/v5/actions.js.map +1 -0
- package/lib-es/exchange/swap/getCompleteSwapHistory.js +1 -1
- package/lib-es/exchange/swap/getCompleteSwapHistory.js.map +1 -1
- package/lib-es/exchange/swap/postSwapState.d.ts.map +1 -1
- package/lib-es/exchange/swap/postSwapState.js +17 -7
- package/lib-es/exchange/swap/postSwapState.js.map +1 -1
- package/lib-es/exchange/swap/setBroadcastTransaction.d.ts +3 -2
- package/lib-es/exchange/swap/setBroadcastTransaction.d.ts.map +1 -1
- package/lib-es/exchange/swap/setBroadcastTransaction.js +4 -2
- package/lib-es/exchange/swap/setBroadcastTransaction.js.map +1 -1
- package/lib-es/exchange/swap/transactionStrategies.d.ts +25 -0
- package/lib-es/exchange/swap/transactionStrategies.d.ts.map +1 -0
- package/lib-es/exchange/swap/transactionStrategies.js +140 -0
- package/lib-es/exchange/swap/transactionStrategies.js.map +1 -0
- package/lib-es/exchange/swap/types.d.ts +59 -0
- package/lib-es/exchange/swap/types.d.ts.map +1 -1
- package/lib-es/families/cardano/signerSerializer.js +4 -2
- package/lib-es/families/cardano/signerSerializer.js.map +1 -1
- package/lib-es/families/evm/bridge/mock.js +1 -1
- package/lib-es/families/evm/platformAdapter.js +1 -1
- package/lib-es/families/evm/platformAdapter.js.map +1 -1
- package/lib-es/families/evm/platformAdapter.test.js +1 -1
- package/lib-es/families/evm/platformAdapter.test.js.map +1 -1
- package/lib-es/families/evm/react.js +1 -1
- package/lib-es/families/evm/react.js.map +1 -1
- package/lib-es/families/evm/react.test.js +2 -2
- package/lib-es/families/evm/react.test.js.map +1 -1
- package/lib-es/families/evm/walletApiAdapter.js +1 -1
- package/lib-es/families/evm/walletApiAdapter.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +1 -1
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/featureFlags/useFeature.d.ts +1 -1
- package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
- package/lib-es/hw/extractOnboardingState.d.ts.map +1 -1
- package/lib-es/hw/extractOnboardingState.js +8 -6
- package/lib-es/hw/extractOnboardingState.js.map +1 -1
- package/lib-es/hw/extractOnboardingState.test.js +7 -0
- package/lib-es/hw/extractOnboardingState.test.js.map +1 -1
- package/lib-es/mock/account.d.ts.map +1 -1
- package/lib-es/mock/account.js +1 -0
- package/lib-es/mock/account.js.map +1 -1
- package/lib-es/wallet-api/Exchange/server.d.ts +29 -10
- package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib-es/wallet-api/Exchange/server.js +206 -9
- package/lib-es/wallet-api/Exchange/server.js.map +1 -1
- package/lib-es/wallet-api/Exchange/server.test.js +3 -1
- package/lib-es/wallet-api/Exchange/server.test.js.map +1 -1
- package/lib-es/wallet-api/useDappLogic.js +1 -1
- package/package.json +40 -40
- package/src/e2e/enum/Provider.ts +3 -0
- package/src/exchange/error.ts +10 -0
- package/src/exchange/swap/api/v5/actions.ts +36 -0
- package/src/exchange/swap/getCompleteSwapHistory.ts +1 -1
- package/src/exchange/swap/postSwapState.ts +24 -6
- package/src/exchange/swap/setBroadcastTransaction.ts +6 -2
- package/src/exchange/swap/transactionStrategies.ts +234 -0
- package/src/exchange/swap/types.ts +64 -0
- package/src/families/cardano/__snapshots__/bridge.integration.test.ts.snap +1 -0
- package/src/families/cardano/signerSerializer.ts +4 -2
- package/src/families/evm/bridge/mock.ts +1 -1
- package/src/families/evm/platformAdapter.test.ts +1 -1
- package/src/families/evm/platformAdapter.ts +1 -1
- package/src/families/evm/react.test.ts +3 -3
- package/src/families/evm/react.ts +1 -1
- package/src/families/evm/walletApiAdapter.ts +1 -1
- package/src/featureFlags/defaultFeatures.ts +1 -1
- package/src/hw/extractOnboardingState.test.ts +9 -0
- package/src/hw/extractOnboardingState.ts +12 -8
- package/src/mock/account.ts +1 -0
- package/src/wallet-api/Exchange/server.test.ts +7 -5
- package/src/wallet-api/Exchange/server.ts +344 -32
- package/src/wallet-api/useDappLogic.ts +1 -1
@@ -11,13 +11,15 @@ export const setBroadcastTransaction = ({
|
|
11
11
|
targetCurrencyId,
|
12
12
|
hardwareWalletType,
|
13
13
|
swapType,
|
14
|
+
swapAppVersion,
|
14
15
|
}: {
|
15
|
-
result: { operation: Operation; swapId: string };
|
16
|
+
result: { operation: Operation | string; swapId: string };
|
16
17
|
provider: string;
|
17
18
|
sourceCurrencyId?: string;
|
18
19
|
targetCurrencyId?: string;
|
19
20
|
hardwareWalletType?: DeviceModelId;
|
20
21
|
swapType?: TradeMethod;
|
22
|
+
swapAppVersion?: string;
|
21
23
|
}) => {
|
22
24
|
const { operation, swapId } = result;
|
23
25
|
|
@@ -36,16 +38,18 @@ export const setBroadcastTransaction = ({
|
|
36
38
|
targetCurrencyId,
|
37
39
|
hardwareWalletType,
|
38
40
|
swapType: swapType,
|
41
|
+
swapAppVersion,
|
39
42
|
});
|
40
43
|
} else {
|
41
44
|
postSwapAccepted({
|
42
45
|
provider,
|
43
46
|
swapId,
|
44
|
-
transactionId: operation.hash,
|
47
|
+
transactionId: typeof operation === "string" ? operation : operation.hash,
|
45
48
|
sourceCurrencyId,
|
46
49
|
targetCurrencyId,
|
47
50
|
hardwareWalletType,
|
48
51
|
swapType,
|
52
|
+
swapAppVersion,
|
49
53
|
});
|
50
54
|
}
|
51
55
|
};
|
@@ -0,0 +1,234 @@
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
2
|
+
|
3
|
+
import {
|
4
|
+
CosmosTransaction,
|
5
|
+
ElrondTransaction,
|
6
|
+
RippleTransaction,
|
7
|
+
SolanaTransaction,
|
8
|
+
StellarTransaction,
|
9
|
+
TonTransaction,
|
10
|
+
Transaction,
|
11
|
+
TransactionCommon,
|
12
|
+
} from "@ledgerhq/wallet-api-client";
|
13
|
+
|
14
|
+
export type { SwapLiveError } from "@ledgerhq/wallet-api-exchange-module";
|
15
|
+
|
16
|
+
export function defaultTransaction({
|
17
|
+
family,
|
18
|
+
amount,
|
19
|
+
recipient,
|
20
|
+
customFeeConfig,
|
21
|
+
}: TransactionWithCustomFee): Transaction {
|
22
|
+
return <Transaction>{
|
23
|
+
family,
|
24
|
+
amount,
|
25
|
+
recipient,
|
26
|
+
...customFeeConfig,
|
27
|
+
};
|
28
|
+
}
|
29
|
+
|
30
|
+
export function modeSendTransaction({
|
31
|
+
family,
|
32
|
+
amount,
|
33
|
+
recipient,
|
34
|
+
customFeeConfig,
|
35
|
+
}: TransactionWithCustomFee): Transaction {
|
36
|
+
return {
|
37
|
+
...defaultTransaction({ family, amount, recipient, customFeeConfig }),
|
38
|
+
mode: "send",
|
39
|
+
};
|
40
|
+
}
|
41
|
+
|
42
|
+
export function stellarTransaction({
|
43
|
+
family,
|
44
|
+
amount,
|
45
|
+
recipient,
|
46
|
+
customFeeConfig,
|
47
|
+
payinExtraId,
|
48
|
+
customErrorType,
|
49
|
+
}: TransactionWithCustomFee): StellarTransaction {
|
50
|
+
if (!payinExtraId)
|
51
|
+
throw {
|
52
|
+
error: new Error("Missing payinExtraId"),
|
53
|
+
step: "PayinExtraIdStepError",
|
54
|
+
customErrorType,
|
55
|
+
};
|
56
|
+
|
57
|
+
return {
|
58
|
+
...defaultTransaction({ family, amount, recipient, customFeeConfig }),
|
59
|
+
family: "stellar",
|
60
|
+
memoValue: payinExtraId,
|
61
|
+
memoType: "MEMO_TEXT",
|
62
|
+
};
|
63
|
+
}
|
64
|
+
|
65
|
+
export function rippleTransaction({
|
66
|
+
amount,
|
67
|
+
recipient,
|
68
|
+
customFeeConfig,
|
69
|
+
payinExtraId,
|
70
|
+
customErrorType,
|
71
|
+
}: TransactionWithCustomFee): RippleTransaction {
|
72
|
+
if (!payinExtraId)
|
73
|
+
throw {
|
74
|
+
error: new Error("Missing payinExtraId"),
|
75
|
+
step: "PayinExtraIdStepError",
|
76
|
+
customErrorType,
|
77
|
+
};
|
78
|
+
|
79
|
+
const transaction: RippleTransaction = {
|
80
|
+
family: "ripple",
|
81
|
+
amount,
|
82
|
+
recipient,
|
83
|
+
...customFeeConfig,
|
84
|
+
tag: new BigNumber(payinExtraId).toNumber(),
|
85
|
+
};
|
86
|
+
return transaction;
|
87
|
+
}
|
88
|
+
|
89
|
+
// Function to remove gasLimit from customFeeConfig for Ethereum or Bitcoin
|
90
|
+
export function withoutGasLimitTransaction({
|
91
|
+
family,
|
92
|
+
amount,
|
93
|
+
recipient,
|
94
|
+
customFeeConfig,
|
95
|
+
extraTransactionParameters,
|
96
|
+
}: TransactionWithCustomFee): Transaction {
|
97
|
+
if (customFeeConfig?.gasLimit) {
|
98
|
+
delete customFeeConfig.gasLimit;
|
99
|
+
}
|
100
|
+
|
101
|
+
if (extraTransactionParameters) {
|
102
|
+
return <Transaction>{
|
103
|
+
family,
|
104
|
+
amount,
|
105
|
+
recipient,
|
106
|
+
...customFeeConfig,
|
107
|
+
data: Buffer.from(extraTransactionParameters, "hex"),
|
108
|
+
};
|
109
|
+
}
|
110
|
+
return defaultTransaction({ family, amount, recipient, customFeeConfig });
|
111
|
+
}
|
112
|
+
|
113
|
+
export function bitcoinTransaction({
|
114
|
+
amount,
|
115
|
+
recipient,
|
116
|
+
customFeeConfig,
|
117
|
+
extraTransactionParameters,
|
118
|
+
}: TransactionWithCustomFee): Transaction {
|
119
|
+
if (extraTransactionParameters) {
|
120
|
+
return {
|
121
|
+
family: "bitcoin",
|
122
|
+
amount,
|
123
|
+
recipient,
|
124
|
+
...customFeeConfig,
|
125
|
+
opReturnData: Buffer.from(extraTransactionParameters, "utf-8"),
|
126
|
+
};
|
127
|
+
}
|
128
|
+
return {
|
129
|
+
family: "bitcoin",
|
130
|
+
amount,
|
131
|
+
recipient,
|
132
|
+
...customFeeConfig,
|
133
|
+
};
|
134
|
+
}
|
135
|
+
|
136
|
+
export function solanaTransaction({
|
137
|
+
family,
|
138
|
+
amount,
|
139
|
+
recipient,
|
140
|
+
customFeeConfig,
|
141
|
+
}: TransactionWithCustomFee): SolanaTransaction {
|
142
|
+
return {
|
143
|
+
...defaultTransaction({ family, amount, recipient, customFeeConfig }),
|
144
|
+
family: "solana",
|
145
|
+
model: { kind: "transfer", uiState: {} },
|
146
|
+
};
|
147
|
+
}
|
148
|
+
|
149
|
+
export function elrondTransaction({
|
150
|
+
amount,
|
151
|
+
recipient,
|
152
|
+
customFeeConfig,
|
153
|
+
}: TransactionWithCustomFee): ElrondTransaction {
|
154
|
+
const transaction: ElrondTransaction = {
|
155
|
+
family: "elrond",
|
156
|
+
amount,
|
157
|
+
recipient,
|
158
|
+
mode: "send",
|
159
|
+
...customFeeConfig,
|
160
|
+
gasLimit: 0, // FIXME: Placeholder, adjust as needed
|
161
|
+
};
|
162
|
+
return transaction;
|
163
|
+
}
|
164
|
+
|
165
|
+
function tonTransaction({
|
166
|
+
family,
|
167
|
+
amount,
|
168
|
+
recipient,
|
169
|
+
customFeeConfig,
|
170
|
+
}: TransactionWithCustomFee): TonTransaction {
|
171
|
+
return {
|
172
|
+
...defaultTransaction({ family, amount, recipient, customFeeConfig }),
|
173
|
+
family: "ton",
|
174
|
+
comment: { isEncrypted: false, text: "" },
|
175
|
+
fees: new BigNumber(0), // Set default value as completeExchange call prepareTransaction, which set again fees.
|
176
|
+
};
|
177
|
+
}
|
178
|
+
|
179
|
+
export function cosmosTransaction({
|
180
|
+
family,
|
181
|
+
amount,
|
182
|
+
recipient,
|
183
|
+
customFeeConfig,
|
184
|
+
payinExtraId,
|
185
|
+
}: TransactionWithCustomFee): CosmosTransaction {
|
186
|
+
return <CosmosTransaction>{
|
187
|
+
...defaultTransaction({ family, amount, recipient, customFeeConfig }),
|
188
|
+
family: "cosmos",
|
189
|
+
mode: "send",
|
190
|
+
memo: payinExtraId ?? undefined,
|
191
|
+
};
|
192
|
+
}
|
193
|
+
|
194
|
+
export type TransactionWithCustomFee = TransactionCommon & {
|
195
|
+
customFeeConfig: {
|
196
|
+
[key: string]: BigNumber;
|
197
|
+
};
|
198
|
+
payinExtraId?: string;
|
199
|
+
customErrorType?: "swap";
|
200
|
+
extraTransactionParameters?: string;
|
201
|
+
};
|
202
|
+
|
203
|
+
// Define a specific type for the strategy functions, assuming they might need parameters
|
204
|
+
export type TransactionStrategyFunction = (params: TransactionWithCustomFee) => Transaction;
|
205
|
+
|
206
|
+
export const transactionStrategy: {
|
207
|
+
[K in Transaction["family"]]: TransactionStrategyFunction;
|
208
|
+
} = {
|
209
|
+
algorand: defaultTransaction,
|
210
|
+
aptos: defaultTransaction,
|
211
|
+
bitcoin: bitcoinTransaction,
|
212
|
+
cardano: modeSendTransaction,
|
213
|
+
celo: defaultTransaction,
|
214
|
+
cosmos: cosmosTransaction,
|
215
|
+
crypto_org: defaultTransaction,
|
216
|
+
elrond: elrondTransaction,
|
217
|
+
ethereum: withoutGasLimitTransaction,
|
218
|
+
filecoin: defaultTransaction,
|
219
|
+
hedera: defaultTransaction,
|
220
|
+
near: modeSendTransaction,
|
221
|
+
neo: defaultTransaction,
|
222
|
+
polkadot: defaultTransaction,
|
223
|
+
ripple: rippleTransaction,
|
224
|
+
solana: solanaTransaction,
|
225
|
+
stacks: defaultTransaction,
|
226
|
+
stellar: stellarTransaction,
|
227
|
+
tezos: modeSendTransaction,
|
228
|
+
ton: tonTransaction,
|
229
|
+
tron: modeSendTransaction,
|
230
|
+
vechain: defaultTransaction,
|
231
|
+
casper: defaultTransaction,
|
232
|
+
sui: defaultTransaction,
|
233
|
+
internet_computer: defaultTransaction,
|
234
|
+
};
|
@@ -4,6 +4,7 @@ import { Account, AccountLike, AccountRaw, AccountRawLike, Operation } from "@le
|
|
4
4
|
import { BigNumber } from "bignumber.js";
|
5
5
|
import { Result as UseBridgeTransactionResult } from "../../bridge/useBridgeTransaction";
|
6
6
|
import { Transaction, TransactionRaw } from "../../generated/types";
|
7
|
+
|
7
8
|
export type { SwapLiveError } from "@ledgerhq/wallet-api-exchange-module";
|
8
9
|
|
9
10
|
export type ExchangeSwap = {
|
@@ -198,6 +199,7 @@ type SwapStateRequest = {
|
|
198
199
|
targetCurrencyId: string;
|
199
200
|
hardwareWalletType: DeviceModelId;
|
200
201
|
swapType: TradeMethod;
|
202
|
+
swapAppVersion?: string;
|
201
203
|
}>;
|
202
204
|
|
203
205
|
export type SwapStateAcceptedRequest = SwapStateRequest & {
|
@@ -336,3 +338,65 @@ export type SwapTransactionType = UseBridgeTransactionResult & {
|
|
336
338
|
fromAmountError?: Error;
|
337
339
|
fromAmountWarning?: Error;
|
338
340
|
};
|
341
|
+
|
342
|
+
export type SwapPayloadRequestData = {
|
343
|
+
provider: string;
|
344
|
+
deviceTransactionId: string;
|
345
|
+
fromAccountAddress: string;
|
346
|
+
toAccountAddress: string;
|
347
|
+
fromAccountCurrency: string;
|
348
|
+
toAccountCurrency: string;
|
349
|
+
amount: string;
|
350
|
+
amountInAtomicUnit: number;
|
351
|
+
quoteId?: string;
|
352
|
+
toNewTokenId?: string;
|
353
|
+
};
|
354
|
+
export type SwapPayloadResponse = {
|
355
|
+
binaryPayload: string;
|
356
|
+
signature: string;
|
357
|
+
payinAddress: string;
|
358
|
+
swapId: string;
|
359
|
+
payinExtraId?: string;
|
360
|
+
extraTransactionParameters?: string;
|
361
|
+
};
|
362
|
+
|
363
|
+
export type ConfirmSwapRequest = {
|
364
|
+
provider: string;
|
365
|
+
swapId: string;
|
366
|
+
transactionId: string;
|
367
|
+
sourceCurrencyId?: string;
|
368
|
+
targetCurrencyId?: string;
|
369
|
+
hardwareWalletType?: string;
|
370
|
+
};
|
371
|
+
|
372
|
+
export type CancelSwapRequest = {
|
373
|
+
provider: string;
|
374
|
+
swapId: string;
|
375
|
+
statusCode?: string;
|
376
|
+
errorMessage?: string;
|
377
|
+
sourceCurrencyId?: string;
|
378
|
+
targetCurrencyId?: string;
|
379
|
+
hardwareWalletType?: string;
|
380
|
+
swapType?: string;
|
381
|
+
swapStep?: string;
|
382
|
+
};
|
383
|
+
|
384
|
+
export type SwapBackendResponse = {
|
385
|
+
provider: string;
|
386
|
+
swapId: string;
|
387
|
+
apiExtraFee: number;
|
388
|
+
apiFee: number;
|
389
|
+
refundAddress: string;
|
390
|
+
amountExpectedFrom: number;
|
391
|
+
amountExpectedTo: number;
|
392
|
+
status: string;
|
393
|
+
from: string;
|
394
|
+
to: string;
|
395
|
+
payinAddress: string;
|
396
|
+
payoutAddress: string;
|
397
|
+
createdAt: string; // ISO-8601
|
398
|
+
binaryPayload: string;
|
399
|
+
signature: string;
|
400
|
+
payinExtraId?: string;
|
401
|
+
extraTransactionParameters?: string;
|
402
|
+
};
|
@@ -7,6 +7,7 @@ exports[`cardano_testnet currency bridge scanAccounts cardano_testnet seed 1 1`]
|
|
7
7
|
"cardanoResources": {
|
8
8
|
"delegation": {
|
9
9
|
"dRepHex": undefined,
|
10
|
+
"deposit": "2000000",
|
10
11
|
"name": "Apex Cardano Pool",
|
11
12
|
"poolId": "7facad662e180ce45e5c504957cd1341940c72a708728f7ecfc6e349",
|
12
13
|
"rewards": "0",
|
@@ -121,9 +121,10 @@ function prepareCertificate(cert: SignerTxCertificate): Certificate {
|
|
121
121
|
switch (cert.type) {
|
122
122
|
case "REGISTRATION":
|
123
123
|
return {
|
124
|
-
type: CertificateType.
|
124
|
+
type: CertificateType.STAKE_REGISTRATION_CONWAY,
|
125
125
|
params: {
|
126
126
|
stakeCredential,
|
127
|
+
deposit: cert.params.deposit,
|
127
128
|
},
|
128
129
|
};
|
129
130
|
case "DELEGATION":
|
@@ -136,9 +137,10 @@ function prepareCertificate(cert: SignerTxCertificate): Certificate {
|
|
136
137
|
};
|
137
138
|
case "DEREGISTRATION":
|
138
139
|
return {
|
139
|
-
type: CertificateType.
|
140
|
+
type: CertificateType.STAKE_DEREGISTRATION_CONWAY,
|
140
141
|
params: {
|
141
142
|
stakeCredential,
|
143
|
+
deposit: cert.params.deposit,
|
142
144
|
},
|
143
145
|
};
|
144
146
|
case "VOTE_DELEGATION_ABSTAIN":
|
@@ -14,7 +14,7 @@ import {
|
|
14
14
|
getSerializedAddressParameters,
|
15
15
|
updateTransaction,
|
16
16
|
} from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
17
|
-
import { getGasLimit } from "@ledgerhq/coin-evm/
|
17
|
+
import { getGasLimit } from "@ledgerhq/coin-evm/utils";
|
18
18
|
import { getTypedTransaction } from "@ledgerhq/coin-evm/transaction";
|
19
19
|
const receive = makeAccountBridgeReceive();
|
20
20
|
const defaultGetFees = (_a, t: any) => (t.gasPrice || new BigNumber(0)).times(getGasLimit(t));
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { DEFAULT_NONCE } from "@ledgerhq/coin-evm/createTransaction";
|
2
1
|
import { Transaction } from "@ledgerhq/coin-evm/types/index";
|
3
2
|
import { FAMILIES, EthereumTransaction as PlatformTransaction } from "@ledgerhq/live-app-sdk";
|
4
3
|
import BigNumber from "bignumber.js";
|
5
4
|
import evm from "./platformAdapter";
|
5
|
+
import { DEFAULT_NONCE } from "@ledgerhq/coin-evm/utils";
|
6
6
|
|
7
7
|
describe("getPlatformTransactionSignFlowInfos", () => {
|
8
8
|
describe("should properly get infos for ETH platform tx", () => {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// TODO: to remove once live-app-sdk is depreciated and removed from LL
|
2
2
|
|
3
|
-
import { DEFAULT_NONCE } from "@ledgerhq/coin-evm/
|
3
|
+
import { DEFAULT_NONCE } from "@ledgerhq/coin-evm/utils";
|
4
4
|
import { Transaction } from "@ledgerhq/coin-evm/types/index";
|
5
5
|
import { EthereumTransaction as PlatformTransaction } from "@ledgerhq/live-app-sdk";
|
6
6
|
|
@@ -4,15 +4,15 @@
|
|
4
4
|
import BigNumber from "bignumber.js";
|
5
5
|
import { renderHook, waitFor } from "@testing-library/react";
|
6
6
|
import { Transaction } from "@ledgerhq/coin-evm/types/index";
|
7
|
-
import { getGasTracker } from "@ledgerhq/coin-evm/
|
8
|
-
import type { GasTrackerApi } from "@ledgerhq/coin-evm/
|
7
|
+
import { getGasTracker } from "@ledgerhq/coin-evm/network/gasTracker/index";
|
8
|
+
import type { GasTrackerApi } from "@ledgerhq/coin-evm/network/gasTracker/types";
|
9
9
|
import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
|
10
10
|
import { useGasOptions } from "./react";
|
11
11
|
|
12
12
|
jest.useFakeTimers();
|
13
13
|
jest.spyOn(global, "setInterval");
|
14
14
|
|
15
|
-
jest.mock("@ledgerhq/coin-evm/
|
15
|
+
jest.mock("@ledgerhq/coin-evm/network/gasTracker/index");
|
16
16
|
const mockedGetGasTracker = jest.mocked(getGasTracker);
|
17
17
|
|
18
18
|
const mockedGetGasOptions = jest.fn();
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { getGasTracker } from "@ledgerhq/coin-evm/
|
1
|
+
import { getGasTracker } from "@ledgerhq/coin-evm/network/gasTracker/index";
|
2
2
|
import type { GasOptions, Transaction } from "@ledgerhq/coin-evm/types/index";
|
3
3
|
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
4
4
|
import { useEffect, useMemo, useState } from "react";
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { createTransaction } from "@ledgerhq/coin-evm/createTransaction";
|
1
|
+
import { createTransaction } from "@ledgerhq/coin-evm/bridge/createTransaction";
|
2
2
|
import { Transaction } from "@ledgerhq/coin-evm/types/index";
|
3
3
|
import { EthereumTransaction as WalletAPIEthereumTransaction } from "@ledgerhq/wallet-api-core";
|
4
4
|
import {
|
@@ -153,6 +153,7 @@ export const DEFAULT_FEATURES: Features = {
|
|
153
153
|
protectServicesDesktop: {
|
154
154
|
enabled: false,
|
155
155
|
params: {
|
156
|
+
openWithDevTools: false,
|
156
157
|
availableOnDesktop: false,
|
157
158
|
isNew: false,
|
158
159
|
ledgerliveStorageState: false,
|
@@ -530,7 +531,6 @@ export const DEFAULT_FEATURES: Features = {
|
|
530
531
|
...DEFAULT_FEATURE,
|
531
532
|
params: { link: null },
|
532
533
|
},
|
533
|
-
llmNetworkBasedAddAccountFlow: DEFAULT_FEATURE,
|
534
534
|
llCounterValueGranularitiesRates: {
|
535
535
|
...DEFAULT_FEATURE,
|
536
536
|
params: {
|
@@ -35,6 +35,15 @@ describe("@hw/extractOnboardingState", () => {
|
|
35
35
|
expect(onboardingState?.currentOnboardingStep).toBe(OnboardingStep.Ready);
|
36
36
|
expect(onboardingState?.charonStatus).toBeNull();
|
37
37
|
});
|
38
|
+
|
39
|
+
it("should ignore charon update status", () => {
|
40
|
+
const charonState = Buffer.from([0x20]);
|
41
|
+
const onboardingState = extractOnboardingState(flagsBytes, charonState);
|
42
|
+
|
43
|
+
expect(onboardingState).not.toBeNull();
|
44
|
+
expect(onboardingState?.currentOnboardingStep).toBe(OnboardingStep.Ready);
|
45
|
+
expect(onboardingState?.charonStatus).toBeNull();
|
46
|
+
});
|
38
47
|
});
|
39
48
|
|
40
49
|
describe("and the user refuse to backup the charon", () => {
|
@@ -137,6 +137,14 @@ export const extractOnboardingState = (
|
|
137
137
|
|
138
138
|
const currentSeedWordIndex = flagsBytes[2] & currentSeedWordIndexMask;
|
139
139
|
|
140
|
+
const charonSupported = charonState !== undefined && charonState.length > 0;
|
141
|
+
const charonOnboardingBits = charonSupported ? charonState[0] & 0xf : 0;
|
142
|
+
//const charonUpdateBits = charonSupported ? (charonState[0] & 0x30) >> 4 : 0;
|
143
|
+
const charonStatus =
|
144
|
+
charonSupported && fromBitsToCharonStatusMap.has(charonOnboardingBits)
|
145
|
+
? fromBitsToCharonStatusMap.get(charonOnboardingBits)!
|
146
|
+
: null;
|
147
|
+
|
140
148
|
/*
|
141
149
|
* Once the device is seeded, there are some additional states for backing up with Charon (for devices that support it)
|
142
150
|
* There are 2 scenarios:
|
@@ -148,9 +156,11 @@ export const extractOnboardingState = (
|
|
148
156
|
if (
|
149
157
|
isOnboarded &&
|
150
158
|
[OnboardingStep.Ready, OnboardingStep.WelcomeScreen1].includes(currentOnboardingStep) &&
|
151
|
-
|
159
|
+
charonSupported
|
152
160
|
) {
|
153
|
-
currentOnboardingStep = fromBitsToOnboardingStep.get(
|
161
|
+
currentOnboardingStep = fromBitsToOnboardingStep.get(
|
162
|
+
charonOnboardingBits + CHARON_STEP_BIT_MASK,
|
163
|
+
);
|
154
164
|
|
155
165
|
if (!currentOnboardingStep) {
|
156
166
|
throw new DeviceExtractOnboardingStateError(
|
@@ -159,12 +169,6 @@ export const extractOnboardingState = (
|
|
159
169
|
}
|
160
170
|
}
|
161
171
|
|
162
|
-
const charonSupported = charonState !== undefined && charonState.length > 0;
|
163
|
-
const charonStatus =
|
164
|
-
charonSupported && fromBitsToCharonStatusMap.has(charonState[0])
|
165
|
-
? fromBitsToCharonStatusMap.get(charonState[0])!
|
166
|
-
: null;
|
167
|
-
|
168
172
|
return {
|
169
173
|
isOnboarded,
|
170
174
|
isInRecoveryMode,
|
package/src/mock/account.ts
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
import {
|
2
|
-
import { AppBranch, AppPlatform, Visibility } from "../types";
|
3
|
-
import { of } from "rxjs";
|
1
|
+
import { RpcRequest } from "@ledgerhq/wallet-api-core";
|
4
2
|
import {
|
5
3
|
ExchangeStartParams,
|
6
4
|
ExchangeStartSellParams,
|
7
5
|
ExchangeStartSwapParams,
|
8
6
|
} from "@ledgerhq/wallet-api-exchange-module";
|
9
|
-
import { RpcRequest } from "@ledgerhq/wallet-api-core";
|
10
|
-
import { genAccount } from "../../mock/account";
|
11
7
|
import { WalletContext, WalletHandlers } from "@ledgerhq/wallet-api-server";
|
8
|
+
import { of } from "rxjs";
|
9
|
+
import { genAccount } from "../../mock/account";
|
10
|
+
import { AppBranch, AppPlatform, Visibility } from "../types";
|
11
|
+
import { handlers } from "./server";
|
12
12
|
|
13
13
|
const mockTracking = {
|
14
14
|
startExchangeRequested: jest.fn(),
|
@@ -46,6 +46,7 @@ const testAppManifest = {
|
|
46
46
|
|
47
47
|
const mockUiStartExchange = jest.fn();
|
48
48
|
const mockUiCompleteExchange = jest.fn();
|
49
|
+
const mockUiSwap = jest.fn();
|
49
50
|
const mockUiError = jest.fn();
|
50
51
|
const mockIsReady = jest.fn();
|
51
52
|
|
@@ -54,6 +55,7 @@ const mockUiHooks = {
|
|
54
55
|
"custom.exchange.complete": mockUiCompleteExchange,
|
55
56
|
"custom.exchange.error": mockUiError,
|
56
57
|
"custom.isReady": mockIsReady,
|
58
|
+
"custom.exchange.swap": mockUiSwap,
|
57
59
|
};
|
58
60
|
|
59
61
|
// Mock converter id to send back the id received in params.
|