@trustware/sdk-staging 1.1.4-staging.50 → 1.1.5-staging.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.
package/dist/widget.cjs CHANGED
@@ -245,7 +245,7 @@ var init_constants = __esm({
245
245
  "src/constants.ts"() {
246
246
  "use strict";
247
247
  SDK_NAME = "@trustware/sdk";
248
- SDK_VERSION = "1.1.4-staging.50";
248
+ SDK_VERSION = "1.1.5-staging.1";
249
249
  API_ROOT = "https://bv-staging-api.trustware.io";
250
250
  GTM_ID = "GTM-TZDGNCXB";
251
251
  API_PREFIX = "/api";
@@ -810,8 +810,8 @@ function ConfettiEffect({
810
810
  clearDelay = 3e3,
811
811
  pieceCount = 50
812
812
  }) {
813
- const [pieces, setPieces] = (0, import_react20.useState)([]);
814
- (0, import_react20.useEffect)(() => {
813
+ const [pieces, setPieces] = (0, import_react21.useState)([]);
814
+ (0, import_react21.useEffect)(() => {
815
815
  if (isActive) {
816
816
  const colors2 = [
817
817
  "#10b981",
@@ -887,11 +887,11 @@ function ConfettiEffect({
887
887
  }
888
888
  );
889
889
  }
890
- var import_react20, import_jsx_runtime6, ConfettiEffect_default;
890
+ var import_react21, import_jsx_runtime6, ConfettiEffect_default;
891
891
  var init_ConfettiEffect = __esm({
892
892
  "src/widget/components/ConfettiEffect.tsx"() {
893
893
  "use strict";
894
- import_react20 = require("react");
894
+ import_react21 = require("react");
895
895
  import_jsx_runtime6 = require("react/jsx-runtime");
896
896
  ConfettiEffect_default = ConfettiEffect;
897
897
  }
@@ -906,7 +906,7 @@ __export(widget_exports, {
906
906
  module.exports = __toCommonJS(widget_exports);
907
907
 
908
908
  // src/widget/TrustwareWidgetV2.tsx
909
- var import_react40 = require("react");
909
+ var import_react41 = require("react");
910
910
 
911
911
  // src/widget/lib/utils.ts
912
912
  function mergeStyles(...styles) {
@@ -1386,7 +1386,7 @@ var ANIMATION_CLASSES = `
1386
1386
  var ALL_ANIMATION_STYLES = KEYFRAMES + ANIMATION_CLASSES;
1387
1387
 
1388
1388
  // src/widget/context/DepositContext.tsx
1389
- var import_react17 = __toESM(require("react"), 1);
1389
+ var import_react18 = __toESM(require("react"), 1);
1390
1390
 
1391
1391
  // src/provider.tsx
1392
1392
  var import_react5 = require("react");
@@ -5974,16 +5974,326 @@ function mapWalletTokens(balances, chains, tokens) {
5974
5974
  });
5975
5975
  }
5976
5976
 
5977
+ // src/widget/state/deposit/useWalletConnect.ts
5978
+ var import_react17 = require("react");
5979
+ init_config2();
5980
+
5981
+ // src/config/walletconnect.ts
5982
+ var import_appkit_universal_connector = require("@reown/appkit-universal-connector");
5983
+ init_store();
5984
+ init_constants();
5985
+ var solanaMainnet = {
5986
+ id: 900,
5987
+ chainNamespace: "solana",
5988
+ caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqAQ3H1FQ",
5989
+ name: "Solana Mainnet",
5990
+ nativeCurrency: {
5991
+ name: "Solana",
5992
+ symbol: "SOL",
5993
+ decimals: 9
5994
+ },
5995
+ rpcUrls: {
5996
+ default: {
5997
+ http: ["https://api.mainnet-beta.solana.com"]
5998
+ }
5999
+ }
6000
+ };
6001
+ var bitcoinMainnet = {
6002
+ id: 8333,
6003
+ chainNamespace: "bip122",
6004
+ caipNetworkId: "bip122:000000000019d6689c085ae165831e93",
6005
+ name: "Bitcoin Mainnet",
6006
+ nativeCurrency: {
6007
+ name: "Bitcoin",
6008
+ symbol: "BTC",
6009
+ decimals: 8
6010
+ },
6011
+ rpcUrls: {
6012
+ default: {
6013
+ http: ["https://api.blockcypher.com/v1/btc/main"]
6014
+ }
6015
+ }
6016
+ };
6017
+ var ethereumMainnet = {
6018
+ id: 1,
6019
+ chainNamespace: "eip155",
6020
+ caipNetworkId: "eip155:1",
6021
+ name: "Ethereum Mainnet",
6022
+ nativeCurrency: {
6023
+ name: "Ether",
6024
+ symbol: "ETH",
6025
+ decimals: 18
6026
+ },
6027
+ rpcUrls: {
6028
+ default: {
6029
+ http: ["https://rpc.ankr.com/eth"]
6030
+ }
6031
+ }
6032
+ };
6033
+ var seiMainnet = {
6034
+ id: 1329,
6035
+ chainNamespace: "eip155",
6036
+ caipNetworkId: "eip155:1329",
6037
+ name: "Sei Mainnet",
6038
+ nativeCurrency: {
6039
+ name: "Sei",
6040
+ symbol: "SEI",
6041
+ decimals: 18
6042
+ },
6043
+ rpcUrls: {
6044
+ default: {
6045
+ http: ["https://evm-rpc.sei-apis.com"]
6046
+ }
6047
+ }
6048
+ };
6049
+ var solanaChains = [solanaMainnet];
6050
+ var evmChains = [ethereumMainnet, seiMainnet];
6051
+ var bitcoinChains = [bitcoinMainnet];
6052
+ var networks = [
6053
+ // ...solanaChains,
6054
+ // ...bitcoinChains,
6055
+ ...evmChains
6056
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6057
+ ];
6058
+ var namespaceConfig = [
6059
+ {
6060
+ namespace: "solana",
6061
+ chains: solanaChains,
6062
+ methods: ["solana_signMessage", "solana_signTransaction"],
6063
+ events: []
6064
+ },
6065
+ {
6066
+ namespace: "eip155",
6067
+ chains: evmChains,
6068
+ methods: [
6069
+ "eth_sendTransaction",
6070
+ "eth_signTransaction",
6071
+ "eth_sign",
6072
+ "personal_sign",
6073
+ "eth_signTypedData_v4"
6074
+ ],
6075
+ events: ["accountsChanged", "chainChanged"]
6076
+ },
6077
+ {
6078
+ namespace: "bip122",
6079
+ chains: bitcoinChains,
6080
+ // FIX 8: Use the standard WalletConnect BIP-122 method name, not the
6081
+ // non-standard "btc_signMessage" prefix that most wallets reject.
6082
+ methods: ["signMessage", "sendTransfer"],
6083
+ events: []
6084
+ }
6085
+ ];
6086
+ function resolvedMetadata() {
6087
+ const cfg = TrustwareConfigStore.peek();
6088
+ const walletConnect = cfg ? cfg?.walletConnect : void 0;
6089
+ const configured = walletConnect?.metadata;
6090
+ const pageUrl = typeof window !== "undefined" && window.location?.origin ? window.location.origin : configured?.url;
6091
+ if (!pageUrl) {
6092
+ console.warn(
6093
+ "[Trustware SDK] WalletConnect metadata.url could not be determined from window.location or config. Falling back to 'https://trustware.io'. Pass metadata.url explicitly in your WalletConnectConfig to avoid domain verification failures in production."
6094
+ );
6095
+ }
6096
+ return {
6097
+ name: configured?.name ?? "Trustware",
6098
+ description: configured?.description ?? "Cross-chain bridge & top-up",
6099
+ url: pageUrl ?? "https://trustware.io",
6100
+ icons: configured?.icons?.length ? configured.icons : ["https://app.trustware.io/icon.png"]
6101
+ };
6102
+ }
6103
+ var universalConnectorPromise = null;
6104
+ var initializedProjectId = null;
6105
+ async function getUniversalConnector(walletCfg) {
6106
+ const projectId = walletCfg?.projectId ?? WALLETCONNECT_PROJECT_ID;
6107
+ if (universalConnectorPromise && initializedProjectId !== projectId) {
6108
+ console.warn(
6109
+ "[Trustware SDK] projectId changed since last init \u2014 reinitializing WalletConnect connector."
6110
+ );
6111
+ universalConnectorPromise = null;
6112
+ initializedProjectId = null;
6113
+ }
6114
+ if (!universalConnectorPromise) {
6115
+ initializedProjectId = projectId;
6116
+ universalConnectorPromise = import_appkit_universal_connector.UniversalConnector.init({
6117
+ projectId,
6118
+ metadata: resolvedMetadata(),
6119
+ networks: namespaceConfig
6120
+ }).catch((error) => {
6121
+ universalConnectorPromise = null;
6122
+ initializedProjectId = null;
6123
+ console.error(
6124
+ "[Trustware SDK] Failed to initialize WalletConnect:",
6125
+ error
6126
+ );
6127
+ throw error;
6128
+ });
6129
+ }
6130
+ return universalConnectorPromise;
6131
+ }
6132
+
6133
+ // src/widget/state/deposit/useWalletConnect.ts
6134
+ function getEvmAccount(session) {
6135
+ const account = session?.namespaces?.eip155?.accounts?.[0];
6136
+ const [, chainId, address] = account?.split(":") ?? [];
6137
+ if (!chainId || !address) {
6138
+ return null;
6139
+ }
6140
+ return {
6141
+ address,
6142
+ chainId: Number(chainId)
6143
+ };
6144
+ }
6145
+ function toHexChainId(chainId) {
6146
+ return `0x${chainId.toString(16)}`;
6147
+ }
6148
+ function useWalletConnect({
6149
+ setWalletType,
6150
+ setCurrentStep
6151
+ }) {
6152
+ const [universalConnector, setUniversalConnector] = (0, import_react17.useState)();
6153
+ const [walletConnectAddress, setWalletConnectAddress] = (0, import_react17.useState)(null);
6154
+ (0, import_react17.useEffect)(() => {
6155
+ if (typeof window === "undefined") {
6156
+ return;
6157
+ }
6158
+ const walletConnect = TrustwareConfigStore.peek()?.walletConnect;
6159
+ getUniversalConnector(walletConnect).then(
6160
+ setUniversalConnector
6161
+ );
6162
+ }, [TrustwareConfigStore.peek()?.walletConnect]);
6163
+ (0, import_react17.useEffect)(() => {
6164
+ return () => {
6165
+ universalConnector?.disconnect();
6166
+ };
6167
+ }, [universalConnector]);
6168
+ const attachWalletConnectWallet = (0, import_react17.useCallback)(
6169
+ (connector, session) => {
6170
+ const account = getEvmAccount(session);
6171
+ if (!account) {
6172
+ return null;
6173
+ }
6174
+ const activeAddress = account.address;
6175
+ let activeChainId = account.chainId;
6176
+ connector.provider.setDefaultChain(`eip155:${activeChainId}`);
6177
+ const wallet = {
6178
+ ecosystem: "evm",
6179
+ type: "eip1193",
6180
+ async getAddress() {
6181
+ return activeAddress;
6182
+ },
6183
+ async getChainId() {
6184
+ return activeChainId;
6185
+ },
6186
+ async switchChain(chainId) {
6187
+ connector.provider.setDefaultChain(`eip155:${chainId}`);
6188
+ await connector.provider.request(
6189
+ {
6190
+ method: "wallet_switchEthereumChain",
6191
+ params: [{ chainId: toHexChainId(chainId) }]
6192
+ },
6193
+ `eip155:${chainId}`
6194
+ );
6195
+ activeChainId = chainId;
6196
+ },
6197
+ async request(args) {
6198
+ const tx = Array.isArray(args.params) ? args.params[0] : void 0;
6199
+ const requestedChainId = typeof tx?.chainId === "string" ? Number.parseInt(tx.chainId, 16) : activeChainId;
6200
+ const chain = Number.isFinite(requestedChainId) ? `eip155:${requestedChainId}` : `eip155:${activeChainId}`;
6201
+ connector.provider.setDefaultChain(chain);
6202
+ return connector.provider.request(args, chain);
6203
+ },
6204
+ async disconnect() {
6205
+ await connector.disconnect();
6206
+ }
6207
+ };
6208
+ walletManager.attachWallet(wallet);
6209
+ setWalletConnectAddress(activeAddress);
6210
+ return activeAddress;
6211
+ },
6212
+ []
6213
+ );
6214
+ const getAddrAndRedirect = (0, import_react17.useCallback)(
6215
+ (connector, session) => {
6216
+ const adr = attachWalletConnectWallet(connector, session);
6217
+ if (!adr) return null;
6218
+ setCurrentStep("crypto-pay");
6219
+ console.log({ adr });
6220
+ return adr;
6221
+ },
6222
+ [attachWalletConnectWallet, setCurrentStep]
6223
+ );
6224
+ const WalletConnect = (0, import_react17.useCallback)(
6225
+ async function() {
6226
+ console.log("got called");
6227
+ if (!universalConnector) {
6228
+ return;
6229
+ }
6230
+ setWalletType("walletconnect");
6231
+ const session = universalConnector.provider.session;
6232
+ const nowInSeconds = Math.floor(Date.now() / 1e3);
6233
+ const isActive = session && session.expiry > nowInSeconds;
6234
+ console.log({ isActive, session });
6235
+ if (isActive && session) {
6236
+ getAddrAndRedirect(universalConnector, session);
6237
+ return;
6238
+ }
6239
+ const { session: providerSession } = await universalConnector.connect();
6240
+ if (providerSession) {
6241
+ getAddrAndRedirect(universalConnector, providerSession);
6242
+ return;
6243
+ }
6244
+ },
6245
+ [getAddrAndRedirect, setWalletType, universalConnector]
6246
+ );
6247
+ const disconnectWalletConnect = async () => {
6248
+ if (universalConnector) {
6249
+ await walletManager.disconnect();
6250
+ setWalletType("other");
6251
+ setCurrentStep("home");
6252
+ }
6253
+ };
6254
+ (0, import_react17.useEffect)(() => {
6255
+ const provider = universalConnector?.provider;
6256
+ if (!provider) {
6257
+ return;
6258
+ }
6259
+ const handleSessionUpdate = ({
6260
+ session
6261
+ }) => {
6262
+ console.log("session_update");
6263
+ if (session) {
6264
+ attachWalletConnectWallet(universalConnector, session);
6265
+ }
6266
+ };
6267
+ const handleSessionDelete = () => {
6268
+ console.log("session_delete");
6269
+ setWalletConnectAddress(null);
6270
+ void walletManager.disconnect();
6271
+ };
6272
+ provider.on("session_update", handleSessionUpdate);
6273
+ provider.on("session_delete", handleSessionDelete);
6274
+ return () => {
6275
+ provider.off("session_update", handleSessionUpdate);
6276
+ provider.off("session_delete", handleSessionDelete);
6277
+ };
6278
+ }, [attachWalletConnectWallet, universalConnector]);
6279
+ return {
6280
+ universalConnector,
6281
+ walletConnectAddress,
6282
+ WalletConnect,
6283
+ disconnectWalletConnect
6284
+ };
6285
+ }
6286
+
5977
6287
  // src/widget/context/DepositContext.tsx
5978
6288
  var import_jsx_runtime2 = require("react/jsx-runtime");
5979
- var DepositContext = (0, import_react17.createContext)(
6289
+ var DepositContext = (0, import_react18.createContext)(
5980
6290
  void 0
5981
6291
  );
5982
- var DepositNavigationContext = (0, import_react17.createContext)(void 0);
5983
- var DepositWalletContext = (0, import_react17.createContext)(void 0);
5984
- var DepositFormContext = (0, import_react17.createContext)(void 0);
5985
- var DepositTransactionContext = (0, import_react17.createContext)(void 0);
5986
- var DepositUiContext = (0, import_react17.createContext)(void 0);
6292
+ var DepositNavigationContext = (0, import_react18.createContext)(void 0);
6293
+ var DepositWalletContext = (0, import_react18.createContext)(void 0);
6294
+ var DepositFormContext = (0, import_react18.createContext)(void 0);
6295
+ var DepositTransactionContext = (0, import_react18.createContext)(void 0);
6296
+ var DepositUiContext = (0, import_react18.createContext)(void 0);
5987
6297
  function DepositProvider({
5988
6298
  children,
5989
6299
  initialStep = "home"
@@ -6001,17 +6311,33 @@ function DepositProvider({
6001
6311
  const { resolvedTheme, toggleTheme } = useThemePreference();
6002
6312
  const {
6003
6313
  selectedWallet,
6004
- walletAddress,
6314
+ walletAddress: otherWalletAddress,
6005
6315
  walletStatus,
6006
6316
  connectWallet,
6007
6317
  disconnectWallet
6008
6318
  } = useWalletSessionState();
6009
- const [amountInputMode, setAmountInputMode] = (0, import_react17.useState)(
6319
+ const [amountInputMode, setAmountInputMode] = (0, import_react18.useState)(
6010
6320
  "usd"
6011
6321
  );
6012
- const [selectedToken, setSelectedToken] = (0, import_react17.useState)(null);
6013
- const [selectedChain, setSelectedChain] = (0, import_react17.useState)(null);
6014
- const [amount, setAmount] = (0, import_react17.useState)("");
6322
+ const [walletType, setWalletType] = (0, import_react18.useState)(
6323
+ "other"
6324
+ );
6325
+ const {
6326
+ universalConnector,
6327
+ walletConnectAddress,
6328
+ WalletConnect,
6329
+ disconnectWalletConnect
6330
+ } = useWalletConnect({
6331
+ setWalletType,
6332
+ setCurrentStep
6333
+ });
6334
+ const [selectedToken, setSelectedToken] = (0, import_react18.useState)(null);
6335
+ const [selectedChain, setSelectedChain] = (0, import_react18.useState)(null);
6336
+ const [amount, setAmount] = (0, import_react18.useState)("");
6337
+ const walletAddress = (0, import_react18.useMemo)(
6338
+ () => walletType === "walletconnect" ? walletConnectAddress : otherWalletAddress,
6339
+ [walletType, walletConnectAddress, otherWalletAddress]
6340
+ );
6015
6341
  const {
6016
6342
  yourWalletTokens,
6017
6343
  setYourWalletTokens,
@@ -6024,12 +6350,12 @@ function DepositProvider({
6024
6350
  selectedToken,
6025
6351
  setSelectedToken
6026
6352
  });
6027
- const [transactionStatus, setTransactionStatus] = (0, import_react17.useState)("idle");
6028
- const [transactionHash, setTransactionHash] = (0, import_react17.useState)(null);
6029
- const [errorMessage, setErrorMessage] = (0, import_react17.useState)(null);
6030
- const [intentId, setIntentId] = (0, import_react17.useState)(null);
6031
- const [paymentMethod, setPaymentMethod] = (0, import_react17.useState)("crypto");
6032
- const resetState = import_react17.default.useCallback(() => {
6353
+ const [transactionStatus, setTransactionStatus] = (0, import_react18.useState)("idle");
6354
+ const [transactionHash, setTransactionHash] = (0, import_react18.useState)(null);
6355
+ const [errorMessage, setErrorMessage] = (0, import_react18.useState)(null);
6356
+ const [intentId, setIntentId] = (0, import_react18.useState)(null);
6357
+ const [paymentMethod, setPaymentMethod] = (0, import_react18.useState)("crypto");
6358
+ const resetState = import_react18.default.useCallback(() => {
6033
6359
  resetNavigation();
6034
6360
  setSelectedToken(null);
6035
6361
  setSelectedChain(null);
@@ -6042,7 +6368,7 @@ function DepositProvider({
6042
6368
  setPaymentMethod("crypto");
6043
6369
  reloadWalletTokens();
6044
6370
  }, [reloadWalletTokens, resetNavigation]);
6045
- const navigationValue = (0, import_react17.useMemo)(
6371
+ const navigationValue = (0, import_react18.useMemo)(
6046
6372
  () => ({
6047
6373
  currentStep,
6048
6374
  setCurrentStep,
@@ -6062,7 +6388,7 @@ function DepositProvider({
6062
6388
  stepHistory
6063
6389
  ]
6064
6390
  );
6065
- const walletValue = (0, import_react17.useMemo)(
6391
+ const walletValue = (0, import_react18.useMemo)(
6066
6392
  () => ({
6067
6393
  selectedWallet,
6068
6394
  walletAddress,
@@ -6071,20 +6397,31 @@ function DepositProvider({
6071
6397
  disconnectWallet,
6072
6398
  yourWalletTokens,
6073
6399
  setYourWalletTokens,
6074
- yourWalletTokensLoading
6400
+ yourWalletTokensLoading,
6401
+ universalConnector,
6402
+ walletConnectAddress,
6403
+ WalletConnect,
6404
+ disconnectWalletConnect,
6405
+ setWalletType,
6406
+ walletType
6075
6407
  }),
6076
6408
  [
6409
+ WalletConnect,
6077
6410
  connectWallet,
6078
6411
  disconnectWallet,
6412
+ disconnectWalletConnect,
6079
6413
  selectedWallet,
6080
6414
  setYourWalletTokens,
6415
+ universalConnector,
6081
6416
  walletAddress,
6417
+ walletConnectAddress,
6082
6418
  walletStatus,
6419
+ walletType,
6083
6420
  yourWalletTokens,
6084
6421
  yourWalletTokensLoading
6085
6422
  ]
6086
6423
  );
6087
- const formValue = (0, import_react17.useMemo)(
6424
+ const formValue = (0, import_react18.useMemo)(
6088
6425
  () => ({
6089
6426
  selectedToken,
6090
6427
  setSelectedToken,
@@ -6106,7 +6443,7 @@ function DepositProvider({
6106
6443
  setPaymentMethod
6107
6444
  ]
6108
6445
  );
6109
- const transactionValue = (0, import_react17.useMemo)(
6446
+ const transactionValue = (0, import_react18.useMemo)(
6110
6447
  () => ({
6111
6448
  transactionStatus,
6112
6449
  setTransactionStatus,
@@ -6119,14 +6456,14 @@ function DepositProvider({
6119
6456
  }),
6120
6457
  [errorMessage, intentId, transactionHash, transactionStatus]
6121
6458
  );
6122
- const uiValue = (0, import_react17.useMemo)(
6459
+ const uiValue = (0, import_react18.useMemo)(
6123
6460
  () => ({
6124
6461
  resolvedTheme,
6125
6462
  toggleTheme
6126
6463
  }),
6127
6464
  [resolvedTheme, toggleTheme]
6128
6465
  );
6129
- const value = (0, import_react17.useMemo)(
6466
+ const value = (0, import_react18.useMemo)(
6130
6467
  () => ({
6131
6468
  ...navigationValue,
6132
6469
  ...walletValue,
@@ -6139,7 +6476,7 @@ function DepositProvider({
6139
6476
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DepositNavigationContext.Provider, { value: navigationValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DepositWalletContext.Provider, { value: walletValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DepositFormContext.Provider, { value: formValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DepositTransactionContext.Provider, { value: transactionValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DepositUiContext.Provider, { value: uiValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DepositContext.Provider, { value, children }) }) }) }) }) });
6140
6477
  }
6141
6478
  function useRequiredContext(context, name) {
6142
- const value = (0, import_react17.useContext)(context);
6479
+ const value = (0, import_react18.useContext)(context);
6143
6480
  if (value === void 0) {
6144
6481
  throw new Error(`${name} must be used within a DepositProvider`);
6145
6482
  }
@@ -6162,7 +6499,7 @@ function useDepositUi() {
6162
6499
  }
6163
6500
 
6164
6501
  // src/widget/components/AmountSlider.tsx
6165
- var import_react18 = require("react");
6502
+ var import_react19 = require("react");
6166
6503
  var import_jsx_runtime3 = require("react/jsx-runtime");
6167
6504
  var roundToNiceNumber = (value, range) => {
6168
6505
  let roundingFactor;
@@ -6212,7 +6549,7 @@ function AmountSlider({
6212
6549
  style,
6213
6550
  disabled = false
6214
6551
  }) {
6215
- const generateTickMarks = (0, import_react18.useCallback)(
6552
+ const generateTickMarks = (0, import_react19.useCallback)(
6216
6553
  (minValue, maxValue) => {
6217
6554
  const range = maxValue - minValue;
6218
6555
  if (range <= 0) {
@@ -6260,25 +6597,25 @@ function AmountSlider({
6260
6597
  },
6261
6598
  []
6262
6599
  );
6263
- const tickMarks = (0, import_react18.useMemo)(
6600
+ const tickMarks = (0, import_react19.useMemo)(
6264
6601
  () => generateTickMarks(min, max),
6265
6602
  [generateTickMarks, min, max]
6266
6603
  );
6267
- const getPercentage = (0, import_react18.useCallback)(() => {
6604
+ const getPercentage = (0, import_react19.useCallback)(() => {
6268
6605
  const range = max - min;
6269
6606
  if (range <= 0) return 0;
6270
6607
  const clampedValue = Math.min(Math.max(value, min), max);
6271
6608
  return (clampedValue - min) / range * 100;
6272
6609
  }, [max, min, value]);
6273
- const percentage = (0, import_react18.useMemo)(() => getPercentage(), [getPercentage]);
6274
- const handleChange = (0, import_react18.useCallback)(
6610
+ const percentage = (0, import_react19.useMemo)(() => getPercentage(), [getPercentage]);
6611
+ const handleChange = (0, import_react19.useCallback)(
6275
6612
  (e2) => {
6276
6613
  const newValue = Math.min(Math.max(Number(e2.target.value), min), max);
6277
6614
  onChange(newValue);
6278
6615
  },
6279
6616
  [onChange, min, max]
6280
6617
  );
6281
- const handleTickClick = (0, import_react18.useCallback)(
6618
+ const handleTickClick = (0, import_react19.useCallback)(
6282
6619
  (tickValue) => {
6283
6620
  if (disabled) return;
6284
6621
  onChange(tickValue);
@@ -6496,7 +6833,7 @@ function AmountSlider({
6496
6833
  }
6497
6834
 
6498
6835
  // src/widget/components/AmountInputDisplay.tsx
6499
- var import_react19 = require("react");
6836
+ var import_react20 = require("react");
6500
6837
  var import_jsx_runtime4 = require("react/jsx-runtime");
6501
6838
  function formatDisplayAmount(value) {
6502
6839
  if (!Number.isFinite(value) || value <= 0) return "0";
@@ -6535,8 +6872,8 @@ function AmountInputDisplay({
6535
6872
  style,
6536
6873
  inputAriaLabel = "Deposit amount"
6537
6874
  }) {
6538
- const [isEditing, setIsEditing] = (0, import_react19.useState)(false);
6539
- const inputRef = (0, import_react19.useRef)(null);
6875
+ const [isEditing, setIsEditing] = (0, import_react20.useState)(false);
6876
+ const inputRef = (0, import_react20.useRef)(null);
6540
6877
  const handleAmountClick = () => {
6541
6878
  if (isFixedAmount) return;
6542
6879
  const isZeroish = !amount || parseFloat(amount) === 0;
@@ -6751,7 +7088,7 @@ function CircularProgress({
6751
7088
  }
6752
7089
 
6753
7090
  // src/widget/components/Dialog.tsx
6754
- var import_react21 = require("react");
7091
+ var import_react22 = require("react");
6755
7092
  var import_jsx_runtime7 = require("react/jsx-runtime");
6756
7093
  var Dialog = ({
6757
7094
  open,
@@ -6763,11 +7100,11 @@ var Dialog = ({
6763
7100
  confirmText = "Close Anyway",
6764
7101
  isDark = false
6765
7102
  }) => {
6766
- const dialogRef = (0, import_react21.useRef)(null);
6767
- const overlayRef = (0, import_react21.useRef)(null);
6768
- const firstButtonRef = (0, import_react21.useRef)(null);
6769
- const lastButtonRef = (0, import_react21.useRef)(null);
6770
- (0, import_react21.useEffect)(() => {
7103
+ const dialogRef = (0, import_react22.useRef)(null);
7104
+ const overlayRef = (0, import_react22.useRef)(null);
7105
+ const firstButtonRef = (0, import_react22.useRef)(null);
7106
+ const lastButtonRef = (0, import_react22.useRef)(null);
7107
+ (0, import_react22.useEffect)(() => {
6771
7108
  const handleEscape = (e2) => {
6772
7109
  if (e2.key === "Escape" && open) {
6773
7110
  e2.preventDefault();
@@ -6781,7 +7118,7 @@ var Dialog = ({
6781
7118
  document.removeEventListener("keydown", handleEscape);
6782
7119
  };
6783
7120
  }, [open, onCancel]);
6784
- (0, import_react21.useEffect)(() => {
7121
+ (0, import_react22.useEffect)(() => {
6785
7122
  const handleTabKey = (e2) => {
6786
7123
  if (!open) return;
6787
7124
  if (e2.key === "Tab") {
@@ -6805,7 +7142,7 @@ var Dialog = ({
6805
7142
  document.removeEventListener("keydown", handleTabKey);
6806
7143
  };
6807
7144
  }, [open]);
6808
- (0, import_react21.useEffect)(() => {
7145
+ (0, import_react22.useEffect)(() => {
6809
7146
  if (open) {
6810
7147
  const originalStyle = window.getComputedStyle(document.body).overflow;
6811
7148
  document.body.style.overflow = "hidden";
@@ -7103,7 +7440,7 @@ function TransactionHashLink({
7103
7440
  }
7104
7441
 
7105
7442
  // src/widget/components/SwipeToConfirmTokens.tsx
7106
- var import_react22 = require("react");
7443
+ var import_react23 = require("react");
7107
7444
  var import_jsx_runtime9 = require("react/jsx-runtime");
7108
7445
  function SwipeToConfirmTokens({
7109
7446
  fromToken,
@@ -7118,33 +7455,33 @@ function SwipeToConfirmTokens({
7118
7455
  style,
7119
7456
  text
7120
7457
  }) {
7121
- const [dragX, setDragX] = (0, import_react22.useState)(0);
7122
- const [isDragging, setIsDragging] = (0, import_react22.useState)(false);
7123
- const [isComplete, setIsComplete] = (0, import_react22.useState)(false);
7124
- const trackRef = (0, import_react22.useRef)(null);
7125
- const thumbRef = (0, import_react22.useRef)(null);
7126
- const [isLongPressing, setIsLongPressing] = (0, import_react22.useState)(false);
7127
- const [longPressProgress, setLongPressProgress] = (0, import_react22.useState)(0);
7128
- const longPressTimerRef = (0, import_react22.useRef)(null);
7129
- const longPressStartRef = (0, import_react22.useRef)(null);
7130
- const longPressAnimationRef = (0, import_react22.useRef)(null);
7458
+ const [dragX, setDragX] = (0, import_react23.useState)(0);
7459
+ const [isDragging, setIsDragging] = (0, import_react23.useState)(false);
7460
+ const [isComplete, setIsComplete] = (0, import_react23.useState)(false);
7461
+ const trackRef = (0, import_react23.useRef)(null);
7462
+ const thumbRef = (0, import_react23.useRef)(null);
7463
+ const [isLongPressing, setIsLongPressing] = (0, import_react23.useState)(false);
7464
+ const [longPressProgress, setLongPressProgress] = (0, import_react23.useState)(0);
7465
+ const longPressTimerRef = (0, import_react23.useRef)(null);
7466
+ const longPressStartRef = (0, import_react23.useRef)(null);
7467
+ const longPressAnimationRef = (0, import_react23.useRef)(null);
7131
7468
  const LONG_PRESS_DURATION = 1500;
7132
7469
  const thumbSize = 48;
7133
7470
  const padding = 4;
7134
7471
  const threshold = 0.8;
7135
- const getMaxDrag = (0, import_react22.useCallback)(() => {
7472
+ const getMaxDrag = (0, import_react23.useCallback)(() => {
7136
7473
  if (!trackRef.current) return 0;
7137
7474
  return trackRef.current.offsetWidth - thumbSize - padding * 2;
7138
7475
  }, []);
7139
- const getProgress = (0, import_react22.useCallback)(() => {
7476
+ const getProgress = (0, import_react23.useCallback)(() => {
7140
7477
  const maxDrag = getMaxDrag();
7141
7478
  return maxDrag > 0 ? dragX / maxDrag : 0;
7142
7479
  }, [dragX, getMaxDrag]);
7143
- const handleDragStart = (0, import_react22.useCallback)(() => {
7480
+ const handleDragStart = (0, import_react23.useCallback)(() => {
7144
7481
  if (disabled || isComplete) return;
7145
7482
  setIsDragging(true);
7146
7483
  }, [disabled, isComplete]);
7147
- const handleDragMove = (0, import_react22.useCallback)(
7484
+ const handleDragMove = (0, import_react23.useCallback)(
7148
7485
  (clientX) => {
7149
7486
  if (!isDragging || !trackRef.current || isComplete) return;
7150
7487
  const rect = trackRef.current.getBoundingClientRect();
@@ -7155,7 +7492,7 @@ function SwipeToConfirmTokens({
7155
7492
  },
7156
7493
  [isDragging, isComplete, getMaxDrag]
7157
7494
  );
7158
- const handleDragEnd = (0, import_react22.useCallback)(() => {
7495
+ const handleDragEnd = (0, import_react23.useCallback)(() => {
7159
7496
  if (!isDragging) return;
7160
7497
  setIsDragging(false);
7161
7498
  const progress2 = getProgress();
@@ -7168,14 +7505,14 @@ function SwipeToConfirmTokens({
7168
7505
  setDragX(0);
7169
7506
  }
7170
7507
  }, [isDragging, getProgress, getMaxDrag, onConfirm]);
7171
- const triggerConfirmation = (0, import_react22.useCallback)(() => {
7508
+ const triggerConfirmation = (0, import_react23.useCallback)(() => {
7172
7509
  if (isComplete) return;
7173
7510
  setDragX(getMaxDrag());
7174
7511
  setIsComplete(true);
7175
7512
  if (navigator.vibrate) navigator.vibrate(50);
7176
7513
  setTimeout(() => onConfirm(), 150);
7177
7514
  }, [isComplete, getMaxDrag, onConfirm]);
7178
- const cancelLongPress = (0, import_react22.useCallback)(() => {
7515
+ const cancelLongPress = (0, import_react23.useCallback)(() => {
7179
7516
  setIsLongPressing(false);
7180
7517
  setLongPressProgress(0);
7181
7518
  longPressStartRef.current = null;
@@ -7188,7 +7525,7 @@ function SwipeToConfirmTokens({
7188
7525
  longPressAnimationRef.current = null;
7189
7526
  }
7190
7527
  }, []);
7191
- const startLongPress = (0, import_react22.useCallback)(() => {
7528
+ const startLongPress = (0, import_react23.useCallback)(() => {
7192
7529
  if (disabled || isComplete || isDragging) return;
7193
7530
  setIsLongPressing(true);
7194
7531
  longPressStartRef.current = Date.now();
@@ -7206,7 +7543,7 @@ function SwipeToConfirmTokens({
7206
7543
  };
7207
7544
  longPressAnimationRef.current = requestAnimationFrame(animateProgress);
7208
7545
  }, [disabled, isComplete, isDragging, triggerConfirmation, cancelLongPress]);
7209
- const handleKeyDown = (0, import_react22.useCallback)(
7546
+ const handleKeyDown = (0, import_react23.useCallback)(
7210
7547
  (e2) => {
7211
7548
  if (disabled || isComplete) return;
7212
7549
  if (e2.key === "Enter" || e2.key === " ") {
@@ -7216,7 +7553,7 @@ function SwipeToConfirmTokens({
7216
7553
  },
7217
7554
  [disabled, isComplete, startLongPress]
7218
7555
  );
7219
- const handleKeyUp = (0, import_react22.useCallback)(
7556
+ const handleKeyUp = (0, import_react23.useCallback)(
7220
7557
  (e2) => {
7221
7558
  if (e2.key === "Enter" || e2.key === " ") {
7222
7559
  e2.preventDefault();
@@ -7225,7 +7562,7 @@ function SwipeToConfirmTokens({
7225
7562
  },
7226
7563
  [cancelLongPress]
7227
7564
  );
7228
- (0, import_react22.useEffect)(() => {
7565
+ (0, import_react23.useEffect)(() => {
7229
7566
  return () => {
7230
7567
  if (longPressTimerRef.current) clearTimeout(longPressTimerRef.current);
7231
7568
  if (longPressAnimationRef.current)
@@ -7236,15 +7573,15 @@ function SwipeToConfirmTokens({
7236
7573
  e2.preventDefault();
7237
7574
  handleDragStart();
7238
7575
  };
7239
- const handleMouseMove = (0, import_react22.useCallback)(
7576
+ const handleMouseMove = (0, import_react23.useCallback)(
7240
7577
  (e2) => handleDragMove(e2.clientX),
7241
7578
  [handleDragMove]
7242
7579
  );
7243
- const handleMouseUp = (0, import_react22.useCallback)(() => handleDragEnd(), [handleDragEnd]);
7580
+ const handleMouseUp = (0, import_react23.useCallback)(() => handleDragEnd(), [handleDragEnd]);
7244
7581
  const handleTouchStart = () => handleDragStart();
7245
7582
  const handleTouchMove = (e2) => handleDragMove(e2.touches[0].clientX);
7246
7583
  const handleTouchEnd = () => handleDragEnd();
7247
- (0, import_react22.useEffect)(() => {
7584
+ (0, import_react23.useEffect)(() => {
7248
7585
  if (isDragging) {
7249
7586
  window.addEventListener("mousemove", handleMouseMove);
7250
7587
  window.addEventListener("mouseup", handleMouseUp);
@@ -7256,8 +7593,8 @@ function SwipeToConfirmTokens({
7256
7593
  }, [isDragging, handleMouseMove, handleMouseUp]);
7257
7594
  const progress = getProgress();
7258
7595
  const effectiveProgress = isLongPressing ? longPressProgress : progress;
7259
- const [blinkOpacity, setBlinkOpacity] = (0, import_react22.useState)(1);
7260
- (0, import_react22.useEffect)(() => {
7596
+ const [blinkOpacity, setBlinkOpacity] = (0, import_react23.useState)(1);
7597
+ (0, import_react23.useEffect)(() => {
7261
7598
  if (disabled || isComplete || isDragging || isLongPressing) {
7262
7599
  setBlinkOpacity(1);
7263
7600
  return;
@@ -7707,7 +8044,7 @@ function ThemeToggle({
7707
8044
  }
7708
8045
 
7709
8046
  // src/widget/components/Toast.tsx
7710
- var import_react23 = require("react");
8047
+ var import_react24 = require("react");
7711
8048
  var import_jsx_runtime11 = require("react/jsx-runtime");
7712
8049
  var variantStyles = {
7713
8050
  default: {
@@ -7737,14 +8074,14 @@ function ToastItem({
7737
8074
  duration = 4e3,
7738
8075
  onDismiss
7739
8076
  }) {
7740
- const [isExiting, setIsExiting] = (0, import_react23.useState)(false);
7741
- (0, import_react23.useEffect)(() => {
8077
+ const [isExiting, setIsExiting] = (0, import_react24.useState)(false);
8078
+ (0, import_react24.useEffect)(() => {
7742
8079
  const timer = setTimeout(() => {
7743
8080
  setIsExiting(true);
7744
8081
  }, duration);
7745
8082
  return () => clearTimeout(timer);
7746
8083
  }, [duration]);
7747
- (0, import_react23.useEffect)(() => {
8084
+ (0, import_react24.useEffect)(() => {
7748
8085
  if (isExiting) {
7749
8086
  const exitTimer = setTimeout(() => {
7750
8087
  onDismiss(id);
@@ -7948,8 +8285,8 @@ function toast(data) {
7948
8285
  toast.error = (title, description) => toast({ title, description, variant: "destructive" });
7949
8286
  toast.success = (title, description) => toast({ title, description, variant: "success" });
7950
8287
  function ToastContainer() {
7951
- const [activeToasts, setActiveToasts] = (0, import_react23.useState)([]);
7952
- (0, import_react23.useEffect)(() => {
8288
+ const [activeToasts, setActiveToasts] = (0, import_react24.useState)([]);
8289
+ (0, import_react24.useEffect)(() => {
7953
8290
  const listener = (newToasts) => {
7954
8291
  setActiveToasts(newToasts);
7955
8292
  };
@@ -7961,7 +8298,7 @@ function ToastContainer() {
7961
8298
  }
7962
8299
  };
7963
8300
  }, []);
7964
- const handleDismiss = (0, import_react23.useCallback)((id) => {
8301
+ const handleDismiss = (0, import_react24.useCallback)((id) => {
7965
8302
  toasts = toasts.filter((t) => t.id !== id);
7966
8303
  notifyListeners();
7967
8304
  }, []);
@@ -7998,7 +8335,7 @@ function ToastContainer() {
7998
8335
  }
7999
8336
 
8000
8337
  // src/widget/components/TokenSwipePill.tsx
8001
- var import_react24 = __toESM(require("react"), 1);
8338
+ var import_react25 = __toESM(require("react"), 1);
8002
8339
  var import_jsx_runtime12 = require("react/jsx-runtime");
8003
8340
  var MAX_VISIBLE_DOTS = 5;
8004
8341
  function TokenSwipePill({
@@ -8010,10 +8347,10 @@ function TokenSwipePill({
8010
8347
  walletAddress,
8011
8348
  style
8012
8349
  }) {
8013
- const [isDragging, setIsDragging] = (0, import_react24.useState)(false);
8014
- const [dragOffset, setDragOffset] = (0, import_react24.useState)(0);
8015
- const startXRef = (0, import_react24.useRef)(0);
8016
- const containerRef = (0, import_react24.useRef)(null);
8350
+ const [isDragging, setIsDragging] = (0, import_react25.useState)(false);
8351
+ const [dragOffset, setDragOffset] = (0, import_react25.useState)(0);
8352
+ const startXRef = (0, import_react25.useRef)(0);
8353
+ const containerRef = (0, import_react25.useRef)(null);
8017
8354
  const currentIndex = tokens.findIndex(
8018
8355
  (t) => normalizeAddress2(
8019
8356
  t.address,
@@ -8034,11 +8371,11 @@ function TokenSwipePill({
8034
8371
  }
8035
8372
  return pos;
8036
8373
  };
8037
- const handleDragStart = (0, import_react24.useCallback)((clientX) => {
8374
+ const handleDragStart = (0, import_react25.useCallback)((clientX) => {
8038
8375
  setIsDragging(true);
8039
8376
  startXRef.current = clientX;
8040
8377
  }, []);
8041
- const handleDragMove = (0, import_react24.useCallback)(
8378
+ const handleDragMove = (0, import_react25.useCallback)(
8042
8379
  (clientX) => {
8043
8380
  if (!isDragging) return;
8044
8381
  const delta = startXRef.current - clientX;
@@ -8046,7 +8383,7 @@ function TokenSwipePill({
8046
8383
  },
8047
8384
  [isDragging]
8048
8385
  );
8049
- const handleDragEnd = (0, import_react24.useCallback)(() => {
8386
+ const handleDragEnd = (0, import_react25.useCallback)(() => {
8050
8387
  if (!isDragging) return;
8051
8388
  setIsDragging(false);
8052
8389
  if (Math.abs(dragOffset) > swipeThreshold) {
@@ -8064,13 +8401,13 @@ function TokenSwipePill({
8064
8401
  e2.preventDefault();
8065
8402
  handleDragStart(e2.clientX);
8066
8403
  };
8067
- const handleMouseMove = (0, import_react24.useCallback)(
8404
+ const handleMouseMove = (0, import_react25.useCallback)(
8068
8405
  (e2) => {
8069
8406
  handleDragMove(e2.clientX);
8070
8407
  },
8071
8408
  [handleDragMove]
8072
8409
  );
8073
- const handleMouseUp = (0, import_react24.useCallback)(() => {
8410
+ const handleMouseUp = (0, import_react25.useCallback)(() => {
8074
8411
  handleDragEnd();
8075
8412
  }, [handleDragEnd]);
8076
8413
  const handleTouchStart = (e2) => {
@@ -8084,7 +8421,7 @@ function TokenSwipePill({
8084
8421
  const handleTouchEnd = () => {
8085
8422
  handleDragEnd();
8086
8423
  };
8087
- (0, import_react24.useEffect)(() => {
8424
+ (0, import_react25.useEffect)(() => {
8088
8425
  if (isDragging) {
8089
8426
  window.addEventListener("mousemove", handleMouseMove);
8090
8427
  window.addEventListener("mouseup", handleMouseUp);
@@ -8098,7 +8435,7 @@ function TokenSwipePill({
8098
8435
  const getChainInitials = (chain) => {
8099
8436
  return chain?.slice(0, 2).toUpperCase();
8100
8437
  };
8101
- const chainBadge = (0, import_react24.useMemo)(() => {
8438
+ const chainBadge = (0, import_react25.useMemo)(() => {
8102
8439
  const url = selectedToken.chainData?.chainIconURI || selectedToken.chainData?.iconUrl;
8103
8440
  return url?.toString();
8104
8441
  }, [selectedToken]);
@@ -8384,7 +8721,7 @@ function TokenSwipePill({
8384
8721
  const token = tokens[index];
8385
8722
  const prevIndex = uniqueIndices[i - 1];
8386
8723
  const showGap = i > 0 && index - prevIndex > 1;
8387
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react24.default.Fragment, { children: [
8724
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react25.default.Fragment, { children: [
8388
8725
  showGap && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
8389
8726
  "span",
8390
8727
  {
@@ -8566,7 +8903,7 @@ function TokenSwipePill({
8566
8903
  }
8567
8904
 
8568
8905
  // src/widget/components/TransactionSteps.tsx
8569
- var import_react25 = require("react");
8906
+ var import_react26 = require("react");
8570
8907
  var import_jsx_runtime13 = require("react/jsx-runtime");
8571
8908
  var DEFAULT_LABELS = {
8572
8909
  confirming: "Confirming in wallet",
@@ -8606,14 +8943,14 @@ function TransactionSteps({
8606
8943
  style,
8607
8944
  stepLabels
8608
8945
  }) {
8609
- const labels = (0, import_react25.useMemo)(
8946
+ const labels = (0, import_react26.useMemo)(
8610
8947
  () => ({
8611
8948
  ...DEFAULT_LABELS,
8612
8949
  ...stepLabels
8613
8950
  }),
8614
8951
  [stepLabels]
8615
8952
  );
8616
- const steps = (0, import_react25.useMemo)(
8953
+ const steps = (0, import_react26.useMemo)(
8617
8954
  () => getSteps(transactionStatus, labels),
8618
8955
  [transactionStatus, labels]
8619
8956
  );
@@ -8772,7 +9109,7 @@ function TransactionSteps({
8772
9109
  }
8773
9110
 
8774
9111
  // src/widget/components/WidgetContainer.tsx
8775
- var import_react26 = require("react");
9112
+ var import_react27 = require("react");
8776
9113
  var import_jsx_runtime14 = require("react/jsx-runtime");
8777
9114
  var INJECTED_STYLES = ALL_THEME_STYLES + ALL_ANIMATION_STYLES;
8778
9115
  function WidgetContainer({
@@ -8781,8 +9118,8 @@ function WidgetContainer({
8781
9118
  className,
8782
9119
  style
8783
9120
  }) {
8784
- const [resolvedTheme, setResolvedTheme] = (0, import_react26.useState)("light");
8785
- (0, import_react26.useEffect)(() => {
9121
+ const [resolvedTheme, setResolvedTheme] = (0, import_react27.useState)("light");
9122
+ (0, import_react27.useEffect)(() => {
8786
9123
  if (theme === "system") {
8787
9124
  const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
8788
9125
  setResolvedTheme(mediaQuery.matches ? "dark" : "light");
@@ -9026,7 +9363,7 @@ function WidgetSecurityFooter({
9026
9363
  }
9027
9364
 
9028
9365
  // src/widget/components/ImageLoader.tsx
9029
- var import_react27 = require("react");
9366
+ var import_react28 = require("react");
9030
9367
  var import_jsx_runtime17 = require("react/jsx-runtime");
9031
9368
  function Skeleton({
9032
9369
  background,
@@ -9056,12 +9393,12 @@ function ImageLoader({
9056
9393
  onLoad,
9057
9394
  onError
9058
9395
  }) {
9059
- const [status, setStatus] = (0, import_react27.useState)("idle");
9060
- const [attempt, setAttempt] = (0, import_react27.useState)(0);
9061
- const [srcIsEmpty, setSrcIsEmpty] = (0, import_react27.useState)(false);
9062
- const imgRef = (0, import_react27.useRef)(null);
9063
- const observerRef = (0, import_react27.useRef)(null);
9064
- (0, import_react27.useEffect)(() => {
9396
+ const [status, setStatus] = (0, import_react28.useState)("idle");
9397
+ const [attempt, setAttempt] = (0, import_react28.useState)(0);
9398
+ const [srcIsEmpty, setSrcIsEmpty] = (0, import_react28.useState)(false);
9399
+ const imgRef = (0, import_react28.useRef)(null);
9400
+ const observerRef = (0, import_react28.useRef)(null);
9401
+ (0, import_react28.useEffect)(() => {
9065
9402
  if (status === "error" && attempt < retry) {
9066
9403
  const timer = setTimeout(() => {
9067
9404
  setAttempt((prev) => prev + 1);
@@ -9087,7 +9424,7 @@ function ImageLoader({
9087
9424
  onError?.();
9088
9425
  };
9089
9426
  };
9090
- (0, import_react27.useEffect)(() => {
9427
+ (0, import_react28.useEffect)(() => {
9091
9428
  if (!lazy2) {
9092
9429
  setTimeout(() => {
9093
9430
  loadImage();
@@ -9110,7 +9447,7 @@ function ImageLoader({
9110
9447
  }
9111
9448
  return () => observerRef.current?.disconnect();
9112
9449
  }, [lazy2, src, loadImage]);
9113
- const showFallback = (0, import_react27.useMemo)(() => {
9450
+ const showFallback = (0, import_react28.useMemo)(() => {
9114
9451
  return (status === "error" && attempt >= retry || srcIsEmpty) && Fallback;
9115
9452
  }, [status, attempt, retry, srcIsEmpty, Fallback]);
9116
9453
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ref: imgRef, style: { position: "relative" }, children: [
@@ -9346,7 +9683,7 @@ function InitErrorOverlay({
9346
9683
  }
9347
9684
 
9348
9685
  // src/widget/app/WidgetRouter.tsx
9349
- var import_react39 = require("react");
9686
+ var import_react40 = require("react");
9350
9687
 
9351
9688
  // src/widget/helpers/tokenAmount.ts
9352
9689
  function rawToDecimal(rawAmount, decimals) {
@@ -10598,7 +10935,7 @@ function TokenSelectorPanel({
10598
10935
  }
10599
10936
 
10600
10937
  // src/widget/features/token-selection/hooks/useOrderedWalletTokens.ts
10601
- var import_react28 = require("react");
10938
+ var import_react29 = require("react");
10602
10939
  function useOrderedWalletTokens({
10603
10940
  amount,
10604
10941
  amountInputMode,
@@ -10607,7 +10944,7 @@ function useOrderedWalletTokens({
10607
10944
  setSelectedToken,
10608
10945
  yourWalletTokens
10609
10946
  }) {
10610
- const handleTokenChange = (0, import_react28.useCallback)(
10947
+ const handleTokenChange = (0, import_react29.useCallback)(
10611
10948
  async (token) => {
10612
10949
  if (token) {
10613
10950
  setSelectedToken(token);
@@ -10616,7 +10953,7 @@ function useOrderedWalletTokens({
10616
10953
  },
10617
10954
  [setSelectedChain, setSelectedToken]
10618
10955
  );
10619
- const orderedTokens = (0, import_react28.useMemo)(() => {
10956
+ const orderedTokens = (0, import_react29.useMemo)(() => {
10620
10957
  const selectedTokenChainType = selectedToken?.chainData?.type ?? selectedToken?.chainData?.chainType;
10621
10958
  const index = yourWalletTokens.findIndex(
10622
10959
  (token) => normalizeAddress2(
@@ -10685,7 +11022,7 @@ function filterTokenAmountCompatibleTokens(tokens, parsedAmount) {
10685
11022
  }
10686
11023
 
10687
11024
  // src/widget/features/token-selection/hooks/useSelectTokenModel.ts
10688
- var import_react29 = require("react");
11025
+ var import_react30 = require("react");
10689
11026
  function useSelectTokenModel({
10690
11027
  goBack,
10691
11028
  searchQuery,
@@ -10709,7 +11046,7 @@ function useSelectTokenModel({
10709
11046
  explorerUrl: chain.blockExplorerUrls?.[0]
10710
11047
  });
10711
11048
  };
10712
- const handleTokenSelect = (0, import_react29.useCallback)(
11049
+ const handleTokenSelect = (0, import_react30.useCallback)(
10713
11050
  async (token) => {
10714
11051
  if (token.balance !== void 0) {
10715
11052
  setSelectedToken(token);
@@ -10733,7 +11070,7 @@ function useSelectTokenModel({
10733
11070
  },
10734
11071
  [goBack, selectedChain, setSelectedToken, walletAddress]
10735
11072
  );
10736
- const handleYourTokenSelect = (0, import_react29.useCallback)(
11073
+ const handleYourTokenSelect = (0, import_react30.useCallback)(
10737
11074
  (token) => {
10738
11075
  setSelectedToken(token);
10739
11076
  setSelectedChain(token.chainData);
@@ -10755,7 +11092,7 @@ function useSelectTokenModel({
10755
11092
  const address = token.address?.toLowerCase() ?? "";
10756
11093
  return symbol.includes(normalizedSearchQuery) || name.includes(normalizedSearchQuery) || address.includes(normalizedSearchQuery);
10757
11094
  };
10758
- const filteredWalletTokens = (0, import_react29.useMemo)(() => {
11095
+ const filteredWalletTokens = (0, import_react30.useMemo)(() => {
10759
11096
  if (!selectedChain?.chainId) {
10760
11097
  return [];
10761
11098
  }
@@ -11227,7 +11564,7 @@ function CryptoPayAmountSection({
11227
11564
  }
11228
11565
 
11229
11566
  // src/widget/features/amount/hooks/useDepositAmountModel.ts
11230
- var import_react30 = require("react");
11567
+ var import_react31 = require("react");
11231
11568
  var BALANCE_TOLERANCE = 1e-9;
11232
11569
  function useDepositAmountModel({
11233
11570
  amount,
@@ -11242,14 +11579,14 @@ function useDepositAmountModel({
11242
11579
  }) {
11243
11580
  const tokenPriceUSD = typeof selectedToken?.usdPrice === "number" && Number.isFinite(selectedToken.usdPrice) && selectedToken.usdPrice > 0 ? selectedToken.usdPrice : 0;
11244
11581
  const hasUsdPrice = typeof tokenPriceUSD === "number" && Number.isFinite(tokenPriceUSD) && tokenPriceUSD > 0;
11245
- const normalizedTokenBalance = (0, import_react30.useMemo)(() => {
11582
+ const normalizedTokenBalance = (0, import_react31.useMemo)(() => {
11246
11583
  if (!selectedToken?.balance) return 0;
11247
11584
  const normalized = Number(
11248
11585
  rawToDecimal(selectedToken.balance, selectedToken.decimals ?? 18)
11249
11586
  );
11250
11587
  return Number.isFinite(normalized) ? normalized : 0;
11251
11588
  }, [selectedToken?.balance, selectedToken?.decimals]);
11252
- (0, import_react30.useEffect)(() => {
11589
+ (0, import_react31.useEffect)(() => {
11253
11590
  if (fixedFromAmountString) return;
11254
11591
  if (isReady && !hasUsdPrice && amountInputMode === "usd") {
11255
11592
  setAmountInputMode("token");
@@ -11261,7 +11598,7 @@ function useDepositAmountModel({
11261
11598
  isReady,
11262
11599
  setAmountInputMode
11263
11600
  ]);
11264
- (0, import_react30.useEffect)(() => {
11601
+ (0, import_react31.useEffect)(() => {
11265
11602
  if (!fixedFromAmountString) return;
11266
11603
  if (amount !== fixedFromAmountString) {
11267
11604
  setAmount(fixedFromAmountString);
@@ -11276,7 +11613,7 @@ function useDepositAmountModel({
11276
11613
  setAmount,
11277
11614
  setAmountInputMode
11278
11615
  ]);
11279
- const amountComputation = (0, import_react30.useMemo)(() => {
11616
+ const amountComputation = (0, import_react31.useMemo)(() => {
11280
11617
  const rawAmount = (fixedFromAmountString ?? amount)?.trim();
11281
11618
  if (!rawAmount) {
11282
11619
  return {
@@ -11343,11 +11680,11 @@ function useDepositAmountModel({
11343
11680
  selectedToken?.decimals,
11344
11681
  tokenPriceUSD
11345
11682
  ]);
11346
- const requestedTokenAmount = (0, import_react30.useMemo)(() => {
11683
+ const requestedTokenAmount = (0, import_react31.useMemo)(() => {
11347
11684
  const tokenAmount = Number(amountComputation.tokenAmount);
11348
11685
  return Number.isFinite(tokenAmount) ? tokenAmount : 0;
11349
11686
  }, [amountComputation.tokenAmount]);
11350
- const amountValidationError = (0, import_react30.useMemo)(() => {
11687
+ const amountValidationError = (0, import_react31.useMemo)(() => {
11351
11688
  if (amountComputation.parseError) {
11352
11689
  return amountComputation.parseError;
11353
11690
  }
@@ -11380,15 +11717,15 @@ function useDepositAmountModel({
11380
11717
  ]);
11381
11718
  const amountWei = amountValidationError ? 0n : amountComputation.fromAmountWei ?? 0n;
11382
11719
  const parsedAmount = parseFloat(fixedFromAmountString ?? amount) || 0;
11383
- const maxTokenAmount = (0, import_react30.useMemo)(
11720
+ const maxTokenAmount = (0, import_react31.useMemo)(
11384
11721
  () => Math.min(normalizedTokenBalance, 1e4),
11385
11722
  [normalizedTokenBalance]
11386
11723
  );
11387
- const maxUsdAmount = (0, import_react30.useMemo)(() => {
11724
+ const maxUsdAmount = (0, import_react31.useMemo)(() => {
11388
11725
  if (!hasUsdPrice) return void 0;
11389
11726
  return Math.min(maxTokenAmount * tokenPriceUSD, 1e4);
11390
11727
  }, [hasUsdPrice, maxTokenAmount, tokenPriceUSD]);
11391
- const minAmountForMode = (0, import_react30.useMemo)(() => {
11728
+ const minAmountForMode = (0, import_react31.useMemo)(() => {
11392
11729
  if (minAmountUsd == null) return 0;
11393
11730
  if (amountInputMode === "usd") {
11394
11731
  return minAmountUsd;
@@ -11397,11 +11734,11 @@ function useDepositAmountModel({
11397
11734
  return minAmountUsd / tokenPriceUSD;
11398
11735
  }, [amountInputMode, hasUsdPrice, minAmountUsd, tokenPriceUSD]);
11399
11736
  const sliderMax = amountInputMode === "usd" ? maxUsdAmount : maxTokenAmount;
11400
- const effectiveSliderMax = (0, import_react30.useMemo)(() => {
11737
+ const effectiveSliderMax = (0, import_react31.useMemo)(() => {
11401
11738
  if (sliderMax == null || !Number.isFinite(sliderMax)) return void 0;
11402
11739
  return Math.max(sliderMax, 0);
11403
11740
  }, [sliderMax]);
11404
- const effectiveSliderMin = (0, import_react30.useMemo)(() => {
11741
+ const effectiveSliderMin = (0, import_react31.useMemo)(() => {
11405
11742
  if (effectiveSliderMax == null || !Number.isFinite(effectiveSliderMax) || effectiveSliderMax <= 0) {
11406
11743
  return 0;
11407
11744
  }
@@ -11428,7 +11765,7 @@ function useDepositAmountModel({
11428
11765
  }
11429
11766
 
11430
11767
  // src/widget/features/amount/hooks/useHomeAmountModel.ts
11431
- var import_react31 = require("react");
11768
+ var import_react32 = require("react");
11432
11769
  function useHomeAmountModel({
11433
11770
  amount,
11434
11771
  setAmount,
@@ -11439,7 +11776,7 @@ function useHomeAmountModel({
11439
11776
  minAmountUsd,
11440
11777
  maxAmountUsd
11441
11778
  }) {
11442
- (0, import_react31.useEffect)(() => {
11779
+ (0, import_react32.useEffect)(() => {
11443
11780
  if (!fixedFromAmountString) return;
11444
11781
  if (amount !== fixedFromAmountString) {
11445
11782
  setAmount(fixedFromAmountString);
@@ -11455,7 +11792,7 @@ function useHomeAmountModel({
11455
11792
  setAmountInputMode
11456
11793
  ]);
11457
11794
  const parsedAmount = parseFloat(fixedFromAmountString ?? amount) || 0;
11458
- const amountValidationMessage = (0, import_react31.useMemo)(() => {
11795
+ const amountValidationMessage = (0, import_react32.useMemo)(() => {
11459
11796
  const rawAmount = (fixedFromAmountString ?? amount)?.trim();
11460
11797
  if (!rawAmount) return null;
11461
11798
  if (!/^\d*\.?\d*$/.test(rawAmount)) {
@@ -11667,7 +12004,7 @@ function WalletConnectRow({
11667
12004
  PaymentOptionRow,
11668
12005
  {
11669
12006
  onClick: () => void onClick(),
11670
- label: "WalletConnect",
12007
+ label: "WalletConnect(EVM)",
11671
12008
  icon: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { style: walletActionIconBoxStyle, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
11672
12009
  "svg",
11673
12010
  {
@@ -12180,152 +12517,20 @@ function HomePaymentOptions({
12180
12517
  }
12181
12518
 
12182
12519
  // src/widget/features/wallet/hooks/useHomeWalletActions.ts
12183
- var import_react32 = require("react");
12184
-
12185
- // src/config/walletconnect.ts
12186
- var import_appkit_universal_connector = require("@reown/appkit-universal-connector");
12187
- init_store();
12188
- init_constants();
12189
- var solanaMainnet = {
12190
- id: 1,
12191
- chainNamespace: "solana",
12192
- caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqAQ3H1FQ",
12193
- name: "Solana Mainnet",
12194
- nativeCurrency: {
12195
- name: "Solana",
12196
- symbol: "SOL",
12197
- decimals: 9
12198
- },
12199
- rpcUrls: {
12200
- default: {
12201
- http: ["https://api.mainnet-beta.solana.com"]
12202
- }
12203
- }
12204
- };
12205
- var bitcoinMainnet = {
12206
- id: 0,
12207
- chainNamespace: "bip122",
12208
- caipNetworkId: "bip122:000000000019d6689c085ae165831e93",
12209
- name: "Bitcoin Mainnet",
12210
- nativeCurrency: {
12211
- name: "Bitcoin",
12212
- symbol: "BTC",
12213
- decimals: 8
12214
- },
12215
- rpcUrls: {
12216
- default: {
12217
- http: ["https://api.blockcypher.com/v1/btc/main"]
12218
- }
12219
- }
12220
- };
12221
- var ethereumMainnet = {
12222
- id: 1,
12223
- chainNamespace: "eip155",
12224
- caipNetworkId: "eip155:1",
12225
- name: "Ethereum Mainnet",
12226
- nativeCurrency: {
12227
- name: "Ether",
12228
- symbol: "ETH",
12229
- decimals: 18
12230
- },
12231
- rpcUrls: {
12232
- default: {
12233
- http: ["https://rpc.ankr.com/eth"]
12234
- }
12235
- }
12236
- };
12237
- var seiMainnet = {
12238
- id: 1329,
12239
- chainNamespace: "eip155",
12240
- caipNetworkId: "eip155:1329",
12241
- name: "Sei Mainnet",
12242
- nativeCurrency: {
12243
- name: "Sei",
12244
- symbol: "SEI",
12245
- decimals: 18
12246
- },
12247
- rpcUrls: {
12248
- default: {
12249
- http: ["https://evm-rpc.sei-apis.com"]
12250
- }
12251
- }
12252
- };
12253
- var universalConnectorPromise = null;
12254
- function resolvedMetadata() {
12255
- const cfg = TrustwareConfigStore.peek();
12256
- const walletConnect = cfg ? cfg?.walletConnect : void 0;
12257
- const configured = walletConnect?.metadata;
12258
- const pageUrl = typeof window !== "undefined" && window.location?.origin ? window.location.origin : configured?.url;
12259
- return {
12260
- name: configured?.name ?? "Trustware",
12261
- description: configured?.description ?? "Cross-chain bridge & top-up",
12262
- url: pageUrl ?? "https://trustware.io",
12263
- icons: configured?.icons?.length ? configured.icons : ["https://app.trustware.io/icon.png"]
12264
- };
12265
- }
12266
- async function getUniversalConnector(walletCfg) {
12267
- const projectId = walletCfg?.projectId ?? WALLETCONNECT_PROJECT_ID;
12268
- if (!projectId) {
12269
- console.warn(
12270
- "[Trustware SDK] WalletConnect disabled: no projectId. Set TRUSTWARE_WALLETCONNECT_PROJECT_ID at build time or pass walletConnect.projectId in config."
12271
- );
12272
- return void 0;
12273
- }
12274
- if (!universalConnectorPromise) {
12275
- universalConnectorPromise = import_appkit_universal_connector.UniversalConnector.init({
12276
- projectId,
12277
- metadata: resolvedMetadata(),
12278
- networks: [
12279
- {
12280
- namespace: "solana",
12281
- chains: [solanaMainnet],
12282
- methods: ["solana_signMessage", "solana_signTransaction"],
12283
- events: []
12284
- },
12285
- {
12286
- namespace: "eip155",
12287
- chains: [ethereumMainnet, seiMainnet],
12288
- methods: ["eth_sendTransaction", "eth_sign", "personal_sign"],
12289
- events: ["accountsChanged", "chainChanged"]
12290
- },
12291
- {
12292
- namespace: "bip122",
12293
- chains: [bitcoinMainnet],
12294
- methods: ["btc_signMessage"],
12295
- events: []
12296
- }
12297
- ]
12298
- }).catch((error) => {
12299
- universalConnectorPromise = null;
12300
- throw error;
12301
- });
12302
- }
12303
- return universalConnectorPromise;
12304
- }
12305
-
12306
- // src/widget/features/wallet/hooks/useHomeWalletActions.ts
12307
- init_config2();
12520
+ var import_react33 = require("react");
12308
12521
  function useHomeWalletActions({
12309
12522
  connectWallet,
12310
12523
  detectedWallets,
12311
- setCurrentStep
12524
+ setCurrentStep,
12525
+ setWalletType,
12526
+ WalletConnect
12312
12527
  // setCurrentStepInternal,
12313
12528
  }) {
12314
- const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = (0, import_react32.useState)(false);
12315
- const [isFiatDropdownOpen, setIsFiatDropdownOpen] = (0, import_react32.useState)(false);
12316
- const [universalConnector, setUniversalConnector] = (0, import_react32.useState)();
12317
- const cryptoDropdownRef = (0, import_react32.useRef)(null);
12318
- const fiatDropdownRef = (0, import_react32.useRef)(null);
12319
- (0, import_react32.useEffect)(() => {
12320
- if (typeof window === "undefined") {
12321
- return;
12322
- }
12323
- const walletConnect = TrustwareConfigStore.peek()?.walletConnect;
12324
- getUniversalConnector(walletConnect).then(
12325
- setUniversalConnector
12326
- );
12327
- }, [TrustwareConfigStore.peek()?.walletConnect]);
12328
- (0, import_react32.useEffect)(() => {
12529
+ const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = (0, import_react33.useState)(false);
12530
+ const [isFiatDropdownOpen, setIsFiatDropdownOpen] = (0, import_react33.useState)(false);
12531
+ const cryptoDropdownRef = (0, import_react33.useRef)(null);
12532
+ const fiatDropdownRef = (0, import_react33.useRef)(null);
12533
+ (0, import_react33.useEffect)(() => {
12329
12534
  const handleClickOutside = (event) => {
12330
12535
  if (cryptoDropdownRef.current && !cryptoDropdownRef.current.contains(event.target)) {
12331
12536
  setIsCryptoDropdownOpen(false);
@@ -12341,6 +12546,7 @@ function useHomeWalletActions({
12341
12546
  const handleWalletSelect = async (wallet) => {
12342
12547
  setIsCryptoDropdownOpen(false);
12343
12548
  try {
12549
+ setWalletType("other");
12344
12550
  const { error } = await connectWallet(wallet);
12345
12551
  if (error) {
12346
12552
  resetNavigation();
@@ -12355,13 +12561,7 @@ function useHomeWalletActions({
12355
12561
  setIsFiatDropdownOpen(false);
12356
12562
  };
12357
12563
  const handleWalletConnect = async () => {
12358
- if (!universalConnector) {
12359
- return;
12360
- }
12361
- const { session: providerSession } = await universalConnector.connect();
12362
- if (providerSession) {
12363
- setCurrentStep("select-token");
12364
- }
12564
+ WalletConnect().catch(() => resetNavigation());
12365
12565
  };
12366
12566
  const browserWallets = detectedWallets.filter(
12367
12567
  (wallet) => wallet.meta.id !== "walletconnect"
@@ -12385,7 +12585,7 @@ var import_jsx_runtime42 = require("react/jsx-runtime");
12385
12585
  function Home({ style: _style }) {
12386
12586
  const { amount, setAmount, amountInputMode, setAmountInputMode } = useDepositForm();
12387
12587
  const { setCurrentStep, setCurrentStepInternal } = useDepositNavigation();
12388
- const { connectWallet } = useDepositWallet();
12588
+ const { connectWallet, WalletConnect, setWalletType } = useDepositWallet();
12389
12589
  const { resolvedTheme } = useDepositUi();
12390
12590
  const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
12391
12591
  const { detected: detectedWallets } = useWalletDetection();
@@ -12414,7 +12614,9 @@ function Home({ style: _style }) {
12414
12614
  connectWallet,
12415
12615
  detectedWallets,
12416
12616
  setCurrentStep,
12417
- setCurrentStepInternal
12617
+ setCurrentStepInternal,
12618
+ WalletConnect,
12619
+ setWalletType
12418
12620
  });
12419
12621
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
12420
12622
  "div",
@@ -12695,10 +12897,10 @@ function SelectToken({ style }) {
12695
12897
  }
12696
12898
 
12697
12899
  // src/widget/pages/CryptoPay/index.tsx
12698
- var import_react35 = require("react");
12900
+ var import_react36 = require("react");
12699
12901
 
12700
12902
  // src/widget/features/route-preview/hooks/useRoutePreviewModel.ts
12701
- var import_react33 = require("react");
12903
+ var import_react34 = require("react");
12702
12904
  function useRoutePreviewModel({
12703
12905
  amountUsd,
12704
12906
  amountValidationError,
@@ -12711,7 +12913,8 @@ function useRoutePreviewModel({
12711
12913
  walletAddress
12712
12914
  }) {
12713
12915
  const { chains } = useChains();
12714
- const destinationConfig = (0, import_react33.useMemo)(
12916
+ console.log({ walletAddress });
12917
+ const destinationConfig = (0, import_react34.useMemo)(
12715
12918
  () => ({
12716
12919
  dappName: config.messages?.title || "DApp",
12717
12920
  toChain: config.routes.toChain,
@@ -12725,7 +12928,7 @@ function useRoutePreviewModel({
12725
12928
  config.routes.toToken
12726
12929
  ]
12727
12930
  );
12728
- const routeConfig = (0, import_react33.useMemo)(() => {
12931
+ const routeConfig = (0, import_react34.useMemo)(() => {
12729
12932
  const toChainId = config.routes.toChain;
12730
12933
  const toChainKey = normalizeChainKey2(toChainId);
12731
12934
  const toChain = toChainKey ? chains.find(
@@ -12759,7 +12962,7 @@ function useRoutePreviewModel({
12759
12962
  walletAddress
12760
12963
  ]);
12761
12964
  const routeBuilderState = useRouteBuilder(routeConfig);
12762
- const routePrerequisiteError = (0, import_react33.useMemo)(() => {
12965
+ const routePrerequisiteError = (0, import_react34.useMemo)(() => {
12763
12966
  if (!isReady) return;
12764
12967
  if (!selectedChain) {
12765
12968
  return "Select a source chain to fetch a route.";
@@ -13198,7 +13401,7 @@ function SuccessSummaryCard({
13198
13401
  }
13199
13402
 
13200
13403
  // src/widget/features/transaction/hooks/useTransactionActionModel.ts
13201
- var import_react34 = require("react");
13404
+ var import_react35 = require("react");
13202
13405
  var import_viem2 = require("viem");
13203
13406
  init_constants();
13204
13407
  function normalizeTokenAddressForCompare(chain, addr) {
@@ -13221,7 +13424,7 @@ function useTransactionActionModel({
13221
13424
  walletAddress,
13222
13425
  walletStatus
13223
13426
  }) {
13224
- const feeDataCacheRef = (0, import_react34.useRef)({});
13427
+ const feeDataCacheRef = (0, import_react35.useRef)({});
13225
13428
  const { isSubmitting, submitTransaction } = useTransactionSubmit();
13226
13429
  const { trackEvent } = useGTM(GTM_ID);
13227
13430
  const destinationConfig = (() => {
@@ -13234,7 +13437,7 @@ function useTransactionActionModel({
13234
13437
  const chainType = selectedChain?.type ?? selectedChain?.chainType;
13235
13438
  const chainTypeNormalized = (chainType ?? "").toLowerCase();
13236
13439
  const isEvm = chainTypeNormalized === "evm";
13237
- const backendChainId2 = (0, import_react34.useMemo)(() => {
13440
+ const backendChainId2 = (0, import_react35.useMemo)(() => {
13238
13441
  const chainRef = routeResult?.txReq?.chainId ?? selectedChain?.networkIdentifier ?? selectedChain?.chainId ?? selectedChain?.id;
13239
13442
  if (chainRef == null) return null;
13240
13443
  return String(chainRef);
@@ -13244,23 +13447,23 @@ function useTransactionActionModel({
13244
13447
  selectedChain?.id,
13245
13448
  selectedChain?.networkIdentifier
13246
13449
  ]);
13247
- const isNativeSelected = (0, import_react34.useMemo)(() => {
13450
+ const isNativeSelected = (0, import_react35.useMemo)(() => {
13248
13451
  const address = selectedToken?.address;
13249
13452
  return isNativeTokenAddress(address, chainType) || isZeroAddrLike(address, chainType) || normalizeTokenAddressForCompare(selectedChain, address) === normalizeTokenAddressForCompare(
13250
13453
  selectedChain,
13251
13454
  getNativeTokenAddress2(chainType)
13252
13455
  );
13253
13456
  }, [chainType, selectedChain, selectedToken?.address]);
13254
- const spender = (0, import_react34.useMemo)(() => {
13457
+ const spender = (0, import_react35.useMemo)(() => {
13255
13458
  const txReq = routeResult?.txReq;
13256
13459
  const addr = txReq?.to ?? txReq?.target;
13257
13460
  return addr ?? null;
13258
13461
  }, [routeResult?.txReq]);
13259
- const [allowanceWei, setAllowanceWei] = (0, import_react34.useState)(0n);
13260
- const [isReadingAllowance, setIsReadingAllowance] = (0, import_react34.useState)(false);
13261
- const [isApproving, setIsApproving] = (0, import_react34.useState)(false);
13262
- const [gasReservationWei, setGasReservationWei] = (0, import_react34.useState)(0n);
13263
- const readAllowance = (0, import_react34.useCallback)(async () => {
13462
+ const [allowanceWei, setAllowanceWei] = (0, import_react35.useState)(0n);
13463
+ const [isReadingAllowance, setIsReadingAllowance] = (0, import_react35.useState)(false);
13464
+ const [isApproving, setIsApproving] = (0, import_react35.useState)(false);
13465
+ const [gasReservationWei, setGasReservationWei] = (0, import_react35.useState)(0n);
13466
+ const readAllowance = (0, import_react35.useCallback)(async () => {
13264
13467
  if (!isEvm || isNativeSelected || !backendChainId2 || !walletAddress || !spender || !selectedToken?.address) {
13265
13468
  setAllowanceWei(0n);
13266
13469
  return;
@@ -13287,11 +13490,11 @@ function useTransactionActionModel({
13287
13490
  spender,
13288
13491
  walletAddress
13289
13492
  ]);
13290
- (0, import_react34.useEffect)(() => {
13493
+ (0, import_react35.useEffect)(() => {
13291
13494
  void readAllowance();
13292
13495
  }, [readAllowance]);
13293
13496
  const needsApproval = isEvm && !isNativeSelected && !!walletAddress && !!spender && amountWei > 0n && allowanceWei < amountWei;
13294
- const waitForApprovalConfirmation = (0, import_react34.useCallback)(
13497
+ const waitForApprovalConfirmation = (0, import_react35.useCallback)(
13295
13498
  async (chainId, txHash) => {
13296
13499
  const timeoutMs = 12e4;
13297
13500
  const intervalMs = 2e3;
@@ -13310,7 +13513,7 @@ function useTransactionActionModel({
13310
13513
  },
13311
13514
  []
13312
13515
  );
13313
- const handleApproveExact = (0, import_react34.useCallback)(async () => {
13516
+ const handleApproveExact = (0, import_react35.useCallback)(async () => {
13314
13517
  if (isApproving || amountWei <= 0n || !walletAddress || !spender || !selectedToken?.address) {
13315
13518
  return;
13316
13519
  }
@@ -13398,7 +13601,7 @@ function useTransactionActionModel({
13398
13601
  waitForApprovalConfirmation,
13399
13602
  walletAddress
13400
13603
  ]);
13401
- const getCachedFeeData = (0, import_react34.useCallback)(async () => {
13604
+ const getCachedFeeData = (0, import_react35.useCallback)(async () => {
13402
13605
  if (!backendChainId2) return {};
13403
13606
  const now = Date.now();
13404
13607
  const cache = feeDataCacheRef.current;
@@ -13421,7 +13624,7 @@ function useTransactionActionModel({
13421
13624
  }
13422
13625
  return cache.inflight;
13423
13626
  }, [backendChainId2]);
13424
- const estimateGasReservationWei = (0, import_react34.useCallback)(async () => {
13627
+ const estimateGasReservationWei = (0, import_react35.useCallback)(async () => {
13425
13628
  if (!isNativeSelected) {
13426
13629
  setGasReservationWei(0n);
13427
13630
  return 0n;
@@ -13485,12 +13688,12 @@ function useTransactionActionModel({
13485
13688
  routeResult?.txReq,
13486
13689
  walletAddress
13487
13690
  ]);
13488
- (0, import_react34.useEffect)(() => {
13691
+ (0, import_react35.useEffect)(() => {
13489
13692
  if (routeResult) {
13490
13693
  void estimateGasReservationWei();
13491
13694
  }
13492
13695
  }, [estimateGasReservationWei, routeResult]);
13493
- const handleConfirm = (0, import_react34.useCallback)(async () => {
13696
+ const handleConfirm = (0, import_react35.useCallback)(async () => {
13494
13697
  if (!routeResult) {
13495
13698
  return;
13496
13699
  }
@@ -13513,7 +13716,7 @@ function useTransactionActionModel({
13513
13716
  submitTransaction,
13514
13717
  trackEvent
13515
13718
  ]);
13516
- const handleSwipeConfirm = (0, import_react34.useCallback)(async () => {
13719
+ const handleSwipeConfirm = (0, import_react35.useCallback)(async () => {
13517
13720
  if (needsApproval) {
13518
13721
  await handleApproveExact();
13519
13722
  return;
@@ -13522,7 +13725,7 @@ function useTransactionActionModel({
13522
13725
  }, [handleApproveExact, handleConfirm, needsApproval]);
13523
13726
  const isWalletConnected = walletStatus === "connected";
13524
13727
  const canSwipe = parsedAmount > 0 && !!selectedToken && isWalletConnected && !isLoadingRoute && !isSubmitting && !!routeResult && !actionErrorMessage && !isApproving && !isReadingAllowance;
13525
- const swipeResetKey = (0, import_react34.useMemo)(() => {
13728
+ const swipeResetKey = (0, import_react35.useMemo)(() => {
13526
13729
  const tokenAddress = selectedToken ? normalizeAddress2(
13527
13730
  selectedToken.address,
13528
13731
  selectedToken?.chainData?.type ?? selectedToken?.chainData?.chainType
@@ -13736,6 +13939,7 @@ function CryptoPay({ style: _style }) {
13736
13939
  } = useDepositForm();
13737
13940
  const {
13738
13941
  walletAddress,
13942
+ walletType,
13739
13943
  walletStatus,
13740
13944
  yourWalletTokens,
13741
13945
  yourWalletTokensLoading
@@ -13743,17 +13947,17 @@ function CryptoPay({ style: _style }) {
13743
13947
  const { goBack, setCurrentStep, currentStep } = useDepositNavigation();
13744
13948
  const config = useTrustwareConfig();
13745
13949
  const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
13746
- const routeRefreshMs = (0, import_react35.useMemo)(() => {
13950
+ const routeRefreshMs = (0, import_react36.useMemo)(() => {
13747
13951
  const raw = config.routes?.options?.routeRefreshMs;
13748
13952
  const n = Number(raw);
13749
13953
  return Number.isFinite(n) && n > 0 ? n : void 0;
13750
13954
  }, [config.routes?.options?.routeRefreshMs]);
13751
13955
  const IsPos = (x) => x !== null && x !== void 0 && x.balance !== "0";
13752
- const showDefaultCryptoPay = (0, import_react35.useMemo)(() => {
13956
+ const showDefaultCryptoPay = (0, import_react36.useMemo)(() => {
13753
13957
  const nonZer0Tks = (yourWalletTokens ?? []).filter(IsPos);
13754
13958
  return !yourWalletTokensLoading && nonZer0Tks.length === 0 && yourWalletTokens.length > 0;
13755
13959
  }, [yourWalletTokens, yourWalletTokensLoading]);
13756
- const showSkeleton = (0, import_react35.useMemo)(() => {
13960
+ const showSkeleton = (0, import_react36.useMemo)(() => {
13757
13961
  return yourWalletTokensLoading || (yourWalletTokens ?? []).length === 0;
13758
13962
  }, [yourWalletTokens, yourWalletTokensLoading]);
13759
13963
  const isReady = !yourWalletTokensLoading && selectedToken != null && selectedToken?.chainData !== void 0 && !showDefaultCryptoPay && !showSkeleton;
@@ -13815,6 +14019,7 @@ function CryptoPay({ style: _style }) {
13815
14019
  selectedChain,
13816
14020
  selectedToken,
13817
14021
  walletAddress,
14022
+ walletType,
13818
14023
  walletStatus
13819
14024
  });
13820
14025
  const { handleTokenChange, orderedTokens } = useOrderedWalletTokens({
@@ -13827,7 +14032,7 @@ function CryptoPay({ style: _style }) {
13827
14032
  });
13828
14033
  const { emitError } = useTrustware();
13829
14034
  const readySelectedToken = isReady ? selectedToken : null;
13830
- (0, import_react35.useEffect)(() => {
14035
+ (0, import_react36.useEffect)(() => {
13831
14036
  if (currentStep !== "crypto-pay" || !actionErrorMessage) return;
13832
14037
  emitError?.(
13833
14038
  new TrustwareError({
@@ -13922,7 +14127,7 @@ function CryptoPay({ style: _style }) {
13922
14127
  isApproving,
13923
14128
  isLoadingRoute,
13924
14129
  isReadingAllowance,
13925
- isWalletConnected,
14130
+ isWalletConnected: isWalletConnected ? isWalletConnected : walletAddress !== null && walletType == "walletconnect" ? true : false,
13926
14131
  needsApproval,
13927
14132
  selectedToken: readySelectedToken,
13928
14133
  swipeResetKey
@@ -13938,7 +14143,7 @@ function CryptoPay({ style: _style }) {
13938
14143
  }
13939
14144
 
13940
14145
  // src/widget/pages/Processing.tsx
13941
- var import_react36 = require("react");
14146
+ var import_react37 = require("react");
13942
14147
  var import_jsx_runtime49 = require("react/jsx-runtime");
13943
14148
  function getProgressFromStatus(status) {
13944
14149
  switch (status) {
@@ -13977,27 +14182,27 @@ function Processing({ style }) {
13977
14182
  const { resetState, setCurrentStep } = useDepositNavigation();
13978
14183
  const { transactionStatus, transactionHash, intentId } = useDepositTransaction();
13979
14184
  const { transaction, startPolling, isPolling } = useTransactionPolling();
13980
- const hasStartedPolling = (0, import_react36.useRef)(false);
13981
- (0, import_react36.useEffect)(() => {
14185
+ const hasStartedPolling = (0, import_react37.useRef)(false);
14186
+ (0, import_react37.useEffect)(() => {
13982
14187
  return () => {
13983
14188
  hasStartedPolling.current = false;
13984
14189
  };
13985
14190
  }, []);
13986
- (0, import_react36.useEffect)(() => {
14191
+ (0, import_react37.useEffect)(() => {
13987
14192
  if (intentId && transactionHash && !isPolling && !hasStartedPolling.current && transactionStatus !== "success" && transactionStatus !== "error") {
13988
14193
  hasStartedPolling.current = true;
13989
14194
  startPolling(intentId, transactionHash);
13990
14195
  }
13991
14196
  }, [intentId, transactionHash, isPolling, transactionStatus, startPolling]);
13992
- const progress = (0, import_react36.useMemo)(
14197
+ const progress = (0, import_react37.useMemo)(
13993
14198
  () => getProgressFromStatus(transactionStatus),
13994
14199
  [transactionStatus]
13995
14200
  );
13996
- const stepText = (0, import_react36.useMemo)(
14201
+ const stepText = (0, import_react37.useMemo)(
13997
14202
  () => getStepText(transactionStatus),
13998
14203
  [transactionStatus]
13999
14204
  );
14000
- const explorerUrl = (0, import_react36.useMemo)(() => {
14205
+ const explorerUrl = (0, import_react37.useMemo)(() => {
14001
14206
  if (transaction?.fromChainTxUrl) {
14002
14207
  return transaction.fromChainTxUrl;
14003
14208
  }
@@ -14134,16 +14339,16 @@ function Processing({ style }) {
14134
14339
  }
14135
14340
 
14136
14341
  // src/widget/pages/Success.tsx
14137
- var import_react37 = require("react");
14342
+ var import_react38 = require("react");
14138
14343
  var import_jsx_runtime50 = require("react/jsx-runtime");
14139
- var ConfettiEffect2 = (0, import_react37.lazy)(() => Promise.resolve().then(() => (init_ConfettiEffect(), ConfettiEffect_exports)));
14344
+ var ConfettiEffect2 = (0, import_react38.lazy)(() => Promise.resolve().then(() => (init_ConfettiEffect(), ConfettiEffect_exports)));
14140
14345
  function Success({ style }) {
14141
14346
  const { selectedToken, selectedChain, amount } = useDepositForm();
14142
14347
  const { resetState } = useDepositNavigation();
14143
14348
  const { transactionHash } = useDepositTransaction();
14144
14349
  const { transaction } = useTransactionPolling();
14145
- const parsedAmount = (0, import_react37.useMemo)(() => parseFloat(amount) || 0, [amount]);
14146
- const explorerUrl = (0, import_react37.useMemo)(() => {
14350
+ const parsedAmount = (0, import_react38.useMemo)(() => parseFloat(amount) || 0, [amount]);
14351
+ const explorerUrl = (0, import_react38.useMemo)(() => {
14147
14352
  if (transaction?.toChainTxUrl) {
14148
14353
  return transaction.toChainTxUrl;
14149
14354
  }
@@ -14171,7 +14376,7 @@ function Success({ style }) {
14171
14376
  ...style
14172
14377
  },
14173
14378
  children: [
14174
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_react37.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ConfettiEffect2, { isActive: true, pieceCount: 60, clearDelay: 4e3 }) }),
14379
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_react38.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ConfettiEffect2, { isActive: true, pieceCount: 60, clearDelay: 4e3 }) }),
14175
14380
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(WidgetPageHeader, { title: "Deposit Complete" }),
14176
14381
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
14177
14382
  "div",
@@ -14206,7 +14411,7 @@ function Success({ style }) {
14206
14411
  }
14207
14412
 
14208
14413
  // src/widget/pages/Error.tsx
14209
- var import_react38 = require("react");
14414
+ var import_react39 = require("react");
14210
14415
  init_store();
14211
14416
  var import_jsx_runtime51 = require("react/jsx-runtime");
14212
14417
  function categorizeError(errorMessage) {
@@ -14295,20 +14500,20 @@ function Error2({ style }) {
14295
14500
  setErrorMessage,
14296
14501
  transactionHash
14297
14502
  } = useDepositTransaction();
14298
- const errorCategory = (0, import_react38.useMemo)(
14503
+ const errorCategory = (0, import_react39.useMemo)(
14299
14504
  () => categorizeError(errorMessage),
14300
14505
  [errorMessage]
14301
14506
  );
14302
- const errorTitle = (0, import_react38.useMemo)(
14507
+ const errorTitle = (0, import_react39.useMemo)(
14303
14508
  () => getErrorTitle(errorCategory),
14304
14509
  [errorCategory]
14305
14510
  );
14306
- const errorSuggestion = (0, import_react38.useMemo)(
14511
+ const errorSuggestion = (0, import_react39.useMemo)(
14307
14512
  () => getErrorSuggestion(errorCategory),
14308
14513
  [errorCategory]
14309
14514
  );
14310
- const retryStep = (0, import_react38.useMemo)(() => getRetryStep(errorCategory), [errorCategory]);
14311
- (0, import_react38.useEffect)(() => {
14515
+ const retryStep = (0, import_react39.useMemo)(() => getRetryStep(errorCategory), [errorCategory]);
14516
+ (0, import_react39.useEffect)(() => {
14312
14517
  if (errorMessage) {
14313
14518
  try {
14314
14519
  const config = TrustwareConfigStore.get();
@@ -14330,7 +14535,7 @@ function Error2({ style }) {
14330
14535
  const handleStartOver = () => {
14331
14536
  resetState();
14332
14537
  };
14333
- const explorerUrl = (0, import_react38.useMemo)(() => {
14538
+ const explorerUrl = (0, import_react39.useMemo)(() => {
14334
14539
  if (transactionHash && selectedChain?.blockExplorerUrls?.length) {
14335
14540
  return `${selectedChain.blockExplorerUrls[0].replace(/\/+$/, "")}/tx/${transactionHash}`;
14336
14541
  }
@@ -14468,11 +14673,11 @@ function WidgetRouter({
14468
14673
  navigationDirection,
14469
14674
  stepHistory
14470
14675
  }) {
14471
- const PageComponent = (0, import_react39.useMemo)(
14676
+ const PageComponent = (0, import_react40.useMemo)(
14472
14677
  () => PAGE_COMPONENTS[currentStep],
14473
14678
  [currentStep]
14474
14679
  );
14475
- const animationClass = (0, import_react39.useMemo)(() => {
14680
+ const animationClass = (0, import_react40.useMemo)(() => {
14476
14681
  return navigationDirection === "forward" ? "tw-animate-slide-in-right" : "tw-animate-slide-in-left";
14477
14682
  }, [navigationDirection]);
14478
14683
  return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
@@ -14509,7 +14714,7 @@ function WidgetContent({
14509
14714
  const { amount, selectedChain, selectedToken } = useDepositForm();
14510
14715
  const { transactionHash, transactionStatus } = useDepositTransaction();
14511
14716
  const { resolvedTheme, toggleTheme } = useDepositUi();
14512
- (0, import_react40.useEffect)(() => {
14717
+ (0, import_react41.useEffect)(() => {
14513
14718
  const state = {
14514
14719
  currentStep,
14515
14720
  amount,
@@ -14552,8 +14757,8 @@ function WidgetInner({
14552
14757
  const { transactionStatus } = useDepositTransaction();
14553
14758
  const { resolvedTheme } = useDepositUi();
14554
14759
  const { status, revalidate } = useTrustware();
14555
- const [showConfirmDialog, setShowConfirmDialog] = (0, import_react40.useState)(false);
14556
- const handleCloseRequest = (0, import_react40.useCallback)(() => {
14760
+ const [showConfirmDialog, setShowConfirmDialog] = (0, import_react41.useState)(false);
14761
+ const handleCloseRequest = (0, import_react41.useCallback)(() => {
14557
14762
  if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
14558
14763
  setShowConfirmDialog(true);
14559
14764
  } else {
@@ -14564,20 +14769,20 @@ function WidgetInner({
14564
14769
  onClose?.();
14565
14770
  }
14566
14771
  }, [transactionStatus, onClose, resetState]);
14567
- (0, import_react40.useEffect)(() => {
14772
+ (0, import_react41.useEffect)(() => {
14568
14773
  closeRequestRef.current = handleCloseRequest;
14569
14774
  }, [handleCloseRequest, closeRequestRef]);
14570
- const handleConfirmClose = (0, import_react40.useCallback)(() => {
14775
+ const handleConfirmClose = (0, import_react41.useCallback)(() => {
14571
14776
  setShowConfirmDialog(false);
14572
14777
  onClose?.();
14573
14778
  }, [onClose]);
14574
- const handleCancelClose = (0, import_react40.useCallback)(() => {
14779
+ const handleCancelClose = (0, import_react41.useCallback)(() => {
14575
14780
  setShowConfirmDialog(false);
14576
14781
  }, []);
14577
14782
  const effectiveTheme = resolvedTheme;
14578
14783
  const isRefreshing = status === "initializing";
14579
14784
  const initBlocked = status === "error";
14580
- const handleRefresh = (0, import_react40.useCallback)(() => {
14785
+ const handleRefresh = (0, import_react41.useCallback)(() => {
14581
14786
  revalidate?.();
14582
14787
  }, [revalidate]);
14583
14788
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
@@ -14610,7 +14815,7 @@ function WidgetInner({
14610
14815
  )
14611
14816
  ] });
14612
14817
  }
14613
- var TrustwareWidgetV2 = (0, import_react40.forwardRef)(function TrustwareWidgetV22({
14818
+ var TrustwareWidgetV2 = (0, import_react41.forwardRef)(function TrustwareWidgetV22({
14614
14819
  theme = "system",
14615
14820
  style,
14616
14821
  initialStep = "home",
@@ -14619,14 +14824,14 @@ var TrustwareWidgetV2 = (0, import_react40.forwardRef)(function TrustwareWidgetV
14619
14824
  onOpen,
14620
14825
  showThemeToggle = true
14621
14826
  }, ref) {
14622
- const [isOpen, setIsOpen] = (0, import_react40.useState)(defaultOpen);
14623
- const closeRequestRef = (0, import_react40.useRef)(null);
14827
+ const [isOpen, setIsOpen] = (0, import_react41.useState)(defaultOpen);
14828
+ const closeRequestRef = (0, import_react41.useRef)(null);
14624
14829
  const effectiveInitialStep = initialStep;
14625
- const open = (0, import_react40.useCallback)(() => {
14830
+ const open = (0, import_react41.useCallback)(() => {
14626
14831
  setIsOpen(true);
14627
14832
  onOpen?.();
14628
14833
  }, [onOpen]);
14629
- const close = (0, import_react40.useCallback)(() => {
14834
+ const close = (0, import_react41.useCallback)(() => {
14630
14835
  if (closeRequestRef.current) {
14631
14836
  closeRequestRef.current();
14632
14837
  } else {
@@ -14634,11 +14839,11 @@ var TrustwareWidgetV2 = (0, import_react40.forwardRef)(function TrustwareWidgetV
14634
14839
  onClose?.();
14635
14840
  }
14636
14841
  }, [onClose]);
14637
- const handleClose = (0, import_react40.useCallback)(() => {
14842
+ const handleClose = (0, import_react41.useCallback)(() => {
14638
14843
  setIsOpen(false);
14639
14844
  onClose?.();
14640
14845
  }, [onClose]);
14641
- (0, import_react40.useImperativeHandle)(
14846
+ (0, import_react41.useImperativeHandle)(
14642
14847
  ref,
14643
14848
  () => ({
14644
14849
  open,