@ledgerhq/live-common 34.51.0-nightly.4 → 34.51.0-nightly.6

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.
Files changed (76) hide show
  1. package/lib/e2e/index.d.ts +2 -0
  2. package/lib/e2e/index.d.ts.map +1 -1
  3. package/lib/exchange/swap/hooks/usePickDefaultAccount.js +1 -1
  4. package/lib/exchange/swap/hooks/usePickDefaultAccount.js.map +1 -1
  5. package/lib/exchange/swap/hooks/useSwapTransaction.d.ts +3 -2
  6. package/lib/exchange/swap/hooks/useSwapTransaction.d.ts.map +1 -1
  7. package/lib/exchange/swap/hooks/useSwapTransaction.js +14 -9
  8. package/lib/exchange/swap/hooks/useSwapTransaction.js.map +1 -1
  9. package/lib/exchange/swap/transactionStrategies.d.ts +2 -1
  10. package/lib/exchange/swap/transactionStrategies.d.ts.map +1 -1
  11. package/lib/exchange/swap/transactionStrategies.js +3 -1
  12. package/lib/exchange/swap/transactionStrategies.js.map +1 -1
  13. package/lib/exchange/swap/types.d.ts +1 -0
  14. package/lib/exchange/swap/types.d.ts.map +1 -1
  15. package/lib/families/evm/walletApiAdapter.d.ts.map +1 -1
  16. package/lib/families/evm/walletApiAdapter.js +5 -0
  17. package/lib/families/evm/walletApiAdapter.js.map +1 -1
  18. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  19. package/lib/featureFlags/defaultFeatures.js +1 -0
  20. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  21. package/lib/featureFlags/useFeature.d.ts +1 -1
  22. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  23. package/lib/modularDrawer/modules/__test__/createNetworkConfiguration.test.d.ts +5 -0
  24. package/lib/modularDrawer/modules/__test__/createNetworkConfiguration.test.d.ts.map +1 -0
  25. package/lib/modularDrawer/modules/__test__/createNetworkConfiguration.test.js +266 -0
  26. package/lib/modularDrawer/modules/__test__/createNetworkConfiguration.test.js.map +1 -0
  27. package/lib/wallet-api/Exchange/server.d.ts +1 -0
  28. package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
  29. package/lib/wallet-api/Exchange/server.js +5 -2
  30. package/lib/wallet-api/Exchange/server.js.map +1 -1
  31. package/lib/wallet-api/react.d.ts.map +1 -1
  32. package/lib/wallet-api/react.js +5 -1
  33. package/lib/wallet-api/react.js.map +1 -1
  34. package/lib-es/e2e/index.d.ts +2 -0
  35. package/lib-es/e2e/index.d.ts.map +1 -1
  36. package/lib-es/exchange/swap/hooks/usePickDefaultAccount.js +2 -2
  37. package/lib-es/exchange/swap/hooks/usePickDefaultAccount.js.map +1 -1
  38. package/lib-es/exchange/swap/hooks/useSwapTransaction.d.ts +3 -2
  39. package/lib-es/exchange/swap/hooks/useSwapTransaction.d.ts.map +1 -1
  40. package/lib-es/exchange/swap/hooks/useSwapTransaction.js +14 -9
  41. package/lib-es/exchange/swap/hooks/useSwapTransaction.js.map +1 -1
  42. package/lib-es/exchange/swap/transactionStrategies.d.ts +2 -1
  43. package/lib-es/exchange/swap/transactionStrategies.d.ts.map +1 -1
  44. package/lib-es/exchange/swap/transactionStrategies.js +3 -1
  45. package/lib-es/exchange/swap/transactionStrategies.js.map +1 -1
  46. package/lib-es/exchange/swap/types.d.ts +1 -0
  47. package/lib-es/exchange/swap/types.d.ts.map +1 -1
  48. package/lib-es/families/evm/walletApiAdapter.d.ts.map +1 -1
  49. package/lib-es/families/evm/walletApiAdapter.js +5 -0
  50. package/lib-es/families/evm/walletApiAdapter.js.map +1 -1
  51. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  52. package/lib-es/featureFlags/defaultFeatures.js +1 -0
  53. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  54. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  55. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  56. package/lib-es/modularDrawer/modules/__test__/createNetworkConfiguration.test.d.ts +5 -0
  57. package/lib-es/modularDrawer/modules/__test__/createNetworkConfiguration.test.d.ts.map +1 -0
  58. package/lib-es/modularDrawer/modules/__test__/createNetworkConfiguration.test.js +264 -0
  59. package/lib-es/modularDrawer/modules/__test__/createNetworkConfiguration.test.js.map +1 -0
  60. package/lib-es/wallet-api/Exchange/server.d.ts +1 -0
  61. package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
  62. package/lib-es/wallet-api/Exchange/server.js +5 -2
  63. package/lib-es/wallet-api/Exchange/server.js.map +1 -1
  64. package/lib-es/wallet-api/react.d.ts.map +1 -1
  65. package/lib-es/wallet-api/react.js +5 -1
  66. package/lib-es/wallet-api/react.js.map +1 -1
  67. package/package.json +72 -72
  68. package/src/exchange/swap/hooks/usePickDefaultAccount.ts +2 -2
  69. package/src/exchange/swap/hooks/useSwapTransaction.ts +20 -7
  70. package/src/exchange/swap/transactionStrategies.ts +4 -0
  71. package/src/exchange/swap/types.ts +1 -0
  72. package/src/families/evm/walletApiAdapter.ts +6 -0
  73. package/src/featureFlags/defaultFeatures.ts +1 -0
  74. package/src/modularDrawer/modules/__test__/createNetworkConfiguration.test.ts +383 -0
  75. package/src/wallet-api/Exchange/server.ts +12 -3
  76. package/src/wallet-api/react.ts +7 -1
