@funkit/connect 5.5.1 → 5.5.3

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 (31) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/components/MeldQuoteItem/MeldQuoteItem.d.ts +2 -2
  3. package/dist/components/SourceMeldQuoteItem/SourceMeldQuoteItem.d.ts +6 -1
  4. package/dist/domains/asset.d.ts +3 -1
  5. package/dist/hooks/queries/useMeldCurrencies.d.ts +1 -1
  6. package/dist/hooks/usePaymentSources.d.ts +0 -1
  7. package/dist/index.js +199 -105
  8. package/dist/modals/CheckoutModal/InputAmount/InputAmount.d.ts +2 -1
  9. package/dist/modals/CheckoutModal/MeldQuotes/MeldQuotes.d.ts +2 -1
  10. package/dist/modals/CheckoutModal/stepTransition.d.ts +5 -1
  11. package/dist/utils/flags/config.d.ts +18 -3
  12. package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
  13. package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
  14. package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
  15. package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
  16. package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
  17. package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
  18. package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
  19. package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
  20. package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
  21. package/dist/wallets/walletConnectors/index.js +66 -66
  22. package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
  23. package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
  24. package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
  25. package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
  26. package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
  27. package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
  28. package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
  29. package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
  30. package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
  31. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use client";
2
- import {
3
- lightTheme
4
- } from "./chunk-RN4I4Y57.js";
5
2
  import {
6
3
  darkTheme
7
4
  } from "./chunk-ICCAQZHZ.js";
5
+ import {
6
+ lightTheme
7
+ } from "./chunk-RN4I4Y57.js";
8
8
  import {
9
9
  systemFontStack
10
10
  } from "./chunk-R2UFCJL7.js";
@@ -3403,7 +3403,22 @@ var flagConfig = {
3403
3403
  default_value: JSON.stringify({
3404
3404
  listRefresh: 30 * 1e3,
3405
3405
  itemRefresh: 5 * 1e3
3406
- })
3406
+ }),
3407
+ overrides: [
3408
+ {
3409
+ if_any: [
3410
+ {
3411
+ key: "apiKey",
3412
+ type: "isAnyOf",
3413
+ values: [KATANA_API_KEY2, POLYMARKET_API_KEY2]
3414
+ }
3415
+ ],
3416
+ value: JSON.stringify({
3417
+ listRefresh: 5 * 1e3,
3418
+ itemRefresh: 2 * 1e3
3419
+ })
3420
+ }
3421
+ ]
3407
3422
  },
