@funkit/connect 9.5.0 → 9.5.1

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 (55) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/__generated__/default_configs.d.ts +145 -6
  3. package/dist/__generated__/default_feature_gates.d.ts +1 -0
  4. package/dist/clients/{chunk-SBQ2UUPK.js → chunk-H6F75ULR.js} +7 -1
  5. package/dist/clients/fanatics.js +1 -1
  6. package/dist/clients/polymarket.js +1 -1
  7. package/dist/components/Dropdown/ChainDropdown.d.ts +1 -3
  8. package/dist/components/Dropdown/TokenAndChainDropdown.d.ts +1 -3
  9. package/dist/hooks/track/CheckoutModalEvent.d.ts +1 -0
  10. package/dist/hooks/useTokenAndChainDropdown.d.ts +0 -1
  11. package/dist/hooks/useTokenTransfer.d.ts +7 -11
  12. package/dist/hooks/useTokenTransferConfig.d.ts +1 -1
  13. package/dist/index.js +1513 -1268
  14. package/dist/modals/CheckoutModal/SwappedIframe/SwappedIframeContainer.d.ts +1 -1
  15. package/dist/providers/SwappedProvider.d.ts +2 -1
  16. package/dist/utils/bluvo.d.ts +2 -4
  17. package/dist/utils/funLogger.d.ts +3 -1
  18. package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
  19. package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
  20. package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
  21. package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
  22. package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
  23. package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
  24. package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
  25. package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
  26. package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
  27. package/dist/wallets/walletConnectors/index.js +47 -47
  28. package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
  29. package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
  30. package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
  31. package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
  32. package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
  33. package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
  34. package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
  35. package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
  36. package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
  37. package/package.json +3 -3
  38. package/dist/wallets/walletConnectors/{chunk-6YO27XOM.js → chunk-3Y2GG3PM.js} +3 -3
  39. package/dist/wallets/walletConnectors/{chunk-HETS3KKI.js → chunk-3YCR2ZB4.js} +3 -3
  40. package/dist/wallets/walletConnectors/{chunk-HOPH3TQ3.js → chunk-C4RP2DNH.js} +3 -3
  41. package/dist/wallets/walletConnectors/{chunk-IICWJWGZ.js → chunk-CBI3SGOC.js} +3 -3
  42. package/dist/wallets/walletConnectors/{chunk-GVOQTORD.js → chunk-CMLFDRCP.js} +3 -3
  43. package/dist/wallets/walletConnectors/{chunk-LI6QY2B5.js → chunk-COX3VEDR.js} +3 -3
  44. package/dist/wallets/walletConnectors/{chunk-EKJHJFRN.js → chunk-CT3QPTAU.js} +3 -3
  45. package/dist/wallets/walletConnectors/{chunk-7OARWILZ.js → chunk-DWMUM4F6.js} +3 -3
  46. package/dist/wallets/walletConnectors/{chunk-CJJT7LMT.js → chunk-FDVJHNLL.js} +3 -3
  47. package/dist/wallets/walletConnectors/{chunk-6UCI7GM6.js → chunk-I7K6LUZR.js} +3 -3
  48. package/dist/wallets/walletConnectors/{chunk-XBLHZICW.js → chunk-N3UJMC3V.js} +3 -3
  49. package/dist/wallets/walletConnectors/{chunk-4C7ER452.js → chunk-NEK7T3IC.js} +3 -3
  50. package/dist/wallets/walletConnectors/{chunk-PKMAPNN6.js → chunk-RLLTYOWT.js} +3 -3
  51. package/dist/wallets/walletConnectors/{chunk-GH4M6FTK.js → chunk-TIT5F32X.js} +3 -3
  52. package/dist/wallets/walletConnectors/{chunk-TTHM3WUR.js → chunk-UPUDLUBT.js} +3 -3
  53. package/dist/wallets/walletConnectors/{chunk-53VYSPXK.js → chunk-UVMMPRDM.js} +3 -3
  54. package/dist/wallets/walletConnectors/{chunk-GSHSWVEG.js → chunk-UVYZSGIX.js} +3 -3
  55. package/dist/wallets/walletConnectors/{chunk-KO56HCTI.js → chunk-ZMRIQOR5.js} +3 -3
