@ledgerhq/live-common 34.48.0-nightly.3 → 34.48.0-nightly.5
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/index.d.ts +0 -2
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/exchange/swap/transactionStrategies.d.ts +38 -11
- package/lib/exchange/swap/transactionStrategies.d.ts.map +1 -1
- package/lib/exchange/swap/transactionStrategies.js +93 -47
- package/lib/exchange/swap/transactionStrategies.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +4 -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/actions/app.d.ts.map +1 -1
- package/lib/hw/actions/app.js +8 -11
- package/lib/hw/actions/app.js.map +1 -1
- package/lib/modularDrawer/data/state-manager/api.d.ts.map +1 -1
- package/lib/modularDrawer/data/state-manager/api.js +3 -2
- package/lib/modularDrawer/data/state-manager/api.js.map +1 -1
- package/lib/modularDrawer/data/state-manager/types.d.ts +1 -0
- package/lib/modularDrawer/data/state-manager/types.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useAssetsData.d.ts +2 -1
- package/lib/modularDrawer/hooks/useAssetsData.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useAssetsData.js +2 -1
- package/lib/modularDrawer/hooks/useAssetsData.js.map +1 -1
- package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib/wallet-api/Exchange/server.js +16 -13
- package/lib/wallet-api/Exchange/server.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/swap/transactionStrategies.d.ts +38 -11
- package/lib-es/exchange/swap/transactionStrategies.d.ts.map +1 -1
- package/lib-es/exchange/swap/transactionStrategies.js +87 -44
- package/lib-es/exchange/swap/transactionStrategies.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +4 -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/actions/app.d.ts.map +1 -1
- package/lib-es/hw/actions/app.js +8 -11
- package/lib-es/hw/actions/app.js.map +1 -1
- package/lib-es/modularDrawer/data/state-manager/api.d.ts.map +1 -1
- package/lib-es/modularDrawer/data/state-manager/api.js +3 -2
- package/lib-es/modularDrawer/data/state-manager/api.js.map +1 -1
- package/lib-es/modularDrawer/data/state-manager/types.d.ts +1 -0
- package/lib-es/modularDrawer/data/state-manager/types.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useAssetsData.d.ts +2 -1
- package/lib-es/modularDrawer/hooks/useAssetsData.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useAssetsData.js +2 -1
- package/lib-es/modularDrawer/hooks/useAssetsData.js.map +1 -1
- package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib-es/wallet-api/Exchange/server.js +16 -13
- package/lib-es/wallet-api/Exchange/server.js.map +1 -1
- package/package.json +44 -44
- package/src/exchange/swap/transactionStrategies.ts +121 -73
- package/src/featureFlags/defaultFeatures.ts +4 -1
- package/src/hw/actions/app.ts +9 -12
- package/src/modularDrawer/data/state-manager/api.ts +4 -2
- package/src/modularDrawer/data/state-manager/types.ts +1 -0
- package/src/modularDrawer/hooks/useAssetsData.ts +3 -0
- package/src/wallet-api/Exchange/server.ts +17 -14
@@ -1,16 +1,7 @@
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
2
2
|
|
3
|
-
import {
|
4
|
-
|
5
|
-
ElrondTransaction,
|
6
|
-
RippleTransaction,
|
7
|
-
SolanaTransaction,
|
8
|
-
StellarTransaction,
|
9
|
-
TonTransaction,
|
10
|
-
Transaction,
|
11
|
-
TransactionCommon,
|
12
|
-
} from "@ledgerhq/wallet-api-client";
|
13
|
-
|
3
|
+
import { Transaction } from "../../generated/types";
|
4
|
+
import { TransactionCommon } from "@ledgerhq/types-live";
|
14
5
|
export type { SwapLiveError } from "@ledgerhq/wallet-api-exchange-module";
|
15
6
|
|
16
7
|
export function defaultTransaction({
|
@@ -18,35 +9,81 @@ export function defaultTransaction({
|
|
18
9
|
amount,
|
19
10
|
recipient,
|
20
11
|
customFeeConfig,
|
21
|
-
}: TransactionWithCustomFee): Transaction {
|
22
|
-
|
12
|
+
}: TransactionWithCustomFee): Partial<Transaction> {
|
13
|
+
// Type assertion needed because each Transaction family has different required properties
|
14
|
+
// This function provides base properties that are then extended by family-specific functions
|
15
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
16
|
+
return {
|
23
17
|
family,
|
24
18
|
amount,
|
25
19
|
recipient,
|
26
20
|
...customFeeConfig,
|
21
|
+
} as Partial<Transaction>;
|
22
|
+
}
|
23
|
+
|
24
|
+
export function cardanoTransaction({
|
25
|
+
amount,
|
26
|
+
recipient,
|
27
|
+
customFeeConfig,
|
28
|
+
}: TransactionWithCustomFee): Partial<Extract<Transaction, { family: "cardano" }>> {
|
29
|
+
return {
|
30
|
+
family: "cardano",
|
31
|
+
amount,
|
32
|
+
recipient,
|
33
|
+
mode: "send",
|
34
|
+
...customFeeConfig,
|
27
35
|
};
|
28
36
|
}
|
29
37
|
|
30
|
-
export function
|
31
|
-
family,
|
38
|
+
export function nearTransaction({
|
32
39
|
amount,
|
33
40
|
recipient,
|
34
41
|
customFeeConfig,
|
35
|
-
}: TransactionWithCustomFee): Transaction {
|
42
|
+
}: TransactionWithCustomFee): Extract<Transaction, { family: "near" }> {
|
36
43
|
return {
|
37
|
-
|
44
|
+
family: "near",
|
45
|
+
amount,
|
46
|
+
recipient,
|
38
47
|
mode: "send",
|
48
|
+
...customFeeConfig,
|
49
|
+
};
|
50
|
+
}
|
51
|
+
|
52
|
+
export function tezosTransaction({
|
53
|
+
amount,
|
54
|
+
recipient,
|
55
|
+
customFeeConfig,
|
56
|
+
}: TransactionWithCustomFee): Partial<Extract<Transaction, { family: "tezos" }>> {
|
57
|
+
return {
|
58
|
+
family: "tezos",
|
59
|
+
amount,
|
60
|
+
recipient,
|
61
|
+
mode: "send",
|
62
|
+
...customFeeConfig,
|
63
|
+
};
|
64
|
+
}
|
65
|
+
|
66
|
+
export function tronTransaction({
|
67
|
+
amount,
|
68
|
+
recipient,
|
69
|
+
customFeeConfig,
|
70
|
+
}: TransactionWithCustomFee): Partial<Extract<Transaction, { family: "tron" }>> {
|
71
|
+
return {
|
72
|
+
family: "tron",
|
73
|
+
amount,
|
74
|
+
recipient,
|
75
|
+
mode: "send",
|
76
|
+
...customFeeConfig,
|
39
77
|
};
|
40
78
|
}
|
41
79
|
|
42
80
|
export function stellarTransaction({
|
43
|
-
family,
|
44
81
|
amount,
|
45
82
|
recipient,
|
46
83
|
customFeeConfig,
|
47
84
|
payinExtraId,
|
48
85
|
customErrorType,
|
49
|
-
}: TransactionWithCustomFee):
|
86
|
+
}: TransactionWithCustomFee): Extract<Transaction, { family: "stellar" }> {
|
50
87
|
if (!payinExtraId)
|
51
88
|
throw {
|
52
89
|
error: new Error("Missing payinExtraId"),
|
@@ -55,8 +92,11 @@ export function stellarTransaction({
|
|
55
92
|
};
|
56
93
|
|
57
94
|
return {
|
58
|
-
...defaultTransaction({ family, amount, recipient, customFeeConfig }),
|
59
95
|
family: "stellar",
|
96
|
+
mode: "send",
|
97
|
+
amount,
|
98
|
+
recipient,
|
99
|
+
...customFeeConfig,
|
60
100
|
memoValue: payinExtraId,
|
61
101
|
memoType: "MEMO_TEXT",
|
62
102
|
};
|
@@ -68,7 +108,7 @@ export function rippleTransaction({
|
|
68
108
|
customFeeConfig,
|
69
109
|
payinExtraId,
|
70
110
|
customErrorType,
|
71
|
-
}: TransactionWithCustomFee):
|
111
|
+
}: TransactionWithCustomFee): Partial<Extract<Transaction, { family: "xrp" }>> {
|
72
112
|
if (!payinExtraId)
|
73
113
|
throw {
|
74
114
|
error: new Error("Missing payinExtraId"),
|
@@ -76,38 +116,40 @@ export function rippleTransaction({
|
|
76
116
|
customErrorType,
|
77
117
|
};
|
78
118
|
|
79
|
-
|
80
|
-
family: "
|
119
|
+
return {
|
120
|
+
family: "xrp",
|
81
121
|
amount,
|
82
122
|
recipient,
|
83
123
|
...customFeeConfig,
|
84
124
|
tag: new BigNumber(payinExtraId).toNumber(),
|
85
125
|
};
|
86
|
-
return transaction;
|
87
126
|
}
|
88
127
|
|
89
|
-
|
90
|
-
export function withoutGasLimitTransaction({
|
91
|
-
family,
|
128
|
+
export function evmTransaction({
|
92
129
|
amount,
|
93
130
|
recipient,
|
94
131
|
customFeeConfig,
|
95
132
|
extraTransactionParameters,
|
96
|
-
}: TransactionWithCustomFee): Transaction {
|
133
|
+
}: TransactionWithCustomFee): Partial<Extract<Transaction, { family: "evm" }>> {
|
97
134
|
if (customFeeConfig?.gasLimit) {
|
98
135
|
delete customFeeConfig.gasLimit;
|
99
136
|
}
|
100
137
|
|
101
138
|
if (extraTransactionParameters) {
|
102
|
-
return
|
103
|
-
family,
|
139
|
+
return {
|
140
|
+
family: "evm" as const,
|
104
141
|
amount,
|
105
142
|
recipient,
|
106
143
|
...customFeeConfig,
|
107
144
|
data: Buffer.from(extraTransactionParameters, "hex"),
|
108
145
|
};
|
109
146
|
}
|
110
|
-
return
|
147
|
+
return {
|
148
|
+
family: "evm" as const,
|
149
|
+
amount,
|
150
|
+
recipient,
|
151
|
+
...customFeeConfig,
|
152
|
+
};
|
111
153
|
}
|
112
154
|
|
113
155
|
export function bitcoinTransaction({
|
@@ -115,33 +157,33 @@ export function bitcoinTransaction({
|
|
115
157
|
recipient,
|
116
158
|
customFeeConfig,
|
117
159
|
extraTransactionParameters,
|
118
|
-
}: TransactionWithCustomFee): Transaction {
|
160
|
+
}: TransactionWithCustomFee): Partial<Extract<Transaction, { family: "bitcoin" }>> {
|
161
|
+
const baseTransaction = {
|
162
|
+
family: "bitcoin" as const,
|
163
|
+
amount,
|
164
|
+
recipient,
|
165
|
+
...customFeeConfig,
|
166
|
+
};
|
167
|
+
|
119
168
|
if (extraTransactionParameters) {
|
120
169
|
return {
|
121
|
-
|
122
|
-
amount,
|
123
|
-
recipient,
|
124
|
-
...customFeeConfig,
|
170
|
+
...baseTransaction,
|
125
171
|
opReturnData: Buffer.from(extraTransactionParameters, "utf-8"),
|
126
172
|
};
|
127
173
|
}
|
128
|
-
|
129
|
-
|
130
|
-
amount,
|
131
|
-
recipient,
|
132
|
-
...customFeeConfig,
|
133
|
-
};
|
174
|
+
|
175
|
+
return baseTransaction;
|
134
176
|
}
|
135
177
|
|
136
178
|
export function solanaTransaction({
|
137
|
-
family,
|
138
179
|
amount,
|
139
180
|
recipient,
|
140
|
-
customFeeConfig,
|
141
|
-
}: TransactionWithCustomFee):
|
181
|
+
customFeeConfig: _customFeeConfig,
|
182
|
+
}: TransactionWithCustomFee): Extract<Transaction, { family: "solana" }> {
|
142
183
|
return {
|
143
|
-
...defaultTransaction({ family, amount, recipient, customFeeConfig }),
|
144
184
|
family: "solana",
|
185
|
+
amount,
|
186
|
+
recipient,
|
145
187
|
model: { kind: "transfer", uiState: {} },
|
146
188
|
};
|
147
189
|
}
|
@@ -150,43 +192,44 @@ export function elrondTransaction({
|
|
150
192
|
amount,
|
151
193
|
recipient,
|
152
194
|
customFeeConfig,
|
153
|
-
}: TransactionWithCustomFee):
|
154
|
-
|
155
|
-
family: "
|
195
|
+
}: TransactionWithCustomFee): Extract<Transaction, { family: "multiversx" }> {
|
196
|
+
return {
|
197
|
+
family: "multiversx",
|
156
198
|
amount,
|
157
199
|
recipient,
|
158
200
|
mode: "send",
|
159
|
-
|
160
|
-
gasLimit:
|
201
|
+
fees: customFeeConfig.fees || null,
|
202
|
+
gasLimit: customFeeConfig.gasLimit ? Number(customFeeConfig.gasLimit) : 0,
|
161
203
|
};
|
162
|
-
return transaction;
|
163
204
|
}
|
164
205
|
|
165
206
|
function tonTransaction({
|
166
|
-
family,
|
167
207
|
amount,
|
168
208
|
recipient,
|
169
|
-
customFeeConfig,
|
170
|
-
}: TransactionWithCustomFee):
|
209
|
+
customFeeConfig: _customFeeConfig,
|
210
|
+
}: TransactionWithCustomFee): Extract<Transaction, { family: "ton" }> {
|
171
211
|
return {
|
172
|
-
...defaultTransaction({ family, amount, recipient, customFeeConfig }),
|
173
212
|
family: "ton",
|
213
|
+
amount,
|
214
|
+
recipient,
|
174
215
|
comment: { isEncrypted: false, text: "" },
|
175
216
|
fees: new BigNumber(0), // Set default value as completeExchange call prepareTransaction, which set again fees.
|
176
217
|
};
|
177
218
|
}
|
178
219
|
|
179
220
|
export function cosmosTransaction({
|
180
|
-
family,
|
181
221
|
amount,
|
182
222
|
recipient,
|
183
223
|
customFeeConfig,
|
184
224
|
payinExtraId,
|
185
|
-
}: TransactionWithCustomFee):
|
186
|
-
return
|
187
|
-
...defaultTransaction({ family, amount, recipient, customFeeConfig }),
|
225
|
+
}: TransactionWithCustomFee): Partial<Extract<Transaction, { family: "cosmos" }>> {
|
226
|
+
return {
|
188
227
|
family: "cosmos",
|
228
|
+
amount,
|
229
|
+
recipient,
|
189
230
|
mode: "send",
|
231
|
+
networkInfo: null,
|
232
|
+
...customFeeConfig,
|
190
233
|
memo: payinExtraId ?? undefined,
|
191
234
|
};
|
192
235
|
}
|
@@ -198,10 +241,13 @@ export type TransactionWithCustomFee = TransactionCommon & {
|
|
198
241
|
payinExtraId?: string;
|
199
242
|
customErrorType?: "swap";
|
200
243
|
extraTransactionParameters?: string;
|
244
|
+
family: string;
|
201
245
|
};
|
202
246
|
|
203
247
|
// Define a specific type for the strategy functions, assuming they might need parameters
|
204
|
-
export type TransactionStrategyFunction = (
|
248
|
+
export type TransactionStrategyFunction = (
|
249
|
+
params: TransactionWithCustomFee,
|
250
|
+
) => Partial<Transaction>;
|
205
251
|
|
206
252
|
export const transactionStrategy: {
|
207
253
|
[K in Transaction["family"]]: TransactionStrategyFunction;
|
@@ -209,26 +255,28 @@ export const transactionStrategy: {
|
|
209
255
|
algorand: defaultTransaction,
|
210
256
|
aptos: defaultTransaction,
|
211
257
|
bitcoin: bitcoinTransaction,
|
212
|
-
|
258
|
+
canton: defaultTransaction,
|
259
|
+
cardano: cardanoTransaction,
|
260
|
+
casper: defaultTransaction,
|
213
261
|
celo: defaultTransaction,
|
214
262
|
cosmos: cosmosTransaction,
|
215
|
-
|
216
|
-
elrond: elrondTransaction,
|
217
|
-
ethereum: withoutGasLimitTransaction,
|
263
|
+
evm: evmTransaction,
|
218
264
|
filecoin: defaultTransaction,
|
219
265
|
hedera: defaultTransaction,
|
220
|
-
|
221
|
-
|
266
|
+
icon: defaultTransaction,
|
267
|
+
internet_computer: defaultTransaction,
|
268
|
+
mina: defaultTransaction,
|
269
|
+
multiversx: elrondTransaction,
|
270
|
+
near: nearTransaction,
|
222
271
|
polkadot: defaultTransaction,
|
223
|
-
ripple: rippleTransaction,
|
224
272
|
solana: solanaTransaction,
|
225
273
|
stacks: defaultTransaction,
|
226
274
|
stellar: stellarTransaction,
|
227
|
-
|
275
|
+
sui: defaultTransaction,
|
276
|
+
tezos: tezosTransaction,
|
228
277
|
ton: tonTransaction,
|
229
|
-
tron:
|
278
|
+
tron: tronTransaction,
|
230
279
|
vechain: defaultTransaction,
|
231
|
-
|
232
|
-
|
233
|
-
internet_computer: defaultTransaction,
|
280
|
+
kaspa: defaultTransaction,
|
281
|
+
xrp: rippleTransaction,
|
234
282
|
};
|
@@ -521,7 +521,6 @@ export const DEFAULT_FEATURES: Features = {
|
|
521
521
|
llmMarketQuickActions: DEFAULT_FEATURE,
|
522
522
|
spamFilteringTx: DEFAULT_FEATURE,
|
523
523
|
lldSpamFilteringTx: DEFAULT_FEATURE,
|
524
|
-
llmSpamFilteringTx: DEFAULT_FEATURE,
|
525
524
|
llmMemoTag: DEFAULT_FEATURE,
|
526
525
|
lldMemoTag: DEFAULT_FEATURE,
|
527
526
|
ldmkTransport: {
|
@@ -621,6 +620,8 @@ export const DEFAULT_FEATURES: Features = {
|
|
621
620
|
receive_flow: true,
|
622
621
|
send_flow: true,
|
623
622
|
enableModularization: false,
|
623
|
+
searchDebounceTime: 500,
|
624
|
+
backendEnvironment: "PROD",
|
624
625
|
},
|
625
626
|
},
|
626
627
|
llmModularDrawer: {
|
@@ -633,6 +634,8 @@ export const DEFAULT_FEATURES: Features = {
|
|
633
634
|
receive_flow: true,
|
634
635
|
send_flow: true,
|
635
636
|
enableModularization: false,
|
637
|
+
searchDebounceTime: 500,
|
638
|
+
backendEnvironment: "PROD",
|
636
639
|
},
|
637
640
|
},
|
638
641
|
llNftSupport: DEFAULT_FEATURE,
|
package/src/hw/actions/app.ts
CHANGED
@@ -540,20 +540,17 @@ export const createAction = (
|
|
540
540
|
displayUpgradeWarning: false,
|
541
541
|
}));
|
542
542
|
}, []);
|
543
|
-
// TODO remove after fix
|
544
|
-
const isCanton = appRequest.account?.currency.id.includes("canton");
|
545
|
-
const wrongDevice =
|
546
|
-
state.derivation && appRequest.account
|
547
|
-
? state.derivation.address !== appRequest.account.freshAddress &&
|
548
|
-
state.derivation.address !== appRequest.account.seedIdentifier // Use-case added for Hedera
|
549
|
-
? {
|
550
|
-
accountName: getDefaultAccountName(appRequest.account),
|
551
|
-
}
|
552
|
-
: null
|
553
|
-
: null;
|
554
543
|
return {
|
555
544
|
...state,
|
556
|
-
inWrongDeviceForAccount:
|
545
|
+
inWrongDeviceForAccount:
|
546
|
+
state.derivation && appRequest.account
|
547
|
+
? state.derivation.address !== appRequest.account.freshAddress &&
|
548
|
+
state.derivation.address !== appRequest.account.seedIdentifier // Use-case added for Hedera
|
549
|
+
? {
|
550
|
+
accountName: getDefaultAccountName(appRequest.account),
|
551
|
+
}
|
552
|
+
: null
|
553
|
+
: null,
|
557
554
|
onRetry,
|
558
555
|
passWarning,
|
559
556
|
};
|
@@ -30,7 +30,7 @@ function transformAssetsResponse(
|
|
30
30
|
export const assetsDataApi = createApi({
|
31
31
|
reducerPath: "assetsDataApi",
|
32
32
|
baseQuery: fetchBaseQuery({
|
33
|
-
baseUrl:
|
33
|
+
baseUrl: "", // Will be overridden in query
|
34
34
|
}),
|
35
35
|
tagTypes: [AssetsDataTags.Assets],
|
36
36
|
endpoints: build => ({
|
@@ -49,8 +49,10 @@ export const assetsDataApi = createApi({
|
|
49
49
|
additionalData: [AssetsAdditionalData.Apy, AssetsAdditionalData.MarketTrend],
|
50
50
|
};
|
51
51
|
|
52
|
+
const baseUrl = queryArg.isStaging ? getEnv("DADA_API_STAGING") : getEnv("DADA_API_PROD");
|
53
|
+
|
52
54
|
return {
|
53
|
-
url:
|
55
|
+
url: `${baseUrl}assets`,
|
54
56
|
params,
|
55
57
|
};
|
56
58
|
},
|
@@ -24,6 +24,7 @@ export function useAssetsData({
|
|
24
24
|
areCurrenciesFiltered,
|
25
25
|
product,
|
26
26
|
version,
|
27
|
+
isStaging,
|
27
28
|
}: {
|
28
29
|
search?: string;
|
29
30
|
currencyIds?: string[];
|
@@ -31,6 +32,7 @@ export function useAssetsData({
|
|
31
32
|
areCurrenciesFiltered?: boolean;
|
32
33
|
product: "llm" | "lld";
|
33
34
|
version: string;
|
35
|
+
isStaging?: boolean;
|
34
36
|
}) {
|
35
37
|
const { data, isLoading, error, fetchNextPage, isSuccess, refetch, isFetching, isError } =
|
36
38
|
useGetAssetsDataInfiniteQuery({
|
@@ -39,6 +41,7 @@ export function useAssetsData({
|
|
39
41
|
currencyIds: areCurrenciesFiltered ? currencyIds : undefined,
|
40
42
|
product,
|
41
43
|
version,
|
44
|
+
isStaging,
|
42
45
|
});
|
43
46
|
|
44
47
|
const joinedPages = useMemo(() => {
|
@@ -53,7 +53,6 @@ import { getSwapStepFromError } from "../../exchange/error";
|
|
53
53
|
import { postSwapCancelled } from "../../exchange/swap";
|
54
54
|
import { DeviceModelId } from "@ledgerhq/types-devices";
|
55
55
|
import { setBroadcastTransaction } from "../../exchange/swap/setBroadcastTransaction";
|
56
|
-
import { FAMILIES_MAPPING_LL_TO_WAPI } from "../constants";
|
57
56
|
|
58
57
|
export { ExchangeType };
|
59
58
|
|
@@ -486,14 +485,11 @@ export const handlers = ({
|
|
486
485
|
});
|
487
486
|
|
488
487
|
const mainFromAccount = getMainAccount(fromAccount, fromParentAccount);
|
489
|
-
const mainFromAccountFamily =
|
490
|
-
FAMILIES_MAPPING_LL_TO_WAPI[mainFromAccount.currency.family] ||
|
491
|
-
mainFromAccount.currency.family;
|
492
488
|
|
493
|
-
if (transaction.family !==
|
489
|
+
if (transaction.family !== mainFromAccount.currency.family) {
|
494
490
|
return Promise.reject(
|
495
491
|
new Error(
|
496
|
-
`Account and transaction must be from the same family. Account family: ${
|
492
|
+
`Account and transaction must be from the same family. Account family: ${mainFromAccount.currency.family}, Transaction family: ${transaction.family}`,
|
497
493
|
),
|
498
494
|
);
|
499
495
|
}
|
@@ -804,27 +800,34 @@ async function getStrategy(
|
|
804
800
|
delete customFeeConfig.utxoStrategy;
|
805
801
|
}
|
806
802
|
|
807
|
-
|
808
|
-
const familyKey = FAMILIES_MAPPING_LL_TO_WAPI[family] || family;
|
809
|
-
const strategy = transactionStrategy?.[familyKey];
|
803
|
+
const strategy = transactionStrategy?.[family];
|
810
804
|
|
811
805
|
if (!strategy) {
|
812
|
-
throw new Error(`No transaction strategy found for family: ${
|
806
|
+
throw new Error(`No transaction strategy found for family: ${family}`);
|
807
|
+
}
|
808
|
+
|
809
|
+
// Convert customFeeConfig values to BigNumber
|
810
|
+
const convertedCustomFeeConfig: { [key: string]: BigNumber } = {};
|
811
|
+
if (customFeeConfig) {
|
812
|
+
for (const [key, value] of Object.entries(customFeeConfig)) {
|
813
|
+
convertedCustomFeeConfig[key] = new BigNumber(value?.toString() || 0);
|
814
|
+
}
|
813
815
|
}
|
814
816
|
|
815
817
|
try {
|
816
818
|
return await strategy({
|
817
|
-
family
|
818
|
-
amount,
|
819
|
+
family,
|
820
|
+
amount: new BigNumber(amount),
|
819
821
|
recipient,
|
820
|
-
customFeeConfig:
|
822
|
+
customFeeConfig: convertedCustomFeeConfig,
|
821
823
|
payinExtraId,
|
822
824
|
extraTransactionParameters,
|
823
825
|
customErrorType,
|
824
826
|
});
|
825
827
|
} catch (error) {
|
828
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
826
829
|
throw new Error(
|
827
|
-
`Failed to execute transaction strategy for family: ${
|
830
|
+
`Failed to execute transaction strategy for family: ${family}. Reason: ${errorMessage}`,
|
828
831
|
);
|
829
832
|
}
|
830
833
|
}
|