@@ -0,0 +1,383 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
5
+ import { BigNumber } from "bignumber.js";
6
+ import { genAccount, genTokenAccount } from "@ledgerhq/coin-framework/lib/mocks/account";
7
+ import { createFixtureCryptoCurrency } from "../../../mock/fixtures/cryptoCurrencies";
8
+ import { createNetworkConfigurationHook } from "../createNetworkConfiguration";
9
+ import { renderHook } from "@testing-library/react";
10
+ import { CounterValuesState } from "@ledgerhq/live-countervalues/lib/types";
11
+ import { FiatCurrency, TokenCurrency, CryptoCurrency } from "@ledgerhq/types-cryptoassets";
12
+
13
+ const makeUsdcToken = (
14
+ parentCurrency: CryptoCurrency,
15
+ contractAddress: string,
16
+ tokenType: string = "erc20",
17
+ magnitude: number = 6,
18
+ name: string = "USD Coin",
19
+ unitName: string = "USD Coin",
20
+ explicitId?: string,
21
+ ) => {
22
+ const id = explicitId ?? `${parentCurrency.id}/${tokenType}/usdc`;
23
+ return {
24
+ type: "TokenCurrency" as const,
25
+ parentCurrency,
26
+ tokenType,
27
+ id,
28
+ contractAddress,
29
+ ticker: "USDC",
30
+ name,
31
+ units: [
32
+ {
33
+ name: unitName,
34
+ code: "USDC",
35
+ magnitude,
36
+ },
37
+ ],
38
+ };
39
+ };
40
+
41
+ const bscCurrency = createFixtureCryptoCurrency("bsc");
42
+ const bscAccount = genAccount("bsc-account", { currency: bscCurrency });
43
+ const bscUsdcToken: TokenCurrency = makeUsdcToken(
44
+ bscCurrency,
45
+ "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
46
+ "bep20",
47
+ 18,
48
+ "USD Coin",
49
+ "Binance-Peg USD Coin",
50
+ "bsc/erc20/usdc",
51
+ );
52
+ const bscUsdcTokenAccount = genTokenAccount(0, bscAccount, bscUsdcToken);
53
+ bscAccount.subAccounts = [bscUsdcTokenAccount];
54
+
55
+ const baseCurrency = createFixtureCryptoCurrency("base");
56
+ const baseAccount = genAccount("base-account", { currency: baseCurrency });
57
+ const baseUsdcToken: TokenCurrency = makeUsdcToken(
58
+ baseCurrency,
59
+ "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
60
+ "erc20",
61
+ 6,
62
+ "USD Coin",
63
+ "USD Coin",
64
+ "base/erc20/usd_coin",
65
+ );
66
+ const baseUsdcTokenAccount = genTokenAccount(0, baseAccount, baseUsdcToken);
67
+ baseAccount.subAccounts = [baseUsdcTokenAccount];
68
+
69
+ const ethereumCurrency = createFixtureCryptoCurrency("ethereum");
70
+ const ethereumAccountHigh = genAccount("ethereum-account-high", {
71
+ currency: ethereumCurrency,
72
+ });
73
+
74
+ ethereumAccountHigh.balance = new BigNumber("1000000000000000000000");
75
+ ethereumAccountHigh.spendableBalance = ethereumAccountHigh.balance;
76
+
77
+ const ethereumUsdcToken: TokenCurrency = makeUsdcToken(
78
+ ethereumCurrency,
79
+ "0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
80
+ "erc20",
81
+ 6,
82
+ "USD Coin",
83
+ "USD Coin",
84
+ );
85
+ const ethereumUsdcTokenAccount = genTokenAccount(0, ethereumAccountHigh, ethereumUsdcToken);
86
+ ethereumAccountHigh.subAccounts = [ethereumUsdcTokenAccount];
87
+
88
+ const ethereumAccountLow = genAccount("ethereum-account-low", {
89
+ currency: ethereumCurrency,
90
+ });
91
+ ethereumAccountLow.balance = new BigNumber("100000000000000000");
92
+ ethereumAccountLow.spendableBalance = ethereumAccountLow.balance;
93
+
94
+ const ethereumAccountZero = genAccount("ethereum-account-zero", {
95
+ currency: ethereumCurrency,
96
+ });
97
+ ethereumAccountZero.balance = new BigNumber("0");
98
+ ethereumAccountZero.spendableBalance = ethereumAccountZero.balance;
99
+
100
+ const polygonCurrency = createFixtureCryptoCurrency("polygon");
101
+ const polygonAccountMedium = genAccount("polygon-account-medium", {
102
+ currency: polygonCurrency,
103
+ });
104
+ polygonAccountMedium.balance = new BigNumber("500000000000000000000");
105
+ polygonAccountMedium.spendableBalance = polygonAccountMedium.balance;
106
+
107
+ const polygonUsdcToken: TokenCurrency = makeUsdcToken(
108
+ polygonCurrency,
109
+ "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
110
+ "erc20",
111
+ 6,
112
+ "USD Coin",
113
+ "USD Coin",
114
+ );
115
+ const polygonUsdcTokenAccount = genTokenAccount(0, polygonAccountMedium, polygonUsdcToken);
116
+ polygonAccountMedium.subAccounts = [polygonUsdcTokenAccount];
117
+
118
+ const makeAccountData = (asset, count) => ({
119
+ asset,
120
+ label: `${count} account`,
121
+ count,
122
+ });
123
+
124
+ const useAccountData = () => {
125
+ return [
126
+ makeAccountData(createFixtureCryptoCurrency("ethereum"), 3),
127
+ makeAccountData(createFixtureCryptoCurrency("polygon"), 1),
128
+ makeAccountData(createFixtureCryptoCurrency("bsc"), 2),
129
+ makeAccountData(createFixtureCryptoCurrency("base"), 1),
130
+ makeAccountData(createFixtureCryptoCurrency("avalanche_c_chain"), 0),
131
+ ];
132
+ };
133
+
134
+ const mockFiatCurrency: FiatCurrency = {
135
+ type: "FiatCurrency",
136
+ ticker: "USD",
137
+ name: "US Dollar",
138
+ symbol: "$",
139
+ units: [
140
+ {
141
+ code: "$",
142
+ name: "US Dollar",
143
+ magnitude: 2,
144
+ showAllDigits: true,
145
+ prefixCode: true,
146
+ },
147
+ ],
148
+ };
149
+
150
+ const accountsCount = jest.fn(() => null);
151
+ const accountsCountAndApy = () => null;
152
+ const useBalanceDeps = () => {
153
+ const mockCounterValuesState: CounterValuesState = {
154
+ cache: {
155
+ "USD testCoinId": {
156
+ fallback: 2354.213,
157
+ map: new Map(),
158
+ stats: {
159
+ oldest: "2024-09-12",
160
+ earliest: "2025-10-02T13",
161
+ oldestDate: new Date(),
162
+ earliestDate: new Date(),
163
+ earliestStableDate: new Date(),
164
+ },
165
+ },
166
+ },
167
+ data: {},
168
+ status: {},
169
+ };
170
+
171
+ return {
172
+ counterValueCurrency: mockFiatCurrency,
173
+ flattenedAccounts: [
174
+ bscAccount,
175
+ bscUsdcTokenAccount,
176
+ baseAccount,
177
+ baseUsdcTokenAccount,
178
+ ethereumAccountHigh,
179
+ ethereumUsdcTokenAccount,
180
+ ethereumAccountLow,
181
+ ethereumAccountZero,
182
+ polygonAccountMedium,
183
+ polygonUsdcTokenAccount,
184
+ ],
185
+ state: mockCounterValuesState,
186
+ locale: "en-US",
187
+ };
188
+ };
189
+ const balanceItem = jest.fn(() => null);
190
+
191
+ const networkConfigurationDeps = {
192
+ useAccountData,
193
+ accountsCount,
194
+ accountsCountAndApy,
195
+ useBalanceDeps,
196
+ balanceItem,
197
+ };
198
+
199
+ describe("createNetworkConfiguration", () => {
200
+ beforeEach(() => {
201
+ jest.clearAllMocks();
202
+ });
203
+
204
+ it("should call balanceItem with correct BalanceUI objects for each network", () => {
205
+ const { result } = renderHook(() => createNetworkConfigurationHook(networkConfigurationDeps));
206
+ const res = result.current({ networksConfig: { rightElement: "balance" } });
207
+ res([baseCurrency, bscCurrency], [baseUsdcToken, bscUsdcToken]);
208
+
209
+ expect(balanceItem).toHaveBeenCalledTimes(2);
210
+ expect(balanceItem).toHaveBeenNthCalledWith(
211
+ 1,
212
+ expect.objectContaining({ balance: baseUsdcTokenAccount.balance }),
213
+ );
214
+ expect(balanceItem).toHaveBeenNthCalledWith(
215
+ 2,
216
+ expect.objectContaining({ balance: bscUsdcTokenAccount.balance }),
217
+ );
218
+ });
219
+
220
+ it("account count", () => {
221
+ const { result } = renderHook(() => createNetworkConfigurationHook(networkConfigurationDeps));
222
+ const res = result.current({ networksConfig: { leftElement: "numberOfAccounts" } });
223
+ res([baseCurrency, bscCurrency], [baseUsdcToken, bscUsdcToken]);
224
+
225
+ expect(accountsCount).toHaveBeenCalledTimes(4);
226
+ expect(accountsCount).toHaveBeenNthCalledWith(1, { label: "3 account" });
227
+ });
228
+
229
+ it("should order by balance (highest first) when only balance element is present", () => {
230
+ const { result } = renderHook(() => createNetworkConfigurationHook(networkConfigurationDeps));
231
+ const res = result.current({
232
+ networksConfig: { rightElement: "balance" },
233
+ });
234
+
235
+ const orderedResult = res(
236
+ [ethereumCurrency, polygonCurrency, bscCurrency],
237
+ [ethereumUsdcToken, polygonUsdcToken, bscUsdcToken],
238
+ );
239
+
240
+ expect(orderedResult).toHaveLength(3);
241
+
242
+ // Should be ordered by balance amount (highest first)
243
+ expect(orderedResult[0].id).toBe(ethereumCurrency.id); // 1000 ETH
244
+ expect(orderedResult[1].id).toBe(polygonCurrency.id); // 500 MATIC
245
+ expect(orderedResult[2].id).toBe(bscCurrency.id); // Lower balance
246
+ });
247
+
248
+ it("should order by account count (highest first) when only account count element is present", () => {
249
+ const { result } = renderHook(() => createNetworkConfigurationHook(networkConfigurationDeps));
250
+ const res = result.current({
251
+ networksConfig: { leftElement: "numberOfAccounts" },
252
+ });
253
+
254
+ const orderedResult = res(
255
+ [ethereumCurrency, polygonCurrency, bscCurrency],
256
+ [ethereumUsdcToken, polygonUsdcToken, bscUsdcToken],
257
+ );
258
+
259
+ expect(orderedResult).toHaveLength(3);
260
+
261
+ // Should be ordered by account count (highest first)
262
+ expect(orderedResult[0].id).toBe(ethereumCurrency.id); // 3 accounts
263
+ expect(orderedResult[1].id).toBe(bscCurrency.id); // 2 accounts
264
+ expect(orderedResult[2].id).toBe(polygonCurrency.id); // 1 account
265
+ });
266
+
267
+ it("should handle networks with zero balances by ordering them by account count", () => {
268
+ const zeroBalanceEth = { ...ethereumAccountZero };
269
+ const zeroBalancePoly = {
270
+ ...polygonAccountMedium,
271
+ balance: new BigNumber("0"),
272
+ spendableBalance: new BigNumber("0"),
273
+ };
274
+
275
+ const mockUseBalanceDepsZero = () => ({
276
+ counterValueCurrency: {
277
+ type: "FiatCurrency" as const,
278
+ ticker: "USD",
279
+ name: "US Dollar",
280
+ symbol: "$",
281
+ units: [
282
+ { code: "$", name: "US Dollar", magnitude: 2, showAllDigits: true, prefixCode: true },
283
+ ],
284
+ },
285
+ flattenedAccounts: [zeroBalanceEth, zeroBalancePoly],
286
+ state: { cache: {}, data: {}, status: {} },
287
+ locale: "en-US",
288
+ });
289
+
290
+ const { result } = renderHook(() =>
291
+ createNetworkConfigurationHook({
292
+ ...networkConfigurationDeps,
293
+ useBalanceDeps: mockUseBalanceDepsZero,
294
+ }),
295
+ );
296
+ const res = result.current({
297
+ networksConfig: { leftElement: "numberOfAccounts", rightElement: "balance" },
298
+ });
299
+
300
+ const orderedResult = res(
301
+ [ethereumCurrency, polygonCurrency],
302
+ [ethereumUsdcToken, polygonUsdcToken],
303
+ );
304
+
305
+ expect(orderedResult).toHaveLength(2);
306
+
307
+ // When both have zero balance, should order by account count
308
+ expect(orderedResult[0].id).toBe(ethereumCurrency.id); // 3 accounts
309
+ expect(orderedResult[1].id).toBe(polygonCurrency.id); // 1 account
310
+ });
311
+
312
+ it("should prioritise non-zero balances over account count", () => {
313
+ const testEthereumCurrency: CryptoCurrency = createFixtureCryptoCurrency("ethereum");
314
+ const testPolygonCurrency: CryptoCurrency = createFixtureCryptoCurrency("polygon");
315
+ const testAvalancheCurrency: CryptoCurrency = createFixtureCryptoCurrency("avalanche_c_chain");
316
+ const testArbitrumCurrency: CryptoCurrency = createFixtureCryptoCurrency("arbitrum");
317
+
318
+ const testEthereumAccount = genAccount("test-ethereum-account", {
319
+ currency: testEthereumCurrency,
320
+ });
321
+ testEthereumAccount.balance = new BigNumber("1000000000000000000000");
322
+ testEthereumAccount.spendableBalance = testEthereumAccount.balance;
323
+
324
+ const testPolygonAccount = genAccount("test-polygon-account", {
325
+ currency: testPolygonCurrency,
326
+ });
327
+ testPolygonAccount.balance = new BigNumber("500000000000000000000");
328
+ testPolygonAccount.spendableBalance = testPolygonAccount.balance;
329
+
330
+ const testEthereumUsdcToken = makeUsdcToken(
331
+ testEthereumCurrency,
332
+ "0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
333
+ );
334
+ const testPolygonUsdcToken = makeUsdcToken(
335
+ testPolygonCurrency,
336
+ "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
337
+ );
338
+ const testAvalancheUsdcToken = makeUsdcToken(
339
+ testAvalancheCurrency,
340
+ "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
341
+ );
342
+ const testArbitrumUsdcToken = makeUsdcToken(
343
+ testArbitrumCurrency,
344
+ "0xFF970A61A04b1cA14834A43f5de4533eBDDB5CC8",
345
+ );
346
+
347
+ const testUseBalanceDeps = () => ({
348
+ counterValueCurrency: mockFiatCurrency,
349
+ flattenedAccounts: [testEthereumAccount, testPolygonAccount],
350
+ state: { cache: {}, data: {}, status: {} },
351
+ locale: "en-US",
352
+ });
353
+
354
+ const testUseAccountData = () => [
355
+ makeAccountData(testEthereumCurrency, 3),
356
+ makeAccountData(testPolygonCurrency, 1),
357
+ makeAccountData(testAvalancheCurrency, 1),
358
+ makeAccountData(testArbitrumCurrency, 2),
359
+ ];
360
+
361
+ const { result } = renderHook(() =>
362
+ createNetworkConfigurationHook({
363
+ ...networkConfigurationDeps,
364
+ useAccountData: testUseAccountData,
365
+ useBalanceDeps: testUseBalanceDeps,
366
+ }),
367
+ );
368
+
369
+ const res = result.current({
370
+ networksConfig: { leftElement: "numberOfAccounts", rightElement: "balance" },
371
+ });
372
+
373
+ const orderedResult = res(
374
+ [testEthereumCurrency, testPolygonCurrency, testAvalancheCurrency, testArbitrumCurrency],
375
+ [testEthereumUsdcToken, testPolygonUsdcToken, testAvalancheUsdcToken, testArbitrumUsdcToken],
376
+ );
377
+
378
+ expect(orderedResult[0].id).toBe(testEthereumCurrency.id); // 1000 ETH balance, 3 accounts
379
+ expect(orderedResult[1].id).toBe(testPolygonCurrency.id); // 500 MATIC balance, 1 account
380
+ expect(orderedResult[2].id).toBe(testArbitrumCurrency.id); // (0 balance, 2 accounts)
381
+ expect(orderedResult[3].id).toBe(testAvalancheCurrency.id); // (0 balance, 1 account)
382
+ });
383
+ });
@@ -80,6 +80,7 @@ export type CompleteExchangeUiRequest = {
80
80
  magnitudeAwareRate?: BigNumber;
81
81
  refundAddress?: string;
82
82
  payoutAddress?: string;
83
+ sponsored?: boolean;
83
84
  };
