@unifold/ui-web 0.1.59 → 0.1.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +242 -114
  2. package/dist/index.mjs +242 -114
  3. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -44159,6 +44159,56 @@ var cva = (base, config) => (props) => {
44159
44159
  }, []);
44160
44160
  return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
44161
44161
  };
44162
+ function requestProviders(listener) {
44163
+ if (typeof window === "undefined")
44164
+ return;
44165
+ const handler = (event) => listener(event.detail);
44166
+ window.addEventListener("eip6963:announceProvider", handler);
44167
+ window.dispatchEvent(new CustomEvent("eip6963:requestProvider"));
44168
+ return () => window.removeEventListener("eip6963:announceProvider", handler);
44169
+ }
44170
+ function createStore() {
44171
+ const listeners = /* @__PURE__ */ new Set();
44172
+ let providerDetails = [];
44173
+ const request = () => requestProviders((providerDetail) => {
44174
+ if (providerDetails.some(({ info }) => info.uuid === providerDetail.info.uuid))
44175
+ return;
44176
+ providerDetails = [...providerDetails, providerDetail];
44177
+ listeners.forEach((listener) => listener(providerDetails, { added: [providerDetail] }));
44178
+ });
44179
+ let unwatch = request();
44180
+ return {
44181
+ _listeners() {
44182
+ return listeners;
44183
+ },
44184
+ clear() {
44185
+ listeners.forEach((listener) => listener([], { removed: [...providerDetails] }));
44186
+ providerDetails = [];
44187
+ },
44188
+ destroy() {
44189
+ this.clear();
44190
+ listeners.clear();
44191
+ unwatch?.();
44192
+ },
44193
+ findProvider({ rdns }) {
44194
+ return providerDetails.find((providerDetail) => providerDetail.info.rdns === rdns);
44195
+ },
44196
+ getProviders() {
44197
+ return providerDetails;
44198
+ },
44199
+ reset() {
44200
+ this.clear();
44201
+ unwatch?.();
44202
+ unwatch = request();
44203
+ },
44204
+ subscribe(listener, { emitImmediately } = {}) {
44205
+ listeners.add(listener);
44206
+ if (emitImmediately)
44207
+ listener(providerDetails, { added: providerDetails });
44208
+ return () => listeners.delete(listener);
44209
+ }
44210
+ };
44211
+ }
44162
44212
  function isArray(value) {
44163
44213
  return !Array.isArray ? getTag(value) === "[object Array]" : Array.isArray(value);
44164
44214
  }
@@ -51452,7 +51502,7 @@ function interpolate(template, params) {
51452
51502
  }
51453
51503
  var DEPOSIT_CONFIRM_DELAY_MS = 5e3;
51454
51504
  var POLL_INTERVAL_MS = 2500;
51455
- var POLL_ENDPOINT_INTERVAL_MS = 3e3;
51505
+ var POLL_ENDPOINT_INTERVAL_MS = 5e3;
51456
51506
  var CUTOFF_BUFFER_MS = 6e4;
