@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.mjs CHANGED
@@ -223,7 +223,7 @@ var init_constants = __esm({
223
223
  "src/constants.ts"() {
224
224
  "use strict";
225
225
  SDK_NAME = "@trustware/sdk";
226
- SDK_VERSION = "1.1.4-staging.50";
226
+ SDK_VERSION = "1.1.5-staging.1";
227
227
  API_ROOT = "https://bv-staging-api.trustware.io";
228
228
  GTM_ID = "GTM-TZDGNCXB";
229
229
  API_PREFIX = "/api";
@@ -783,15 +783,15 @@ __export(ConfettiEffect_exports, {
783
783
  ConfettiEffect: () => ConfettiEffect,
784
784
  default: () => ConfettiEffect_default
785
785
  });
786
- import { useEffect as useEffect13, useState as useState15 } from "react";
786
+ import { useEffect as useEffect14, useState as useState16 } from "react";
787
787
  import { jsx as jsx6 } from "react/jsx-runtime";
788
788
  function ConfettiEffect({
789
789
  isActive,
790
790
  clearDelay = 3e3,
791
791
  pieceCount = 50
792
792
  }) {
793
- const [pieces, setPieces] = useState15([]);
794
- useEffect13(() => {
793
+ const [pieces, setPieces] = useState16([]);
794
+ useEffect14(() => {
795
795
  if (isActive) {
796
796
  const colors2 = [
797
797
  "#10b981",
@@ -877,10 +877,10 @@ var init_ConfettiEffect = __esm({
877
877
 
878
878
  // src/widget/TrustwareWidgetV2.tsx
879
879
  import {
880
- useState as useState23,
881
- useEffect as useEffect27,
880
+ useState as useState24,
881
+ useEffect as useEffect28,
882
882
  useRef as useRef13,
883
- useCallback as useCallback15,
883
+ useCallback as useCallback16,
884
884
  useImperativeHandle,
885
885
  forwardRef
886
886
  } from "react";
@@ -1363,7 +1363,7 @@ var ANIMATION_CLASSES = `
1363
1363
  var ALL_ANIMATION_STYLES = KEYFRAMES + ANIMATION_CLASSES;
1364
1364
 
1365
1365
  // src/widget/context/DepositContext.tsx
1366
- import React2, { createContext as createContext2, useContext as useContext2, useState as useState13, useMemo as useMemo7 } from "react";
1366
+ import React2, { createContext as createContext2, useContext as useContext2, useState as useState14, useMemo as useMemo7 } from "react";
1367
1367
 
1368
1368
  // src/provider.tsx
1369
1369
  import {
@@ -5958,6 +5958,316 @@ function mapWalletTokens(balances, chains, tokens) {
5958
5958
  });
5959
5959
  }
5960
5960
 
5961
+ // src/widget/state/deposit/useWalletConnect.ts
5962
+ init_config2();
5963
+ import { useCallback as useCallback8, useEffect as useEffect13, useState as useState13 } from "react";
5964
+
5965
+ // src/config/walletconnect.ts
5966
+ init_store();
5967
+ init_constants();
5968
+ import { UniversalConnector } from "@reown/appkit-universal-connector";
5969
+ var solanaMainnet = {
5970
+ id: 900,
5971
+ chainNamespace: "solana",
5972
+ caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqAQ3H1FQ",
5973
+ name: "Solana Mainnet",
5974
+ nativeCurrency: {
5975
+ name: "Solana",
5976
+ symbol: "SOL",
5977
+ decimals: 9
5978
+ },
5979
+ rpcUrls: {
5980
+ default: {
5981
+ http: ["https://api.mainnet-beta.solana.com"]
5982
+ }
5983
+ }
5984
+ };
5985
+ var bitcoinMainnet = {
5986
+ id: 8333,
5987
+ chainNamespace: "bip122",
5988
+ caipNetworkId: "bip122:000000000019d6689c085ae165831e93",
5989
+ name: "Bitcoin Mainnet",
5990
+ nativeCurrency: {
5991
+ name: "Bitcoin",
5992
+ symbol: "BTC",
5993
+ decimals: 8
5994
+ },
5995
+ rpcUrls: {
5996
+ default: {
5997
+ http: ["https://api.blockcypher.com/v1/btc/main"]
5998
+ }
5999
+ }
6000
+ };
6001
+ var ethereumMainnet = {
6002
+ id: 1,
6003
+ chainNamespace: "eip155",
6004
+ caipNetworkId: "eip155:1",
6005
+ name: "Ethereum Mainnet",
6006
+ nativeCurrency: {
6007
+ name: "Ether",
6008
+ symbol: "ETH",
6009
+ decimals: 18
6010
+ },
6011
+ rpcUrls: {
6012
+ default: {
6013
+ http: ["https://rpc.ankr.com/eth"]
6014
+ }
6015
+ }
6016
+ };
6017
+ var seiMainnet = {
6018
+ id: 1329,
6019
+ chainNamespace: "eip155",
6020
+ caipNetworkId: "eip155:1329",
6021
+ name: "Sei Mainnet",
6022
+ nativeCurrency: {
6023
+ name: "Sei",
6024
+ symbol: "SEI",
6025
+ decimals: 18
6026
+ },
6027
+ rpcUrls: {
6028
+ default: {
6029
+ http: ["https://evm-rpc.sei-apis.com"]
6030
+ }
6031
+ }
6032
+ };
6033
+ var solanaChains = [solanaMainnet];
6034
+ var evmChains = [ethereumMainnet, seiMainnet];
6035
+ var bitcoinChains = [bitcoinMainnet];
6036
+ var networks = [
6037
+ // ...solanaChains,
6038
+ // ...bitcoinChains,
6039
+ ...evmChains
6040
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6041
+ ];
6042
+ var namespaceConfig = [
6043
+ {
6044
+ namespace: "solana",
6045
+ chains: solanaChains,
6046
+ methods: ["solana_signMessage", "solana_signTransaction"],
6047
+ events: []
6048
+ },
6049
+ {
6050
+ namespace: "eip155",
6051
+ chains: evmChains,
6052
+ methods: [
6053
+ "eth_sendTransaction",
6054
+ "eth_signTransaction",
6055
+ "eth_sign",
6056
+ "personal_sign",
6057
+ "eth_signTypedData_v4"
6058
+ ],
6059
+ events: ["accountsChanged", "chainChanged"]
6060
+ },
6061
+ {
6062
+ namespace: "bip122",
6063
+ chains: bitcoinChains,
6064
+ // FIX 8: Use the standard WalletConnect BIP-122 method name, not the
6065
+ // non-standard "btc_signMessage" prefix that most wallets reject.
6066
+ methods: ["signMessage", "sendTransfer"],
6067
+ events: []
6068
+ }
6069
+ ];
6070
+ function resolvedMetadata() {
6071
+ const cfg = TrustwareConfigStore.peek();
6072
+ const walletConnect = cfg ? cfg?.walletConnect : void 0;
6073
+ const configured = walletConnect?.metadata;
6074
+ const pageUrl = typeof window !== "undefined" && window.location?.origin ? window.location.origin : configured?.url;
6075
+ if (!pageUrl) {
6076
+ console.warn(
6077
+ "[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."
6078
+ );
6079
+ }
6080
+ return {
6081
+ name: configured?.name ?? "Trustware",
6082
+ description: configured?.description ?? "Cross-chain bridge & top-up",
6083
+ url: pageUrl ?? "https://trustware.io",
6084
+ icons: configured?.icons?.length ? configured.icons : ["https://app.trustware.io/icon.png"]
6085
+ };
6086
+ }
6087
+ var universalConnectorPromise = null;
6088
+ var initializedProjectId = null;
6089
+ async function getUniversalConnector(walletCfg) {
6090
+ const projectId = walletCfg?.projectId ?? WALLETCONNECT_PROJECT_ID;
6091
+ if (universalConnectorPromise && initializedProjectId !== projectId) {
6092
+ console.warn(
6093
+ "[Trustware SDK] projectId changed since last init \u2014 reinitializing WalletConnect connector."
6094
+ );
6095
+ universalConnectorPromise = null;
6096
+ initializedProjectId = null;
6097
+ }
6098
+ if (!universalConnectorPromise) {
6099
+ initializedProjectId = projectId;
6100
+ universalConnectorPromise = UniversalConnector.init({
6101
+ projectId,
6102
+ metadata: resolvedMetadata(),
6103
+ networks: namespaceConfig
6104
+ }).catch((error) => {
6105
+ universalConnectorPromise = null;
6106
+ initializedProjectId = null;
6107
+ console.error(
6108
+ "[Trustware SDK] Failed to initialize WalletConnect:",
6109
+ error
6110
+ );
6111
+ throw error;
6112
+ });
6113
+ }
6114
+ return universalConnectorPromise;
6115
+ }
6116
+
6117
+ // src/widget/state/deposit/useWalletConnect.ts
6118
+ function getEvmAccount(session) {
6119
+ const account = session?.namespaces?.eip155?.accounts?.[0];
6120
+ const [, chainId, address] = account?.split(":") ?? [];
6121
+ if (!chainId || !address) {
6122
+ return null;
6123
+ }
6124
+ return {
6125
+ address,
6126
+ chainId: Number(chainId)
6127
+ };
6128
+ }
6129
+ function toHexChainId(chainId) {
6130
+ return `0x${chainId.toString(16)}`;
6131
+ }
6132
+ function useWalletConnect({
6133
+ setWalletType,
6134
+ setCurrentStep
6135
+ }) {
6136
+ const [universalConnector, setUniversalConnector] = useState13();
6137
+ const [walletConnectAddress, setWalletConnectAddress] = useState13(null);
6138
+ useEffect13(() => {
6139
+ if (typeof window === "undefined") {
6140
+ return;
6141
+ }
6142
+ const walletConnect = TrustwareConfigStore.peek()?.walletConnect;
6143
+ getUniversalConnector(walletConnect).then(
6144
+ setUniversalConnector
6145
+ );
6146
+ }, [TrustwareConfigStore.peek()?.walletConnect]);
6147
+ useEffect13(() => {
6148
+ return () => {
6149
+ universalConnector?.disconnect();
6150
+ };
6151
+ }, [universalConnector]);
6152
+ const attachWalletConnectWallet = useCallback8(
6153
+ (connector, session) => {
6154
+ const account = getEvmAccount(session);
6155
+ if (!account) {
6156
+ return null;
6157
+ }
6158
+ const activeAddress = account.address;
6159
+ let activeChainId = account.chainId;
6160
+ connector.provider.setDefaultChain(`eip155:${activeChainId}`);
6161
+ const wallet = {
6162
+ ecosystem: "evm",
6163
+ type: "eip1193",
6164
+ async getAddress() {
6165
+ return activeAddress;
6166
+ },
6167
+ async getChainId() {
6168
+ return activeChainId;
6169
+ },
6170
+ async switchChain(chainId) {
6171
+ connector.provider.setDefaultChain(`eip155:${chainId}`);
6172
+ await connector.provider.request(
6173
+ {
6174
+ method: "wallet_switchEthereumChain",
6175
+ params: [{ chainId: toHexChainId(chainId) }]
6176
+ },
6177
+ `eip155:${chainId}`
6178
+ );
6179
+ activeChainId = chainId;
6180
+ },
6181
+ async request(args) {
6182
+ const tx = Array.isArray(args.params) ? args.params[0] : void 0;
6183
+ const requestedChainId = typeof tx?.chainId === "string" ? Number.parseInt(tx.chainId, 16) : activeChainId;
6184
+ const chain = Number.isFinite(requestedChainId) ? `eip155:${requestedChainId}` : `eip155:${activeChainId}`;
6185
+ connector.provider.setDefaultChain(chain);
6186
+ return connector.provider.request(args, chain);
6187
+ },
6188
+ async disconnect() {
6189
+ await connector.disconnect();
6190
+ }
6191
+ };
6192
+ walletManager.attachWallet(wallet);
6193
+ setWalletConnectAddress(activeAddress);
6194
+ return activeAddress;
6195
+ },
6196
+ []
6197
+ );
6198
+ const getAddrAndRedirect = useCallback8(
6199
+ (connector, session) => {
6200
+ const adr = attachWalletConnectWallet(connector, session);
6201
+ if (!adr) return null;
6202
+ setCurrentStep("crypto-pay");
6203
+ console.log({ adr });
6204
+ return adr;
6205
+ },
6206
+ [attachWalletConnectWallet, setCurrentStep]
6207
+ );
6208
+ const WalletConnect = useCallback8(
6209
+ async function() {
6210
+ console.log("got called");
6211
+ if (!universalConnector) {
6212
+ return;
6213
+ }
6214
+ setWalletType("walletconnect");
6215
+ const session = universalConnector.provider.session;
6216
+ const nowInSeconds = Math.floor(Date.now() / 1e3);
6217
+ const isActive = session && session.expiry > nowInSeconds;
6218
+ console.log({ isActive, session });
6219
+ if (isActive && session) {
6220
+ getAddrAndRedirect(universalConnector, session);
6221
+ return;
6222
+ }
6223
+ const { session: providerSession } = await universalConnector.connect();
6224
+ if (providerSession) {
6225
+ getAddrAndRedirect(universalConnector, providerSession);
6226
+ return;
6227
+ }
6228
+ },
6229
+ [getAddrAndRedirect, setWalletType, universalConnector]
6230
+ );
6231
+ const disconnectWalletConnect = async () => {
6232
+ if (universalConnector) {
6233
+ await walletManager.disconnect();
6234
+ setWalletType("other");
6235
+ setCurrentStep("home");
6236
+ }
6237
+ };
6238
+ useEffect13(() => {
6239
+ const provider = universalConnector?.provider;
6240
+ if (!provider) {
6241
+ return;
6242
+ }
6243
+ const handleSessionUpdate = ({
6244
+ session
6245
+ }) => {
6246
+ console.log("session_update");
6247
+ if (session) {
6248
+ attachWalletConnectWallet(universalConnector, session);
6249
+ }
6250
+ };
6251
+ const handleSessionDelete = () => {
6252
+ console.log("session_delete");
6253
+ setWalletConnectAddress(null);
6254
+ void walletManager.disconnect();
6255
+ };
6256
+ provider.on("session_update", handleSessionUpdate);
6257
+ provider.on("session_delete", handleSessionDelete);
6258
+ return () => {
6259
+ provider.off("session_update", handleSessionUpdate);
6260
+ provider.off("session_delete", handleSessionDelete);
6261
+ };
6262
+ }, [attachWalletConnectWallet, universalConnector]);
6263
+ return {
6264
+ universalConnector,
6265
+ walletConnectAddress,
6266
+ WalletConnect,
6267
+ disconnectWalletConnect
6268
+ };
6269
+ }
6270
+
5961
6271
  // src/widget/context/DepositContext.tsx
5962
6272
  import { jsx as jsx2 } from "react/jsx-runtime";
5963
6273
  var DepositContext = createContext2(
@@ -5985,17 +6295,33 @@ function DepositProvider({
5985
6295
  const { resolvedTheme, toggleTheme } = useThemePreference();
5986
6296
  const {
5987
6297
  selectedWallet,
5988
- walletAddress,
6298
+ walletAddress: otherWalletAddress,
5989
6299
  walletStatus,
5990
6300
  connectWallet,
5991
6301
  disconnectWallet
5992
6302
  } = useWalletSessionState();
5993
- const [amountInputMode, setAmountInputMode] = useState13(
6303
+ const [amountInputMode, setAmountInputMode] = useState14(
5994
6304
  "usd"
5995
6305
  );
5996
- const [selectedToken, setSelectedToken] = useState13(null);
5997
- const [selectedChain, setSelectedChain] = useState13(null);
5998
- const [amount, setAmount] = useState13("");
6306
+ const [walletType, setWalletType] = useState14(
6307
+ "other"
6308
+ );
6309
+ const {
6310
+ universalConnector,
6311
+ walletConnectAddress,
6312
+ WalletConnect,
6313
+ disconnectWalletConnect
6314
+ } = useWalletConnect({
6315
+ setWalletType,
6316
+ setCurrentStep
6317
+ });
6318
+ const [selectedToken, setSelectedToken] = useState14(null);
6319
+ const [selectedChain, setSelectedChain] = useState14(null);
6320
+ const [amount, setAmount] = useState14("");
6321
+ const walletAddress = useMemo7(
6322
+ () => walletType === "walletconnect" ? walletConnectAddress : otherWalletAddress,
6323
+ [walletType, walletConnectAddress, otherWalletAddress]
6324
+ );
5999
6325
  const {
6000
6326
  yourWalletTokens,
6001
6327
  setYourWalletTokens,
@@ -6008,11 +6334,11 @@ function DepositProvider({
6008
6334
  selectedToken,
6009
6335
  setSelectedToken
6010
6336
  });
6011
- const [transactionStatus, setTransactionStatus] = useState13("idle");
6012
- const [transactionHash, setTransactionHash] = useState13(null);
6013
- const [errorMessage, setErrorMessage] = useState13(null);
6014
- const [intentId, setIntentId] = useState13(null);
6015
- const [paymentMethod, setPaymentMethod] = useState13("crypto");
6337
+ const [transactionStatus, setTransactionStatus] = useState14("idle");
6338
+ const [transactionHash, setTransactionHash] = useState14(null);
6339
+ const [errorMessage, setErrorMessage] = useState14(null);
6340
+ const [intentId, setIntentId] = useState14(null);
6341
+ const [paymentMethod, setPaymentMethod] = useState14("crypto");
6016
6342
  const resetState = React2.useCallback(() => {
6017
6343
  resetNavigation();
6018
6344
  setSelectedToken(null);
@@ -6055,15 +6381,26 @@ function DepositProvider({
6055
6381
  disconnectWallet,
6056
6382
  yourWalletTokens,
6057
6383
  setYourWalletTokens,
6058
- yourWalletTokensLoading
6384
+ yourWalletTokensLoading,
6385
+ universalConnector,
6386
+ walletConnectAddress,
6387
+ WalletConnect,
6388
+ disconnectWalletConnect,
6389
+ setWalletType,
6390
+ walletType
6059
6391
  }),
6060
6392
  [
6393
+ WalletConnect,
6061
6394
  connectWallet,
6062
6395
  disconnectWallet,
6396
+ disconnectWalletConnect,
6063
6397
  selectedWallet,
6064
6398
  setYourWalletTokens,
6399
+ universalConnector,
6065
6400
  walletAddress,
6401
+ walletConnectAddress,
6066
6402
  walletStatus,
6403
+ walletType,
6067
6404
  yourWalletTokens,
6068
6405
  yourWalletTokensLoading
6069
6406
  ]
@@ -6146,7 +6483,7 @@ function useDepositUi() {
6146
6483
  }
6147
6484
 
6148
6485
  // src/widget/components/AmountSlider.tsx
6149
- import { useCallback as useCallback8, useMemo as useMemo8 } from "react";
6486
+ import { useCallback as useCallback9, useMemo as useMemo8 } from "react";
6150
6487
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
6151
6488
  var roundToNiceNumber = (value, range) => {
6152
6489
  let roundingFactor;
@@ -6196,7 +6533,7 @@ function AmountSlider({
6196
6533
  style,
6197
6534
  disabled = false
6198
6535
  }) {
6199
- const generateTickMarks = useCallback8(
6536
+ const generateTickMarks = useCallback9(
6200
6537
  (minValue, maxValue) => {
6201
6538
  const range = maxValue - minValue;
6202
6539
  if (range <= 0) {
@@ -6248,21 +6585,21 @@ function AmountSlider({
6248
6585
  () => generateTickMarks(min, max),
6249
6586
  [generateTickMarks, min, max]
6250
6587
  );
6251
- const getPercentage = useCallback8(() => {
6588
+ const getPercentage = useCallback9(() => {
6252
6589
  const range = max - min;
6253
6590
  if (range <= 0) return 0;
6254
6591
  const clampedValue = Math.min(Math.max(value, min), max);
6255
6592
  return (clampedValue - min) / range * 100;
6256
6593
  }, [max, min, value]);
6257
6594
  const percentage = useMemo8(() => getPercentage(), [getPercentage]);
6258
- const handleChange = useCallback8(
6595
+ const handleChange = useCallback9(
6259
6596
  (e2) => {
6260
6597
  const newValue = Math.min(Math.max(Number(e2.target.value), min), max);
6261
6598
  onChange(newValue);
6262
6599
  },
6263
6600
  [onChange, min, max]
6264
6601
  );
6265
- const handleTickClick = useCallback8(
6602
+ const handleTickClick = useCallback9(
6266
6603
  (tickValue) => {
6267
6604
  if (disabled) return;
6268
6605
  onChange(tickValue);
@@ -6480,7 +6817,7 @@ function AmountSlider({
6480
6817
  }
6481
6818
 
6482
6819
  // src/widget/components/AmountInputDisplay.tsx
6483
- import { useRef as useRef5, useState as useState14 } from "react";
6820
+ import { useRef as useRef5, useState as useState15 } from "react";
6484
6821
  import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
6485
6822
  function formatDisplayAmount(value) {
6486
6823
  if (!Number.isFinite(value) || value <= 0) return "0";
@@ -6519,7 +6856,7 @@ function AmountInputDisplay({
6519
6856
  style,
6520
6857
  inputAriaLabel = "Deposit amount"
6521
6858
  }) {
6522
- const [isEditing, setIsEditing] = useState14(false);
6859
+ const [isEditing, setIsEditing] = useState15(false);
6523
6860
  const inputRef = useRef5(null);
6524
6861
  const handleAmountClick = () => {
6525
6862
  if (isFixedAmount) return;
@@ -6735,7 +7072,7 @@ function CircularProgress({
6735
7072
  }
6736
7073
 
6737
7074
  // src/widget/components/Dialog.tsx
6738
- import { useEffect as useEffect14, useRef as useRef6 } from "react";
7075
+ import { useEffect as useEffect15, useRef as useRef6 } from "react";
6739
7076
  import { Fragment, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
6740
7077
  var Dialog = ({
6741
7078
  open,
@@ -6751,7 +7088,7 @@ var Dialog = ({
6751
7088
  const overlayRef = useRef6(null);
6752
7089
  const firstButtonRef = useRef6(null);
6753
7090
  const lastButtonRef = useRef6(null);
6754
- useEffect14(() => {
7091
+ useEffect15(() => {
6755
7092
  const handleEscape = (e2) => {
6756
7093
  if (e2.key === "Escape" && open) {
6757
7094
  e2.preventDefault();
@@ -6765,7 +7102,7 @@ var Dialog = ({
6765
7102
  document.removeEventListener("keydown", handleEscape);
6766
7103
  };
6767
7104
  }, [open, onCancel]);
6768
- useEffect14(() => {
7105
+ useEffect15(() => {
6769
7106
  const handleTabKey = (e2) => {
6770
7107
  if (!open) return;
6771
7108
  if (e2.key === "Tab") {
@@ -6789,7 +7126,7 @@ var Dialog = ({
6789
7126
  document.removeEventListener("keydown", handleTabKey);
6790
7127
  };
6791
7128
  }, [open]);
6792
- useEffect14(() => {
7129
+ useEffect15(() => {
6793
7130
  if (open) {
6794
7131
  const originalStyle = window.getComputedStyle(document.body).overflow;
6795
7132
  document.body.style.overflow = "hidden";
@@ -7087,7 +7424,7 @@ function TransactionHashLink({
7087
7424
  }
7088
7425
 
7089
7426
  // src/widget/components/SwipeToConfirmTokens.tsx
7090
- import { useState as useState16, useRef as useRef7, useCallback as useCallback9, useEffect as useEffect15 } from "react";
7427
+ import { useState as useState17, useRef as useRef7, useCallback as useCallback10, useEffect as useEffect16 } from "react";
7091
7428
  import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
7092
7429
  function SwipeToConfirmTokens({
7093
7430
  fromToken,
@@ -7102,13 +7439,13 @@ function SwipeToConfirmTokens({
7102
7439
  style,
7103
7440
  text
7104
7441
  }) {
7105
- const [dragX, setDragX] = useState16(0);
7106
- const [isDragging, setIsDragging] = useState16(false);
7107
- const [isComplete, setIsComplete] = useState16(false);
7442
+ const [dragX, setDragX] = useState17(0);
7443
+ const [isDragging, setIsDragging] = useState17(false);
7444
+ const [isComplete, setIsComplete] = useState17(false);
7108
7445
  const trackRef = useRef7(null);
7109
7446
  const thumbRef = useRef7(null);
7110
- const [isLongPressing, setIsLongPressing] = useState16(false);
7111
- const [longPressProgress, setLongPressProgress] = useState16(0);
7447
+ const [isLongPressing, setIsLongPressing] = useState17(false);
7448
+ const [longPressProgress, setLongPressProgress] = useState17(0);
7112
7449
  const longPressTimerRef = useRef7(null);
7113
7450
  const longPressStartRef = useRef7(null);
7114
7451
  const longPressAnimationRef = useRef7(null);
@@ -7116,19 +7453,19 @@ function SwipeToConfirmTokens({
7116
7453
  const thumbSize = 48;
7117
7454
  const padding = 4;
7118
7455
  const threshold = 0.8;
7119
- const getMaxDrag = useCallback9(() => {
7456
+ const getMaxDrag = useCallback10(() => {
7120
7457
  if (!trackRef.current) return 0;
7121
7458
  return trackRef.current.offsetWidth - thumbSize - padding * 2;
7122
7459
  }, []);
7123
- const getProgress = useCallback9(() => {
7460
+ const getProgress = useCallback10(() => {
7124
7461
  const maxDrag = getMaxDrag();
7125
7462
  return maxDrag > 0 ? dragX / maxDrag : 0;
7126
7463
  }, [dragX, getMaxDrag]);
7127
- const handleDragStart = useCallback9(() => {
7464
+ const handleDragStart = useCallback10(() => {
7128
7465
  if (disabled || isComplete) return;
7129
7466
  setIsDragging(true);
7130
7467
  }, [disabled, isComplete]);
7131
- const handleDragMove = useCallback9(
7468
+ const handleDragMove = useCallback10(
7132
7469
  (clientX) => {
7133
7470
  if (!isDragging || !trackRef.current || isComplete) return;
7134
7471
  const rect = trackRef.current.getBoundingClientRect();
@@ -7139,7 +7476,7 @@ function SwipeToConfirmTokens({
7139
7476
  },
7140
7477
  [isDragging, isComplete, getMaxDrag]
7141
7478
  );
7142
- const handleDragEnd = useCallback9(() => {
7479
+ const handleDragEnd = useCallback10(() => {
7143
7480
  if (!isDragging) return;
7144
7481
  setIsDragging(false);
7145
7482
  const progress2 = getProgress();
@@ -7152,14 +7489,14 @@ function SwipeToConfirmTokens({
7152
7489
  setDragX(0);
7153
7490
  }
7154
7491
  }, [isDragging, getProgress, getMaxDrag, onConfirm]);
7155
- const triggerConfirmation = useCallback9(() => {
7492
+ const triggerConfirmation = useCallback10(() => {
7156
7493
  if (isComplete) return;
7157
7494
  setDragX(getMaxDrag());
7158
7495
  setIsComplete(true);
7159
7496
  if (navigator.vibrate) navigator.vibrate(50);
7160
7497
  setTimeout(() => onConfirm(), 150);
7161
7498
  }, [isComplete, getMaxDrag, onConfirm]);
7162
- const cancelLongPress = useCallback9(() => {
7499
+ const cancelLongPress = useCallback10(() => {
7163
7500
  setIsLongPressing(false);
7164
7501
  setLongPressProgress(0);
7165
7502
  longPressStartRef.current = null;
@@ -7172,7 +7509,7 @@ function SwipeToConfirmTokens({
7172
7509
  longPressAnimationRef.current = null;
7173
7510
  }
7174
7511
  }, []);
7175
- const startLongPress = useCallback9(() => {
7512
+ const startLongPress = useCallback10(() => {
7176
7513
  if (disabled || isComplete || isDragging) return;
7177
7514
  setIsLongPressing(true);
7178
7515
  longPressStartRef.current = Date.now();
@@ -7190,7 +7527,7 @@ function SwipeToConfirmTokens({
7190
7527
  };
7191
7528
  longPressAnimationRef.current = requestAnimationFrame(animateProgress);
7192
7529
  }, [disabled, isComplete, isDragging, triggerConfirmation, cancelLongPress]);
7193
- const handleKeyDown = useCallback9(
7530
+ const handleKeyDown = useCallback10(
7194
7531
  (e2) => {
7195
7532
  if (disabled || isComplete) return;
7196
7533
  if (e2.key === "Enter" || e2.key === " ") {
@@ -7200,7 +7537,7 @@ function SwipeToConfirmTokens({
7200
7537
  },
7201
7538
  [disabled, isComplete, startLongPress]
7202
7539
  );
7203
- const handleKeyUp = useCallback9(
7540
+ const handleKeyUp = useCallback10(
7204
7541
  (e2) => {
7205
7542
  if (e2.key === "Enter" || e2.key === " ") {
7206
7543
  e2.preventDefault();
@@ -7209,7 +7546,7 @@ function SwipeToConfirmTokens({
7209
7546
  },
7210
7547
  [cancelLongPress]
7211
7548
  );
7212
- useEffect15(() => {
7549
+ useEffect16(() => {
7213
7550
  return () => {
7214
7551
  if (longPressTimerRef.current) clearTimeout(longPressTimerRef.current);
7215
7552
  if (longPressAnimationRef.current)
@@ -7220,15 +7557,15 @@ function SwipeToConfirmTokens({
7220
7557
  e2.preventDefault();
7221
7558
  handleDragStart();
7222
7559
  };
7223
- const handleMouseMove = useCallback9(
7560
+ const handleMouseMove = useCallback10(
7224
7561
  (e2) => handleDragMove(e2.clientX),
7225
7562
  [handleDragMove]
7226
7563
  );
7227
- const handleMouseUp = useCallback9(() => handleDragEnd(), [handleDragEnd]);
7564
+ const handleMouseUp = useCallback10(() => handleDragEnd(), [handleDragEnd]);
7228
7565
  const handleTouchStart = () => handleDragStart();
7229
7566
  const handleTouchMove = (e2) => handleDragMove(e2.touches[0].clientX);
7230
7567
  const handleTouchEnd = () => handleDragEnd();
7231
- useEffect15(() => {
7568
+ useEffect16(() => {
7232
7569
  if (isDragging) {
7233
7570
  window.addEventListener("mousemove", handleMouseMove);
7234
7571
  window.addEventListener("mouseup", handleMouseUp);
@@ -7240,8 +7577,8 @@ function SwipeToConfirmTokens({
7240
7577
  }, [isDragging, handleMouseMove, handleMouseUp]);
7241
7578
  const progress = getProgress();
7242
7579
  const effectiveProgress = isLongPressing ? longPressProgress : progress;
7243
- const [blinkOpacity, setBlinkOpacity] = useState16(1);
7244
- useEffect15(() => {
7580
+ const [blinkOpacity, setBlinkOpacity] = useState17(1);
7581
+ useEffect16(() => {
7245
7582
  if (disabled || isComplete || isDragging || isLongPressing) {
7246
7583
  setBlinkOpacity(1);
7247
7584
  return;
@@ -7691,7 +8028,7 @@ function ThemeToggle({
7691
8028
  }
7692
8029
 
7693
8030
  // src/widget/components/Toast.tsx
7694
- import { useEffect as useEffect16, useState as useState17, useCallback as useCallback10 } from "react";
8031
+ import { useEffect as useEffect17, useState as useState18, useCallback as useCallback11 } from "react";
7695
8032
  import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
7696
8033
  var variantStyles = {
7697
8034
  default: {
@@ -7721,14 +8058,14 @@ function ToastItem({
7721
8058
  duration = 4e3,
7722
8059
  onDismiss
7723
8060
  }) {
7724
- const [isExiting, setIsExiting] = useState17(false);
7725
- useEffect16(() => {
8061
+ const [isExiting, setIsExiting] = useState18(false);
8062
+ useEffect17(() => {
7726
8063
  const timer = setTimeout(() => {
7727
8064
  setIsExiting(true);
7728
8065
  }, duration);
7729
8066
  return () => clearTimeout(timer);
7730
8067
  }, [duration]);
7731
- useEffect16(() => {
8068
+ useEffect17(() => {
7732
8069
  if (isExiting) {
7733
8070
  const exitTimer = setTimeout(() => {
7734
8071
  onDismiss(id);
@@ -7932,8 +8269,8 @@ function toast(data) {
7932
8269
  toast.error = (title, description) => toast({ title, description, variant: "destructive" });
7933
8270
  toast.success = (title, description) => toast({ title, description, variant: "success" });
7934
8271
  function ToastContainer() {
7935
- const [activeToasts, setActiveToasts] = useState17([]);
7936
- useEffect16(() => {
8272
+ const [activeToasts, setActiveToasts] = useState18([]);
8273
+ useEffect17(() => {
7937
8274
  const listener = (newToasts) => {
7938
8275
  setActiveToasts(newToasts);
7939
8276
  };
@@ -7945,7 +8282,7 @@ function ToastContainer() {
7945
8282
  }
7946
8283
  };
7947
8284
  }, []);
7948
- const handleDismiss = useCallback10((id) => {
8285
+ const handleDismiss = useCallback11((id) => {
7949
8286
  toasts = toasts.filter((t) => t.id !== id);
7950
8287
  notifyListeners();
7951
8288
  }, []);
@@ -7983,10 +8320,10 @@ function ToastContainer() {
7983
8320
 
7984
8321
  // src/widget/components/TokenSwipePill.tsx
7985
8322
  import React9, {
7986
- useState as useState18,
8323
+ useState as useState19,
7987
8324
  useRef as useRef8,
7988
- useCallback as useCallback11,
7989
- useEffect as useEffect17,
8325
+ useCallback as useCallback12,
8326
+ useEffect as useEffect18,
7990
8327
  useMemo as useMemo9
7991
8328
  } from "react";
7992
8329
  import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
@@ -8000,8 +8337,8 @@ function TokenSwipePill({
8000
8337
  walletAddress,
8001
8338
  style
8002
8339
  }) {
8003
- const [isDragging, setIsDragging] = useState18(false);
8004
- const [dragOffset, setDragOffset] = useState18(0);
8340
+ const [isDragging, setIsDragging] = useState19(false);
8341
+ const [dragOffset, setDragOffset] = useState19(0);
8005
8342
  const startXRef = useRef8(0);
8006
8343
  const containerRef = useRef8(null);
8007
8344
  const currentIndex = tokens.findIndex(
@@ -8024,11 +8361,11 @@ function TokenSwipePill({
8024
8361
  }
8025
8362
  return pos;
8026
8363
  };
8027
- const handleDragStart = useCallback11((clientX) => {
8364
+ const handleDragStart = useCallback12((clientX) => {
8028
8365
  setIsDragging(true);
8029
8366
  startXRef.current = clientX;
8030
8367
  }, []);
8031
- const handleDragMove = useCallback11(
8368
+ const handleDragMove = useCallback12(
8032
8369
  (clientX) => {
8033
8370
  if (!isDragging) return;
8034
8371
  const delta = startXRef.current - clientX;
@@ -8036,7 +8373,7 @@ function TokenSwipePill({
8036
8373
  },
8037
8374
  [isDragging]
8038
8375
  );
8039
- const handleDragEnd = useCallback11(() => {
8376
+ const handleDragEnd = useCallback12(() => {
8040
8377
  if (!isDragging) return;
8041
8378
  setIsDragging(false);
8042
8379
  if (Math.abs(dragOffset) > swipeThreshold) {
@@ -8054,13 +8391,13 @@ function TokenSwipePill({
8054
8391
  e2.preventDefault();
8055
8392
  handleDragStart(e2.clientX);
8056
8393
  };
8057
- const handleMouseMove = useCallback11(
8394
+ const handleMouseMove = useCallback12(
8058
8395
  (e2) => {
8059
8396
  handleDragMove(e2.clientX);
8060
8397
  },
8061
8398
  [handleDragMove]
8062
8399
  );
8063
- const handleMouseUp = useCallback11(() => {
8400
+ const handleMouseUp = useCallback12(() => {
8064
8401
  handleDragEnd();
8065
8402
  }, [handleDragEnd]);
8066
8403
  const handleTouchStart = (e2) => {
@@ -8074,7 +8411,7 @@ function TokenSwipePill({
8074
8411
  const handleTouchEnd = () => {
8075
8412
  handleDragEnd();
8076
8413
  };
8077
- useEffect17(() => {
8414
+ useEffect18(() => {
8078
8415
  if (isDragging) {
8079
8416
  window.addEventListener("mousemove", handleMouseMove);
8080
8417
  window.addEventListener("mouseup", handleMouseUp);
@@ -8762,7 +9099,7 @@ function TransactionSteps({
8762
9099
  }
8763
9100
 
8764
9101
  // src/widget/components/WidgetContainer.tsx
8765
- import { useEffect as useEffect18, useState as useState19 } from "react";
9102
+ import { useEffect as useEffect19, useState as useState20 } from "react";
8766
9103
  import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
8767
9104
  var INJECTED_STYLES = ALL_THEME_STYLES + ALL_ANIMATION_STYLES;
8768
9105
  function WidgetContainer({
@@ -8771,8 +9108,8 @@ function WidgetContainer({
8771
9108
  className,
8772
9109
  style
8773
9110
  }) {
8774
- const [resolvedTheme, setResolvedTheme] = useState19("light");
8775
- useEffect18(() => {
9111
+ const [resolvedTheme, setResolvedTheme] = useState20("light");
9112
+ useEffect19(() => {
8776
9113
  if (theme === "system") {
8777
9114
  const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
8778
9115
  setResolvedTheme(mediaQuery.matches ? "dark" : "light");
@@ -9016,7 +9353,7 @@ function WidgetSecurityFooter({
9016
9353
  }
9017
9354
 
9018
9355
  // src/widget/components/ImageLoader.tsx
9019
- import { useEffect as useEffect19, useMemo as useMemo11, useRef as useRef9, useState as useState20 } from "react";
9356
+ import { useEffect as useEffect20, useMemo as useMemo11, useRef as useRef9, useState as useState21 } from "react";
9020
9357
  import { jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
9021
9358
  function Skeleton({
9022
9359
  background,
@@ -9046,12 +9383,12 @@ function ImageLoader({
9046
9383
  onLoad,
9047
9384
  onError
9048
9385
  }) {
9049
- const [status, setStatus] = useState20("idle");
9050
- const [attempt, setAttempt] = useState20(0);
9051
- const [srcIsEmpty, setSrcIsEmpty] = useState20(false);
9386
+ const [status, setStatus] = useState21("idle");
9387
+ const [attempt, setAttempt] = useState21(0);
9388
+ const [srcIsEmpty, setSrcIsEmpty] = useState21(false);
9052
9389
  const imgRef = useRef9(null);
9053
9390
  const observerRef = useRef9(null);
9054
- useEffect19(() => {
9391
+ useEffect20(() => {
9055
9392
  if (status === "error" && attempt < retry) {
9056
9393
  const timer = setTimeout(() => {
9057
9394
  setAttempt((prev) => prev + 1);
@@ -9077,7 +9414,7 @@ function ImageLoader({
9077
9414
  onError?.();
9078
9415
  };
9079
9416
  };
9080
- useEffect19(() => {
9417
+ useEffect20(() => {
9081
9418
  if (!lazy2) {
9082
9419
  setTimeout(() => {
9083
9420
  loadImage();
@@ -10588,7 +10925,7 @@ function TokenSelectorPanel({
10588
10925
  }
10589
10926
 
10590
10927
  // src/widget/features/token-selection/hooks/useOrderedWalletTokens.ts
10591
- import { useCallback as useCallback12, useMemo as useMemo12 } from "react";
10928
+ import { useCallback as useCallback13, useMemo as useMemo12 } from "react";
10592
10929
  function useOrderedWalletTokens({
10593
10930
  amount,
10594
10931
  amountInputMode,
@@ -10597,7 +10934,7 @@ function useOrderedWalletTokens({
10597
10934
  setSelectedToken,
10598
10935
  yourWalletTokens
10599
10936
  }) {
10600
- const handleTokenChange = useCallback12(
10937
+ const handleTokenChange = useCallback13(
10601
10938
  async (token) => {
10602
10939
  if (token) {
10603
10940
  setSelectedToken(token);
@@ -10675,7 +11012,7 @@ function filterTokenAmountCompatibleTokens(tokens, parsedAmount) {
10675
11012
  }
10676
11013
 
10677
11014
  // src/widget/features/token-selection/hooks/useSelectTokenModel.ts
10678
- import { useCallback as useCallback13, useMemo as useMemo13 } from "react";
11015
+ import { useCallback as useCallback14, useMemo as useMemo13 } from "react";
10679
11016
  function useSelectTokenModel({
10680
11017
  goBack,
10681
11018
  searchQuery,
@@ -10699,7 +11036,7 @@ function useSelectTokenModel({
10699
11036
  explorerUrl: chain.blockExplorerUrls?.[0]
10700
11037
  });
10701
11038
  };
10702
- const handleTokenSelect = useCallback13(
11039
+ const handleTokenSelect = useCallback14(
10703
11040
  async (token) => {
10704
11041
  if (token.balance !== void 0) {
10705
11042
  setSelectedToken(token);
@@ -10723,7 +11060,7 @@ function useSelectTokenModel({
10723
11060
  },
10724
11061
  [goBack, selectedChain, setSelectedToken, walletAddress]
10725
11062
  );
10726
- const handleYourTokenSelect = useCallback13(
11063
+ const handleYourTokenSelect = useCallback14(
10727
11064
  (token) => {
10728
11065
  setSelectedToken(token);
10729
11066
  setSelectedChain(token.chainData);
@@ -11217,7 +11554,7 @@ function CryptoPayAmountSection({
11217
11554
  }
11218
11555
 
11219
11556
  // src/widget/features/amount/hooks/useDepositAmountModel.ts
11220
- import { useEffect as useEffect20, useMemo as useMemo14 } from "react";
11557
+ import { useEffect as useEffect21, useMemo as useMemo14 } from "react";
11221
11558
  var BALANCE_TOLERANCE = 1e-9;
11222
11559
  function useDepositAmountModel({
11223
11560
  amount,
@@ -11239,7 +11576,7 @@ function useDepositAmountModel({
11239
11576
  );
11240
11577
  return Number.isFinite(normalized) ? normalized : 0;
11241
11578
  }, [selectedToken?.balance, selectedToken?.decimals]);
11242
- useEffect20(() => {
11579
+ useEffect21(() => {
11243
11580
  if (fixedFromAmountString) return;
11244
11581
  if (isReady && !hasUsdPrice && amountInputMode === "usd") {
11245
11582
  setAmountInputMode("token");
@@ -11251,7 +11588,7 @@ function useDepositAmountModel({
11251
11588
  isReady,
11252
11589
  setAmountInputMode
11253
11590
  ]);
11254
- useEffect20(() => {
11591
+ useEffect21(() => {
11255
11592
  if (!fixedFromAmountString) return;
11256
11593
  if (amount !== fixedFromAmountString) {
11257
11594
  setAmount(fixedFromAmountString);
@@ -11418,7 +11755,7 @@ function useDepositAmountModel({
11418
11755
  }
11419
11756
 
11420
11757
  // src/widget/features/amount/hooks/useHomeAmountModel.ts
11421
- import { useEffect as useEffect21, useMemo as useMemo15 } from "react";
11758
+ import { useEffect as useEffect22, useMemo as useMemo15 } from "react";
11422
11759
  function useHomeAmountModel({
11423
11760
  amount,
11424
11761
  setAmount,
@@ -11429,7 +11766,7 @@ function useHomeAmountModel({
11429
11766
  minAmountUsd,
11430
11767
  maxAmountUsd
11431
11768
  }) {
11432
- useEffect21(() => {
11769
+ useEffect22(() => {
11433
11770
  if (!fixedFromAmountString) return;
11434
11771
  if (amount !== fixedFromAmountString) {
11435
11772
  setAmount(fixedFromAmountString);
@@ -11657,7 +11994,7 @@ function WalletConnectRow({
11657
11994
  PaymentOptionRow,
11658
11995
  {
11659
11996
  onClick: () => void onClick(),
11660
- label: "WalletConnect",
11997
+ label: "WalletConnect(EVM)",
11661
11998
  icon: /* @__PURE__ */ jsx32("div", { style: walletActionIconBoxStyle, children: /* @__PURE__ */ jsx32(
11662
11999
  "svg",
11663
12000
  {
@@ -12170,152 +12507,20 @@ function HomePaymentOptions({
12170
12507
  }
12171
12508
 
12172
12509
  // src/widget/features/wallet/hooks/useHomeWalletActions.ts
12173
- import { useEffect as useEffect22, useRef as useRef10, useState as useState21 } from "react";
12174
-
12175
- // src/config/walletconnect.ts
12176
- init_store();
12177
- init_constants();
12178
- import { UniversalConnector } from "@reown/appkit-universal-connector";
12179
- var solanaMainnet = {
12180
- id: 1,
12181
- chainNamespace: "solana",
12182
- caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqAQ3H1FQ",
12183
- name: "Solana Mainnet",
12184
- nativeCurrency: {
12185
- name: "Solana",
12186
- symbol: "SOL",
12187
- decimals: 9
12188
- },
12189
- rpcUrls: {
12190
- default: {
12191
- http: ["https://api.mainnet-beta.solana.com"]
12192
- }
12193
- }
12194
- };
12195
- var bitcoinMainnet = {
12196
- id: 0,
12197
- chainNamespace: "bip122",
12198
- caipNetworkId: "bip122:000000000019d6689c085ae165831e93",
12199
- name: "Bitcoin Mainnet",
12200
- nativeCurrency: {
12201
- name: "Bitcoin",
12202
- symbol: "BTC",
12203
- decimals: 8
12204
- },
12205
- rpcUrls: {
12206
- default: {
12207
- http: ["https://api.blockcypher.com/v1/btc/main"]
12208
- }
12209
- }
12210
- };
12211
- var ethereumMainnet = {
12212
- id: 1,
12213
- chainNamespace: "eip155",
12214
- caipNetworkId: "eip155:1",
12215
- name: "Ethereum Mainnet",
12216
- nativeCurrency: {
12217
- name: "Ether",
12218
- symbol: "ETH",
12219
- decimals: 18
12220
- },
12221
- rpcUrls: {
12222
- default: {
12223
- http: ["https://rpc.ankr.com/eth"]
12224
- }
12225
- }
12226
- };
12227
- var seiMainnet = {
12228
- id: 1329,
12229
- chainNamespace: "eip155",
12230
- caipNetworkId: "eip155:1329",
12231
- name: "Sei Mainnet",
12232
- nativeCurrency: {
12233
- name: "Sei",
12234
- symbol: "SEI",
12235
- decimals: 18
12236
- },
12237
- rpcUrls: {
12238
- default: {
12239
- http: ["https://evm-rpc.sei-apis.com"]
12240
- }
12241
- }
12242
- };
12243
- var universalConnectorPromise = null;
12244
- function resolvedMetadata() {
12245
- const cfg = TrustwareConfigStore.peek();
12246
- const walletConnect = cfg ? cfg?.walletConnect : void 0;
12247
- const configured = walletConnect?.metadata;
12248
- const pageUrl = typeof window !== "undefined" && window.location?.origin ? window.location.origin : configured?.url;
12249
- return {
12250
- name: configured?.name ?? "Trustware",
12251
- description: configured?.description ?? "Cross-chain bridge & top-up",
12252
- url: pageUrl ?? "https://trustware.io",
12253
- icons: configured?.icons?.length ? configured.icons : ["https://app.trustware.io/icon.png"]
12254
- };
12255
- }
12256
- async function getUniversalConnector(walletCfg) {
12257
- const projectId = walletCfg?.projectId ?? WALLETCONNECT_PROJECT_ID;
12258
- if (!projectId) {
12259
- console.warn(
12260
- "[Trustware SDK] WalletConnect disabled: no projectId. Set TRUSTWARE_WALLETCONNECT_PROJECT_ID at build time or pass walletConnect.projectId in config."
12261
- );
12262
- return void 0;
12263
- }
12264
- if (!universalConnectorPromise) {
12265
- universalConnectorPromise = UniversalConnector.init({
12266
- projectId,
12267
- metadata: resolvedMetadata(),
12268
- networks: [
12269
- {
12270
- namespace: "solana",
12271
- chains: [solanaMainnet],
12272
- methods: ["solana_signMessage", "solana_signTransaction"],
12273
- events: []
12274
- },
12275
- {
12276
- namespace: "eip155",
12277
- chains: [ethereumMainnet, seiMainnet],
12278
- methods: ["eth_sendTransaction", "eth_sign", "personal_sign"],
12279
- events: ["accountsChanged", "chainChanged"]
12280
- },
12281
- {
12282
- namespace: "bip122",
12283
- chains: [bitcoinMainnet],
12284
- methods: ["btc_signMessage"],
12285
- events: []
12286
- }
12287
- ]
12288
- }).catch((error) => {
12289
- universalConnectorPromise = null;
12290
- throw error;
12291
- });
12292
- }
12293
- return universalConnectorPromise;
12294
- }
12295
-
12296
- // src/widget/features/wallet/hooks/useHomeWalletActions.ts
12297
- init_config2();
12510
+ import { useEffect as useEffect23, useRef as useRef10, useState as useState22 } from "react";
12298
12511
  function useHomeWalletActions({
12299
12512
  connectWallet,
12300
12513
  detectedWallets,
12301
- setCurrentStep
12514
+ setCurrentStep,
12515
+ setWalletType,
12516
+ WalletConnect
12302
12517
  // setCurrentStepInternal,
12303
12518
  }) {
12304
- const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = useState21(false);
12305
- const [isFiatDropdownOpen, setIsFiatDropdownOpen] = useState21(false);
12306
- const [universalConnector, setUniversalConnector] = useState21();
12519
+ const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = useState22(false);
12520
+ const [isFiatDropdownOpen, setIsFiatDropdownOpen] = useState22(false);
12307
12521
  const cryptoDropdownRef = useRef10(null);
12308
12522
  const fiatDropdownRef = useRef10(null);
12309
- useEffect22(() => {
12310
- if (typeof window === "undefined") {
12311
- return;
12312
- }
12313
- const walletConnect = TrustwareConfigStore.peek()?.walletConnect;
12314
- getUniversalConnector(walletConnect).then(
12315
- setUniversalConnector
12316
- );
12317
- }, [TrustwareConfigStore.peek()?.walletConnect]);
12318
- useEffect22(() => {
12523
+ useEffect23(() => {
12319
12524
  const handleClickOutside = (event) => {
12320
12525
  if (cryptoDropdownRef.current && !cryptoDropdownRef.current.contains(event.target)) {
12321
12526
  setIsCryptoDropdownOpen(false);
@@ -12331,6 +12536,7 @@ function useHomeWalletActions({
12331
12536
  const handleWalletSelect = async (wallet) => {
12332
12537
  setIsCryptoDropdownOpen(false);
12333
12538
  try {
12539
+ setWalletType("other");
12334
12540
  const { error } = await connectWallet(wallet);
12335
12541
  if (error) {
12336
12542
  resetNavigation();
@@ -12345,13 +12551,7 @@ function useHomeWalletActions({
12345
12551
  setIsFiatDropdownOpen(false);
12346
12552
  };
12347
12553
  const handleWalletConnect = async () => {
12348
- if (!universalConnector) {
12349
- return;
12350
- }
12351
- const { session: providerSession } = await universalConnector.connect();
12352
- if (providerSession) {
12353
- setCurrentStep("select-token");
12354
- }
12554
+ WalletConnect().catch(() => resetNavigation());
12355
12555
  };
12356
12556
  const browserWallets = detectedWallets.filter(
12357
12557
  (wallet) => wallet.meta.id !== "walletconnect"
@@ -12375,7 +12575,7 @@ import { jsx as jsx42, jsxs as jsxs33 } from "react/jsx-runtime";
12375
12575
  function Home({ style: _style }) {
12376
12576
  const { amount, setAmount, amountInputMode, setAmountInputMode } = useDepositForm();
12377
12577
  const { setCurrentStep, setCurrentStepInternal } = useDepositNavigation();
12378
- const { connectWallet } = useDepositWallet();
12578
+ const { connectWallet, WalletConnect, setWalletType } = useDepositWallet();
12379
12579
  const { resolvedTheme } = useDepositUi();
12380
12580
  const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
12381
12581
  const { detected: detectedWallets } = useWalletDetection();
@@ -12404,7 +12604,9 @@ function Home({ style: _style }) {
12404
12604
  connectWallet,
12405
12605
  detectedWallets,
12406
12606
  setCurrentStep,
12407
- setCurrentStepInternal
12607
+ setCurrentStepInternal,
12608
+ WalletConnect,
12609
+ setWalletType
12408
12610
  });
12409
12611
  return /* @__PURE__ */ jsxs33(
12410
12612
  "div",
@@ -12685,7 +12887,7 @@ function SelectToken({ style }) {
12685
12887
  }
12686
12888
 
12687
12889
  // src/widget/pages/CryptoPay/index.tsx
12688
- import { useEffect as useEffect24, useMemo as useMemo18 } from "react";
12890
+ import { useEffect as useEffect25, useMemo as useMemo18 } from "react";
12689
12891
 
12690
12892
  // src/widget/features/route-preview/hooks/useRoutePreviewModel.ts
12691
12893
  import { useMemo as useMemo16 } from "react";
@@ -12701,6 +12903,7 @@ function useRoutePreviewModel({
12701
12903
  walletAddress
12702
12904
  }) {
12703
12905
  const { chains } = useChains();
12906
+ console.log({ walletAddress });
12704
12907
  const destinationConfig = useMemo16(
12705
12908
  () => ({
12706
12909
  dappName: config.messages?.title || "DApp",
@@ -13188,7 +13391,7 @@ function SuccessSummaryCard({
13188
13391
  }
13189
13392
 
13190
13393
  // src/widget/features/transaction/hooks/useTransactionActionModel.ts
13191
- import { useCallback as useCallback14, useEffect as useEffect23, useMemo as useMemo17, useRef as useRef11, useState as useState22 } from "react";
13394
+ import { useCallback as useCallback15, useEffect as useEffect24, useMemo as useMemo17, useRef as useRef11, useState as useState23 } from "react";
13192
13395
  import { encodeFunctionData, erc20Abi } from "viem";
13193
13396
  init_constants();
13194
13397
  function normalizeTokenAddressForCompare(chain, addr) {
@@ -13246,11 +13449,11 @@ function useTransactionActionModel({
13246
13449
  const addr = txReq?.to ?? txReq?.target;
13247
13450
  return addr ?? null;
13248
13451
  }, [routeResult?.txReq]);
13249
- const [allowanceWei, setAllowanceWei] = useState22(0n);
13250
- const [isReadingAllowance, setIsReadingAllowance] = useState22(false);
13251
- const [isApproving, setIsApproving] = useState22(false);
13252
- const [gasReservationWei, setGasReservationWei] = useState22(0n);
13253
- const readAllowance = useCallback14(async () => {
13452
+ const [allowanceWei, setAllowanceWei] = useState23(0n);
13453
+ const [isReadingAllowance, setIsReadingAllowance] = useState23(false);
13454
+ const [isApproving, setIsApproving] = useState23(false);
13455
+ const [gasReservationWei, setGasReservationWei] = useState23(0n);
13456
+ const readAllowance = useCallback15(async () => {
13254
13457
  if (!isEvm || isNativeSelected || !backendChainId2 || !walletAddress || !spender || !selectedToken?.address) {
13255
13458
  setAllowanceWei(0n);
13256
13459
  return;
@@ -13277,11 +13480,11 @@ function useTransactionActionModel({
13277
13480
  spender,
13278
13481
  walletAddress
13279
13482
  ]);
13280
- useEffect23(() => {
13483
+ useEffect24(() => {
13281
13484
  void readAllowance();
13282
13485
  }, [readAllowance]);
13283
13486
  const needsApproval = isEvm && !isNativeSelected && !!walletAddress && !!spender && amountWei > 0n && allowanceWei < amountWei;
13284
- const waitForApprovalConfirmation = useCallback14(
13487
+ const waitForApprovalConfirmation = useCallback15(
13285
13488
  async (chainId, txHash) => {
13286
13489
  const timeoutMs = 12e4;
13287
13490
  const intervalMs = 2e3;
@@ -13300,7 +13503,7 @@ function useTransactionActionModel({
13300
13503
  },
13301
13504
  []
13302
13505
  );
13303
- const handleApproveExact = useCallback14(async () => {
13506
+ const handleApproveExact = useCallback15(async () => {
13304
13507
  if (isApproving || amountWei <= 0n || !walletAddress || !spender || !selectedToken?.address) {
13305
13508
  return;
13306
13509
  }
@@ -13388,7 +13591,7 @@ function useTransactionActionModel({
13388
13591
  waitForApprovalConfirmation,
13389
13592
  walletAddress
13390
13593
  ]);
13391
- const getCachedFeeData = useCallback14(async () => {
13594
+ const getCachedFeeData = useCallback15(async () => {
13392
13595
  if (!backendChainId2) return {};
13393
13596
  const now = Date.now();
13394
13597
  const cache = feeDataCacheRef.current;
@@ -13411,7 +13614,7 @@ function useTransactionActionModel({
13411
13614
  }
13412
13615
  return cache.inflight;
13413
13616
  }, [backendChainId2]);
13414
- const estimateGasReservationWei = useCallback14(async () => {
13617
+ const estimateGasReservationWei = useCallback15(async () => {
13415
13618
  if (!isNativeSelected) {
13416
13619
  setGasReservationWei(0n);
13417
13620
  return 0n;
@@ -13475,12 +13678,12 @@ function useTransactionActionModel({
13475
13678
  routeResult?.txReq,
13476
13679
  walletAddress
13477
13680
  ]);
13478
- useEffect23(() => {
13681
+ useEffect24(() => {
13479
13682
  if (routeResult) {
13480
13683
  void estimateGasReservationWei();
13481
13684
  }
13482
13685
  }, [estimateGasReservationWei, routeResult]);
13483
- const handleConfirm = useCallback14(async () => {
13686
+ const handleConfirm = useCallback15(async () => {
13484
13687
  if (!routeResult) {
13485
13688
  return;
13486
13689
  }
@@ -13503,7 +13706,7 @@ function useTransactionActionModel({
13503
13706
  submitTransaction,
13504
13707
  trackEvent
13505
13708
  ]);
13506
- const handleSwipeConfirm = useCallback14(async () => {
13709
+ const handleSwipeConfirm = useCallback15(async () => {
13507
13710
  if (needsApproval) {
13508
13711
  await handleApproveExact();
13509
13712
  return;
@@ -13726,6 +13929,7 @@ function CryptoPay({ style: _style }) {
13726
13929
  } = useDepositForm();
13727
13930
  const {
13728
13931
  walletAddress,
13932
+ walletType,
13729
13933
  walletStatus,
13730
13934
  yourWalletTokens,
13731
13935
  yourWalletTokensLoading
@@ -13805,6 +14009,7 @@ function CryptoPay({ style: _style }) {
13805
14009
  selectedChain,
13806
14010
  selectedToken,
13807
14011
  walletAddress,
14012
+ walletType,
13808
14013
  walletStatus
13809
14014
  });
13810
14015
  const { handleTokenChange, orderedTokens } = useOrderedWalletTokens({
@@ -13817,7 +14022,7 @@ function CryptoPay({ style: _style }) {
13817
14022
  });
13818
14023
  const { emitError } = useTrustware();
13819
14024
  const readySelectedToken = isReady ? selectedToken : null;
13820
- useEffect24(() => {
14025
+ useEffect25(() => {
13821
14026
  if (currentStep !== "crypto-pay" || !actionErrorMessage) return;
13822
14027
  emitError?.(
13823
14028
  new TrustwareError({
@@ -13912,7 +14117,7 @@ function CryptoPay({ style: _style }) {
13912
14117
  isApproving,
13913
14118
  isLoadingRoute,
13914
14119
  isReadingAllowance,
13915
- isWalletConnected,
14120
+ isWalletConnected: isWalletConnected ? isWalletConnected : walletAddress !== null && walletType == "walletconnect" ? true : false,
13916
14121
  needsApproval,
13917
14122
  selectedToken: readySelectedToken,
13918
14123
  swipeResetKey
@@ -13928,7 +14133,7 @@ function CryptoPay({ style: _style }) {
13928
14133
  }
13929
14134
 
13930
14135
  // src/widget/pages/Processing.tsx
13931
- import { useEffect as useEffect25, useMemo as useMemo19, useRef as useRef12 } from "react";
14136
+ import { useEffect as useEffect26, useMemo as useMemo19, useRef as useRef12 } from "react";
13932
14137
  import { jsx as jsx49, jsxs as jsxs39 } from "react/jsx-runtime";
13933
14138
  function getProgressFromStatus(status) {
13934
14139
  switch (status) {
@@ -13968,12 +14173,12 @@ function Processing({ style }) {
13968
14173
  const { transactionStatus, transactionHash, intentId } = useDepositTransaction();
13969
14174
  const { transaction, startPolling, isPolling } = useTransactionPolling();
13970
14175
  const hasStartedPolling = useRef12(false);
13971
- useEffect25(() => {
14176
+ useEffect26(() => {
13972
14177
  return () => {
13973
14178
  hasStartedPolling.current = false;
13974
14179
  };
13975
14180
  }, []);
13976
- useEffect25(() => {
14181
+ useEffect26(() => {
13977
14182
  if (intentId && transactionHash && !isPolling && !hasStartedPolling.current && transactionStatus !== "success" && transactionStatus !== "error") {
13978
14183
  hasStartedPolling.current = true;
13979
14184
  startPolling(intentId, transactionHash);
@@ -14196,7 +14401,7 @@ function Success({ style }) {
14196
14401
  }
14197
14402
 
14198
14403
  // src/widget/pages/Error.tsx
14199
- import { useMemo as useMemo21, useEffect as useEffect26 } from "react";
14404
+ import { useMemo as useMemo21, useEffect as useEffect27 } from "react";
14200
14405
  init_store();
14201
14406
  import { jsx as jsx51, jsxs as jsxs41 } from "react/jsx-runtime";
14202
14407
  function categorizeError(errorMessage) {
@@ -14298,7 +14503,7 @@ function Error2({ style }) {
14298
14503
  [errorCategory]
14299
14504
  );
14300
14505
  const retryStep = useMemo21(() => getRetryStep(errorCategory), [errorCategory]);
14301
- useEffect26(() => {
14506
+ useEffect27(() => {
14302
14507
  if (errorMessage) {
14303
14508
  try {
14304
14509
  const config = TrustwareConfigStore.get();
@@ -14499,7 +14704,7 @@ function WidgetContent({
14499
14704
  const { amount, selectedChain, selectedToken } = useDepositForm();
14500
14705
  const { transactionHash, transactionStatus } = useDepositTransaction();
14501
14706
  const { resolvedTheme, toggleTheme } = useDepositUi();
14502
- useEffect27(() => {
14707
+ useEffect28(() => {
14503
14708
  const state = {
14504
14709
  currentStep,
14505
14710
  amount,
@@ -14542,8 +14747,8 @@ function WidgetInner({
14542
14747
  const { transactionStatus } = useDepositTransaction();
14543
14748
  const { resolvedTheme } = useDepositUi();
14544
14749
  const { status, revalidate } = useTrustware();
14545
- const [showConfirmDialog, setShowConfirmDialog] = useState23(false);
14546
- const handleCloseRequest = useCallback15(() => {
14750
+ const [showConfirmDialog, setShowConfirmDialog] = useState24(false);
14751
+ const handleCloseRequest = useCallback16(() => {
14547
14752
  if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
14548
14753
  setShowConfirmDialog(true);
14549
14754
  } else {
@@ -14554,20 +14759,20 @@ function WidgetInner({
14554
14759
  onClose?.();
14555
14760
  }
14556
14761
  }, [transactionStatus, onClose, resetState]);
14557
- useEffect27(() => {
14762
+ useEffect28(() => {
14558
14763
  closeRequestRef.current = handleCloseRequest;
14559
14764
  }, [handleCloseRequest, closeRequestRef]);
14560
- const handleConfirmClose = useCallback15(() => {
14765
+ const handleConfirmClose = useCallback16(() => {
14561
14766
  setShowConfirmDialog(false);
14562
14767
  onClose?.();
14563
14768
  }, [onClose]);
14564
- const handleCancelClose = useCallback15(() => {
14769
+ const handleCancelClose = useCallback16(() => {
14565
14770
  setShowConfirmDialog(false);
14566
14771
  }, []);
14567
14772
  const effectiveTheme = resolvedTheme;
14568
14773
  const isRefreshing = status === "initializing";
14569
14774
  const initBlocked = status === "error";
14570
- const handleRefresh = useCallback15(() => {
14775
+ const handleRefresh = useCallback16(() => {
14571
14776
  revalidate?.();
14572
14777
  }, [revalidate]);
14573
14778
  return /* @__PURE__ */ jsxs42(Fragment7, { children: [
@@ -14609,14 +14814,14 @@ var TrustwareWidgetV2 = forwardRef(function TrustwareWidgetV22({
14609
14814
  onOpen,
14610
14815
  showThemeToggle = true
14611
14816
  }, ref) {
14612
- const [isOpen, setIsOpen] = useState23(defaultOpen);
14817
+ const [isOpen, setIsOpen] = useState24(defaultOpen);
14613
14818
  const closeRequestRef = useRef13(null);
14614
14819
  const effectiveInitialStep = initialStep;
14615
- const open = useCallback15(() => {
14820
+ const open = useCallback16(() => {
14616
14821
  setIsOpen(true);
14617
14822
  onOpen?.();
14618
14823
  }, [onOpen]);
14619
- const close = useCallback15(() => {
14824
+ const close = useCallback16(() => {
14620
14825
  if (closeRequestRef.current) {
14621
14826
  closeRequestRef.current();
14622
14827
  } else {
@@ -14624,7 +14829,7 @@ var TrustwareWidgetV2 = forwardRef(function TrustwareWidgetV22({
14624
14829
  onClose?.();
14625
14830
  }
14626
14831
  }, [onClose]);
14627
- const handleClose = useCallback15(() => {
14832
+ const handleClose = useCallback16(() => {
14628
14833
  setIsOpen(false);
14629
14834
  onClose?.();
14630
14835
  }, [onClose]);