84
85
  type FundStartParamsUiRequest = {
85
86
  exchangeType: "FUND";
@@ -386,6 +387,7 @@ export const handlers = ({
386
387
  toNewTokenId,
387
388
  customFeeConfig,
388
389
  swapAppVersion,
390
+ sponsored,
389
391
  } = params;
390
392
 
391
393
  const trackingParams = {
@@ -478,11 +480,14 @@ export const handlers = ({
478
480
  customFeeConfig: customFeeConfig ?? {},
479
481
  payinExtraId,
480
482
  extraTransactionParameters,
483
+ sponsored,
481
484
  };
482
485
 
483
- const transaction = await getStrategy(strategyData, "swap").catch(async error => {
484
- throw error;
485
- });
486
+ const transaction: Transaction = await getStrategy(strategyData, "swap").catch(
487
+ async error => {
488
+ throw error;
489
+ },
490
+ );
486
491
 
487
492
  const mainFromAccount = getMainAccount(fromAccount, fromParentAccount);
488
493
 
@@ -553,6 +558,7 @@ export const handlers = ({
553
558
  magnitudeAwareRate,
554
559
  refundAddress,
555
560
  payoutAddress,
561
+ sponsored,
556
562
  },
557
563
  onSuccess: ({ operationHash, swapId }: { operationHash: string; swapId: string }) => {
558
564
  tracking.completeExchangeSuccess({
@@ -775,6 +781,7 @@ interface StrategyParams {
775
781
  customFeeConfig?: Record<string, unknown>;
776
782
  payinExtraId?: string;
777
783
  extraTransactionParameters?: string;
784
+ sponsored?: boolean;
778
785
  }
779
786
 
780
787
  async function getStrategy(
@@ -785,6 +792,7 @@ async function getStrategy(
785
792
  customFeeConfig,
786
793
  payinExtraId,
787
794
  extraTransactionParameters,
795
+ sponsored,
788
796
  }: StrategyParams,
789
797
  customErrorType?: any,
790
798
  ): Promise<Transaction> {
@@ -823,6 +831,7 @@ async function getStrategy(
823
831
  payinExtraId,
824
832
  extraTransactionParameters,
825
833
  customErrorType,
834
+ sponsored,
826
835
  });
827
836
  } catch (error) {
828
837
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -17,6 +17,7 @@ import {
17
17
  } from "./converters";
18
18
  import { isWalletAPISupportedCurrency } from "./helpers";
19
19
  import { WalletAPICurrency, AppManifest, WalletAPIAccount, WalletAPICustomHandlers } from "./types";
20
+
20
21
  import { getMainAccount, getParentAccount } from "../account";
21
22
  import {
22
23
  listCurrencies,
@@ -628,6 +629,8 @@ export function useWalletAPIServer({
628
629
  server.setHandler(
629
630
  "transaction.signAndBroadcast",
630
631
  async ({ account, tokenCurrency, transaction, options }) => {
632
+ const sponsored = transaction.family === "ethereum" && transaction.sponsored;
633
+
631
634
  const signedTransaction = await signTransactionLogic(
632
635
  { manifest, accounts, tracking },
633
636
  account.id,
@@ -672,7 +675,10 @@ export function useWalletAPIServer({
672
675
  optimisticOperation = await bridge.broadcast({
673
676
  account: mainAccount,
674
677
  signedOperation,
675
- broadcastConfig: { mevProtected: !!config.mevProtected },
678
+ broadcastConfig: {
679
+ mevProtected: !!config.mevProtected,
680
+ sponsored,
681
+ },
676
682
  });
677
683
  tracking.broadcastSuccess(manifest);
678
684
  } catch (error) {