@unifold/ui-web 0.1.59 → 0.1.61

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 +250 -115
  2. package/dist/index.mjs +250 -115
  3. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -43195,6 +43195,7 @@ async function createDepositAddress(overrides, publishableKey) {
43195
43195
  recipient_address: overrides?.recipient_address || DEFAULT_CONFIG.recipientAddress || "0x309a4154a2CD4153Da886E780890C9cb5161553C",
43196
43196
  ...overrides?.action_type ? { action_type: overrides.action_type } : {},
43197
43197
  ...overrides?.source_chain_type ? { source_chain_type: overrides.source_chain_type } : {},
43198
+ ...overrides?.contract_calls ? { contract_calls: overrides.contract_calls } : {},
43198
43199
  client_metadata: overrides?.client_metadata || {}
43199
43200
  };
43200
43201
  const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
@@ -44159,6 +44160,56 @@ var cva = (base, config) => (props) => {
44159
44160
  }, []);
44160
44161
  return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
44161
44162
  };
44163
+ function requestProviders(listener) {
44164
+ if (typeof window === "undefined")
44165
+ return;
44166
+ const handler = (event) => listener(event.detail);
44167
+ window.addEventListener("eip6963:announceProvider", handler);
44168
+ window.dispatchEvent(new CustomEvent("eip6963:requestProvider"));
44169
+ return () => window.removeEventListener("eip6963:announceProvider", handler);
44170
+ }
44171
+ function createStore() {
44172
+ const listeners = /* @__PURE__ */ new Set();
44173
+ let providerDetails = [];
44174
+ const request = () => requestProviders((providerDetail) => {
44175
+ if (providerDetails.some(({ info }) => info.uuid === providerDetail.info.uuid))
44176
+ return;
44177
+ providerDetails = [...providerDetails, providerDetail];
44178
+ listeners.forEach((listener) => listener(providerDetails, { added: [providerDetail] }));
44179
+ });
44180
+ let unwatch = request();
44181
+ return {
44182
+ _listeners() {
44183
+ return listeners;
44184
+ },
44185
+ clear() {
44186
+ listeners.forEach((listener) => listener([], { removed: [...providerDetails] }));
44187
+ providerDetails = [];
44188
+ },
44189
+ destroy() {
44190
+ this.clear();
44191
+ listeners.clear();
44192
+ unwatch?.();
44193
+ },
44194
+ findProvider({ rdns }) {
44195
+ return providerDetails.find((providerDetail) => providerDetail.info.rdns === rdns);
44196
+ },
44197
+ getProviders() {
44198
+ return providerDetails;
44199
+ },
44200
+ reset() {
44201
+ this.clear();
44202
+ unwatch?.();
44203
+ unwatch = request();
44204
+ },
44205
+ subscribe(listener, { emitImmediately } = {}) {
44206
+ listeners.add(listener);
44207
+ if (emitImmediately)
44208
+ listener(providerDetails, { added: providerDetails });
44209
+ return () => listeners.delete(listener);
44210
+ }
44211
+ };
44212
+ }
44162
44213
  function isArray(value) {
44163
44214
  return !Array.isArray ? getTag(value) === "[object Array]" : Array.isArray(value);
44164
44215
  }
@@ -50629,6 +50680,7 @@ function useDepositAddress(params) {
50629
50680
  destinationChainId,
50630
50681
  destinationTokenAddress,
50631
50682
  actionType,
50683
+ contractCalls,
50632
50684
  enabled = true
50633
50685
  } = params;
