@unifold/connect-react 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.
- package/dist/index.js +248 -114
- package/dist/index.mjs +248 -114
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -7382,6 +7382,62 @@ var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
|
7382
7382
|
var React112 = __toESM(require("react"), 1);
|
|
7383
7383
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
7384
7384
|
var React242 = __toESM(require("react"), 1);
|
|
7385
|
+
|
|
7386
|
+
// ../../node_modules/.pnpm/mipd@0.0.7_typescript@5.9.3/node_modules/mipd/dist/esm/utils.js
|
|
7387
|
+
function requestProviders(listener) {
|
|
7388
|
+
if (typeof window === "undefined")
|
|
7389
|
+
return;
|
|
7390
|
+
const handler = (event) => listener(event.detail);
|
|
7391
|
+
window.addEventListener("eip6963:announceProvider", handler);
|
|
7392
|
+
window.dispatchEvent(new CustomEvent("eip6963:requestProvider"));
|
|
7393
|
+
return () => window.removeEventListener("eip6963:announceProvider", handler);
|
|
7394
|
+
}
|
|
7395
|
+
|
|
7396
|
+
// ../../node_modules/.pnpm/mipd@0.0.7_typescript@5.9.3/node_modules/mipd/dist/esm/store.js
|
|
7397
|
+
function createStore() {
|
|
7398
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
7399
|
+
let providerDetails = [];
|
|
7400
|
+
const request = () => requestProviders((providerDetail) => {
|
|
7401
|
+
if (providerDetails.some(({ info }) => info.uuid === providerDetail.info.uuid))
|
|
7402
|
+
return;
|
|
7403
|
+
providerDetails = [...providerDetails, providerDetail];
|
|
7404
|
+
listeners.forEach((listener) => listener(providerDetails, { added: [providerDetail] }));
|
|
7405
|
+
});
|
|
7406
|
+
let unwatch = request();
|
|
7407
|
+
return {
|
|
7408
|
+
_listeners() {
|
|
7409
|
+
return listeners;
|
|
7410
|
+
},
|
|
7411
|
+
clear() {
|
|
7412
|
+
listeners.forEach((listener) => listener([], { removed: [...providerDetails] }));
|
|
7413
|
+
providerDetails = [];
|
|
7414
|
+
},
|
|
7415
|
+
destroy() {
|
|
7416
|
+
this.clear();
|
|
7417
|
+
listeners.clear();
|
|
7418
|
+
unwatch?.();
|
|
7419
|
+
},
|
|
7420
|
+
findProvider({ rdns }) {
|
|
7421
|
+
return providerDetails.find((providerDetail) => providerDetail.info.rdns === rdns);
|
|
7422
|
+
},
|
|
7423
|
+
getProviders() {
|
|
7424
|
+
return providerDetails;
|
|
7425
|
+
},
|
|
7426
|
+
reset() {
|
|
7427
|
+
this.clear();
|
|
7428
|
+
unwatch?.();
|
|
7429
|
+
unwatch = request();
|
|
7430
|
+
},
|
|
7431
|
+
subscribe(listener, { emitImmediately } = {}) {
|
|
7432
|
+
listeners.add(listener);
|
|
7433
|
+
if (emitImmediately)
|
|
7434
|
+
listener(providerDetails, { added: providerDetails });
|
|
7435
|
+
return () => listeners.delete(listener);
|
|
7436
|
+
}
|
|
7437
|
+
};
|
|
7438
|
+
}
|
|
7439
|
+
|
|
7440
|
+
// ../ui-react/dist/index.mjs
|
|
7385
7441
|
var React122 = __toESM(require("react"), 1);
|
|
7386
7442
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
7387
7443
|
var React132 = __toESM(require("react"), 1);
|
|
@@ -14828,7 +14884,7 @@ function interpolate(template, params) {
|
|
|
14828
14884
|
}
|
|
14829
14885
|
var DEPOSIT_CONFIRM_DELAY_MS = 5e3;
|
|
14830
14886
|
var POLL_INTERVAL_MS = 2500;
|
|
14831
|
-
var POLL_ENDPOINT_INTERVAL_MS =
|
|
14887
|
+
var POLL_ENDPOINT_INTERVAL_MS = 5e3;
|
|
14832
14888
|
var CUTOFF_BUFFER_MS = 6e4;
|
|
14833
14889
|
function useDepositPolling({
|
|
14834
14890
|
userId,
|
|
@@ -18470,6 +18526,53 @@ function CashAppButton({
|
|
|
18470
18526
|
}
|
|
18471
18527
|
);
|
|
18472
18528
|
}
|
|
18529
|
+
var _store = null;
|
|
18530
|
+
function getEip6963Store() {
|
|
18531
|
+
if (typeof window === "undefined") return null;
|
|
18532
|
+
if (!_store) {
|
|
18533
|
+
_store = createStore();
|
|
18534
|
+
}
|
|
18535
|
+
return _store;
|
|
18536
|
+
}
|
|
18537
|
+
var RDNS_TO_WALLET_ID = {
|
|
18538
|
+
"io.metamask": "metamask",
|
|
18539
|
+
"io.metamask.flask": "metamask",
|
|
18540
|
+
"io.metamask.mmi": "metamask",
|
|
18541
|
+
"app.phantom": "phantom",
|
|
18542
|
+
"com.coinbase.wallet": "coinbase",
|
|
18543
|
+
"com.okex.wallet": "okx",
|
|
18544
|
+
"io.rabby": "rabby",
|
|
18545
|
+
"com.trustwallet.app": "trust",
|
|
18546
|
+
"me.rainbow": "rainbow"
|
|
18547
|
+
};
|
|
18548
|
+
function rdnsToWalletId(rdns) {
|
|
18549
|
+
if (RDNS_TO_WALLET_ID[rdns]) return RDNS_TO_WALLET_ID[rdns];
|
|
18550
|
+
if (rdns.includes("metamask")) return "metamask";
|
|
18551
|
+
if (rdns.includes("phantom")) return "phantom";
|
|
18552
|
+
if (rdns.includes("coinbase")) return "coinbase";
|
|
18553
|
+
if (rdns.includes("okx") || rdns.includes("okex")) return "okx";
|
|
18554
|
+
if (rdns.includes("rabby")) return "rabby";
|
|
18555
|
+
if (rdns.includes("trust")) return "trust";
|
|
18556
|
+
if (rdns.includes("rainbow")) return "rainbow";
|
|
18557
|
+
return "unknown";
|
|
18558
|
+
}
|
|
18559
|
+
function getEip6963Providers() {
|
|
18560
|
+
const store = getEip6963Store();
|
|
18561
|
+
if (!store) return [];
|
|
18562
|
+
return store.getProviders().map((detail) => ({
|
|
18563
|
+
walletId: rdnsToWalletId(detail.info.rdns),
|
|
18564
|
+
provider: detail.provider,
|
|
18565
|
+
info: detail.info
|
|
18566
|
+
}));
|
|
18567
|
+
}
|
|
18568
|
+
function findProviderByWalletId(walletId) {
|
|
18569
|
+
return getEip6963Providers().find((p) => p.walletId === walletId);
|
|
18570
|
+
}
|
|
18571
|
+
function collectAllEip6963EthProviders() {
|
|
18572
|
+
const store = getEip6963Store();
|
|
18573
|
+
if (!store) return [];
|
|
18574
|
+
return store.getProviders().map((d) => d.provider);
|
|
18575
|
+
}
|
|
18473
18576
|
var SOLANA_DISCONNECT_TYPES = [
|
|
18474
18577
|
"phantom-solana",
|
|
18475
18578
|
"solflare",
|
|
@@ -18509,8 +18612,9 @@ function collectEthereumProvidersForDisconnect(win) {
|
|
|
18509
18612
|
out.push(p);
|
|
18510
18613
|
}
|
|
18511
18614
|
};
|
|
18512
|
-
const
|
|
18513
|
-
|
|
18615
|
+
for (const p of collectAllEip6963EthProviders()) {
|
|
18616
|
+
add(p);
|
|
18617
|
+
}
|
|
18514
18618
|
add(win.ethereum);
|
|
18515
18619
|
add(
|
|
18516
18620
|
win.phantom?.ethereum
|
|
@@ -20516,30 +20620,13 @@ function BrowserWalletButton({
|
|
|
20516
20620
|
}, []);
|
|
20517
20621
|
const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
|
|
20518
20622
|
React242.useEffect(() => {
|
|
20519
|
-
|
|
20520
|
-
|
|
20521
|
-
|
|
20522
|
-
|
|
20523
|
-
|
|
20524
|
-
|
|
20525
|
-
|
|
20526
|
-
if (!detail?.info || !detail?.provider) return;
|
|
20527
|
-
const exists = anyWin.__eip6963Providers.some(
|
|
20528
|
-
(p) => p.info.uuid === detail.info.uuid
|
|
20529
|
-
);
|
|
20530
|
-
if (!exists) {
|
|
20531
|
-
anyWin.__eip6963Providers.push(detail);
|
|
20532
|
-
setEip6963ProviderCount(anyWin.__eip6963Providers.length);
|
|
20533
|
-
}
|
|
20534
|
-
};
|
|
20535
|
-
window.addEventListener("eip6963:announceProvider", handleAnnouncement);
|
|
20536
|
-
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
20537
|
-
return () => {
|
|
20538
|
-
window.removeEventListener(
|
|
20539
|
-
"eip6963:announceProvider",
|
|
20540
|
-
handleAnnouncement
|
|
20541
|
-
);
|
|
20542
|
-
};
|
|
20623
|
+
const store = getEip6963Store();
|
|
20624
|
+
if (!store) return;
|
|
20625
|
+
setEip6963ProviderCount(store.getProviders().length);
|
|
20626
|
+
const unsubscribe = store.subscribe((providers) => {
|
|
20627
|
+
setEip6963ProviderCount(providers.length);
|
|
20628
|
+
});
|
|
20629
|
+
return unsubscribe;
|
|
20543
20630
|
}, []);
|
|
20544
20631
|
React242.useEffect(() => {
|
|
20545
20632
|
if (!wallet || !publishableKey) {
|
|
@@ -20598,7 +20685,7 @@ function BrowserWalletButton({
|
|
|
20598
20685
|
return;
|
|
20599
20686
|
}
|
|
20600
20687
|
if (!chainType || chainType === "solana") {
|
|
20601
|
-
const
|
|
20688
|
+
const anyWin = win;
|
|
20602
20689
|
const trySilentSolana = async (provider, type, name, icon) => {
|
|
20603
20690
|
if (!provider) return false;
|
|
20604
20691
|
if (provider.isConnected && provider.publicKey) {
|
|
@@ -20637,21 +20724,21 @@ function BrowserWalletButton({
|
|
|
20637
20724
|
))
|
|
20638
20725
|
return;
|
|
20639
20726
|
if (await trySilentSolana(
|
|
20640
|
-
|
|
20727
|
+
anyWin.solflare,
|
|
20641
20728
|
"solflare",
|
|
20642
20729
|
"Solflare",
|
|
20643
20730
|
"solflare"
|
|
20644
20731
|
))
|
|
20645
20732
|
return;
|
|
20646
20733
|
if (await trySilentSolana(
|
|
20647
|
-
|
|
20734
|
+
anyWin.backpack,
|
|
20648
20735
|
"backpack",
|
|
20649
20736
|
"Backpack",
|
|
20650
20737
|
"backpack"
|
|
20651
20738
|
))
|
|
20652
20739
|
return;
|
|
20653
20740
|
if (await trySilentSolana(
|
|
20654
|
-
|
|
20741
|
+
anyWin.glow,
|
|
20655
20742
|
"glow",
|
|
20656
20743
|
"Glow",
|
|
20657
20744
|
"glow"
|
|
@@ -20659,19 +20746,14 @@ function BrowserWalletButton({
|
|
|
20659
20746
|
return;
|
|
20660
20747
|
}
|
|
20661
20748
|
if (!chainType || chainType === "ethereum") {
|
|
20662
|
-
const
|
|
20749
|
+
const anyWin = win;
|
|
20663
20750
|
const allProviders = [];
|
|
20664
|
-
const
|
|
20665
|
-
for (const {
|
|
20666
|
-
|
|
20667
|
-
|
|
20668
|
-
|
|
20669
|
-
|
|
20670
|
-
else if (info.rdns.includes("okx")) walletId = "okx";
|
|
20671
|
-
else if (info.rdns.includes("rabby")) walletId = "rabby";
|
|
20672
|
-
else if (info.rdns.includes("trust")) walletId = "trust";
|
|
20673
|
-
else if (info.rdns.includes("rainbow")) walletId = "rainbow";
|
|
20674
|
-
allProviders.push({ provider, walletId });
|
|
20751
|
+
const eip6963 = getEip6963Providers();
|
|
20752
|
+
for (const { provider, walletId } of eip6963) {
|
|
20753
|
+
allProviders.push({
|
|
20754
|
+
provider,
|
|
20755
|
+
walletId: walletId === "unknown" ? "default" : walletId
|
|
20756
|
+
});
|
|
20675
20757
|
}
|
|
20676
20758
|
if (allProviders.length === 0) {
|
|
20677
20759
|
if (win.phantom?.ethereum) {
|
|
@@ -20680,15 +20762,15 @@ function BrowserWalletButton({
|
|
|
20680
20762
|
walletId: "phantom"
|
|
20681
20763
|
});
|
|
20682
20764
|
}
|
|
20683
|
-
if (
|
|
20765
|
+
if (anyWin.okxwallet) {
|
|
20684
20766
|
allProviders.push({
|
|
20685
|
-
provider:
|
|
20767
|
+
provider: anyWin.okxwallet,
|
|
20686
20768
|
walletId: "okx"
|
|
20687
20769
|
});
|
|
20688
20770
|
}
|
|
20689
|
-
if (
|
|
20771
|
+
if (anyWin.coinbaseWalletExtension) {
|
|
20690
20772
|
allProviders.push({
|
|
20691
|
-
provider:
|
|
20773
|
+
provider: anyWin.coinbaseWalletExtension,
|
|
20692
20774
|
walletId: "coinbase"
|
|
20693
20775
|
});
|
|
20694
20776
|
}
|
|
@@ -20712,7 +20794,7 @@ function BrowserWalletButton({
|
|
|
20712
20794
|
});
|
|
20713
20795
|
if (!accounts || accounts.length === 0) continue;
|
|
20714
20796
|
const address = accounts[0];
|
|
20715
|
-
const resolved = identifyEthWallet(provider,
|
|
20797
|
+
const resolved = identifyEthWallet(provider, anyWin, walletId);
|
|
20716
20798
|
if (mounted) {
|
|
20717
20799
|
setWallet({ ...resolved, address });
|
|
20718
20800
|
setIsLoading(false);
|
|
@@ -20754,15 +20836,11 @@ function BrowserWalletButton({
|
|
|
20754
20836
|
solanaProvider.on("disconnect", handleDisconnect);
|
|
20755
20837
|
solanaProvider.on("accountChanged", handleAccountsChanged);
|
|
20756
20838
|
}
|
|
20757
|
-
const anyWin = window;
|
|
20758
20839
|
const ethProviders = [];
|
|
20759
|
-
|
|
20760
|
-
|
|
20761
|
-
|
|
20762
|
-
|
|
20763
|
-
if (provider && !ethProviders.includes(provider)) {
|
|
20764
|
-
ethProviders.push(provider);
|
|
20765
|
-
}
|
|
20840
|
+
for (const { provider } of getEip6963Providers()) {
|
|
20841
|
+
const p = provider;
|
|
20842
|
+
if (p && !ethProviders.includes(p)) {
|
|
20843
|
+
ethProviders.push(p);
|
|
20766
20844
|
}
|
|
20767
20845
|
}
|
|
20768
20846
|
if (window.ethereum && !ethProviders.includes(window.ethereum)) {
|
|
@@ -20864,7 +20942,7 @@ function BrowserWalletButton({
|
|
|
20864
20942
|
if (isLoading) {
|
|
20865
20943
|
return null;
|
|
20866
20944
|
}
|
|
20867
|
-
const hasWalletExtension = (!chainType || chainType === "solana") && (window.phantom?.solana?.isPhantom || window.solana?.isPhantom)
|
|
20945
|
+
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);
|
|
20868
20946
|
if (!onConnectClick && !wallet && !hasWalletExtension) {
|
|
20869
20947
|
return null;
|
|
20870
20948
|
}
|
|
@@ -26372,15 +26450,10 @@ var WALLET_DEFINITIONS = [
|
|
|
26372
26450
|
{ id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
|
|
26373
26451
|
{ id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
|
|
26374
26452
|
];
|
|
26375
|
-
function
|
|
26453
|
+
function getSolanaProviders() {
|
|
26376
26454
|
if (typeof window === "undefined") return {};
|
|
26377
26455
|
const win = window;
|
|
26378
26456
|
return {
|
|
26379
|
-
ethereum: win.ethereum,
|
|
26380
|
-
phantomEthereum: win.phantom?.ethereum,
|
|
26381
|
-
coinbaseEthereum: win.coinbaseWalletExtension,
|
|
26382
|
-
trustEthereum: win.trustwallet?.ethereum,
|
|
26383
|
-
okxEthereum: win.okxwallet,
|
|
26384
26457
|
phantomSolana: win.phantom?.solana,
|
|
26385
26458
|
solflare: win.solflare,
|
|
26386
26459
|
backpack: win.backpack,
|
|
@@ -26388,37 +26461,71 @@ function getWalletProviders() {
|
|
|
26388
26461
|
coinbaseSolana: win.coinbaseSolana || win.coinbaseWalletExtension?.solana
|
|
26389
26462
|
};
|
|
26390
26463
|
}
|
|
26464
|
+
function getLegacyEvmProviders() {
|
|
26465
|
+
if (typeof window === "undefined") return {};
|
|
26466
|
+
const win = window;
|
|
26467
|
+
return {
|
|
26468
|
+
ethereum: win.ethereum,
|
|
26469
|
+
phantomEthereum: win.phantom?.ethereum,
|
|
26470
|
+
coinbaseEthereum: win.coinbaseWalletExtension,
|
|
26471
|
+
trustEthereum: win.trustwallet?.ethereum,
|
|
26472
|
+
okxEthereum: win.okxwallet
|
|
26473
|
+
};
|
|
26474
|
+
}
|
|
26391
26475
|
function detectAvailableWallets(filterChainType) {
|
|
26392
|
-
const
|
|
26476
|
+
const solProviders = getSolanaProviders();
|
|
26477
|
+
const legacyEvm = getLegacyEvmProviders();
|
|
26478
|
+
const eip6963List = getEip6963Providers();
|
|
26393
26479
|
const win = typeof window !== "undefined" ? window : null;
|
|
26480
|
+
const hasEip6963 = (walletId) => eip6963List.some((d) => {
|
|
26481
|
+
const rdns = d.info?.rdns || "";
|
|
26482
|
+
switch (walletId) {
|
|
26483
|
+
case "metamask":
|
|
26484
|
+
return rdns.includes("metamask");
|
|
26485
|
+
case "phantom":
|
|
26486
|
+
return rdns.includes("phantom");
|
|
26487
|
+
case "coinbase":
|
|
26488
|
+
return rdns.includes("coinbase");
|
|
26489
|
+
case "trust":
|
|
26490
|
+
return rdns.includes("trust");
|
|
26491
|
+
case "rainbow":
|
|
26492
|
+
return rdns.includes("rainbow");
|
|
26493
|
+
case "rabby":
|
|
26494
|
+
return rdns.includes("rabby");
|
|
26495
|
+
case "okx":
|
|
26496
|
+
return rdns.includes("okx") || rdns.includes("okex");
|
|
26497
|
+
default:
|
|
26498
|
+
return false;
|
|
26499
|
+
}
|
|
26500
|
+
});
|
|
26394
26501
|
return WALLET_DEFINITIONS.filter((w) => !filterChainType || w.networks.includes(filterChainType)).map((wallet) => {
|
|
26395
26502
|
let isInstalled = false;
|
|
26396
26503
|
const detectedNetworks = [];
|
|
26397
26504
|
switch (wallet.id) {
|
|
26398
26505
|
case "metamask":
|
|
26399
|
-
isInstalled = !!(
|
|
26506
|
+
isInstalled = hasEip6963("metamask") || !!(legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom && !legacyEvm.ethereum?.isRabby && !legacyEvm.ethereum?.isOkxWallet);
|
|
26400
26507
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26401
26508
|
break;
|
|
26402
26509
|
case "phantom":
|
|
26403
|
-
if (
|
|
26510
|
+
if (solProviders.phantomSolana?.isPhantom) {
|
|
26404
26511
|
isInstalled = true;
|
|
26405
26512
|
detectedNetworks.push("solana");
|
|
26406
26513
|
}
|
|
26407
|
-
if (
|
|
26514
|
+
if (hasEip6963("phantom") || legacyEvm.phantomEthereum?.isPhantom) {
|
|
26408
26515
|
isInstalled = true;
|
|
26409
26516
|
detectedNetworks.push("ethereum");
|
|
26410
26517
|
}
|
|
26411
26518
|
break;
|
|
26412
26519
|
case "coinbase":
|
|
26413
|
-
if (
|
|
26520
|
+
if (hasEip6963("coinbase") || legacyEvm.coinbaseEthereum || legacyEvm.ethereum?.isCoinbaseWallet) {
|
|
26414
26521
|
isInstalled = true;
|
|
26415
26522
|
detectedNetworks.push("ethereum");
|
|
26416
26523
|
}
|
|
26417
|
-
if (
|
|
26524
|
+
if (solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana) detectedNetworks.push("solana");
|
|
26418
26525
|
if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
|
|
26419
26526
|
break;
|
|
26420
26527
|
case "trust":
|
|
26421
|
-
if (
|
|
26528
|
+
if (hasEip6963("trust") || legacyEvm.trustEthereum || legacyEvm.ethereum?.isTrust || win?.trustwallet) {
|
|
26422
26529
|
isInstalled = true;
|
|
26423
26530
|
detectedNetworks.push("ethereum");
|
|
26424
26531
|
}
|
|
@@ -26426,27 +26533,27 @@ function detectAvailableWallets(filterChainType) {
|
|
|
26426
26533
|
if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
|
|
26427
26534
|
break;
|
|
26428
26535
|
case "rainbow":
|
|
26429
|
-
isInstalled = !!
|
|
26536
|
+
isInstalled = hasEip6963("rainbow") || !!legacyEvm.ethereum?.isRainbow;
|
|
26430
26537
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26431
26538
|
break;
|
|
26432
26539
|
case "rabby":
|
|
26433
|
-
isInstalled = !!
|
|
26540
|
+
isInstalled = hasEip6963("rabby") || !!legacyEvm.ethereum?.isRabby;
|
|
26434
26541
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26435
26542
|
break;
|
|
26436
26543
|
case "okx":
|
|
26437
|
-
isInstalled = !!(
|
|
26544
|
+
isInstalled = hasEip6963("okx") || !!(legacyEvm.okxEthereum || legacyEvm.ethereum?.isOkxWallet);
|
|
26438
26545
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26439
26546
|
break;
|
|
26440
26547
|
case "solflare":
|
|
26441
|
-
isInstalled = !!
|
|
26548
|
+
isInstalled = !!solProviders.solflare?.isSolflare;
|
|
26442
26549
|
if (isInstalled) detectedNetworks.push("solana");
|
|
26443
26550
|
break;
|
|
26444
26551
|
case "backpack":
|
|
26445
|
-
isInstalled = !!(
|
|
26552
|
+
isInstalled = !!(solProviders.backpack?.isBackpack || win?.backpack);
|
|
26446
26553
|
if (isInstalled) detectedNetworks.push("solana");
|
|
26447
26554
|
break;
|
|
26448
26555
|
case "glow":
|
|
26449
|
-
isInstalled = !!(
|
|
26556
|
+
isInstalled = !!(solProviders.glow?.isGlow || win?.glow);
|
|
26450
26557
|
if (isInstalled) detectedNetworks.push("solana");
|
|
26451
26558
|
break;
|
|
26452
26559
|
}
|
|
@@ -26501,7 +26608,16 @@ function WalletConnect({
|
|
|
26501
26608
|
const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
|
|
26502
26609
|
const [walletError, setWalletError] = React292.useState(null);
|
|
26503
26610
|
const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
|
|
26504
|
-
const
|
|
26611
|
+
const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
|
|
26612
|
+
React292.useEffect(() => {
|
|
26613
|
+
const store = getEip6963Store();
|
|
26614
|
+
if (!store) return;
|
|
26615
|
+
setEip6963ProviderCount(store.getProviders().length);
|
|
26616
|
+
return store.subscribe((providers) => {
|
|
26617
|
+
setEip6963ProviderCount(providers.length);
|
|
26618
|
+
});
|
|
26619
|
+
}, []);
|
|
26620
|
+
const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
|
|
26505
26621
|
const [balances, setBalances] = React292.useState([]);
|
|
26506
26622
|
const [isLoading, setIsLoading] = React292.useState(false);
|
|
26507
26623
|
const [selectedBalance, setSelectedBalance] = React292.useState(null);
|
|
@@ -26560,59 +26676,72 @@ function WalletConnect({
|
|
|
26560
26676
|
setWalletError(null);
|
|
26561
26677
|
setIsWalletConnecting(true);
|
|
26562
26678
|
try {
|
|
26563
|
-
const providers = getWalletProviders();
|
|
26564
26679
|
const win = typeof window !== "undefined" ? window : null;
|
|
26565
26680
|
let connectedInfo;
|
|
26566
26681
|
if (network === "ethereum") {
|
|
26567
|
-
|
|
26568
|
-
|
|
26569
|
-
|
|
26570
|
-
|
|
26571
|
-
|
|
26572
|
-
|
|
26573
|
-
|
|
26574
|
-
|
|
26575
|
-
|
|
26576
|
-
|
|
26577
|
-
|
|
26578
|
-
|
|
26579
|
-
|
|
26580
|
-
|
|
26581
|
-
|
|
26582
|
-
|
|
26583
|
-
|
|
26584
|
-
|
|
26585
|
-
|
|
26586
|
-
|
|
26587
|
-
|
|
26588
|
-
|
|
26589
|
-
|
|
26590
|
-
|
|
26591
|
-
|
|
26682
|
+
const eip6963Match = findProviderByWalletId(wallet.id);
|
|
26683
|
+
let provider = eip6963Match?.provider;
|
|
26684
|
+
if (!provider) {
|
|
26685
|
+
const legacyEvm = getLegacyEvmProviders();
|
|
26686
|
+
switch (wallet.id) {
|
|
26687
|
+
case "metamask":
|
|
26688
|
+
if (legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom) provider = legacyEvm.ethereum;
|
|
26689
|
+
break;
|
|
26690
|
+
case "phantom":
|
|
26691
|
+
provider = legacyEvm.phantomEthereum;
|
|
26692
|
+
break;
|
|
26693
|
+
case "coinbase":
|
|
26694
|
+
provider = legacyEvm.coinbaseEthereum || (legacyEvm.ethereum?.isCoinbaseWallet ? legacyEvm.ethereum : void 0);
|
|
26695
|
+
break;
|
|
26696
|
+
case "trust":
|
|
26697
|
+
provider = legacyEvm.trustEthereum || (legacyEvm.ethereum?.isTrust ? legacyEvm.ethereum : void 0);
|
|
26698
|
+
break;
|
|
26699
|
+
case "rainbow":
|
|
26700
|
+
if (legacyEvm.ethereum?.isRainbow) provider = legacyEvm.ethereum;
|
|
26701
|
+
break;
|
|
26702
|
+
case "rabby":
|
|
26703
|
+
if (legacyEvm.ethereum?.isRabby) provider = legacyEvm.ethereum;
|
|
26704
|
+
break;
|
|
26705
|
+
case "okx":
|
|
26706
|
+
provider = legacyEvm.okxEthereum || (legacyEvm.ethereum?.isOkxWallet ? legacyEvm.ethereum : void 0);
|
|
26707
|
+
break;
|
|
26708
|
+
default:
|
|
26709
|
+
provider = legacyEvm.ethereum;
|
|
26710
|
+
}
|
|
26592
26711
|
}
|
|
26593
26712
|
if (!provider) throw new Error(`${wallet.name} wallet not found. Please install it.`);
|
|
26594
26713
|
const accounts = await provider.request({ method: "eth_requestAccounts" });
|
|
26595
26714
|
if (!accounts?.length) throw new Error("No accounts returned from wallet");
|
|
26596
26715
|
setUserDisconnectedWallet(false);
|
|
26597
|
-
const
|
|
26716
|
+
const walletIdToType = {
|
|
26717
|
+
phantom: "phantom-ethereum",
|
|
26718
|
+
coinbase: "coinbase",
|
|
26719
|
+
trust: "trust",
|
|
26720
|
+
rainbow: "rainbow",
|
|
26721
|
+
rabby: "rabby",
|
|
26722
|
+
okx: "okx",
|
|
26723
|
+
metamask: "metamask"
|
|
26724
|
+
};
|
|
26725
|
+
const walletType = walletIdToType[wallet.id] || "metamask";
|
|
26598
26726
|
connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
|
|
26599
26727
|
} else {
|
|
26728
|
+
const solProviders = getSolanaProviders();
|
|
26600
26729
|
let provider;
|
|
26601
26730
|
switch (wallet.id) {
|
|
26602
26731
|
case "phantom":
|
|
26603
|
-
provider =
|
|
26732
|
+
provider = solProviders.phantomSolana;
|
|
26604
26733
|
break;
|
|
26605
26734
|
case "solflare":
|
|
26606
|
-
provider =
|
|
26735
|
+
provider = solProviders.solflare;
|
|
26607
26736
|
break;
|
|
26608
26737
|
case "backpack":
|
|
26609
|
-
provider =
|
|
26738
|
+
provider = solProviders.backpack || win?.backpack;
|
|
26610
26739
|
break;
|
|
26611
26740
|
case "glow":
|
|
26612
|
-
provider =
|
|
26741
|
+
provider = solProviders.glow || win?.glow;
|
|
26613
26742
|
break;
|
|
26614
26743
|
case "coinbase":
|
|
26615
|
-
provider =
|
|
26744
|
+
provider = solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
|
|
26616
26745
|
break;
|
|
26617
26746
|
case "trust":
|
|
26618
26747
|
provider = win?.trustwallet?.solana;
|
|
@@ -26858,10 +26987,15 @@ function WalletConnect({
|
|
|
26858
26987
|
};
|
|
26859
26988
|
const sendEthereumTransaction = async (token, amountStr) => {
|
|
26860
26989
|
if (!recipientAddress || !/^0x[a-fA-F0-9]{40}$/.test(recipientAddress)) throw new Error(`Invalid recipient address.`);
|
|
26861
|
-
|
|
26862
|
-
|
|
26863
|
-
|
|
26864
|
-
|
|
26990
|
+
const walletIdMap = { "phantom-ethereum": "phantom", coinbase: "coinbase", trust: "trust", okx: "okx", rainbow: "rainbow", rabby: "rabby", metamask: "metamask" };
|
|
26991
|
+
const lookupId = walletIdMap[walletInfo.type] || walletInfo.type;
|
|
26992
|
+
const eip6963Match = findProviderByWalletId(lookupId);
|
|
26993
|
+
let provider = eip6963Match?.provider;
|
|
26994
|
+
if (!provider) {
|
|
26995
|
+
if (walletInfo.type === "phantom-ethereum") provider = window.phantom?.ethereum;
|
|
26996
|
+
else if (walletInfo.type === "coinbase") provider = window.coinbaseWalletExtension || window.ethereum;
|
|
26997
|
+
else provider = window.ethereum;
|
|
26998
|
+
}
|
|
26865
26999
|
if (!provider) throw new Error("Ethereum wallet not found");
|
|
26866
27000
|
const currentChainIdHex = await provider.request({ method: "eth_chainId", params: [] });
|
|
26867
27001
|
if (parseInt(currentChainIdHex, 16).toString() !== token.chain_id) {
|
|
@@ -28695,7 +28829,7 @@ function useExecutions(userId, publishableKey, options) {
|
|
|
28695
28829
|
});
|
|
28696
28830
|
}
|
|
28697
28831
|
var POLL_INTERVAL_MS3 = 2500;
|
|
28698
|
-
var POLL_ENDPOINT_INTERVAL_MS2 =
|
|
28832
|
+
var POLL_ENDPOINT_INTERVAL_MS2 = 5e3;
|
|
28699
28833
|
var CUTOFF_BUFFER_MS2 = 6e4;
|
|
28700
28834
|
function useWithdrawPolling({
|
|
28701
28835
|
userId,
|
package/dist/index.mjs
CHANGED
|
@@ -7355,6 +7355,62 @@ import { jsx as jsx21, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
|
7355
7355
|
import * as React112 from "react";
|
|
7356
7356
|
import { jsx as jsx222, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
7357
7357
|
import * as React242 from "react";
|
|
7358
|
+
|
|
7359
|
+
// ../../node_modules/.pnpm/mipd@0.0.7_typescript@5.9.3/node_modules/mipd/dist/esm/utils.js
|
|
7360
|
+
function requestProviders(listener) {
|
|
7361
|
+
if (typeof window === "undefined")
|
|
7362
|
+
return;
|
|
7363
|
+
const handler = (event) => listener(event.detail);
|
|
7364
|
+
window.addEventListener("eip6963:announceProvider", handler);
|
|
7365
|
+
window.dispatchEvent(new CustomEvent("eip6963:requestProvider"));
|
|
7366
|
+
return () => window.removeEventListener("eip6963:announceProvider", handler);
|
|
7367
|
+
}
|
|
7368
|
+
|
|
7369
|
+
// ../../node_modules/.pnpm/mipd@0.0.7_typescript@5.9.3/node_modules/mipd/dist/esm/store.js
|
|
7370
|
+
function createStore() {
|
|
7371
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
7372
|
+
let providerDetails = [];
|
|
7373
|
+
const request = () => requestProviders((providerDetail) => {
|
|
7374
|
+
if (providerDetails.some(({ info }) => info.uuid === providerDetail.info.uuid))
|
|
7375
|
+
return;
|
|
7376
|
+
providerDetails = [...providerDetails, providerDetail];
|
|
7377
|
+
listeners.forEach((listener) => listener(providerDetails, { added: [providerDetail] }));
|
|
7378
|
+
});
|
|
7379
|
+
let unwatch = request();
|
|
7380
|
+
return {
|
|
7381
|
+
_listeners() {
|
|
7382
|
+
return listeners;
|
|
7383
|
+
},
|
|
7384
|
+
clear() {
|
|
7385
|
+
listeners.forEach((listener) => listener([], { removed: [...providerDetails] }));
|
|
7386
|
+
providerDetails = [];
|
|
7387
|
+
},
|
|
7388
|
+
destroy() {
|
|
7389
|
+
this.clear();
|
|
7390
|
+
listeners.clear();
|
|
7391
|
+
unwatch?.();
|
|
7392
|
+
},
|
|
7393
|
+
findProvider({ rdns }) {
|
|
7394
|
+
return providerDetails.find((providerDetail) => providerDetail.info.rdns === rdns);
|
|
7395
|
+
},
|
|
7396
|
+
getProviders() {
|
|
7397
|
+
return providerDetails;
|
|
7398
|
+
},
|
|
7399
|
+
reset() {
|
|
7400
|
+
this.clear();
|
|
7401
|
+
unwatch?.();
|
|
7402
|
+
unwatch = request();
|
|
7403
|
+
},
|
|
7404
|
+
subscribe(listener, { emitImmediately } = {}) {
|
|
7405
|
+
listeners.add(listener);
|
|
7406
|
+
if (emitImmediately)
|
|
7407
|
+
listener(providerDetails, { added: providerDetails });
|
|
7408
|
+
return () => listeners.delete(listener);
|
|
7409
|
+
}
|
|
7410
|
+
};
|
|
7411
|
+
}
|
|
7412
|
+
|
|
7413
|
+
// ../ui-react/dist/index.mjs
|
|
7358
7414
|
import * as React122 from "react";
|
|
7359
7415
|
import { jsx as jsx232, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
7360
7416
|
import * as React132 from "react";
|
|
@@ -14814,7 +14870,7 @@ function interpolate(template, params) {
|
|
|
14814
14870
|
}
|
|
14815
14871
|
var DEPOSIT_CONFIRM_DELAY_MS = 5e3;
|
|
14816
14872
|
var POLL_INTERVAL_MS = 2500;
|
|
14817
|
-
var POLL_ENDPOINT_INTERVAL_MS =
|
|
14873
|
+
var POLL_ENDPOINT_INTERVAL_MS = 5e3;
|
|
14818
14874
|
var CUTOFF_BUFFER_MS = 6e4;
|
|
14819
14875
|
function useDepositPolling({
|
|
14820
14876
|
userId,
|
|
@@ -18456,6 +18512,53 @@ function CashAppButton({
|
|
|
18456
18512
|
}
|
|
18457
18513
|
);
|
|
18458
18514
|
}
|
|
18515
|
+
var _store = null;
|
|
18516
|
+
function getEip6963Store() {
|
|
18517
|
+
if (typeof window === "undefined") return null;
|
|
18518
|
+
if (!_store) {
|
|
18519
|
+
_store = createStore();
|
|
18520
|
+
}
|
|
18521
|
+
return _store;
|
|
18522
|
+
}
|
|
18523
|
+
var RDNS_TO_WALLET_ID = {
|
|
18524
|
+
"io.metamask": "metamask",
|
|
18525
|
+
"io.metamask.flask": "metamask",
|
|
18526
|
+
"io.metamask.mmi": "metamask",
|
|
18527
|
+
"app.phantom": "phantom",
|
|
18528
|
+
"com.coinbase.wallet": "coinbase",
|
|
18529
|
+
"com.okex.wallet": "okx",
|
|
18530
|
+
"io.rabby": "rabby",
|
|
18531
|
+
"com.trustwallet.app": "trust",
|
|
18532
|
+
"me.rainbow": "rainbow"
|
|
18533
|
+
};
|
|
18534
|
+
function rdnsToWalletId(rdns) {
|
|
18535
|
+
if (RDNS_TO_WALLET_ID[rdns]) return RDNS_TO_WALLET_ID[rdns];
|
|
18536
|
+
if (rdns.includes("metamask")) return "metamask";
|
|
18537
|
+
if (rdns.includes("phantom")) return "phantom";
|
|
18538
|
+
if (rdns.includes("coinbase")) return "coinbase";
|
|
18539
|
+
if (rdns.includes("okx") || rdns.includes("okex")) return "okx";
|
|
18540
|
+
if (rdns.includes("rabby")) return "rabby";
|
|
18541
|
+
if (rdns.includes("trust")) return "trust";
|
|
18542
|
+
if (rdns.includes("rainbow")) return "rainbow";
|
|
18543
|
+
return "unknown";
|
|
18544
|
+
}
|
|
18545
|
+
function getEip6963Providers() {
|
|
18546
|
+
const store = getEip6963Store();
|
|
18547
|
+
if (!store) return [];
|
|
18548
|
+
return store.getProviders().map((detail) => ({
|
|
18549
|
+
walletId: rdnsToWalletId(detail.info.rdns),
|
|
18550
|
+
provider: detail.provider,
|
|
18551
|
+
info: detail.info
|
|
18552
|
+
}));
|
|
18553
|
+
}
|
|
18554
|
+
function findProviderByWalletId(walletId) {
|
|
18555
|
+
return getEip6963Providers().find((p) => p.walletId === walletId);
|
|
18556
|
+
}
|
|
18557
|
+
function collectAllEip6963EthProviders() {
|
|
18558
|
+
const store = getEip6963Store();
|
|
18559
|
+
if (!store) return [];
|
|
18560
|
+
return store.getProviders().map((d) => d.provider);
|
|
18561
|
+
}
|
|
18459
18562
|
var SOLANA_DISCONNECT_TYPES = [
|
|
18460
18563
|
"phantom-solana",
|
|
18461
18564
|
"solflare",
|
|
@@ -18495,8 +18598,9 @@ function collectEthereumProvidersForDisconnect(win) {
|
|
|
18495
18598
|
out.push(p);
|
|
18496
18599
|
}
|
|
18497
18600
|
};
|
|
18498
|
-
const
|
|
18499
|
-
|
|
18601
|
+
for (const p of collectAllEip6963EthProviders()) {
|
|
18602
|
+
add(p);
|
|
18603
|
+
}
|
|
18500
18604
|
add(win.ethereum);
|
|
18501
18605
|
add(
|
|
18502
18606
|
win.phantom?.ethereum
|
|
@@ -20502,30 +20606,13 @@ function BrowserWalletButton({
|
|
|
20502
20606
|
}, []);
|
|
20503
20607
|
const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
|
|
20504
20608
|
React242.useEffect(() => {
|
|
20505
|
-
|
|
20506
|
-
|
|
20507
|
-
|
|
20508
|
-
|
|
20509
|
-
|
|
20510
|
-
|
|
20511
|
-
|
|
20512
|
-
if (!detail?.info || !detail?.provider) return;
|
|
20513
|
-
const exists = anyWin.__eip6963Providers.some(
|
|
20514
|
-
(p) => p.info.uuid === detail.info.uuid
|
|
20515
|
-
);
|
|
20516
|
-
if (!exists) {
|
|
20517
|
-
anyWin.__eip6963Providers.push(detail);
|
|
20518
|
-
setEip6963ProviderCount(anyWin.__eip6963Providers.length);
|
|
20519
|
-
}
|
|
20520
|
-
};
|
|
20521
|
-
window.addEventListener("eip6963:announceProvider", handleAnnouncement);
|
|
20522
|
-
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
20523
|
-
return () => {
|
|
20524
|
-
window.removeEventListener(
|
|
20525
|
-
"eip6963:announceProvider",
|
|
20526
|
-
handleAnnouncement
|
|
20527
|
-
);
|
|
20528
|
-
};
|
|
20609
|
+
const store = getEip6963Store();
|
|
20610
|
+
if (!store) return;
|
|
20611
|
+
setEip6963ProviderCount(store.getProviders().length);
|
|
20612
|
+
const unsubscribe = store.subscribe((providers) => {
|
|
20613
|
+
setEip6963ProviderCount(providers.length);
|
|
20614
|
+
});
|
|
20615
|
+
return unsubscribe;
|
|
20529
20616
|
}, []);
|
|
20530
20617
|
React242.useEffect(() => {
|
|
20531
20618
|
if (!wallet || !publishableKey) {
|
|
@@ -20584,7 +20671,7 @@ function BrowserWalletButton({
|
|
|
20584
20671
|
return;
|
|
20585
20672
|
}
|
|
20586
20673
|
if (!chainType || chainType === "solana") {
|
|
20587
|
-
const
|
|
20674
|
+
const anyWin = win;
|
|
20588
20675
|
const trySilentSolana = async (provider, type, name, icon) => {
|
|
20589
20676
|
if (!provider) return false;
|
|
20590
20677
|
if (provider.isConnected && provider.publicKey) {
|
|
@@ -20623,21 +20710,21 @@ function BrowserWalletButton({
|
|
|
20623
20710
|
))
|
|
20624
20711
|
return;
|
|
20625
20712
|
if (await trySilentSolana(
|
|
20626
|
-
|
|
20713
|
+
anyWin.solflare,
|
|
20627
20714
|
"solflare",
|
|
20628
20715
|
"Solflare",
|
|
20629
20716
|
"solflare"
|
|
20630
20717
|
))
|
|
20631
20718
|
return;
|
|
20632
20719
|
if (await trySilentSolana(
|
|
20633
|
-
|
|
20720
|
+
anyWin.backpack,
|
|
20634
20721
|
"backpack",
|
|
20635
20722
|
"Backpack",
|
|
20636
20723
|
"backpack"
|
|
20637
20724
|
))
|
|
20638
20725
|
return;
|
|
20639
20726
|
if (await trySilentSolana(
|
|
20640
|
-
|
|
20727
|
+
anyWin.glow,
|
|
20641
20728
|
"glow",
|
|
20642
20729
|
"Glow",
|
|
20643
20730
|
"glow"
|
|
@@ -20645,19 +20732,14 @@ function BrowserWalletButton({
|
|
|
20645
20732
|
return;
|
|
20646
20733
|
}
|
|
20647
20734
|
if (!chainType || chainType === "ethereum") {
|
|
20648
|
-
const
|
|
20735
|
+
const anyWin = win;
|
|
20649
20736
|
const allProviders = [];
|
|
20650
|
-
const
|
|
20651
|
-
for (const {
|
|
20652
|
-
|
|
20653
|
-
|
|
20654
|
-
|
|
20655
|
-
|
|
20656
|
-
else if (info.rdns.includes("okx")) walletId = "okx";
|
|
20657
|
-
else if (info.rdns.includes("rabby")) walletId = "rabby";
|
|
20658
|
-
else if (info.rdns.includes("trust")) walletId = "trust";
|
|
20659
|
-
else if (info.rdns.includes("rainbow")) walletId = "rainbow";
|
|
20660
|
-
allProviders.push({ provider, walletId });
|
|
20737
|
+
const eip6963 = getEip6963Providers();
|
|
20738
|
+
for (const { provider, walletId } of eip6963) {
|
|
20739
|
+
allProviders.push({
|
|
20740
|
+
provider,
|
|
20741
|
+
walletId: walletId === "unknown" ? "default" : walletId
|
|
20742
|
+
});
|
|
20661
20743
|
}
|
|
20662
20744
|
if (allProviders.length === 0) {
|
|
20663
20745
|
if (win.phantom?.ethereum) {
|
|
@@ -20666,15 +20748,15 @@ function BrowserWalletButton({
|
|
|
20666
20748
|
walletId: "phantom"
|
|
20667
20749
|
});
|
|
20668
20750
|
}
|
|
20669
|
-
if (
|
|
20751
|
+
if (anyWin.okxwallet) {
|
|
20670
20752
|
allProviders.push({
|
|
20671
|
-
provider:
|
|
20753
|
+
provider: anyWin.okxwallet,
|
|
20672
20754
|
walletId: "okx"
|
|
20673
20755
|
});
|
|
20674
20756
|
}
|
|
20675
|
-
if (
|
|
20757
|
+
if (anyWin.coinbaseWalletExtension) {
|
|
20676
20758
|
allProviders.push({
|
|
20677
|
-
provider:
|
|
20759
|
+
provider: anyWin.coinbaseWalletExtension,
|
|
20678
20760
|
walletId: "coinbase"
|
|
20679
20761
|
});
|
|
20680
20762
|
}
|
|
@@ -20698,7 +20780,7 @@ function BrowserWalletButton({
|
|
|
20698
20780
|
});
|
|
20699
20781
|
if (!accounts || accounts.length === 0) continue;
|
|
20700
20782
|
const address = accounts[0];
|
|
20701
|
-
const resolved = identifyEthWallet(provider,
|
|
20783
|
+
const resolved = identifyEthWallet(provider, anyWin, walletId);
|
|
20702
20784
|
if (mounted) {
|
|
20703
20785
|
setWallet({ ...resolved, address });
|
|
20704
20786
|
setIsLoading(false);
|
|
@@ -20740,15 +20822,11 @@ function BrowserWalletButton({
|
|
|
20740
20822
|
solanaProvider.on("disconnect", handleDisconnect);
|
|
20741
20823
|
solanaProvider.on("accountChanged", handleAccountsChanged);
|
|
20742
20824
|
}
|
|
20743
|
-
const anyWin = window;
|
|
20744
20825
|
const ethProviders = [];
|
|
20745
|
-
|
|
20746
|
-
|
|
20747
|
-
|
|
20748
|
-
|
|
20749
|
-
if (provider && !ethProviders.includes(provider)) {
|
|
20750
|
-
ethProviders.push(provider);
|
|
20751
|
-
}
|
|
20826
|
+
for (const { provider } of getEip6963Providers()) {
|
|
20827
|
+
const p = provider;
|
|
20828
|
+
if (p && !ethProviders.includes(p)) {
|
|
20829
|
+
ethProviders.push(p);
|
|
20752
20830
|
}
|
|
20753
20831
|
}
|
|
20754
20832
|
if (window.ethereum && !ethProviders.includes(window.ethereum)) {
|
|
@@ -20850,7 +20928,7 @@ function BrowserWalletButton({
|
|
|
20850
20928
|
if (isLoading) {
|
|
20851
20929
|
return null;
|
|
20852
20930
|
}
|
|
20853
|
-
const hasWalletExtension = (!chainType || chainType === "solana") && (window.phantom?.solana?.isPhantom || window.solana?.isPhantom)
|
|
20931
|
+
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);
|
|
20854
20932
|
if (!onConnectClick && !wallet && !hasWalletExtension) {
|
|
20855
20933
|
return null;
|
|
20856
20934
|
}
|
|
@@ -26358,15 +26436,10 @@ var WALLET_DEFINITIONS = [
|
|
|
26358
26436
|
{ id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
|
|
26359
26437
|
{ id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
|
|
26360
26438
|
];
|
|
26361
|
-
function
|
|
26439
|
+
function getSolanaProviders() {
|
|
26362
26440
|
if (typeof window === "undefined") return {};
|
|
26363
26441
|
const win = window;
|
|
26364
26442
|
return {
|
|
26365
|
-
ethereum: win.ethereum,
|
|
26366
|
-
phantomEthereum: win.phantom?.ethereum,
|
|
26367
|
-
coinbaseEthereum: win.coinbaseWalletExtension,
|
|
26368
|
-
trustEthereum: win.trustwallet?.ethereum,
|
|
26369
|
-
okxEthereum: win.okxwallet,
|
|
26370
26443
|
phantomSolana: win.phantom?.solana,
|
|
26371
26444
|
solflare: win.solflare,
|
|
26372
26445
|
backpack: win.backpack,
|
|
@@ -26374,37 +26447,71 @@ function getWalletProviders() {
|
|
|
26374
26447
|
coinbaseSolana: win.coinbaseSolana || win.coinbaseWalletExtension?.solana
|
|
26375
26448
|
};
|
|
26376
26449
|
}
|
|
26450
|
+
function getLegacyEvmProviders() {
|
|
26451
|
+
if (typeof window === "undefined") return {};
|
|
26452
|
+
const win = window;
|
|
26453
|
+
return {
|
|
26454
|
+
ethereum: win.ethereum,
|
|
26455
|
+
phantomEthereum: win.phantom?.ethereum,
|
|
26456
|
+
coinbaseEthereum: win.coinbaseWalletExtension,
|
|
26457
|
+
trustEthereum: win.trustwallet?.ethereum,
|
|
26458
|
+
okxEthereum: win.okxwallet
|
|
26459
|
+
};
|
|
26460
|
+
}
|
|
26377
26461
|
function detectAvailableWallets(filterChainType) {
|
|
26378
|
-
const
|
|
26462
|
+
const solProviders = getSolanaProviders();
|
|
26463
|
+
const legacyEvm = getLegacyEvmProviders();
|
|
26464
|
+
const eip6963List = getEip6963Providers();
|
|
26379
26465
|
const win = typeof window !== "undefined" ? window : null;
|
|
26466
|
+
const hasEip6963 = (walletId) => eip6963List.some((d) => {
|
|
26467
|
+
const rdns = d.info?.rdns || "";
|
|
26468
|
+
switch (walletId) {
|
|
26469
|
+
case "metamask":
|
|
26470
|
+
return rdns.includes("metamask");
|
|
26471
|
+
case "phantom":
|
|
26472
|
+
return rdns.includes("phantom");
|
|
26473
|
+
case "coinbase":
|
|
26474
|
+
return rdns.includes("coinbase");
|
|
26475
|
+
case "trust":
|
|
26476
|
+
return rdns.includes("trust");
|
|
26477
|
+
case "rainbow":
|
|
26478
|
+
return rdns.includes("rainbow");
|
|
26479
|
+
case "rabby":
|
|
26480
|
+
return rdns.includes("rabby");
|
|
26481
|
+
case "okx":
|
|
26482
|
+
return rdns.includes("okx") || rdns.includes("okex");
|
|
26483
|
+
default:
|
|
26484
|
+
return false;
|
|
26485
|
+
}
|
|
26486
|
+
});
|
|
26380
26487
|
return WALLET_DEFINITIONS.filter((w) => !filterChainType || w.networks.includes(filterChainType)).map((wallet) => {
|
|
26381
26488
|
let isInstalled = false;
|
|
26382
26489
|
const detectedNetworks = [];
|
|
26383
26490
|
switch (wallet.id) {
|
|
26384
26491
|
case "metamask":
|
|
26385
|
-
isInstalled = !!(
|
|
26492
|
+
isInstalled = hasEip6963("metamask") || !!(legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom && !legacyEvm.ethereum?.isRabby && !legacyEvm.ethereum?.isOkxWallet);
|
|
26386
26493
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26387
26494
|
break;
|
|
26388
26495
|
case "phantom":
|
|
26389
|
-
if (
|
|
26496
|
+
if (solProviders.phantomSolana?.isPhantom) {
|
|
26390
26497
|
isInstalled = true;
|
|
26391
26498
|
detectedNetworks.push("solana");
|
|
26392
26499
|
}
|
|
26393
|
-
if (
|
|
26500
|
+
if (hasEip6963("phantom") || legacyEvm.phantomEthereum?.isPhantom) {
|
|
26394
26501
|
isInstalled = true;
|
|
26395
26502
|
detectedNetworks.push("ethereum");
|
|
26396
26503
|
}
|
|
26397
26504
|
break;
|
|
26398
26505
|
case "coinbase":
|
|
26399
|
-
if (
|
|
26506
|
+
if (hasEip6963("coinbase") || legacyEvm.coinbaseEthereum || legacyEvm.ethereum?.isCoinbaseWallet) {
|
|
26400
26507
|
isInstalled = true;
|
|
26401
26508
|
detectedNetworks.push("ethereum");
|
|
26402
26509
|
}
|
|
26403
|
-
if (
|
|
26510
|
+
if (solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana) detectedNetworks.push("solana");
|
|
26404
26511
|
if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
|
|
26405
26512
|
break;
|
|
26406
26513
|
case "trust":
|
|
26407
|
-
if (
|
|
26514
|
+
if (hasEip6963("trust") || legacyEvm.trustEthereum || legacyEvm.ethereum?.isTrust || win?.trustwallet) {
|
|
26408
26515
|
isInstalled = true;
|
|
26409
26516
|
detectedNetworks.push("ethereum");
|
|
26410
26517
|
}
|
|
@@ -26412,27 +26519,27 @@ function detectAvailableWallets(filterChainType) {
|
|
|
26412
26519
|
if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
|
|
26413
26520
|
break;
|
|
26414
26521
|
case "rainbow":
|
|
26415
|
-
isInstalled = !!
|
|
26522
|
+
isInstalled = hasEip6963("rainbow") || !!legacyEvm.ethereum?.isRainbow;
|
|
26416
26523
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26417
26524
|
break;
|
|
26418
26525
|
case "rabby":
|
|
26419
|
-
isInstalled = !!
|
|
26526
|
+
isInstalled = hasEip6963("rabby") || !!legacyEvm.ethereum?.isRabby;
|
|
26420
26527
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26421
26528
|
break;
|
|
26422
26529
|
case "okx":
|
|
26423
|
-
isInstalled = !!(
|
|
26530
|
+
isInstalled = hasEip6963("okx") || !!(legacyEvm.okxEthereum || legacyEvm.ethereum?.isOkxWallet);
|
|
26424
26531
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26425
26532
|
break;
|
|
26426
26533
|
case "solflare":
|
|
26427
|
-
isInstalled = !!
|
|
26534
|
+
isInstalled = !!solProviders.solflare?.isSolflare;
|
|
26428
26535
|
if (isInstalled) detectedNetworks.push("solana");
|
|
26429
26536
|
break;
|
|
26430
26537
|
case "backpack":
|
|
26431
|
-
isInstalled = !!(
|
|
26538
|
+
isInstalled = !!(solProviders.backpack?.isBackpack || win?.backpack);
|
|
26432
26539
|
if (isInstalled) detectedNetworks.push("solana");
|
|
26433
26540
|
break;
|
|
26434
26541
|
case "glow":
|
|
26435
|
-
isInstalled = !!(
|
|
26542
|
+
isInstalled = !!(solProviders.glow?.isGlow || win?.glow);
|
|
26436
26543
|
if (isInstalled) detectedNetworks.push("solana");
|
|
26437
26544
|
break;
|
|
26438
26545
|
}
|
|
@@ -26487,7 +26594,16 @@ function WalletConnect({
|
|
|
26487
26594
|
const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
|
|
26488
26595
|
const [walletError, setWalletError] = React292.useState(null);
|
|
26489
26596
|
const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
|
|
26490
|
-
const
|
|
26597
|
+
const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
|
|
26598
|
+
React292.useEffect(() => {
|
|
26599
|
+
const store = getEip6963Store();
|
|
26600
|
+
if (!store) return;
|
|
26601
|
+
setEip6963ProviderCount(store.getProviders().length);
|
|
26602
|
+
return store.subscribe((providers) => {
|
|
26603
|
+
setEip6963ProviderCount(providers.length);
|
|
26604
|
+
});
|
|
26605
|
+
}, []);
|
|
26606
|
+
const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
|
|
26491
26607
|
const [balances, setBalances] = React292.useState([]);
|
|
26492
26608
|
const [isLoading, setIsLoading] = React292.useState(false);
|
|
26493
26609
|
const [selectedBalance, setSelectedBalance] = React292.useState(null);
|
|
@@ -26546,59 +26662,72 @@ function WalletConnect({
|
|
|
26546
26662
|
setWalletError(null);
|
|
26547
26663
|
setIsWalletConnecting(true);
|
|
26548
26664
|
try {
|
|
26549
|
-
const providers = getWalletProviders();
|
|
26550
26665
|
const win = typeof window !== "undefined" ? window : null;
|
|
26551
26666
|
let connectedInfo;
|
|
26552
26667
|
if (network === "ethereum") {
|
|
26553
|
-
|
|
26554
|
-
|
|
26555
|
-
|
|
26556
|
-
|
|
26557
|
-
|
|
26558
|
-
|
|
26559
|
-
|
|
26560
|
-
|
|
26561
|
-
|
|
26562
|
-
|
|
26563
|
-
|
|
26564
|
-
|
|
26565
|
-
|
|
26566
|
-
|
|
26567
|
-
|
|
26568
|
-
|
|
26569
|
-
|
|
26570
|
-
|
|
26571
|
-
|
|
26572
|
-
|
|
26573
|
-
|
|
26574
|
-
|
|
26575
|
-
|
|
26576
|
-
|
|
26577
|
-
|
|
26668
|
+
const eip6963Match = findProviderByWalletId(wallet.id);
|
|
26669
|
+
let provider = eip6963Match?.provider;
|
|
26670
|
+
if (!provider) {
|
|
26671
|
+
const legacyEvm = getLegacyEvmProviders();
|
|
26672
|
+
switch (wallet.id) {
|
|
26673
|
+
case "metamask":
|
|
26674
|
+
if (legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom) provider = legacyEvm.ethereum;
|
|
26675
|
+
break;
|
|
26676
|
+
case "phantom":
|
|
26677
|
+
provider = legacyEvm.phantomEthereum;
|
|
26678
|
+
break;
|
|
26679
|
+
case "coinbase":
|
|
26680
|
+
provider = legacyEvm.coinbaseEthereum || (legacyEvm.ethereum?.isCoinbaseWallet ? legacyEvm.ethereum : void 0);
|
|
26681
|
+
break;
|
|
26682
|
+
case "trust":
|
|
26683
|
+
provider = legacyEvm.trustEthereum || (legacyEvm.ethereum?.isTrust ? legacyEvm.ethereum : void 0);
|
|
26684
|
+
break;
|
|
26685
|
+
case "rainbow":
|
|
26686
|
+
if (legacyEvm.ethereum?.isRainbow) provider = legacyEvm.ethereum;
|
|
26687
|
+
break;
|
|
26688
|
+
case "rabby":
|
|
26689
|
+
if (legacyEvm.ethereum?.isRabby) provider = legacyEvm.ethereum;
|
|
26690
|
+
break;
|
|
26691
|
+
case "okx":
|
|
26692
|
+
provider = legacyEvm.okxEthereum || (legacyEvm.ethereum?.isOkxWallet ? legacyEvm.ethereum : void 0);
|
|
26693
|
+
break;
|
|
26694
|
+
default:
|
|
26695
|
+
provider = legacyEvm.ethereum;
|
|
26696
|
+
}
|
|
26578
26697
|
}
|
|
26579
26698
|
if (!provider) throw new Error(`${wallet.name} wallet not found. Please install it.`);
|
|
26580
26699
|
const accounts = await provider.request({ method: "eth_requestAccounts" });
|
|
26581
26700
|
if (!accounts?.length) throw new Error("No accounts returned from wallet");
|
|
26582
26701
|
setUserDisconnectedWallet(false);
|
|
26583
|
-
const
|
|
26702
|
+
const walletIdToType = {
|
|
26703
|
+
phantom: "phantom-ethereum",
|
|
26704
|
+
coinbase: "coinbase",
|
|
26705
|
+
trust: "trust",
|
|
26706
|
+
rainbow: "rainbow",
|
|
26707
|
+
rabby: "rabby",
|
|
26708
|
+
okx: "okx",
|
|
26709
|
+
metamask: "metamask"
|
|
26710
|
+
};
|
|
26711
|
+
const walletType = walletIdToType[wallet.id] || "metamask";
|
|
26584
26712
|
connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
|
|
26585
26713
|
} else {
|
|
26714
|
+
const solProviders = getSolanaProviders();
|
|
26586
26715
|
let provider;
|
|
26587
26716
|
switch (wallet.id) {
|
|
26588
26717
|
case "phantom":
|
|
26589
|
-
provider =
|
|
26718
|
+
provider = solProviders.phantomSolana;
|
|
26590
26719
|
break;
|
|
26591
26720
|
case "solflare":
|
|
26592
|
-
provider =
|
|
26721
|
+
provider = solProviders.solflare;
|
|
26593
26722
|
break;
|
|
26594
26723
|
case "backpack":
|
|
26595
|
-
provider =
|
|
26724
|
+
provider = solProviders.backpack || win?.backpack;
|
|
26596
26725
|
break;
|
|
26597
26726
|
case "glow":
|
|
26598
|
-
provider =
|
|
26727
|
+
provider = solProviders.glow || win?.glow;
|
|
26599
26728
|
break;
|
|
26600
26729
|
case "coinbase":
|
|
26601
|
-
provider =
|
|
26730
|
+
provider = solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
|
|
26602
26731
|
break;
|
|
26603
26732
|
case "trust":
|
|
26604
26733
|
provider = win?.trustwallet?.solana;
|
|
@@ -26844,10 +26973,15 @@ function WalletConnect({
|
|
|
26844
26973
|
};
|
|
26845
26974
|
const sendEthereumTransaction = async (token, amountStr) => {
|
|
26846
26975
|
if (!recipientAddress || !/^0x[a-fA-F0-9]{40}$/.test(recipientAddress)) throw new Error(`Invalid recipient address.`);
|
|
26847
|
-
|
|
26848
|
-
|
|
26849
|
-
|
|
26850
|
-
|
|
26976
|
+
const walletIdMap = { "phantom-ethereum": "phantom", coinbase: "coinbase", trust: "trust", okx: "okx", rainbow: "rainbow", rabby: "rabby", metamask: "metamask" };
|
|
26977
|
+
const lookupId = walletIdMap[walletInfo.type] || walletInfo.type;
|
|
26978
|
+
const eip6963Match = findProviderByWalletId(lookupId);
|
|
26979
|
+
let provider = eip6963Match?.provider;
|
|
26980
|
+
if (!provider) {
|
|
26981
|
+
if (walletInfo.type === "phantom-ethereum") provider = window.phantom?.ethereum;
|
|
26982
|
+
else if (walletInfo.type === "coinbase") provider = window.coinbaseWalletExtension || window.ethereum;
|
|
26983
|
+
else provider = window.ethereum;
|
|
26984
|
+
}
|
|
26851
26985
|
if (!provider) throw new Error("Ethereum wallet not found");
|
|
26852
26986
|
const currentChainIdHex = await provider.request({ method: "eth_chainId", params: [] });
|
|
26853
26987
|
if (parseInt(currentChainIdHex, 16).toString() !== token.chain_id) {
|
|
@@ -28681,7 +28815,7 @@ function useExecutions(userId, publishableKey, options) {
|
|
|
28681
28815
|
});
|
|
28682
28816
|
}
|
|
28683
28817
|
var POLL_INTERVAL_MS3 = 2500;
|
|
28684
|
-
var POLL_ENDPOINT_INTERVAL_MS2 =
|
|
28818
|
+
var POLL_ENDPOINT_INTERVAL_MS2 = 5e3;
|
|
28685
28819
|
var CUTOFF_BUFFER_MS2 = 6e4;
|
|
28686
28820
|
function useWithdrawPolling({
|
|
28687
28821
|
userId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unifold/connect-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.60",
|
|
4
4
|
"description": "Unifold Connect React - Complete React SDK with UI components for crypto deposits",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@tanstack/react-query": "^5.90.11",
|
|
29
|
-
"@unifold/
|
|
30
|
-
"@unifold/
|
|
31
|
-
"@unifold/ui-react": "0.1.
|
|
29
|
+
"@unifold/core": "0.1.60",
|
|
30
|
+
"@unifold/react-provider": "0.1.60",
|
|
31
|
+
"@unifold/ui-react": "0.1.60"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/react": "^19.0.0",
|