51457
51507
  function useDepositPolling({
51458
51508
  userId,
@@ -55094,6 +55144,53 @@ function CashAppButton({
55094
55144
  }
55095
55145
  );
55096
55146
  }
55147
+ var _store = null;
55148
+ function getEip6963Store() {
55149
+ if (typeof window === "undefined") return null;
55150
+ if (!_store) {
55151
+ _store = createStore();
55152
+ }
55153
+ return _store;
55154
+ }
55155
+ var RDNS_TO_WALLET_ID = {
55156
+ "io.metamask": "metamask",
55157
+ "io.metamask.flask": "metamask",
55158
+ "io.metamask.mmi": "metamask",
55159
+ "app.phantom": "phantom",
55160
+ "com.coinbase.wallet": "coinbase",
55161
+ "com.okex.wallet": "okx",
55162
+ "io.rabby": "rabby",
55163
+ "com.trustwallet.app": "trust",
55164
+ "me.rainbow": "rainbow"
55165
+ };
55166
+ function rdnsToWalletId(rdns) {
55167
+ if (RDNS_TO_WALLET_ID[rdns]) return RDNS_TO_WALLET_ID[rdns];
55168
+ if (rdns.includes("metamask")) return "metamask";
55169
+ if (rdns.includes("phantom")) return "phantom";
55170
+ if (rdns.includes("coinbase")) return "coinbase";
55171
+ if (rdns.includes("okx") || rdns.includes("okex")) return "okx";
55172
+ if (rdns.includes("rabby")) return "rabby";
55173
+ if (rdns.includes("trust")) return "trust";
55174
+ if (rdns.includes("rainbow")) return "rainbow";
55175
+ return "unknown";
55176
+ }
55177
+ function getEip6963Providers() {
55178
+ const store = getEip6963Store();
55179
+ if (!store) return [];
55180
+ return store.getProviders().map((detail) => ({
55181
+ walletId: rdnsToWalletId(detail.info.rdns),
55182
+ provider: detail.provider,
55183
+ info: detail.info
55184
+ }));
55185
+ }
55186
+ function findProviderByWalletId(walletId) {
55187
+ return getEip6963Providers().find((p) => p.walletId === walletId);
55188
+ }
55189
+ function collectAllEip6963EthProviders() {
55190
+ const store = getEip6963Store();
55191
+ if (!store) return [];
55192
+ return store.getProviders().map((d) => d.provider);
55193
+ }
55097
55194
  var SOLANA_DISCONNECT_TYPES = [
55098
55195
  "phantom-solana",
55099
55196
  "solflare",
@@ -55133,8 +55230,9 @@ function collectEthereumProvidersForDisconnect(win) {
55133
55230
  out.push(p);
55134
55231
  }
55135
55232
  };
55136
- const list = anyWin.__eip6963Providers || [];
55137
- for (const d of list) add(d.provider);
55233
+ for (const p of collectAllEip6963EthProviders()) {
55234
+ add(p);
55235
+ }
55138
55236
  add(win.ethereum);
55139
55237
  add(
55140
55238
  win.phantom?.ethereum
@@ -57140,30 +57238,13 @@ function BrowserWalletButton({
57140
57238
  }, []);
57141
57239
  const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
57142
57240
  React242.useEffect(() => {
57143
- if (typeof window === "undefined") return;
57144
- const anyWin = window;
57145
- if (!anyWin.__eip6963Providers) {
57146
- anyWin.__eip6963Providers = [];
57147
- }
57148
- const handleAnnouncement = (event) => {
57149
- const { detail } = event;
57150
- if (!detail?.info || !detail?.provider) return;
57151
- const exists = anyWin.__eip6963Providers.some(
57152
- (p) => p.info.uuid === detail.info.uuid
57153
- );
57154
- if (!exists) {
57155
- anyWin.__eip6963Providers.push(detail);
57156
- setEip6963ProviderCount(anyWin.__eip6963Providers.length);
57157
- }
57158
- };
57159
- window.addEventListener("eip6963:announceProvider", handleAnnouncement);
57160
- window.dispatchEvent(new Event("eip6963:requestProvider"));
57161
- return () => {
57162
- window.removeEventListener(
57163
- "eip6963:announceProvider",
57164
- handleAnnouncement
57165
- );
57166
- };
57241
+ const store = getEip6963Store();
57242
+ if (!store) return;
57243
+ setEip6963ProviderCount(store.getProviders().length);
57244
+ const unsubscribe = store.subscribe((providers) => {
57245
+ setEip6963ProviderCount(providers.length);
57246
+ });
57247
+ return unsubscribe;
57167
57248
  }, []);
57168
57249
  React242.useEffect(() => {
57169
57250
  if (!wallet || !publishableKey) {
@@ -57222,7 +57303,7 @@ function BrowserWalletButton({
57222
57303
  return;
57223
57304
  }
57224
57305
  if (!chainType || chainType === "solana") {
57225
- const anyWin2 = win;
57306
+ const anyWin = win;
57226
57307
  const trySilentSolana = async (provider, type, name, icon) => {
57227
57308
  if (!provider) return false;
57228
57309
  if (provider.isConnected && provider.publicKey) {
@@ -57261,21 +57342,21 @@ function BrowserWalletButton({
57261
57342
  ))
57262
57343
  return;
57263
57344
  if (await trySilentSolana(
57264
- anyWin2.solflare,
57345
+ anyWin.solflare,
57265
57346
  "solflare",
57266
57347
  "Solflare",
57267
57348
  "solflare"
57268
57349
  ))
57269
57350
  return;
57270
57351
  if (await trySilentSolana(
57271
- anyWin2.backpack,
57352
+ anyWin.backpack,
57272
57353
  "backpack",
57273
57354
  "Backpack",
57274
57355
  "backpack"
57275
57356
  ))
57276
57357
  return;
57277
57358
  if (await trySilentSolana(
57278
- anyWin2.glow,
57359
+ anyWin.glow,
57279
57360
  "glow",
57280
57361
  "Glow",
57281
57362
  "glow"
@@ -57283,19 +57364,14 @@ function BrowserWalletButton({
57283
57364
  return;
57284
57365
  }
57285
57366
  if (!chainType || chainType === "ethereum") {
57286
- const anyWin2 = win;
57367
+ const anyWin = win;
57287
57368
  const allProviders = [];
57288
- const eip6963Providers = anyWin2.__eip6963Providers || [];
57289
- for (const { info, provider } of eip6963Providers) {
57290
- let walletId = "default";
57291
- if (info.rdns.includes("metamask")) walletId = "metamask";
57292
- else if (info.rdns.includes("phantom")) walletId = "phantom";
57293
- else if (info.rdns.includes("coinbase")) walletId = "coinbase";
57294
- else if (info.rdns.includes("okx")) walletId = "okx";
57295
- else if (info.rdns.includes("rabby")) walletId = "rabby";
57296
- else if (info.rdns.includes("trust")) walletId = "trust";
57297
- else if (info.rdns.includes("rainbow")) walletId = "rainbow";
57298
- allProviders.push({ provider, walletId });
57369
+ const eip6963 = getEip6963Providers();
57370
+ for (const { provider, walletId } of eip6963) {
57371
+ allProviders.push({
57372
+ provider,
57373
+ walletId: walletId === "unknown" ? "default" : walletId
57374
+ });
57299
57375
  }
57300
57376
  if (allProviders.length === 0) {
57301
57377
  if (win.phantom?.ethereum) {
@@ -57304,15 +57380,15 @@ function BrowserWalletButton({
57304
57380
  walletId: "phantom"
57305
57381
  });
57306
57382
  }
57307
- if (anyWin2.okxwallet) {
57383
+ if (anyWin.okxwallet) {
57308
57384
  allProviders.push({
57309
- provider: anyWin2.okxwallet,
57385
+ provider: anyWin.okxwallet,
57310
57386
  walletId: "okx"
57311
57387
  });
57312
57388
  }
57313
- if (anyWin2.coinbaseWalletExtension) {
57389
+ if (anyWin.coinbaseWalletExtension) {
57314
57390
  allProviders.push({
57315
- provider: anyWin2.coinbaseWalletExtension,
57391
+ provider: anyWin.coinbaseWalletExtension,
57316
57392
  walletId: "coinbase"
57317
57393
  });
57318
57394
  }
@@ -57336,7 +57412,7 @@ function BrowserWalletButton({
57336
57412
  });
57337
57413
  if (!accounts || accounts.length === 0) continue;
57338
57414
  const address = accounts[0];
57339
- const resolved = identifyEthWallet(provider, anyWin2, walletId);
57415
+ const resolved = identifyEthWallet(provider, anyWin, walletId);
57340
57416
  if (mounted) {
57341
57417
  setWallet({ ...resolved, address });
57342
57418
  setIsLoading(false);
@@ -57378,15 +57454,11 @@ function BrowserWalletButton({
57378
57454
  solanaProvider.on("disconnect", handleDisconnect);
57379
57455
  solanaProvider.on("accountChanged", handleAccountsChanged);
57380
57456
  }
57381
- const anyWin = window;
57382
57457
  const ethProviders = [];
57383
- if (anyWin.__eip6963Providers) {
57384
- for (const {
57385
- provider
57386
- } of anyWin.__eip6963Providers) {
57387
- if (provider && !ethProviders.includes(provider)) {
57388
- ethProviders.push(provider);
57389
- }
57458
+ for (const { provider } of getEip6963Providers()) {
57459
+ const p = provider;
57460
+ if (p && !ethProviders.includes(p)) {
57461
+ ethProviders.push(p);
57390
57462
  }
57391
57463
  }
57392
57464
  if (window.ethereum && !ethProviders.includes(window.ethereum)) {
@@ -57488,7 +57560,7 @@ function BrowserWalletButton({
57488
57560
  if (isLoading) {
57489
57561
  return null;
57490
57562
  }
57491
- const hasWalletExtension = (!chainType || chainType === "solana") && (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) ? true : (!chainType || chainType === "ethereum") && (window.phantom?.ethereum || window.ethereum) ? true : false;
57563
+ const hasWalletExtension = (!chainType || chainType === "ethereum") && getEip6963Providers().length > 0 || (!chainType || chainType === "solana") && (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) || (!chainType || chainType === "ethereum") && (window.phantom?.ethereum || window.ethereum);
57492
57564
  if (!onConnectClick && !wallet && !hasWalletExtension) {
57493
57565
  return null;
57494
57566
  }
@@ -62996,15 +63068,10 @@ var WALLET_DEFINITIONS = [
62996
63068
  { id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
62997
63069
  { id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
62998
63070
  ];
62999
- function getWalletProviders() {
63071
+ function getSolanaProviders() {
63000
63072
  if (typeof window === "undefined") return {};
63001
63073
  const win = window;
63002
63074
  return {
63003
- ethereum: win.ethereum,
63004
- phantomEthereum: win.phantom?.ethereum,
63005
- coinbaseEthereum: win.coinbaseWalletExtension,
63006
- trustEthereum: win.trustwallet?.ethereum,
63007
- okxEthereum: win.okxwallet,
63008
63075
  phantomSolana: win.phantom?.solana,
63009
63076
  solflare: win.solflare,
63010
63077
  backpack: win.backpack,
@@ -63012,37 +63079,71 @@ function getWalletProviders() {
63012
63079
  coinbaseSolana: win.coinbaseSolana || win.coinbaseWalletExtension?.solana
63013
63080
  };
63014
63081
  }
63082
+ function getLegacyEvmProviders() {
63083
+ if (typeof window === "undefined") return {};
63084
+ const win = window;
63085
+ return {
63086
+ ethereum: win.ethereum,
63087
+ phantomEthereum: win.phantom?.ethereum,
63088
+ coinbaseEthereum: win.coinbaseWalletExtension,
63089
+ trustEthereum: win.trustwallet?.ethereum,
63090
+ okxEthereum: win.okxwallet
63091
+ };
63092
+ }
63015
63093
  function detectAvailableWallets(filterChainType) {
63016
- const providers = getWalletProviders();
63094
+ const solProviders = getSolanaProviders();
63095
+ const legacyEvm = getLegacyEvmProviders();
63096
+ const eip6963List = getEip6963Providers();
63017
63097
  const win = typeof window !== "undefined" ? window : null;
63098
+ const hasEip6963 = (walletId) => eip6963List.some((d) => {
63099
+ const rdns = d.info?.rdns || "";
63100
+ switch (walletId) {
63101
+ case "metamask":
63102
+ return rdns.includes("metamask");
63103
+ case "phantom":
63104
+ return rdns.includes("phantom");
63105
+ case "coinbase":
63106
+ return rdns.includes("coinbase");
63107
+ case "trust":
63108
+ return rdns.includes("trust");
63109
+ case "rainbow":
63110
+ return rdns.includes("rainbow");
63111
+ case "rabby":
63112
+ return rdns.includes("rabby");
63113
+ case "okx":
63114
+ return rdns.includes("okx") || rdns.includes("okex");
63115
+ default:
63116
+ return false;
63117
+ }
63118
+ });
63018
63119
  return WALLET_DEFINITIONS.filter((w) => !filterChainType || w.networks.includes(filterChainType)).map((wallet) => {
63019
63120
  let isInstalled = false;
63020
63121
  const detectedNetworks = [];
63021
63122
  switch (wallet.id) {
63022
63123
  case "metamask":
63023
- isInstalled = !!(providers.ethereum?.isMetaMask && !providers.ethereum?.isPhantom && !providers.ethereum?.isRabby && !providers.ethereum?.isOkxWallet);
63124
+ isInstalled = hasEip6963("metamask") || !!(legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom && !legacyEvm.ethereum?.isRabby && !legacyEvm.ethereum?.isOkxWallet);
63024
63125
  if (isInstalled) detectedNetworks.push("ethereum");
63025
63126
  break;
63026
63127
  case "phantom":
63027
- if (providers.phantomSolana?.isPhantom) {
63128
+ if (solProviders.phantomSolana?.isPhantom) {
63028
63129
  isInstalled = true;
63029
63130
  detectedNetworks.push("solana");
63030
63131
  }
63031
- if (providers.phantomEthereum?.isPhantom) {
63132
+ if (hasEip6963("phantom") || legacyEvm.phantomEthereum?.isPhantom) {
63032
63133
  isInstalled = true;
63033
63134
  detectedNetworks.push("ethereum");
63034
63135
  }
63035
63136
  break;
63036
63137
  case "coinbase":
63037
- if (providers.coinbaseEthereum || providers.ethereum?.isCoinbaseWallet) {
63138
+ if (hasEip6963("coinbase") || legacyEvm.coinbaseEthereum || legacyEvm.ethereum?.isCoinbaseWallet) {
63038
63139
  isInstalled = true;
63039
63140
  detectedNetworks.push("ethereum");
63040
63141
  }
63041
- if (providers.coinbaseSolana || win?.coinbaseWalletExtension?.solana) detectedNetworks.push("solana");
63142
+ if (solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana) detectedNetworks.push("solana");
63042
63143
  if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
63043
63144
  break;
63044
63145
  case "trust":
63045
- if (providers.trustEthereum || providers.ethereum?.isTrust || win?.trustwallet) {
63146
+ if (hasEip6963("trust") || legacyEvm.trustEthereum || legacyEvm.ethereum?.isTrust || win?.trustwallet) {
63046
63147
  isInstalled = true;
63047
63148
  detectedNetworks.push("ethereum");
63048
63149
  }
@@ -63050,27 +63151,27 @@ function detectAvailableWallets(filterChainType) {
63050
63151
  if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
63051
63152
  break;
63052
63153
  case "rainbow":
63053
- isInstalled = !!providers.ethereum?.isRainbow;
63154
+ isInstalled = hasEip6963("rainbow") || !!legacyEvm.ethereum?.isRainbow;
63054
63155
  if (isInstalled) detectedNetworks.push("ethereum");
63055
63156
  break;
63056
63157
  case "rabby":
63057
- isInstalled = !!providers.ethereum?.isRabby;
63158
+ isInstalled = hasEip6963("rabby") || !!legacyEvm.ethereum?.isRabby;
63058
63159
  if (isInstalled) detectedNetworks.push("ethereum");
63059
63160
  break;
63060
63161
  case "okx":
63061
- isInstalled = !!(providers.okxEthereum || providers.ethereum?.isOkxWallet);
63162
+ isInstalled = hasEip6963("okx") || !!(legacyEvm.okxEthereum || legacyEvm.ethereum?.isOkxWallet);
63062
63163
  if (isInstalled) detectedNetworks.push("ethereum");
63063
63164
  break;
63064
63165
  case "solflare":
63065
- isInstalled = !!providers.solflare?.isSolflare;
63166
+ isInstalled = !!solProviders.solflare?.isSolflare;
63066
63167
  if (isInstalled) detectedNetworks.push("solana");
63067
63168
  break;
63068
63169
  case "backpack":
63069
- isInstalled = !!(providers.backpack?.isBackpack || win?.backpack);
63170
+ isInstalled = !!(solProviders.backpack?.isBackpack || win?.backpack);
63070
63171
  if (isInstalled) detectedNetworks.push("solana");
63071
63172
  break;
63072
63173
  case "glow":
63073
- isInstalled = !!(providers.glow?.isGlow || win?.glow);
63174
+ isInstalled = !!(solProviders.glow?.isGlow || win?.glow);
63074
63175
  if (isInstalled) detectedNetworks.push("solana");
63075
63176
  break;
63076
63177
  }
@@ -63125,7 +63226,16 @@ function WalletConnect({
63125
63226
  const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
63126
63227
  const [walletError, setWalletError] = React292.useState(null);
63127
63228
  const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
63128
- const availableWallets = React292.useMemo(() => detectAvailableWallets(), []);
63229
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
63230
+ React292.useEffect(() => {
63231
+ const store = getEip6963Store();
63232
+ if (!store) return;
63233
+ setEip6963ProviderCount(store.getProviders().length);
63234
+ return store.subscribe((providers) => {
63235
+ setEip6963ProviderCount(providers.length);
63236
+ });
63237
+ }, []);
63238
+ const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
63129
63239
  const [balances, setBalances] = React292.useState([]);
63130
63240
  const [isLoading, setIsLoading] = React292.useState(false);
63131
63241
  const [selectedBalance, setSelectedBalance] = React292.useState(null);
@@ -63184,59 +63294,72 @@ function WalletConnect({
63184
63294
  setWalletError(null);
63185
63295
  setIsWalletConnecting(true);
63186
63296
  try {
63187
- const providers = getWalletProviders();
63188
63297
  const win = typeof window !== "undefined" ? window : null;
63189
63298
  let connectedInfo;
63190
63299
  if (network === "ethereum") {
63191
- let provider;
63192
- switch (wallet.id) {
63193
- case "metamask":
63194
- if (providers.ethereum?.isMetaMask && !providers.ethereum?.isPhantom) provider = providers.ethereum;
63195
- break;
63196
- case "phantom":
63197
- provider = providers.phantomEthereum;
63198
- break;
63199
- case "coinbase":
63200
- provider = providers.coinbaseEthereum || (providers.ethereum?.isCoinbaseWallet ? providers.ethereum : void 0);
63201
- break;
63202
- case "trust":
63203
- provider = providers.trustEthereum || (providers.ethereum?.isTrust ? providers.ethereum : void 0);
63204
- break;
63205
- case "rainbow":
63206
- if (providers.ethereum?.isRainbow) provider = providers.ethereum;
63207
- break;
63208
- case "rabby":
63209
- if (providers.ethereum?.isRabby) provider = providers.ethereum;
63210
- break;
63211
- case "okx":
63212
- provider = providers.okxEthereum || (providers.ethereum?.isOkxWallet ? providers.ethereum : void 0);
63213
- break;
63214
- default:
63215
- provider = providers.ethereum;
63300
+ const eip6963Match = findProviderByWalletId(wallet.id);
63301
+ let provider = eip6963Match?.provider;
63302
+ if (!provider) {
63303
+ const legacyEvm = getLegacyEvmProviders();
63304
+ switch (wallet.id) {
63305
+ case "metamask":
63306
+ if (legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom) provider = legacyEvm.ethereum;
63307
+ break;
63308
+ case "phantom":
63309
+ provider = legacyEvm.phantomEthereum;
63310
+ break;
63311
+ case "coinbase":
63312
+ provider = legacyEvm.coinbaseEthereum || (legacyEvm.ethereum?.isCoinbaseWallet ? legacyEvm.ethereum : void 0);
63313
+ break;
63314
+ case "trust":
63315
+ provider = legacyEvm.trustEthereum || (legacyEvm.ethereum?.isTrust ? legacyEvm.ethereum : void 0);
63316
+ break;
63317
+ case "rainbow":
63318
+ if (legacyEvm.ethereum?.isRainbow) provider = legacyEvm.ethereum;
63319
+ break;
63320
+ case "rabby":
63321
+ if (legacyEvm.ethereum?.isRabby) provider = legacyEvm.ethereum;
63322
+ break;
63323
+ case "okx":
63324
+ provider = legacyEvm.okxEthereum || (legacyEvm.ethereum?.isOkxWallet ? legacyEvm.ethereum : void 0);
63325
+ break;
63326
+ default:
63327
+ provider = legacyEvm.ethereum;
63328
+ }
63216
63329
  }
63217
63330
  if (!provider) throw new Error(`${wallet.name} wallet not found. Please install it.`);
63218
63331
  const accounts = await provider.request({ method: "eth_requestAccounts" });
63219
63332
  if (!accounts?.length) throw new Error("No accounts returned from wallet");
63220
63333
  setUserDisconnectedWallet(false);
63221
- const walletType = wallet.id === "phantom" ? "phantom-ethereum" : wallet.id === "coinbase" ? "coinbase" : "metamask";
63334
+ const walletIdToType = {
63335
+ phantom: "phantom-ethereum",
63336
+ coinbase: "coinbase",
63337
+ trust: "trust",
63338
+ rainbow: "rainbow",
63339
+ rabby: "rabby",
63340
+ okx: "okx",
63341
+ metamask: "metamask"
63342
+ };
63343
+ const walletType = walletIdToType[wallet.id] || "metamask";
63222
63344
  connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
63223
63345
  } else {
63346
+ const solProviders = getSolanaProviders();
63224
63347
  let provider;
63225
63348
  switch (wallet.id) {
63226
63349
  case "phantom":
63227
- provider = providers.phantomSolana;
63350
+ provider = solProviders.phantomSolana;
63228
63351
  break;
63229
63352
  case "solflare":
63230
- provider = providers.solflare;
63353
+ provider = solProviders.solflare;
63231
63354
  break;
63232
63355
  case "backpack":
63233
- provider = providers.backpack || win?.backpack;
63356
+ provider = solProviders.backpack || win?.backpack;
63234
63357
  break;
63235
63358
  case "glow":
63236
- provider = providers.glow || win?.glow;
63359
+ provider = solProviders.glow || win?.glow;
63237
63360
  break;
63238
63361
  case "coinbase":
63239
- provider = providers.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
63362
+ provider = solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
63240
63363
  break;
63241
63364
  case "trust":
63242
63365
  provider = win?.trustwallet?.solana;
@@ -63482,10 +63605,15 @@ function WalletConnect({
63482
63605
  };
63483
63606
  const sendEthereumTransaction = async (token, amountStr) => {
63484
63607
  if (!recipientAddress || !/^0x[a-fA-F0-9]{40}$/.test(recipientAddress)) throw new Error(`Invalid recipient address.`);
63485
- let provider;
63486
- if (walletInfo.type === "phantom-ethereum") provider = window.phantom?.ethereum;
63487
- else if (walletInfo.type === "coinbase") provider = window.coinbaseWalletExtension || window.ethereum;
63488
- else provider = window.ethereum;
63608
+ const walletIdMap = { "phantom-ethereum": "phantom", coinbase: "coinbase", trust: "trust", okx: "okx", rainbow: "rainbow", rabby: "rabby", metamask: "metamask" };
63609
+ const lookupId = walletIdMap[walletInfo.type] || walletInfo.type;
63610
+ const eip6963Match = findProviderByWalletId(lookupId);
63611
+ let provider = eip6963Match?.provider;
63612
+ if (!provider) {
63613
+ if (walletInfo.type === "phantom-ethereum") provider = window.phantom?.ethereum;
63614
+ else if (walletInfo.type === "coinbase") provider = window.coinbaseWalletExtension || window.ethereum;
63615
+ else provider = window.ethereum;
63616
+ }
63489
63617
  if (!provider) throw new Error("Ethereum wallet not found");
63490
63618
  const currentChainIdHex = await provider.request({ method: "eth_chainId", params: [] });
63491
63619
  if (parseInt(currentChainIdHex, 16).toString() !== token.chain_id) {
@@ -65319,7 +65447,7 @@ function useExecutions(userId, publishableKey, options2) {
65319
65447
  });
65320
65448
  }
65321
65449
  var POLL_INTERVAL_MS3 = 2500;
65322
- var POLL_ENDPOINT_INTERVAL_MS2 = 3e3;
65450
+ var POLL_ENDPOINT_INTERVAL_MS2 = 5e3;
65323
65451
  var CUTOFF_BUFFER_MS2 = 6e4;
65324
65452
  function useWithdrawPolling({
65325
65453
  userId,
package/dist/index.mjs CHANGED
@@ -44146,6 +44146,56 @@ var cva = (base, config) => (props) => {
44146
44146
  }, []);
44147
44147
  return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
44148
44148
  };
44149
+ function requestProviders(listener) {
44150
+ if (typeof window === "undefined")
44151
+ return;
44152
+ const handler = (event) => listener(event.detail);
44153
+ window.addEventListener("eip6963:announceProvider", handler);
44154
+ window.dispatchEvent(new CustomEvent("eip6963:requestProvider"));
44155
+ return () => window.removeEventListener("eip6963:announceProvider", handler);
44156
+ }
44157
+ function createStore() {
44158
+ const listeners = /* @__PURE__ */ new Set();
44159
+ let providerDetails = [];
44160
+ const request = () => requestProviders((providerDetail) => {
44161
+ if (providerDetails.some(({ info }) => info.uuid === providerDetail.info.uuid))
44162
+ return;
44163
+ providerDetails = [...providerDetails, providerDetail];
44164
+ listeners.forEach((listener) => listener(providerDetails, { added: [providerDetail] }));
44165
+ });
44166
+ let unwatch = request();
44167
+ return {
44168
+ _listeners() {
44169
+ return listeners;
44170
+ },
44171
+ clear() {
44172
+ listeners.forEach((listener) => listener([], { removed: [...providerDetails] }));
44173
+ providerDetails = [];
44174
+ },
44175
+ destroy() {
44176
+ this.clear();
44177
+ listeners.clear();
44178
+ unwatch?.();
44179
+ },
44180
+ findProvider({ rdns }) {
44181
+ return providerDetails.find((providerDetail) => providerDetail.info.rdns === rdns);
44182
+ },
44183
+ getProviders() {
44184
+ return providerDetails;
44185
+ },
44186
+ reset() {
44187
+ this.clear();
44188
+ unwatch?.();
44189
+ unwatch = request();
44190
+ },
44191
+ subscribe(listener, { emitImmediately } = {}) {
44192
+ listeners.add(listener);
44193
+ if (emitImmediately)
44194
+ listener(providerDetails, { added: providerDetails });
44195
+ return () => listeners.delete(listener);
44196
+ }
44197
+ };
44198
+ }
44149
44199
  function isArray(value) {
44150
44200
  return !Array.isArray ? getTag(value) === "[object Array]" : Array.isArray(value);
44151
44201
  }
@@ -51439,7 +51489,7 @@ function interpolate(template, params) {
51439
51489
  }
51440
51490
  var DEPOSIT_CONFIRM_DELAY_MS = 5e3;
51441
51491
  var POLL_INTERVAL_MS = 2500;
51442
- var POLL_ENDPOINT_INTERVAL_MS = 3e3;
51492
+ var POLL_ENDPOINT_INTERVAL_MS = 5e3;
51443
51493
  var CUTOFF_BUFFER_MS = 6e4;
51444
51494
  function useDepositPolling({
51445
51495
  userId,
@@ -55081,6 +55131,53 @@ function CashAppButton({
55081
55131
  }
55082
55132
  );
55083
55133
  }
55134
+ var _store = null;
55135
+ function getEip6963Store() {
55136
+ if (typeof window === "undefined") return null;
55137
+ if (!_store) {
55138
+ _store = createStore();
55139
+ }
55140
+ return _store;
55141
+ }
55142
+ var RDNS_TO_WALLET_ID = {
55143
+ "io.metamask": "metamask",
55144
+ "io.metamask.flask": "metamask",
55145
+ "io.metamask.mmi": "metamask",
55146
+ "app.phantom": "phantom",
55147
+ "com.coinbase.wallet": "coinbase",
55148
+ "com.okex.wallet": "okx",
55149
+ "io.rabby": "rabby",
55150
+ "com.trustwallet.app": "trust",
55151
+ "me.rainbow": "rainbow"
55152
+ };
55153
+ function rdnsToWalletId(rdns) {
55154
+ if (RDNS_TO_WALLET_ID[rdns]) return RDNS_TO_WALLET_ID[rdns];
55155
+ if (rdns.includes("metamask")) return "metamask";
55156
+ if (rdns.includes("phantom")) return "phantom";
55157
+ if (rdns.includes("coinbase")) return "coinbase";
55158
+ if (rdns.includes("okx") || rdns.includes("okex")) return "okx";
55159
+ if (rdns.includes("rabby")) return "rabby";
55160
+ if (rdns.includes("trust")) return "trust";
55161
+ if (rdns.includes("rainbow")) return "rainbow";
55162
+ return "unknown";
55163
+ }
55164
+ function getEip6963Providers() {
55165
+ const store = getEip6963Store();
55166
+ if (!store) return [];
55167
+ return store.getProviders().map((detail) => ({
55168
+ walletId: rdnsToWalletId(detail.info.rdns),
55169
+ provider: detail.provider,
55170
+ info: detail.info
55171
+ }));
55172
+ }
55173
+ function findProviderByWalletId(walletId) {
55174
+ return getEip6963Providers().find((p) => p.walletId === walletId);
55175
+ }
55176
+ function collectAllEip6963EthProviders() {
55177
+ const store = getEip6963Store();
55178
+ if (!store) return [];
55179
+ return store.getProviders().map((d) => d.provider);
55180
+ }
55084
55181
  var SOLANA_DISCONNECT_TYPES = [
55085
55182
  "phantom-solana",
55086
55183
  "solflare",
@@ -55120,8 +55217,9 @@ function collectEthereumProvidersForDisconnect(win) {
55120
55217
  out.push(p);
55121
55218
  }
55122
55219
  };
55123
- const list = anyWin.__eip6963Providers || [];
55124
- for (const d of list) add(d.provider);
55220
+ for (const p of collectAllEip6963EthProviders()) {
55221
+ add(p);
55222
+ }
55125
55223
  add(win.ethereum);
55126
55224
  add(
55127
55225
  win.phantom?.ethereum
@@ -57127,30 +57225,13 @@ function BrowserWalletButton({
57127
57225
  }, []);
57128
57226
  const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
57129
57227
  React242.useEffect(() => {
57130
- if (typeof window === "undefined") return;
57131
- const anyWin = window;
57132
- if (!anyWin.__eip6963Providers) {
57133
- anyWin.__eip6963Providers = [];
57134
- }
57135
- const handleAnnouncement = (event) => {
57136
- const { detail } = event;
57137
- if (!detail?.info || !detail?.provider) return;
57138
- const exists = anyWin.__eip6963Providers.some(
57139
- (p) => p.info.uuid === detail.info.uuid
57140
- );
57141
- if (!exists) {
57142
- anyWin.__eip6963Providers.push(detail);
57143
- setEip6963ProviderCount(anyWin.__eip6963Providers.length);
57144
- }
57145
- };
57146
- window.addEventListener("eip6963:announceProvider", handleAnnouncement);
57147
- window.dispatchEvent(new Event("eip6963:requestProvider"));
57148
- return () => {
57149
- window.removeEventListener(
57150
- "eip6963:announceProvider",
57151
- handleAnnouncement
57152
- );
57153
- };
57228
+ const store = getEip6963Store();
57229
+ if (!store) return;
57230
+ setEip6963ProviderCount(store.getProviders().length);
57231
+ const unsubscribe = store.subscribe((providers) => {
57232
+ setEip6963ProviderCount(providers.length);
57233
+ });
57234
+ return unsubscribe;
57154
57235
  }, []);
57155
57236
  React242.useEffect(() => {
57156
57237
  if (!wallet || !publishableKey) {
@@ -57209,7 +57290,7 @@ function BrowserWalletButton({
57209
57290
  return;
57210
57291
  }
57211
57292
  if (!chainType || chainType === "solana") {
57212
- const anyWin2 = win;
57293
+ const anyWin = win;
57213
57294
  const trySilentSolana = async (provider, type, name, icon) => {
57214
57295
  if (!provider) return false;
57215
57296
  if (provider.isConnected && provider.publicKey) {
@@ -57248,21 +57329,21 @@ function BrowserWalletButton({
57248
57329
  ))
57249
57330
  return;
57250
57331
  if (await trySilentSolana(
57251
- anyWin2.solflare,
57332
+ anyWin.solflare,
57252
57333
  "solflare",
57253
57334
  "Solflare",
57254
57335
  "solflare"
57255
57336
  ))
57256
57337
  return;
57257
57338
  if (await trySilentSolana(
57258
- anyWin2.backpack,
57339
+ anyWin.backpack,
57259
57340
  "backpack",
57260
57341
  "Backpack",
57261
57342
  "backpack"
57262
57343
  ))
57263
57344
  return;
57264
57345
  if (await trySilentSolana(
57265
- anyWin2.glow,
57346
+ anyWin.glow,
57266
57347
  "glow",
57267
57348
  "Glow",
57268
57349
  "glow"
@@ -57270,19 +57351,14 @@ function BrowserWalletButton({
57270
57351
  return;
57271
57352
  }
57272
57353
  if (!chainType || chainType === "ethereum") {
57273
- const anyWin2 = win;
57354
+ const anyWin = win;
57274
57355
  const allProviders = [];
57275
- const eip6963Providers = anyWin2.__eip6963Providers || [];
57276
- for (const { info, provider } of eip6963Providers) {
57277
- let walletId = "default";
57278
- if (info.rdns.includes("metamask")) walletId = "metamask";
57279
- else if (info.rdns.includes("phantom")) walletId = "phantom";
57280
- else if (info.rdns.includes("coinbase")) walletId = "coinbase";
57281
- else if (info.rdns.includes("okx")) walletId = "okx";
57282
- else if (info.rdns.includes("rabby")) walletId = "rabby";
57283
- else if (info.rdns.includes("trust")) walletId = "trust";
57284
- else if (info.rdns.includes("rainbow")) walletId = "rainbow";
57285
- allProviders.push({ provider, walletId });
57356
+ const eip6963 = getEip6963Providers();
57357
+ for (const { provider, walletId } of eip6963) {
57358
+ allProviders.push({
57359
+ provider,
57360
+ walletId: walletId === "unknown" ? "default" : walletId
57361
+ });
57286
57362
  }
57287
57363
  if (allProviders.length === 0) {
57288
57364
  if (win.phantom?.ethereum) {
@@ -57291,15 +57367,15 @@ function BrowserWalletButton({
57291
57367
  walletId: "phantom"
57292
57368
  });
57293
57369
  }
57294
- if (anyWin2.okxwallet) {
57370
+ if (anyWin.okxwallet) {
57295
57371
  allProviders.push({
57296
- provider: anyWin2.okxwallet,
57372
+ provider: anyWin.okxwallet,
57297
57373
  walletId: "okx"
57298
57374
  });
57299
57375
  }
57300
- if (anyWin2.coinbaseWalletExtension) {
57376
+ if (anyWin.coinbaseWalletExtension) {
57301
57377
  allProviders.push({
57302
- provider: anyWin2.coinbaseWalletExtension,
57378
+ provider: anyWin.coinbaseWalletExtension,
57303
57379
  walletId: "coinbase"
57304
57380
  });
57305
57381
  }
@@ -57323,7 +57399,7 @@ function BrowserWalletButton({
57323
57399
  });
57324
57400
  if (!accounts || accounts.length === 0) continue;
57325
57401
  const address = accounts[0];
57326
- const resolved = identifyEthWallet(provider, anyWin2, walletId);
57402
+ const resolved = identifyEthWallet(provider, anyWin, walletId);
57327
57403
  if (mounted) {
57328
57404
  setWallet({ ...resolved, address });
57329
57405
  setIsLoading(false);
@@ -57365,15 +57441,11 @@ function BrowserWalletButton({
57365
57441
  solanaProvider.on("disconnect", handleDisconnect);
57366
57442
  solanaProvider.on("accountChanged", handleAccountsChanged);
57367
57443
  }
57368
- const anyWin = window;
57369
57444
  const ethProviders = [];
57370
- if (anyWin.__eip6963Providers) {
57371
- for (const {
57372
- provider
57373
- } of anyWin.__eip6963Providers) {
57374
- if (provider && !ethProviders.includes(provider)) {
57375
- ethProviders.push(provider);
57376
- }
57445
+ for (const { provider } of getEip6963Providers()) {
57446
+ const p = provider;
57447
+ if (p && !ethProviders.includes(p)) {
57448
+ ethProviders.push(p);
57377
57449
  }
57378
57450
  }
57379
57451
  if (window.ethereum && !ethProviders.includes(window.ethereum)) {
@@ -57475,7 +57547,7 @@ function BrowserWalletButton({
57475
57547
  if (isLoading) {
57476
57548
  return null;
57477
57549
  }
57478
- const hasWalletExtension = (!chainType || chainType === "solana") && (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) ? true : (!chainType || chainType === "ethereum") && (window.phantom?.ethereum || window.ethereum) ? true : false;
57550
+ const hasWalletExtension = (!chainType || chainType === "ethereum") && getEip6963Providers().length > 0 || (!chainType || chainType === "solana") && (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) || (!chainType || chainType === "ethereum") && (window.phantom?.ethereum || window.ethereum);
57479
57551
  if (!onConnectClick && !wallet && !hasWalletExtension) {
57480
57552
  return null;
57481
57553
  }
@@ -62983,15 +63055,10 @@ var WALLET_DEFINITIONS = [
62983
63055
  { id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
62984
63056
  { id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
62985
63057
  ];
62986
- function getWalletProviders() {
63058
+ function getSolanaProviders() {
62987
63059
  if (typeof window === "undefined") return {};
62988
63060
  const win = window;
62989
63061
  return {
62990
- ethereum: win.ethereum,
62991
- phantomEthereum: win.phantom?.ethereum,
62992
- coinbaseEthereum: win.coinbaseWalletExtension,
62993
- trustEthereum: win.trustwallet?.ethereum,
62994
- okxEthereum: win.okxwallet,
62995
63062
  phantomSolana: win.phantom?.solana,
62996
63063
  solflare: win.solflare,
62997
63064
  backpack: win.backpack,
@@ -62999,37 +63066,71 @@ function getWalletProviders() {
62999
63066
  coinbaseSolana: win.coinbaseSolana || win.coinbaseWalletExtension?.solana
63000
63067
  };
63001
63068
  }
63069
+ function getLegacyEvmProviders() {
63070
+ if (typeof window === "undefined") return {};
63071
+ const win = window;
63072
+ return {
63073
+ ethereum: win.ethereum,
63074
+ phantomEthereum: win.phantom?.ethereum,
63075
+ coinbaseEthereum: win.coinbaseWalletExtension,
63076
+ trustEthereum: win.trustwallet?.ethereum,
63077
+ okxEthereum: win.okxwallet
63078
+ };
63079
+ }
63002
63080
  function detectAvailableWallets(filterChainType) {
63003
- const providers = getWalletProviders();
63081
+ const solProviders = getSolanaProviders();
63082
+ const legacyEvm = getLegacyEvmProviders();
63083
+ const eip6963List = getEip6963Providers();
63004
63084
  const win = typeof window !== "undefined" ? window : null;
63085
+ const hasEip6963 = (walletId) => eip6963List.some((d) => {
63086
+ const rdns = d.info?.rdns || "";
63087
+ switch (walletId) {
63088
+ case "metamask":
63089
+ return rdns.includes("metamask");
63090
+ case "phantom":
63091
+ return rdns.includes("phantom");
63092
+ case "coinbase":
63093
+ return rdns.includes("coinbase");
63094
+ case "trust":
63095
+ return rdns.includes("trust");
63096
+ case "rainbow":
63097
+ return rdns.includes("rainbow");
63098
+ case "rabby":
63099
+ return rdns.includes("rabby");
63100
+ case "okx":
63101
+ return rdns.includes("okx") || rdns.includes("okex");
63102
+ default:
63103
+ return false;
63104
+ }
63105
+ });
63005
63106
  return WALLET_DEFINITIONS.filter((w) => !filterChainType || w.networks.includes(filterChainType)).map((wallet) => {
63006
63107
  let isInstalled = false;
63007
63108
  const detectedNetworks = [];
63008
63109
  switch (wallet.id) {
63009
63110
  case "metamask":
63010
- isInstalled = !!(providers.ethereum?.isMetaMask && !providers.ethereum?.isPhantom && !providers.ethereum?.isRabby && !providers.ethereum?.isOkxWallet);
63111
+ isInstalled = hasEip6963("metamask") || !!(legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom && !legacyEvm.ethereum?.isRabby && !legacyEvm.ethereum?.isOkxWallet);
63011
63112
  if (isInstalled) detectedNetworks.push("ethereum");
63012
63113
  break;
63013
63114
  case "phantom":
63014
- if (providers.phantomSolana?.isPhantom) {
63115
+ if (solProviders.phantomSolana?.isPhantom) {
63015
63116
  isInstalled = true;
63016
63117
  detectedNetworks.push("solana");
63017
63118
  }
63018
- if (providers.phantomEthereum?.isPhantom) {
63119
+ if (hasEip6963("phantom") || legacyEvm.phantomEthereum?.isPhantom) {
63019
63120
  isInstalled = true;
63020
63121
  detectedNetworks.push("ethereum");
63021
63122
  }
63022
63123
  break;
63023
63124
  case "coinbase":
63024
- if (providers.coinbaseEthereum || providers.ethereum?.isCoinbaseWallet) {
63125
+ if (hasEip6963("coinbase") || legacyEvm.coinbaseEthereum || legacyEvm.ethereum?.isCoinbaseWallet) {
63025
63126
  isInstalled = true;
63026
63127
  detectedNetworks.push("ethereum");
63027
63128
  }
63028
- if (providers.coinbaseSolana || win?.coinbaseWalletExtension?.solana) detectedNetworks.push("solana");
63129
+ if (solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana) detectedNetworks.push("solana");
63029
63130
  if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
63030
63131
  break;
63031
63132
  case "trust":
63032
- if (providers.trustEthereum || providers.ethereum?.isTrust || win?.trustwallet) {
63133
+ if (hasEip6963("trust") || legacyEvm.trustEthereum || legacyEvm.ethereum?.isTrust || win?.trustwallet) {
63033
63134
  isInstalled = true;
63034
63135
  detectedNetworks.push("ethereum");
63035
63136
  }
@@ -63037,27 +63138,27 @@ function detectAvailableWallets(filterChainType) {
63037
63138
  if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
63038
63139
  break;
63039
63140
  case "rainbow":
63040
- isInstalled = !!providers.ethereum?.isRainbow;
63141
+ isInstalled = hasEip6963("rainbow") || !!legacyEvm.ethereum?.isRainbow;
63041
63142
  if (isInstalled) detectedNetworks.push("ethereum");
63042
63143
  break;
63043
63144
  case "rabby":
63044
- isInstalled = !!providers.ethereum?.isRabby;
63145
+ isInstalled = hasEip6963("rabby") || !!legacyEvm.ethereum?.isRabby;
63045
63146
  if (isInstalled) detectedNetworks.push("ethereum");
63046
63147
  break;
63047
63148
  case "okx":
63048
- isInstalled = !!(providers.okxEthereum || providers.ethereum?.isOkxWallet);
63149
+ isInstalled = hasEip6963("okx") || !!(legacyEvm.okxEthereum || legacyEvm.ethereum?.isOkxWallet);
63049
63150
  if (isInstalled) detectedNetworks.push("ethereum");
63050
63151
  break;
63051
63152
  case "solflare":
63052
- isInstalled = !!providers.solflare?.isSolflare;
63153
+ isInstalled = !!solProviders.solflare?.isSolflare;
63053
63154
  if (isInstalled) detectedNetworks.push("solana");
63054
63155
  break;
63055
63156
  case "backpack":
63056
- isInstalled = !!(providers.backpack?.isBackpack || win?.backpack);
63157
+ isInstalled = !!(solProviders.backpack?.isBackpack || win?.backpack);
63057
63158
  if (isInstalled) detectedNetworks.push("solana");
63058
63159
  break;
63059
63160
  case "glow":
63060
- isInstalled = !!(providers.glow?.isGlow || win?.glow);
63161
+ isInstalled = !!(solProviders.glow?.isGlow || win?.glow);
63061
63162
  if (isInstalled) detectedNetworks.push("solana");
63062
63163
  break;
63063
63164
  }
@@ -63112,7 +63213,16 @@ function WalletConnect({
63112
63213
  const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
63113
63214
  const [walletError, setWalletError] = React292.useState(null);
63114
63215
  const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
63115
- const availableWallets = React292.useMemo(() => detectAvailableWallets(), []);
63216
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
63217
+ React292.useEffect(() => {
63218
+ const store = getEip6963Store();
63219
+ if (!store) return;
63220
+ setEip6963ProviderCount(store.getProviders().length);
63221
+ return store.subscribe((providers) => {
63222
+ setEip6963ProviderCount(providers.length);
63223
+ });
63224
+ }, []);
63225
+ const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
63116
63226
  const [balances, setBalances] = React292.useState([]);
63117
63227
  const [isLoading, setIsLoading] = React292.useState(false);
63118
63228
  const [selectedBalance, setSelectedBalance] = React292.useState(null);
@@ -63171,59 +63281,72 @@ function WalletConnect({
63171
63281
  setWalletError(null);
63172
63282
  setIsWalletConnecting(true);
63173
63283
  try {
63174
- const providers = getWalletProviders();
63175
63284
  const win = typeof window !== "undefined" ? window : null;
63176
63285
  let connectedInfo;
63177
63286
  if (network === "ethereum") {
63178
- let provider;
63179
- switch (wallet.id) {
63180
- case "metamask":
63181
- if (providers.ethereum?.isMetaMask && !providers.ethereum?.isPhantom) provider = providers.ethereum;
63182
- break;
63183
- case "phantom":
63184
- provider = providers.phantomEthereum;
63185
- break;
63186
- case "coinbase":
63187
- provider = providers.coinbaseEthereum || (providers.ethereum?.isCoinbaseWallet ? providers.ethereum : void 0);
63188
- break;
63189
- case "trust":
63190
- provider = providers.trustEthereum || (providers.ethereum?.isTrust ? providers.ethereum : void 0);
63191
- break;
63192
- case "rainbow":
63193
- if (providers.ethereum?.isRainbow) provider = providers.ethereum;
63194
- break;
63195
- case "rabby":
63196
- if (providers.ethereum?.isRabby) provider = providers.ethereum;
63197
- break;
63198
- case "okx":
63199
- provider = providers.okxEthereum || (providers.ethereum?.isOkxWallet ? providers.ethereum : void 0);
63200
- break;
63201
- default:
63202
- provider = providers.ethereum;
63287
+ const eip6963Match = findProviderByWalletId(wallet.id);
63288
+ let provider = eip6963Match?.provider;
63289
+ if (!provider) {
63290
+ const legacyEvm = getLegacyEvmProviders();
63291
+ switch (wallet.id) {
63292
+ case "metamask":
63293
+ if (legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom) provider = legacyEvm.ethereum;
63294
+ break;
63295
+ case "phantom":
63296
+ provider = legacyEvm.phantomEthereum;
63297
+ break;
63298
+ case "coinbase":
63299
+ provider = legacyEvm.coinbaseEthereum || (legacyEvm.ethereum?.isCoinbaseWallet ? legacyEvm.ethereum : void 0);
63300
+ break;
63301
+ case "trust":
63302
+ provider = legacyEvm.trustEthereum || (legacyEvm.ethereum?.isTrust ? legacyEvm.ethereum : void 0);
63303
+ break;
63304
+ case "rainbow":
63305
+ if (legacyEvm.ethereum?.isRainbow) provider = legacyEvm.ethereum;
63306
+ break;
63307
+ case "rabby":
63308
+ if (legacyEvm.ethereum?.isRabby) provider = legacyEvm.ethereum;
63309
+ break;
63310
+ case "okx":
63311
+ provider = legacyEvm.okxEthereum || (legacyEvm.ethereum?.isOkxWallet ? legacyEvm.ethereum : void 0);
63312
+ break;
63313
+ default:
63314
+ provider = legacyEvm.ethereum;
63315
+ }
63203
63316
  }
63204
63317
  if (!provider) throw new Error(`${wallet.name} wallet not found. Please install it.`);
63205
63318
  const accounts = await provider.request({ method: "eth_requestAccounts" });
63206
63319
  if (!accounts?.length) throw new Error("No accounts returned from wallet");
63207
63320
  setUserDisconnectedWallet(false);
63208
- const walletType = wallet.id === "phantom" ? "phantom-ethereum" : wallet.id === "coinbase" ? "coinbase" : "metamask";
63321
+ const walletIdToType = {
63322
+ phantom: "phantom-ethereum",
63323
+ coinbase: "coinbase",
63324
+ trust: "trust",
63325
+ rainbow: "rainbow",
63326
+ rabby: "rabby",
63327
+ okx: "okx",
63328
+ metamask: "metamask"
63329
+ };
63330
+ const walletType = walletIdToType[wallet.id] || "metamask";
63209
63331
  connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
63210
63332
  } else {
63333
+ const solProviders = getSolanaProviders();
63211
63334
  let provider;
63212
63335
  switch (wallet.id) {
63213
63336
  case "phantom":
63214
- provider = providers.phantomSolana;
63337
+ provider = solProviders.phantomSolana;
63215
63338
  break;
63216
63339
  case "solflare":
63217
- provider = providers.solflare;
63340
+ provider = solProviders.solflare;
63218
63341
  break;
63219
63342
  case "backpack":
63220
- provider = providers.backpack || win?.backpack;
63343
+ provider = solProviders.backpack || win?.backpack;
63221
63344
  break;
63222
63345
  case "glow":
63223
- provider = providers.glow || win?.glow;
63346
+ provider = solProviders.glow || win?.glow;
63224
63347
  break;
63225
63348
  case "coinbase":
63226
- provider = providers.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
63349
+ provider = solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
63227
63350
  break;
63228
63351
  case "trust":
63229
63352
  provider = win?.trustwallet?.solana;
@@ -63469,10 +63592,15 @@ function WalletConnect({
63469
63592
  };
63470
63593
  const sendEthereumTransaction = async (token, amountStr) => {
63471
63594
  if (!recipientAddress || !/^0x[a-fA-F0-9]{40}$/.test(recipientAddress)) throw new Error(`Invalid recipient address.`);
63472
- let provider;
63473
- if (walletInfo.type === "phantom-ethereum") provider = window.phantom?.ethereum;
63474
- else if (walletInfo.type === "coinbase") provider = window.coinbaseWalletExtension || window.ethereum;
63475
- else provider = window.ethereum;
63595
+ const walletIdMap = { "phantom-ethereum": "phantom", coinbase: "coinbase", trust: "trust", okx: "okx", rainbow: "rainbow", rabby: "rabby", metamask: "metamask" };
63596
+ const lookupId = walletIdMap[walletInfo.type] || walletInfo.type;
63597
+ const eip6963Match = findProviderByWalletId(lookupId);
63598
+ let provider = eip6963Match?.provider;
63599
+ if (!provider) {
63600
+ if (walletInfo.type === "phantom-ethereum") provider = window.phantom?.ethereum;
63601
+ else if (walletInfo.type === "coinbase") provider = window.coinbaseWalletExtension || window.ethereum;
63602
+ else provider = window.ethereum;
63603
+ }
63476
63604
  if (!provider) throw new Error("Ethereum wallet not found");
63477
63605
  const currentChainIdHex = await provider.request({ method: "eth_chainId", params: [] });
63478
63606
  if (parseInt(currentChainIdHex, 16).toString() !== token.chain_id) {
@@ -65306,7 +65434,7 @@ function useExecutions(userId, publishableKey, options2) {
65306
65434
  });
65307
65435
  }
65308
65436
  var POLL_INTERVAL_MS3 = 2500;
65309
- var POLL_ENDPOINT_INTERVAL_MS2 = 3e3;
65437
+ var POLL_ENDPOINT_INTERVAL_MS2 = 5e3;
65310
65438
  var CUTOFF_BUFFER_MS2 = 6e4;
65311
65439
  function useWithdrawPolling({
65312
65440
  userId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/ui-web",
3
- "version": "0.1.59",
3
+ "version": "0.1.60",
4
4
  "description": "Unifold UI Web - Framework-agnostic deposit widget",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -30,10 +30,10 @@
30
30
  "@types/react-dom": "^19.0.0",
31
31
  "tsup": "^8.0.0",
32
32
  "typescript": "^5.0.0",
33
- "@unifold/connect-react": "0.1.59",
34
- "@unifold/ui-react": "0.1.59",
35
- "@unifold/react-provider": "0.1.59",
36
- "@unifold/core": "0.1.59"
33
+ "@unifold/core": "0.1.60",
34
+ "@unifold/react-provider": "0.1.60",
35
+ "@unifold/ui-react": "0.1.60",
36
+ "@unifold/connect-react": "0.1.60"
37
37
  },
38
38
  "keywords": [
39
39
  "unifold",