50634
50686
  return useQuery({
@@ -50641,6 +50693,7 @@ function useDepositAddress(params) {
50641
50693
  destinationChainId ?? null,
50642
50694
  destinationTokenAddress ?? null,
50643
50695
  actionType ?? null,
50696
+ contractCalls ?? null,
50644
50697
  publishableKey
50645
50698
  ],
50646
50699
  queryFn: () => createDepositAddress(
@@ -50650,7 +50703,8 @@ function useDepositAddress(params) {
50650
50703
  destination_chain_type: destinationChainType,
50651
50704
  destination_chain_id: destinationChainId,
50652
50705
  destination_token_address: destinationTokenAddress,
50653
- action_type: actionType
50706
+ action_type: actionType,
50707
+ contract_calls: contractCalls
50654
50708
  },
50655
50709
  publishableKey
50656
50710
  ),
@@ -51452,7 +51506,7 @@ function interpolate(template, params) {
51452
51506
  }
51453
51507
  var DEPOSIT_CONFIRM_DELAY_MS = 5e3;
51454
51508
  var POLL_INTERVAL_MS = 2500;
51455
- var POLL_ENDPOINT_INTERVAL_MS = 3e3;
51509
+ var POLL_ENDPOINT_INTERVAL_MS = 5e3;
51456
51510
  var CUTOFF_BUFFER_MS = 6e4;
51457
51511
  function useDepositPolling({
51458
51512
  userId,
@@ -55094,6 +55148,53 @@ function CashAppButton({
55094
55148
  }
55095
55149
  );
55096
55150
  }
55151
+ var _store = null;
55152
+ function getEip6963Store() {
55153
+ if (typeof window === "undefined") return null;
55154
+ if (!_store) {
55155
+ _store = createStore();
55156
+ }
55157
+ return _store;
55158
+ }
55159
+ var RDNS_TO_WALLET_ID = {
55160
+ "io.metamask": "metamask",
55161
+ "io.metamask.flask": "metamask",
55162
+ "io.metamask.mmi": "metamask",
55163
+ "app.phantom": "phantom",
55164
+ "com.coinbase.wallet": "coinbase",
55165
+ "com.okex.wallet": "okx",
55166
+ "io.rabby": "rabby",
55167
+ "com.trustwallet.app": "trust",
55168
+ "me.rainbow": "rainbow"
55169
+ };
55170
+ function rdnsToWalletId(rdns) {
55171
+ if (RDNS_TO_WALLET_ID[rdns]) return RDNS_TO_WALLET_ID[rdns];
55172
+ if (rdns.includes("metamask")) return "metamask";
55173
+ if (rdns.includes("phantom")) return "phantom";
55174
+ if (rdns.includes("coinbase")) return "coinbase";
55175
+ if (rdns.includes("okx") || rdns.includes("okex")) return "okx";
55176
+ if (rdns.includes("rabby")) return "rabby";
55177
+ if (rdns.includes("trust")) return "trust";
55178
+ if (rdns.includes("rainbow")) return "rainbow";
55179
+ return "unknown";
55180
+ }
55181
+ function getEip6963Providers() {
55182
+ const store = getEip6963Store();
55183
+ if (!store) return [];
55184
+ return store.getProviders().map((detail) => ({
55185
+ walletId: rdnsToWalletId(detail.info.rdns),
55186
+ provider: detail.provider,
55187
+ info: detail.info
55188
+ }));
55189
+ }
55190
+ function findProviderByWalletId(walletId) {
55191
+ return getEip6963Providers().find((p) => p.walletId === walletId);
55192
+ }
55193
+ function collectAllEip6963EthProviders() {
55194
+ const store = getEip6963Store();
55195
+ if (!store) return [];
55196
+ return store.getProviders().map((d) => d.provider);
55197
+ }
55097
55198
  var SOLANA_DISCONNECT_TYPES = [
55098
55199
  "phantom-solana",
55099
55200
  "solflare",
@@ -55133,8 +55234,9 @@ function collectEthereumProvidersForDisconnect(win) {
55133
55234
  out.push(p);
55134
55235
  }
55135
55236
  };
55136
- const list = anyWin.__eip6963Providers || [];
55137
- for (const d of list) add(d.provider);
55237
+ for (const p of collectAllEip6963EthProviders()) {
55238
+ add(p);
55239
+ }
55138
55240
  add(win.ethereum);
55139
55241
  add(
55140
55242
  win.phantom?.ethereum
@@ -57140,30 +57242,13 @@ function BrowserWalletButton({
57140
57242
  }, []);
57141
57243
  const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
57142
57244
  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
- };
57245
+ const store = getEip6963Store();
57246
+ if (!store) return;
57247
+ setEip6963ProviderCount(store.getProviders().length);
57248
+ const unsubscribe = store.subscribe((providers) => {
57249
+ setEip6963ProviderCount(providers.length);
57250
+ });
57251
+ return unsubscribe;
57167
57252
  }, []);
57168
57253
  React242.useEffect(() => {
57169
57254
  if (!wallet || !publishableKey) {
@@ -57222,7 +57307,7 @@ function BrowserWalletButton({
57222
57307
  return;
57223
57308
  }
57224
57309
  if (!chainType || chainType === "solana") {
57225
- const anyWin2 = win;
57310
+ const anyWin = win;
57226
57311
  const trySilentSolana = async (provider, type, name, icon) => {
57227
57312
  if (!provider) return false;
57228
57313
  if (provider.isConnected && provider.publicKey) {
@@ -57261,21 +57346,21 @@ function BrowserWalletButton({
57261
57346
  ))
57262
57347
  return;
57263
57348
  if (await trySilentSolana(
57264
- anyWin2.solflare,
57349
+ anyWin.solflare,
57265
57350
  "solflare",
57266
57351
  "Solflare",
57267
57352
  "solflare"
57268
57353
  ))
57269
57354
  return;
57270
57355
  if (await trySilentSolana(
57271
- anyWin2.backpack,
57356
+ anyWin.backpack,
57272
57357
  "backpack",
57273
57358
  "Backpack",
57274
57359
  "backpack"
57275
57360
  ))
57276
57361
  return;
57277
57362
  if (await trySilentSolana(
57278
- anyWin2.glow,
57363
+ anyWin.glow,
57279
57364
  "glow",
57280
57365
  "Glow",
57281
57366
  "glow"
@@ -57283,19 +57368,14 @@ function BrowserWalletButton({
57283
57368
  return;
57284
57369
  }
57285
57370
  if (!chainType || chainType === "ethereum") {
57286
- const anyWin2 = win;
57371
+ const anyWin = win;
57287
57372
  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 });
57373
+ const eip6963 = getEip6963Providers();
57374
+ for (const { provider, walletId } of eip6963) {
57375
+ allProviders.push({
57376
+ provider,
57377
+ walletId: walletId === "unknown" ? "default" : walletId
57378
+ });
57299
57379
  }
57300
57380
  if (allProviders.length === 0) {
57301
57381
  if (win.phantom?.ethereum) {
@@ -57304,15 +57384,15 @@ function BrowserWalletButton({
57304
57384
  walletId: "phantom"
57305
57385
  });
57306
57386
  }
57307
- if (anyWin2.okxwallet) {
57387
+ if (anyWin.okxwallet) {
57308
57388
  allProviders.push({
57309
- provider: anyWin2.okxwallet,
57389
+ provider: anyWin.okxwallet,
57310
57390
  walletId: "okx"
57311
57391
  });
57312
57392
  }
57313
- if (anyWin2.coinbaseWalletExtension) {
57393
+ if (anyWin.coinbaseWalletExtension) {
57314
57394
  allProviders.push({
57315
- provider: anyWin2.coinbaseWalletExtension,
57395
+ provider: anyWin.coinbaseWalletExtension,
57316
57396
  walletId: "coinbase"
57317
57397
  });
57318
57398
  }
@@ -57336,7 +57416,7 @@ function BrowserWalletButton({
57336
57416
  });
57337
57417
  if (!accounts || accounts.length === 0) continue;
57338
57418
  const address = accounts[0];
57339
- const resolved = identifyEthWallet(provider, anyWin2, walletId);
57419
+ const resolved = identifyEthWallet(provider, anyWin, walletId);
57340
57420
  if (mounted) {
57341
57421
  setWallet({ ...resolved, address });
57342
57422
  setIsLoading(false);
@@ -57378,15 +57458,11 @@ function BrowserWalletButton({
57378
57458
  solanaProvider.on("disconnect", handleDisconnect);
57379
57459
  solanaProvider.on("accountChanged", handleAccountsChanged);
57380
57460
  }
57381
- const anyWin = window;
57382
57461
  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
- }
57462
+ for (const { provider } of getEip6963Providers()) {
57463
+ const p = provider;
57464
+ if (p && !ethProviders.includes(p)) {
57465
+ ethProviders.push(p);
57390
57466
  }
57391
57467
  }
57392
57468
  if (window.ethereum && !ethProviders.includes(window.ethereum)) {
@@ -57488,7 +57564,7 @@ function BrowserWalletButton({
57488
57564
  if (isLoading) {
57489
57565
  return null;
57490
57566
  }
57491
- const hasWalletExtension = (!chainType || chainType === "solana") && (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) ? true : (!chainType || chainType === "ethereum") && (window.phantom?.ethereum || window.ethereum) ? true : false;
57567
+ 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
57568
  if (!onConnectClick && !wallet && !hasWalletExtension) {
57493
57569
  return null;
57494
57570
  }
@@ -62996,15 +63072,10 @@ var WALLET_DEFINITIONS = [
62996
63072
  { id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
62997
63073
  { id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
62998
63074
  ];
62999
- function getWalletProviders() {
63075
+ function getSolanaProviders() {
63000
63076
  if (typeof window === "undefined") return {};
63001
63077
  const win = window;
63002
63078
  return {
63003
- ethereum: win.ethereum,
63004
- phantomEthereum: win.phantom?.ethereum,
63005
- coinbaseEthereum: win.coinbaseWalletExtension,
63006
- trustEthereum: win.trustwallet?.ethereum,
63007
- okxEthereum: win.okxwallet,
63008
63079
  phantomSolana: win.phantom?.solana,
63009
63080
  solflare: win.solflare,
63010
63081
  backpack: win.backpack,
@@ -63012,37 +63083,71 @@ function getWalletProviders() {
63012
63083
  coinbaseSolana: win.coinbaseSolana || win.coinbaseWalletExtension?.solana
63013
63084
  };
63014
63085
  }
63086
+ function getLegacyEvmProviders() {
63087
+ if (typeof window === "undefined") return {};
63088
+ const win = window;
63089
+ return {
63090
+ ethereum: win.ethereum,
63091
+ phantomEthereum: win.phantom?.ethereum,
63092
+ coinbaseEthereum: win.coinbaseWalletExtension,
63093
+ trustEthereum: win.trustwallet?.ethereum,
63094
+ okxEthereum: win.okxwallet
63095
+ };
63096
+ }
63015
63097
  function detectAvailableWallets(filterChainType) {
63016
- const providers = getWalletProviders();
63098
+ const solProviders = getSolanaProviders();
63099
+ const legacyEvm = getLegacyEvmProviders();
63100
+ const eip6963List = getEip6963Providers();
63017
63101
  const win = typeof window !== "undefined" ? window : null;
63102
+ const hasEip6963 = (walletId) => eip6963List.some((d) => {
63103
+ const rdns = d.info?.rdns || "";
63104
+ switch (walletId) {
63105
+ case "metamask":
63106
+ return rdns.includes("metamask");
63107
+ case "phantom":
63108
+ return rdns.includes("phantom");
63109
+ case "coinbase":
63110
+ return rdns.includes("coinbase");
63111
+ case "trust":
63112
+ return rdns.includes("trust");
63113
+ case "rainbow":
63114
+ return rdns.includes("rainbow");
63115
+ case "rabby":
63116
+ return rdns.includes("rabby");
63117
+ case "okx":
63118
+ return rdns.includes("okx") || rdns.includes("okex");
63119
+ default:
63120
+ return false;
63121
+ }
63122
+ });
63018
63123
  return WALLET_DEFINITIONS.filter((w) => !filterChainType || w.networks.includes(filterChainType)).map((wallet) => {
63019
63124
  let isInstalled = false;
63020
63125
  const detectedNetworks = [];
63021
63126
  switch (wallet.id) {
63022
63127
  case "metamask":
63023
- isInstalled = !!(providers.ethereum?.isMetaMask && !providers.ethereum?.isPhantom && !providers.ethereum?.isRabby && !providers.ethereum?.isOkxWallet);
63128
+ isInstalled = hasEip6963("metamask") || !!(legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom && !legacyEvm.ethereum?.isRabby && !legacyEvm.ethereum?.isOkxWallet);
63024
63129
  if (isInstalled) detectedNetworks.push("ethereum");
63025
63130
  break;
63026
63131
  case "phantom":
63027
- if (providers.phantomSolana?.isPhantom) {
63132
+ if (solProviders.phantomSolana?.isPhantom) {
63028
63133
  isInstalled = true;
63029
63134
  detectedNetworks.push("solana");
63030
63135
  }
63031
- if (providers.phantomEthereum?.isPhantom) {
63136
+ if (hasEip6963("phantom") || legacyEvm.phantomEthereum?.isPhantom) {
63032
63137
  isInstalled = true;
63033
63138
  detectedNetworks.push("ethereum");
63034
63139
  }
63035
63140
  break;
63036
63141
  case "coinbase":
63037
- if (providers.coinbaseEthereum || providers.ethereum?.isCoinbaseWallet) {
63142
+ if (hasEip6963("coinbase") || legacyEvm.coinbaseEthereum || legacyEvm.ethereum?.isCoinbaseWallet) {
63038
63143
  isInstalled = true;
63039
63144
  detectedNetworks.push("ethereum");
63040
63145
  }
63041
- if (providers.coinbaseSolana || win?.coinbaseWalletExtension?.solana) detectedNetworks.push("solana");
63146
+ if (solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana) detectedNetworks.push("solana");
63042
63147
  if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
63043
63148
  break;
63044
63149
  case "trust":
63045
- if (providers.trustEthereum || providers.ethereum?.isTrust || win?.trustwallet) {
63150
+ if (hasEip6963("trust") || legacyEvm.trustEthereum || legacyEvm.ethereum?.isTrust || win?.trustwallet) {
63046
63151
  isInstalled = true;
63047
63152
  detectedNetworks.push("ethereum");
63048
63153
  }
@@ -63050,27 +63155,27 @@ function detectAvailableWallets(filterChainType) {
63050
63155
  if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
63051
63156
  break;
63052
63157
  case "rainbow":
63053
- isInstalled = !!providers.ethereum?.isRainbow;
63158
+ isInstalled = hasEip6963("rainbow") || !!legacyEvm.ethereum?.isRainbow;
63054
63159
  if (isInstalled) detectedNetworks.push("ethereum");
63055
63160
  break;
63056
63161
  case "rabby":
63057
- isInstalled = !!providers.ethereum?.isRabby;
63162
+ isInstalled = hasEip6963("rabby") || !!legacyEvm.ethereum?.isRabby;
63058
63163
  if (isInstalled) detectedNetworks.push("ethereum");
63059
63164
  break;
63060
63165
  case "okx":
63061
- isInstalled = !!(providers.okxEthereum || providers.ethereum?.isOkxWallet);
63166
+ isInstalled = hasEip6963("okx") || !!(legacyEvm.okxEthereum || legacyEvm.ethereum?.isOkxWallet);
63062
63167
  if (isInstalled) detectedNetworks.push("ethereum");
63063
63168
  break;
63064
63169
  case "solflare":
63065
- isInstalled = !!providers.solflare?.isSolflare;
63170
+ isInstalled = !!solProviders.solflare?.isSolflare;
63066
63171
  if (isInstalled) detectedNetworks.push("solana");
63067
63172
  break;
63068
63173
  case "backpack":
63069
- isInstalled = !!(providers.backpack?.isBackpack || win?.backpack);
63174
+ isInstalled = !!(solProviders.backpack?.isBackpack || win?.backpack);
63070
63175
  if (isInstalled) detectedNetworks.push("solana");
63071
63176
  break;
63072
63177
  case "glow":
63073
- isInstalled = !!(providers.glow?.isGlow || win?.glow);
63178
+ isInstalled = !!(solProviders.glow?.isGlow || win?.glow);
63074
63179
  if (isInstalled) detectedNetworks.push("solana");
63075
63180
  break;
63076
63181
  }
@@ -63125,7 +63230,16 @@ function WalletConnect({
63125
63230
  const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
63126
63231
  const [walletError, setWalletError] = React292.useState(null);
63127
63232
  const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
63128
- const availableWallets = React292.useMemo(() => detectAvailableWallets(), []);
63233
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
63234
+ React292.useEffect(() => {
63235
+ const store = getEip6963Store();
63236
+ if (!store) return;
63237
+ setEip6963ProviderCount(store.getProviders().length);
63238
+ return store.subscribe((providers) => {
63239
+ setEip6963ProviderCount(providers.length);
63240
+ });
63241
+ }, []);
63242
+ const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
63129
63243
  const [balances, setBalances] = React292.useState([]);
63130
63244
  const [isLoading, setIsLoading] = React292.useState(false);
63131
63245
  const [selectedBalance, setSelectedBalance] = React292.useState(null);
@@ -63184,59 +63298,72 @@ function WalletConnect({
63184
63298
  setWalletError(null);
63185
63299
  setIsWalletConnecting(true);
63186
63300
  try {
63187
- const providers = getWalletProviders();
63188
63301
  const win = typeof window !== "undefined" ? window : null;
63189
63302
  let connectedInfo;
63190
63303
  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;
63304
+ const eip6963Match = findProviderByWalletId(wallet.id);
63305
+ let provider = eip6963Match?.provider;
63306
+ if (!provider) {
63307
+ const legacyEvm = getLegacyEvmProviders();
63308
+ switch (wallet.id) {
63309
+ case "metamask":
63310
+ if (legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom) provider = legacyEvm.ethereum;
63311
+ break;
63312
+ case "phantom":
63313
+ provider = legacyEvm.phantomEthereum;
63314
+ break;
63315
+ case "coinbase":
63316
+ provider = legacyEvm.coinbaseEthereum || (legacyEvm.ethereum?.isCoinbaseWallet ? legacyEvm.ethereum : void 0);
63317
+ break;
63318
+ case "trust":
63319
+ provider = legacyEvm.trustEthereum || (legacyEvm.ethereum?.isTrust ? legacyEvm.ethereum : void 0);
63320
+ break;
63321
+ case "rainbow":
63322
+ if (legacyEvm.ethereum?.isRainbow) provider = legacyEvm.ethereum;
63323
+ break;
63324
+ case "rabby":
63325
+ if (legacyEvm.ethereum?.isRabby) provider = legacyEvm.ethereum;
63326
+ break;
63327
+ case "okx":
63328
+ provider = legacyEvm.okxEthereum || (legacyEvm.ethereum?.isOkxWallet ? legacyEvm.ethereum : void 0);
63329
+ break;
63330
+ default:
63331
+ provider = legacyEvm.ethereum;
63332
+ }
63216
63333
  }
63217
63334
  if (!provider) throw new Error(`${wallet.name} wallet not found. Please install it.`);
63218
63335
  const accounts = await provider.request({ method: "eth_requestAccounts" });
63219
63336
  if (!accounts?.length) throw new Error("No accounts returned from wallet");
63220
63337
  setUserDisconnectedWallet(false);
63221
- const walletType = wallet.id === "phantom" ? "phantom-ethereum" : wallet.id === "coinbase" ? "coinbase" : "metamask";
63338
+ const walletIdToType = {
63339
+ phantom: "phantom-ethereum",
63340
+ coinbase: "coinbase",
63341
+ trust: "trust",
63342
+ rainbow: "rainbow",
63343
+ rabby: "rabby",
63344
+ okx: "okx",
63345
+ metamask: "metamask"
63346
+ };
63347
+ const walletType = walletIdToType[wallet.id] || "metamask";
63222
63348
  connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
63223
63349
  } else {
63350
+ const solProviders = getSolanaProviders();
63224
63351
  let provider;
63225
63352
  switch (wallet.id) {
63226
63353
  case "phantom":
63227
- provider = providers.phantomSolana;
63354
+ provider = solProviders.phantomSolana;
63228
63355
  break;
63229
63356
  case "solflare":
63230
- provider = providers.solflare;
63357
+ provider = solProviders.solflare;
63231
63358
  break;
63232
63359
  case "backpack":
63233
- provider = providers.backpack || win?.backpack;
63360
+ provider = solProviders.backpack || win?.backpack;
63234
63361
  break;
63235
63362
  case "glow":
63236
- provider = providers.glow || win?.glow;
63363
+ provider = solProviders.glow || win?.glow;
63237
63364
  break;
63238
63365
  case "coinbase":
63239
- provider = providers.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
63366
+ provider = solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
63240
63367
  break;
63241
63368
  case "trust":
63242
63369
  provider = win?.trustwallet?.solana;
@@ -63482,10 +63609,15 @@ function WalletConnect({
63482
63609
  };
63483
63610
  const sendEthereumTransaction = async (token, amountStr) => {
63484
63611
  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;
63612
+ const walletIdMap = { "phantom-ethereum": "phantom", coinbase: "coinbase", trust: "trust", okx: "okx", rainbow: "rainbow", rabby: "rabby", metamask: "metamask" };
63613
+ const lookupId = walletIdMap[walletInfo.type] || walletInfo.type;
63614
+ const eip6963Match = findProviderByWalletId(lookupId);
63615
+ let provider = eip6963Match?.provider;
63616
+ if (!provider) {
63617
+ if (walletInfo.type === "phantom-ethereum") provider = window.phantom?.ethereum;
63618
+ else if (walletInfo.type === "coinbase") provider = window.coinbaseWalletExtension || window.ethereum;
63619
+ else provider = window.ethereum;
63620
+ }
63489
63621
  if (!provider) throw new Error("Ethereum wallet not found");
63490
63622
  const currentChainIdHex = await provider.request({ method: "eth_chainId", params: [] });
63491
63623
  if (parseInt(currentChainIdHex, 16).toString() !== token.chain_id) {
@@ -63713,6 +63845,7 @@ function DepositModal({
63713
63845
  destinationChainType,
63714
63846
  destinationChainId,
63715
63847
  destinationTokenAddress,
63848
+ contractCalls,
63716
63849
  defaultSourceChainType,
63717
63850
  defaultSourceChainId,
63718
63851
  defaultSourceTokenAddress,
@@ -63839,6 +63972,7 @@ function DepositModal({
63839
63972
  destinationChainType,
63840
63973
  destinationChainId,
63841
63974
  destinationTokenAddress,
63975
+ contractCalls,
63842
63976
  enabled: open
63843
63977
  // Only fetch when modal is open
63844
63978
  });
@@ -65319,7 +65453,7 @@ function useExecutions(userId, publishableKey, options2) {
65319
65453
  });
65320
65454
  }
65321
65455
  var POLL_INTERVAL_MS3 = 2500;
65322
- var POLL_ENDPOINT_INTERVAL_MS2 = 3e3;
65456
+ var POLL_ENDPOINT_INTERVAL_MS2 = 5e3;
65323
65457
  var CUTOFF_BUFFER_MS2 = 6e4;
65324
65458
  function useWithdrawPolling({
65325
65459
  userId,
@@ -67169,6 +67303,7 @@ function UnifoldProvider2({
67169
67303
  destinationChainType: depositConfig.destinationChainType,
67170
67304
  destinationChainId: depositConfig.destinationChainId,
67171
67305
  destinationTokenAddress: depositConfig.destinationTokenAddress,
67306
+ contractCalls: depositConfig.contractCalls,
67172
67307
  defaultSourceChainType: depositConfig.defaultSourceChainType,
67173
67308
  defaultSourceChainId: depositConfig.defaultSourceChainId,
67174
67309
  defaultSourceTokenAddress: depositConfig.defaultSourceTokenAddress,
package/dist/index.mjs CHANGED
@@ -43182,6 +43182,7 @@ async function createDepositAddress(overrides, publishableKey) {
43182
43182
  recipient_address: overrides?.recipient_address || DEFAULT_CONFIG.recipientAddress || "0x309a4154a2CD4153Da886E780890C9cb5161553C",
43183
43183
  ...overrides?.action_type ? { action_type: overrides.action_type } : {},
43184
43184
  ...overrides?.source_chain_type ? { source_chain_type: overrides.source_chain_type } : {},
43185
+ ...overrides?.contract_calls ? { contract_calls: overrides.contract_calls } : {},
43185
43186
  client_metadata: overrides?.client_metadata || {}
43186
43187
  };
43187
43188
  const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
@@ -44146,6 +44147,56 @@ var cva = (base, config) => (props) => {
44146
44147
  }, []);
44147
44148
  return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
44148
44149
  };
44150
+ function requestProviders(listener) {
44151
+ if (typeof window === "undefined")
44152
+ return;
44153
+ const handler = (event) => listener(event.detail);
44154
+ window.addEventListener("eip6963:announceProvider", handler);
44155
+ window.dispatchEvent(new CustomEvent("eip6963:requestProvider"));
44156
+ return () => window.removeEventListener("eip6963:announceProvider", handler);
44157
+ }
44158
+ function createStore() {
44159
+ const listeners = /* @__PURE__ */ new Set();
44160
+ let providerDetails = [];
44161
+ const request = () => requestProviders((providerDetail) => {
44162
+ if (providerDetails.some(({ info }) => info.uuid === providerDetail.info.uuid))
44163
+ return;
44164
+ providerDetails = [...providerDetails, providerDetail];
44165
+ listeners.forEach((listener) => listener(providerDetails, { added: [providerDetail] }));
44166
+ });
44167
+ let unwatch = request();
44168
+ return {
44169
+ _listeners() {
44170
+ return listeners;
44171
+ },
44172
+ clear() {
44173
+ listeners.forEach((listener) => listener([], { removed: [...providerDetails] }));
44174
+ providerDetails = [];
44175
+ },
44176
+ destroy() {
44177
+ this.clear();
44178
+ listeners.clear();
44179
+ unwatch?.();
44180
+ },
44181
+ findProvider({ rdns }) {
44182
+ return providerDetails.find((providerDetail) => providerDetail.info.rdns === rdns);
44183
+ },
44184
+ getProviders() {
44185
+ return providerDetails;
44186
+ },
44187
+ reset() {
44188
+ this.clear();
44189
+ unwatch?.();
44190
+ unwatch = request();
44191
+ },
44192
+ subscribe(listener, { emitImmediately } = {}) {
44193
+ listeners.add(listener);
44194
+ if (emitImmediately)
44195
+ listener(providerDetails, { added: providerDetails });
44196
+ return () => listeners.delete(listener);
44197
+ }
44198
+ };
44199
+ }
44149
44200
  function isArray(value) {
44150
44201
  return !Array.isArray ? getTag(value) === "[object Array]" : Array.isArray(value);
44151
44202
  }
@@ -50616,6 +50667,7 @@ function useDepositAddress(params) {
50616
50667
  destinationChainId,
50617
50668
  destinationTokenAddress,
50618
50669
  actionType,
50670
+ contractCalls,
50619
50671
  enabled = true
50620
50672
  } = params;
50621
50673
  return useQuery({
@@ -50628,6 +50680,7 @@ function useDepositAddress(params) {
50628
50680
  destinationChainId ?? null,
50629
50681
  destinationTokenAddress ?? null,
50630
50682
  actionType ?? null,
50683
+ contractCalls ?? null,
50631
50684
  publishableKey
50632
50685
  ],
50633
50686
  queryFn: () => createDepositAddress(
@@ -50637,7 +50690,8 @@ function useDepositAddress(params) {
50637
50690
  destination_chain_type: destinationChainType,
50638
50691
  destination_chain_id: destinationChainId,
50639
50692
  destination_token_address: destinationTokenAddress,
50640
- action_type: actionType
50693
+ action_type: actionType,
50694
+ contract_calls: contractCalls
50641
50695
  },
50642
50696
  publishableKey
50643
50697
  ),
@@ -51439,7 +51493,7 @@ function interpolate(template, params) {
51439
51493
  }
51440
51494
  var DEPOSIT_CONFIRM_DELAY_MS = 5e3;
51441
51495
  var POLL_INTERVAL_MS = 2500;
51442
- var POLL_ENDPOINT_INTERVAL_MS = 3e3;
51496
+ var POLL_ENDPOINT_INTERVAL_MS = 5e3;
51443
51497
  var CUTOFF_BUFFER_MS = 6e4;
51444
51498
  function useDepositPolling({
51445
51499
  userId,
@@ -55081,6 +55135,53 @@ function CashAppButton({
55081
55135
  }
55082
55136
  );
55083
55137
  }
55138
+ var _store = null;
55139
+ function getEip6963Store() {
55140
+ if (typeof window === "undefined") return null;
55141
+ if (!_store) {
55142
+ _store = createStore();
55143
+ }
55144
+ return _store;
55145
+ }
55146
+ var RDNS_TO_WALLET_ID = {
55147
+ "io.metamask": "metamask",
55148
+ "io.metamask.flask": "metamask",
55149
+ "io.metamask.mmi": "metamask",
55150
+ "app.phantom": "phantom",
55151
+ "com.coinbase.wallet": "coinbase",
55152
+ "com.okex.wallet": "okx",
55153
+ "io.rabby": "rabby",
55154
+ "com.trustwallet.app": "trust",
55155
+ "me.rainbow": "rainbow"
55156
+ };
55157
+ function rdnsToWalletId(rdns) {
55158
+ if (RDNS_TO_WALLET_ID[rdns]) return RDNS_TO_WALLET_ID[rdns];
55159
+ if (rdns.includes("metamask")) return "metamask";
55160
+ if (rdns.includes("phantom")) return "phantom";
55161
+ if (rdns.includes("coinbase")) return "coinbase";
55162
+ if (rdns.includes("okx") || rdns.includes("okex")) return "okx";
55163
+ if (rdns.includes("rabby")) return "rabby";
55164
+ if (rdns.includes("trust")) return "trust";
55165
+ if (rdns.includes("rainbow")) return "rainbow";
55166
+ return "unknown";
55167
+ }
55168
+ function getEip6963Providers() {
55169
+ const store = getEip6963Store();
55170
+ if (!store) return [];
55171
+ return store.getProviders().map((detail) => ({
55172
+ walletId: rdnsToWalletId(detail.info.rdns),
55173
+ provider: detail.provider,
55174
+ info: detail.info
55175
+ }));
55176
+ }
55177
+ function findProviderByWalletId(walletId) {
55178
+ return getEip6963Providers().find((p) => p.walletId === walletId);
55179
+ }
55180
+ function collectAllEip6963EthProviders() {
55181
+ const store = getEip6963Store();
55182
+ if (!store) return [];
55183
+ return store.getProviders().map((d) => d.provider);
55184
+ }
55084
55185
  var SOLANA_DISCONNECT_TYPES = [
55085
55186
  "phantom-solana",
55086
55187
  "solflare",
@@ -55120,8 +55221,9 @@ function collectEthereumProvidersForDisconnect(win) {
55120
55221
  out.push(p);
55121
55222
  }
55122
55223
  };
55123
- const list = anyWin.__eip6963Providers || [];
55124
- for (const d of list) add(d.provider);
55224
+ for (const p of collectAllEip6963EthProviders()) {
55225
+ add(p);
55226
+ }
55125
55227
  add(win.ethereum);
55126
55228
  add(
55127
55229
  win.phantom?.ethereum
@@ -57127,30 +57229,13 @@ function BrowserWalletButton({
57127
57229
  }, []);
57128
57230
  const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
57129
57231
  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
- };
57232
+ const store = getEip6963Store();
57233
+ if (!store) return;
57234
+ setEip6963ProviderCount(store.getProviders().length);
57235
+ const unsubscribe = store.subscribe((providers) => {
57236
+ setEip6963ProviderCount(providers.length);
57237
+ });
57238
+ return unsubscribe;
57154
57239
  }, []);
57155
57240
  React242.useEffect(() => {
57156
57241
  if (!wallet || !publishableKey) {
@@ -57209,7 +57294,7 @@ function BrowserWalletButton({
57209
57294
  return;
57210
57295
  }
57211
57296
  if (!chainType || chainType === "solana") {
57212
- const anyWin2 = win;
57297
+ const anyWin = win;
57213
57298
  const trySilentSolana = async (provider, type, name, icon) => {
57214
57299
  if (!provider) return false;
57215
57300
  if (provider.isConnected && provider.publicKey) {
@@ -57248,21 +57333,21 @@ function BrowserWalletButton({
57248
57333
  ))
57249
57334
  return;
57250
57335
  if (await trySilentSolana(
57251
- anyWin2.solflare,
57336
+ anyWin.solflare,
57252
57337
  "solflare",
57253
57338
  "Solflare",
57254
57339
  "solflare"
57255
57340
  ))
57256
57341
  return;
57257
57342
  if (await trySilentSolana(
57258
- anyWin2.backpack,
57343
+ anyWin.backpack,
57259
57344
  "backpack",
57260
57345
  "Backpack",
57261
57346
  "backpack"
57262
57347
  ))
57263
57348
  return;
57264
57349
  if (await trySilentSolana(
57265
- anyWin2.glow,
57350
+ anyWin.glow,
57266
57351
  "glow",
57267
57352
  "Glow",
57268
57353
  "glow"
@@ -57270,19 +57355,14 @@ function BrowserWalletButton({
57270
57355
  return;
57271
57356
  }
57272
57357
  if (!chainType || chainType === "ethereum") {
57273
- const anyWin2 = win;
57358
+ const anyWin = win;
57274
57359
  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 });
57360
+ const eip6963 = getEip6963Providers();
57361
+ for (const { provider, walletId } of eip6963) {
57362
+ allProviders.push({
57363
+ provider,
57364
+ walletId: walletId === "unknown" ? "default" : walletId
57365
+ });
57286
57366
  }
57287
57367
  if (allProviders.length === 0) {
57288
57368
  if (win.phantom?.ethereum) {
@@ -57291,15 +57371,15 @@ function BrowserWalletButton({
57291
57371
  walletId: "phantom"
57292
57372
  });
57293
57373
  }
57294
- if (anyWin2.okxwallet) {
57374
+ if (anyWin.okxwallet) {
57295
57375
  allProviders.push({
57296
- provider: anyWin2.okxwallet,
57376
+ provider: anyWin.okxwallet,
57297
57377
  walletId: "okx"
57298
57378
  });
57299
57379
  }
57300
- if (anyWin2.coinbaseWalletExtension) {
57380
+ if (anyWin.coinbaseWalletExtension) {
57301
57381
  allProviders.push({
57302
- provider: anyWin2.coinbaseWalletExtension,
57382
+ provider: anyWin.coinbaseWalletExtension,
57303
57383
  walletId: "coinbase"
57304
57384
  });
57305
57385
  }
@@ -57323,7 +57403,7 @@ function BrowserWalletButton({
57323
57403
  });
57324
57404
  if (!accounts || accounts.length === 0) continue;
57325
57405
  const address = accounts[0];
57326
- const resolved = identifyEthWallet(provider, anyWin2, walletId);
57406
+ const resolved = identifyEthWallet(provider, anyWin, walletId);
57327
57407
  if (mounted) {
57328
57408
  setWallet({ ...resolved, address });
57329
57409
  setIsLoading(false);
@@ -57365,15 +57445,11 @@ function BrowserWalletButton({
57365
57445
  solanaProvider.on("disconnect", handleDisconnect);
57366
57446
  solanaProvider.on("accountChanged", handleAccountsChanged);
57367
57447
  }
57368
- const anyWin = window;
57369
57448
  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
- }
57449
+ for (const { provider } of getEip6963Providers()) {
57450
+ const p = provider;
57451
+ if (p && !ethProviders.includes(p)) {
57452
+ ethProviders.push(p);
57377
57453
  }
57378
57454
  }
57379
57455
  if (window.ethereum && !ethProviders.includes(window.ethereum)) {
@@ -57475,7 +57551,7 @@ function BrowserWalletButton({
57475
57551
  if (isLoading) {
57476
57552
  return null;
57477
57553
  }
57478
- const hasWalletExtension = (!chainType || chainType === "solana") && (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) ? true : (!chainType || chainType === "ethereum") && (window.phantom?.ethereum || window.ethereum) ? true : false;
57554
+ 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
57555
  if (!onConnectClick && !wallet && !hasWalletExtension) {
57480
57556
  return null;
57481
57557
  }
@@ -62983,15 +63059,10 @@ var WALLET_DEFINITIONS = [
62983
63059
  { id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
62984
63060
  { id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
62985
63061
  ];
62986
- function getWalletProviders() {
63062
+ function getSolanaProviders() {
62987
63063
  if (typeof window === "undefined") return {};
62988
63064
  const win = window;
62989
63065
  return {
62990
- ethereum: win.ethereum,
62991
- phantomEthereum: win.phantom?.ethereum,
62992
- coinbaseEthereum: win.coinbaseWalletExtension,
62993
- trustEthereum: win.trustwallet?.ethereum,
62994
- okxEthereum: win.okxwallet,
62995
63066
  phantomSolana: win.phantom?.solana,
62996
63067
  solflare: win.solflare,
62997
63068
  backpack: win.backpack,
@@ -62999,37 +63070,71 @@ function getWalletProviders() {
62999
63070
  coinbaseSolana: win.coinbaseSolana || win.coinbaseWalletExtension?.solana
63000
63071
  };
63001
63072
  }
63073
+ function getLegacyEvmProviders() {
63074
+ if (typeof window === "undefined") return {};
63075
+ const win = window;
63076
+ return {
63077
+ ethereum: win.ethereum,
63078
+ phantomEthereum: win.phantom?.ethereum,
63079
+ coinbaseEthereum: win.coinbaseWalletExtension,
63080
+ trustEthereum: win.trustwallet?.ethereum,
63081
+ okxEthereum: win.okxwallet
63082
+ };
63083
+ }
63002
63084
  function detectAvailableWallets(filterChainType) {
63003
- const providers = getWalletProviders();
63085
+ const solProviders = getSolanaProviders();
63086
+ const legacyEvm = getLegacyEvmProviders();
63087
+ const eip6963List = getEip6963Providers();
63004
63088
  const win = typeof window !== "undefined" ? window : null;
63089
+ const hasEip6963 = (walletId) => eip6963List.some((d) => {
63090
+ const rdns = d.info?.rdns || "";
63091
+ switch (walletId) {
63092
+ case "metamask":
63093
+ return rdns.includes("metamask");
63094
+ case "phantom":
63095
+ return rdns.includes("phantom");
63096
+ case "coinbase":
63097
+ return rdns.includes("coinbase");
63098
+ case "trust":
63099
+ return rdns.includes("trust");
63100
+ case "rainbow":
63101
+ return rdns.includes("rainbow");
63102
+ case "rabby":
63103
+ return rdns.includes("rabby");
63104
+ case "okx":
63105
+ return rdns.includes("okx") || rdns.includes("okex");
63106
+ default:
63107
+ return false;
63108
+ }
63109
+ });
63005
63110
  return WALLET_DEFINITIONS.filter((w) => !filterChainType || w.networks.includes(filterChainType)).map((wallet) => {
63006
63111
  let isInstalled = false;
63007
63112
  const detectedNetworks = [];
63008
63113
  switch (wallet.id) {
63009
63114
  case "metamask":
63010
- isInstalled = !!(providers.ethereum?.isMetaMask && !providers.ethereum?.isPhantom && !providers.ethereum?.isRabby && !providers.ethereum?.isOkxWallet);
63115
+ isInstalled = hasEip6963("metamask") || !!(legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom && !legacyEvm.ethereum?.isRabby && !legacyEvm.ethereum?.isOkxWallet);
63011
63116
  if (isInstalled) detectedNetworks.push("ethereum");
63012
63117
  break;
63013
63118
  case "phantom":
63014
- if (providers.phantomSolana?.isPhantom) {
63119
+ if (solProviders.phantomSolana?.isPhantom) {
63015
63120
  isInstalled = true;
63016
63121
  detectedNetworks.push("solana");
63017
63122
  }
63018
- if (providers.phantomEthereum?.isPhantom) {
63123
+ if (hasEip6963("phantom") || legacyEvm.phantomEthereum?.isPhantom) {
63019
63124
  isInstalled = true;
63020
63125
  detectedNetworks.push("ethereum");
63021
63126
  }
63022
63127
  break;
63023
63128
  case "coinbase":
63024
- if (providers.coinbaseEthereum || providers.ethereum?.isCoinbaseWallet) {
63129
+ if (hasEip6963("coinbase") || legacyEvm.coinbaseEthereum || legacyEvm.ethereum?.isCoinbaseWallet) {
63025
63130
  isInstalled = true;
63026
63131
  detectedNetworks.push("ethereum");
63027
63132
  }
63028
- if (providers.coinbaseSolana || win?.coinbaseWalletExtension?.solana) detectedNetworks.push("solana");
63133
+ if (solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana) detectedNetworks.push("solana");
63029
63134
  if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
63030
63135
  break;
63031
63136
  case "trust":
63032
- if (providers.trustEthereum || providers.ethereum?.isTrust || win?.trustwallet) {
63137
+ if (hasEip6963("trust") || legacyEvm.trustEthereum || legacyEvm.ethereum?.isTrust || win?.trustwallet) {
63033
63138
  isInstalled = true;
63034
63139
  detectedNetworks.push("ethereum");
63035
63140
  }
@@ -63037,27 +63142,27 @@ function detectAvailableWallets(filterChainType) {
63037
63142
  if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
63038
63143
  break;
63039
63144
  case "rainbow":
63040
- isInstalled = !!providers.ethereum?.isRainbow;
63145
+ isInstalled = hasEip6963("rainbow") || !!legacyEvm.ethereum?.isRainbow;
63041
63146
  if (isInstalled) detectedNetworks.push("ethereum");
63042
63147
  break;
63043
63148
  case "rabby":
63044
- isInstalled = !!providers.ethereum?.isRabby;
63149
+ isInstalled = hasEip6963("rabby") || !!legacyEvm.ethereum?.isRabby;
63045
63150
  if (isInstalled) detectedNetworks.push("ethereum");
63046
63151
  break;
63047
63152
  case "okx":
63048
- isInstalled = !!(providers.okxEthereum || providers.ethereum?.isOkxWallet);
63153
+ isInstalled = hasEip6963("okx") || !!(legacyEvm.okxEthereum || legacyEvm.ethereum?.isOkxWallet);
63049
63154
  if (isInstalled) detectedNetworks.push("ethereum");
63050
63155
  break;
63051
63156
  case "solflare":
63052
- isInstalled = !!providers.solflare?.isSolflare;
63157
+ isInstalled = !!solProviders.solflare?.isSolflare;
63053
63158
  if (isInstalled) detectedNetworks.push("solana");
63054
63159
  break;
63055
63160
  case "backpack":
63056
- isInstalled = !!(providers.backpack?.isBackpack || win?.backpack);
63161
+ isInstalled = !!(solProviders.backpack?.isBackpack || win?.backpack);
63057
63162
  if (isInstalled) detectedNetworks.push("solana");
63058
63163
  break;
63059
63164
  case "glow":
63060
- isInstalled = !!(providers.glow?.isGlow || win?.glow);
63165
+ isInstalled = !!(solProviders.glow?.isGlow || win?.glow);
63061
63166
  if (isInstalled) detectedNetworks.push("solana");
63062
63167
  break;
63063
63168
  }
@@ -63112,7 +63217,16 @@ function WalletConnect({
63112
63217
  const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
63113
63218
  const [walletError, setWalletError] = React292.useState(null);
63114
63219
  const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
63115
- const availableWallets = React292.useMemo(() => detectAvailableWallets(), []);
63220
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
63221
+ React292.useEffect(() => {
63222
+ const store = getEip6963Store();
63223
+ if (!store) return;
63224
+ setEip6963ProviderCount(store.getProviders().length);
63225
+ return store.subscribe((providers) => {
63226
+ setEip6963ProviderCount(providers.length);
63227
+ });
63228
+ }, []);
63229
+ const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
63116
63230
  const [balances, setBalances] = React292.useState([]);
63117
63231
  const [isLoading, setIsLoading] = React292.useState(false);
63118
63232
  const [selectedBalance, setSelectedBalance] = React292.useState(null);
@@ -63171,59 +63285,72 @@ function WalletConnect({
63171
63285
  setWalletError(null);
63172
63286
  setIsWalletConnecting(true);
63173
63287
  try {
63174
- const providers = getWalletProviders();
63175
63288
  const win = typeof window !== "undefined" ? window : null;
63176
63289
  let connectedInfo;
63177
63290
  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;
63291
+ const eip6963Match = findProviderByWalletId(wallet.id);
63292
+ let provider = eip6963Match?.provider;
63293
+ if (!provider) {
63294
+ const legacyEvm = getLegacyEvmProviders();
63295
+ switch (wallet.id) {
63296
+ case "metamask":
63297
+ if (legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom) provider = legacyEvm.ethereum;
63298
+ break;
63299
+ case "phantom":
63300
+ provider = legacyEvm.phantomEthereum;
63301
+ break;
63302
+ case "coinbase":
63303
+ provider = legacyEvm.coinbaseEthereum || (legacyEvm.ethereum?.isCoinbaseWallet ? legacyEvm.ethereum : void 0);
63304
+ break;
63305
+ case "trust":
63306
+ provider = legacyEvm.trustEthereum || (legacyEvm.ethereum?.isTrust ? legacyEvm.ethereum : void 0);
63307
+ break;
63308
+ case "rainbow":
63309
+ if (legacyEvm.ethereum?.isRainbow) provider = legacyEvm.ethereum;
63310
+ break;
63311
+ case "rabby":
63312
+ if (legacyEvm.ethereum?.isRabby) provider = legacyEvm.ethereum;
63313
+ break;
63314
+ case "okx":
63315
+ provider = legacyEvm.okxEthereum || (legacyEvm.ethereum?.isOkxWallet ? legacyEvm.ethereum : void 0);
63316
+ break;
63317
+ default:
63318
+ provider = legacyEvm.ethereum;
63319
+ }
63203
63320
  }
63204
63321
  if (!provider) throw new Error(`${wallet.name} wallet not found. Please install it.`);
63205
63322
  const accounts = await provider.request({ method: "eth_requestAccounts" });
63206
63323
  if (!accounts?.length) throw new Error("No accounts returned from wallet");
63207
63324
  setUserDisconnectedWallet(false);
63208
- const walletType = wallet.id === "phantom" ? "phantom-ethereum" : wallet.id === "coinbase" ? "coinbase" : "metamask";
63325
+ const walletIdToType = {
63326
+ phantom: "phantom-ethereum",
63327
+ coinbase: "coinbase",
63328
+ trust: "trust",
63329
+ rainbow: "rainbow",
63330
+ rabby: "rabby",
63331
+ okx: "okx",
63332
+ metamask: "metamask"
63333
+ };
63334
+ const walletType = walletIdToType[wallet.id] || "metamask";
63209
63335
  connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
63210
63336
  } else {
63337
+ const solProviders = getSolanaProviders();
63211
63338
  let provider;
63212
63339
  switch (wallet.id) {
63213
63340
  case "phantom":
63214
- provider = providers.phantomSolana;
63341
+ provider = solProviders.phantomSolana;
63215
63342
  break;
63216
63343
  case "solflare":
63217
- provider = providers.solflare;
63344
+ provider = solProviders.solflare;
63218
63345
  break;
63219
63346
  case "backpack":
63220
- provider = providers.backpack || win?.backpack;
63347
+ provider = solProviders.backpack || win?.backpack;
63221
63348
  break;
63222
63349
  case "glow":
63223
- provider = providers.glow || win?.glow;
63350
+ provider = solProviders.glow || win?.glow;
63224
63351
  break;
63225
63352
  case "coinbase":
63226
- provider = providers.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
63353
+ provider = solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
63227
63354
  break;
63228
63355
  case "trust":
63229
63356
  provider = win?.trustwallet?.solana;
@@ -63469,10 +63596,15 @@ function WalletConnect({
63469
63596
  };
63470
63597
  const sendEthereumTransaction = async (token, amountStr) => {
63471
63598
  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;
63599
+ const walletIdMap = { "phantom-ethereum": "phantom", coinbase: "coinbase", trust: "trust", okx: "okx", rainbow: "rainbow", rabby: "rabby", metamask: "metamask" };
63600
+ const lookupId = walletIdMap[walletInfo.type] || walletInfo.type;
63601
+ const eip6963Match = findProviderByWalletId(lookupId);
63602
+ let provider = eip6963Match?.provider;
63603
+ if (!provider) {
63604
+ if (walletInfo.type === "phantom-ethereum") provider = window.phantom?.ethereum;
63605
+ else if (walletInfo.type === "coinbase") provider = window.coinbaseWalletExtension || window.ethereum;
63606
+ else provider = window.ethereum;
63607
+ }
63476
63608
  if (!provider) throw new Error("Ethereum wallet not found");
63477
63609
  const currentChainIdHex = await provider.request({ method: "eth_chainId", params: [] });
63478
63610
  if (parseInt(currentChainIdHex, 16).toString() !== token.chain_id) {
@@ -63700,6 +63832,7 @@ function DepositModal({
63700
63832
  destinationChainType,
63701
63833
  destinationChainId,
63702
63834
  destinationTokenAddress,
63835
+ contractCalls,
63703
63836
  defaultSourceChainType,
63704
63837
  defaultSourceChainId,
63705
63838
  defaultSourceTokenAddress,
@@ -63826,6 +63959,7 @@ function DepositModal({
63826
63959
  destinationChainType,
63827
63960
  destinationChainId,
63828
63961
  destinationTokenAddress,
63962
+ contractCalls,
63829
63963
  enabled: open
63830
63964
  // Only fetch when modal is open
63831
63965
  });
@@ -65306,7 +65440,7 @@ function useExecutions(userId, publishableKey, options2) {
65306
65440
  });
65307
65441
  }
65308
65442
  var POLL_INTERVAL_MS3 = 2500;
65309
- var POLL_ENDPOINT_INTERVAL_MS2 = 3e3;
65443
+ var POLL_ENDPOINT_INTERVAL_MS2 = 5e3;
65310
65444
  var CUTOFF_BUFFER_MS2 = 6e4;
65311
65445
  function useWithdrawPolling({
65312
65446
  userId,
@@ -67156,6 +67290,7 @@ function UnifoldProvider2({
67156
67290
  destinationChainType: depositConfig.destinationChainType,
67157
67291
  destinationChainId: depositConfig.destinationChainId,
67158
67292
  destinationTokenAddress: depositConfig.destinationTokenAddress,
67293
+ contractCalls: depositConfig.contractCalls,
67159
67294
  defaultSourceChainType: depositConfig.defaultSourceChainType,
67160
67295
  defaultSourceChainId: depositConfig.defaultSourceChainId,
67161
67296
  defaultSourceTokenAddress: depositConfig.defaultSourceTokenAddress,
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.61",
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/connect-react": "0.1.61",
34
+ "@unifold/core": "0.1.61",
35
+ "@unifold/react-provider": "0.1.61",
36
+ "@unifold/ui-react": "0.1.61"
37
37
  },
38
38
  "keywords": [
39
39
  "unifold",