@unifold/connect-react 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.
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +256 -115
- package/dist/index.mjs +256 -115
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { QueryClient } from '@tanstack/react-query';
|
|
4
4
|
import { ChainType, DepositConfirmationMode, DepositModalInitialScreen, ThemeMode, ThemeConfig, FontConfig, ComponentConfig, WithdrawTransactionInfo, AllowedCountryResult } from '@unifold/ui-react';
|
|
5
5
|
export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode, UseSupportedDepositTokensOptions, WithdrawTransactionInfo, useSupportedDepositTokens } from '@unifold/ui-react';
|
|
6
|
-
import { DepositEvent } from '@unifold/core';
|
|
6
|
+
import { EvmContractCall, DepositEvent } from '@unifold/core';
|
|
7
7
|
export { ActionType, AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, DepositEvent, DepositEventType, DepositQuote, DepositQuoteRequest, DestinationToken, DestinationTokenChain, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, LockedQuoteLimits, LockedQuotePreview, LockedQuotePreviewRequest, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionCreatedData, OnrampSessionCreatedEvent, OnrampSessionRequest, OnrampSessionResponse, PaymentIntent, PaymentIntentDepositAddress, PaymentIntentStatus, PaymentIntentType, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SendSolanaTransactionRequest, SendSolanaTransactionResponse, SourceToken, SourceTokenNetwork, SupportedChain, SupportedDepositTokensResponse, SupportedDestinationTokensResponse, SupportedSourceTokensQuery, SupportedSourceTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, createDepositAddress, createOnrampSession, generatePrefixedKSUID, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, retrievePaymentIntent, sendSolanaTransaction, setApiConfig, useUserIp } from '@unifold/core';
|
|
8
8
|
|
|
9
9
|
interface UnifoldConnectProviderConfig {
|
|
@@ -85,6 +85,13 @@ interface DepositConfig {
|
|
|
85
85
|
destinationTokenAddress: string;
|
|
86
86
|
destinationTokenSymbol: string;
|
|
87
87
|
recipientAddress: string;
|
|
88
|
+
/**
|
|
89
|
+
* Array of contract calls to execute on the destination chain when delivering funds.
|
|
90
|
+
* Each entry specifies a target contract address, hex-encoded data, and optional value in wei (defaults to "0").
|
|
91
|
+
* Only supported when destinationChainType is "ethereum" and
|
|
92
|
+
* destinationChainId is one of: "1", "8453", "42161", "4326".
|
|
93
|
+
*/
|
|
94
|
+
contractCalls?: EvmContractCall[];
|
|
88
95
|
/**
|
|
89
96
|
* Pre-select source token/chain in the Transfer Crypto view.
|
|
90
97
|
* All four props are optional. To match a specific token, provide `chainType` + `chainId` + (`symbol` OR `tokenAddress`).
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { QueryClient } from '@tanstack/react-query';
|
|
4
4
|
import { ChainType, DepositConfirmationMode, DepositModalInitialScreen, ThemeMode, ThemeConfig, FontConfig, ComponentConfig, WithdrawTransactionInfo, AllowedCountryResult } from '@unifold/ui-react';
|
|
5
5
|
export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode, UseSupportedDepositTokensOptions, WithdrawTransactionInfo, useSupportedDepositTokens } from '@unifold/ui-react';
|
|
6
|
-
import { DepositEvent } from '@unifold/core';
|
|
6
|
+
import { EvmContractCall, DepositEvent } from '@unifold/core';
|
|
7
7
|
export { ActionType, AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, DepositEvent, DepositEventType, DepositQuote, DepositQuoteRequest, DestinationToken, DestinationTokenChain, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, LockedQuoteLimits, LockedQuotePreview, LockedQuotePreviewRequest, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionCreatedData, OnrampSessionCreatedEvent, OnrampSessionRequest, OnrampSessionResponse, PaymentIntent, PaymentIntentDepositAddress, PaymentIntentStatus, PaymentIntentType, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SendSolanaTransactionRequest, SendSolanaTransactionResponse, SourceToken, SourceTokenNetwork, SupportedChain, SupportedDepositTokensResponse, SupportedDestinationTokensResponse, SupportedSourceTokensQuery, SupportedSourceTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, createDepositAddress, createOnrampSession, generatePrefixedKSUID, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, retrievePaymentIntent, sendSolanaTransaction, setApiConfig, useUserIp } from '@unifold/core';
|
|
8
8
|
|
|
9
9
|
interface UnifoldConnectProviderConfig {
|
|
@@ -85,6 +85,13 @@ interface DepositConfig {
|
|
|
85
85
|
destinationTokenAddress: string;
|
|
86
86
|
destinationTokenSymbol: string;
|
|
87
87
|
recipientAddress: string;
|
|
88
|
+
/**
|
|
89
|
+
* Array of contract calls to execute on the destination chain when delivering funds.
|
|
90
|
+
* Each entry specifies a target contract address, hex-encoded data, and optional value in wei (defaults to "0").
|
|
91
|
+
* Only supported when destinationChainType is "ethereum" and
|
|
92
|
+
* destinationChainId is one of: "1", "8453", "42161", "4326".
|
|
93
|
+
*/
|
|
94
|
+
contractCalls?: EvmContractCall[];
|
|
88
95
|
/**
|
|
89
96
|
* Pre-select source token/chain in the Transfer Crypto view.
|
|
90
97
|
* All four props are optional. To match a specific token, provide `chainType` + `chainId` + (`symbol` OR `tokenAddress`).
|
package/dist/index.js
CHANGED
|
@@ -6220,6 +6220,7 @@ async function createDepositAddress(overrides, publishableKey) {
|
|
|
6220
6220
|
recipient_address: overrides?.recipient_address || DEFAULT_CONFIG.recipientAddress || "0x309a4154a2CD4153Da886E780890C9cb5161553C",
|
|
6221
6221
|
...overrides?.action_type ? { action_type: overrides.action_type } : {},
|
|
6222
6222
|
...overrides?.source_chain_type ? { source_chain_type: overrides.source_chain_type } : {},
|
|
6223
|
+
...overrides?.contract_calls ? { contract_calls: overrides.contract_calls } : {},
|
|
6223
6224
|
client_metadata: overrides?.client_metadata || {}
|
|
6224
6225
|
};
|
|
6225
6226
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
@@ -7382,6 +7383,62 @@ var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
|
7382
7383
|
var React112 = __toESM(require("react"), 1);
|
|
7383
7384
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
7384
7385
|
var React242 = __toESM(require("react"), 1);
|
|
7386
|
+
|
|
7387
|
+
// ../../node_modules/.pnpm/mipd@0.0.7_typescript@5.9.3/node_modules/mipd/dist/esm/utils.js
|
|
7388
|
+
function requestProviders(listener) {
|
|
7389
|
+
if (typeof window === "undefined")
|
|
7390
|
+
return;
|
|
7391
|
+
const handler = (event) => listener(event.detail);
|
|
7392
|
+
window.addEventListener("eip6963:announceProvider", handler);
|
|
7393
|
+
window.dispatchEvent(new CustomEvent("eip6963:requestProvider"));
|
|
7394
|
+
return () => window.removeEventListener("eip6963:announceProvider", handler);
|
|
7395
|
+
}
|
|
7396
|
+
|
|
7397
|
+
// ../../node_modules/.pnpm/mipd@0.0.7_typescript@5.9.3/node_modules/mipd/dist/esm/store.js
|
|
7398
|
+
function createStore() {
|
|
7399
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
7400
|
+
let providerDetails = [];
|
|
7401
|
+
const request = () => requestProviders((providerDetail) => {
|
|
7402
|
+
if (providerDetails.some(({ info }) => info.uuid === providerDetail.info.uuid))
|
|
7403
|
+
return;
|
|
7404
|
+
providerDetails = [...providerDetails, providerDetail];
|
|
7405
|
+
listeners.forEach((listener) => listener(providerDetails, { added: [providerDetail] }));
|
|
7406
|
+
});
|
|
7407
|
+
let unwatch = request();
|
|
7408
|
+
return {
|
|
7409
|
+
_listeners() {
|
|
7410
|
+
return listeners;
|
|
7411
|
+
},
|
|
7412
|
+
clear() {
|
|
7413
|
+
listeners.forEach((listener) => listener([], { removed: [...providerDetails] }));
|
|
7414
|
+
providerDetails = [];
|
|
7415
|
+
},
|
|
7416
|
+
destroy() {
|
|
7417
|
+
this.clear();
|
|
7418
|
+
listeners.clear();
|
|
7419
|
+
unwatch?.();
|
|
7420
|
+
},
|
|
7421
|
+
findProvider({ rdns }) {
|
|
7422
|
+
return providerDetails.find((providerDetail) => providerDetail.info.rdns === rdns);
|
|
7423
|
+
},
|
|
7424
|
+
getProviders() {
|
|
7425
|
+
return providerDetails;
|
|
7426
|
+
},
|
|
7427
|
+
reset() {
|
|
7428
|
+
this.clear();
|
|
7429
|
+
unwatch?.();
|
|
7430
|
+
unwatch = request();
|
|
7431
|
+
},
|
|
7432
|
+
subscribe(listener, { emitImmediately } = {}) {
|
|
7433
|
+
listeners.add(listener);
|
|
7434
|
+
if (emitImmediately)
|
|
7435
|
+
listener(providerDetails, { added: providerDetails });
|
|
7436
|
+
return () => listeners.delete(listener);
|
|
7437
|
+
}
|
|
7438
|
+
};
|
|
7439
|
+
}
|
|
7440
|
+
|
|
7441
|
+
// ../ui-react/dist/index.mjs
|
|
7385
7442
|
var React122 = __toESM(require("react"), 1);
|
|
7386
7443
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
7387
7444
|
var React132 = __toESM(require("react"), 1);
|
|
@@ -14005,6 +14062,7 @@ function useDepositAddress(params) {
|
|
|
14005
14062
|
destinationChainId,
|
|
14006
14063
|
destinationTokenAddress,
|
|
14007
14064
|
actionType,
|
|
14065
|
+
contractCalls,
|
|
14008
14066
|
enabled = true
|
|
14009
14067
|
} = params;
|
|
14010
14068
|
return (0, import_react_query3.useQuery)({
|
|
@@ -14017,6 +14075,7 @@ function useDepositAddress(params) {
|
|
|
14017
14075
|
destinationChainId ?? null,
|
|
14018
14076
|
destinationTokenAddress ?? null,
|
|
14019
14077
|
actionType ?? null,
|
|
14078
|
+
contractCalls ?? null,
|
|
14020
14079
|
publishableKey
|
|
14021
14080
|
],
|
|
14022
14081
|
queryFn: () => createDepositAddress(
|
|
@@ -14026,7 +14085,8 @@ function useDepositAddress(params) {
|
|
|
14026
14085
|
destination_chain_type: destinationChainType,
|
|
14027
14086
|
destination_chain_id: destinationChainId,
|
|
14028
14087
|
destination_token_address: destinationTokenAddress,
|
|
14029
|
-
action_type: actionType
|
|
14088
|
+
action_type: actionType,
|
|
14089
|
+
contract_calls: contractCalls
|
|
14030
14090
|
},
|
|
14031
14091
|
publishableKey
|
|
14032
14092
|
),
|
|
@@ -14828,7 +14888,7 @@ function interpolate(template, params) {
|
|
|
14828
14888
|
}
|
|
14829
14889
|
var DEPOSIT_CONFIRM_DELAY_MS = 5e3;
|
|
14830
14890
|
var POLL_INTERVAL_MS = 2500;
|
|
14831
|
-
var POLL_ENDPOINT_INTERVAL_MS =
|
|
14891
|
+
var POLL_ENDPOINT_INTERVAL_MS = 5e3;
|
|
14832
14892
|
var CUTOFF_BUFFER_MS = 6e4;
|
|
14833
14893
|
function useDepositPolling({
|
|
14834
14894
|
userId,
|
|
@@ -18470,6 +18530,53 @@ function CashAppButton({
|
|
|
18470
18530
|
}
|
|
18471
18531
|
);
|
|
18472
18532
|
}
|
|
18533
|
+
var _store = null;
|
|
18534
|
+
function getEip6963Store() {
|
|
18535
|
+
if (typeof window === "undefined") return null;
|
|
18536
|
+
if (!_store) {
|
|
18537
|
+
_store = createStore();
|
|
18538
|
+
}
|
|
18539
|
+
return _store;
|
|
18540
|
+
}
|
|
18541
|
+
var RDNS_TO_WALLET_ID = {
|
|
18542
|
+
"io.metamask": "metamask",
|
|
18543
|
+
"io.metamask.flask": "metamask",
|
|
18544
|
+
"io.metamask.mmi": "metamask",
|
|
18545
|
+
"app.phantom": "phantom",
|
|
18546
|
+
"com.coinbase.wallet": "coinbase",
|
|
18547
|
+
"com.okex.wallet": "okx",
|
|
18548
|
+
"io.rabby": "rabby",
|
|
18549
|
+
"com.trustwallet.app": "trust",
|
|
18550
|
+
"me.rainbow": "rainbow"
|
|
18551
|
+
};
|
|
18552
|
+
function rdnsToWalletId(rdns) {
|
|
18553
|
+
if (RDNS_TO_WALLET_ID[rdns]) return RDNS_TO_WALLET_ID[rdns];
|
|
18554
|
+
if (rdns.includes("metamask")) return "metamask";
|
|
18555
|
+
if (rdns.includes("phantom")) return "phantom";
|
|
18556
|
+
if (rdns.includes("coinbase")) return "coinbase";
|
|
18557
|
+
if (rdns.includes("okx") || rdns.includes("okex")) return "okx";
|
|
18558
|
+
if (rdns.includes("rabby")) return "rabby";
|
|
18559
|
+
if (rdns.includes("trust")) return "trust";
|
|
18560
|
+
if (rdns.includes("rainbow")) return "rainbow";
|
|
18561
|
+
return "unknown";
|
|
18562
|
+
}
|
|
18563
|
+
function getEip6963Providers() {
|
|
18564
|
+
const store = getEip6963Store();
|
|
18565
|
+
if (!store) return [];
|
|
18566
|
+
return store.getProviders().map((detail) => ({
|
|
18567
|
+
walletId: rdnsToWalletId(detail.info.rdns),
|
|
18568
|
+
provider: detail.provider,
|
|
18569
|
+
info: detail.info
|
|
18570
|
+
}));
|
|
18571
|
+
}
|
|
18572
|
+
function findProviderByWalletId(walletId) {
|
|
18573
|
+
return getEip6963Providers().find((p) => p.walletId === walletId);
|
|
18574
|
+
}
|
|
18575
|
+
function collectAllEip6963EthProviders() {
|
|
18576
|
+
const store = getEip6963Store();
|
|
18577
|
+
if (!store) return [];
|
|
18578
|
+
return store.getProviders().map((d) => d.provider);
|
|
18579
|
+
}
|
|
18473
18580
|
var SOLANA_DISCONNECT_TYPES = [
|
|
18474
18581
|
"phantom-solana",
|
|
18475
18582
|
"solflare",
|
|
@@ -18509,8 +18616,9 @@ function collectEthereumProvidersForDisconnect(win) {
|
|
|
18509
18616
|
out.push(p);
|
|
18510
18617
|
}
|
|
18511
18618
|
};
|
|
18512
|
-
const
|
|
18513
|
-
|
|
18619
|
+
for (const p of collectAllEip6963EthProviders()) {
|
|
18620
|
+
add(p);
|
|
18621
|
+
}
|
|
18514
18622
|
add(win.ethereum);
|
|
18515
18623
|
add(
|
|
18516
18624
|
win.phantom?.ethereum
|
|
@@ -20516,30 +20624,13 @@ function BrowserWalletButton({
|
|
|
20516
20624
|
}, []);
|
|
20517
20625
|
const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
|
|
20518
20626
|
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
|
-
};
|
|
20627
|
+
const store = getEip6963Store();
|
|
20628
|
+
if (!store) return;
|
|
20629
|
+
setEip6963ProviderCount(store.getProviders().length);
|
|
20630
|
+
const unsubscribe = store.subscribe((providers) => {
|
|
20631
|
+
setEip6963ProviderCount(providers.length);
|
|
20632
|
+
});
|
|
20633
|
+
return unsubscribe;
|
|
20543
20634
|
}, []);
|
|
20544
20635
|
React242.useEffect(() => {
|
|
20545
20636
|
if (!wallet || !publishableKey) {
|
|
@@ -20598,7 +20689,7 @@ function BrowserWalletButton({
|
|
|
20598
20689
|
return;
|
|
20599
20690
|
}
|
|
20600
20691
|
if (!chainType || chainType === "solana") {
|
|
20601
|
-
const
|
|
20692
|
+
const anyWin = win;
|
|
20602
20693
|
const trySilentSolana = async (provider, type, name, icon) => {
|
|
20603
20694
|
if (!provider) return false;
|
|
20604
20695
|
if (provider.isConnected && provider.publicKey) {
|
|
@@ -20637,21 +20728,21 @@ function BrowserWalletButton({
|
|
|
20637
20728
|
))
|
|
20638
20729
|
return;
|
|
20639
20730
|
if (await trySilentSolana(
|
|
20640
|
-
|
|
20731
|
+
anyWin.solflare,
|
|
20641
20732
|
"solflare",
|
|
20642
20733
|
"Solflare",
|
|
20643
20734
|
"solflare"
|
|
20644
20735
|
))
|
|
20645
20736
|
return;
|
|
20646
20737
|
if (await trySilentSolana(
|
|
20647
|
-
|
|
20738
|
+
anyWin.backpack,
|
|
20648
20739
|
"backpack",
|
|
20649
20740
|
"Backpack",
|
|
20650
20741
|
"backpack"
|
|
20651
20742
|
))
|
|
20652
20743
|
return;
|
|
20653
20744
|
if (await trySilentSolana(
|
|
20654
|
-
|
|
20745
|
+
anyWin.glow,
|
|
20655
20746
|
"glow",
|
|
20656
20747
|
"Glow",
|
|
20657
20748
|
"glow"
|
|
@@ -20659,19 +20750,14 @@ function BrowserWalletButton({
|
|
|
20659
20750
|
return;
|
|
20660
20751
|
}
|
|
20661
20752
|
if (!chainType || chainType === "ethereum") {
|
|
20662
|
-
const
|
|
20753
|
+
const anyWin = win;
|
|
20663
20754
|
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 });
|
|
20755
|
+
const eip6963 = getEip6963Providers();
|
|
20756
|
+
for (const { provider, walletId } of eip6963) {
|
|
20757
|
+
allProviders.push({
|
|
20758
|
+
provider,
|
|
20759
|
+
walletId: walletId === "unknown" ? "default" : walletId
|
|
20760
|
+
});
|
|
20675
20761
|
}
|
|
20676
20762
|
if (allProviders.length === 0) {
|
|
20677
20763
|
if (win.phantom?.ethereum) {
|
|
@@ -20680,15 +20766,15 @@ function BrowserWalletButton({
|
|
|
20680
20766
|
walletId: "phantom"
|
|
20681
20767
|
});
|
|
20682
20768
|
}
|
|
20683
|
-
if (
|
|
20769
|
+
if (anyWin.okxwallet) {
|
|
20684
20770
|
allProviders.push({
|
|
20685
|
-
provider:
|
|
20771
|
+
provider: anyWin.okxwallet,
|
|
20686
20772
|
walletId: "okx"
|
|
20687
20773
|
});
|
|
20688
20774
|
}
|
|
20689
|
-
if (
|
|
20775
|
+
if (anyWin.coinbaseWalletExtension) {
|
|
20690
20776
|
allProviders.push({
|
|
20691
|
-
provider:
|
|
20777
|
+
provider: anyWin.coinbaseWalletExtension,
|
|
20692
20778
|
walletId: "coinbase"
|
|
20693
20779
|
});
|
|
20694
20780
|
}
|
|
@@ -20712,7 +20798,7 @@ function BrowserWalletButton({
|
|
|
20712
20798
|
});
|
|
20713
20799
|
if (!accounts || accounts.length === 0) continue;
|
|
20714
20800
|
const address = accounts[0];
|
|
20715
|
-
const resolved = identifyEthWallet(provider,
|
|
20801
|
+
const resolved = identifyEthWallet(provider, anyWin, walletId);
|
|
20716
20802
|
if (mounted) {
|
|
20717
20803
|
setWallet({ ...resolved, address });
|
|
20718
20804
|
setIsLoading(false);
|
|
@@ -20754,15 +20840,11 @@ function BrowserWalletButton({
|
|
|
20754
20840
|
solanaProvider.on("disconnect", handleDisconnect);
|
|
20755
20841
|
solanaProvider.on("accountChanged", handleAccountsChanged);
|
|
20756
20842
|
}
|
|
20757
|
-
const anyWin = window;
|
|
20758
20843
|
const ethProviders = [];
|
|
20759
|
-
|
|
20760
|
-
|
|
20761
|
-
|
|
20762
|
-
|
|
20763
|
-
if (provider && !ethProviders.includes(provider)) {
|
|
20764
|
-
ethProviders.push(provider);
|
|
20765
|
-
}
|
|
20844
|
+
for (const { provider } of getEip6963Providers()) {
|
|
20845
|
+
const p = provider;
|
|
20846
|
+
if (p && !ethProviders.includes(p)) {
|
|
20847
|
+
ethProviders.push(p);
|
|
20766
20848
|
}
|
|
20767
20849
|
}
|
|
20768
20850
|
if (window.ethereum && !ethProviders.includes(window.ethereum)) {
|
|
@@ -20864,7 +20946,7 @@ function BrowserWalletButton({
|
|
|
20864
20946
|
if (isLoading) {
|
|
20865
20947
|
return null;
|
|
20866
20948
|
}
|
|
20867
|
-
const hasWalletExtension = (!chainType || chainType === "solana") && (window.phantom?.solana?.isPhantom || window.solana?.isPhantom)
|
|
20949
|
+
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
20950
|
if (!onConnectClick && !wallet && !hasWalletExtension) {
|
|
20869
20951
|
return null;
|
|
20870
20952
|
}
|
|
@@ -26372,15 +26454,10 @@ var WALLET_DEFINITIONS = [
|
|
|
26372
26454
|
{ id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
|
|
26373
26455
|
{ id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
|
|
26374
26456
|
];
|
|
26375
|
-
function
|
|
26457
|
+
function getSolanaProviders() {
|
|
26376
26458
|
if (typeof window === "undefined") return {};
|
|
26377
26459
|
const win = window;
|
|
26378
26460
|
return {
|
|
26379
|
-
ethereum: win.ethereum,
|
|
26380
|
-
phantomEthereum: win.phantom?.ethereum,
|
|
26381
|
-
coinbaseEthereum: win.coinbaseWalletExtension,
|
|
26382
|
-
trustEthereum: win.trustwallet?.ethereum,
|
|
26383
|
-
okxEthereum: win.okxwallet,
|
|
26384
26461
|
phantomSolana: win.phantom?.solana,
|
|
26385
26462
|
solflare: win.solflare,
|
|
26386
26463
|
backpack: win.backpack,
|
|
@@ -26388,37 +26465,71 @@ function getWalletProviders() {
|
|
|
26388
26465
|
coinbaseSolana: win.coinbaseSolana || win.coinbaseWalletExtension?.solana
|
|
26389
26466
|
};
|
|
26390
26467
|
}
|
|
26468
|
+
function getLegacyEvmProviders() {
|
|
26469
|
+
if (typeof window === "undefined") return {};
|
|
26470
|
+
const win = window;
|
|
26471
|
+
return {
|
|
26472
|
+
ethereum: win.ethereum,
|
|
26473
|
+
phantomEthereum: win.phantom?.ethereum,
|
|
26474
|
+
coinbaseEthereum: win.coinbaseWalletExtension,
|
|
26475
|
+
trustEthereum: win.trustwallet?.ethereum,
|
|
26476
|
+
okxEthereum: win.okxwallet
|
|
26477
|
+
};
|
|
26478
|
+
}
|
|
26391
26479
|
function detectAvailableWallets(filterChainType) {
|
|
26392
|
-
const
|
|
26480
|
+
const solProviders = getSolanaProviders();
|
|
26481
|
+
const legacyEvm = getLegacyEvmProviders();
|
|
26482
|
+
const eip6963List = getEip6963Providers();
|
|
26393
26483
|
const win = typeof window !== "undefined" ? window : null;
|
|
26484
|
+
const hasEip6963 = (walletId) => eip6963List.some((d) => {
|
|
26485
|
+
const rdns = d.info?.rdns || "";
|
|
26486
|
+
switch (walletId) {
|
|
26487
|
+
case "metamask":
|
|
26488
|
+
return rdns.includes("metamask");
|
|
26489
|
+
case "phantom":
|
|
26490
|
+
return rdns.includes("phantom");
|
|
26491
|
+
case "coinbase":
|
|
26492
|
+
return rdns.includes("coinbase");
|
|
26493
|
+
case "trust":
|
|
26494
|
+
return rdns.includes("trust");
|
|
26495
|
+
case "rainbow":
|
|
26496
|
+
return rdns.includes("rainbow");
|
|
26497
|
+
case "rabby":
|
|
26498
|
+
return rdns.includes("rabby");
|
|
26499
|
+
case "okx":
|
|
26500
|
+
return rdns.includes("okx") || rdns.includes("okex");
|
|
26501
|
+
default:
|
|
26502
|
+
return false;
|
|
26503
|
+
}
|
|
26504
|
+
});
|
|
26394
26505
|
return WALLET_DEFINITIONS.filter((w) => !filterChainType || w.networks.includes(filterChainType)).map((wallet) => {
|
|
26395
26506
|
let isInstalled = false;
|
|
26396
26507
|
const detectedNetworks = [];
|
|
26397
26508
|
switch (wallet.id) {
|
|
26398
26509
|
case "metamask":
|
|
26399
|
-
isInstalled = !!(
|
|
26510
|
+
isInstalled = hasEip6963("metamask") || !!(legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom && !legacyEvm.ethereum?.isRabby && !legacyEvm.ethereum?.isOkxWallet);
|
|
26400
26511
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26401
26512
|
break;
|
|
26402
26513
|
case "phantom":
|
|
26403
|
-
if (
|
|
26514
|
+
if (solProviders.phantomSolana?.isPhantom) {
|
|
26404
26515
|
isInstalled = true;
|
|
26405
26516
|
detectedNetworks.push("solana");
|
|
26406
26517
|
}
|
|
26407
|
-
if (
|
|
26518
|
+
if (hasEip6963("phantom") || legacyEvm.phantomEthereum?.isPhantom) {
|
|
26408
26519
|
isInstalled = true;
|
|
26409
26520
|
detectedNetworks.push("ethereum");
|
|
26410
26521
|
}
|
|
26411
26522
|
break;
|
|
26412
26523
|
case "coinbase":
|
|
26413
|
-
if (
|
|
26524
|
+
if (hasEip6963("coinbase") || legacyEvm.coinbaseEthereum || legacyEvm.ethereum?.isCoinbaseWallet) {
|
|
26414
26525
|
isInstalled = true;
|
|
26415
26526
|
detectedNetworks.push("ethereum");
|
|
26416
26527
|
}
|
|
26417
|
-
if (
|
|
26528
|
+
if (solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana) detectedNetworks.push("solana");
|
|
26418
26529
|
if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
|
|
26419
26530
|
break;
|
|
26420
26531
|
case "trust":
|
|
26421
|
-
if (
|
|
26532
|
+
if (hasEip6963("trust") || legacyEvm.trustEthereum || legacyEvm.ethereum?.isTrust || win?.trustwallet) {
|
|
26422
26533
|
isInstalled = true;
|
|
26423
26534
|
detectedNetworks.push("ethereum");
|
|
26424
26535
|
}
|
|
@@ -26426,27 +26537,27 @@ function detectAvailableWallets(filterChainType) {
|
|
|
26426
26537
|
if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
|
|
26427
26538
|
break;
|
|
26428
26539
|
case "rainbow":
|
|
26429
|
-
isInstalled = !!
|
|
26540
|
+
isInstalled = hasEip6963("rainbow") || !!legacyEvm.ethereum?.isRainbow;
|
|
26430
26541
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26431
26542
|
break;
|
|
26432
26543
|
case "rabby":
|
|
26433
|
-
isInstalled = !!
|
|
26544
|
+
isInstalled = hasEip6963("rabby") || !!legacyEvm.ethereum?.isRabby;
|
|
26434
26545
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26435
26546
|
break;
|
|
26436
26547
|
case "okx":
|
|
26437
|
-
isInstalled = !!(
|
|
26548
|
+
isInstalled = hasEip6963("okx") || !!(legacyEvm.okxEthereum || legacyEvm.ethereum?.isOkxWallet);
|
|
26438
26549
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26439
26550
|
break;
|
|
26440
26551
|
case "solflare":
|
|
26441
|
-
isInstalled = !!
|
|
26552
|
+
isInstalled = !!solProviders.solflare?.isSolflare;
|
|
26442
26553
|
if (isInstalled) detectedNetworks.push("solana");
|
|
26443
26554
|
break;
|
|
26444
26555
|
case "backpack":
|
|
26445
|
-
isInstalled = !!(
|
|
26556
|
+
isInstalled = !!(solProviders.backpack?.isBackpack || win?.backpack);
|
|
26446
26557
|
if (isInstalled) detectedNetworks.push("solana");
|
|
26447
26558
|
break;
|
|
26448
26559
|
case "glow":
|
|
26449
|
-
isInstalled = !!(
|
|
26560
|
+
isInstalled = !!(solProviders.glow?.isGlow || win?.glow);
|
|
26450
26561
|
if (isInstalled) detectedNetworks.push("solana");
|
|
26451
26562
|
break;
|
|
26452
26563
|
}
|
|
@@ -26501,7 +26612,16 @@ function WalletConnect({
|
|
|
26501
26612
|
const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
|
|
26502
26613
|
const [walletError, setWalletError] = React292.useState(null);
|
|
26503
26614
|
const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
|
|
26504
|
-
const
|
|
26615
|
+
const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
|
|
26616
|
+
React292.useEffect(() => {
|
|
26617
|
+
const store = getEip6963Store();
|
|
26618
|
+
if (!store) return;
|
|
26619
|
+
setEip6963ProviderCount(store.getProviders().length);
|
|
26620
|
+
return store.subscribe((providers) => {
|
|
26621
|
+
setEip6963ProviderCount(providers.length);
|
|
26622
|
+
});
|
|
26623
|
+
}, []);
|
|
26624
|
+
const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
|
|
26505
26625
|
const [balances, setBalances] = React292.useState([]);
|
|
26506
26626
|
const [isLoading, setIsLoading] = React292.useState(false);
|
|
26507
26627
|
const [selectedBalance, setSelectedBalance] = React292.useState(null);
|
|
@@ -26560,59 +26680,72 @@ function WalletConnect({
|
|
|
26560
26680
|
setWalletError(null);
|
|
26561
26681
|
setIsWalletConnecting(true);
|
|
26562
26682
|
try {
|
|
26563
|
-
const providers = getWalletProviders();
|
|
26564
26683
|
const win = typeof window !== "undefined" ? window : null;
|
|
26565
26684
|
let connectedInfo;
|
|
26566
26685
|
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
|
-
|
|
26686
|
+
const eip6963Match = findProviderByWalletId(wallet.id);
|
|
26687
|
+
let provider = eip6963Match?.provider;
|
|
26688
|
+
if (!provider) {
|
|
26689
|
+
const legacyEvm = getLegacyEvmProviders();
|
|
26690
|
+
switch (wallet.id) {
|
|
26691
|
+
case "metamask":
|
|
26692
|
+
if (legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom) provider = legacyEvm.ethereum;
|
|
26693
|
+
break;
|
|
26694
|
+
case "phantom":
|
|
26695
|
+
provider = legacyEvm.phantomEthereum;
|
|
26696
|
+
break;
|
|
26697
|
+
case "coinbase":
|
|
26698
|
+
provider = legacyEvm.coinbaseEthereum || (legacyEvm.ethereum?.isCoinbaseWallet ? legacyEvm.ethereum : void 0);
|
|
26699
|
+
break;
|
|
26700
|
+
case "trust":
|
|
26701
|
+
provider = legacyEvm.trustEthereum || (legacyEvm.ethereum?.isTrust ? legacyEvm.ethereum : void 0);
|
|
26702
|
+
break;
|
|
26703
|
+
case "rainbow":
|
|
26704
|
+
if (legacyEvm.ethereum?.isRainbow) provider = legacyEvm.ethereum;
|
|
26705
|
+
break;
|
|
26706
|
+
case "rabby":
|
|
26707
|
+
if (legacyEvm.ethereum?.isRabby) provider = legacyEvm.ethereum;
|
|
26708
|
+
break;
|
|
26709
|
+
case "okx":
|
|
26710
|
+
provider = legacyEvm.okxEthereum || (legacyEvm.ethereum?.isOkxWallet ? legacyEvm.ethereum : void 0);
|
|
26711
|
+
break;
|
|
26712
|
+
default:
|
|
26713
|
+
provider = legacyEvm.ethereum;
|
|
26714
|
+
}
|
|
26592
26715
|
}
|
|
26593
26716
|
if (!provider) throw new Error(`${wallet.name} wallet not found. Please install it.`);
|
|
26594
26717
|
const accounts = await provider.request({ method: "eth_requestAccounts" });
|
|
26595
26718
|
if (!accounts?.length) throw new Error("No accounts returned from wallet");
|
|
26596
26719
|
setUserDisconnectedWallet(false);
|
|
26597
|
-
const
|
|
26720
|
+
const walletIdToType = {
|
|
26721
|
+
phantom: "phantom-ethereum",
|
|
26722
|
+
coinbase: "coinbase",
|
|
26723
|
+
trust: "trust",
|
|
26724
|
+
rainbow: "rainbow",
|
|
26725
|
+
rabby: "rabby",
|
|
26726
|
+
okx: "okx",
|
|
26727
|
+
metamask: "metamask"
|
|
26728
|
+
};
|
|
26729
|
+
const walletType = walletIdToType[wallet.id] || "metamask";
|
|
26598
26730
|
connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
|
|
26599
26731
|
} else {
|
|
26732
|
+
const solProviders = getSolanaProviders();
|
|
26600
26733
|
let provider;
|
|
26601
26734
|
switch (wallet.id) {
|
|
26602
26735
|
case "phantom":
|
|
26603
|
-
provider =
|
|
26736
|
+
provider = solProviders.phantomSolana;
|
|
26604
26737
|
break;
|
|
26605
26738
|
case "solflare":
|
|
26606
|
-
provider =
|
|
26739
|
+
provider = solProviders.solflare;
|
|
26607
26740
|
break;
|
|
26608
26741
|
case "backpack":
|
|
26609
|
-
provider =
|
|
26742
|
+
provider = solProviders.backpack || win?.backpack;
|
|
26610
26743
|
break;
|
|
26611
26744
|
case "glow":
|
|
26612
|
-
provider =
|
|
26745
|
+
provider = solProviders.glow || win?.glow;
|
|
26613
26746
|
break;
|
|
26614
26747
|
case "coinbase":
|
|
26615
|
-
provider =
|
|
26748
|
+
provider = solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
|
|
26616
26749
|
break;
|
|
26617
26750
|
case "trust":
|
|
26618
26751
|
provider = win?.trustwallet?.solana;
|
|
@@ -26858,10 +26991,15 @@ function WalletConnect({
|
|
|
26858
26991
|
};
|
|
26859
26992
|
const sendEthereumTransaction = async (token, amountStr) => {
|
|
26860
26993
|
if (!recipientAddress || !/^0x[a-fA-F0-9]{40}$/.test(recipientAddress)) throw new Error(`Invalid recipient address.`);
|
|
26861
|
-
|
|
26862
|
-
|
|
26863
|
-
|
|
26864
|
-
|
|
26994
|
+
const walletIdMap = { "phantom-ethereum": "phantom", coinbase: "coinbase", trust: "trust", okx: "okx", rainbow: "rainbow", rabby: "rabby", metamask: "metamask" };
|
|
26995
|
+
const lookupId = walletIdMap[walletInfo.type] || walletInfo.type;
|
|
26996
|
+
const eip6963Match = findProviderByWalletId(lookupId);
|
|
26997
|
+
let provider = eip6963Match?.provider;
|
|
26998
|
+
if (!provider) {
|
|
26999
|
+
if (walletInfo.type === "phantom-ethereum") provider = window.phantom?.ethereum;
|
|
27000
|
+
else if (walletInfo.type === "coinbase") provider = window.coinbaseWalletExtension || window.ethereum;
|
|
27001
|
+
else provider = window.ethereum;
|
|
27002
|
+
}
|
|
26865
27003
|
if (!provider) throw new Error("Ethereum wallet not found");
|
|
26866
27004
|
const currentChainIdHex = await provider.request({ method: "eth_chainId", params: [] });
|
|
26867
27005
|
if (parseInt(currentChainIdHex, 16).toString() !== token.chain_id) {
|
|
@@ -27089,6 +27227,7 @@ function DepositModal({
|
|
|
27089
27227
|
destinationChainType,
|
|
27090
27228
|
destinationChainId,
|
|
27091
27229
|
destinationTokenAddress,
|
|
27230
|
+
contractCalls,
|
|
27092
27231
|
defaultSourceChainType,
|
|
27093
27232
|
defaultSourceChainId,
|
|
27094
27233
|
defaultSourceTokenAddress,
|
|
@@ -27215,6 +27354,7 @@ function DepositModal({
|
|
|
27215
27354
|
destinationChainType,
|
|
27216
27355
|
destinationChainId,
|
|
27217
27356
|
destinationTokenAddress,
|
|
27357
|
+
contractCalls,
|
|
27218
27358
|
enabled: open
|
|
27219
27359
|
// Only fetch when modal is open
|
|
27220
27360
|
});
|
|
@@ -28695,7 +28835,7 @@ function useExecutions(userId, publishableKey, options) {
|
|
|
28695
28835
|
});
|
|
28696
28836
|
}
|
|
28697
28837
|
var POLL_INTERVAL_MS3 = 2500;
|
|
28698
|
-
var POLL_ENDPOINT_INTERVAL_MS2 =
|
|
28838
|
+
var POLL_ENDPOINT_INTERVAL_MS2 = 5e3;
|
|
28699
28839
|
var CUTOFF_BUFFER_MS2 = 6e4;
|
|
28700
28840
|
function useWithdrawPolling({
|
|
28701
28841
|
userId,
|
|
@@ -30548,6 +30688,7 @@ function UnifoldProvider2({
|
|
|
30548
30688
|
destinationChainType: depositConfig.destinationChainType,
|
|
30549
30689
|
destinationChainId: depositConfig.destinationChainId,
|
|
30550
30690
|
destinationTokenAddress: depositConfig.destinationTokenAddress,
|
|
30691
|
+
contractCalls: depositConfig.contractCalls,
|
|
30551
30692
|
defaultSourceChainType: depositConfig.defaultSourceChainType,
|
|
30552
30693
|
defaultSourceChainId: depositConfig.defaultSourceChainId,
|
|
30553
30694
|
defaultSourceTokenAddress: depositConfig.defaultSourceTokenAddress,
|
package/dist/index.mjs
CHANGED
|
@@ -6193,6 +6193,7 @@ async function createDepositAddress(overrides, publishableKey) {
|
|
|
6193
6193
|
recipient_address: overrides?.recipient_address || DEFAULT_CONFIG.recipientAddress || "0x309a4154a2CD4153Da886E780890C9cb5161553C",
|
|
6194
6194
|
...overrides?.action_type ? { action_type: overrides.action_type } : {},
|
|
6195
6195
|
...overrides?.source_chain_type ? { source_chain_type: overrides.source_chain_type } : {},
|
|
6196
|
+
...overrides?.contract_calls ? { contract_calls: overrides.contract_calls } : {},
|
|
6196
6197
|
client_metadata: overrides?.client_metadata || {}
|
|
6197
6198
|
};
|
|
6198
6199
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
@@ -7355,6 +7356,62 @@ import { jsx as jsx21, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
|
7355
7356
|
import * as React112 from "react";
|
|
7356
7357
|
import { jsx as jsx222, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
7357
7358
|
import * as React242 from "react";
|
|
7359
|
+
|
|
7360
|
+
// ../../node_modules/.pnpm/mipd@0.0.7_typescript@5.9.3/node_modules/mipd/dist/esm/utils.js
|
|
7361
|
+
function requestProviders(listener) {
|
|
7362
|
+
if (typeof window === "undefined")
|
|
7363
|
+
return;
|
|
7364
|
+
const handler = (event) => listener(event.detail);
|
|
7365
|
+
window.addEventListener("eip6963:announceProvider", handler);
|
|
7366
|
+
window.dispatchEvent(new CustomEvent("eip6963:requestProvider"));
|
|
7367
|
+
return () => window.removeEventListener("eip6963:announceProvider", handler);
|
|
7368
|
+
}
|
|
7369
|
+
|
|
7370
|
+
// ../../node_modules/.pnpm/mipd@0.0.7_typescript@5.9.3/node_modules/mipd/dist/esm/store.js
|
|
7371
|
+
function createStore() {
|
|
7372
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
7373
|
+
let providerDetails = [];
|
|
7374
|
+
const request = () => requestProviders((providerDetail) => {
|
|
7375
|
+
if (providerDetails.some(({ info }) => info.uuid === providerDetail.info.uuid))
|
|
7376
|
+
return;
|
|
7377
|
+
providerDetails = [...providerDetails, providerDetail];
|
|
7378
|
+
listeners.forEach((listener) => listener(providerDetails, { added: [providerDetail] }));
|
|
7379
|
+
});
|
|
7380
|
+
let unwatch = request();
|
|
7381
|
+
return {
|
|
7382
|
+
_listeners() {
|
|
7383
|
+
return listeners;
|
|
7384
|
+
},
|
|
7385
|
+
clear() {
|
|
7386
|
+
listeners.forEach((listener) => listener([], { removed: [...providerDetails] }));
|
|
7387
|
+
providerDetails = [];
|
|
7388
|
+
},
|
|
7389
|
+
destroy() {
|
|
7390
|
+
this.clear();
|
|
7391
|
+
listeners.clear();
|
|
7392
|
+
unwatch?.();
|
|
7393
|
+
},
|
|
7394
|
+
findProvider({ rdns }) {
|
|
7395
|
+
return providerDetails.find((providerDetail) => providerDetail.info.rdns === rdns);
|
|
7396
|
+
},
|
|
7397
|
+
getProviders() {
|
|
7398
|
+
return providerDetails;
|
|
7399
|
+
},
|
|
7400
|
+
reset() {
|
|
7401
|
+
this.clear();
|
|
7402
|
+
unwatch?.();
|
|
7403
|
+
unwatch = request();
|
|
7404
|
+
},
|
|
7405
|
+
subscribe(listener, { emitImmediately } = {}) {
|
|
7406
|
+
listeners.add(listener);
|
|
7407
|
+
if (emitImmediately)
|
|
7408
|
+
listener(providerDetails, { added: providerDetails });
|
|
7409
|
+
return () => listeners.delete(listener);
|
|
7410
|
+
}
|
|
7411
|
+
};
|
|
7412
|
+
}
|
|
7413
|
+
|
|
7414
|
+
// ../ui-react/dist/index.mjs
|
|
7358
7415
|
import * as React122 from "react";
|
|
7359
7416
|
import { jsx as jsx232, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
7360
7417
|
import * as React132 from "react";
|
|
@@ -13991,6 +14048,7 @@ function useDepositAddress(params) {
|
|
|
13991
14048
|
destinationChainId,
|
|
13992
14049
|
destinationTokenAddress,
|
|
13993
14050
|
actionType,
|
|
14051
|
+
contractCalls,
|
|
13994
14052
|
enabled = true
|
|
13995
14053
|
} = params;
|
|
13996
14054
|
return useQuery2({
|
|
@@ -14003,6 +14061,7 @@ function useDepositAddress(params) {
|
|
|
14003
14061
|
destinationChainId ?? null,
|
|
14004
14062
|
destinationTokenAddress ?? null,
|
|
14005
14063
|
actionType ?? null,
|
|
14064
|
+
contractCalls ?? null,
|
|
14006
14065
|
publishableKey
|
|
14007
14066
|
],
|
|
14008
14067
|
queryFn: () => createDepositAddress(
|
|
@@ -14012,7 +14071,8 @@ function useDepositAddress(params) {
|
|
|
14012
14071
|
destination_chain_type: destinationChainType,
|
|
14013
14072
|
destination_chain_id: destinationChainId,
|
|
14014
14073
|
destination_token_address: destinationTokenAddress,
|
|
14015
|
-
action_type: actionType
|
|
14074
|
+
action_type: actionType,
|
|
14075
|
+
contract_calls: contractCalls
|
|
14016
14076
|
},
|
|
14017
14077
|
publishableKey
|
|
14018
14078
|
),
|
|
@@ -14814,7 +14874,7 @@ function interpolate(template, params) {
|
|
|
14814
14874
|
}
|
|
14815
14875
|
var DEPOSIT_CONFIRM_DELAY_MS = 5e3;
|
|
14816
14876
|
var POLL_INTERVAL_MS = 2500;
|
|
14817
|
-
var POLL_ENDPOINT_INTERVAL_MS =
|
|
14877
|
+
var POLL_ENDPOINT_INTERVAL_MS = 5e3;
|
|
14818
14878
|
var CUTOFF_BUFFER_MS = 6e4;
|
|
14819
14879
|
function useDepositPolling({
|
|
14820
14880
|
userId,
|
|
@@ -18456,6 +18516,53 @@ function CashAppButton({
|
|
|
18456
18516
|
}
|
|
18457
18517
|
);
|
|
18458
18518
|
}
|
|
18519
|
+
var _store = null;
|
|
18520
|
+
function getEip6963Store() {
|
|
18521
|
+
if (typeof window === "undefined") return null;
|
|
18522
|
+
if (!_store) {
|
|
18523
|
+
_store = createStore();
|
|
18524
|
+
}
|
|
18525
|
+
return _store;
|
|
18526
|
+
}
|
|
18527
|
+
var RDNS_TO_WALLET_ID = {
|
|
18528
|
+
"io.metamask": "metamask",
|
|
18529
|
+
"io.metamask.flask": "metamask",
|
|
18530
|
+
"io.metamask.mmi": "metamask",
|
|
18531
|
+
"app.phantom": "phantom",
|
|
18532
|
+
"com.coinbase.wallet": "coinbase",
|
|
18533
|
+
"com.okex.wallet": "okx",
|
|
18534
|
+
"io.rabby": "rabby",
|
|
18535
|
+
"com.trustwallet.app": "trust",
|
|
18536
|
+
"me.rainbow": "rainbow"
|
|
18537
|
+
};
|
|
18538
|
+
function rdnsToWalletId(rdns) {
|
|
18539
|
+
if (RDNS_TO_WALLET_ID[rdns]) return RDNS_TO_WALLET_ID[rdns];
|
|
18540
|
+
if (rdns.includes("metamask")) return "metamask";
|
|
18541
|
+
if (rdns.includes("phantom")) return "phantom";
|
|
18542
|
+
if (rdns.includes("coinbase")) return "coinbase";
|
|
18543
|
+
if (rdns.includes("okx") || rdns.includes("okex")) return "okx";
|
|
18544
|
+
if (rdns.includes("rabby")) return "rabby";
|
|
18545
|
+
if (rdns.includes("trust")) return "trust";
|
|
18546
|
+
if (rdns.includes("rainbow")) return "rainbow";
|
|
18547
|
+
return "unknown";
|
|
18548
|
+
}
|
|
18549
|
+
function getEip6963Providers() {
|
|
18550
|
+
const store = getEip6963Store();
|
|
18551
|
+
if (!store) return [];
|
|
18552
|
+
return store.getProviders().map((detail) => ({
|
|
18553
|
+
walletId: rdnsToWalletId(detail.info.rdns),
|
|
18554
|
+
provider: detail.provider,
|
|
18555
|
+
info: detail.info
|
|
18556
|
+
}));
|
|
18557
|
+
}
|
|
18558
|
+
function findProviderByWalletId(walletId) {
|
|
18559
|
+
return getEip6963Providers().find((p) => p.walletId === walletId);
|
|
18560
|
+
}
|
|
18561
|
+
function collectAllEip6963EthProviders() {
|
|
18562
|
+
const store = getEip6963Store();
|
|
18563
|
+
if (!store) return [];
|
|
18564
|
+
return store.getProviders().map((d) => d.provider);
|
|
18565
|
+
}
|
|
18459
18566
|
var SOLANA_DISCONNECT_TYPES = [
|
|
18460
18567
|
"phantom-solana",
|
|
18461
18568
|
"solflare",
|
|
@@ -18495,8 +18602,9 @@ function collectEthereumProvidersForDisconnect(win) {
|
|
|
18495
18602
|
out.push(p);
|
|
18496
18603
|
}
|
|
18497
18604
|
};
|
|
18498
|
-
const
|
|
18499
|
-
|
|
18605
|
+
for (const p of collectAllEip6963EthProviders()) {
|
|
18606
|
+
add(p);
|
|
18607
|
+
}
|
|
18500
18608
|
add(win.ethereum);
|
|
18501
18609
|
add(
|
|
18502
18610
|
win.phantom?.ethereum
|
|
@@ -20502,30 +20610,13 @@ function BrowserWalletButton({
|
|
|
20502
20610
|
}, []);
|
|
20503
20611
|
const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
|
|
20504
20612
|
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
|
-
};
|
|
20613
|
+
const store = getEip6963Store();
|
|
20614
|
+
if (!store) return;
|
|
20615
|
+
setEip6963ProviderCount(store.getProviders().length);
|
|
20616
|
+
const unsubscribe = store.subscribe((providers) => {
|
|
20617
|
+
setEip6963ProviderCount(providers.length);
|
|
20618
|
+
});
|
|
20619
|
+
return unsubscribe;
|
|
20529
20620
|
}, []);
|
|
20530
20621
|
React242.useEffect(() => {
|
|
20531
20622
|
if (!wallet || !publishableKey) {
|
|
@@ -20584,7 +20675,7 @@ function BrowserWalletButton({
|
|
|
20584
20675
|
return;
|
|
20585
20676
|
}
|
|
20586
20677
|
if (!chainType || chainType === "solana") {
|
|
20587
|
-
const
|
|
20678
|
+
const anyWin = win;
|
|
20588
20679
|
const trySilentSolana = async (provider, type, name, icon) => {
|
|
20589
20680
|
if (!provider) return false;
|
|
20590
20681
|
if (provider.isConnected && provider.publicKey) {
|
|
@@ -20623,21 +20714,21 @@ function BrowserWalletButton({
|
|
|
20623
20714
|
))
|
|
20624
20715
|
return;
|
|
20625
20716
|
if (await trySilentSolana(
|
|
20626
|
-
|
|
20717
|
+
anyWin.solflare,
|
|
20627
20718
|
"solflare",
|
|
20628
20719
|
"Solflare",
|
|
20629
20720
|
"solflare"
|
|
20630
20721
|
))
|
|
20631
20722
|
return;
|
|
20632
20723
|
if (await trySilentSolana(
|
|
20633
|
-
|
|
20724
|
+
anyWin.backpack,
|
|
20634
20725
|
"backpack",
|
|
20635
20726
|
"Backpack",
|
|
20636
20727
|
"backpack"
|
|
20637
20728
|
))
|
|
20638
20729
|
return;
|
|
20639
20730
|
if (await trySilentSolana(
|
|
20640
|
-
|
|
20731
|
+
anyWin.glow,
|
|
20641
20732
|
"glow",
|
|
20642
20733
|
"Glow",
|
|
20643
20734
|
"glow"
|
|
@@ -20645,19 +20736,14 @@ function BrowserWalletButton({
|
|
|
20645
20736
|
return;
|
|
20646
20737
|
}
|
|
20647
20738
|
if (!chainType || chainType === "ethereum") {
|
|
20648
|
-
const
|
|
20739
|
+
const anyWin = win;
|
|
20649
20740
|
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 });
|
|
20741
|
+
const eip6963 = getEip6963Providers();
|
|
20742
|
+
for (const { provider, walletId } of eip6963) {
|
|
20743
|
+
allProviders.push({
|
|
20744
|
+
provider,
|
|
20745
|
+
walletId: walletId === "unknown" ? "default" : walletId
|
|
20746
|
+
});
|
|
20661
20747
|
}
|
|
20662
20748
|
if (allProviders.length === 0) {
|
|
20663
20749
|
if (win.phantom?.ethereum) {
|
|
@@ -20666,15 +20752,15 @@ function BrowserWalletButton({
|
|
|
20666
20752
|
walletId: "phantom"
|
|
20667
20753
|
});
|
|
20668
20754
|
}
|
|
20669
|
-
if (
|
|
20755
|
+
if (anyWin.okxwallet) {
|
|
20670
20756
|
allProviders.push({
|
|
20671
|
-
provider:
|
|
20757
|
+
provider: anyWin.okxwallet,
|
|
20672
20758
|
walletId: "okx"
|
|
20673
20759
|
});
|
|
20674
20760
|
}
|
|
20675
|
-
if (
|
|
20761
|
+
if (anyWin.coinbaseWalletExtension) {
|
|
20676
20762
|
allProviders.push({
|
|
20677
|
-
provider:
|
|
20763
|
+
provider: anyWin.coinbaseWalletExtension,
|
|
20678
20764
|
walletId: "coinbase"
|
|
20679
20765
|
});
|
|
20680
20766
|
}
|
|
@@ -20698,7 +20784,7 @@ function BrowserWalletButton({
|
|
|
20698
20784
|
});
|
|
20699
20785
|
if (!accounts || accounts.length === 0) continue;
|
|
20700
20786
|
const address = accounts[0];
|
|
20701
|
-
const resolved = identifyEthWallet(provider,
|
|
20787
|
+
const resolved = identifyEthWallet(provider, anyWin, walletId);
|
|
20702
20788
|
if (mounted) {
|
|
20703
20789
|
setWallet({ ...resolved, address });
|
|
20704
20790
|
setIsLoading(false);
|
|
@@ -20740,15 +20826,11 @@ function BrowserWalletButton({
|
|
|
20740
20826
|
solanaProvider.on("disconnect", handleDisconnect);
|
|
20741
20827
|
solanaProvider.on("accountChanged", handleAccountsChanged);
|
|
20742
20828
|
}
|
|
20743
|
-
const anyWin = window;
|
|
20744
20829
|
const ethProviders = [];
|
|
20745
|
-
|
|
20746
|
-
|
|
20747
|
-
|
|
20748
|
-
|
|
20749
|
-
if (provider && !ethProviders.includes(provider)) {
|
|
20750
|
-
ethProviders.push(provider);
|
|
20751
|
-
}
|
|
20830
|
+
for (const { provider } of getEip6963Providers()) {
|
|
20831
|
+
const p = provider;
|
|
20832
|
+
if (p && !ethProviders.includes(p)) {
|
|
20833
|
+
ethProviders.push(p);
|
|
20752
20834
|
}
|
|
20753
20835
|
}
|
|
20754
20836
|
if (window.ethereum && !ethProviders.includes(window.ethereum)) {
|
|
@@ -20850,7 +20932,7 @@ function BrowserWalletButton({
|
|
|
20850
20932
|
if (isLoading) {
|
|
20851
20933
|
return null;
|
|
20852
20934
|
}
|
|
20853
|
-
const hasWalletExtension = (!chainType || chainType === "solana") && (window.phantom?.solana?.isPhantom || window.solana?.isPhantom)
|
|
20935
|
+
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
20936
|
if (!onConnectClick && !wallet && !hasWalletExtension) {
|
|
20855
20937
|
return null;
|
|
20856
20938
|
}
|
|
@@ -26358,15 +26440,10 @@ var WALLET_DEFINITIONS = [
|
|
|
26358
26440
|
{ id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
|
|
26359
26441
|
{ id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
|
|
26360
26442
|
];
|
|
26361
|
-
function
|
|
26443
|
+
function getSolanaProviders() {
|
|
26362
26444
|
if (typeof window === "undefined") return {};
|
|
26363
26445
|
const win = window;
|
|
26364
26446
|
return {
|
|
26365
|
-
ethereum: win.ethereum,
|
|
26366
|
-
phantomEthereum: win.phantom?.ethereum,
|
|
26367
|
-
coinbaseEthereum: win.coinbaseWalletExtension,
|
|
26368
|
-
trustEthereum: win.trustwallet?.ethereum,
|
|
26369
|
-
okxEthereum: win.okxwallet,
|
|
26370
26447
|
phantomSolana: win.phantom?.solana,
|
|
26371
26448
|
solflare: win.solflare,
|
|
26372
26449
|
backpack: win.backpack,
|
|
@@ -26374,37 +26451,71 @@ function getWalletProviders() {
|
|
|
26374
26451
|
coinbaseSolana: win.coinbaseSolana || win.coinbaseWalletExtension?.solana
|
|
26375
26452
|
};
|
|
26376
26453
|
}
|
|
26454
|
+
function getLegacyEvmProviders() {
|
|
26455
|
+
if (typeof window === "undefined") return {};
|
|
26456
|
+
const win = window;
|
|
26457
|
+
return {
|
|
26458
|
+
ethereum: win.ethereum,
|
|
26459
|
+
phantomEthereum: win.phantom?.ethereum,
|
|
26460
|
+
coinbaseEthereum: win.coinbaseWalletExtension,
|
|
26461
|
+
trustEthereum: win.trustwallet?.ethereum,
|
|
26462
|
+
okxEthereum: win.okxwallet
|
|
26463
|
+
};
|
|
26464
|
+
}
|
|
26377
26465
|
function detectAvailableWallets(filterChainType) {
|
|
26378
|
-
const
|
|
26466
|
+
const solProviders = getSolanaProviders();
|
|
26467
|
+
const legacyEvm = getLegacyEvmProviders();
|
|
26468
|
+
const eip6963List = getEip6963Providers();
|
|
26379
26469
|
const win = typeof window !== "undefined" ? window : null;
|
|
26470
|
+
const hasEip6963 = (walletId) => eip6963List.some((d) => {
|
|
26471
|
+
const rdns = d.info?.rdns || "";
|
|
26472
|
+
switch (walletId) {
|
|
26473
|
+
case "metamask":
|
|
26474
|
+
return rdns.includes("metamask");
|
|
26475
|
+
case "phantom":
|
|
26476
|
+
return rdns.includes("phantom");
|
|
26477
|
+
case "coinbase":
|
|
26478
|
+
return rdns.includes("coinbase");
|
|
26479
|
+
case "trust":
|
|
26480
|
+
return rdns.includes("trust");
|
|
26481
|
+
case "rainbow":
|
|
26482
|
+
return rdns.includes("rainbow");
|
|
26483
|
+
case "rabby":
|
|
26484
|
+
return rdns.includes("rabby");
|
|
26485
|
+
case "okx":
|
|
26486
|
+
return rdns.includes("okx") || rdns.includes("okex");
|
|
26487
|
+
default:
|
|
26488
|
+
return false;
|
|
26489
|
+
}
|
|
26490
|
+
});
|
|
26380
26491
|
return WALLET_DEFINITIONS.filter((w) => !filterChainType || w.networks.includes(filterChainType)).map((wallet) => {
|
|
26381
26492
|
let isInstalled = false;
|
|
26382
26493
|
const detectedNetworks = [];
|
|
26383
26494
|
switch (wallet.id) {
|
|
26384
26495
|
case "metamask":
|
|
26385
|
-
isInstalled = !!(
|
|
26496
|
+
isInstalled = hasEip6963("metamask") || !!(legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom && !legacyEvm.ethereum?.isRabby && !legacyEvm.ethereum?.isOkxWallet);
|
|
26386
26497
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26387
26498
|
break;
|
|
26388
26499
|
case "phantom":
|
|
26389
|
-
if (
|
|
26500
|
+
if (solProviders.phantomSolana?.isPhantom) {
|
|
26390
26501
|
isInstalled = true;
|
|
26391
26502
|
detectedNetworks.push("solana");
|
|
26392
26503
|
}
|
|
26393
|
-
if (
|
|
26504
|
+
if (hasEip6963("phantom") || legacyEvm.phantomEthereum?.isPhantom) {
|
|
26394
26505
|
isInstalled = true;
|
|
26395
26506
|
detectedNetworks.push("ethereum");
|
|
26396
26507
|
}
|
|
26397
26508
|
break;
|
|
26398
26509
|
case "coinbase":
|
|
26399
|
-
if (
|
|
26510
|
+
if (hasEip6963("coinbase") || legacyEvm.coinbaseEthereum || legacyEvm.ethereum?.isCoinbaseWallet) {
|
|
26400
26511
|
isInstalled = true;
|
|
26401
26512
|
detectedNetworks.push("ethereum");
|
|
26402
26513
|
}
|
|
26403
|
-
if (
|
|
26514
|
+
if (solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana) detectedNetworks.push("solana");
|
|
26404
26515
|
if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
|
|
26405
26516
|
break;
|
|
26406
26517
|
case "trust":
|
|
26407
|
-
if (
|
|
26518
|
+
if (hasEip6963("trust") || legacyEvm.trustEthereum || legacyEvm.ethereum?.isTrust || win?.trustwallet) {
|
|
26408
26519
|
isInstalled = true;
|
|
26409
26520
|
detectedNetworks.push("ethereum");
|
|
26410
26521
|
}
|
|
@@ -26412,27 +26523,27 @@ function detectAvailableWallets(filterChainType) {
|
|
|
26412
26523
|
if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
|
|
26413
26524
|
break;
|
|
26414
26525
|
case "rainbow":
|
|
26415
|
-
isInstalled = !!
|
|
26526
|
+
isInstalled = hasEip6963("rainbow") || !!legacyEvm.ethereum?.isRainbow;
|
|
26416
26527
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26417
26528
|
break;
|
|
26418
26529
|
case "rabby":
|
|
26419
|
-
isInstalled = !!
|
|
26530
|
+
isInstalled = hasEip6963("rabby") || !!legacyEvm.ethereum?.isRabby;
|
|
26420
26531
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26421
26532
|
break;
|
|
26422
26533
|
case "okx":
|
|
26423
|
-
isInstalled = !!(
|
|
26534
|
+
isInstalled = hasEip6963("okx") || !!(legacyEvm.okxEthereum || legacyEvm.ethereum?.isOkxWallet);
|
|
26424
26535
|
if (isInstalled) detectedNetworks.push("ethereum");
|
|
26425
26536
|
break;
|
|
26426
26537
|
case "solflare":
|
|
26427
|
-
isInstalled = !!
|
|
26538
|
+
isInstalled = !!solProviders.solflare?.isSolflare;
|
|
26428
26539
|
if (isInstalled) detectedNetworks.push("solana");
|
|
26429
26540
|
break;
|
|
26430
26541
|
case "backpack":
|
|
26431
|
-
isInstalled = !!(
|
|
26542
|
+
isInstalled = !!(solProviders.backpack?.isBackpack || win?.backpack);
|
|
26432
26543
|
if (isInstalled) detectedNetworks.push("solana");
|
|
26433
26544
|
break;
|
|
26434
26545
|
case "glow":
|
|
26435
|
-
isInstalled = !!(
|
|
26546
|
+
isInstalled = !!(solProviders.glow?.isGlow || win?.glow);
|
|
26436
26547
|
if (isInstalled) detectedNetworks.push("solana");
|
|
26437
26548
|
break;
|
|
26438
26549
|
}
|
|
@@ -26487,7 +26598,16 @@ function WalletConnect({
|
|
|
26487
26598
|
const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
|
|
26488
26599
|
const [walletError, setWalletError] = React292.useState(null);
|
|
26489
26600
|
const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
|
|
26490
|
-
const
|
|
26601
|
+
const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
|
|
26602
|
+
React292.useEffect(() => {
|
|
26603
|
+
const store = getEip6963Store();
|
|
26604
|
+
if (!store) return;
|
|
26605
|
+
setEip6963ProviderCount(store.getProviders().length);
|
|
26606
|
+
return store.subscribe((providers) => {
|
|
26607
|
+
setEip6963ProviderCount(providers.length);
|
|
26608
|
+
});
|
|
26609
|
+
}, []);
|
|
26610
|
+
const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
|
|
26491
26611
|
const [balances, setBalances] = React292.useState([]);
|
|
26492
26612
|
const [isLoading, setIsLoading] = React292.useState(false);
|
|
26493
26613
|
const [selectedBalance, setSelectedBalance] = React292.useState(null);
|
|
@@ -26546,59 +26666,72 @@ function WalletConnect({
|
|
|
26546
26666
|
setWalletError(null);
|
|
26547
26667
|
setIsWalletConnecting(true);
|
|
26548
26668
|
try {
|
|
26549
|
-
const providers = getWalletProviders();
|
|
26550
26669
|
const win = typeof window !== "undefined" ? window : null;
|
|
26551
26670
|
let connectedInfo;
|
|
26552
26671
|
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
|
-
|
|
26672
|
+
const eip6963Match = findProviderByWalletId(wallet.id);
|
|
26673
|
+
let provider = eip6963Match?.provider;
|
|
26674
|
+
if (!provider) {
|
|
26675
|
+
const legacyEvm = getLegacyEvmProviders();
|
|
26676
|
+
switch (wallet.id) {
|
|
26677
|
+
case "metamask":
|
|
26678
|
+
if (legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom) provider = legacyEvm.ethereum;
|
|
26679
|
+
break;
|
|
26680
|
+
case "phantom":
|
|
26681
|
+
provider = legacyEvm.phantomEthereum;
|
|
26682
|
+
break;
|
|
26683
|
+
case "coinbase":
|
|
26684
|
+
provider = legacyEvm.coinbaseEthereum || (legacyEvm.ethereum?.isCoinbaseWallet ? legacyEvm.ethereum : void 0);
|
|
26685
|
+
break;
|
|
26686
|
+
case "trust":
|
|
26687
|
+
provider = legacyEvm.trustEthereum || (legacyEvm.ethereum?.isTrust ? legacyEvm.ethereum : void 0);
|
|
26688
|
+
break;
|
|
26689
|
+
case "rainbow":
|
|
26690
|
+
if (legacyEvm.ethereum?.isRainbow) provider = legacyEvm.ethereum;
|
|
26691
|
+
break;
|
|
26692
|
+
case "rabby":
|
|
26693
|
+
if (legacyEvm.ethereum?.isRabby) provider = legacyEvm.ethereum;
|
|
26694
|
+
break;
|
|
26695
|
+
case "okx":
|
|
26696
|
+
provider = legacyEvm.okxEthereum || (legacyEvm.ethereum?.isOkxWallet ? legacyEvm.ethereum : void 0);
|
|
26697
|
+
break;
|
|
26698
|
+
default:
|
|
26699
|
+
provider = legacyEvm.ethereum;
|
|
26700
|
+
}
|
|
26578
26701
|
}
|
|
26579
26702
|
if (!provider) throw new Error(`${wallet.name} wallet not found. Please install it.`);
|
|
26580
26703
|
const accounts = await provider.request({ method: "eth_requestAccounts" });
|
|
26581
26704
|
if (!accounts?.length) throw new Error("No accounts returned from wallet");
|
|
26582
26705
|
setUserDisconnectedWallet(false);
|
|
26583
|
-
const
|
|
26706
|
+
const walletIdToType = {
|
|
26707
|
+
phantom: "phantom-ethereum",
|
|
26708
|
+
coinbase: "coinbase",
|
|
26709
|
+
trust: "trust",
|
|
26710
|
+
rainbow: "rainbow",
|
|
26711
|
+
rabby: "rabby",
|
|
26712
|
+
okx: "okx",
|
|
26713
|
+
metamask: "metamask"
|
|
26714
|
+
};
|
|
26715
|
+
const walletType = walletIdToType[wallet.id] || "metamask";
|
|
26584
26716
|
connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
|
|
26585
26717
|
} else {
|
|
26718
|
+
const solProviders = getSolanaProviders();
|
|
26586
26719
|
let provider;
|
|
26587
26720
|
switch (wallet.id) {
|
|
26588
26721
|
case "phantom":
|
|
26589
|
-
provider =
|
|
26722
|
+
provider = solProviders.phantomSolana;
|
|
26590
26723
|
break;
|
|
26591
26724
|
case "solflare":
|
|
26592
|
-
provider =
|
|
26725
|
+
provider = solProviders.solflare;
|
|
26593
26726
|
break;
|
|
26594
26727
|
case "backpack":
|
|
26595
|
-
provider =
|
|
26728
|
+
provider = solProviders.backpack || win?.backpack;
|
|
26596
26729
|
break;
|
|
26597
26730
|
case "glow":
|
|
26598
|
-
provider =
|
|
26731
|
+
provider = solProviders.glow || win?.glow;
|
|
26599
26732
|
break;
|
|
26600
26733
|
case "coinbase":
|
|
26601
|
-
provider =
|
|
26734
|
+
provider = solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
|
|
26602
26735
|
break;
|
|
26603
26736
|
case "trust":
|
|
26604
26737
|
provider = win?.trustwallet?.solana;
|
|
@@ -26844,10 +26977,15 @@ function WalletConnect({
|
|
|
26844
26977
|
};
|
|
26845
26978
|
const sendEthereumTransaction = async (token, amountStr) => {
|
|
26846
26979
|
if (!recipientAddress || !/^0x[a-fA-F0-9]{40}$/.test(recipientAddress)) throw new Error(`Invalid recipient address.`);
|
|
26847
|
-
|
|
26848
|
-
|
|
26849
|
-
|
|
26850
|
-
|
|
26980
|
+
const walletIdMap = { "phantom-ethereum": "phantom", coinbase: "coinbase", trust: "trust", okx: "okx", rainbow: "rainbow", rabby: "rabby", metamask: "metamask" };
|
|
26981
|
+
const lookupId = walletIdMap[walletInfo.type] || walletInfo.type;
|
|
26982
|
+
const eip6963Match = findProviderByWalletId(lookupId);
|
|
26983
|
+
let provider = eip6963Match?.provider;
|
|
26984
|
+
if (!provider) {
|
|
26985
|
+
if (walletInfo.type === "phantom-ethereum") provider = window.phantom?.ethereum;
|
|
26986
|
+
else if (walletInfo.type === "coinbase") provider = window.coinbaseWalletExtension || window.ethereum;
|
|
26987
|
+
else provider = window.ethereum;
|
|
26988
|
+
}
|
|
26851
26989
|
if (!provider) throw new Error("Ethereum wallet not found");
|
|
26852
26990
|
const currentChainIdHex = await provider.request({ method: "eth_chainId", params: [] });
|
|
26853
26991
|
if (parseInt(currentChainIdHex, 16).toString() !== token.chain_id) {
|
|
@@ -27075,6 +27213,7 @@ function DepositModal({
|
|
|
27075
27213
|
destinationChainType,
|
|
27076
27214
|
destinationChainId,
|
|
27077
27215
|
destinationTokenAddress,
|
|
27216
|
+
contractCalls,
|
|
27078
27217
|
defaultSourceChainType,
|
|
27079
27218
|
defaultSourceChainId,
|
|
27080
27219
|
defaultSourceTokenAddress,
|
|
@@ -27201,6 +27340,7 @@ function DepositModal({
|
|
|
27201
27340
|
destinationChainType,
|
|
27202
27341
|
destinationChainId,
|
|
27203
27342
|
destinationTokenAddress,
|
|
27343
|
+
contractCalls,
|
|
27204
27344
|
enabled: open
|
|
27205
27345
|
// Only fetch when modal is open
|
|
27206
27346
|
});
|
|
@@ -28681,7 +28821,7 @@ function useExecutions(userId, publishableKey, options) {
|
|
|
28681
28821
|
});
|
|
28682
28822
|
}
|
|
28683
28823
|
var POLL_INTERVAL_MS3 = 2500;
|
|
28684
|
-
var POLL_ENDPOINT_INTERVAL_MS2 =
|
|
28824
|
+
var POLL_ENDPOINT_INTERVAL_MS2 = 5e3;
|
|
28685
28825
|
var CUTOFF_BUFFER_MS2 = 6e4;
|
|
28686
28826
|
function useWithdrawPolling({
|
|
28687
28827
|
userId,
|
|
@@ -30534,6 +30674,7 @@ function UnifoldProvider2({
|
|
|
30534
30674
|
destinationChainType: depositConfig.destinationChainType,
|
|
30535
30675
|
destinationChainId: depositConfig.destinationChainId,
|
|
30536
30676
|
destinationTokenAddress: depositConfig.destinationTokenAddress,
|
|
30677
|
+
contractCalls: depositConfig.contractCalls,
|
|
30537
30678
|
defaultSourceChainType: depositConfig.defaultSourceChainType,
|
|
30538
30679
|
defaultSourceChainId: depositConfig.defaultSourceChainId,
|
|
30539
30680
|
defaultSourceTokenAddress: depositConfig.defaultSourceTokenAddress,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unifold/connect-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.61",
|
|
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/
|
|
29
|
+
"@unifold/core": "0.1.61",
|
|
30
|
+
"@unifold/ui-react": "0.1.61",
|
|
31
|
+
"@unifold/react-provider": "0.1.61"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/react": "^19.0.0",
|