package/dist/index.js CHANGED
@@ -686,6 +686,7 @@ var FunLogger = class {
686
686
  this.userAddress = null;
687
687
  this.userName = null;
688
688
  this.userLoginType = null;
689
+ this.typeLabel = null;
689
690
  this.sdkVersion = null;
690
691
  this.l2Address = null;
691
692
  this.isConfigured = false;
@@ -709,6 +710,7 @@ var FunLogger = class {
709
710
  userName: this.userName,
710
711
  userAddress: this.userAddress,
711
712
  userLoginType: this.userLoginType,
713
+ typeLabel: this.typeLabel,
712
714
  sdkVersion: this.sdkVersion
713
715
  };
714
716
  switch (level) {
@@ -850,14 +852,18 @@ var FunLogger = class {
850
852
  getUserLoginType() {
851
853
  return this.userLoginType;
852
854
  }
855
+ getTypeLabel() {
856
+ return this.typeLabel;
857
+ }
853
858
  getL2Address() {
854
859
  return this.l2Address;
855
860
  }
856
- setUserInfo(userId, userAddress, userName, userLoginType, l2Address) {
861
+ setUserInfo(userId, userAddress, userName, userLoginType, typeLabel, l2Address) {
857
862
  this.userId = userId;
858
863
  this.userAddress = userAddress;
859
864
  this.userName = userName;
860
865
  this.userLoginType = userLoginType;
866
+ this.typeLabel = typeLabel;
861
867
  this.l2Address = l2Address ?? null;
862
868
  }
863
869
  };
@@ -1148,7 +1154,7 @@ import {
1148
1154
  isTokenEquivalent as isTokenEquivalent8,
1149
1155
  round as round4
1150
1156
  } from "@funkit/utils";
1151
- import { arbitrum as arbitrum6, base as base7, mainnet as mainnet11, optimism as optimism2, polygon as polygon8 } from "viem/chains";
1157
+ import { arbitrum as arbitrum6, base as base7, mainnet as mainnet10, optimism as optimism2, polygon as polygon8 } from "viem/chains";
1152
1158
 
1153
1159
  // src/modals/CheckoutModal/InputAmount/utils.ts
1154
1160
  import { formatCurrencyAndStringify } from "@funkit/utils";
@@ -1946,6 +1952,9 @@ var default_configs_default = {
1946
1952
  disabletokentransferchainsandassets: {
1947
1953
  value: {}
1948
1954
  },
1955
+ disablewithdrawalchainsandassets: {
1956
+ value: {}
1957
+ },
1949
1958
  dynamicrouting: {
1950
1959
  value: [
1951
1960
  {
@@ -2537,8 +2546,12 @@ var default_configs_default = {
2537
2546
  countryCodes: ["CA"]
2538
2547
  },
2539
2548
  value: {
2540
- mainnet: 15,
2541
- nonMainnet: 3
2549
+ default: 3,
2550
+ chains: {
2551
+ "1": 15,
2552
+ "8253038": 15,
2553
+ "728126428": 15
2554
+ }
2542
2555
  }
2543
2556
  },
2544
2557
  {
@@ -2547,16 +2560,27 @@ var default_configs_default = {
2547
2560
  countryCodes: ["AU"]
2548
2561
  },
2549
2562
  value: {
2550
- mainnet: 15,
2551
- nonMainnet: 3
2563
+ default: 3.5,
2564
+ chains: {
2565
+ "1": 15,
2566
+ "8253038": 15,
2567
+ "728126428": 15
2568
+ }
2552
2569
  }
2553
2570
  }
2554
2571
  ],
2555
2572
  value: {
2556
- mainnet: 10,
2557
- nonMainnet: 2.5
2573
+ default: 2.5,
2574
+ chains: {
2575
+ "1": 10,
2576
+ "8253038": 10,
2577
+ "728126428": 10
2578
+ }
2558
2579
  }
2559
2580
  },
2581
+ newtokenassetselectionbanner: {
2582
+ value: {}
2583
+ },
2560
2584
  relaybypasssourcechainsandassets: {
2561
2585
  value: {
2562
2586
  "1": ["*"],
@@ -2911,6 +2935,189 @@ var default_configs_default = {
2911
2935
  }
2912
2936
  ]
2913
2937
  },
2938
+ withdrawalconfig: {
2939
+ value: {
2940
+ priorityTokens: [],
2941
+ chains: [
2942
+ {
2943
+ chainId: 1,
2944
+ assets: [
2945
+ {
2946
+ address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
2947
+ },
2948
+ {
2949
+ address: "0x6B175474E89094C44Da98b954EedeAC495271d0F"
2950
+ },
2951
+ {
2952
+ address: "0xdAC17F958D2ee523a2206206994597C13D831ec7"
2953
+ },
2954
+ {
2955
+ address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
2956
+ },
2957
+ {
2958
+ address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
2959
+ },
2960
+ {
2961
+ address: "0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6"
2962
+ },
2963
+ {
2964
+ address: "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0"
2965
+ },
2966
+ {
2967
+ address: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf"
2968
+ },
2969
+ {
2970
+ address: "0x4c9EDD5852cd905f086C759E8383e09bff1E68B3"
2971
+ }
2972
+ ]
2973
+ },
2974
+ {
2975
+ chainId: 1151111081099710,
2976
+ assets: [
2977
+ {
2978
+ address: "11111111111111111111111111111111"
2979
+ },
2980
+ {
2981
+ address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
2982
+ },
2983
+ {
2984
+ address: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"
2985
+ }
2986
+ ]
2987
+ },
2988
+ {
2989
+ chainId: 56,
2990
+ assets: [
2991
+ {
2992
+ address: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"
2993
+ },
2994
+ {
2995
+ address: "0x55d398326f99059fF775485246999027B3197955"
2996
+ },
2997
+ {
2998
+ address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
2999
+ },
3000
+ {
3001
+ address: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"
3002
+ },
3003
+ {
3004
+ address: "0x2170Ed0880ac9A755fd29B2688956BD959F933F8"
3005
+ },
3006
+ {
3007
+ address: "0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3"
3008
+ },
3009
+ {
3010
+ address: "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56"
3011
+ },
3012
+ {
3013
+ address: "0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c"
3014
+ },
3015
+ {
3016
+ address: "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34"
3017
+ }
3018
+ ]
3019
+ },
3020
+ {
3021
+ chainId: 8453,
3022
+ assets: [
3023
+ {
3024
+ address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
3025
+ },
3026
+ {
3027
+ address: "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2"
3028
+ },
3029
+ {
3030
+ address: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb"
3031
+ },
3032
+ {
3033
+ address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
3034
+ },
3035
+ {
3036
+ address: "0x4200000000000000000000000000000000000006"
3037
+ },
3038
+ {
3039
+ address: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf"
3040
+ },
3041
+ {
3042
+ address: "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34"
3043
+ }
3044
+ ]
3045
+ },
3046
+ {
3047
+ chainId: 137,
3048
+ assets: [
3049
+ {
3050
+ address: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"
3051
+ },
3052
+ {
3053
+ address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"
3054
+ },
3055
+ {
3056
+ address: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
3057
+ },
3058
+ {
3059
+ address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
3060
+ },
3061
+ {
3062
+ address: "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063"
3063
+ },
3064
+ {
3065
+ address: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619"
3066
+ }
3067
+ ]
3068
+ },
3069
+ {
3070
+ chainId: 42161,
3071
+ assets: [
3072
+ {
3073
+ address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
3074
+ },
3075
+ {
3076
+ address: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"
3077
+ },
3078
+ {
3079
+ address: "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"
3080
+ },
3081
+ {
3082
+ address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
3083
+ },
3084
+ {
3085
+ address: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
3086
+ },
3087
+ {
3088
+ address: "0x912CE59144191C1204E64559FE8253a0e49E6548"
3089
+ },
3090
+ {
3091
+ address: "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34"
3092
+ }
3093
+ ]
3094
+ },
3095
+ {
3096
+ chainId: 10,
3097
+ assets: [
3098
+ {
3099
+ address: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85"
3100
+ },
3101
+ {
3102
+ address: "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"
3103
+ },
3104
+ {
3105
+ address: "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"
3106
+ },
3107
+ {
3108
+ address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
3109
+ },
3110
+ {
3111
+ address: "0x4200000000000000000000000000000000000006"
3112
+ },
3113
+ {
3114
+ address: "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34"
3115
+ }
3116
+ ]
3117
+ }
3118
+ ]
3119
+ }
3120
+ },
2914
3121
  withdrawalinfobanner: {
2915
3122
  value: {
2916
3123
  message: "",
@@ -2953,7 +3160,7 @@ function setFunkitConnectVersion({ version }) {
2953
3160
  localStorage.setItem(storageKey, version);
2954
3161
  }
2955
3162
  function getCurrentSdkVersion() {
2956
- return "9.5.0";
3163
+ return "9.5.1";
2957
3164
  }
2958
3165
  function useFingerprint() {
2959
3166
  const fingerprint = useCallback3(() => {
@@ -3521,7 +3728,7 @@ function GeneralWalletProvider({ children }) {
3521
3728
  useLoggingLogout(userInfo.id);
3522
3729
  useEffect6(() => {
3523
3730
  const apiKeyChanged = prevApiKeyRef.current !== apiKey;
3524
- const userInfoChanged = userInfo.id !== logger.getUserId() || userInfo.address !== logger.getUserAddress() || userInfo.name !== logger.getUserName() || userInfo.type !== logger.getUserLoginType() || l2Address !== logger.getL2Address();
3731
+ const userInfoChanged = userInfo.id !== logger.getUserId() || userInfo.address !== logger.getUserAddress() || userInfo.name !== logger.getUserName() || userInfo.type !== logger.getUserLoginType() || userInfo.typeLabel !== logger.getTypeLabel() || l2Address !== logger.getL2Address();
3525
3732
  if (apiKeyChanged || userInfoChanged) {
3526
3733
  const userInfoWithL2Address = { ...userInfo, l2Address };
3527
3734
  logger.log("settingUserInfo", userInfoWithL2Address);
@@ -3533,6 +3740,7 @@ function GeneralWalletProvider({ children }) {
3533
3740
  userInfo.address,
3534
3741
  userInfo.name,
3535
3742
  userInfo.type,
3743
+ userInfo.typeLabel,
3536
3744
  userInfoWithL2Address.l2Address
3537
3745
  );
3538
3746
  prevApiKeyRef.current = apiKey;
@@ -6889,7 +7097,7 @@ import React63, {
6889
7097
  useCallback as useCallback18,
6890
7098
  useContext as useContext16,
6891
7099
  useEffect as useEffect24,
6892
- useRef as useRef11
7100
+ useRef as useRef10
6893
7101
  } from "react";
6894
7102
  import { createPortal } from "react-dom";
6895
7103
  import { RemoveScroll } from "react-remove-scroll";
@@ -6901,8 +7109,8 @@ import React46, {
6901
7109
  createContext as createContext15,
6902
7110
  useContext as useContext14,
6903
7111
  useEffect as useEffect20,
6904
- useMemo as useMemo19,
6905
- useRef as useRef9
7112
+ useMemo as useMemo18,
7113
+ useRef as useRef8
6906
7114
  } from "react";
6907
7115
 
6908
7116
  // src/utils/sanitizeHtml.ts
@@ -7691,182 +7899,694 @@ import {
7691
7899
  bluvoListExchanges,
7692
7900
  bluvoRequestQuotation
7693
7901
  } from "@funkit/api-base";
7694
- import { safeParseJson as safeParseJson2 } from "@funkit/utils";
7695
- import React39, {
7696
- useContext as useContext11,
7697
- useEffect as useEffect15,
7698
- useMemo as useMemo17,
7699
- useRef as useRef8,
7902
+ import { safeParseJson } from "@funkit/utils";
7903
+ import React38, {
7904
+ useContext as useContext10,
7905
+ useEffect as useEffect14,
7906
+ useMemo as useMemo14,
7700
7907
  useState as useState18
7701
7908
  } from "react";
7702
- import { createContext as createContext11 } from "react";
7909
+ import { createContext as createContext10 } from "react";
7910
+
7911
+ // src/utils/bluvo.ts
7912
+ import {
7913
+ BluvoWithdrawalError
7914
+ } from "@funkit/api-base";
7915
+ import {
7916
+ FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS as FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS2,
7917
+ FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO as FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO2,
7918
+ hyperCoreChain,
7919
+ hyperEvmChain as hyperEvmChain3
7920
+ } from "@funkit/chains";
7921
+ import { v4 as uuid } from "uuid";
7922
+ import { arbitrum as arbitrum3 } from "viem/chains";
7703
7923
 
7704
7924
  // src/hooks/useTokenTransfer.ts
7705
7925
  import {
7706
- bitcoinChain as bitcoinChain3,
7926
+ bitcoinChain as bitcoinChain2,
7707
7927
  hyperEvmChain as hyperEvmChain2,
7708
7928
  monadChain,
7709
7929
  solanaChain as solanaChain2,
7710
7930
  tronChain as tronChain2
7711
7931
  } from "@funkit/chains";
7712
- import { FlagKey as FlagKey2 } from "@funkit/utils";
7713
- import { useMemo as useMemo16 } from "react";
7714
- import { arbitrum as arbitrum3, mainnet as mainnet4, polygon as polygon3, tron } from "viem/chains";
7932
+ import { useMemo as useMemo13 } from "react";
7933
+ import { arbitrum as arbitrum2, polygon as polygon2 } from "viem/chains";
7715
7934
 
7716
- // src/providers/FunkitFlagsProvider.tsx
7717
- import { datadogLogs as datadogLogs2 } from "@datadog/browser-logs";
7718
- import { useQuery as useQuery6 } from "@tanstack/react-query";
7719
- import React38, {
7720
- createContext as createContext9,
7721
- useContext as useContext9,
7722
- useEffect as useEffect14,
7723
- useMemo as useMemo14
7724
- } from "react";
7935
+ // src/utils/transfer.ts
7936
+ import { bitcoinChain, solanaChain, tronChain } from "@funkit/chains";
7937
+ function getDepositAddressForChain(chainId, transferInit) {
7938
+ if (chainId === solanaChain.id) {
7939
+ return transferInit?.solanaAddr;
7940
+ }
7941
+ if (chainId === bitcoinChain.id) {
7942
+ return transferInit?.btcAddrSegwit;
7943
+ }
7944
+ if (chainId === tronChain.id) {
7945
+ return transferInit?.tronAddr;
7946
+ }
7947
+ return transferInit?.depositAddr;
7948
+ }
7949
+ var getTransferTokenQrCodeUri = (props) => {
7950
+ const { depositAddress, type } = props;
7951
+ if (type === "ethereum") {
7952
+ return `ethereum:${depositAddress}`;
7953
+ }
7954
+ if (type === "solana") {
7955
+ return `solana:${depositAddress}`;
7956
+ }
7957
+ if (type === "bitcoin") {
7958
+ return `bitcoin:${depositAddress}`;
7959
+ }
7960
+ if (type === "tron") {
7961
+ return depositAddress;
7962
+ }
7963
+ throw new Error(`Invalid transfer token qr code type: ${type}`);
7964
+ };
7725
7965
 
7726
- // src/utils/flags/config.ts
7727
- import {
7728
- AVANTIS_API_KEY as AVANTIS_API_KEY2,
7729
- BASED_API_KEY as BASED_API_KEY2,
7730
- BENTO_API_KEY,
7731
- BULLPEN_API_KEY,
7732
- EITGHTYEIGHTUPS_API_KEY,
7733
- ETHEREAL_API_KEY as ETHEREAL_API_KEY3,
7734
- FANATICS_API_KEY as FANATICS_API_KEY2,
7735
- FELIX_API_KEY,
7736
- GINZA_API_KEY,
7737
- GLOBAL_COMPUTE_API_KEY,
7738
- HYENA_API_KEY as HYENA_API_KEY2,
7739
- HYPERDASH_API_KEY as HYPERDASH_API_KEY2,
7740
- HYPEREDGE_API_KEY,
7741
- HYPERSWAP_API_KEY,
7742
- KURU_API_KEY,
7743
- LIGHTERXYZ_API_KEY as LIGHTERXYZ_API_KEY2,
7744
- MEGAPOT_API_KEY,
7745
- MONAD_API_KEY as MONAD_API_KEY2,
7746
- OPINION_API_KEY,
7747
- OSTIUM_API_KEY as OSTIUM_API_KEY2,
7748
- PERPL_API_KEY as PERPL_API_KEY2,
7749
- POLYMARKET_API_KEY as POLYMARKET_API_KEY2,
7750
- RAREBETSPORTS_API_KEY,
7751
- SUSHI_API_KEY,
7752
- VENTUALS_API_KEY
7753
- } from "@funkit/api-base";
7754
- import {
7755
- MONAD_CHAIN_ID,
7756
- TRON_MAINNET_CHAIN_ID,
7757
- bitcoinChain
7758
- } from "@funkit/chains";
7759
- import { FlagKey } from "@funkit/utils";
7760
- import { arbitrum as arbitrum2, base as base4, bsc, mainnet as mainnet3, polygon as polygon2 } from "viem/chains";
7761
- var FUN_INTERNAL_USERS = [
7762
- "0x6ec0c2f25d323e7779925Cc20c3740101f990d9F",
7763
- // Chloe
7764
- "0xbeFE12aA8cBa36DD79F50eE5E23828adB62f2FD6",
7765
- // Chloe
7766
- "0x2A8Bd916E85d98d8175258De99fc0ddbcC102eF6",
7767
- // Mingyang
7768
- "0xda6b07Eb94f699F511a943e9bFC12B64B7fe3486",
7769
- // Alex
7770
- "0x236c60C57a8B9ca563Fb0dA5199FDdCB686d91E8",
7771
- // Greg
7772
- "0x9CB7F86F360459cC96C74a0F81aF2C4cC7a54bd2",
7773
- // Felix
7774
- "0xA30FD5C8E09987F99A99825bB9223288F4F142C2",
7775
- // David
7776
- "0x3c937d73f7FE55b386c309C65087d9F5bdd1a780",
7777
- // Anton
7778
- "0x21b94a3E67c4a72d3D15f478A696c5175f036092",
7779
- // Jianhe
7780
- "0x28b8848C6c3aaBF4669997563dc07888eb3B0960",
7781
- // Amadu
7782
- "0x3dEA0CdE9678f32B503c18879ACCedfe868787Db",
7783
- // Clinton
7784
- "0xb84440Ee8BAD69c14755bBb7093f861c3512E3D1",
7785
- // Ashraf
7786
- "0x7779FFB11d50fcEae8E533b611b5CB5A1C1db3d4",
7787
- // Noah
7788
- "0xe9F1a56452A6f1fFA396241a0fB4A0655C1ed523",
7789
- // Connor
7790
- "0x84Bc1AC5621d2B44C5D3e3E79b45C2885406026D",
7791
- // Hunter
7792
- "0x0D0377aa9CCA769931821842aB0E1A75e7DD6dD6",
7793
- // Cheng-Yu
7794
- "0x7B0195921183f7E04f0D331c1DAF7C1bB208CC4E"
7795
- // Kurt
7796
- ];
7797
- var DEFAULT_BLOCKED_COUNTRIES = [
7798
- "AF",
7799
- // Afghanistan
7800
- "BY",
7801
- // Belarus
7802
- "MM",
7803
- // Myanmar / Burma
7804
- "CF",
7805
- // Central African Republic
7806
- "CU",
7807
- // Cuba
7808
- "CD",
7809
- // DRC
7810
- "IR",
7811
- // Iran
7812
- "LB",
7813
- // Lebanon
7814
- "LY",
7815
- // Libya
7816
- "NI",
7817
- // Nicaragua
7818
- "KP",
7819
- // North Korea
7820
- "UA",
7821
- // Ukraine
7822
- "SO",
7823
- // Somalia
7824
- "SS",
7825
- // South Sudan
7826
- "SY",
7827
- // Syria
7828
- "VE"
7829
- // Venezuela
7830
- ];
7831
- var COMMON_SUPPORT_CHAINS_AND_ASSETS = {
7832
- // mainnet
7833
- 1: ["USDC", "DAI", "USDT", "ETH", "WETH", "POL", "MATIC", "CBBTC", "USDe"],
7834
- // base
7835
- 8453: ["USDC", "USDT", "DAI", "ETH", "WETH", "CBBTC", "USDe"],
7836
- // arbitrum
7837
- 42161: ["USDC", "USDT", "DAI", "ETH", "WETH", "ARB", "USDe"],
7838
- // polygon
7839
- 137: ["USDC", "USDC.e", "USDT", "POL", "MATIC", "DAI", "WETH"],
7840
- // optimism
7841
- 10: ["USDC", "USDT", "DAI", "ETH", "WETH", "USDe"],
7842
- // bsc
7843
- 56: ["USDC", "USDT", "BNB", "WBNB", "ETH", "DAI", "BUSD", "BTCB", "USDe"]
7966
+ // src/hooks/useTokenTransfer.ts
7967
+ var useTokenTransfer = (selectedChainId, selectedToken, chainIds) => {
7968
+ const { t } = useFunkitTranslation();
7969
+ const { apiKey } = useFunkitConfig();
7970
+ const { checkoutItem } = useCheckoutContext();
7971
+ const enableUniversal = useDynamicConfig(
7972
+ "enabletokentransferuniversaldepositaddress"
7973
+ );
7974
+ const estPriceImpact = usePriceImpactEstimation(
7975
+ selectedToken,
7976
+ selectedChainId
7977
+ );
7978
+ const checkoutConfig = checkoutItem?.initSettings.config;
7979
+ const maxSlippage = useMaxSlippage({
7980
+ apiKey,
7981
+ sourceToken: selectedToken,
7982
+ selectedChainId,
7983
+ targetAssetTicker: checkoutConfig?.targetAssetTicker ?? ""
7984
+ });
7985
+ const { transferInit, recipientAddr } = useCheckoutTransferInit();
7986
+ const minTransferUsd = useMinTransferValue(selectedChainId);
7987
+ const minTransferUsdPerChain = useMinTransferValues(chainIds ?? []);
7988
+ const isPolygon = selectedChainId === polygon2.id;
7989
+ const isUsdceOnPolygon = isPolygon && selectedToken === "USDC.e";
7990
+ const isUsdcOnPolygon = isPolygon && selectedToken === "USDC";
7991
+ const showOriginalRecipient = !enableUniversal && (isUsdceOnPolygon || isUsdcOnPolygon);
7992
+ const funDepositAddress = getDepositAddressForChain(
7993
+ selectedChainId,
7994
+ transferInit
7995
+ );
7996
+ const blockchainType = (() => {
7997
+ if (selectedChainId === solanaChain2.id) {
7998
+ return "solana";
7999
+ }
8000
+ if (selectedChainId === bitcoinChain2.id) {
8001
+ return "bitcoin";
8002
+ }
8003
+ if (selectedChainId === tronChain2.id) {
8004
+ return "tron";
8005
+ }
8006
+ return "ethereum";
8007
+ })();
8008
+ const depositAddressTooltip = showOriginalRecipient ? t("transferToken.depositAddressOriginalRecipient") : t("transferToken.depositAddressUniversal", {
8009
+ targetToken: checkoutConfig?.targetAssetTicker
8010
+ });
8011
+ const qrCodeUri = funDepositAddress ? getTransferTokenQrCodeUri({
8012
+ depositAddress: funDepositAddress,
8013
+ type: blockchainType
8014
+ }) : void 0;
8015
+ return {
8016
+ depositAddress: showOriginalRecipient ? recipientAddr : funDepositAddress,
8017
+ depositAddressTooltip,
8018
+ recipientAddr,
8019
+ minTransferUsd: showOriginalRecipient ? 0 : minTransferUsd,
8020
+ minTransferUsdPerChain,
8021
+ showOriginalRecipient,
8022
+ estPriceImpact: showOriginalRecipient ? void 0 : estPriceImpact,
8023
+ maxSlippage: showOriginalRecipient ? void 0 : maxSlippage,
8024
+ qrCodeUri,
8025
+ blockchain: blockchainType
8026
+ };
7844
8027
  };
7845
- var QR_CODE_EVM = {
7846
- ...COMMON_SUPPORT_CHAINS_AND_ASSETS,
7847
- // abstract
7848
- 2741: ["USDC.e", "ETH", "WETH", "USDT"],
7849
- // hyperevm. TODO: Consider adding UETH, hbHYPE, stHYPE once their icons are in assets.ts. Also holding back as they are lower mkt cap tokens and would overcrowd our UI.
7850
- 999: ["USDC", "HYPE", "USDT", "UBTC", "USDe"],
7851
- // ethereal
7852
- 5064014: ["USDe"]
8028
+ function getMinTransferValueForChain(chainId, limits) {
8029
+ return limits.chains[String(chainId)] ?? limits.default;
8030
+ }
8031
+ var useMinTransferValue = (selectedChainId) => {
8032
+ const limits = useDynamicConfig("mintokentransfervalue");
8033
+ const { checkoutItem } = useCheckoutContext();
8034
+ let limit = getMinTransferValueForChain(selectedChainId, limits);
8035
+ if (checkoutItem) {
8036
+ const { getMinDepositUSD, targetAsset, targetChain } = checkoutItem.initSettings.config;
8037
+ limit += getMinDepositUSD?.({
8038
+ tokenChainId: targetChain,
8039
+ tokenAddress: targetAsset
8040
+ }) ?? 0;
8041
+ }
8042
+ return Math.ceil(limit);
7853
8043
  };
7854
- var QR_CODE_WITH_SOLANA = {
7855
- ...QR_CODE_EVM,
7856
- // solana - only enable once customers are on v5.0.11, anything prior will break
7857
- 1151111081099710: ["SOL", "USDC", "USDT", "TRUMP", "USDe"]
8044
+ var useMinTransferValues = (chainIds) => {
8045
+ const limits = useDynamicConfig("mintokentransfervalue");
8046
+ return useMemo13(() => {
8047
+ return chainIds.reduce(
8048
+ (acc, id) => {
8049
+ const limit = getMinTransferValueForChain(id, limits);
8050
+ acc[id] = Math.ceil(limit);
8051
+ return acc;
8052
+ },
8053
+ {}
8054
+ );
8055
+ }, [chainIds, limits]);
7858
8056
  };
7859
- var QR_CODE_WITH_BITCOIN = {
7860
- ...QR_CODE_WITH_SOLANA,
7861
- [bitcoinChain.id]: ["BTC"]
8057
+ var usePriceImpactEstimation = (selectedToken, selectedChainId) => {
8058
+ const { t } = useFunkitTranslation();
8059
+ const { checkoutItem } = useCheckoutContext();
8060
+ const label = t("fees.priceImpact");
8061
+ const isUSDC = selectedToken === "USDC" || selectedToken === "USDC.e";
8062
+ const isUSDT = selectedToken === "USDT";
8063
+ const isPreferredChainId = isPreferredChain(selectedChainId);
8064
+ const targetAssetTicker = checkoutItem?.initSettings.config.targetAssetTicker ?? "";
8065
+ if (!isPreferredChainId || !isStablecoin(targetAssetTicker)) {
8066
+ return { label, value: 0.25 };
8067
+ }
8068
+ if (isUSDC) {
8069
+ return { label, value: 0 };
8070
+ }
8071
+ if (isUSDT) {
8072
+ return { label, value: 0.05 };
8073
+ }
8074
+ return { label, value: 0.1 };
7862
8075
  };
7863
- var QR_CODE_WITH_MONAD = {
7864
- ...QR_CODE_WITH_BITCOIN,
7865
- [MONAD_CHAIN_ID]: ["MON", "USDC"]
8076
+ var useMaxSlippage = ({
8077
+ apiKey,
8078
+ sourceToken,
8079
+ selectedChainId,
8080
+ targetAssetTicker
8081
+ }) => {
8082
+ const { t } = useFunkitTranslation();
8083
+ const label = t("fees.maxSlippage");
8084
+ const isArbitrum = selectedChainId === arbitrum2.id;
8085
+ const isPreferredChainId = isPreferredChain(selectedChainId);
8086
+ const defaultValue = 0.25;
8087
+ if (isBasedCustomer(apiKey) && isArbitrum && sourceToken === "USDC") {
8088
+ return { label, value: 0.1 };
8089
+ }
8090
+ if (isLighterxyzCustomer(apiKey) && // if preferred chains + chains that have CCTP support
8091
+ isPreferredChain(selectedChainId, [hyperEvmChain2.id, monadChain.id]) && sourceToken === "USDC") {
8092
+ return { label, value: 0.01 };
8093
+ }
8094
+ if (isPolymarketCustomer(apiKey) && isPreferredChainId) {
8095
+ if (sourceToken === "USDC.e") {
8096
+ return { label, value: 0 };
8097
+ }
8098
+ if (sourceToken === "USDC") {
8099
+ return { label, value: 0.05 };
8100
+ }
8101
+ if (sourceToken === "USDT") {
8102
+ return { label, value: 0.2 };
8103
+ }
8104
+ }
8105
+ if (!isPreferredChainId || !isStablecoin(targetAssetTicker) || sourceToken === "DAI") {
8106
+ return { label, value: 1 };
8107
+ }
8108
+ return { label, value: defaultValue };
7866
8109
  };
7867
- var QR_CODE_WITH_TRON = {
7868
- ...QR_CODE_WITH_MONAD,
7869
- [TRON_MAINNET_CHAIN_ID]: ["USDT"]
8110
+
8111
+ // src/utils/combineChainSymbolOrAddress.ts
8112
+ function combineChainSymbolOrAddress({
8113
+ chainId,
8114
+ symbolOrAddress
8115
+ }) {
8116
+ return `${chainId}|${symbolOrAddress}`;
8117
+ }
8118
+
8119
+ // src/utils/bluvo.ts
8120
+ var ASSETS_LOW_VALUE_THRESHOLD = 0.1;
8121
+ var isBrokerageAsset = (asset) => "minAmount" in asset && "maxAmount" in asset && asset.usdAmount !== null;
8122
+ function getBrokerageMinMax(asset, minTransferLimits, minDeposit = 1) {
8123
+ const chainId = Number(asset.pickedChainId);
8124
+ const unitPrice = asset.usdAmount / asset.amount;
8125
+ const brokerageMin = Number.parseFloat(asset.minAmount);
8126
+ const brokerageMax = Number.parseFloat(asset.maxAmount);
8127
+ const brokerageMinUsd = brokerageMin * unitPrice;
8128
+ const brokerageMaxUsd = brokerageMax * unitPrice;
8129
+ const tokenTransferMin = getMinTransferValueForChain(
8130
+ chainId,
8131
+ minTransferLimits
8132
+ );
8133
+ return {
8134
+ minUsd: Math.ceil(Math.max(tokenTransferMin, brokerageMinUsd, minDeposit)),
8135
+ maxUsd: brokerageMaxUsd
8136
+ };
8137
+ }
8138
+ function getPreferredNetwork(networks, targetChainId) {
8139
+ let preferredChainId = targetChainId;
8140
+ const validNetworks = networks.filter(({ chainId }) => !!chainId);
8141
+ const networkMap = Object.fromEntries(
8142
+ validNetworks.map((n) => [n.chainId?.toString(), n])
8143
+ );
8144
+ const isArbritrumOverride = [hyperCoreChain, hyperEvmChain3].some(
8145
+ ({ id }) => id.toString() === targetChainId
8146
+ );
8147
+ if (validNetworks.length === 0) {
8148
+ logger.warn("bluvo-getPreferredNetwork:noValidNetworks", {
8149
+ networks,
8150
+ validNetworks
8151
+ });
8152
+ return null;
8153
+ }
8154
+ if (isArbritrumOverride) {
8155
+ preferredChainId = arbitrum3.id.toString();
8156
+ }
8157
+ if (preferredChainId && networkMap[preferredChainId]) {
8158
+ return networkMap[preferredChainId];
8159
+ }
8160
+ let pickedNetwork = validNetworks[0];
8161
+ let lowestPriority = Number.MAX_SAFE_INTEGER;
8162
+ for (const chainId of Object.keys(networkMap)) {
8163
+ const chainInfo = FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO2[chainId];
8164
+ const pickPriority = chainInfo?.pickPriority || Number.MAX_SAFE_INTEGER;
8165
+ if (pickPriority < lowestPriority) {
8166
+ lowestPriority = pickPriority;
8167
+ pickedNetwork = networkMap[chainId];
8168
+ }
8169
+ }
8170
+ return pickedNetwork ?? null;
8171
+ }
8172
+ function transformBluvoBalancesToAssetHoldings(balances, preferredChainId) {
8173
+ const LOG_PREFIX = "bluvo-transformBalance";
8174
+ const assetHoldings = {};
8175
+ if (!balances || balances.length === 0) {
8176
+ logger.warn(`${LOG_PREFIX}:emptyAssets`, {
8177
+ message: "No available assets from CEX wallet",
8178
+ balances,
8179
+ preferredChainId
8180
+ });
8181
+ return assetHoldings;
8182
+ }
8183
+ logger.info(`${LOG_PREFIX}:totalAssets`, {
8184
+ message: "Total assets from CEX wallet",
8185
+ balances,
8186
+ preferredChainId
8187
+ });
8188
+ for (const balance of balances) {
8189
+ const { amount, amountInFiat, networks } = balance;
8190
+ const preferredNetwork = getPreferredNetwork(networks, preferredChainId);
8191
+ const asset = preferredNetwork?.assetName;
8192
+ const tokenAddress = preferredNetwork?.contractAddress;
8193
+ const chainId = preferredNetwork?.chainId;
8194
+ if (!chainId || !tokenAddress || !asset) {
8195
+ logger.warn(`${LOG_PREFIX}:invalidNetwork`, {
8196
+ message: `Invalid network for checkout ${balance.asset}`,
8197
+ balance,
8198
+ preferredNetwork
8199
+ });
8200
+ continue;
8201
+ }
8202
+ const chainInfo = FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO2[chainId];
8203
+ if (!chainInfo?.isCheckoutSupported || !chainInfo?.isMainnet) {
8204
+ logger.warn(`${LOG_PREFIX}:unsupportedAsset`, {
8205
+ message: `Unsupported asset for checkout ${chainId}|${asset}`,
8206
+ chainId,
8207
+ asset,
8208
+ preferredNetwork
8209
+ });
8210
+ continue;
8211
+ }
8212
+ if (!tokenAddress) {
8213
+ logger.warn(`${LOG_PREFIX}:invalidTokenAddress`, {
8214
+ message: `Invalid token address for ${chainId}|${asset}`,
8215
+ chainId,
8216
+ asset,
8217
+ preferredNetwork
8218
+ });
8219
+ continue;
8220
+ }
8221
+ if (!amountInFiat || amountInFiat < ASSETS_LOW_VALUE_THRESHOLD) {
8222
+ logger.warn(`${LOG_PREFIX}:assetBelowThreshold`, {
8223
+ message: `Asset below threshold ${chainId}|${asset}. Amount in fiat: ${amountInFiat}`,
8224
+ chainId,
8225
+ asset,
8226
+ amountInFiat,
8227
+ preferredNetwork
8228
+ });
8229
+ continue;
8230
+ }
8231
+ const isNativeCurrency = chainInfo.nativeCurrency.symbol.toUpperCase() === asset.toUpperCase();
8232
+ const normalizedTokenAddress = isNativeCurrency ? FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS2 : tokenAddress;
8233
+ const chainSymbolKey = combineChainSymbolOrAddress({
8234
+ chainId: chainId.toString(),
8235
+ symbolOrAddress: asset
8236
+ });
8237
+ const iconSrc = ASSET_LOGO_SRCS[asset.toUpperCase()] || FALLBACK_ASSET;
8238
+ assetHoldings[chainSymbolKey] = {
8239
+ iconSrc,
8240
+ symbol: asset,
8241
+ amount,
8242
+ tokenAddress: normalizedTokenAddress,
8243
+ usdAmount: amountInFiat,
8244
+ pickedChainId: chainId.toString(),
8245
+ chainSymbolKey,
8246
+ minAmount: preferredNetwork.minWithdrawal,
8247
+ maxAmount: preferredNetwork.maxWithdrawal || amount.toString()
8248
+ };
8249
+ }
8250
+ logger.info(`${LOG_PREFIX}:transformedAssets`, {
8251
+ message: "Transformed usable assets from CEX wallet",
8252
+ assetHoldings,
8253
+ preferredChainId
8254
+ });
8255
+ return assetHoldings;
8256
+ }
8257
+ function getWalletId(authorizedConnections, exchange) {
8258
+ return authorizedConnections?.[exchange] || uuid();
8259
+ }
8260
+ var BluvoError = class extends Error {
8261
+ constructor(message, errorCode) {
8262
+ super(message);
8263
+ this.message = message;
8264
+ this.errorCode = errorCode;
8265
+ this.name = "BluvoError";
8266
+ }
8267
+ };
8268
+ function getBluvoError(error) {
8269
+ const errorMessage = error.error;
8270
+ return new BluvoError(errorMessage, error.type);
8271
+ }
8272
+ var normalizeWithdrawalResponse = (response) => {
8273
+ try {
8274
+ if (!response) {
8275
+ throw new BluvoWithdrawalError("Invalid response");
8276
+ }
8277
+ if (!response.success) {
8278
+ const _code = response.error?.type;
8279
+ const errorObjOrString = response.error?.error;
8280
+ if (typeof errorObjOrString === "object" && errorObjOrString !== null) {
8281
+ const errorMessage = errorObjOrString.error;
8282
+ const errorCode = errorObjOrString.type;
8283
+ throw new BluvoWithdrawalError(errorMessage, errorCode);
8284
+ }
8285
+ throw new BluvoWithdrawalError(errorObjOrString, _code);
8286
+ }
8287
+ const data = response.data;
8288
+ if (!data) {
8289
+ throw new BluvoWithdrawalError(
8290
+ "Unexpected error occurred during withdrawal. Please try again."
8291
+ );
8292
+ }
8293
+ if (!data.success) {
8294
+ const errorMessage = data.error;
8295
+ const errorCode = data.type;
8296
+ throw new BluvoWithdrawalError(errorMessage, errorCode);
8297
+ }
8298
+ return data.result;
8299
+ } catch (error) {
8300
+ if (error instanceof BluvoWithdrawalError) {
8301
+ throw error;
8302
+ }
8303
+ throw new BluvoWithdrawalError(
8304
+ "An error occurred during withdrawal. Please try again."
8305
+ );
8306
+ }
8307
+ };
8308
+ var isBluvoWithdrawalError = (error) => {
8309
+ return error instanceof BluvoWithdrawalError;
8310
+ };
8311
+
8312
+ // src/providers/FunkitSandboxContext.tsx
8313
+ import { createContext as createContext9, useContext as useContext9 } from "react";
8314
+ var FunkitSandboxContext = createContext9(false);
8315
+ var useIsFunkitSandboxMode = () => useContext9(FunkitSandboxContext);
8316
+
8317
+ // src/providers/FunkitBrokerageProvider.tsx
8318
+ var PROD_ORG_ID = "swVwRpxm54werxWOQ5EayjtWM8i33jtL";
8319
+ var PROD_PROJECT_ID = "tdN6yxVldIkEuE9XjKVGu0OCLsHcjVuy";
8320
+ var STAGE_ORG_ID = "ezCUF9l9zpdB01nVvGe8O2E1vDZSbkVa";
8321
+ var STAGE_PROJECT_ID = "D00dTLSdlAYpEFDTL2mMj7bee3SbjYI0";
8322
+ var LOCAL_STORAGE_KEY = "fkc-bluvo-cex";
8323
+ var FunkitBrokerageContext = createContext10(void 0);
8324
+ var FunkitBrokerageProvider = ({
8325
+ children
8326
+ }) => {
8327
+ const { apiKey } = useFunkitConfig();
8328
+ const isSandboxMode = useIsFunkitSandboxMode();
8329
+ const minTransferValue = useDynamicConfig("mintokentransfervalue");
8330
+ const ORG_ID = isSandboxMode ? STAGE_ORG_ID : PROD_ORG_ID;
8331
+ const PROJECT_ID = isSandboxMode ? STAGE_PROJECT_ID : PROD_PROJECT_ID;
8332
+ const apiBaseConfig = { apiKey, logger };
8333
+ const [authConnections, setAuthConnections] = useState18(
8334
+ {}
8335
+ );
8336
+ const [selectedBrokerageAsset, setSelectedBrokerageAsset] = useState18(null);
8337
+ const bluvoClient = useBluvoFlow({
8338
+ orgId: ORG_ID,
8339
+ projectId: PROJECT_ID,
8340
+ listExchangesFn: (status = "live") => bluvoListExchanges({ status, ...apiBaseConfig }),
8341
+ fetchWithdrawableBalanceFn: (id) => bluvoGetWithdrawableBalanceById({ id, ...apiBaseConfig }),
8342
+ pingWalletByIdFn: () => {
8343
+ throw new Error("Not implemented");
8344
+ },
8345
+ requestQuotationFn: (id, params) => bluvoRequestQuotation({ id, params, ...apiBaseConfig }),
8346
+ executeWithdrawalFn: (id, idempotencyKey, quoteId, params) => bluvoExecuteWithdrawal({
8347
+ id,
8348
+ idempotencyKey,
8349
+ quoteId,
8350
+ params,
8351
+ ...apiBaseConfig
8352
+ }),
8353
+ onWalletConnectedFn: (id, exchange) => handleOnWalletConnected(id, exchange),
8354
+ getWalletByIdFn: (id) => bluvoGetWalletById({ id, ...apiBaseConfig }),
8355
+ options: {
8356
+ customDomain: "bluvo.fun.xyz",
8357
+ autoRefreshQuotation: false
8358
+ }
8359
+ });
8360
+ const initialIsConnected = !!bluvoClient.context?.walletBalances;
8361
+ const [isConnected, setIsConnected] = useState18(
8362
+ () => initialIsConnected
8363
+ );
8364
+ useEffect14(() => {
8365
+ const initialConnections = getAuthConnectedExchanges();
8366
+ setAuthConnections(initialConnections);
8367
+ }, []);
8368
+ useEffect14(() => {
8369
+ if (bluvoClient.withdrawal?.status === "completed") {
8370
+ setSelectedBrokerageAsset(null);
8371
+ }
8372
+ }, [bluvoClient.withdrawal?.status]);
8373
+ const brokerageMinMax = useMemo14(() => {
8374
+ if (!selectedBrokerageAsset || !isBrokerageAsset(selectedBrokerageAsset)) {
8375
+ return null;
8376
+ }
8377
+ return getBrokerageMinMax(
8378
+ selectedBrokerageAsset,
8379
+ minTransferValue,
8380
+ BLUVO_MIN_DEPOSIT_BY_CUSTOMER[apiKey]
8381
+ );
8382
+ }, [selectedBrokerageAsset, minTransferValue, apiKey]);
8383
+ function getAuthConnectedExchanges() {
8384
+ if (typeof localStorage !== "undefined") {
8385
+ const connections = localStorage.getItem(LOCAL_STORAGE_KEY) || void 0;
8386
+ return safeParseJson(connections) || {};
8387
+ }
8388
+ return {};
8389
+ }
8390
+ function saveAuthConnectedExchange(id, exchange) {
8391
+ try {
8392
+ const connections = { ...authConnections, [exchange]: id };
8393
+ localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(connections));
8394
+ setAuthConnections(connections);
8395
+ } catch (error) {
8396
+ const errorToLog = error instanceof Error ? error : new Error("Failed to save brokerage connection");
8397
+ logger.error("brokerage:saveConnectionFailed", errorToLog, {
8398
+ exchange
8399
+ });
8400
+ }
8401
+ }
8402
+ function purgeAuthConnectedExchange(exchange) {
8403
+ const connections = { ...authConnections };
8404
+ delete connections[exchange];
8405
+ localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(connections));
8406
+ setAuthConnections(connections);
8407
+ }
8408
+ const handleOnWalletConnected = async (walletId, exchange) => {
8409
+ saveAuthConnectedExchange(walletId, exchange);
8410
+ setIsConnected(true);
8411
+ };
8412
+ return /* @__PURE__ */ React38.createElement(
8413
+ FunkitBrokerageContext.Provider,
8414
+ {
8415
+ value: {
8416
+ bluvoClient,
8417
+ authorizedConnections: authConnections,
8418
+ purgeAuthConnectedExchange,
8419
+ isConnected,
8420
+ selectedBrokerageAsset,
8421
+ setSelectedBrokerageAsset,
8422
+ brokerageMinMax
8423
+ }
8424
+ },
8425
+ children
8426
+ );
8427
+ };
8428
+ function useFunkitBrokerageContext() {
8429
+ const context = useContext10(FunkitBrokerageContext);
8430
+ if (!context) {
8431
+ throw new Error("FunkitBrokerageContext not found");
8432
+ }
8433
+ return context;
8434
+ }
8435
+
8436
+ // src/providers/FunkitFlagsProvider.tsx
8437
+ import { datadogLogs as datadogLogs2 } from "@datadog/browser-logs";
8438
+ import { useQuery as useQuery6 } from "@tanstack/react-query";
8439
+ import React39, {
8440
+ createContext as createContext11,
8441
+ useContext as useContext11,
8442
+ useEffect as useEffect15,
8443
+ useMemo as useMemo16
8444
+ } from "react";
8445
+
8446
+ // src/utils/flags/config.ts
8447
+ import {
8448
+ AVANTIS_API_KEY as AVANTIS_API_KEY2,
8449
+ BASED_API_KEY as BASED_API_KEY2,
8450
+ BENTO_API_KEY,
8451
+ BULLPEN_API_KEY,
8452
+ EITGHTYEIGHTUPS_API_KEY,
8453
+ ETHEREAL_API_KEY as ETHEREAL_API_KEY3,
8454
+ FANATICS_API_KEY as FANATICS_API_KEY2,
8455
+ FELIX_API_KEY,
8456
+ GINZA_API_KEY,
8457
+ GLOBAL_COMPUTE_API_KEY,
8458
+ HYENA_API_KEY as HYENA_API_KEY2,
8459
+ HYPERDASH_API_KEY as HYPERDASH_API_KEY2,
8460
+ HYPEREDGE_API_KEY,
8461
+ HYPERSWAP_API_KEY,
8462
+ KURU_API_KEY,
8463
+ LIGHTERXYZ_API_KEY as LIGHTERXYZ_API_KEY2,
8464
+ MEGAPOT_API_KEY,
8465
+ MONAD_API_KEY as MONAD_API_KEY2,
8466
+ OPINION_API_KEY,
8467
+ OSTIUM_API_KEY as OSTIUM_API_KEY2,
8468
+ PERPL_API_KEY as PERPL_API_KEY2,
8469
+ POLYMARKET_API_KEY as POLYMARKET_API_KEY2,
8470
+ RAREBETSPORTS_API_KEY,
8471
+ SUSHI_API_KEY,
8472
+ VENTUALS_API_KEY
8473
+ } from "@funkit/api-base";
8474
+ import {
8475
+ MONAD_CHAIN_ID,
8476
+ TRON_MAINNET_CHAIN_ID,
8477
+ bitcoinChain as bitcoinChain3
8478
+ } from "@funkit/chains";
8479
+ import { FlagKey } from "@funkit/utils";
8480
+ import { arbitrum as arbitrum4, base as base4, bsc, mainnet as mainnet3, polygon as polygon3 } from "viem/chains";
8481
+ var FUN_INTERNAL_USERS = [
8482
+ "0x6ec0c2f25d323e7779925Cc20c3740101f990d9F",
8483
+ // Chloe
8484
+ "0xbeFE12aA8cBa36DD79F50eE5E23828adB62f2FD6",
8485
+ // Chloe
8486
+ "0x2A8Bd916E85d98d8175258De99fc0ddbcC102eF6",
8487
+ // Mingyang
8488
+ "0xda6b07Eb94f699F511a943e9bFC12B64B7fe3486",
8489
+ // Alex
8490
+ "0x236c60C57a8B9ca563Fb0dA5199FDdCB686d91E8",
8491
+ // Greg
8492
+ "0x9CB7F86F360459cC96C74a0F81aF2C4cC7a54bd2",
8493
+ // Felix
8494
+ "0xA30FD5C8E09987F99A99825bB9223288F4F142C2",
8495
+ // David
8496
+ "0x3c937d73f7FE55b386c309C65087d9F5bdd1a780",
8497
+ // Anton
8498
+ "0x21b94a3E67c4a72d3D15f478A696c5175f036092",
8499
+ // Jianhe
8500
+ "0x28b8848C6c3aaBF4669997563dc07888eb3B0960",
8501
+ // Amadu
8502
+ "0x3dEA0CdE9678f32B503c18879ACCedfe868787Db",
8503
+ // Clinton
8504
+ "0xb84440Ee8BAD69c14755bBb7093f861c3512E3D1",
8505
+ // Ashraf
8506
+ "0x7779FFB11d50fcEae8E533b611b5CB5A1C1db3d4",
8507
+ // Noah
8508
+ "0xe9F1a56452A6f1fFA396241a0fB4A0655C1ed523",
8509
+ // Connor
8510
+ "0x84Bc1AC5621d2B44C5D3e3E79b45C2885406026D",
8511
+ // Hunter
8512
+ "0x0D0377aa9CCA769931821842aB0E1A75e7DD6dD6",
8513
+ // Cheng-Yu
8514
+ "0x7B0195921183f7E04f0D331c1DAF7C1bB208CC4E"
8515
+ // Kurt
8516
+ ];
8517
+ var DEFAULT_BLOCKED_COUNTRIES = [
8518
+ "AF",
8519
+ // Afghanistan
8520
+ "BY",
8521
+ // Belarus
8522
+ "MM",
8523
+ // Myanmar / Burma
8524
+ "CF",
8525
+ // Central African Republic
8526
+ "CU",
8527
+ // Cuba
8528
+ "CD",
8529
+ // DRC
8530
+ "IR",
8531
+ // Iran
8532
+ "LB",
8533
+ // Lebanon
8534
+ "LY",
8535
+ // Libya
8536
+ "NI",
8537
+ // Nicaragua
8538
+ "KP",
8539
+ // North Korea
8540
+ "UA",
8541
+ // Ukraine
8542
+ "SO",
8543
+ // Somalia
8544
+ "SS",
8545
+ // South Sudan
8546
+ "SY",
8547
+ // Syria
8548
+ "VE"
8549
+ // Venezuela
8550
+ ];
8551
+ var COMMON_SUPPORT_CHAINS_AND_ASSETS = {
8552
+ // mainnet
8553
+ 1: ["USDC", "DAI", "USDT", "ETH", "WETH", "POL", "MATIC", "CBBTC", "USDe"],
8554
+ // base
8555
+ 8453: ["USDC", "USDT", "DAI", "ETH", "WETH", "CBBTC", "USDe"],
8556
+ // arbitrum
8557
+ 42161: ["USDC", "USDT", "DAI", "ETH", "WETH", "ARB", "USDe"],
8558
+ // polygon
8559
+ 137: ["USDC", "USDC.e", "USDT", "POL", "MATIC", "DAI", "WETH"],
8560
+ // optimism
8561
+ 10: ["USDC", "USDT", "DAI", "ETH", "WETH", "USDe"],
8562
+ // bsc
8563
+ 56: ["USDC", "USDT", "BNB", "WBNB", "ETH", "DAI", "BUSD", "BTCB", "USDe"]
8564
+ };
8565
+ var QR_CODE_EVM = {
8566
+ ...COMMON_SUPPORT_CHAINS_AND_ASSETS,
8567
+ // abstract
8568
+ 2741: ["USDC.e", "ETH", "WETH", "USDT"],
8569
+ // hyperevm. TODO: Consider adding UETH, hbHYPE, stHYPE once their icons are in assets.ts. Also holding back as they are lower mkt cap tokens and would overcrowd our UI.
8570
+ 999: ["USDC", "HYPE", "USDT", "UBTC", "USDe"],
8571
+ // ethereal
8572
+ 5064014: ["USDe"]
8573
+ };
8574
+ var QR_CODE_WITH_SOLANA = {
8575
+ ...QR_CODE_EVM,
8576
+ // solana - only enable once customers are on v5.0.11, anything prior will break
8577
+ 1151111081099710: ["SOL", "USDC", "USDT", "TRUMP", "USDe"]
8578
+ };
8579
+ var QR_CODE_WITH_BITCOIN = {
8580
+ ...QR_CODE_WITH_SOLANA,
8581
+ [bitcoinChain3.id]: ["BTC"]
8582
+ };
8583
+ var QR_CODE_WITH_MONAD = {
8584
+ ...QR_CODE_WITH_BITCOIN,
8585
+ [MONAD_CHAIN_ID]: ["MON", "USDC"]
8586
+ };
8587
+ var QR_CODE_WITH_TRON = {
8588
+ ...QR_CODE_WITH_MONAD,
8589
+ [TRON_MAINNET_CHAIN_ID]: ["USDT"]
7870
8590
  };
7871
8591
  var WITHDRAWAL_CHAINS_AND_ASSETS = {
7872
8592
  ...COMMON_SUPPORT_CHAINS_AND_ASSETS,
@@ -8064,7 +8784,7 @@ var flagConfig = {
8064
8784
  // Add Bitcoin to the list of supported assets for Hyena
8065
8785
  // For safety we don't use QR_CODE_WITH_BITCOIN here as it also includes Solana
8066
8786
  // And Solana was disabled for Hyena historically for unknown reasons
8067
- [bitcoinChain.id]: ["BTC"]
8787
+ [bitcoinChain3.id]: ["BTC"]
8068
8788
  })
8069
8789
  },
8070
8790
  {
@@ -8132,7 +8852,7 @@ var flagConfig = {
8132
8852
  },
8133
8853
  [FlagKey.TokenTransferDefaultChainId]: {
8134
8854
  type: "string",
8135
- default_value: polygon2.id.toString(),
8855
+ default_value: polygon3.id.toString(),
8136
8856
  overrides: [
8137
8857
  {
8138
8858
  if_any: [
@@ -8143,7 +8863,7 @@ var flagConfig = {
8143
8863
  values: [OSTIUM_API_KEY2, ETHEREAL_API_KEY3]
8144
8864
  }
8145
8865
  ],
8146
- value: arbitrum2.id.toString()
8866
+ value: arbitrum4.id.toString()
8147
8867
  },
8148
8868
  {
8149
8869
  if_any: [
@@ -8478,7 +9198,7 @@ var flagConfig = {
8478
9198
  "42161",
8479
9199
  // Arbitrum
8480
9200
  TRON_MAINNET_CHAIN_ID.toString(),
8481
- bitcoinChain.id.toString(),
9201
+ bitcoinChain3.id.toString(),
8482
9202
  "10"
8483
9203
  // Optimism
8484
9204
  ])
@@ -8515,7 +9235,7 @@ var flagConfig = {
8515
9235
  }
8516
9236
  ],
8517
9237
  value: JSON.stringify({
8518
- [arbitrum2.id]: [
9238
+ [arbitrum4.id]: [
8519
9239
  "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
8520
9240
  // USDC on Arbitrum
8521
9241
  ]
@@ -8570,724 +9290,184 @@ async function fetchWithTimeout(url, options = {}, timeout = 15e3) {
8570
9290
  }
8571
9291
  }
8572
9292
  async function fetchConfigFromServer() {
8573
- const response = await fetchWithTimeout(FLAG_PROD_ENDPOINT, {}, 1e4);
8574
- const configData = await response.json();
8575
- logger.log("flag_fetchConfigFromServer", {
8576
- configData
8577
- });
8578
- return configData.flags;
8579
- }
8580
- function deriveAllFlags(config, userContext) {
8581
- return Object.fromEntries(
8582
- Object.entries(config).map(([key, flag]) => [
8583
- key,
8584
- deriveFlag(key, flag, userContext)
8585
- ]).filter(([key, value]) => {
8586
- const configItem = config[key];
8587
- if (!configItem) {
8588
- return false;
8589
- }
8590
- if (typeof value !== configItem.type) {
8591
- logger.warn("flag_mismatchingType", {
8592
- flagKey: key,
8593
- type: configItem.type,
8594
- value
8595
- });
8596
- return false;
8597
- }
8598
- return true;
8599
- })
8600
- );
8601
- }
8602
- function deriveFlag(flagKey, flagConfig2, context) {
8603
- const override = flagConfig2.overrides?.find((override2) => {
8604
- if (override2.if_all) {
8605
- return override2.if_all.every((condition) => {
8606
- return evalCondition(flagKey, condition, context);
8607
- });
8608
- }
8609
- return override2.if_any.some((condition) => {
8610
- return evalCondition(flagKey, condition, context);
8611
- });
8612
- });
8613
- return override?.value ?? flagConfig2.default_value;
8614
- }
8615
- function evalConditionValue(condition, context) {
8616
- switch (condition.key) {
8617
- case "userId":
8618
- return context.userId;
8619
- case "ipCountry":
8620
- return context.ipCountry;
8621
- case "apiKey":
8622
- return context.apiKey;
8623
- default: {
8624
- exhaustiveCheck2(condition.key);
8625
- return void 0;
8626
- }
8627
- }
8628
- }
8629
- function evalCondition(flagKey, condition, context) {
8630
- const needle = evalConditionValue(condition, context);
8631
- if (!needle) {
8632
- return false;
8633
- }
8634
- switch (condition.type) {
8635
- case "pctRollout": {
8636
- return hashPct(flagKey, needle, condition.pct);
8637
- }
8638
- case "isAnyOf": {
8639
- return condition.values?.includes(needle) ?? false;
8640
- }
8641
- default: {
8642
- throw new Error(`Unknown condition type: ${JSON.stringify(condition)}`);
8643
- }
8644
- }
8645
- }
8646
-
8647
- // src/providers/FunkitMoonpayProvider.tsx
8648
- import { useMemo as useMemo13 } from "react";
8649
- var BYPASS_COUNTRY_BLOCK_CHECK = false;
8650
- var ALL_MATCH = "*";
8651
- var isCountryBlocked = (blockedList, userIpInfo) => {
8652
- if (BYPASS_COUNTRY_BLOCK_CHECK) {
8653
- return false;
8654
- }
8655
- if (!userIpInfo.alpha2) {
8656
- logger.log("isUserBlockedForCheckout_NoIpDetected");
8657
- return true;
8658
- }
8659
- const isBlocked = blockedList.includes(ALL_MATCH) || blockedList.includes(userIpInfo.alpha2);
8660
- logger.log("isUserBlockedForCheckoutResult", {
8661
- isBlocked,
8662
- blockedList,
8663
- userIpInfo
8664
- });
8665
- return isBlocked;
8666
- };
8667
- function useFunkitUserIp() {
8668
- const { apiKey } = useFunkitConfig();
8669
- const isPolymarket = isPolymarketCustomer(apiKey);
8670
- const { isUserLoggedIn } = useGeneralWallet();
8671
- const { userIpInfo, isLoadingGeoCheck } = useUserIpInfo();
8672
- const blockedCountries = useDynamicConfig("blockedcountries");
8673
- const isUserGeoblocked = useMemo13(() => {
8674
- if (isLoadingGeoCheck || isPolymarket) {
8675
- return false;
8676
- }
8677
- if (!userIpInfo) {
8678
- return true;
8679
- }
8680
- return isCountryBlocked(blockedCountries, userIpInfo);
8681
- }, [blockedCountries, isLoadingGeoCheck, userIpInfo, isPolymarket]);
8682
- return {
8683
- isLoadingGeoCheck,
8684
- isUserGeoblocked,
8685
- isUserLoggedIn,
8686
- userIpInfo
8687
- };
8688
- }
8689
-
8690
- // src/providers/FunkitFlagsProvider.tsx
8691
- var FunkitFlagsContext = createContext9({
8692
- error: null,
8693
- flags: {},
8694
- getFlag() {
8695
- throw Error("Missing FunkitFlagsProvider");
8696
- },
8697
- isLoading: true
8698
- });
8699
- function FunkitFlagsProvider({ children }) {
8700
- const { apiKey } = useFunkitConfig();
8701
- const { userInfo } = useGeneralWallet();
8702
- const { userIpInfo } = useFunkitUserIp();
8703
- const {
8704
- data: onlineConfig,
8705
- error,
8706
- isLoading
8707
- } = useQuery6({
8708
- queryKey: ["flags"],
8709
- queryFn: fetchConfigFromServer,
8710
- refetchOnMount: false,
8711
- refetchOnReconnect: true,
8712
- refetchOnWindowFocus: false
8713
- });
8714
- const flags = useMemo14(() => {
8715
- const config = onlineConfig ?? flagConfig;
8716
- return deriveAllFlags(config, {
8717
- apiKey,
8718
- // placeholder user info is '0x'
8719
- userId: userInfo.id === "0x" ? void 0 : userInfo.id,
8720
- ipCountry: userIpInfo?.alpha2
8721
- });
8722
- }, [apiKey, onlineConfig, userInfo.id, userIpInfo?.alpha2]);
8723
- const context = useMemo14(() => {
8724
- return {
8725
- error,
8726
- flags,
8727
- getFlag: (flagKey, fallback2) => {
8728
- return flags[flagKey] ?? fallback2 ?? flagConfig[flagKey].default_value;
8729
- },
8730
- isLoading
8731
- };
8732
- }, [error, flags, isLoading]);
8733
- useEffect14(() => {
8734
- if (!isLoading) {
8735
- datadogLogs2.setGlobalContextProperty("flags", flags);
8736
- }
8737
- }, [flags, isLoading]);
8738
- useEffect14(() => {
8739
- if (error) {
8740
- logger.error("flag_initError", error);
8741
- }
8742
- }, [error]);
8743
- return /* @__PURE__ */ React38.createElement(FunkitFlagsContext.Provider, { value: context }, children);
8744
- }
8745
- function useFlags() {
8746
- return useContext9(FunkitFlagsContext);
8747
- }
8748
- function useFlag(flagKey, fallback2, middleware) {
8749
- const flagValue = useContext9(FunkitFlagsContext).getFlag(flagKey, fallback2);
8750
- return middleware ? middleware(flagValue) : flagValue;
8751
- }
8752
-
8753
- // src/utils/safeJSON.ts
8754
- import { safeParseJson } from "@funkit/utils";
8755
- import { useMemo as useMemo15 } from "react";
8756
- function safeJSONParse(src) {
8757
- return safeParseJson(src, (e) => {
8758
- logger.error("parseJSON:error", e);
8759
- });
8760
- }
8761
- function useSafeJSONParse(src) {
8762
- return useMemo15(() => safeJSONParse(src), [src]);
8763
- }
8764
-
8765
- // src/utils/transfer.ts
8766
- import { bitcoinChain as bitcoinChain2, solanaChain, tronChain } from "@funkit/chains";
8767
- function getDepositAddressForChain(chainId, transferInit) {
8768
- if (chainId === solanaChain.id) {
8769
- return transferInit?.solanaAddr;
8770
- }
8771
- if (chainId === bitcoinChain2.id) {
8772
- return transferInit?.btcAddrSegwit;
8773
- }
8774
- if (chainId === tronChain.id) {
8775
- return transferInit?.tronAddr;
8776
- }
8777
- return transferInit?.depositAddr;
8778
- }
8779
- var getTransferTokenQrCodeUri = (props) => {
8780
- const { depositAddress, type } = props;
8781
- if (type === "ethereum") {
8782
- return `ethereum:${depositAddress}`;
8783
- }
8784
- if (type === "solana") {
8785
- return `solana:${depositAddress}`;
8786
- }
8787
- if (type === "bitcoin") {
8788
- return `bitcoin:${depositAddress}`;
8789
- }
8790
- if (type === "tron") {
8791
- return depositAddress;
8792
- }
8793
- throw new Error(`Invalid transfer token qr code type: ${type}`);
8794
- };
8795
-
8796
- // src/hooks/useTokenTransfer.ts
8797
- var useTokenTransfer = (selectedChainId, selectedToken, chainIds) => {
8798
- const { t } = useFunkitTranslation();
8799
- const { apiKey } = useFunkitConfig();
8800
- const { checkoutItem } = useCheckoutContext();
8801
- const enableUniversal = useDynamicConfig(
8802
- "enabletokentransferuniversaldepositaddress"
8803
- );
8804
- const estPriceImpact = usePriceImpactEstimation(
8805
- selectedToken,
8806
- selectedChainId
8807
- );
8808
- const checkoutConfig = checkoutItem?.initSettings.config;
8809
- const maxSlippage = useMaxSlippage({
8810
- apiKey,
8811
- sourceToken: selectedToken,
8812
- selectedChainId,
8813
- targetAssetTicker: checkoutConfig?.targetAssetTicker ?? ""
8814
- });
8815
- const { transferInit, recipientAddr } = useCheckoutTransferInit();
8816
- const minTransferUsd = useMinTransferValue(selectedChainId);
8817
- const minTransferUsdPerChain = useMinTransferValues(chainIds ?? []);
8818
- const isPolygon = selectedChainId === polygon3.id;
8819
- const isUsdceOnPolygon = isPolygon && selectedToken === "USDC.e";
8820
- const isUsdcOnPolygon = isPolygon && selectedToken === "USDC";
8821
- const showOriginalRecipient = !enableUniversal && (isUsdceOnPolygon || isUsdcOnPolygon);
8822
- const funDepositAddress = getDepositAddressForChain(
8823
- selectedChainId,
8824
- transferInit
8825
- );
8826
- const blockchainType = (() => {
8827
- if (selectedChainId === solanaChain2.id) {
8828
- return "solana";
8829
- }
8830
- if (selectedChainId === bitcoinChain3.id) {
8831
- return "bitcoin";
8832
- }
8833
- if (selectedChainId === tronChain2.id) {
8834
- return "tron";
8835
- }
8836
- return "ethereum";
8837
- })();
8838
- const depositAddressTooltip = showOriginalRecipient ? t("transferToken.depositAddressOriginalRecipient") : t("transferToken.depositAddressUniversal", {
8839
- targetToken: checkoutConfig?.targetAssetTicker
8840
- });
8841
- const qrCodeUri = funDepositAddress ? getTransferTokenQrCodeUri({
8842
- depositAddress: funDepositAddress,
8843
- type: blockchainType
8844
- }) : void 0;
8845
- return {
8846
- depositAddress: showOriginalRecipient ? recipientAddr : funDepositAddress,
8847
- depositAddressTooltip,
8848
- recipientAddr,
8849
- minTransferUsd: showOriginalRecipient ? 0 : minTransferUsd,
8850
- minTransferUsdPerChain,
8851
- showOriginalRecipient,
8852
- estPriceImpact: showOriginalRecipient ? void 0 : estPriceImpact,
8853
- maxSlippage: showOriginalRecipient ? void 0 : maxSlippage,
8854
- qrCodeUri,
8855
- blockchain: blockchainType
8856
- };
8857
- };
8858
- var useMinTransferLimits = () => {
8859
- const { userIpInfo } = useFunkitUserIp();
8860
- const minTransferValueJsonString = useFlag(FlagKey2.MinTokenTransferValue);
8861
- const minTransferValue = safeJSONParse(
8862
- minTransferValueJsonString
8863
- );
8864
- if (!minTransferValue) {
8865
- return { mainnet: 0, nonMainnet: 0 };
8866
- }
8867
- const transferLimitKey = userIpInfo?.alpha2 || "DEFAULT";
8868
- const limits = minTransferValue[transferLimitKey] ?? minTransferValue.DEFAULT;
8869
- return limits ?? { mainnet: 0, nonMainnet: 0 };
8870
- };
8871
- function getMinTransferValueForChain(chainId, limits) {
8872
- const MAINNET_IDS = [mainnet4.id, bitcoinChain3.id, tron.id];
8873
- return MAINNET_IDS.includes(chainId) ? limits.mainnet : limits.nonMainnet;
8874
- }
8875
- var useMinTransferValue = (selectedChainId) => {
8876
- const limits = useMinTransferLimits();
8877
- const { checkoutItem } = useCheckoutContext();
8878
- let limit = getMinTransferValueForChain(selectedChainId, limits);
8879
- if (checkoutItem) {
8880
- const { getMinDepositUSD, targetAsset, targetChain } = checkoutItem.initSettings.config;
8881
- limit += getMinDepositUSD?.({
8882
- tokenChainId: targetChain,
8883
- tokenAddress: targetAsset
8884
- }) ?? 0;
8885
- }
8886
- return Math.ceil(limit);
8887
- };
8888
- var useMinTransferValues = (chainIds) => {
8889
- const limits = useMinTransferLimits();
8890
- return useMemo16(() => {
8891
- return chainIds.reduce(
8892
- (acc, id) => {
8893
- const limit = getMinTransferValueForChain(id, limits);
8894
- acc[id] = Math.ceil(limit);
8895
- return acc;
8896
- },
8897
- {}
8898
- );
8899
- }, [chainIds, limits]);
8900
- };
8901
- var usePriceImpactEstimation = (selectedToken, selectedChainId) => {
8902
- const { t } = useFunkitTranslation();
8903
- const { checkoutItem } = useCheckoutContext();
8904
- const label = t("fees.priceImpact");
8905
- const isUSDC = selectedToken === "USDC" || selectedToken === "USDC.e";
8906
- const isUSDT = selectedToken === "USDT";
8907
- const isPreferredChainId = isPreferredChain(selectedChainId);
8908
- const targetAssetTicker = checkoutItem?.initSettings.config.targetAssetTicker ?? "";
8909
- if (!isPreferredChainId || !isStablecoin(targetAssetTicker)) {
8910
- return { label, value: 0.25 };
8911
- }
8912
- if (isUSDC) {
8913
- return { label, value: 0 };
8914
- }
8915
- if (isUSDT) {
8916
- return { label, value: 0.05 };
8917
- }
8918
- return { label, value: 0.1 };
8919
- };
8920
- var useMaxSlippage = ({
8921
- apiKey,
8922
- sourceToken,
8923
- selectedChainId,
8924
- targetAssetTicker
8925
- }) => {
8926
- const { t } = useFunkitTranslation();
8927
- const label = t("fees.maxSlippage");
8928
- const isArbitrum = selectedChainId === arbitrum3.id;
8929
- const isPreferredChainId = isPreferredChain(selectedChainId);
8930
- const defaultValue = 0.25;
8931
- if (isBasedCustomer(apiKey) && isArbitrum && sourceToken === "USDC") {
8932
- return { label, value: 0.1 };
8933
- }
8934
- if (isLighterxyzCustomer(apiKey) && // if preferred chains + chains that have CCTP support
8935
- isPreferredChain(selectedChainId, [hyperEvmChain2.id, monadChain.id]) && sourceToken === "USDC") {
8936
- return { label, value: 0.01 };
8937
- }
8938
- if (isPolymarketCustomer(apiKey) && isPreferredChainId) {
8939
- if (sourceToken === "USDC.e") {
8940
- return { label, value: 0 };
8941
- }
8942
- if (sourceToken === "USDC") {
8943
- return { label, value: 0.05 };
8944
- }
8945
- if (sourceToken === "USDT") {
8946
- return { label, value: 0.2 };
8947
- }
8948
- }
8949
- if (!isPreferredChainId || !isStablecoin(targetAssetTicker) || sourceToken === "DAI") {
8950
- return { label, value: 1 };
8951
- }
8952
- return { label, value: defaultValue };
8953
- };
8954
-
8955
- // src/utils/bluvo.ts
8956
- import {
8957
- BluvoWithdrawalError
8958
- } from "@funkit/api-base";
8959
- import {
8960
- FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS as FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS2,
8961
- FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO as FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO2,
8962
- hyperCoreChain,
8963
- hyperEvmChain as hyperEvmChain3
8964
- } from "@funkit/chains";
8965
- import { v4 as uuid } from "uuid";
8966
- import { arbitrum as arbitrum4 } from "viem/chains";
8967
-
8968
- // src/utils/combineChainSymbolOrAddress.ts
8969
- function combineChainSymbolOrAddress({
8970
- chainId,
8971
- symbolOrAddress
8972
- }) {
8973
- return `${chainId}|${symbolOrAddress}`;
8974
- }
8975
-
8976
- // src/utils/bluvo.ts
8977
- var ASSETS_LOW_VALUE_THRESHOLD = 0.1;
8978
- var isBrokerageAsset = (asset) => "minAmount" in asset && "maxAmount" in asset && asset.usdAmount !== null;
8979
- function getBrokerageMinMax(asset, minTransferLimits, minDeposit = 1) {
8980
- const chainId = Number(asset.pickedChainId);
8981
- const unitPrice = asset.usdAmount / asset.amount;
8982
- const brokerageMin = Number.parseFloat(asset.minAmount);
8983
- const brokerageMax = Number.parseFloat(asset.maxAmount);
8984
- const brokerageMinUsd = brokerageMin * unitPrice;
8985
- const brokerageMaxUsd = brokerageMax * unitPrice;
8986
- const tokenTransferMin = getMinTransferValueForChain(
8987
- chainId,
8988
- minTransferLimits
8989
- );
8990
- return {
8991
- minUsd: Math.ceil(Math.max(tokenTransferMin, brokerageMinUsd, minDeposit)),
8992
- maxUsd: brokerageMaxUsd
8993
- };
8994
- }
8995
- function getPreferredNetwork(networks, targetChainId) {
8996
- let preferredChainId = targetChainId;
8997
- const validNetworks = networks.filter(({ chainId }) => !!chainId);
8998
- const networkMap = Object.fromEntries(
8999
- validNetworks.map((n) => [n.chainId?.toString(), n])
9000
- );
9001
- const isArbritrumOverride = [hyperCoreChain, hyperEvmChain3].some(
9002
- ({ id }) => id.toString() === targetChainId
9003
- );
9004
- if (validNetworks.length === 0) {
9005
- logger.warn("bluvo-getPreferredNetwork:noValidNetworks", {
9006
- networks,
9007
- validNetworks
9008
- });
9009
- return null;
9010
- }
9011
- if (isArbritrumOverride) {
9012
- preferredChainId = arbitrum4.id.toString();
9013
- }
9014
- if (preferredChainId && networkMap[preferredChainId]) {
9015
- return networkMap[preferredChainId];
9016
- }
9017
- let pickedNetwork = validNetworks[0];
9018
- let lowestPriority = Number.MAX_SAFE_INTEGER;
9019
- for (const chainId of Object.keys(networkMap)) {
9020
- const chainInfo = FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO2[chainId];
9021
- const pickPriority = chainInfo?.pickPriority || Number.MAX_SAFE_INTEGER;
9022
- if (pickPriority < lowestPriority) {
9023
- lowestPriority = pickPriority;
9024
- pickedNetwork = networkMap[chainId];
9025
- }
9026
- }
9027
- return pickedNetwork ?? null;
9028
- }
9029
- function transformBluvoBalancesToAssetHoldings(balances, preferredChainId) {
9030
- const LOG_PREFIX = "bluvo-transformBalance";
9031
- const assetHoldings = {};
9032
- if (!balances || balances.length === 0) {
9033
- logger.warn(`${LOG_PREFIX}:emptyAssets`, {
9034
- message: "No available assets from CEX wallet",
9035
- balances,
9036
- preferredChainId
9037
- });
9038
- return assetHoldings;
9039
- }
9040
- logger.info(`${LOG_PREFIX}:totalAssets`, {
9041
- message: "Total assets from CEX wallet",
9042
- balances,
9043
- preferredChainId
9044
- });
9045
- for (const balance of balances) {
9046
- const { amount, amountInFiat, networks } = balance;
9047
- const preferredNetwork = getPreferredNetwork(networks, preferredChainId);
9048
- const asset = preferredNetwork?.assetName;
9049
- const tokenAddress = preferredNetwork?.contractAddress;
9050
- const chainId = preferredNetwork?.chainId;
9051
- if (!chainId || !tokenAddress || !asset) {
9052
- logger.warn(`${LOG_PREFIX}:invalidNetwork`, {
9053
- message: `Invalid network for checkout ${balance.asset}`,
9054
- balance,
9055
- preferredNetwork
9056
- });
9057
- continue;
9058
- }
9059
- const chainInfo = FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO2[chainId];
9060
- if (!chainInfo?.isCheckoutSupported || !chainInfo?.isMainnet) {
9061
- logger.warn(`${LOG_PREFIX}:unsupportedAsset`, {
9062
- message: `Unsupported asset for checkout ${chainId}|${asset}`,
9063
- chainId,
9064
- asset,
9065
- preferredNetwork
9066
- });
9067
- continue;
9068
- }
9069
- if (!tokenAddress) {
9070
- logger.warn(`${LOG_PREFIX}:invalidTokenAddress`, {
9071
- message: `Invalid token address for ${chainId}|${asset}`,
9072
- chainId,
9073
- asset,
9074
- preferredNetwork
9075
- });
9076
- continue;
9077
- }
9078
- if (!amountInFiat || amountInFiat < ASSETS_LOW_VALUE_THRESHOLD) {
9079
- logger.warn(`${LOG_PREFIX}:assetBelowThreshold`, {
9080
- message: `Asset below threshold ${chainId}|${asset}. Amount in fiat: ${amountInFiat}`,
9081
- chainId,
9082
- asset,
9083
- amountInFiat,
9084
- preferredNetwork
9293
+ const response = await fetchWithTimeout(FLAG_PROD_ENDPOINT, {}, 1e4);
9294
+ const configData = await response.json();
9295
+ logger.log("flag_fetchConfigFromServer", {
9296
+ configData
9297
+ });
9298
+ return configData.flags;
9299
+ }
9300
+ function deriveAllFlags(config, userContext) {
9301
+ return Object.fromEntries(
9302
+ Object.entries(config).map(([key, flag]) => [
9303
+ key,
9304
+ deriveFlag(key, flag, userContext)
9305
+ ]).filter(([key, value]) => {
9306
+ const configItem = config[key];
9307
+ if (!configItem) {
9308
+ return false;
9309
+ }
9310
+ if (typeof value !== configItem.type) {
9311
+ logger.warn("flag_mismatchingType", {
9312
+ flagKey: key,
9313
+ type: configItem.type,
9314
+ value
9315
+ });
9316
+ return false;
9317
+ }
9318
+ return true;
9319
+ })
9320
+ );
9321
+ }
9322
+ function deriveFlag(flagKey, flagConfig2, context) {
9323
+ const override = flagConfig2.overrides?.find((override2) => {
9324
+ if (override2.if_all) {
9325
+ return override2.if_all.every((condition) => {
9326
+ return evalCondition(flagKey, condition, context);
9085
9327
  });
9086
- continue;
9087
9328
  }
9088
- const isNativeCurrency = chainInfo.nativeCurrency.symbol.toUpperCase() === asset.toUpperCase();
9089
- const normalizedTokenAddress = isNativeCurrency ? FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS2 : tokenAddress;
9090
- const chainSymbolKey = combineChainSymbolOrAddress({
9091
- chainId: chainId.toString(),
9092
- symbolOrAddress: asset
9329
+ return override2.if_any.some((condition) => {
9330
+ return evalCondition(flagKey, condition, context);
9093
9331
  });
9094
- const iconSrc = ASSET_LOGO_SRCS[asset.toUpperCase()] || FALLBACK_ASSET;
9095
- assetHoldings[chainSymbolKey] = {
9096
- iconSrc,
9097
- symbol: asset,
9098
- amount,
9099
- tokenAddress: normalizedTokenAddress,
9100
- usdAmount: amountInFiat,
9101
- pickedChainId: chainId.toString(),
9102
- chainSymbolKey,
9103
- minAmount: preferredNetwork.minWithdrawal,
9104
- maxAmount: preferredNetwork.maxWithdrawal || amount.toString()
9105
- };
9106
- }
9107
- logger.info(`${LOG_PREFIX}:transformedAssets`, {
9108
- message: "Transformed usable assets from CEX wallet",
9109
- assetHoldings,
9110
- preferredChainId
9111
9332
  });
9112
- return assetHoldings;
9113
- }
9114
- function getWalletId(authorizedConnections, exchange) {
9115
- return authorizedConnections?.[exchange] || uuid();
9333
+ return override?.value ?? flagConfig2.default_value;
9116
9334
  }
9117
- var BluvoError = class extends Error {
9118
- constructor(message, errorCode) {
9119
- super(message);
9120
- this.message = message;
9121
- this.errorCode = errorCode;
9122
- this.name = "BluvoError";
9335
+ function evalConditionValue(condition, context) {
9336
+ switch (condition.key) {
9337
+ case "userId":
9338
+ return context.userId;
9339
+ case "ipCountry":
9340
+ return context.ipCountry;
9341
+ case "apiKey":
9342
+ return context.apiKey;
9343
+ default: {
9344
+ exhaustiveCheck2(condition.key);
9345
+ return void 0;
9346
+ }
9123
9347
  }
9124
- };
9125
- function getBluvoError(error) {
9126
- const errorMessage = error.error;
9127
- return new BluvoError(errorMessage, error.type);
9128
9348
  }
9129
- var normalizeWithdrawalResponse = (response) => {
9130
- try {
9131
- if (!response) {
9132
- throw new BluvoWithdrawalError("Invalid response");
9133
- }
9134
- if (!response.success) {
9135
- const _code = response.error?.type;
9136
- const errorObjOrString = response.error?.error;
9137
- if (typeof errorObjOrString === "object" && errorObjOrString !== null) {
9138
- const errorMessage = errorObjOrString.error;
9139
- const errorCode = errorObjOrString.type;
9140
- throw new BluvoWithdrawalError(errorMessage, errorCode);
9141
- }
9142
- throw new BluvoWithdrawalError(errorObjOrString, _code);
9143
- }
9144
- const data = response.data;
9145
- if (!data) {
9146
- throw new BluvoWithdrawalError(
9147
- "Unexpected error occurred during withdrawal. Please try again."
9148
- );
9349
+ function evalCondition(flagKey, condition, context) {
9350
+ const needle = evalConditionValue(condition, context);
9351
+ if (!needle) {
9352
+ return false;
9353
+ }
9354
+ switch (condition.type) {
9355
+ case "pctRollout": {
9356
+ return hashPct(flagKey, needle, condition.pct);
9149
9357
  }
9150
- if (!data.success) {
9151
- const errorMessage = data.error;
9152
- const errorCode = data.type;
9153
- throw new BluvoWithdrawalError(errorMessage, errorCode);
9358
+ case "isAnyOf": {
9359
+ return condition.values?.includes(needle) ?? false;
9154
9360
  }
9155
- return data.result;
9156
- } catch (error) {
9157
- if (error instanceof BluvoWithdrawalError) {
9158
- throw error;
9361
+ default: {
9362
+ throw new Error(`Unknown condition type: ${JSON.stringify(condition)}`);
9159
9363
  }
9160
- throw new BluvoWithdrawalError(
9161
- "An error occurred during withdrawal. Please try again."
9162
- );
9163
9364
  }
9164
- };
9165
- var isBluvoWithdrawalError = (error) => {
9166
- return error instanceof BluvoWithdrawalError;
9167
- };
9168
-
9169
- // src/providers/FunkitSandboxContext.tsx
9170
- import { createContext as createContext10, useContext as useContext10 } from "react";
9171
- var FunkitSandboxContext = createContext10(false);
9172
- var useIsFunkitSandboxMode = () => useContext10(FunkitSandboxContext);
9365
+ }
9173
9366
 
9174
- // src/providers/FunkitBrokerageProvider.tsx
9175
- var PROD_ORG_ID = "swVwRpxm54werxWOQ5EayjtWM8i33jtL";
9176
- var PROD_PROJECT_ID = "tdN6yxVldIkEuE9XjKVGu0OCLsHcjVuy";
9177
- var STAGE_ORG_ID = "ezCUF9l9zpdB01nVvGe8O2E1vDZSbkVa";
9178
- var STAGE_PROJECT_ID = "D00dTLSdlAYpEFDTL2mMj7bee3SbjYI0";
9179
- var LOCAL_STORAGE_KEY = "fkc-bluvo-cex";
9180
- var FunkitBrokerageContext = createContext11(void 0);
9181
- var FunkitBrokerageProvider = ({
9182
- children
9183
- }) => {
9367
+ // src/providers/FunkitMoonpayProvider.tsx
9368
+ import { useMemo as useMemo15 } from "react";
9369
+ var BYPASS_COUNTRY_BLOCK_CHECK = false;
9370
+ var ALL_MATCH = "*";
9371
+ var isCountryBlocked = (blockedList, userIpInfo) => {
9372
+ if (BYPASS_COUNTRY_BLOCK_CHECK) {
9373
+ return false;
9374
+ }
9375
+ if (!userIpInfo.alpha2) {
9376
+ logger.log("isUserBlockedForCheckout_NoIpDetected");
9377
+ return true;
9378
+ }
9379
+ const isBlocked = blockedList.includes(ALL_MATCH) || blockedList.includes(userIpInfo.alpha2);
9380
+ logger.log("isUserBlockedForCheckoutResult", {
9381
+ isBlocked,
9382
+ blockedList,
9383
+ userIpInfo
9384
+ });
9385
+ return isBlocked;
9386
+ };
9387
+ function useFunkitUserIp() {
9184
9388
  const { apiKey } = useFunkitConfig();
9185
- const isSandboxMode = useIsFunkitSandboxMode();
9186
- const minTransferRef = useRef8(useMinTransferLimits());
9187
- const ORG_ID = isSandboxMode ? STAGE_ORG_ID : PROD_ORG_ID;
9188
- const PROJECT_ID = isSandboxMode ? STAGE_PROJECT_ID : PROD_PROJECT_ID;
9189
- const apiBaseConfig = { apiKey, logger };
9190
- const [authConnections, setAuthConnections] = useState18(
9191
- {}
9192
- );
9193
- const [selectedBrokerageAsset, setSelectedBrokerageAsset] = useState18(null);
9194
- const bluvoClient = useBluvoFlow({
9195
- orgId: ORG_ID,
9196
- projectId: PROJECT_ID,
9197
- listExchangesFn: (status = "live") => bluvoListExchanges({ status, ...apiBaseConfig }),
9198
- fetchWithdrawableBalanceFn: (id) => bluvoGetWithdrawableBalanceById({ id, ...apiBaseConfig }),
9199
- pingWalletByIdFn: () => {
9200
- throw new Error("Not implemented");
9201
- },
9202
- requestQuotationFn: (id, params) => bluvoRequestQuotation({ id, params, ...apiBaseConfig }),
9203
- executeWithdrawalFn: (id, idempotencyKey, quoteId, params) => bluvoExecuteWithdrawal({
9204
- id,
9205
- idempotencyKey,
9206
- quoteId,
9207
- params,
9208
- ...apiBaseConfig
9209
- }),
9210
- onWalletConnectedFn: (id, exchange) => handleOnWalletConnected(id, exchange),
9211
- getWalletByIdFn: (id) => bluvoGetWalletById({ id, ...apiBaseConfig }),
9212
- options: {
9213
- customDomain: "bluvo.fun.xyz",
9214
- autoRefreshQuotation: false
9389
+ const isPolymarket = isPolymarketCustomer(apiKey);
9390
+ const { isUserLoggedIn } = useGeneralWallet();
9391
+ const { userIpInfo, isLoadingGeoCheck } = useUserIpInfo();
9392
+ const blockedCountries = useDynamicConfig("blockedcountries");
9393
+ const isUserGeoblocked = useMemo15(() => {
9394
+ if (isLoadingGeoCheck || isPolymarket) {
9395
+ return false;
9396
+ }
9397
+ if (!userIpInfo) {
9398
+ return true;
9215
9399
  }
9400
+ return isCountryBlocked(blockedCountries, userIpInfo);
9401
+ }, [blockedCountries, isLoadingGeoCheck, userIpInfo, isPolymarket]);
9402
+ return {
9403
+ isLoadingGeoCheck,
9404
+ isUserGeoblocked,
9405
+ isUserLoggedIn,
9406
+ userIpInfo
9407
+ };
9408
+ }
9409
+
9410
+ // src/providers/FunkitFlagsProvider.tsx
9411
+ var FunkitFlagsContext = createContext11({
9412
+ error: null,
9413
+ flags: {},
9414
+ getFlag() {
9415
+ throw Error("Missing FunkitFlagsProvider");
9416
+ },
9417
+ isLoading: true
9418
+ });
9419
+ function FunkitFlagsProvider({ children }) {
9420
+ const { apiKey } = useFunkitConfig();
9421
+ const { userInfo } = useGeneralWallet();
9422
+ const { userIpInfo } = useFunkitUserIp();
9423
+ const {
9424
+ data: onlineConfig,
9425
+ error,
9426
+ isLoading
9427
+ } = useQuery6({
9428
+ queryKey: ["flags"],
9429
+ queryFn: fetchConfigFromServer,
9430
+ refetchOnMount: false,
9431
+ refetchOnReconnect: true,
9432
+ refetchOnWindowFocus: false
9216
9433
  });
9217
- const initialIsConnected = !!bluvoClient.context?.walletBalances;
9218
- const [isConnected, setIsConnected] = useState18(
9219
- () => initialIsConnected
9220
- );
9221
- useEffect15(() => {
9222
- const initialConnections = getAuthConnectedExchanges();
9223
- setAuthConnections(initialConnections);
9224
- }, []);
9434
+ const flags = useMemo16(() => {
9435
+ const config = onlineConfig ?? flagConfig;
9436
+ return deriveAllFlags(config, {
9437
+ apiKey,
9438
+ // placeholder user info is '0x'
9439
+ userId: userInfo.id === "0x" ? void 0 : userInfo.id,
9440
+ ipCountry: userIpInfo?.alpha2
9441
+ });
9442
+ }, [apiKey, onlineConfig, userInfo.id, userIpInfo?.alpha2]);
9443
+ const context = useMemo16(() => {
9444
+ return {
9445
+ error,
9446
+ flags,
9447
+ getFlag: (flagKey, fallback2) => {
9448
+ return flags[flagKey] ?? fallback2 ?? flagConfig[flagKey].default_value;
9449
+ },
9450
+ isLoading
9451
+ };
9452
+ }, [error, flags, isLoading]);
9225
9453
  useEffect15(() => {
9226
- if (bluvoClient.withdrawal?.status === "completed") {
9227
- setSelectedBrokerageAsset(null);
9228
- }
9229
- }, [bluvoClient.withdrawal?.status]);
9230
- const brokerageMinMax = useMemo17(() => {
9231
- if (!selectedBrokerageAsset || !isBrokerageAsset(selectedBrokerageAsset)) {
9232
- return null;
9233
- }
9234
- return getBrokerageMinMax(
9235
- selectedBrokerageAsset,
9236
- minTransferRef.current,
9237
- BLUVO_MIN_DEPOSIT_BY_CUSTOMER[apiKey]
9238
- );
9239
- }, [selectedBrokerageAsset, apiKey]);
9240
- function getAuthConnectedExchanges() {
9241
- if (typeof localStorage !== "undefined") {
9242
- const connections = localStorage.getItem(LOCAL_STORAGE_KEY) || void 0;
9243
- return safeParseJson2(connections) || {};
9454
+ if (!isLoading) {
9455
+ datadogLogs2.setGlobalContextProperty("flags", flags);
9244
9456
  }
9245
- return {};
9246
- }
9247
- function saveAuthConnectedExchange(id, exchange) {
9248
- try {
9249
- const connections = { ...authConnections, [exchange]: id };
9250
- localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(connections));
9251
- setAuthConnections(connections);
9252
- } catch (error) {
9253
- const errorToLog = error instanceof Error ? error : new Error("Failed to save brokerage connection");
9254
- logger.error("brokerage:saveConnectionFailed", errorToLog, {
9255
- exchange
9256
- });
9457
+ }, [flags, isLoading]);
9458
+ useEffect15(() => {
9459
+ if (error) {
9460
+ logger.error("flag_initError", error);
9257
9461
  }
9258
- }
9259
- function purgeAuthConnectedExchange(exchange) {
9260
- const connections = { ...authConnections };
9261
- delete connections[exchange];
9262
- localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(connections));
9263
- setAuthConnections(connections);
9264
- }
9265
- const handleOnWalletConnected = async (walletId, exchange) => {
9266
- saveAuthConnectedExchange(walletId, exchange);
9267
- setIsConnected(true);
9268
- };
9269
- return /* @__PURE__ */ React39.createElement(
9270
- FunkitBrokerageContext.Provider,
9271
- {
9272
- value: {
9273
- bluvoClient,
9274
- authorizedConnections: authConnections,
9275
- purgeAuthConnectedExchange,
9276
- isConnected,
9277
- selectedBrokerageAsset,
9278
- setSelectedBrokerageAsset,
9279
- brokerageMinMax
9280
- }
9281
- },
9282
- children
9283
- );
9284
- };
9285
- function useFunkitBrokerageContext() {
9286
- const context = useContext11(FunkitBrokerageContext);
9287
- if (!context) {
9288
- throw new Error("FunkitBrokerageContext not found");
9289
- }
9290
- return context;
9462
+ }, [error]);
9463
+ return /* @__PURE__ */ React39.createElement(FunkitFlagsContext.Provider, { value: context }, children);
9464
+ }
9465
+ function useFlags() {
9466
+ return useContext11(FunkitFlagsContext);
9467
+ }
9468
+ function useFlag(flagKey, fallback2, middleware) {
9469
+ const flagValue = useContext11(FunkitFlagsContext).getFlag(flagKey, fallback2);
9470
+ return middleware ? middleware(flagValue) : flagValue;
9291
9471
  }
9292
9472
 
9293
9473
  // src/providers/FunkitI18nProvider.tsx
@@ -13693,7 +13873,7 @@ import React42, {
13693
13873
  import { bluvoGetWithdrawableBalanceById as bluvoGetWithdrawableBalanceById2 } from "@funkit/api-base";
13694
13874
  import { FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO as FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO3 } from "@funkit/chains";
13695
13875
  import { keepPreviousData, useQuery as useQuery7 } from "@tanstack/react-query";
13696
- import { useCallback as useCallback13, useMemo as useMemo18 } from "react";
13876
+ import { useCallback as useCallback13, useMemo as useMemo17 } from "react";
13697
13877
 
13698
13878
  // src/domains/wallet.ts
13699
13879
  import { polygon as polygon4 } from "viem/chains";
@@ -13813,7 +13993,7 @@ var useBluvoSupportedExchanges = ({
13813
13993
  filterBy = ["live" /* Live */]
13814
13994
  }) => {
13815
13995
  const { authorizedConnections } = useFunkitBrokerageContext();
13816
- const exchangeOptions = useMemo18(
13996
+ const exchangeOptions = useMemo17(
13817
13997
  () => SUPPORTED_EXCHANGES.filter(
13818
13998
  ({ status: exchangeStatus }) => filterBy.includes(exchangeStatus)
13819
13999
  ).map(({ exchange, status }) => {
@@ -14990,7 +15170,7 @@ var useThemeRootProps = () => {
14990
15170
  function FunkitProvider(props) {
14991
15171
  validateFunkitProviderProps(props);
14992
15172
  const initialChainId = getInitialChainIdFromFunkitProviderProps(props);
14993
- const finalWagmiConfig = useMemo19(() => {
15173
+ const finalWagmiConfig = useMemo18(() => {
14994
15174
  if (!props.wagmiConfig || !initialChainId) {
14995
15175
  return void 0;
14996
15176
  }
@@ -15000,7 +15180,7 @@ function FunkitProvider(props) {
15000
15180
  });
15001
15181
  }, [initialChainId, props.wagmiConfig, props.funkitConfig.appName]);
15002
15182
  const finalQueryClient = props.queryClient;
15003
- const sdkVersion = useMemo19(() => getCurrentSdkVersion(), []);
15183
+ const sdkVersion = useMemo18(() => getCurrentSdkVersion(), []);
15004
15184
  useEffect20(() => {
15005
15185
  logger.configure(
15006
15186
  props.funkitConfig.apiKey,
@@ -15047,16 +15227,16 @@ function FunkitProviderInner({
15047
15227
  useFingerprint();
15048
15228
  useAccountEffect({ onDisconnect: clearWalletConnectDeepLink });
15049
15229
  const { activeTheme } = useActiveTheme();
15050
- const selector = useMemo19(() => createThemeRootSelector(id), [id]);
15051
- const themeRootProps = useMemo19(() => createThemeRootProps(id), [id]);
15052
- const themeStyles = useMemo19(() => {
15230
+ const selector = useMemo18(() => createThemeRootSelector(id), [id]);
15231
+ const themeRootProps = useMemo18(() => createThemeRootProps(id), [id]);
15232
+ const themeStyles = useMemo18(() => {
15053
15233
  if (!activeTheme) {
15054
15234
  return "";
15055
15235
  }
15056
15236
  const rawCss = `${selector}{${cssStringFromTheme(activeTheme)}}`;
15057
15237
  return useStyleRefForTheme ? rawCss : sanitizeCssStyleContent(rawCss);
15058
15238
  }, [activeTheme, selector, useStyleRefForTheme]);
15059
- const styleRef = useRef9(null);
15239
+ const styleRef = useRef8(null);
15060
15240
  useIsomorphicLayoutEffect(() => {
15061
15241
  if (useStyleRefForTheme && styleRef.current) {
15062
15242
  styleRef.current.textContent = themeStyles;
@@ -16031,7 +16211,7 @@ var FunTooltip = ({
16031
16211
  };
16032
16212
 
16033
16213
  // src/components/Dialog/FocusTrap.tsx
16034
- import React62, { useCallback as useCallback17, useEffect as useEffect22, useRef as useRef10 } from "react";
16214
+ import React62, { useCallback as useCallback17, useEffect as useEffect22, useRef as useRef9 } from "react";
16035
16215
  var moveFocusWithin = (element2, position) => {
16036
16216
  const focusableElements = element2.querySelectorAll(
16037
16217
  "button:not(:disabled), a[href]"
@@ -16042,7 +16222,7 @@ var moveFocusWithin = (element2, position) => {
16042
16222
  focusableElements[position === "end" ? focusableElements.length - 1 : 0]?.focus();
16043
16223
  };
16044
16224
  function FocusTrap(props) {
16045
- const contentRef = useRef10(null);
16225
+ const contentRef = useRef9(null);
16046
16226
  useEffect22(() => {
16047
16227
  const previouslyActiveElement = document.activeElement;
16048
16228
  return () => {
@@ -16267,7 +16447,7 @@ function Dialog({
16267
16447
  transition: transitionIn
16268
16448
  };
16269
16449
  };
16270
- const tooltipAnchorRef = useRef11(null);
16450
+ const tooltipAnchorRef = useRef10(null);
16271
16451
  if (typeof document === "undefined") {
16272
16452
  return null;
16273
16453
  }
@@ -16435,7 +16615,7 @@ var DialogBottom = ({
16435
16615
  ...boxProps
16436
16616
  }) => {
16437
16617
  const { activeTheme } = useActiveTheme();
16438
- const ref = useRef11(null);
16618
+ const ref = useRef10(null);
16439
16619
  const extraBottomPadding = getValueFromPxString(activeTheme.spacing.modalBaseHorizontalPadding) * 2 - getValueFromPxString(activeTheme.spacing.modalPaddingBottomLower);
16440
16620
  const hasNoChildren = useBottomBarHasNoChildren();
16441
16621
  const paddingBottom = (() => {
@@ -16606,21 +16786,21 @@ Dialog.BottomSection = DialogBottom;
16606
16786
  Dialog.BottomBar = FunBottomBar;
16607
16787
 
16608
16788
  // src/modals/WithdrawalModal/WithdrawalCallbackSuccess.tsx
16609
- import React98, { useMemo as useMemo27 } from "react";
16789
+ import React98, { useMemo as useMemo26 } from "react";
16610
16790
 
16611
16791
  // src/components/FunCheckoutHistory/PendingSuccessScreen.tsx
16612
16792
  import {
16613
16793
  DirectExecutionType as DirectExecutionType2,
16614
16794
  RelayExecutionStatus as RelayExecutionStatus3
16615
16795
  } from "@funkit/api-base";
16616
- import React97, { useCallback as useCallback22, useEffect as useEffect27, useMemo as useMemo26, useState as useState26 } from "react";
16796
+ import React97, { useCallback as useCallback22, useEffect as useEffect27, useMemo as useMemo25, useState as useState26 } from "react";
16617
16797
 
16618
16798
  // src/hooks/queries/useRecentDeposits.ts
16619
16799
  import {
16620
16800
  getDirectExecutionsByUserId as getDirectExecutionsByUserId2
16621
16801
  } from "@funkit/api-base";
16622
16802
  import { useQuery as useQuery9 } from "@tanstack/react-query";
16623
- import { useMemo as useMemo20 } from "react";
16803
+ import { useMemo as useMemo19 } from "react";
16624
16804
 
16625
16805
  // src/hooks/queries/useRecentCheckouts.ts
16626
16806
  import {
@@ -16719,7 +16899,7 @@ function useRecentDepositsImpl({
16719
16899
  refetchInterval: refreshIntervalMs,
16720
16900
  enabled: isVisible && !!userId
16721
16901
  });
16722
- const data = useMemo20(() => {
16902
+ const data = useMemo19(() => {
16723
16903
  if (!directExecutions) {
16724
16904
  return directExecutions;
16725
16905
  }
@@ -16777,7 +16957,7 @@ function useFunkitRecentDepositsImpl(query) {
16777
16957
  fetchSize: fetchSize * 2
16778
16958
  // fetch extra to account for merging
16779
16959
  });
16780
- return useMemo20(
16960
+ return useMemo19(
16781
16961
  () => ({
16782
16962
  data: data?.map((de) => purifyCheckoutHistoryItem(de)).slice(0, fetchSize)
16783
16963
  }),
@@ -16791,7 +16971,7 @@ import {
16791
16971
  formatTimestamp as formatTimestamp2,
16792
16972
  isTokenEquivalent
16793
16973
  } from "@funkit/utils";
16794
- import React96, { useCallback as useCallback21, useMemo as useMemo25, useRef as useRef14, useState as useState25 } from "react";
16974
+ import React96, { useCallback as useCallback21, useMemo as useMemo24, useRef as useRef13, useState as useState25 } from "react";
16795
16975
  import { createPortal as createPortal2 } from "react-dom";
16796
16976
 
16797
16977
  // src/hooks/useReceiveAmountLabel.ts
@@ -16966,7 +17146,7 @@ import {
16966
17146
  BridgeCustomerStatus as BridgeCustomerStatus3,
16967
17147
  FormOfPaymentType as FormOfPaymentType2
16968
17148
  } from "@funkit/api-base";
16969
- import { FlagKey as FlagKey3, formatCurrencyAndStringify as formatCurrencyAndStringify2 } from "@funkit/utils";
17149
+ import { FlagKey as FlagKey2, formatCurrencyAndStringify as formatCurrencyAndStringify2 } from "@funkit/utils";
16970
17150
  import React74, { useEffect as useEffect25 } from "react";
16971
17151
 
16972
17152
  // src/domains/bridge.ts
@@ -17063,7 +17243,7 @@ var isSoftRejected = (customer) => customer && isKycUninitialized(customer.statu
17063
17243
  var FIAT_PROCESSING_TIME = "1-2 business days";
17064
17244
 
17065
17245
  // src/hooks/useCheckoutTimeEstimate.ts
17066
- import { mainnet as mainnet5 } from "viem/chains";
17246
+ import { mainnet as mainnet4 } from "viem/chains";
17067
17247
 
17068
17248
  // src/utils/timeFormat.ts
17069
17249
  import { formatSecondsToReadableForm } from "@funkit/utils";
@@ -17090,7 +17270,7 @@ function useCheckoutTimeEstimate(latestQuote, originalTimeEstimationMs, paymentM
17090
17270
  );
17091
17271
  const { showInstantTimeEstimate } = uiCustomizations.confirmationScreen;
17092
17272
  const sourceChainId = checkoutItem?.selectedSourceAssetInfo.chainId;
17093
- const isSourceChainMainnet = sourceChainId === String(mainnet5.id);
17273
+ const isSourceChainMainnet = sourceChainId === String(mainnet4.id);
17094
17274
  const isBrokeragePayment = paymentMethod === "brokerage" /* BROKERAGE */;
17095
17275
  const formatTimeText = (seconds) => {
17096
17276
  if (seconds === 0) {
@@ -17362,195 +17542,12 @@ function useCreateVirtualBankAccount() {
17362
17542
  return handleCreateVirtualFiatAccount;
17363
17543
  }
17364
17544
 
17365
- // src/hooks/useTokenTransferConfig.ts
17366
- import { useMemo as useMemo21 } from "react";
17367
- import { polygon as polygon5 } from "viem/chains";
17368
-
17369
- // src/hooks/useSupportedAssets.ts
17370
- import {
17371
- getSupportedAssets
17372
- } from "@funkit/api-base";
17373
- import { useQuery as useQuery11 } from "@tanstack/react-query";
17374
- function useSupportedAssets(options) {
17375
- const { apiKey } = useFunkitConfig();
17376
- return useQuery11({
17377
- queryKey: ["getSupportedAssets", apiKey],
17378
- queryFn: () => getSupportedAssets({ apiKey, logger }),
17379
- refetchOnMount: false,
17380
- refetchOnReconnect: false,
17381
- refetchOnWindowFocus: false,
17382
- staleTime: 5 * 60 * 1e3,
17383
- gcTime: Number.POSITIVE_INFINITY,
17384
- enabled: !!apiKey && (options?.enabled ?? true)
17385
- });
17386
- }
17387
-
17388
- // src/utils/tokenTransfer/disabledList.ts
17389
- import { isTokenAddressEquivalent } from "@funkit/utils";
17390
- function isChainDisabled(disabledConfig, chainId) {
17391
- if (!disabledConfig) {
17392
- return false;
17393
- }
17394
- const disabledTokens = disabledConfig[String(chainId)];
17395
- if (!disabledTokens) {
17396
- return false;
17397
- }
17398
- return disabledTokens.includes("*");
17399
- }
17400
- function isAssetDisabled(disabledConfig, chainId, tokenAddress) {
17401
- if (!disabledConfig) {
17402
- return false;
17403
- }
17404
- const disabledTokens = disabledConfig[String(chainId)];
17405
- if (!disabledTokens) {
17406
- return false;
17407
- }
17408
- if (disabledTokens.includes("*")) {
17409
- return true;
17410
- }
17411
- return disabledTokens.some(
17412
- (disabledTokenAddress) => isTokenAddressEquivalent({
17413
- firstTokenAddress: disabledTokenAddress,
17414
- secondTokenAddress: tokenAddress
17415
- })
17416
- );
17417
- }
17418
-
17419
- // src/hooks/useTokenTransferConfig.ts
17420
- var SYMBOL_OVERRIDES = {
17421
- "USD\u20AE0": "USDT",
17422
- USDT0: "USDT"
17423
- };
17424
- var POLYGON_NATIVE_TOKEN_ALIAS = "MATIC";
17425
- function lowercaseAddressKeys(response) {
17426
- return Object.fromEntries(
17427
- Object.entries(response).map(([chainId, chainAssets]) => [
17428
- chainId,
17429
- Object.fromEntries(
17430
- Object.entries(chainAssets).map(([address, metadata]) => [
17431
- address.toLowerCase(),
17432
- metadata
17433
- ])
17434
- )
17435
- ])
17436
- );
17437
- }
17438
- function resolveSymbols(backendSymbol, chainId, address) {
17439
- const displaySymbol = SYMBOL_OVERRIDES[backendSymbol] ?? backendSymbol;
17440
- const alias = chainId === polygon5.id && isNativeTokenAddress(address) ? POLYGON_NATIVE_TOKEN_ALIAS : void 0;
17441
- return { displaySymbol, alias };
17442
- }
17443
- function resolveChainAssets(chainConfig, chainAssets, disabledChainAssets) {
17444
- const { chainId } = chainConfig;
17445
- const resolvedChainAssets = chainConfig.assets.filter(
17446
- (configAsset) => !isAssetDisabled(
17447
- disabledChainAssets,
17448
- chainId,
17449
- configAsset.address.toLowerCase()
17450
- )
17451
- ).map((configAsset) => {
17452
- const address = configAsset.address.toLowerCase();
17453
- const metadata = chainAssets?.[address];
17454
- if (!metadata) {
17455
- logger.warn("useTokenTransferConfig:tokenMetadataMissing", {
17456
- chainId,
17457
- address: configAsset.address
17458
- });
17459
- return null;
17460
- }
17461
- const { displaySymbol, alias } = resolveSymbols(
17462
- metadata.symbol,
17463
- chainId,
17464
- address
17465
- );
17466
- return {
17467
- address,
17468
- metadata: { ...metadata, symbol: displaySymbol },
17469
- alias
17470
- };
17471
- }).filter((item) => item !== null);
17472
- const assets = Object.fromEntries(
17473
- resolvedChainAssets.map(({ address, metadata }) => [address, metadata])
17474
- );
17475
- const symbols = [
17476
- ...new Set(
17477
- resolvedChainAssets.flatMap(
17478
- ({ metadata, alias }) => alias ? [metadata.symbol, alias] : [metadata.symbol]
17479
- )
17480
- )
17481
- ];
17482
- return { assets, symbols };
17483
- }
17484
- function resolveTokenTransferConfig(chainConfigs, rawPriorityTokens, disabledChainAssets, allSupportedAssets) {
17485
- const lowercasedAssets = lowercaseAddressKeys(allSupportedAssets);
17486
- const resolvedChains = chainConfigs.filter((c) => !isChainDisabled(disabledChainAssets, c.chainId)).map((chainConfig) => ({
17487
- chainConfig,
17488
- resolvedChainAssets: resolveChainAssets(
17489
- chainConfig,
17490
- lowercasedAssets[String(chainConfig.chainId)],
17491
- disabledChainAssets
17492
- )
17493
- })).filter(({ resolvedChainAssets }) => resolvedChainAssets.symbols.length > 0);
17494
- const supportedAssets = Object.fromEntries(
17495
- resolvedChains.map(({ chainConfig, resolvedChainAssets }) => [
17496
- chainConfig.chainId,
17497
- resolvedChainAssets.assets
17498
- ])
17499
- );
17500
- const symbolsByChainId = Object.fromEntries(
17501
- resolvedChains.map(({ chainConfig, resolvedChainAssets }) => [
17502
- chainConfig.chainId,
17503
- resolvedChainAssets.symbols
17504
- ])
17505
- );
17506
- const chainIdSortOrder = resolvedChains.map(
17507
- ({ chainConfig }) => chainConfig.chainId
17508
- );
17509
- const defaultChainId = resolvedChains.find(
17510
- ({ chainConfig }) => chainConfig.isDefault
17511
- )?.chainConfig.chainId;
17512
- return {
17513
- supportedAssets,
17514
- symbolsByChainId,
17515
- chainIdSortOrder,
17516
- defaultChainId,
17517
- priorityTokenSymbols: [...rawPriorityTokens]
17518
- };
17519
- }
17520
- var EMPTY_CONFIG = {
17521
- supportedAssets: {},
17522
- symbolsByChainId: {},
17523
- chainIdSortOrder: [],
17524
- defaultChainId: void 0,
17525
- priorityTokenSymbols: []
17526
- };
17527
- function useTokenTransferConfig() {
17528
- const rawConfig = useDynamicConfig("tokentransferconfig");
17529
- const disabledChainAssets = useDynamicConfig(
17530
- "disabletokentransferchainsandassets"
17531
- );
17532
- const { data: allSupportedAssets, isLoading } = useSupportedAssets();
17533
- const config = useMemo21(() => {
17534
- if (!allSupportedAssets) {
17535
- return EMPTY_CONFIG;
17536
- }
17537
- const { chains: rawChains, priorityTokens: rawPriorityTokens } = rawConfig;
17538
- return resolveTokenTransferConfig(
17539
- rawChains ?? [],
17540
- rawPriorityTokens ?? [],
17541
- disabledChainAssets,
17542
- allSupportedAssets
17543
- );
17544
- }, [rawConfig, disabledChainAssets, allSupportedAssets]);
17545
- return { ...config, isLoading };
17546
- }
17547
-
17548
17545
  // src/hooks/useWalletAssetHoldings.ts
17549
17546
  import {
17550
17547
  FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS as FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS3,
17551
17548
  FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO as FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO7
17552
17549
  } from "@funkit/chains";
17553
- import { useMemo as useMemo23 } from "react";
17550
+ import { useMemo as useMemo21 } from "react";
17554
17551
 
17555
17552
  // src/utils/assets.ts
17556
17553
  import { formatUnits as formatUnits2 } from "viem";
@@ -17584,14 +17581,14 @@ var getDefaultDynamicTargetAsset = (checkoutConfig) => {
17584
17581
 
17585
17582
  // src/hooks/useAllowedAssets.ts
17586
17583
  import { getAllowedAssets } from "@funkit/api-base";
17587
- import { useQuery as useQuery12 } from "@tanstack/react-query";
17588
- import { useCallback as useCallback20, useMemo as useMemo22 } from "react";
17584
+ import { useQuery as useQuery11 } from "@tanstack/react-query";
17585
+ import { useCallback as useCallback20, useMemo as useMemo20 } from "react";
17589
17586
  function useAllowedAssets({
17590
17587
  enabled
17591
17588
  } = {}) {
17592
17589
  const { apiKey } = useFunkitConfig();
17593
17590
  const { checkoutItem } = useCheckoutContext();
17594
- const { data: allowedAssets, isLoading } = useQuery12({
17591
+ const { data: allowedAssets, isLoading } = useQuery11({
17595
17592
  queryKey: ["getAllowedAssets", apiKey],
17596
17593
  queryFn: () => getAllowedAssets({ apiKey, logger }),
17597
17594
  refetchOnMount: false,
@@ -17601,7 +17598,7 @@ function useAllowedAssets({
17601
17598
  gcTime: Number.POSITIVE_INFINITY,
17602
17599
  enabled
17603
17600
  });
17604
- const tokens = useMemo22(() => {
17601
+ const tokens = useMemo20(() => {
17605
17602
  if (!allowedAssets) {
17606
17603
  return {};
17607
17604
  }
@@ -17689,12 +17686,12 @@ function useWalletAssetHoldings(targetChain) {
17689
17686
  });
17690
17687
  const isDynamicRoutingEnabled = useIsDynamicRoutingEnabled();
17691
17688
  const { t } = useFunkitTranslation();
17692
- const processedAssets = useMemo23(
17689
+ const processedAssets = useMemo21(
17693
17690
  () => processWalletAssets(walletAssets, targetChain),
17694
17691
  [targetChain, walletAssets]
17695
17692
  );
17696
17693
  const minValueThreshold = getMinValueThreshold(config);
17697
- const hasUsableBalance = useMemo23(() => {
17694
+ const hasUsableBalance = useMemo21(() => {
17698
17695
  if (isLoading || isAllowedAssetsLoading) {
17699
17696
  return true;
17700
17697
  }
@@ -17782,6 +17779,18 @@ var useWalletLabel = () => {
17782
17779
  return t("sourceChange.walletDisplayLabel", { walletLabel: label });
17783
17780
  };
17784
17781
 
17782
+ // src/utils/safeJSON.ts
17783
+ import { safeParseJson as safeParseJson2 } from "@funkit/utils";
17784
+ import { useMemo as useMemo22 } from "react";
17785
+ function safeJSONParse(src) {
17786
+ return safeParseJson2(src, (e) => {
17787
+ logger.error("parseJSON:error", e);
17788
+ });
17789
+ }
17790
+ function useSafeJSONParse(src) {
17791
+ return useMemo22(() => safeJSONParse(src), [src]);
17792
+ }
17793
+
17785
17794
  // src/utils/swapped.ts
17786
17795
  import {
17787
17796
  FormOfPaymentType
@@ -17969,7 +17978,7 @@ import { exhaustiveCheck as exhaustiveCheck3 } from "@funkit/utils";
17969
17978
 
17970
17979
  // src/components/FunBadge/FunBadge.tsx
17971
17980
  import clsx9 from "clsx";
17972
- import React67, { useMemo as useMemo24 } from "react";
17981
+ import React67, { useMemo as useMemo23 } from "react";
17973
17982
 
17974
17983
  // src/components/FunBadge/FunBadge.css.ts
17975
17984
  var badgeShineStyle = "bc2uzy2";
@@ -17993,7 +18002,7 @@ function FunBadge({
17993
18002
  hasShine = false
17994
18003
  }) {
17995
18004
  const { t } = useFunkitTranslation();
17996
- const borderStyle = useMemo24(() => {
18005
+ const borderStyle = useMemo23(() => {
17997
18006
  return borderColor ? { borderStyle: "solid", borderColor, borderWidth: "1" } : {};
17998
18007
  }, [borderColor]);
17999
18008
  return /* @__PURE__ */ React67.createElement(
@@ -18132,7 +18141,7 @@ import React70 from "react";
18132
18141
 
18133
18142
  // src/components/FunOptionBox/FunOptionBox.tsx
18134
18143
  import clsx10 from "clsx";
18135
- import React69, { useRef as useRef12 } from "react";
18144
+ import React69, { useRef as useRef11 } from "react";
18136
18145
 
18137
18146
  // src/components/FunOptionBox/FunOptionBox.css.ts
18138
18147
  var funOptionBoxStyle = { baseStyle: "_1rfcluh0", compactListStyle: "_1rfcluh1", defaultBorder: "_1rsrm2f28o _1rsrm2f28v _1rsrm2f1qt", defaultModeNotActiveBorder: "_1rsrm2f290 _1rsrm2f297 _1rsrm2f1qt _1rsrm2f1n", activeBorder: "_1rsrm2f1qo", disabledOptionBorder: "_1rsrm2f1si", defaultBackground: "_1rsrm2f1ho _1rsrm2f11d", activeBackground: "_1rsrm2f1ho _1rsrm2f181 _1rsrm2f182", uninteractiveBackground: "_1rsrm2f1hu" };
@@ -18159,7 +18168,7 @@ function FunOptionBox({
18159
18168
  ...boxProps
18160
18169
  }) {
18161
18170
  const isClickable = !!onClick && !disabled;
18162
- const ref = useRef12(null);
18171
+ const ref = useRef11(null);
18163
18172
  return /* @__PURE__ */ React69.createElement(
18164
18173
  Box,
18165
18174
  {
@@ -18702,18 +18711,19 @@ var TransferPaymentMethodItem = ({
18702
18711
  const { isUserGeoblocked } = useFunkitUserIp();
18703
18712
  const { t } = useFunkitTranslation();
18704
18713
  const { textCustomizations } = useFunkitConfig();
18705
- const bannerJson = useFlag(FlagKey3.NewTokenAssetSelectionBanner);
18714
+ const bannerJson = useFlag(FlagKey2.NewTokenAssetSelectionBanner);
18706
18715
  const bannerData = useSafeJSONParse(bannerJson);
18707
18716
  const depositAssetsJson = useFlag(
18708
- FlagKey3.TokenTransferSourceChainsAndAssets,
18717
+ FlagKey2.TokenTransferSourceChainsAndAssets,
18709
18718
  void 0
18710
18719
  );
18711
18720
  const depositAssetsData = safeJSONParse(depositAssetsJson);
18712
18721
  const useNewConfig = useFeatureGate("new-token-transfer-config");
18713
- const { supportedAssets } = useTokenTransferConfig();
18722
+ const tokenTransferConfig = useDynamicConfig("tokentransferconfig");
18714
18723
  const getTokenTransferIcon = () => {
18715
18724
  const hasNewChain = bannerData?.isChainNew;
18716
- const allChainIds = useNewConfig && Object.keys(supportedAssets).length > 0 ? Object.keys(supportedAssets) : Object.keys(depositAssetsData ?? {});
18725
+ const tokenTransferChainIds = (tokenTransferConfig.chains ?? []).map((chain) => chain.chainId).map(String);
18726
+ const allChainIds = useNewConfig ? tokenTransferChainIds : Object.keys(depositAssetsData ?? {});
18717
18727
  const chainIds = hasNewChain ? allChainIds.filter((id) => id !== String(bannerData.chainId)) : allChainIds;
18718
18728
  return /* @__PURE__ */ React74.createElement(Box, { display: "flex", gap: "8" }, /* @__PURE__ */ React74.createElement(SupportedChainList, { chainIdList: chainIds }), hasNewChain && /* @__PURE__ */ React74.createElement(NewTokenBadge, { iconSymbol: bannerData.symbol }));
18719
18729
  };
@@ -19581,7 +19591,7 @@ var HelpAlert = ({ onHelp }) => {
19581
19591
  import { CheckoutState as CheckoutState3 } from "@funkit/api-base";
19582
19592
  import { SOLANA_MAINNET_CHAIN_ID } from "@funkit/chains";
19583
19593
  import { formatAddress as formatAddress4, formatTimestamp } from "@funkit/utils";
19584
- import React94, { useState as useState24, useRef as useRef13, useEffect as useEffect26 } from "react";
19594
+ import React94, { useState as useState24, useRef as useRef12, useEffect as useEffect26 } from "react";
19585
19595
 
19586
19596
  // src/utils/checkoutHistory.ts
19587
19597
  var storageKey4 = "fkc-last-report-submit-time";
@@ -19795,7 +19805,7 @@ function OrderDetail({
19795
19805
  }) {
19796
19806
  const { t } = useFunkitTranslation();
19797
19807
  const [isExpanded, setIsExpanded] = useState24(false);
19798
- const contentRef = useRef13(null);
19808
+ const contentRef = useRef12(null);
19799
19809
  const isCheckoutItemLoaded = checkoutHistoryItem !== void 0;
19800
19810
  return /* @__PURE__ */ React94.createElement(Box, { ref: contentRef, paddingX: "12" }, /* @__PURE__ */ React94.createElement(
19801
19811
  Box,
@@ -19933,7 +19943,7 @@ function FunDirectExecutionHistoryDetail({
19933
19943
  ]
19934
19944
  );
19935
19945
  const isWithdrawal = directExecution?.clientMetadata?.isWithdrawal;
19936
- const buttonProps = useMemo25(() => {
19946
+ const buttonProps = useMemo24(() => {
19937
19947
  if (!directExecution) {
19938
19948
  return void 0;
19939
19949
  }
@@ -20129,7 +20139,7 @@ function DirectExecutionOrderDetail({
20129
20139
  }) {
20130
20140
  const { t } = useFunkitTranslation();
20131
20141
  const [isExpanded, setIsExpanded] = useState25(false);
20132
- const contentRef = useRef14(null);
20142
+ const contentRef = useRef13(null);
20133
20143
  return /* @__PURE__ */ React96.createElement(Box, { ref: contentRef, paddingX: "12" }, /* @__PURE__ */ React96.createElement(
20134
20144
  Box,
20135
20145
  {
@@ -20291,7 +20301,7 @@ var PendingSuccessScreen = ({
20291
20301
  hideYouReceive
20292
20302
  }) => {
20293
20303
  const [startTime] = useState26(() => Date.now());
20294
- const filterFunc = useMemo26(() => {
20304
+ const filterFunc = useMemo25(() => {
20295
20305
  return (execution) => execution.createdTimeMs > startTime && !!isWithdrawal === isWithdrawalDirectExecution(execution);
20296
20306
  }, [startTime, isWithdrawal]);
20297
20307
  const { data: directExecutions } = useRecentDeposits({
@@ -20315,7 +20325,7 @@ var PendingSuccessScreen = ({
20315
20325
  );
20316
20326
  }
20317
20327
  }, [directExecution, checkoutItem, setCheckoutProgress, quote, isWithdrawal]);
20318
- const latestDirectExecution = useMemo26(() => {
20328
+ const latestDirectExecution = useMemo25(() => {
20319
20329
  const de = directExecutions?.[0];
20320
20330
  if (!de) {
20321
20331
  return void 0;
@@ -20424,7 +20434,7 @@ var WithdrawalCallbackSuccess = ({
20424
20434
  quote
20425
20435
  }) => {
20426
20436
  const { t } = useFunkitTranslation();
20427
- const customTextConfigSteps = useMemo27(() => {
20437
+ const customTextConfigSteps = useMemo26(() => {
20428
20438
  return {
20429
20439
  ...getDefaultTextConfigSteps(t),
20430
20440
  1: ({ textCustomizations }) => ({
@@ -20454,14 +20464,14 @@ import {
20454
20464
  solanaChain as solanaChain5
20455
20465
  } from "@funkit/chains";
20456
20466
  import {
20457
- FlagKey as FlagKey7,
20467
+ FlagKey as FlagKey6,
20458
20468
  formatCryptoAndStringify as formatCryptoAndStringify2,
20459
20469
  formatCurrencyAndStringify as formatCurrencyAndStringify4
20460
20470
  } from "@funkit/utils";
20461
20471
  import React120, {
20462
20472
  useEffect as useEffect35,
20463
20473
  useMemo as useMemo32,
20464
- useRef as useRef19,
20474
+ useRef as useRef18,
20465
20475
  useState as useState36
20466
20476
  } from "react";
20467
20477
  import { createPortal as createPortal3 } from "react-dom";
@@ -20472,12 +20482,12 @@ import { useDebounce } from "use-debounce";
20472
20482
  import React110 from "react";
20473
20483
 
20474
20484
  // src/components/Dropdown/ChainDropdown.tsx
20475
- import React108, { useMemo as useMemo29 } from "react";
20485
+ import React108, { useMemo as useMemo28 } from "react";
20476
20486
 
20477
20487
  // src/components/Dropdown/BaseDropdown.tsx
20478
20488
  import { isMobile as isMobile4 } from "@funkit/utils";
20479
20489
  import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
20480
- import React106, { useCallback as useCallback23, useEffect as useEffect29, useMemo as useMemo28, useRef as useRef15, useState as useState28 } from "react";
20490
+ import React106, { useCallback as useCallback23, useEffect as useEffect29, useMemo as useMemo27, useRef as useRef14, useState as useState28 } from "react";
20481
20491
 
20482
20492
  // src/components/FunInput/FunInput.tsx
20483
20493
  import React100, {
@@ -21153,7 +21163,7 @@ function BaseDropdown({
21153
21163
  const [isOpened, setIsOpened] = useState28(false);
21154
21164
  const [searchInput, setSearchInput] = useState28("");
21155
21165
  const { ref: scrollRef, hasTopDivider, isAtBottom } = useScrollDivider();
21156
- const allOptions = useMemo28(() => {
21166
+ const allOptions = useMemo27(() => {
21157
21167
  if (allowUnselect) {
21158
21168
  return [
21159
21169
  {
@@ -21166,18 +21176,18 @@ function BaseDropdown({
21166
21176
  return options;
21167
21177
  }, [options, allowUnselect, unselectLabel]);
21168
21178
  const selectedOption = allOptions.find((option) => option.value === value);
21169
- const prevIsOpenedRef = useRef15(false);
21170
- const portalThemeRef = useRef15(null);
21179
+ const prevIsOpenedRef = useRef14(false);
21180
+ const portalThemeRef = useRef14(null);
21171
21181
  const handleSearch = (event) => {
21172
21182
  setSearchInput(event.target.value);
21173
21183
  };
21174
- const filteredOptions = useMemo28(() => {
21184
+ const filteredOptions = useMemo27(() => {
21175
21185
  const search = searchInput?.trim().toLowerCase() ?? "";
21176
21186
  return allOptions.filter(
21177
21187
  (option) => option.label.toLowerCase().includes(search)
21178
21188
  );
21179
21189
  }, [allOptions, searchInput]);
21180
- const { organizedGroups, organizedOptions } = useMemo28(() => {
21190
+ const { organizedGroups, organizedOptions } = useMemo27(() => {
21181
21191
  const organizedGroups2 = /* @__PURE__ */ new Map();
21182
21192
  if (!groups) {
21183
21193
  organizedGroups2.set(OTHERS_GROUP_KEY, {
@@ -21526,19 +21536,18 @@ var ChainDropdown = ({
21526
21536
  alwaysOpenToTop,
21527
21537
  maxDropdownHeight,
21528
21538
  tagComponent,
21529
- testId,
21530
- defaultChainId
21539
+ testId
21531
21540
  }) => {
21532
21541
  const { t } = useFunkitTranslation();
21533
21542
  const chainGroups = useDynamicConfig("tokentransferchaingroups");
21534
- const chainIds = useMemo29(() => {
21543
+ const chainIds = useMemo28(() => {
21535
21544
  const availableChainIds = new Set(Object.keys(assets).map(Number));
21536
- const priorityIds = [defaultChainId, ...chainIdSortOrder ?? []].filter(
21537
- (id) => id != null && availableChainIds.has(id)
21545
+ const priorityIds = (chainIdSortOrder ?? []).filter(
21546
+ (id) => availableChainIds.has(id)
21538
21547
  );
21539
21548
  return [.../* @__PURE__ */ new Set([...priorityIds, ...availableChainIds])];
21540
- }, [assets, chainIdSortOrder, defaultChainId]);
21541
- const options = useMemo29(() => {
21549
+ }, [assets, chainIdSortOrder]);
21550
+ const options = useMemo28(() => {
21542
21551
  const popular = new Set(chainGroups.popular);
21543
21552
  const options2 = chainIds.map(
21544
21553
  (chainId) => ({
@@ -21549,7 +21558,7 @@ var ChainDropdown = ({
21549
21558
  );
21550
21559
  return options2;
21551
21560
  }, [chainGroups, chainIds]);
21552
- const groups = useMemo29(() => {
21561
+ const groups = useMemo28(() => {
21553
21562
  return [
21554
21563
  {
21555
21564
  key: "popular",
@@ -21663,8 +21672,8 @@ var ChainDropdown = ({
21663
21672
  var hideOnXsmallScreenSize = "_6yd4t20";
21664
21673
 
21665
21674
  // src/components/Dropdown/TokenDropdown.tsx
21666
- import { FlagKey as FlagKey4 } from "@funkit/utils";
21667
- import React109, { useMemo as useMemo30, useState as useState29 } from "react";
21675
+ import { FlagKey as FlagKey3 } from "@funkit/utils";
21676
+ import React109, { useMemo as useMemo29, useState as useState29 } from "react";
21668
21677
 
21669
21678
  // src/utils/tokenIconUrl.ts
21670
21679
  var getLocalTokenIconUrl = (symbol) => {
@@ -21686,9 +21695,9 @@ var getTokenIconUrl = (symbol, tokens) => {
21686
21695
  // src/components/Dropdown/TokenDropdown.tsx
21687
21696
  var TOKEN_ICON_SIZE = 16;
21688
21697
  var useNewTokens = () => {
21689
- const bannerJson = useFlag(FlagKey4.NewTokenAssetSelectionBanner);
21698
+ const bannerJson = useFlag(FlagKey3.NewTokenAssetSelectionBanner);
21690
21699
  const bannerData = useSafeJSONParse(bannerJson);
21691
- const newBadgeTokensJson = useFlag(FlagKey4.TokenTransferNewTokens, void 0);
21700
+ const newBadgeTokensJson = useFlag(FlagKey3.TokenTransferNewTokens, void 0);
21692
21701
  const newBadgeData = useSafeJSONParse(newBadgeTokensJson);
21693
21702
  const newTokens = newBadgeData && Object.values(newBadgeData).flat();
21694
21703
  const newUniqueTokens = new Set(newTokens);
@@ -21713,7 +21722,7 @@ var TokenDropdown = ({
21713
21722
  const defaultToken = selectedToken ?? enabledTokens?.[0] ?? "";
21714
21723
  const [isTouched, setIsTouched] = useState29(false);
21715
21724
  const [selectedSymbol, setSelectedSymbol] = useState29(defaultToken);
21716
- const allTokens = useMemo30(() => {
21725
+ const allTokens = useMemo29(() => {
21717
21726
  const tokens = [...new Set(Object.values(assets).flat())];
21718
21727
  const sortedTokens = tokens.sort((a, b) => a.localeCompare(b));
21719
21728
  const validPriority = priorityTokenSymbols.filter(
@@ -21725,7 +21734,7 @@ var TokenDropdown = ({
21725
21734
  return sortedTokens;
21726
21735
  }, [assets, priorityTokenSymbols]);
21727
21736
  const { newTokens, newSymbol } = useNewTokens();
21728
- const options = useMemo30(() => {
21737
+ const options = useMemo29(() => {
21729
21738
  const popular = new Set(tokenGroups.popular);
21730
21739
  const stablecoins = new Set(tokenGroups.stablecoins);
21731
21740
  const options2 = allTokens.map((symbol) => ({
@@ -21735,7 +21744,7 @@ var TokenDropdown = ({
21735
21744
  }));
21736
21745
  return options2;
21737
21746
  }, [tokenGroups, allTokens]);
21738
- const groups = useMemo30(() => {
21747
+ const groups = useMemo29(() => {
21739
21748
  return [
21740
21749
  {
21741
21750
  key: "popular",
@@ -21843,8 +21852,7 @@ var TokenAndChainDropdown = ({
21843
21852
  chainTagComponent,
21844
21853
  hideNewTokenBadge,
21845
21854
  priorityTokenSymbols,
21846
- chainIdSortOrder,
21847
- defaultChainId
21855
+ chainIdSortOrder
21848
21856
  }) => {
21849
21857
  const { t } = useFunkitTranslation();
21850
21858
  const { apiKey } = useFunkitConfig();
@@ -21929,7 +21937,6 @@ var TokenAndChainDropdown = ({
21929
21937
  tagComponent: chainTagComponent,
21930
21938
  openDropdownFullWidth: openChainDropdownFullWidth,
21931
21939
  chainIdSortOrder,
21932
- defaultChainId,
21933
21940
  testId: "chain-selector-dropdown"
21934
21941
  }
21935
21942
  ))
@@ -21943,9 +21950,9 @@ import React113 from "react";
21943
21950
  import React112, { useState as useState30 } from "react";
21944
21951
 
21945
21952
  // src/hooks/useInterval.ts
21946
- import { useEffect as useEffect30, useRef as useRef16 } from "react";
21953
+ import { useEffect as useEffect30, useRef as useRef15 } from "react";
21947
21954
  function useInterval(callback, delay) {
21948
- const savedCallback = useRef16(callback);
21955
+ const savedCallback = useRef15(callback);
21949
21956
  useIsomorphicLayoutEffect(() => {
21950
21957
  savedCallback.current = callback;
21951
21958
  }, [callback]);
@@ -22252,10 +22259,10 @@ import {
22252
22259
  formatPercent,
22253
22260
  noop as noop3
22254
22261
  } from "@funkit/utils";
22255
- import React118, { useEffect as useEffect31, useMemo as useMemo31, useState as useState31 } from "react";
22262
+ import React118, { useEffect as useEffect31, useMemo as useMemo30, useState as useState31 } from "react";
22256
22263
  import clsx15 from "clsx";
22257
22264
  import { motion as motion7, useAnimationControls } from "motion/react";
22258
- import { mainnet as mainnet6 } from "viem/chains";
22265
+ import { mainnet as mainnet5 } from "viem/chains";
22259
22266
 
22260
22267
  // src/domains/relay.ts
22261
22268
  function extractRelayFeeInfo(quoteV2) {
@@ -22498,7 +22505,7 @@ function computeDigest(relayQuoteMetadata, uiCustomizations, totalPriceImpactPer
22498
22505
  value: void 0
22499
22506
  };
22500
22507
  }
22501
- const isMainnet = details?.currencyIn?.currency?.chainId === mainnet6.id || details?.currencyOut?.currency?.chainId === mainnet6.id;
22508
+ const isMainnet = details?.currencyIn?.currency?.chainId === mainnet5.id || details?.currencyOut?.currency?.chainId === mainnet5.id;
22502
22509
  const percent = totalPriceImpactPercent < 0 ? "< 0.01%" : formatPercent(totalPriceImpactPercent);
22503
22510
  return {
22504
22511
  isMainnet,
@@ -22830,7 +22837,7 @@ function PaymentFeesSummary({
22830
22837
  setIsExpanded(false);
22831
22838
  }
22832
22839
  }, [valuesNotAvailable, isExpanded]);
22833
- const { collapsed: collapsedItem, expanded: expandedItems } = useMemo31(() => {
22840
+ const { collapsed: collapsedItem, expanded: expandedItems } = useMemo30(() => {
22834
22841
  const fees = quote?.finalFeesBreakdown ?? fallbackFees;
22835
22842
  if (!fees) {
22836
22843
  return NO_DATA;
@@ -22982,14 +22989,14 @@ function FeeLineItem({
22982
22989
 
22983
22990
  // src/hooks/queries/useWithdrawalQuote.ts
22984
22991
  import { isTokenEquivalent as isTokenEquivalent2 } from "@funkit/utils";
22985
- import { useQuery as useQuery13 } from "@tanstack/react-query";
22992
+ import { useQuery as useQuery12 } from "@tanstack/react-query";
22986
22993
 
22987
22994
  // src/hooks/useIsBlacklistedWithdrawalAddress.ts
22988
- import { isTokenAddressEquivalent as isTokenAddressEquivalent2 } from "@funkit/utils";
22995
+ import { isTokenAddressEquivalent } from "@funkit/utils";
22989
22996
  function useIsBlacklistedWithdrawalAddress(address) {
22990
22997
  const addressBlacklist = useDynamicConfig("blacklistedwithdrawaladdress");
22991
22998
  return Object.keys(addressBlacklist).some(
22992
- (blacklistedAddress) => isTokenAddressEquivalent2({
22999
+ (blacklistedAddress) => isTokenAddressEquivalent({
22993
23000
  firstTokenAddress: blacklistedAddress,
22994
23001
  secondTokenAddress: address
22995
23002
  })
@@ -23035,7 +23042,7 @@ function useWithdrawalQuote({
23035
23042
  secondTokenAddress: selectedTokenAddress
23036
23043
  });
23037
23044
  const { logEvent } = useTrack();
23038
- const query = useQuery13({
23045
+ const query = useQuery12({
23039
23046
  queryKey: [
23040
23047
  "withdrawal",
23041
23048
  "quote",
@@ -23116,12 +23123,12 @@ function useWithdrawalQuote({
23116
23123
  }
23117
23124
 
23118
23125
  // src/hooks/queries/useWithdrawalRisk.ts
23119
- import { useQuery as useQuery14 } from "@tanstack/react-query";
23120
- import { useEffect as useEffect32, useRef as useRef17 } from "react";
23126
+ import { useQuery as useQuery13 } from "@tanstack/react-query";
23127
+ import { useEffect as useEffect32, useRef as useRef16 } from "react";
23121
23128
  import { isAddress as isAddress2 } from "viem";
23122
23129
  var useWithdrawalRisk = (apiKey, receiveAddress) => {
23123
- const lastRiskyAddressRef = useRef17(null);
23124
- const query = useQuery14({
23130
+ const lastRiskyAddressRef = useRef16(null);
23131
+ const query = useQuery13({
23125
23132
  queryKey: ["withdrawal", "addressRisk", apiKey, receiveAddress],
23126
23133
  queryFn: async () => {
23127
23134
  try {
@@ -23160,17 +23167,17 @@ import {
23160
23167
  convertFunToRelayTokenAddress,
23161
23168
  getRelayAssetPriceInfo
23162
23169
  } from "@funkit/fun-relay";
23163
- import { skipToken, useQuery as useQuery16 } from "@tanstack/react-query";
23170
+ import { skipToken, useQuery as useQuery15 } from "@tanstack/react-query";
23164
23171
 
23165
23172
  // src/hooks/queries/useErc20Asset.ts
23166
23173
  import { getAssetErc20ByChainAndSymbol } from "@funkit/api-base";
23167
- import { useQuery as useQuery15 } from "@tanstack/react-query";
23174
+ import { useQuery as useQuery14 } from "@tanstack/react-query";
23168
23175
  var useErc20Asset = ({
23169
23176
  chainId,
23170
23177
  symbol
23171
23178
  }) => {
23172
23179
  const { apiKey } = useFunkitConfig();
23173
- const query = useQuery15({
23180
+ const query = useQuery14({
23174
23181
  queryKey: ["erc20Asset", chainId, symbol],
23175
23182
  queryFn: async () => {
23176
23183
  if (!apiKey || !chainId || !symbol) {
@@ -23222,7 +23229,7 @@ function useAssetAddressPrice({
23222
23229
  refetchInterval = 1e4
23223
23230
  }) {
23224
23231
  const { apiKey } = useFunkitConfig();
23225
- const { data, error, isLoading } = useQuery16({
23232
+ const { data, error, isLoading } = useQuery15({
23226
23233
  queryKey: ["getAssetPriceInfo", chainId, assetTokenAddress],
23227
23234
  queryFn: chainId && assetTokenAddress ? async () => {
23228
23235
  try {
@@ -23271,28 +23278,223 @@ var useAssetSymbolPrice = ({
23271
23278
  };
23272
23279
 
23273
23280
  // src/hooks/useTokenAndChainDropdown.ts
23274
- import { FlagKey as FlagKey6 } from "@funkit/utils";
23281
+ import { FlagKey as FlagKey5 } from "@funkit/utils";
23275
23282
  import { useEffect as useEffect33, useState as useState32 } from "react";
23276
23283
  import { polygon as polygon6 } from "viem/chains";
23277
23284
 
23278
23285
  // src/hooks/useEnabledTokenTransferChainTokens.ts
23279
23286
  import { bitcoinChain as bitcoinChain4, solanaChain as solanaChain4, tronChain as tronChain3 } from "@funkit/chains";
23280
- import { FlagKey as FlagKey5 } from "@funkit/utils";
23287
+ import { FlagKey as FlagKey4 } from "@funkit/utils";
23288
+
23289
+ // src/hooks/useTokenTransferConfig.ts
23290
+ import { useMemo as useMemo31 } from "react";
23291
+ import { polygon as polygon5 } from "viem/chains";
23292
+
23293
+ // src/hooks/useSupportedAssets.ts
23294
+ import {
23295
+ getSupportedAssets
23296
+ } from "@funkit/api-base";
23297
+ import { useQuery as useQuery16 } from "@tanstack/react-query";
23298
+ function useSupportedAssets(options) {
23299
+ const { apiKey } = useFunkitConfig();
23300
+ return useQuery16({
23301
+ queryKey: ["getSupportedAssets", apiKey],
23302
+ queryFn: () => getSupportedAssets({ apiKey, logger }),
23303
+ refetchOnMount: false,
23304
+ refetchOnReconnect: false,
23305
+ refetchOnWindowFocus: false,
23306
+ staleTime: 5 * 60 * 1e3,
23307
+ gcTime: Number.POSITIVE_INFINITY,
23308
+ enabled: !!apiKey && (options?.enabled ?? true)
23309
+ });
23310
+ }
23311
+
23312
+ // src/utils/tokenTransfer/disabledList.ts
23313
+ import { isTokenAddressEquivalent as isTokenAddressEquivalent2 } from "@funkit/utils";
23314
+ function isChainDisabled(disabledConfig, chainId) {
23315
+ if (!disabledConfig) {
23316
+ return false;
23317
+ }
23318
+ const disabledTokens = disabledConfig[String(chainId)];
23319
+ if (!disabledTokens) {
23320
+ return false;
23321
+ }
23322
+ return disabledTokens.includes("*");
23323
+ }
23324
+ function isAssetDisabled(disabledConfig, chainId, tokenAddress) {
23325
+ if (!disabledConfig) {
23326
+ return false;
23327
+ }
23328
+ const disabledTokens = disabledConfig[String(chainId)];
23329
+ if (!disabledTokens) {
23330
+ return false;
23331
+ }
23332
+ if (disabledTokens.includes("*")) {
23333
+ return true;
23334
+ }
23335
+ return disabledTokens.some(
23336
+ (disabledTokenAddress) => isTokenAddressEquivalent2({
23337
+ firstTokenAddress: disabledTokenAddress,
23338
+ secondTokenAddress: tokenAddress
23339
+ })
23340
+ );
23341
+ }
23342
+
23343
+ // src/hooks/useTokenTransferConfig.ts
23344
+ var SYMBOL_OVERRIDES = {
23345
+ "USD\u20AE0": "USDT",
23346
+ USDT0: "USDT"
23347
+ };
23348
+ var POLYGON_NATIVE_TOKEN_ALIAS = "MATIC";
23349
+ function lowercaseAddressKeys(response) {
23350
+ return Object.fromEntries(
23351
+ Object.entries(response).map(([chainId, chainAssets]) => [
23352
+ chainId,
23353
+ Object.fromEntries(
23354
+ Object.entries(chainAssets).map(([address, metadata]) => [
23355
+ address.toLowerCase(),
23356
+ metadata
23357
+ ])
23358
+ )
23359
+ ])
23360
+ );
23361
+ }
23362
+ function resolveSymbols(backendSymbol, chainId, address) {
23363
+ const displaySymbol = SYMBOL_OVERRIDES[backendSymbol] ?? backendSymbol;
23364
+ const alias = chainId === polygon5.id && isNativeTokenAddress(address) ? POLYGON_NATIVE_TOKEN_ALIAS : void 0;
23365
+ return { displaySymbol, alias };
23366
+ }
23367
+ function resolveChainAssets(chainConfig, chainAssets, disabledChainAssets) {
23368
+ const { chainId } = chainConfig;
23369
+ const resolvedChainAssets = chainConfig.assets.filter(
23370
+ (configAsset) => !isAssetDisabled(
23371
+ disabledChainAssets,
23372
+ chainId,
23373
+ configAsset.address.toLowerCase()
23374
+ )
23375
+ ).map((configAsset) => {
23376
+ const address = configAsset.address.toLowerCase();
23377
+ const metadata = chainAssets?.[address];
23378
+ if (!metadata) {
23379
+ logger.warn("useTokenTransferConfig:tokenMetadataMissing", {
23380
+ chainId,
23381
+ address: configAsset.address
23382
+ });
23383
+ return null;
23384
+ }
23385
+ const { displaySymbol, alias } = resolveSymbols(
23386
+ metadata.symbol,
23387
+ chainId,
23388
+ address
23389
+ );
23390
+ return {
23391
+ address,
23392
+ metadata: { ...metadata, symbol: displaySymbol },
23393
+ alias
23394
+ };
23395
+ }).filter((item) => item !== null);
23396
+ const assets = Object.fromEntries(
23397
+ resolvedChainAssets.map(({ address, metadata }) => [address, metadata])
23398
+ );
23399
+ const symbols = [
23400
+ ...new Set(
23401
+ resolvedChainAssets.flatMap(
23402
+ ({ metadata, alias }) => alias ? [metadata.symbol, alias] : [metadata.symbol]
23403
+ )
23404
+ )
23405
+ ];
23406
+ return { assets, symbols };
23407
+ }
23408
+ function resolveTokenTransferConfig(chainConfigs, rawPriorityTokens, disabledChainAssets, allSupportedAssets) {
23409
+ const lowercasedAssets = lowercaseAddressKeys(allSupportedAssets);
23410
+ const resolvedChains = chainConfigs.filter((c) => !isChainDisabled(disabledChainAssets, c.chainId)).map((chainConfig) => ({
23411
+ chainConfig,
23412
+ resolvedChainAssets: resolveChainAssets(
23413
+ chainConfig,
23414
+ lowercasedAssets[String(chainConfig.chainId)],
23415
+ disabledChainAssets
23416
+ )
23417
+ })).filter(({ resolvedChainAssets }) => resolvedChainAssets.symbols.length > 0);
23418
+ const supportedAssets = Object.fromEntries(
23419
+ resolvedChains.map(({ chainConfig, resolvedChainAssets }) => [
23420
+ chainConfig.chainId,
23421
+ resolvedChainAssets.assets
23422
+ ])
23423
+ );
23424
+ const symbolsByChainId = Object.fromEntries(
23425
+ resolvedChains.map(({ chainConfig, resolvedChainAssets }) => [
23426
+ chainConfig.chainId,
23427
+ resolvedChainAssets.symbols
23428
+ ])
23429
+ );
23430
+ const chainIdSortOrder = resolvedChains.map(
23431
+ ({ chainConfig }) => chainConfig.chainId
23432
+ );
23433
+ const defaultChainId = resolvedChains.find(
23434
+ ({ chainConfig }) => chainConfig.isDefault
23435
+ )?.chainConfig.chainId;
23436
+ return {
23437
+ supportedAssets,
23438
+ symbolsByChainId,
23439
+ chainIdSortOrder,
23440
+ defaultChainId,
23441
+ priorityTokenSymbols: [...rawPriorityTokens]
23442
+ };
23443
+ }
23444
+ var EMPTY_CONFIG = {
23445
+ supportedAssets: {},
23446
+ symbolsByChainId: {},
23447
+ chainIdSortOrder: [],
23448
+ defaultChainId: void 0,
23449
+ priorityTokenSymbols: []
23450
+ };
23451
+ function useTokenTransferConfig(isWithdrawal = false) {
23452
+ const tokenTransferConfig = useDynamicConfig("tokentransferconfig");
23453
+ const tokenTransferDisabled = useDynamicConfig(
23454
+ "disabletokentransferchainsandassets"
23455
+ );
23456
+ const withdrawalConfig = useDynamicConfig("withdrawalconfig");
23457
+ const withdrawalDisabled = useDynamicConfig(
23458
+ "disablewithdrawalchainsandassets"
23459
+ );
23460
+ const rawConfig = isWithdrawal ? withdrawalConfig : tokenTransferConfig;
23461
+ const disabledChainAssets = isWithdrawal ? withdrawalDisabled : tokenTransferDisabled;
23462
+ const { data: allSupportedAssets, isLoading } = useSupportedAssets();
23463
+ const config = useMemo31(() => {
23464
+ if (!allSupportedAssets) {
23465
+ return EMPTY_CONFIG;
23466
+ }
23467
+ const { chains: rawChains, priorityTokens: rawPriorityTokens } = rawConfig;
23468
+ return resolveTokenTransferConfig(
23469
+ rawChains ?? [],
23470
+ rawPriorityTokens ?? [],
23471
+ disabledChainAssets,
23472
+ allSupportedAssets
23473
+ );
23474
+ }, [rawConfig, disabledChainAssets, allSupportedAssets]);
23475
+ return { ...config, isLoading };
23476
+ }
23477
+
23478
+ // src/hooks/useEnabledTokenTransferChainTokens.ts
23281
23479
  function useEnabledTokenTransferChainTokens(transferInit, isWithdrawal) {
23282
- const { symbolsByChainId, isLoading } = useTokenTransferConfig();
23480
+ const { symbolsByChainId, isLoading } = useTokenTransferConfig(isWithdrawal);
23283
23481
  const legacyDepositAssets = useFlag(
23284
- FlagKey5.TokenTransferSourceChainsAndAssets
23482
+ FlagKey4.TokenTransferSourceChainsAndAssets
23285
23483
  );
23286
23484
  const parsedLegacyDeposit = safeJSONParse(legacyDepositAssets);
23287
- const legacyWithdrawalAssets = useFlag(FlagKey5.WithdrawalChainsAndAssets);
23485
+ const legacyWithdrawalAssets = useFlag(FlagKey4.WithdrawalChainsAndAssets);
23288
23486
  const parsedLegacyWithdrawal = safeJSONParse(legacyWithdrawalAssets);
23289
- const useNewConfig = useFeatureGate("new-token-transfer-config");
23487
+ const useNewTokenTransferConfig = useFeatureGate("new-token-transfer-config");
23488
+ const useNewWithdrawalConfig = useFeatureGate("new-withdrawal-config");
23290
23489
  const isNewConfigReady = !isLoading && Object.keys(symbolsByChainId).length > 0;
23291
23490
  const assets = (() => {
23292
23491
  if (isWithdrawal) {
23492
+ if (useNewWithdrawalConfig && isNewConfigReady) {
23493
+ return symbolsByChainId;
23494
+ }
23293
23495
  return parsedLegacyWithdrawal ?? {};
23294
23496
  }
23295
- if (useNewConfig && isNewConfigReady) {
23497
+ if (useNewTokenTransferConfig && isNewConfigReady) {
23296
23498
  return symbolsByChainId;
23297
23499
  }
23298
23500
  return parsedLegacyDeposit ?? {};
@@ -23344,17 +23546,23 @@ function findChainForToken(enabledChainSymbols, token, fallbackChainId) {
23344
23546
  );
23345
23547
  return matchingChainId ? Number(matchingChainId) : fallbackChainId;
23346
23548
  }
23347
- function compareLegacyAndNewConfig(legacyConfig, newConfig) {
23549
+ function compareLegacyAndNewConfig(legacyConfig, newConfig, configType = "deposit") {
23348
23550
  const legacyChains = new Set(Object.keys(legacyConfig).map(Number));
23349
23551
  const newChains = new Set(Object.keys(newConfig).map(Number));
23350
23552
  for (const chainId of legacyChains) {
23351
23553
  if (!newChains.has(chainId)) {
23352
- logger.warn("tokenTransferConfig:chainMissingInNewConfig", { chainId });
23554
+ logger.warn("tokenTransferConfig:chainMissingInNewConfig", {
23555
+ chainId,
23556
+ configType
23557
+ });
23353
23558
  }
23354
23559
  }
23355
23560
  for (const chainId of newChains) {
23356
23561
  if (!legacyChains.has(chainId)) {
23357
- logger.warn("tokenTransferConfig:extraChainInNewConfig", { chainId });
23562
+ logger.warn("tokenTransferConfig:extraChainInNewConfig", {
23563
+ chainId,
23564
+ configType
23565
+ });
23358
23566
  }
23359
23567
  }
23360
23568
  for (const chainId of legacyChains) {
@@ -23365,7 +23573,7 @@ function compareLegacyAndNewConfig(legacyConfig, newConfig) {
23365
23573
  const missing = legacySymbols.filter((s) => !newSet.has(s.toLowerCase()));
23366
23574
  const extra = newSymbols.filter((s) => !legacySet.has(s.toLowerCase()));
23367
23575
  if (missing.length > 0 || extra.length > 0) {
23368
- const data = { chainId, missing, extra };
23576
+ const data = { chainId, configType, missing, extra };
23369
23577
  logger.warn("tokenTransferConfig:symbolMismatch", data);
23370
23578
  }
23371
23579
  if (missing.length === 0 && extra.length === 0) {
@@ -23374,6 +23582,7 @@ function compareLegacyAndNewConfig(legacyConfig, newConfig) {
23374
23582
  if (JSON.stringify(legacyOrder) !== JSON.stringify(newOrder)) {
23375
23583
  const data = {
23376
23584
  chainId,
23585
+ configType,
23377
23586
  legacyOrder: legacySymbols,
23378
23587
  newOrder: newSymbols
23379
23588
  };
@@ -23383,34 +23592,57 @@ function compareLegacyAndNewConfig(legacyConfig, newConfig) {
23383
23592
  }
23384
23593
  }
23385
23594
  var useTokenAndChainDropdown = (transferInit, defaultValues, isWithdrawal) => {
23386
- const useNewConfig = useFeatureGate("new-token-transfer-config");
23595
+ const useNewTokenTransferConfig = useFeatureGate("new-token-transfer-config");
23596
+ const useNewWithdrawalConfig = useFeatureGate("new-withdrawal-config");
23387
23597
  const enabledChainSymbols = useEnabledTokenTransferChainTokens(
23388
23598
  transferInit ?? null,
23389
23599
  isWithdrawal
23390
23600
  );
23391
- const newConfig = useTokenTransferConfig();
23601
+ const newConfig = useTokenTransferConfig(isWithdrawal);
23392
23602
  const isNewConfigReady = !newConfig.isLoading && Object.keys(newConfig.symbolsByChainId).length > 0;
23393
- const isGatedDeposit = useNewConfig && !isWithdrawal;
23394
- const useNewConfigActive = isGatedDeposit && isNewConfigReady;
23395
- const isLoadingAssets = isGatedDeposit && !isNewConfigReady;
23396
- const legacyDefaultChainIdJson = useFlag(FlagKey6.TokenTransferDefaultChainId);
23397
- const legacyChainSortOrderJson = useFlag(FlagKey6.ChainIdSortOrder);
23398
- const legacyDefaultTokensJson = useFlag(FlagKey6.TokenTransferDefaultTokens);
23603
+ const isGated = isWithdrawal ? useNewWithdrawalConfig : useNewTokenTransferConfig;
23604
+ const useNewConfigActive = isGated && isNewConfigReady;
23605
+ const isLoadingAssets = isGated && !isNewConfigReady;
23606
+ const legacyDefaultChainIdJson = useFlag(FlagKey5.TokenTransferDefaultChainId);
23607
+ const legacyChainSortOrderJson = useFlag(FlagKey5.ChainIdSortOrder);
23608
+ const legacyDefaultTokensJson = useFlag(FlagKey5.TokenTransferDefaultTokens);
23399
23609
  const legacyChainIdSortOrder = (safeJSONParse(legacyChainSortOrderJson) ?? []).map(Number);
23400
23610
  const legacyPriorityTokenSymbols = safeJSONParse(legacyDefaultTokensJson) ?? [];
23401
23611
  const legacyDefaultChainId = Number(safeJSONParse(legacyDefaultChainIdJson)) || polygon6.id;
23402
23612
  const legacyDepositAssetsJson = useFlag(
23403
- FlagKey6.TokenTransferSourceChainsAndAssets
23613
+ FlagKey5.TokenTransferSourceChainsAndAssets
23404
23614
  );
23405
- const legacyDepositAssets = safeJSONParse(
23615
+ const legacyDepositAssets = useSafeJSONParse(
23406
23616
  legacyDepositAssetsJson
23407
23617
  );
23618
+ const legacyWithdrawalAssetsJson = useFlag(FlagKey5.WithdrawalChainsAndAssets);
23619
+ const legacyWithdrawalAssets = useSafeJSONParse(
23620
+ legacyWithdrawalAssetsJson
23621
+ );
23408
23622
  useEffect33(() => {
23409
- if (!isNewConfigReady || !legacyDepositAssets) {
23623
+ if (!isNewConfigReady) {
23410
23624
  return;
23411
23625
  }
23412
- compareLegacyAndNewConfig(legacyDepositAssets, newConfig.symbolsByChainId);
23413
- }, [isNewConfigReady, legacyDepositAssets, newConfig.symbolsByChainId]);
23626
+ if (isWithdrawal && legacyWithdrawalAssets) {
23627
+ compareLegacyAndNewConfig(
23628
+ legacyWithdrawalAssets,
23629
+ newConfig.symbolsByChainId,
23630
+ "withdrawal"
23631
+ );
23632
+ } else if (!isWithdrawal && legacyDepositAssets) {
23633
+ compareLegacyAndNewConfig(
23634
+ legacyDepositAssets,
23635
+ newConfig.symbolsByChainId,
23636
+ "deposit"
23637
+ );
23638
+ }
23639
+ }, [
23640
+ isNewConfigReady,
23641
+ isWithdrawal,
23642
+ legacyDepositAssets,
23643
+ legacyWithdrawalAssets,
23644
+ newConfig.symbolsByChainId
23645
+ ]);
23414
23646
  const activeDefaultChainId = useNewConfigActive ? newConfig.defaultChainId ?? polygon6.id : legacyDefaultChainId;
23415
23647
  const activeChainIdSortOrder = useNewConfigActive ? newConfig.chainIdSortOrder : legacyChainIdSortOrder;
23416
23648
  const activePriorityTokens = useNewConfigActive ? newConfig.priorityTokenSymbols : legacyPriorityTokenSymbols;
@@ -23421,9 +23653,9 @@ var useTokenAndChainDropdown = (transferInit, defaultValues, isWithdrawal) => {
23421
23653
  );
23422
23654
  const [selectedChainId, setSelectedChainId] = useState32(validDefaultChainId);
23423
23655
  const selectedChainName = chainMetadataById[selectedChainId]?.name ?? "";
23424
- const currentChainSymbols = enabledChainSymbols?.[selectedChainId];
23656
+ const defaultChainSymbols = enabledChainSymbols?.[validDefaultChainId];
23425
23657
  const defaultSelectedToken = resolveDefaultToken(
23426
- currentChainSymbols,
23658
+ defaultChainSymbols,
23427
23659
  defaultValues?.token
23428
23660
  );
23429
23661
  const [selectedToken, setSelectedToken] = useState32(defaultSelectedToken);
@@ -23431,11 +23663,10 @@ var useTokenAndChainDropdown = (transferInit, defaultValues, isWithdrawal) => {
23431
23663
  () => setSelectedChainId(validDefaultChainId),
23432
23664
  [validDefaultChainId]
23433
23665
  );
23434
- useEffect33(() => {
23435
- if (defaultSelectedToken && !currentChainSymbols?.includes(selectedToken)) {
23436
- setSelectedToken(defaultSelectedToken);
23437
- }
23438
- }, [defaultSelectedToken, currentChainSymbols]);
23666
+ useEffect33(
23667
+ () => setSelectedToken(defaultSelectedToken),
23668
+ [defaultSelectedToken]
23669
+ );
23439
23670
  const handleTokenChange = (token, chainId, autoUpdate) => {
23440
23671
  setSelectedToken(token);
23441
23672
  if (chainId !== void 0 && chainId !== selectedChainId) {
@@ -23470,9 +23701,15 @@ var useTokenAndChainDropdown = (transferInit, defaultValues, isWithdrawal) => {
23470
23701
  selectedChainName,
23471
23702
  handleTokenChange,
23472
23703
  isLoadingAssets,
23473
- chainIdSortOrder: activeChainIdSortOrder,
23474
- priorityTokenSymbols: activePriorityTokens,
23475
- defaultChainId: activeDefaultChainId
23704
+ // Promote the default chain and token to the top of the list and dedupe
23705
+ chainIdSortOrder: [
23706
+ validDefaultChainId,
23707
+ ...activeChainIdSortOrder.filter((id) => id !== validDefaultChainId)
23708
+ ],
23709
+ priorityTokenSymbols: [
23710
+ defaultSelectedToken,
23711
+ ...activePriorityTokens.filter((token) => token !== defaultSelectedToken)
23712
+ ]
23476
23713
  };
23477
23714
  };
23478
23715
 
@@ -23480,10 +23717,10 @@ var useTokenAndChainDropdown = (transferInit, defaultValues, isWithdrawal) => {
23480
23717
  import { useState as useState35 } from "react";
23481
23718
 
23482
23719
  // src/hooks/useAutoClearState.ts
23483
- import { useCallback as useCallback24, useEffect as useEffect34, useRef as useRef18, useState as useState33 } from "react";
23720
+ import { useCallback as useCallback24, useEffect as useEffect34, useRef as useRef17, useState as useState33 } from "react";
23484
23721
  function useAutoClearState(initialValue = null) {
23485
23722
  const [state, setState] = useState33(initialValue);
23486
- const timeoutRef = useRef18(void 0);
23723
+ const timeoutRef = useRef17(void 0);
23487
23724
  useEffect34(() => {
23488
23725
  return () => {
23489
23726
  if (timeoutRef.current !== void 0) {
@@ -24014,7 +24251,7 @@ function useWithdrawalAssets(config) {
24014
24251
  handleTokenChange,
24015
24252
  chainIdSortOrder,
24016
24253
  priorityTokenSymbols,
24017
- defaultChainId
24254
+ isLoadingAssets
24018
24255
  } = useTokenAndChainDropdown(
24019
24256
  void 0,
24020
24257
  {
@@ -24023,7 +24260,7 @@ function useWithdrawalAssets(config) {
24023
24260
  },
24024
24261
  true
24025
24262
  );
24026
- const excludedTokenStr = useFlag(FlagKey7.WithdrawalExcludeTokens);
24263
+ const excludedTokenStr = useFlag(FlagKey6.WithdrawalExcludeTokens);
24027
24264
  const excludedTokens = safeJSONParse(excludedTokenStr);
24028
24265
  if (excludedTokens) {
24029
24266
  for (const chainIdStr of Object.keys(excludedTokens)) {
@@ -24046,7 +24283,7 @@ function useWithdrawalAssets(config) {
24046
24283
  handleTokenChange,
24047
24284
  chainIdSortOrder,
24048
24285
  priorityTokenSymbols,
24049
- defaultChainId
24286
+ isLoadingAssets
24050
24287
  };
24051
24288
  }
24052
24289
  function getRelayOutputCurrencyAmount(quote, fallback2) {
@@ -24196,7 +24433,7 @@ var WithdrawContent = ({
24196
24433
  selectedChainName,
24197
24434
  chainIdSortOrder,
24198
24435
  priorityTokenSymbols,
24199
- defaultChainId
24436
+ isLoadingAssets
24200
24437
  } = useWithdrawalAssets(config);
24201
24438
  const {
24202
24439
  asset: targetAssetInfo,
@@ -24326,10 +24563,10 @@ var WithdrawContent = ({
24326
24563
  recipientAddress
24327
24564
  );
24328
24565
  const isRecipientBlacklisted = useIsBlacklistedWithdrawalAddress(recipientAddress);
24329
- const lastTargetAssetErrorRef = useRef19(null);
24330
- const lastQuoteErrorRef = useRef19(null);
24331
- const lastRiskyRecipientRef = useRef19(null);
24332
- const lastBlacklistedRecipientRef = useRef19(null);
24566
+ const lastTargetAssetErrorRef = useRef18(null);
24567
+ const lastQuoteErrorRef = useRef18(null);
24568
+ const lastRiskyRecipientRef = useRef18(null);
24569
+ const lastBlacklistedRecipientRef = useRef18(null);
24333
24570
  useEffect35(() => {
24334
24571
  if (!targetAssetFetchError) {
24335
24572
  return;
@@ -24465,7 +24702,7 @@ var WithdrawContent = ({
24465
24702
  ), /* @__PURE__ */ React120.createElement(
24466
24703
  TokenAndChainDropdown,
24467
24704
  {
24468
- isLoading: false,
24705
+ isLoading: isLoadingAssets,
24469
24706
  assets,
24470
24707
  selectedToken,
24471
24708
  onTokenSelected: handleTokenChange,
@@ -24478,8 +24715,7 @@ var WithdrawContent = ({
24478
24715
  maxTokenDropdownHeight: 195,
24479
24716
  hideNewTokenBadge: true,
24480
24717
  priorityTokenSymbols,
24481
- chainIdSortOrder,
24482
- defaultChainId
24718
+ chainIdSortOrder
24483
24719
  }
24484
24720
  ), /* @__PURE__ */ React120.createElement(Box, { display: "flex", justifyContent: "space-between", alignItems: "center" }, /* @__PURE__ */ React120.createElement(
24485
24721
  Text,
@@ -24831,7 +25067,7 @@ function useFiatExchangeRates(enabled = true) {
24831
25067
  }
24832
25068
 
24833
25069
  // src/modals/CheckoutModal/SourceChange/FormOfPaymentsList.tsx
24834
- import React124, { useRef as useRef20, useState as useState37 } from "react";
25070
+ import React124, { useRef as useRef19, useState as useState37 } from "react";
24835
25071
 
24836
25072
  // src/domains/swapped.ts
24837
25073
  import { formatCurrencyAndStringify as formatCurrencyAndStringify5 } from "@funkit/utils";
@@ -25124,7 +25360,7 @@ function FormOfPaymentsContent({
25124
25360
  }) {
25125
25361
  const { t } = useFunkitTranslation();
25126
25362
  const [isExpanded, setIsExpanded] = useState37(false);
25127
- const toggleRef = useRef20(null);
25363
+ const toggleRef = useRef19(null);
25128
25364
  const { primary, secondary } = getFormOfPaymentSections(fopsData, fopPriority);
25129
25365
  const totalItems = primary.items.length + secondary.items.length;
25130
25366
  const showToggle = totalItems > defaultMaxItems;
@@ -25296,9 +25532,9 @@ import React126, { useCallback as useCallback25, useMemo as useMemo33, useState
25296
25532
  import { createPortal as createPortal4 } from "react-dom";
25297
25533
 
25298
25534
  // src/hooks/useFunListeners.ts
25299
- import { useEffect as useEffect36, useRef as useRef21 } from "react";
25535
+ import { useEffect as useEffect36, useRef as useRef20 } from "react";
25300
25536
  function useCheckoutHistoryListener(activate = true, singleDepositAddr) {
25301
- const activeIntervalRef = useRef21(void 0);
25537
+ const activeIntervalRef = useRef20(void 0);
25302
25538
  const { startCheckoutHistoryListener, stopCheckoutHistoryListener } = useCheckoutHistoryContext();
25303
25539
  useEffect36(() => {
25304
25540
  if (activate) {
@@ -25443,7 +25679,7 @@ var CheckoutAlert = ({ state, refundState, onHelp }) => {
25443
25679
 
25444
25680
  // src/components/FunCheckoutHistory/FunCheckoutHistoryHelp.tsx
25445
25681
  import { sendSupportMessage } from "@funkit/api-base";
25446
- import React130, { useEffect as useEffect37, useMemo as useMemo34, useRef as useRef22, useState as useState39 } from "react";
25682
+ import React130, { useEffect as useEffect37, useMemo as useMemo34, useRef as useRef21, useState as useState39 } from "react";
25447
25683
  import { createPortal as createPortal5 } from "react-dom";
25448
25684
 
25449
25685
  // src/components/FunInput/FunTextAreaInput.tsx
@@ -25633,7 +25869,7 @@ function FunCheckoutHistoryHelp({
25633
25869
  const [processStage, setProcessStage] = useState39(
25634
25870
  0 /* INPUT */
25635
25871
  );
25636
- const wrapperRef = useRef22(null);
25872
+ const wrapperRef = useRef21(null);
25637
25873
  useEffect37(() => wrapperRef.current?.scrollIntoView(), []);
25638
25874
  const handleShowErrorMessage = (message, timeMs = FIVE_SECONDS_MS) => {
25639
25875
  setErrorMessage(message);
@@ -26140,7 +26376,7 @@ import React235 from "react";
26140
26376
  import {
26141
26377
  useCallback as useCallback46,
26142
26378
  useEffect as useEffect56,
26143
- useRef as useRef31,
26379
+ useRef as useRef30,
26144
26380
  useState as useState69
26145
26381
  } from "react";
26146
26382
 
@@ -27688,7 +27924,7 @@ import { bluvoExecuteWithdrawal as bluvoExecuteWithdrawal2 } from "@funkit/api-b
27688
27924
  import React158, {
27689
27925
  useCallback as useCallback29,
27690
27926
  useEffect as useEffect39,
27691
- useRef as useRef23,
27927
+ useRef as useRef22,
27692
27928
  useState as useState44
27693
27929
  } from "react";
27694
27930
  var FunTwoFaInput = ({
@@ -27702,7 +27938,7 @@ var FunTwoFaInput = ({
27702
27938
  hasResent = false,
27703
27939
  onCompleted
27704
27940
  }) => {
27705
- const inputRefs = useRef23(
27941
+ const inputRefs = useRef22(
27706
27942
  Array.from({ length: initialInputLength }, () => null)
27707
27943
  );
27708
27944
  const [currentLength, setCurrentLength] = useState44(initialInputLength);
@@ -29586,14 +29822,14 @@ import { erc20Abi as erc20Abi4 } from "viem";
29586
29822
 
29587
29823
  // src/utils/isMainnetUsdt.ts
29588
29824
  import { isTokenEquivalent as isTokenEquivalent4 } from "@funkit/utils";
29589
- import { mainnet as mainnet7 } from "viem/chains";
29825
+ import { mainnet as mainnet6 } from "viem/chains";
29590
29826
  var USDT_MAINNET_ADDRESS = "0xdAC17F958D2ee523a2206206994597C13D831ec7";
29591
29827
  function isMainnetUsdt(chainId, address) {
29592
29828
  return isTokenEquivalent4({
29593
29829
  firstTokenAddress: address,
29594
29830
  firstTokenChainId: chainId.toString(),
29595
29831
  secondTokenAddress: USDT_MAINNET_ADDRESS,
29596
- secondTokenChainId: mainnet7.id.toString()
29832
+ secondTokenChainId: mainnet6.id.toString()
29597
29833
  });
29598
29834
  }
29599
29835
 
@@ -29864,7 +30100,7 @@ function usePostCheckout({
29864
30100
  }
29865
30101
 
29866
30102
  // src/modals/CheckoutModal/ConfirmationStep/useQuoteRefresh.ts
29867
- import { useCallback as useCallback36, useEffect as useEffect43, useMemo as useMemo42, useRef as useRef24, useState as useState53 } from "react";
30103
+ import { useCallback as useCallback36, useEffect as useEffect43, useMemo as useMemo42, useRef as useRef23, useState as useState53 } from "react";
29868
30104
 
29869
30105
  // src/hooks/useCountdown.tsx
29870
30106
  import React179 from "react";
@@ -30062,10 +30298,10 @@ function useQuoteRefresh({
30062
30298
  refreshIntervalSeconds
30063
30299
  }) {
30064
30300
  const { setCheckoutQuote, isQuoting, quoteErrorMessage, quoteStepMessage } = useQuoteContext();
30065
- const preloadedQuoteRef = useRef24(
30301
+ const preloadedQuoteRef = useRef23(
30066
30302
  void 0
30067
30303
  );
30068
- const quoteCallbackRef = useRef24(void 0);
30304
+ const quoteCallbackRef = useRef23(void 0);
30069
30305
  const [isPendingRefresh, setIsPendingRefresh] = useState53(false);
30070
30306
  const {
30071
30307
  isSourceAssetConfirming,
@@ -30728,11 +30964,11 @@ import React193, { useEffect as useEffect46, useMemo as useMemo45 } from "react"
30728
30964
  // src/components/AnimatedWidthWrapper/AnimatedWidthWrapper.tsx
30729
30965
  import { motion as motion9 } from "motion/react";
30730
30966
  import React181 from "react";
30731
- import { useEffect as useEffect45, useRef as useRef25, useState as useState55 } from "react";
30967
+ import { useEffect as useEffect45, useRef as useRef24, useState as useState55 } from "react";
30732
30968
  function AnimatedWidthWrapper({ children }) {
30733
- const containerRef = useRef25(null);
30734
- const animationFrameRef = useRef25(null);
30735
- const resizeObserverRef = useRef25(null);
30969
+ const containerRef = useRef24(null);
30970
+ const animationFrameRef = useRef24(null);
30971
+ const resizeObserverRef = useRef24(null);
30736
30972
  const [width, setWidth] = useState55("auto");
30737
30973
  useEffect45(() => {
30738
30974
  if (containerRef.current) {
@@ -31892,7 +32128,7 @@ import {
31892
32128
  useCallback as useCallback38,
31893
32129
  useMemo as useMemo44,
31894
32130
  useReducer as useReducer3,
31895
- useRef as useRef26,
32131
+ useRef as useRef25,
31896
32132
  useState as useState57
31897
32133
  } from "react";
31898
32134
 
@@ -32375,7 +32611,7 @@ function useAmountInput(options) {
32375
32611
  () => getDerivedState(state, checkoutConfig.targetAssetTicker),
32376
32612
  [state, checkoutConfig]
32377
32613
  );
32378
- const inputRef = useRef26(null);
32614
+ const inputRef = useRef25(null);
32379
32615
  const { inputValue, locale } = state;
32380
32616
  const { inputDecimals, inputAffix, placeholder } = derivedState;
32381
32617
  const { measureText } = useTextMeasurer(inputRef);
@@ -32851,7 +33087,7 @@ import {
32851
33087
  hyperEvmChain as hyperEvmChain4
32852
33088
  } from "@funkit/chains";
32853
33089
  import { useCallback as useCallback39, useState as useState58 } from "react";
32854
- import { mainnet as mainnet8, mantle, zksync as zksync2 } from "viem/chains";
33090
+ import { mainnet as mainnet7, mantle, zksync as zksync2 } from "viem/chains";
32855
33091
  import { getAssetErc20ByChainAndSymbol as getAssetErc20ByChainAndSymbol2 } from "@funkit/api-base";
32856
33092
  var pickSourceAssetForCard = async (checkoutItem, userIpInfo, apiKey) => {
32857
33093
  if (!checkoutItem?.initSettings.config.targetChain) {
@@ -32881,7 +33117,7 @@ var pickSourceAssetForCard = async (checkoutItem, userIpInfo, apiKey) => {
32881
33117
  sourceTokenAddress = NATIVE_TOKEN;
32882
33118
  sourceTokenChainId = moonpayChainId;
32883
33119
  } else {
32884
- sourceTokenChainId = isNyOrTxOrVi ? mainnet8.id.toString() : moonpayChainId;
33120
+ sourceTokenChainId = isNyOrTxOrVi ? mainnet7.id.toString() : moonpayChainId;
32885
33121
  if (isTargetAssetEthOrWeth) {
32886
33122
  sourceTokenTicker = "ETH" /* ETH */;
32887
33123
  sourceTokenAddress = NATIVE_TOKEN;
@@ -34993,7 +35229,7 @@ import React211, {
34993
35229
  useState as useState60
34994
35230
  } from "react";
34995
35231
  import { createPortal as createPortal17 } from "react-dom";
34996
- import { mainnet as mainnet9 } from "viem/chains";
35232
+ import { mainnet as mainnet8 } from "viem/chains";
34997
35233
 
34998
35234
  // src/hooks/useDynamicRoutes.ts
34999
35235
  import { useMemo as useMemo49 } from "react";
@@ -35028,7 +35264,7 @@ import React209 from "react";
35028
35264
  // src/components/NewTokenDepositAlert/NewTokenDepositAlert.tsx
35029
35265
  import React208 from "react";
35030
35266
  import { Trans as Trans13 } from "react-i18next";
35031
- import { FlagKey as FlagKey8 } from "@funkit/utils";
35267
+ import { FlagKey as FlagKey7 } from "@funkit/utils";
35032
35268
  var FunLinkButtonComponent2 = ({
35033
35269
  children,
35034
35270
  onClick,
@@ -35048,7 +35284,7 @@ var NewTokenDepositAlert = ({
35048
35284
  onClick
35049
35285
  }) => {
35050
35286
  const { t } = useFunkitTranslation();
35051
- const alertJson = useFlag(FlagKey8.NewTokenAssetSelectionBanner);
35287
+ const alertJson = useFlag(FlagKey7.NewTokenAssetSelectionBanner);
35052
35288
  const alertData = useSafeJSONParse(alertJson);
35053
35289
  const { enabled: isTokenTransferEnabled } = useIsQRCodeTransferEnabled();
35054
35290
  if (!alertData || !isTokenTransferEnabled) {
@@ -35243,7 +35479,7 @@ function useEnrichedAccountHoldings({
35243
35479
  const { t } = useFunkitTranslation();
35244
35480
  const { isAllowed, isLoading } = useAllowedAssets();
35245
35481
  const { walletAddress } = useGeneralWallet();
35246
- const minTransferLimits = useMinTransferLimits();
35482
+ const minTransferLimits = useDynamicConfig("mintokentransfervalue");
35247
35483
  const isDynamicRoutingEnabled = useIsDynamicRoutingEnabled();
35248
35484
  const enrichedAccountHoldings = useMemo50(() => {
35249
35485
  if (!checkoutConfig) {
@@ -35633,7 +35869,7 @@ function isTreatedAsNativeToken(apiKey, asset, dynamicTargetAssetCandidates, fin
35633
35869
  }
35634
35870
  if (isEtherealCustomer(apiKey)) {
35635
35871
  if (isTokenEquivalent6({
35636
- firstTokenChainId: mainnet9.id.toString(),
35872
+ firstTokenChainId: mainnet8.id.toString(),
35637
35873
  firstTokenAddress: "0x90d2af7d622ca3141efa4d8f1f24d86e5974cc8f",
35638
35874
  // eUSDe (Ethereum)
35639
35875
  secondTokenChainId: asset.pickedChainId,
@@ -35681,7 +35917,7 @@ import {
35681
35917
  import { LIGHTER_CHAIN_ID as LIGHTER_CHAIN_ID3 } from "@funkit/chains";
35682
35918
  import { noop as noop8 } from "@funkit/utils";
35683
35919
  import clsx20 from "clsx";
35684
- import React217, { useEffect as useEffect52, useRef as useRef28, useState as useState62 } from "react";
35920
+ import React217, { useEffect as useEffect52, useRef as useRef27, useState as useState62 } from "react";
35685
35921
  import { createPortal as createPortal18 } from "react-dom";
35686
35922
 
35687
35923
  // src/components/Dropdown/ReceiveTokenDropdown.tsx
@@ -36058,7 +36294,7 @@ import React213, {
36058
36294
  useContext as useContext18,
36059
36295
  useEffect as useEffect50,
36060
36296
  useMemo as useMemo52,
36061
- useRef as useRef27,
36297
+ useRef as useRef26,
36062
36298
  useState as useState61
36063
36299
  } from "react";
36064
36300
  var SwappedContext = createContext18(null);
@@ -36069,9 +36305,9 @@ function SwappedProvider({ children }) {
36069
36305
  const [iframeUrl, setIframeUrl] = useState61(null);
36070
36306
  const [isActive, setIsActive] = useState61(false);
36071
36307
  const [isSwappedReady, setIsSwappedReady] = useState61(false);
36072
- const iframeRef = useRef27(null);
36073
- const activeFopTypeRef = useRef27(null);
36074
- const activeCallbacksRef = useRef27(null);
36308
+ const iframeRef = useRef26(null);
36309
+ const activeFopTypeRef = useRef26(null);
36310
+ const activeCallbacksRef = useRef26(null);
36075
36311
  const swappedTheme = useMemo52(() => {
36076
36312
  const customFontFamily = uiCustomizations.customFontFamily;
36077
36313
  const theme = { ...activeTheme, customFontFamily };
@@ -36106,6 +36342,16 @@ function SwappedProvider({ children }) {
36106
36342
  logger.info("swapped-provider:sendTheme", { postMessage: msg });
36107
36343
  }
36108
36344
  );
36345
+ const focusAmountInput = useEffectEvent(() => {
36346
+ const contentWindow = iframeRef.current?.contentWindow;
36347
+ const targetOrigin = getSwappedOrigin(iframeUrl || "");
36348
+ if (!contentWindow || !targetOrigin) {
36349
+ return;
36350
+ }
36351
+ const msg = { type: "SWAPPED_FOCUS" };
36352
+ contentWindow.postMessage(msg, targetOrigin);
36353
+ logger.info("swapped-provider:focusAmountInput", { postMessage: msg });
36354
+ });
36109
36355
  const activateIframe = useCallback41(
36110
36356
  (fopType) => {
36111
36357
  setIsActive(true);
@@ -36141,11 +36387,6 @@ function SwappedProvider({ children }) {
36141
36387
  }
36142
36388
  setIsSwappedReady(true);
36143
36389
  break;
36144
- // "SWAPPED_COMPLETE" is not a real event at the moment
36145
- // consider removing this event in the future if its not supported
36146
- case "SWAPPED_COMPLETE":
36147
- activeCallbacksRef.current?.onComplete();
36148
- break;
36149
36390
  case "SWAPPED_GO_BACK":
36150
36391
  activeCallbacksRef.current?.onBack();
36151
36392
  break;
@@ -36156,7 +36397,7 @@ function SwappedProvider({ children }) {
36156
36397
  activeCallbacksRef.current?.onNewDeposit();
36157
36398
  break;
36158
36399
  case "SWAPPED_ERROR":
36159
- activeCallbacksRef.current?.onError(event.data.data || {});
36400
+ activeCallbacksRef.current?.onError(event.data.data ?? {});
36160
36401
  break;
36161
36402
  case "SWAPPED_NAVIGATION":
36162
36403
  activeCallbacksRef.current?.onNavigation(
@@ -36166,6 +36407,9 @@ function SwappedProvider({ children }) {
36166
36407
  case "SWAPPED_ORDER_DATA":
36167
36408
  activeCallbacksRef.current?.onOrderData(event.data.data ?? {});
36168
36409
  break;
36410
+ case "SWAPPED_TRANSACTION_SUCCESSFUL":
36411
+ activeCallbacksRef.current?.onSuccess(event.data.data ?? {});
36412
+ break;
36169
36413
  case "SWAPPED_LOGOUT":
36170
36414
  activeCallbacksRef.current?.onLogout();
36171
36415
  break;
@@ -36185,6 +36429,7 @@ function SwappedProvider({ children }) {
36185
36429
  resetIframe,
36186
36430
  setIframeRef,
36187
36431
  setActiveCallbacks,
36432
+ focusAmountInput,
36188
36433
  swappedTheme
36189
36434
  }),
36190
36435
  [
@@ -36196,6 +36441,7 @@ function SwappedProvider({ children }) {
36196
36441
  resetIframe,
36197
36442
  setIframeRef,
36198
36443
  setActiveCallbacks,
36444
+ focusAmountInput,
36199
36445
  swappedTheme
36200
36446
  ]
36201
36447
  );
@@ -36606,7 +36852,7 @@ function SourceChange({
36606
36852
  setModalState((state) => ({ ...state, showWalletOptions: true }));
36607
36853
  }
36608
36854
  };
36609
- const lastObservedTabRef = useRef28(void 0);
36855
+ const lastObservedTabRef = useRef27(void 0);
36610
36856
  const sendPaymentMethodTabEvent = useEffectEvent((tab) => {
36611
36857
  if (lastObservedTabRef.current === tab) {
36612
36858
  return;
@@ -36904,7 +37150,7 @@ function trackEventForTabChange(checkoutItem, tab) {
36904
37150
 
36905
37151
  // src/modals/CheckoutModal/SwappedIframe/SwappedIframeContainer.tsx
36906
37152
  import { useQueryClient as useQueryClient3 } from "@tanstack/react-query";
36907
- import React218, { useEffect as useEffect53, useRef as useRef29 } from "react";
37153
+ import React218, { useEffect as useEffect53, useRef as useRef28 } from "react";
36908
37154
  import { createPortal as createPortal19 } from "react-dom";
36909
37155
  var SwappedIframeInfo = {
36910
37156
  Component: SwappedIframeContainer,
@@ -36931,7 +37177,6 @@ var SwappedIframeInfo = {
36931
37177
  };
36932
37178
  function SwappedIframeContainer({
36933
37179
  modalState,
36934
- onNext,
36935
37180
  onBack,
36936
37181
  onClose,
36937
37182
  setModalState
@@ -36940,12 +37185,13 @@ function SwappedIframeContainer({
36940
37185
  const { logEvent, logMeasuredEvent, startMeasuredEvent } = useTrack();
36941
37186
  const { t } = useFunkitTranslation();
36942
37187
  const queryClient = useQueryClient3();
36943
- const timeoutRef = useRef29(void 0);
37188
+ const timeoutRef = useRef28(void 0);
36944
37189
  const { checkoutItem } = useCheckoutContext();
36945
37190
  const bottomSectionRef = useBottomSectionRef();
36946
37191
  const {
36947
37192
  activateIframe,
36948
37193
  deactivateIframe,
37194
+ focusAmountInput,
36949
37195
  isSwappedReady,
36950
37196
  resetIframe,
36951
37197
  setActiveCallbacks,
@@ -36968,17 +37214,11 @@ function SwappedIframeContainer({
36968
37214
  const event = getTrackEvent("fc::ready::swapped_iframe" /* READY_SWAPPED_IFRAME */);
36969
37215
  logger.info("swapped-iframe:ready", event.metadata);
36970
37216
  logMeasuredEvent(event);
37217
+ focusAmountInput();
36971
37218
  }
36972
- }, [getTrackEvent, isSwappedReady, logMeasuredEvent]);
37219
+ }, [getTrackEvent, isSwappedReady, logMeasuredEvent, focusAmountInput]);
36973
37220
  useEffect53(() => {
36974
37221
  setActiveCallbacks({
36975
- onComplete: () => {
36976
- const event = getTrackEvent("fc::swapped_iframe::complete" /* SWAPPED_IFRAME_COMPLETE */);
36977
- logger.info("swapped-iframe:complete", event.metadata);
36978
- logEvent(event);
36979
- queryClient.invalidateQueries({ queryKey: ["fops"] });
36980
- onNext({ success: true });
36981
- },
36982
37222
  onBack: () => {
36983
37223
  const event = getTrackEvent("fc::swapped_iframe::back" /* SWAPPED_IFRAME_BACK */);
36984
37224
  logger.info("swapped-iframe:back", event.metadata);
@@ -37010,6 +37250,14 @@ function SwappedIframeContainer({
37010
37250
  logger.info("swapped-iframe:order_data", event.metadata);
37011
37251
  logEvent(event);
37012
37252
  },
37253
+ onSuccess: (data) => {
37254
+ const event = getTrackEvent(
37255
+ "fc::swapped_iframe::transaction_successful" /* SWAPPED_IFRAME_TRANSACTION_SUCCESSFUL */,
37256
+ { data: JSON.stringify(data) }
37257
+ );
37258
+ logger.info("swapped-iframe:transaction_successful", event.metadata);
37259
+ logEvent(event);
37260
+ },
37013
37261
  onLogout: () => {
37014
37262
  const event = getTrackEvent("fc::swapped_iframe::logout" /* SWAPPED_IFRAME_LOGOUT */);
37015
37263
  logger.info("swapped-iframe:logout", event.metadata);
@@ -37105,7 +37353,6 @@ function SwappedIframeContainer({
37105
37353
  logEvent,
37106
37354
  onBack,
37107
37355
  onClose,
37108
- onNext,
37109
37356
  setModalState,
37110
37357
  queryClient
37111
37358
  ]);
@@ -37262,7 +37509,7 @@ function trackEventForFormOfPayment(fop, checkoutItem, eventName, extras) {
37262
37509
 
37263
37510
  // src/modals/CheckoutModal/TransferToken/TransferToken.tsx
37264
37511
  import { motion as motion13, useAnimationControls as useAnimationControls3 } from "motion/react";
37265
- import React228, { useRef as useRef30, useState as useState66 } from "react";
37512
+ import React228, { useRef as useRef29, useState as useState66 } from "react";
37266
37513
  import { createPortal as createPortal20 } from "react-dom";
37267
37514
 
37268
37515
  // src/components/CopyAddress/CopyInputDisplayedAddress.tsx
@@ -37967,7 +38214,7 @@ function TransferToken({
37967
38214
  const { checkoutItem } = useCheckoutContext();
37968
38215
  const checkoutConfig = checkoutItem?.initSettings.config;
37969
38216
  const { transferToken } = modalState;
37970
- const disclaimerTextWrapperRef = useRef30(null);
38217
+ const disclaimerTextWrapperRef = useRef29(null);
37971
38218
  const { transferInit } = useCheckoutTransferInit();
37972
38219
  const {
37973
38220
  assets,
@@ -37977,8 +38224,7 @@ function TransferToken({
37977
38224
  handleTokenChange,
37978
38225
  isLoadingAssets,
37979
38226
  chainIdSortOrder,
37980
- priorityTokenSymbols,
37981
- defaultChainId
38227
+ priorityTokenSymbols
37982
38228
  } = useTokenAndChainDropdown(transferInit, getDefaultTransferToken());
37983
38229
  const chainIds = Object.keys(assets).map(Number);
37984
38230
  const {
@@ -38035,8 +38281,8 @@ function TransferToken({
38035
38281
  );
38036
38282
  };
38037
38283
  function getDefaultTransferToken() {
38038
- const { defaultTokenSymbol, defaultChainId: defaultChainId2 } = udaParams ?? {};
38039
- const chainId = Number(defaultChainId2);
38284
+ const { defaultTokenSymbol, defaultChainId } = udaParams ?? {};
38285
+ const chainId = Number(defaultChainId);
38040
38286
  if (defaultTokenSymbol && !Number.isNaN(chainId)) {
38041
38287
  return { token: defaultTokenSymbol, chainId };
38042
38288
  }
@@ -38149,8 +38395,7 @@ function TransferToken({
38149
38395
  ),
38150
38396
  openChainDropdownFullWidth: false,
38151
38397
  priorityTokenSymbols,
38152
- chainIdSortOrder,
38153
- defaultChainId
38398
+ chainIdSortOrder
38154
38399
  }
38155
38400
  ),
38156
38401
  /* @__PURE__ */ React228.createElement(
@@ -38881,7 +39126,7 @@ function useCheckoutModalTransition(checkoutItem, onClose) {
38881
39126
  );
38882
39127
  const { animation, animate } = useAnimatedNavigation(void 0);
38883
39128
  const [stateHistory, setHistory] = useState69([]);
38884
- const prevStep = useRef31(null);
39129
+ const prevStep = useRef30(null);
38885
39130
  const hasHistoryEntry = stateHistory.length > 1;
38886
39131
  const onNext = useCallback46(
38887
39132
  (payload) => {
@@ -39054,7 +39299,7 @@ function useCheckoutModalTitle(depositAddress, defaultTitle) {
39054
39299
  import { IN_PROGRESS_CHECKOUT_STATES as IN_PROGRESS_CHECKOUT_STATES2 } from "@funkit/api-base";
39055
39300
  import { formatTimestampToDate, fullMonthNames } from "@funkit/utils";
39056
39301
  import clsx22 from "clsx";
39057
- import React245, { useEffect as useEffect58, useMemo as useMemo55, useRef as useRef33, useState as useState71 } from "react";
39302
+ import React245, { useEffect as useEffect58, useMemo as useMemo55, useRef as useRef32, useState as useState71 } from "react";
39058
39303
  import { Virtuoso } from "react-virtuoso";
39059
39304
 
39060
39305
  // src/consts/layout.ts
@@ -39439,12 +39684,12 @@ import { useCallback as useCallback47, useState as useState70 } from "react";
39439
39684
 
39440
39685
  // src/components/FunSelect/FunClickOutside.tsx
39441
39686
  import React241 from "react";
39442
- import { useEffect as useEffect57, useRef as useRef32 } from "react";
39687
+ import { useEffect as useEffect57, useRef as useRef31 } from "react";
39443
39688
  function FunClickOutside({
39444
39689
  children,
39445
39690
  onClick
39446
39691
  }) {
39447
- const wrapperRef = useRef32(null);
39692
+ const wrapperRef = useRef31(null);
39448
39693
  useEffect57(() => {
39449
39694
  const handleClickListener = (event) => {
39450
39695
  const clickedInside = wrapperRef.current?.contains(
@@ -39619,8 +39864,8 @@ function Home({
39619
39864
  }) {
39620
39865
  const { t } = useFunkitTranslation();
39621
39866
  const [selectedView, setSelectedView] = useState71(defaultHomeTab);
39622
- const checkoutsListRef = useRef33(null);
39623
- const virtuosoParentRef = useRef33(null);
39867
+ const checkoutsListRef = useRef32(null);
39868
+ const virtuosoParentRef = useRef32(null);
39624
39869
  const account = useAccount();
39625
39870
  useCheckoutHistoryListener();
39626
39871
  const { userInfo, handleLogout } = useGeneralWallet();
@@ -40378,7 +40623,7 @@ function ChainModal({ onClose, open }) {
40378
40623
  // src/modals/CheckoutModal/FunCheckoutModal.tsx
40379
40624
  import { FUNKIT_CONNECT_SUPPORTED_CHECKOUT_CHAINS_INFO_LIST as FUNKIT_CONNECT_SUPPORTED_CHECKOUT_CHAINS_INFO_LIST2 } from "@funkit/chains";
40380
40625
  import { LogLevel as LogLevel2, initializeRelayClient } from "@funkit/fun-relay";
40381
- import React270, { useRef as useRef35 } from "react";
40626
+ import React270, { useRef as useRef34 } from "react";
40382
40627
 
40383
40628
  // src/components/FunConnectOptions/FunConnectOptions.tsx
40384
40629
  import React261, { useCallback as useCallback49, useMemo as useMemo56, useState as useState75 } from "react";
@@ -41091,7 +41336,7 @@ var showMoreButtonStyle = "_4yitd93 _1rsrm2f1q0 _1rsrm2f1i _1rsrm2f1f _1rsrm2f11
41091
41336
  // src/components/FunNotificationBanner/FunNotificationBannerIcon.tsx
41092
41337
  import clsx23 from "clsx";
41093
41338
  import { motion as motion14, useAnimate as useAnimate3 } from "motion/react";
41094
- import React265, { useCallback as useCallback50, useEffect as useEffect62, useRef as useRef34 } from "react";
41339
+ import React265, { useCallback as useCallback50, useEffect as useEffect62, useRef as useRef33 } from "react";
41095
41340
 
41096
41341
  // src/components/FunNotificationBanner/FunNotificationBannerIcon.css.ts
41097
41342
  var STATUS_SPINNER_BOTTOM_POSITION = -5;
@@ -41540,7 +41785,7 @@ var FunNotificationBannerIcon = ({
41540
41785
  )
41541
41786
  ]);
41542
41787
  }, [animate]);
41543
- const statusRef = useRef34(status);
41788
+ const statusRef = useRef33(status);
41544
41789
  useEffect62(() => {
41545
41790
  if (statusRef.current !== status) {
41546
41791
  if (statusRef.current === "processing" && status === "completed") {
@@ -42385,8 +42630,8 @@ function FunCheckoutModalInner({
42385
42630
  depositAddress
42386
42631
  });
42387
42632
  };
42388
- const animationCallbackRef = useRef35(null);
42389
- const tooltipAnchorRef = useRef35(null);
42633
+ const animationCallbackRef = useRef34(null);
42634
+ const tooltipAnchorRef = useRef34(null);
42390
42635
  const handleAnimationCompleteRegister = (cb) => {
42391
42636
  animationCallbackRef.current = cb;
42392
42637
  };
@@ -43908,12 +44153,12 @@ function computeDisplayDestinationToken(checkoutConfig, displayAssetAmount) {
43908
44153
  }
43909
44154
 
43910
44155
  // src/domains/feeEstimate.ts
43911
- import { mainnet as mainnet10 } from "viem/chains";
44156
+ import { mainnet as mainnet9 } from "viem/chains";
43912
44157
  var L1_FEES_ESTIMATE = 1;
43913
44158
  var L2_FEES_ESTIMATE = 1;
43914
44159
  var BROKERAGE_FEES_ESTIMATE = 0;
43915
44160
  var getBaseFeeUsdEstimate = (targetChainId, assetChainId) => {
43916
- if (targetChainId !== mainnet10.id.toString() && assetChainId !== mainnet10.id.toString()) {
44161
+ if (targetChainId !== mainnet9.id.toString() && assetChainId !== mainnet9.id.toString()) {
43917
44162
  return L2_FEES_ESTIMATE;
43918
44163
  }
43919
44164
  return L1_FEES_ESTIMATE;
@@ -43940,7 +44185,7 @@ function getMinValueThreshold(config, minUsdRequired) {
43940
44185
  var isStablecoin = (symbol) => STABLECOIN_SYMBOLS.some((s) => symbol.toLowerCase().includes(s.toLowerCase()));
43941
44186
  function isPreferredChain(chainId, additionalChains = []) {
43942
44187
  const chains = /* @__PURE__ */ new Set([
43943
- mainnet11.id,
44188
+ mainnet10.id,
43944
44189
  polygon8.id,
43945
44190
  base7.id,
43946
44191
  arbitrum6.id,