3408
3423
  [FlagKey.TokenTransferNewTokens]: {
3409
3424
  type: "string",
@@ -3420,7 +3435,7 @@ var flagConfig = {
3420
3435
  {
3421
3436
  value: true,
3422
3437
  if_any: [
3423
- // Full rollout to Katana and Ethereal users
3438
+ // Full rollout to Katana / Ethereal
3424
3439
  {
3425
3440
  key: "apiKey",
3426
3441
  type: "isAnyOf",
@@ -3448,7 +3463,7 @@ var flagConfig = {
3448
3463
  }
3449
3464
  ]
3450
3465
  },
3451
- // 1% rollout to Polymarket and Ostium users
3466
+ // 5% rollout to Ostium and Polymarket users
3452
3467
  {
3453
3468
  value: true,
3454
3469
  if_all: [
@@ -3460,7 +3475,7 @@ var flagConfig = {
3460
3475
  {
3461
3476
  key: "apiKey",
3462
3477
  type: "isAnyOf",
3463
- values: [POLYMARKET_API_KEY2, OSTIUM_API_KEY2]
3478
+ values: [OSTIUM_API_KEY2, POLYMARKET_API_KEY2]
3464
3479
  }
3465
3480
  ],
3466
3481
  if_any: [
@@ -3575,14 +3590,32 @@ var flagConfig = {
3575
3590
  },
3576
3591
  [FlagKey.EnableMeldPayment]: {
3577
3592
  type: "boolean",
3578
- default_value: true,
3593
+ default_value: false,
3579
3594
  overrides: [
3580
3595
  {
3581
3596
  if_any: [
3582
3597
  {
3583
3598
  key: "userId",
3584
3599
  type: "isAnyOf",
3585
- values: ["0x2A8Bd916E85d98d8175258De99fc0ddbcC102eF6"]
3600
+ values: [
3601
+ "0x6ec0c2f25d323e7779925Cc20c3740101f990d9F",
3602
+ "0xbeFE12aA8cBa36DD79F50eE5E23828adB62f2FD6",
3603
+ "0x2A8Bd916E85d98d8175258De99fc0ddbcC102eF6",
3604
+ "0xda6b07Eb94f699F511a943e9bFC12B64B7fe3486",
3605
+ "0x0D6e43CA32545B3dc2FE6f93AafBD7e640F548d4",
3606
+ "0x236c60C57a8B9ca563Fb0dA5199FDdCB686d91E8"
3607
+ // greg
3608
+ ]
3609
+ }
3610
+ ],
3611
+ value: true
3612
+ },
3613
+ {
3614
+ if_any: [
3615
+ {
3616
+ key: "userId",
3617
+ type: "pctRollout",
3618
+ pct: 100
3586
3619
  }
3587
3620
  ],
3588
3621
  value: false
@@ -4301,13 +4334,14 @@ var isAssetUsableToPayForCheckout = ({
4301
4334
  config,
4302
4335
  payerAddress,
4303
4336
  paymentMethod,
4337
+ targetChainId,
4338
+ targetTokenAddress,
4304
4339
  assetChainId,
4305
4340
  assetTokenAddress,
4306
4341
  assetUsdAmount,
4307
4342
  loginType,
4308
4343
  isAllowedForCheckout
4309
4344
  }) => {
4310
- const targetChainId = config.targetChain;
4311
4345
  const finalCheckoutRecipient = getCheckoutRecipient({
4312
4346
  config,
4313
4347
  walletAddress: payerAddress
@@ -4315,7 +4349,7 @@ var isAssetUsableToPayForCheckout = ({
4315
4349
  const isSameAsPurchasingToken = !isCheckoutPostActionRequired(config) && // however, if the recipient address is different from the payer address (via account balance payment), it is possible to transfer money
4316
4350
  paymentMethod === "balance" /* ACCOUNT_BALANCE */ && finalCheckoutRecipient.toLowerCase() === payerAddress.toLowerCase() && isTokenEquivalent2({
4317
4351
  firstTokenChainId: targetChainId,
4318
- firstTokenAddress: config.targetAsset,
4352
+ firstTokenAddress: targetTokenAddress,
4319
4353
  secondTokenChainId: assetChainId,
4320
4354
  secondTokenAddress: assetTokenAddress
4321
4355
  });
@@ -5495,7 +5529,7 @@ var getStyleProps = (type, isDisabled) => {
5495
5529
  focusedVisible: isDisabled ? void 0 : "buttonFocusedShadow"
5496
5530
  },
5497
5531
  paddingX: "24",
5498
- paddingY: isDisabled ? "11" : "10"
5532
+ paddingY: "10"
5499
5533
  };
5500
5534
  };
5501
5535
  function FunButton({
@@ -9802,6 +9836,8 @@ function useUsableWalletAssetsForCheckout() {
9802
9836
  config: checkoutItem.initSettings.config,
9803
9837
  payerAddress: walletAddress,
9804
9838
  paymentMethod: "balance" /* ACCOUNT_BALANCE */,
9839
+ targetChainId: checkoutItem.initSettings.config.targetChain,
9840
+ targetTokenAddress: checkoutItem.initSettings.config.targetAsset,
9805
9841
  assetChainId: asset.chainId,
9806
9842
  assetTokenAddress: asset.contractAddress,
9807
9843
  assetUsdAmount: asset.totalUsdValue,
@@ -13489,7 +13525,7 @@ var CheckoutCompleteInfo = {
13489
13525
  depositAddress: state.depositAddress
13490
13526
  };
13491
13527
  },
13492
- disableBack: true,
13528
+ disableBack: () => true,
13493
13529
  fallbackTitle: DEFAULT_CHECKOUT_HISTORY_DETAIL_TITLE
13494
13530
  };
13495
13531
  function CheckoutComplete({
@@ -16234,15 +16270,47 @@ function ConnectExchange({
16234
16270
  import { isMobile as isMobile5 } from "@funkit/utils";
16235
16271
  import React152, { useEffect as useEffect28 } from "react";
16236
16272
 
16273
+ // src/hooks/queries/useMeldCurrencies.ts
16274
+ import { getMeldSupportedFiat } from "@funkit/api-base";
16275
+ import { useQuery as useQuery11 } from "@tanstack/react-query";
16276
+ var getPriority = (currencyCode) => {
16277
+ if (currencyCode === "USD") return 0;
16278
+ if (currencyCode === "EUR") return 1;
16279
+ return 2;
16280
+ };
16281
+ var useMeldCurrencies = (isEnabled = true) => {
16282
+ const { apiKey } = useFunkitConfig();
16283
+ const query = useQuery11({
16284
+ queryKey: ["meld", "currencies"],
16285
+ queryFn: async () => {
16286
+ if (!apiKey) {
16287
+ return [];
16288
+ }
16289
+ const { currencies } = await getMeldSupportedFiat({ apiKey });
16290
+ return currencies.sort((a, b) => {
16291
+ const aPriority = getPriority(a.currencyCode);
16292
+ const bPriority = getPriority(b.currencyCode);
16293
+ if (aPriority !== bPriority) return aPriority - bPriority;
16294
+ return a.name.localeCompare(b.name);
16295
+ });
16296
+ },
16297
+ enabled: !!apiKey && isEnabled,
16298
+ refetchOnMount: false,
16299
+ refetchOnReconnect: false,
16300
+ refetchOnWindowFocus: false
16301
+ });
16302
+ return query;
16303
+ };
16304
+
16237
16305
  // src/hooks/queries/useMeldDefaultCurrency.ts
16238
16306
  import { getMeldDefaultFiat } from "@funkit/api-base";
16239
16307
  import { FlagKey as FlagKey18 } from "@funkit/utils";
16240
- import { useQuery as useQuery11 } from "@tanstack/react-query";
16308
+ import { useQuery as useQuery12 } from "@tanstack/react-query";
16241
16309
  var useMeldDefaultCurrency = (paymentMethod) => {
16242
16310
  const { apiKey } = useFunkitConfig();
16243
16311
  const { userIpInfo } = useFunkitUserIp();
16244
16312
  const enableMeld = useFlag(FlagKey18.EnableMeldPayment);
16245
- const query = useQuery11({
16313
+ const query = useQuery12({
16246
16314
  queryKey: ["meld", "defaultCurrency"],
16247
16315
  queryFn: async () => {
16248
16316
  if (!apiKey) return "";
@@ -16380,6 +16448,7 @@ var providerLabelMap = {
16380
16448
  KOYWE: "Koywe",
16381
16449
  MESH: "Mesh",
16382
16450
  MESO: "Meso",
16451
+ MERCURYO: "Mercuryo",
16383
16452
  ONMETA: "Onmeta",
16384
16453
  ONRAMPMONEY: "Onramp Money",
16385
16454
  PAYBIS: "Paybis",
@@ -16395,7 +16464,7 @@ var providerLabelMap = {
16395
16464
  };
16396
16465
  var MeldQuoteItem = ({
16397
16466
  quote,
16398
- badge,
16467
+ isBestQuote,
16399
16468
  onClick,
16400
16469
  isDisabled = false,
16401
16470
  isActive = false
@@ -16404,16 +16473,15 @@ var MeldQuoteItem = ({
16404
16473
  return /* @__PURE__ */ React141.createElement(FunSkeletonBlock, { height: "56", width: "full" });
16405
16474
  }
16406
16475
  const destinationCurrencyCode = quote.destinationCurrencyCode.split("_")[0];
16476
+ const cryptoDecimals = isStablecoin(destinationCurrencyCode) ? 2 : 5;
16407
16477
  const cryptoAmount = formatCryptoAndStringify2(
16408
16478
  quote.destinationAmount,
16409
16479
  destinationCurrencyCode,
16410
16480
  true,
16411
- // TODO: fix crypto formatting so that options are respected
16412
16481
  {
16413
- minimumSignificantDigits: 2,
16414
16482
  numberFormatOptions: {
16415
- minimumFractionDigits: 2,
16416
- maximumFractionDigits: 2
16483
+ minimumFractionDigits: cryptoDecimals,
16484
+ maximumFractionDigits: cryptoDecimals
16417
16485
  }
16418
16486
  }
16419
16487
  );
@@ -16443,14 +16511,12 @@ var MeldQuoteItem = ({
16443
16511
  alt: quote.serviceProvider,
16444
16512
  borderRadius: "full"
16445
16513
  }
16446
- )), /* @__PURE__ */ React141.createElement(Text, { weight: "medium", size: "12", style: { whiteSpace: "nowrap" } }, providerLabelMap[quote.serviceProvider] ?? quote.serviceProvider), badge && /* @__PURE__ */ React141.createElement(
16447
- FunBadge,
16514
+ )), /* @__PURE__ */ React141.createElement(
16515
+ MeldProviderLabel,
16448
16516
  {
16449
- background: "approvedBadgeBackground",
16450
- borderColor: "approvedBadgeBorder",
16451
- color: "approvedBadgeText"
16452
- },
16453
- badge
16517
+ serviceProvider: quote.serviceProvider,
16518
+ isBest: isBestQuote
16519
+ }
16454
16520
  )),
16455
16521
  /* @__PURE__ */ React141.createElement(Box, { display: "flex", alignItems: "center", gap: "8" }, /* @__PURE__ */ React141.createElement(
16456
16522
  Box,
@@ -16500,9 +16566,29 @@ var SourceMeldQuoteItem = ({
16500
16566
  alt: quote.serviceProvider,
16501
16567
  borderRadius: "full"
16502
16568
  }
16503
- ), /* @__PURE__ */ React142.createElement(Box, { display: "flex", flexDirection: "column" }, /* @__PURE__ */ React142.createElement(Text, { size: "12", weight: "medium" }, providerLabelMap[quote.serviceProvider]), isBestQuote && /* @__PURE__ */ React142.createElement(Text, { color: "approvedBadgeText", size: "10" }, "Best price"))) : /* @__PURE__ */ React142.createElement(Text, { size: "12", color: "secondaryText", weight: "medium" }, "No quotes found")), /* @__PURE__ */ React142.createElement(ArrowIcon, { direction: "right", size: 16 }))
16569
+ ), /* @__PURE__ */ React142.createElement(
16570
+ MeldProviderLabel,
16571
+ {
16572
+ serviceProvider: quote.serviceProvider,
16573
+ isBest: isBestQuote
16574
+ }
16575
+ )) : /* @__PURE__ */ React142.createElement(Text, { size: "12", color: "secondaryText", weight: "medium" }, "No quotes found")), /* @__PURE__ */ React142.createElement(ArrowIcon, { direction: "right", size: 16 }))
16504
16576
  );
16505
16577
  };
16578
+ var MeldProviderLabel = ({
16579
+ serviceProvider,
16580
+ isBest
16581
+ }) => {
16582
+ return /* @__PURE__ */ React142.createElement(Box, { display: "flex", flexDirection: "column", gap: "2" }, /* @__PURE__ */ React142.createElement(Text, { size: "12", weight: "medium", style: { whiteSpace: "nowrap" } }, providerLabelMap[serviceProvider] ?? serviceProvider), isBest && /* @__PURE__ */ React142.createElement(
16583
+ Text,
16584
+ {
16585
+ color: "approvedBadgeText",
16586
+ size: "10",
16587
+ style: { whiteSpace: "nowrap" }
16588
+ },
16589
+ "Best price"
16590
+ ));
16591
+ };
16506
16592
 
16507
16593
  // src/components/SourcePaymentMethodItem/SourcePaymentMethodItem.tsx
16508
16594
  import clsx14 from "clsx";
@@ -17268,7 +17354,7 @@ var YouPayYouReceiveBottomBarLayoutWrapper = ({
17268
17354
  // src/hooks/queries/useMeldLimits.ts
17269
17355
  import { getMeldFiatLimits } from "@funkit/api-base";
17270
17356
  import { formatCurrencyAndStringify as formatCurrencyAndStringify6 } from "@funkit/utils";
17271
- import { useQuery as useQuery12 } from "@tanstack/react-query";
17357
+ import { useQuery as useQuery13 } from "@tanstack/react-query";
17272
17358
  import { useMemo as useMemo23 } from "react";
17273
17359
 
17274
17360
  // src/hooks/queries/useMeldCryptoCurrencyCode.ts
@@ -17284,7 +17370,7 @@ var useMeldLimits = (fiatCurrency) => {
17284
17370
  const { apiKey } = useFunkitConfig();
17285
17371
  const { userIpInfo } = useFunkitUserIp();
17286
17372
  const cryptoCurrency = useMeldCryptoCurrencyCode();
17287
- const query = useQuery12({
17373
+ const query = useQuery13({
17288
17374
  queryKey: ["meld", "limits", userIpInfo?.alpha2, cryptoCurrency],
17289
17375
  queryFn: async () => {
17290
17376
  if (!apiKey || !userIpInfo) return void 0;
@@ -17440,7 +17526,7 @@ var useMeldLink = (sourceAmount, sourceCurrencyCode = "USD") => {
17440
17526
 
17441
17527
  // src/modals/CheckoutModal/MeldQuotes/useMeldQuotes.tsx
17442
17528
  import { getMeldQuotes } from "@funkit/api-base";
17443
- import { useQuery as useQuery13 } from "@tanstack/react-query";
17529
+ import { useQuery as useQuery14 } from "@tanstack/react-query";
17444
17530
  import { useDebounce } from "use-debounce";
17445
17531
  var DEBOUNCE_DELAY = 500;
17446
17532
  var COUNTDOWN_INTERVAL_SEC = 60;
@@ -17452,7 +17538,7 @@ var useMeldQuotes = (sourceAmount, fiatCurrency) => {
17452
17538
  const { isAway } = useUserPresence();
17453
17539
  const destinationCurrencyCode = useMeldCryptoCurrencyCode();
17454
17540
  const sourceCurrencyCode = fiatCurrency || "USD";
17455
- const query = useQuery13({
17541
+ const query = useQuery14({
17456
17542
  queryKey: [
17457
17543
  "meld",
17458
17544
  "quotes",
@@ -17482,7 +17568,8 @@ var useMeldQuotes = (sourceAmount, fiatCurrency) => {
17482
17568
  },
17483
17569
  enabled: !!userIpInfo && !!apiKey && !!destinationCurrencyCode && !isAway && !!fiatCurrency,
17484
17570
  refetchInterval: COUNTDOWN_INTERVAL_SEC * 1e3,
17485
- refetchOnWindowFocus: false
17571
+ refetchOnWindowFocus: false,
17572
+ retry: false
17486
17573
  });
17487
17574
  const { countdown } = useCountdown({
17488
17575
  countdownSeconds: COUNTDOWN_INTERVAL_SEC,
@@ -17999,8 +18086,8 @@ function InputAmountLoaded({
17999
18086
  }
18000
18087
  if (meldQuotesQuery.error) {
18001
18088
  return {
18002
- message: "An error occurred. Please try again or contact us for more information",
18003
- type: "error"
18089
+ message: "It seems something didn't work. Our team has been notified of the issue",
18090
+ type: "hint"
18004
18091
  };
18005
18092
  }
18006
18093
  }
@@ -18049,13 +18136,14 @@ function InputAmountLoaded({
18049
18136
  ASSET_DECIMALS
18050
18137
  );
18051
18138
  const isConvertedAmountShown = targetAssetTicker && (!isInputInUsd || isCardCheckout && fiatCurrency === "USD" || !isCardCheckout);
18139
+ const isMeldContinueDisabled = meldEnabled && (!!meldLimitError || isMeldLinkPending || !!meldQuotesQuery.error || meldQuotesQuery.isFetching || isSelectedQuoteUnavailable);
18052
18140
  return /* @__PURE__ */ React150.createElement(
18053
18141
  InputAmountLayout,
18054
18142
  {
18055
18143
  actionButtonProps: {
18056
18144
  title: suggestion?.buttonLabel ?? "Continue",
18057
18145
  onClick: handleSubmit,
18058
- isDisabled: !isValid && !suggestion || error?.type === "error" || !!meldLimitError || isMeldLinkPending || meldQuotesQuery.isFetching || isCardCheckout && isSelectedQuoteUnavailable,
18146
+ isDisabled: !isValid && !suggestion || isMeldContinueDisabled,
18059
18147
  isLoading: isMeldLinkPending
18060
18148
  },
18061
18149
  fiatCurrencySelector: meldEnabled && /* @__PURE__ */ React150.createElement(
@@ -18153,12 +18241,13 @@ function InputAmountLoaded({
18153
18241
  }
18154
18242
  }
18155
18243
  ),
18156
- footer: meldEnabled ? /* @__PURE__ */ React150.createElement(
18244
+ footer: meldEnabled ? /* @__PURE__ */ React150.createElement(Box, { paddingX: "6" }, /* @__PURE__ */ React150.createElement(
18157
18245
  SourceMeldQuoteItem,
18158
18246
  {
18159
18247
  onClick: () => onNext({
18160
18248
  fiatAmount: usdAmount,
18161
18249
  fiatCurrency,
18250
+ provider: selectedQuote?.serviceProvider,
18162
18251
  nextStep: "meld_quotes" /* MELD_QUOTES */
18163
18252
  }),
18164
18253
  quote: selectedQuote,
@@ -18168,7 +18257,7 @@ function InputAmountLoaded({
18168
18257
  isPreselected: !manuallySelectedQuote && !!bestRateQuote,
18169
18258
  error: meldLimitError?.issue
18170
18259
  }
18171
- ) : /* @__PURE__ */ React150.createElement(
18260
+ )) : /* @__PURE__ */ React150.createElement(
18172
18261
  YouPayYouReceiveWrapper,
18173
18262
  {
18174
18263
  targetChainId: modalState.targetChainId,
@@ -18318,7 +18407,7 @@ function InputAmountLoading({
18318
18407
  )
18319
18408
  ),
18320
18409
  amountOptions: /* @__PURE__ */ React151.createElement(QuickOptions, { disabled: true, percentMode: !isCardCheckout }),
18321
- footer: isMeldCheckout ? /* @__PURE__ */ React151.createElement(SourceMeldQuoteItem, { isLoading: true }) : /* @__PURE__ */ React151.createElement(YouPayYouReceiveBottomBarLayoutWrapper, null, /* @__PURE__ */ React151.createElement(
18410
+ footer: isMeldCheckout ? /* @__PURE__ */ React151.createElement(Box, { paddingX: "6" }, /* @__PURE__ */ React151.createElement(SourceMeldQuoteItem, { isLoading: true })) : /* @__PURE__ */ React151.createElement(YouPayYouReceiveBottomBarLayoutWrapper, null, /* @__PURE__ */ React151.createElement(
18322
18411
  FunSkeletonBlock,
18323
18412
  {
18324
18413
  borderRadius: "youPayYouReceive",
@@ -18340,7 +18429,7 @@ import {
18340
18429
  convertFunToRelayTokenAddress,
18341
18430
  getRelayAssetPriceInfo
18342
18431
  } from "@funkit/fun-relay";
18343
- import { skipToken, useQuery as useQuery14 } from "@tanstack/react-query";
18432
+ import { skipToken, useQuery as useQuery15 } from "@tanstack/react-query";
18344
18433
  async function getFormattedRelayAssetPriceInfo({
18345
18434
  chainId,
18346
18435
  assetTokenAddress
@@ -18366,7 +18455,7 @@ function useAssetPrice({
18366
18455
  assetTokenAddress
18367
18456
  }) {
18368
18457
  const { apiKey } = useFunkitConfig();
18369
- const { data, error, isLoading } = useQuery14({
18458
+ const { data, error, isLoading } = useQuery15({
18370
18459
  queryKey: ["getAssetPriceInfo", chainId, assetTokenAddress],
18371
18460
  queryFn: chainId && assetTokenAddress ? async () => {
18372
18461
  const isRelayPrimary = RELAY_SHORT_CIRCUIT_CHAIN_IDS.includes(chainId);
@@ -18468,7 +18557,8 @@ var InputAmountInfo = {
18468
18557
  step: "meld_quotes" /* MELD_QUOTES */,
18469
18558
  fiatAmount: payload.fiatAmount,
18470
18559
  paymentMethodInfo: state.paymentMethodInfo,
18471
- fiatCurrency: payload.fiatCurrency ?? state.fiatCurrency
18560
+ fiatCurrency: payload.fiatCurrency ?? state.fiatCurrency,
18561
+ provider: payload.provider
18472
18562
  };
18473
18563
  }
18474
18564
  return {
@@ -18477,9 +18567,14 @@ var InputAmountInfo = {
18477
18567
  paymentMethodInfo: state.paymentMethodInfo
18478
18568
  };
18479
18569
  },
18480
- showFullHeight: !isMobile5()
18570
+ showFullHeight: !isMobile5(),
18571
+ // back should be disabled in card flow in input_amount
18572
+ disableBack: ({ state }) => {
18573
+ return state.paymentMethodInfo?.paymentMethod === "card" /* CARD */;
18574
+ }
18481
18575
  };
18482
18576
  function InputAmount(props) {
18577
+ const { paymentMethodInfo } = props.modalState;
18483
18578
  const { textCustomizations } = useFunkitConfig();
18484
18579
  const { setCheckoutQuote } = useQuoteContext();
18485
18580
  const { checkoutItem } = useCheckoutContext();
@@ -18488,12 +18583,13 @@ function InputAmount(props) {
18488
18583
  error: sourceHoldingError,
18489
18584
  isLoading: isLoadingSourceHolding
18490
18585
  } = useAvailableBalanceForCheckout(
18491
- props.modalState.paymentMethodInfo,
18586
+ paymentMethodInfo,
18492
18587
  checkoutItem?.initSettings.config.targetChain ?? "",
18493
18588
  checkoutItem?.selectedSourceAssetInfo.chainId ?? "",
18494
18589
  checkoutItem?.selectedSourceAssetInfo.symbol ?? null
18495
18590
  );
18496
- const { data: defaultCurrency, isLoading: isMeldDefaultCurrencyLoading } = useMeldDefaultCurrency(props.modalState.paymentMethodInfo.paymentMethod);
18591
+ const { data: defaultCurrency, isLoading: isMeldDefaultCurrencyLoading } = useMeldDefaultCurrency(paymentMethodInfo.paymentMethod);
18592
+ useMeldCurrencies(paymentMethodInfo.paymentMethod === "card" /* CARD */);
18497
18593
  const { error: unitPriceError, unitPrice } = useAssetPrice({
18498
18594
  chainId: checkoutItem?.initSettings.config.targetChain,
18499
18595
  assetTokenAddress: checkoutItem?.initSettings.config.targetAsset
@@ -18900,38 +18996,6 @@ var FunNoResults = ({ text }) => {
18900
18996
  var hideScrollBar = "_163ehmk0";
18901
18997
  var selectWrapperStyle = "_163ehmk1";
18902
18998
 
18903
- // src/hooks/queries/useMeldCurrencies.ts
18904
- import { getMeldSupportedFiat } from "@funkit/api-base";
18905
- import { useQuery as useQuery15 } from "@tanstack/react-query";
18906
- var getPriority = (currencyCode) => {
18907
- if (currencyCode === "USD") return 0;
18908
- if (currencyCode === "EUR") return 1;
18909
- return 2;
18910
- };
18911
- var useMeldCurrencies = () => {
18912
- const { apiKey } = useFunkitConfig();
18913
- const query = useQuery15({
18914
- queryKey: ["meld", "currencies"],
18915
- queryFn: async () => {
18916
- if (!apiKey) {
18917
- return [];
18918
- }
18919
- const { currencies } = await getMeldSupportedFiat({ apiKey });
18920
- return currencies.sort((a, b) => {
18921
- const aPriority = getPriority(a.currencyCode);
18922
- const bPriority = getPriority(b.currencyCode);
18923
- if (aPriority !== bPriority) return aPriority - bPriority;
18924
- return a.name.localeCompare(b.name);
18925
- });
18926
- },
18927
- enabled: !!apiKey,
18928
- refetchOnMount: false,
18929
- refetchOnReconnect: false,
18930
- refetchOnWindowFocus: false
18931
- });
18932
- return query;
18933
- };
18934
-
18935
18999
  // src/modals/CheckoutModal/MeldCurrencySelect/MeldCurrencySelect.tsx
18936
19000
  var MeldCurrencySelectInfo = {
18937
19001
  Component: MeldCurrencySelect,
@@ -18946,7 +19010,17 @@ var MeldCurrencySelectInfo = {
18946
19010
  paymentMethodInfo: state.paymentMethodInfo
18947
19011
  };
18948
19012
  },
18949
- title: (_textCustomizations) => "Currency"
19013
+ title: (_textCustomizations) => "Currency",
19014
+ onBack: (state) => {
19015
+ const common = extractCommonState(state);
19016
+ return {
19017
+ ...common,
19018
+ step: "input_amount" /* INPUT_AMOUNT */,
19019
+ fiatAmount: state.fiatAmount,
19020
+ fiatCurrency: state.defaultCurrency,
19021
+ paymentMethodInfo: state.paymentMethodInfo
19022
+ };
19023
+ }
18950
19024
  };
18951
19025
  function MeldCurrencySelect({
18952
19026
  modalState,
@@ -19036,7 +19110,17 @@ var MeldQuotesInfo = {
19036
19110
  paymentMethodInfo: state.paymentMethodInfo
19037
19111
  };
19038
19112
  },
19039
- title: (_textCustomizations) => "Quotes"
19113
+ title: (_textCustomizations) => "Quotes",
19114
+ onBack: (state) => {
19115
+ const common = extractCommonState(state);
19116
+ return {
19117
+ ...common,
19118
+ step: "input_amount" /* INPUT_AMOUNT */,
19119
+ fiatAmount: state.fiatAmount,
19120
+ fiatCurrency: state.fiatCurrency,
19121
+ paymentMethodInfo: state.paymentMethodInfo
19122
+ };
19123
+ }
19040
19124
  };
19041
19125
  function MeldQuotes({
19042
19126
  modalState,
@@ -19055,7 +19139,8 @@ function MeldQuotes({
19055
19139
  MeldQuoteItem,
19056
19140
  {
19057
19141
  key: quote.serviceProvider,
19058
- badge: index === 0 ? "Best Price" : void 0,
19142
+ isBestQuote: index === 0,
19143
+ isActive: modalState.provider === quote.serviceProvider,
19059
19144
  quote,
19060
19145
  onClick: () => onNext({ quote, navigateToHistoryStep: true })
19061
19146
  }
@@ -20628,7 +20713,7 @@ var ASSET_ITEM_HEIGHT = 52;
20628
20713
  var VISIBLE_ITEMS_COUNT = 5;
20629
20714
  var SelectAssetInfo = {
20630
20715
  Component: SelectAsset,
20631
- disableBack: true,
20716
+ disableBack: ({ apiKey }) => !isOstiumCustomer(apiKey),
20632
20717
  onNext(state, payload) {
20633
20718
  const common = extractCommonState(state);
20634
20719
  if (payload.disconnectedBrokerage) {
@@ -20662,7 +20747,8 @@ var isKnownAsset2 = (asset) => asset.usdAmount !== null;
20662
20747
  function useEnrichedAccountHoldings({
20663
20748
  paymentMethodInfo,
20664
20749
  checkoutConfig,
20665
- accountHoldings
20750
+ accountHoldings,
20751
+ targetAssetInfo
20666
20752
  }) {
20667
20753
  const { apiKey } = useFunkitConfig();
20668
20754
  const { isAllowed, isLoading } = useAllowedAssets();
@@ -20673,6 +20759,8 @@ function useEnrichedAccountHoldings({
20673
20759
  const usableForCheckout = isAssetUsableToPayForCheckout({
20674
20760
  apiKey,
20675
20761
  config: checkoutConfig,
20762
+ targetTokenAddress: targetAssetInfo.tokenAddress,
20763
+ targetChainId: targetAssetInfo.tokenChainId,
20676
20764
  paymentMethod: paymentMethodInfo.paymentMethod,
20677
20765
  payerAddress: walletAddress,
20678
20766
  assetChainId: asset.pickedChainId,
@@ -20696,7 +20784,8 @@ function useEnrichedAccountHoldings({
20696
20784
  isAllowed,
20697
20785
  loginType,
20698
20786
  paymentMethodInfo.paymentMethod,
20699
- walletAddress
20787
+ walletAddress,
20788
+ targetAssetInfo
20700
20789
  ]);
20701
20790
  return { enrichedAccountHoldings, isLoading };
20702
20791
  }
@@ -20768,7 +20857,13 @@ function MeshOrAccountSelectAsset({
20768
20857
  const isTargetAssetSelectable = withTargetAssetSection && candidates;
20769
20858
  const defaultTargetAsset = isTargetAssetSelectable ? candidates.find(
20770
20859
  (token) => token.tokenSymbol === checkoutConfig?.targetAssetTicker
20771
- ) ?? candidates.find((token) => token.isDefault) ?? candidates[0] : void 0;
20860
+ ) ?? candidates.find((token) => token.isDefault) ?? candidates[0] : {
20861
+ tokenAddress: checkoutItem?.initSettings.config.targetAsset || "0x",
20862
+ tokenChainId: checkoutItem?.initSettings.config.targetChain || "",
20863
+ tokenSymbol: checkoutItem?.initSettings.config.targetAssetTicker || "",
20864
+ iconSrc: checkoutItem?.initSettings.config.iconSrc || "",
20865
+ targetAssetMinAmount: 0
20866
+ };
20772
20867
  const [selectedTargetAsset, setSelectedTargetAsset] = useState42(defaultTargetAsset);
20773
20868
  const defaultTokenSymbols = useMemo33(() => {
20774
20869
  if (!checkoutConfig) {
@@ -20785,7 +20880,8 @@ function MeshOrAccountSelectAsset({
20785
20880
  const { enrichedAccountHoldings, isLoading: isLoadingEnrichedHoldings } = useEnrichedAccountHoldings({
20786
20881
  accountHoldings,
20787
20882
  paymentMethodInfo,
20788
- checkoutConfig
20883
+ checkoutConfig,
20884
+ targetAssetInfo: selectedTargetAsset
20789
20885
  });
20790
20886
  const assetOptions = useAssetOptions({
20791
20887
  enrichedAccountHoldings,
@@ -20884,7 +20980,7 @@ function MeshOrAccountSelectAsset({
20884
20980
  asset,
20885
20981
  isActive: selectedChainTokenSymbol === asset.chainSymbolKey,
20886
20982
  isDisabled: isDisabled2,
20887
- badgeText,
20983
+ badgeText: isPolymarketCustomer(apiKey) && badgeText === "Same Asset" ? "" : badgeText,
20888
20984
  onClick: () => setSelectedChainTokenSymbol(asset.chainSymbolKey)
20889
20985
  }
20890
20986
  )));
@@ -21320,11 +21416,10 @@ var usePaymentSources = (paymentMethodInfo, targetChainId, checkoutConfig) => {
21320
21416
  isTokenInNewSources && "token_transfer" /* TOKEN_TRANSFER */,
21321
21417
  isBrokerageEnabled && "brokerage" /* BROKERAGE */,
21322
21418
  isBankInNewSources && "virtual_bank" /* VIRTUAL_BANK */,
21323
- isWalletInNewSources && "balance" /* ACCOUNT_BALANCE */
21419
+ isWalletInNewSources && "balance" /* ACCOUNT_BALANCE */,
21420
+ !fallback2.includes("card" /* CARD */) && isCardEnabled && "card" /* CARD */
21324
21421
  ].filter((b) => !!b);
21325
- const promotedSource = !fallback2.includes("card" /* CARD */) && isCardEnabled ? "card" /* CARD */ : void 0;
21326
21422
  return {
21327
- promoted: promotedSource,
21328
21423
  preferred: connected.length > 0 ? connected : fallback2,
21329
21424
  moreSources: newSources
21330
21425
  };
@@ -21607,7 +21702,7 @@ function SourceChange({
21607
21702
  titleCustomization: textCustomizations.debitOrCredit
21608
21703
  });
21609
21704
  updateSelectedPaymentMethodInfo(paymentMethodInfo2);
21610
- await onSelectCard();
21705
+ if (!enableMeldPayment) await onSelectCard();
21611
21706
  onNext({
21612
21707
  connectNew: true,
21613
21708
  paymentMethod: newSource2,
@@ -21654,7 +21749,7 @@ function SourceChange({
21654
21749
  });
21655
21750
  }
21656
21751
  };
21657
- const { promoted, preferred, moreSources } = usePaymentSources(
21752
+ const { preferred, moreSources } = usePaymentSources(
21658
21753
  paymentMethodInfo,
21659
21754
  targetChainId,
21660
21755
  checkoutItem?.initSettings.config
@@ -21684,14 +21779,7 @@ function SourceChange({
21684
21779
  );
21685
21780
  }
21686
21781
  const bottomSectionRef = useBottomSectionRef();
21687
- return /* @__PURE__ */ React185.createElement(React185.Fragment, null, /* @__PURE__ */ React185.createElement(Box, { display: "flex", flexDirection: "column", gap: "4" }, promoted && renderSource(promoted), promoted && paymentMethodInfo && /* @__PURE__ */ React185.createElement(
21688
- FunDivider,
21689
- {
21690
- marginTop: "8",
21691
- marginBottom: "8",
21692
- borderColor: "selectedOptionBorder"
21693
- }
21694
- ), preferred.map(renderSource), preferred.length > 0 && moreSources.length > 0 && /* @__PURE__ */ React185.createElement(
21782
+ return /* @__PURE__ */ React185.createElement(React185.Fragment, null, /* @__PURE__ */ React185.createElement(Box, { display: "flex", flexDirection: "column", gap: "4" }, preferred.map(renderSource), preferred.length > 0 && moreSources.length > 0 && /* @__PURE__ */ React185.createElement(
21695
21783
  FunDivider,
21696
21784
  {
21697
21785
  label: "more",
@@ -22545,7 +22633,7 @@ var getMaxSlippage = (sourceToken, targetToken, isSameChain) => {
22545
22633
  // src/modals/CheckoutModal/TransferToken/TransferToken.tsx
22546
22634
  var TransferTokenInfo = {
22547
22635
  Component: TransferToken,
22548
- disableBack: true,
22636
+ disableBack: () => true,
22549
22637
  onNext: (state) => {
22550
22638
  const common = extractCommonState(state);
22551
22639
  return {
@@ -23090,7 +23178,7 @@ var AccountDetailsScreen = ({
23090
23178
  };
23091
23179
  var FiatAccountDetail = {
23092
23180
  Component: AccountDetailsScreen,
23093
- disableBack: true,
23181
+ disableBack: () => true,
23094
23182
  onNext(state, _payload) {
23095
23183
  const common = extractCommonState(state);
23096
23184
  return {
@@ -23146,7 +23234,7 @@ var KycIframeInfo = {
23146
23234
  };
23147
23235
  },
23148
23236
  title: (textCustomizations) => textCustomizations.virtualFiat,
23149
- disableBack: true
23237
+ disableBack: () => true
23150
23238
  };
23151
23239
  function KycIframe({
23152
23240
  modalState,
@@ -23392,10 +23480,16 @@ function useCheckoutModalTransition(checkoutItem, onClose) {
23392
23480
  }
23393
23481
  function useTitleConfig(checkoutItem, state) {
23394
23482
  const { apiKey, textCustomizations } = useFunkitConfig();
23395
- const { showFullHeight, disableBack, hideClose, title, fallbackTitle } = CheckoutModalSteps[state.step];
23483
+ const {
23484
+ showFullHeight,
23485
+ disableBack = () => false,
23486
+ hideClose,
23487
+ title,
23488
+ fallbackTitle
23489
+ } = CheckoutModalSteps[state.step];
23396
23490
  const baseTitle = checkoutItem.initSettings.config.modalTitle ?? fallbackTitle ?? "Checkout";
23397
23491
  return {
23398
- disableBack: isOstiumCustomer(apiKey) && state.step === "select_asset" /* SELECT_ASSET */ ? false : disableBack ?? false,
23492
+ disableBack: disableBack({ state, apiKey }),
23399
23493
  hideClose: hideClose ?? false,
23400
23494
  showFullHeight: showFullHeight ?? ((isVertexCustomer(apiKey) || isKatanaCustomer(apiKey)) && state.step === "select_asset" /* SELECT_ASSET */),
23401
23495
  title: title?.(textCustomizations) ?? baseTitle
@@ -29981,7 +30075,7 @@ function setFunkitConnectVersion({ version }) {
29981
30075
  localStorage.setItem(storageKey5, version);
29982
30076
  }
29983
30077
  function getCurrentSdkVersion() {
29984
- return "5.5.1";
30078
+ return "5.5.3";
29985
30079
  }
29986
30080
  function useFingerprint() {
29987
30081
  const fingerprint = useCallback49(() => {