@0xsquid/react-hooks 8.3.1 → 8.4.0
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/core/constants.d.ts +1 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/types/transaction.d.ts +19 -1
- package/dist/hooks/hedera/useHederaAccountActivation.d.ts +10 -0
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/tokens/useNativeBalance.d.ts +2 -0
- package/dist/hooks/transaction/useGetRoute.d.ts +18 -7
- package/dist/{index-qAOvcSon.js → index-BdrSk8Ed.js} +874 -764
- package/dist/index-BdrSk8Ed.js.map +1 -0
- package/dist/{index-CMrdTYeW.js → index-BxJVsDEs.js} +861 -765
- package/dist/index-BxJVsDEs.js.map +1 -0
- package/dist/{index.es-DRgOycmm.js → index.es-CFf55ppw.js} +2 -2
- package/dist/{index.es-DRgOycmm.js.map → index.es-CFf55ppw.js.map} +1 -1
- package/dist/{index.es-Cu_QQTg-.js → index.es-DhiQj1ju.js} +2 -2
- package/dist/{index.es-Cu_QQTg-.js.map → index.es-DhiQj1ju.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/{secretService-B3sc6ibT.js → secretService-D0xrwhEv.js} +2 -2
- package/dist/{secretService-B3sc6ibT.js.map → secretService-D0xrwhEv.js.map} +1 -1
- package/dist/{secretService-B_-XWo1F.js → secretService-DRTd4cda.js} +2 -2
- package/dist/{secretService-B_-XWo1F.js.map → secretService-DRTd4cda.js.map} +1 -1
- package/dist/services/index.d.ts +1 -0
- package/dist/services/internal/hederaService.d.ts +2 -0
- package/dist/services/internal/routeService.d.ts +8 -0
- package/dist/services/internal/transactionService.d.ts +14 -1
- package/dist/{stellarService.client-sRzC5VSD.js → stellarService.client-CRFUb2R6.js} +2 -2
- package/dist/{stellarService.client-sRzC5VSD.js.map → stellarService.client-CRFUb2R6.js.map} +1 -1
- package/dist/{stellarService.client-Ciqw9lmL.js → stellarService.client-xMf7fjCz.js} +2 -2
- package/dist/{stellarService.client-Ciqw9lmL.js.map → stellarService.client-xMf7fjCz.js.map} +1 -1
- package/package.json +4 -4
- package/dist/index-CMrdTYeW.js.map +0 -1
- package/dist/index-qAOvcSon.js.map +0 -1
|
@@ -81,6 +81,7 @@ const gasRefundMultiplier = 25;
|
|
|
81
81
|
const internalSquidApiBaseUrl = "https://app.squidrouter.com/api";
|
|
82
82
|
const XAMAN_API_URL = `${internalSquidApiBaseUrl}/xaman/`;
|
|
83
83
|
const TOKEN_PRICE_API_URL = `${internalSquidApiBaseUrl}/coingecko`;
|
|
84
|
+
const DEFAULT_ROUTE_REFETCH_INTERVAL = 30_000;
|
|
84
85
|
const SOLANA_RPC_URL = "https://meredith-ute2ko-fast-mainnet.helius-rpc.com";
|
|
85
86
|
const INTEGRATOR_ID = "squid-widget-playground-local-cd33cba6-7e12-4fcc-8d5d-35e286f655ea";
|
|
86
87
|
const DEFAULT_COUNTRY_CODE = "US";
|
|
@@ -20834,6 +20835,309 @@ const isBitcoinAddressValid = (address$1) => {
|
|
|
20834
20835
|
}
|
|
20835
20836
|
};
|
|
20836
20837
|
|
|
20838
|
+
var HistoryTxType;
|
|
20839
|
+
(function (HistoryTxType) {
|
|
20840
|
+
HistoryTxType[HistoryTxType["SWAP"] = 0] = "SWAP";
|
|
20841
|
+
HistoryTxType[HistoryTxType["BUY"] = 1] = "BUY";
|
|
20842
|
+
HistoryTxType[HistoryTxType["SEND"] = 2] = "SEND";
|
|
20843
|
+
})(HistoryTxType || (HistoryTxType = {}));
|
|
20844
|
+
|
|
20845
|
+
var TransactionType;
|
|
20846
|
+
(function (TransactionType) {
|
|
20847
|
+
TransactionType["BRIDGE"] = "BRIDGE";
|
|
20848
|
+
TransactionType["BRIDGE_CALL"] = "BRIDGE_CALL";
|
|
20849
|
+
TransactionType["CALL_BRIDGE"] = "CALL_BRIDGE";
|
|
20850
|
+
TransactionType["CALL_BRIDGE_CALL"] = "CALL_BRIDGE_CALL";
|
|
20851
|
+
})(TransactionType || (TransactionType = {}));
|
|
20852
|
+
var AxelarStatusResponseType;
|
|
20853
|
+
(function (AxelarStatusResponseType) {
|
|
20854
|
+
AxelarStatusResponseType["GAS_PAID_NOT_ENOUGH_GAS"] = "gas_paid_not_enough_gas";
|
|
20855
|
+
AxelarStatusResponseType["DESTINATION_EXECUTED"] = "destination_executed";
|
|
20856
|
+
AxelarStatusResponseType["EXPRESS_EXECUTED"] = "express_executed";
|
|
20857
|
+
AxelarStatusResponseType["CROSS_MULTICALL_EXECUTED"] = "CrossMulticallExecuted";
|
|
20858
|
+
AxelarStatusResponseType["CROSS_MULTICALL_FAILED"] = "CrossMulticallFailed";
|
|
20859
|
+
AxelarStatusResponseType["SRC_GATEWAY_CALLED"] = "source_gateway_called";
|
|
20860
|
+
AxelarStatusResponseType["DEST_GATEWAY_APPROVED"] = "destination_gateway_approved";
|
|
20861
|
+
AxelarStatusResponseType["DESTINATION_EXECUTE_ERROR"] = "destination_execute_error";
|
|
20862
|
+
AxelarStatusResponseType["DESTINATION_EXECUTING"] = "executing";
|
|
20863
|
+
AxelarStatusResponseType["UNKNOWN_ERROR"] = "unknown_error";
|
|
20864
|
+
AxelarStatusResponseType["CANNOT_FETCH_STATUS"] = "cannot_fetch_status";
|
|
20865
|
+
AxelarStatusResponseType["ERROR"] = "error";
|
|
20866
|
+
})(AxelarStatusResponseType || (AxelarStatusResponseType = {}));
|
|
20867
|
+
var TransactionStatus;
|
|
20868
|
+
(function (TransactionStatus) {
|
|
20869
|
+
// Submitted transaction, returned by squid axelar
|
|
20870
|
+
TransactionStatus["SUCCESS"] = "success";
|
|
20871
|
+
TransactionStatus["NEEDS_GAS"] = "needs_gas";
|
|
20872
|
+
TransactionStatus["ONGOING"] = "ongoing";
|
|
20873
|
+
TransactionStatus["PARTIAL_SUCCESS"] = "partial_success";
|
|
20874
|
+
TransactionStatus["NOT_FOUND"] = "not_found";
|
|
20875
|
+
// Unsubmitted Transaction, can be status from wallet
|
|
20876
|
+
TransactionStatus["INITIAL_LOADING"] = "initialLoading";
|
|
20877
|
+
TransactionStatus["GENERATING_DEPOSIT"] = "generating_deposit";
|
|
20878
|
+
TransactionStatus["ERROR"] = "error";
|
|
20879
|
+
TransactionStatus["WARNING"] = "warning";
|
|
20880
|
+
TransactionStatus["PENDING"] = "pending";
|
|
20881
|
+
TransactionStatus["REJECTED"] = "rejected";
|
|
20882
|
+
// Coral refund
|
|
20883
|
+
TransactionStatus["REFUNDED"] = "refunded";
|
|
20884
|
+
})(TransactionStatus || (TransactionStatus = {}));
|
|
20885
|
+
var SendTransactionStatus;
|
|
20886
|
+
(function (SendTransactionStatus) {
|
|
20887
|
+
SendTransactionStatus[SendTransactionStatus["ONGOING"] = 0] = "ONGOING";
|
|
20888
|
+
SendTransactionStatus[SendTransactionStatus["SUCCESS"] = 1] = "SUCCESS";
|
|
20889
|
+
SendTransactionStatus[SendTransactionStatus["ERROR"] = 2] = "ERROR";
|
|
20890
|
+
})(SendTransactionStatus || (SendTransactionStatus = {}));
|
|
20891
|
+
|
|
20892
|
+
const getQueryHeaders = (integratorId, requestId) => {
|
|
20893
|
+
return {
|
|
20894
|
+
...(integratorId ? { "X-Integrator-Id": integratorId } : {}),
|
|
20895
|
+
...(requestId ? { "X-Request-Id": requestId } : {}),
|
|
20896
|
+
};
|
|
20897
|
+
};
|
|
20898
|
+
const getStatusCode = (error) => {
|
|
20899
|
+
if (axios.isAxiosError(error)) {
|
|
20900
|
+
return error.response?.status;
|
|
20901
|
+
}
|
|
20902
|
+
return undefined;
|
|
20903
|
+
};
|
|
20904
|
+
const is404Error = (error) => {
|
|
20905
|
+
const statusCode = getStatusCode(error);
|
|
20906
|
+
if (statusCode === 404) {
|
|
20907
|
+
return true;
|
|
20908
|
+
}
|
|
20909
|
+
return false;
|
|
20910
|
+
};
|
|
20911
|
+
|
|
20912
|
+
const formatTransactionHistoryDate = (transaction) => {
|
|
20913
|
+
if (!transaction?.timestamp)
|
|
20914
|
+
return undefined;
|
|
20915
|
+
try {
|
|
20916
|
+
const date = new Date(Number(transaction.timestamp));
|
|
20917
|
+
// Format date to: MMM DD. Examples:
|
|
20918
|
+
// Jan 01
|
|
20919
|
+
// May 12
|
|
20920
|
+
const month = new Intl.DateTimeFormat(DEFAULT_LOCALE, {
|
|
20921
|
+
month: "short",
|
|
20922
|
+
}).format(date);
|
|
20923
|
+
const day = date.toLocaleString(DEFAULT_LOCALE, { day: "2-digit" });
|
|
20924
|
+
return { month, day };
|
|
20925
|
+
}
|
|
20926
|
+
catch (error) {
|
|
20927
|
+
console.error("Error formatting date:", error);
|
|
20928
|
+
return undefined;
|
|
20929
|
+
}
|
|
20930
|
+
};
|
|
20931
|
+
const getAxelarExplorerTxUrl = (urlPrefix, routeType, txID) => {
|
|
20932
|
+
if (!urlPrefix) {
|
|
20933
|
+
return undefined;
|
|
20934
|
+
}
|
|
20935
|
+
const txType = routeType ?? TransactionType.BRIDGE;
|
|
20936
|
+
if (txType === TransactionType.CALL_BRIDGE ||
|
|
20937
|
+
txType === TransactionType.BRIDGE) {
|
|
20938
|
+
return `${urlPrefix}transfer/${txID}`;
|
|
20939
|
+
}
|
|
20940
|
+
return `${urlPrefix}gmp/${txID}`;
|
|
20941
|
+
};
|
|
20942
|
+
const getSourceExplorerTxUrl = (chain, txID) => {
|
|
20943
|
+
if (!chain || !chain.blockExplorerUrls[0] || !txID) {
|
|
20944
|
+
return undefined;
|
|
20945
|
+
}
|
|
20946
|
+
let txSuffix;
|
|
20947
|
+
switch (chain.chainId) {
|
|
20948
|
+
case CHAIN_IDS.AGORIC:
|
|
20949
|
+
case CHAIN_IDS.XRPL:
|
|
20950
|
+
case CHAIN_IDS.XRPL_TESTNET:
|
|
20951
|
+
txSuffix = "/transactions/";
|
|
20952
|
+
break;
|
|
20953
|
+
case CHAIN_IDS.HEDERA:
|
|
20954
|
+
txSuffix = "/transaction/";
|
|
20955
|
+
break;
|
|
20956
|
+
default:
|
|
20957
|
+
txSuffix = "/tx/";
|
|
20958
|
+
}
|
|
20959
|
+
if (chain.blockExplorerUrls[0].endsWith("/")) {
|
|
20960
|
+
txSuffix = txSuffix.slice(1);
|
|
20961
|
+
}
|
|
20962
|
+
return `${chain.blockExplorerUrls[0]}${txSuffix}${txID}`;
|
|
20963
|
+
};
|
|
20964
|
+
const getMainExplorerUrl = (transaction) => {
|
|
20965
|
+
// The most accurate one is coming from squid /status api
|
|
20966
|
+
if (transaction?.statusResponse?.axelarTransactionUrl) {
|
|
20967
|
+
return transaction?.statusResponse.axelarTransactionUrl;
|
|
20968
|
+
}
|
|
20969
|
+
// If not, we can try to get it from the source chain
|
|
20970
|
+
if (transaction?.sourceTxExplorerUrl) {
|
|
20971
|
+
return transaction?.sourceTxExplorerUrl;
|
|
20972
|
+
}
|
|
20973
|
+
// If not, we can try to guess it from the transaction type
|
|
20974
|
+
if (transaction && transaction?.transactionId) {
|
|
20975
|
+
return getAxelarExplorerTxUrl(transaction.statusResponse?.axelarTransactionUrl, transaction.routeType, transaction.transactionId);
|
|
20976
|
+
}
|
|
20977
|
+
return undefined;
|
|
20978
|
+
};
|
|
20979
|
+
const formatDistance = (date, baseDate, options) => {
|
|
20980
|
+
const { includeSeconds = false, addSuffix = false, locale = { locale: DEFAULT_LOCALE }, } = options || {};
|
|
20981
|
+
const elapsedMilliseconds = Math.abs(new Date(date).getTime() - new Date(baseDate).getTime());
|
|
20982
|
+
const seconds = Math.round(elapsedMilliseconds / 1000);
|
|
20983
|
+
const minutes = Math.round(seconds / 60);
|
|
20984
|
+
const hours = Math.round(minutes / 60);
|
|
20985
|
+
const days = Math.round(hours / 24);
|
|
20986
|
+
const months = Math.round(days / 30.44);
|
|
20987
|
+
const years = Math.round(days / 365.25);
|
|
20988
|
+
const rtf = new Intl.RelativeTimeFormat(locale.locale, { numeric: "auto" });
|
|
20989
|
+
let formatted = "";
|
|
20990
|
+
if (includeSeconds && seconds < 45) {
|
|
20991
|
+
const unit = addSuffix ? "second" : "seconds";
|
|
20992
|
+
formatted = rtf.format(-seconds, unit);
|
|
20993
|
+
}
|
|
20994
|
+
else if (minutes < 60) {
|
|
20995
|
+
formatted = rtf.format(-minutes, "minutes");
|
|
20996
|
+
}
|
|
20997
|
+
else if (hours < 24) {
|
|
20998
|
+
formatted = rtf.format(-hours, "hours");
|
|
20999
|
+
}
|
|
21000
|
+
else if (days < 30) {
|
|
21001
|
+
formatted = rtf.format(-days, "days");
|
|
21002
|
+
}
|
|
21003
|
+
else if (months < 12) {
|
|
21004
|
+
formatted = rtf.format(-months, "months");
|
|
21005
|
+
}
|
|
21006
|
+
else {
|
|
21007
|
+
formatted = rtf.format(-years, "years");
|
|
21008
|
+
}
|
|
21009
|
+
// remove "ago" from the string
|
|
21010
|
+
// before: "2 minutes ago"
|
|
21011
|
+
// after: "2 minutes"
|
|
21012
|
+
return addSuffix ? formatted : formatted.replace(/\b(?:ago)\b/, "").trim();
|
|
21013
|
+
};
|
|
21014
|
+
const formatSeconds = (seconds, secondsTemplate = "s", minutesTemplate = "m", hoursTemplate = "h") => {
|
|
21015
|
+
let duration = "";
|
|
21016
|
+
if (seconds < 60) {
|
|
21017
|
+
duration = `${seconds.toString()}${secondsTemplate}`;
|
|
21018
|
+
}
|
|
21019
|
+
else {
|
|
21020
|
+
duration = formatDistance(0, seconds * 1000, { includeSeconds: true });
|
|
21021
|
+
}
|
|
21022
|
+
const result = duration.startsWith("1 ")
|
|
21023
|
+
? duration
|
|
21024
|
+
.replace(" minute", minutesTemplate)
|
|
21025
|
+
.replace(" hour", hoursTemplate)
|
|
21026
|
+
: duration
|
|
21027
|
+
.replace(" minutes", minutesTemplate)
|
|
21028
|
+
.replace(" hours", hoursTemplate);
|
|
21029
|
+
return result;
|
|
21030
|
+
};
|
|
21031
|
+
/**
|
|
21032
|
+
* Remove the chainData from statusResponse to gain some storage space
|
|
21033
|
+
*/
|
|
21034
|
+
const formatSwapTxStatusResponseForStorage = (sr) => {
|
|
21035
|
+
if (!sr) {
|
|
21036
|
+
return sr;
|
|
21037
|
+
}
|
|
21038
|
+
return {
|
|
21039
|
+
axelarTransactionUrl: sr.axelarTransactionUrl,
|
|
21040
|
+
toChain: sr.toChain?.transactionUrl
|
|
21041
|
+
? {
|
|
21042
|
+
transactionUrl: sr.toChain?.transactionUrl,
|
|
21043
|
+
}
|
|
21044
|
+
: undefined,
|
|
21045
|
+
};
|
|
21046
|
+
};
|
|
21047
|
+
const simplifyRouteAction = (action) => {
|
|
21048
|
+
return {
|
|
21049
|
+
type: action.type,
|
|
21050
|
+
provider: action.provider,
|
|
21051
|
+
data: {
|
|
21052
|
+
type: action.data?.type,
|
|
21053
|
+
},
|
|
21054
|
+
...(action.coralV2Order ? { isCoralV2: true } : undefined),
|
|
21055
|
+
};
|
|
21056
|
+
};
|
|
21057
|
+
const fetchSwapTransactionStatus = async ({ transaction, integratorId, apiUrl, }) => {
|
|
21058
|
+
const statusEndpoint = `${apiUrl}/v2/status`;
|
|
21059
|
+
try {
|
|
21060
|
+
const response = await axios.get(statusEndpoint, {
|
|
21061
|
+
params: {
|
|
21062
|
+
transactionId: transaction?.transactionIdForStatus ?? transaction?.transactionId,
|
|
21063
|
+
fromChainId: transaction?.fromChain,
|
|
21064
|
+
toChainId: transaction?.toChain,
|
|
21065
|
+
bridgeType: transaction?.bridgeType,
|
|
21066
|
+
quoteId: transaction?.quoteId,
|
|
21067
|
+
depositTxVerificationSignature: transaction?.depositTxVerificationSignature,
|
|
21068
|
+
},
|
|
21069
|
+
headers: getQueryHeaders(integratorId, transaction?.quoteId),
|
|
21070
|
+
});
|
|
21071
|
+
return response.data;
|
|
21072
|
+
}
|
|
21073
|
+
catch (error) {
|
|
21074
|
+
if (error) {
|
|
21075
|
+
throw new Error("Fetch transaction status failed", { cause: error });
|
|
21076
|
+
}
|
|
21077
|
+
throw new Error("Fetch transaction status failed", { cause: undefined });
|
|
21078
|
+
}
|
|
21079
|
+
};
|
|
21080
|
+
const compareTransactionIds = (idA, idB) => {
|
|
21081
|
+
if (!idA || !idB) {
|
|
21082
|
+
return false;
|
|
21083
|
+
}
|
|
21084
|
+
const normalizedA = idA.toLowerCase();
|
|
21085
|
+
const normalizedB = idB.toLowerCase();
|
|
21086
|
+
return normalizedA.includes(normalizedB) || normalizedB.includes(normalizedA);
|
|
21087
|
+
};
|
|
21088
|
+
/**
|
|
21089
|
+
* Checks if the provided action is Coral bridge action
|
|
21090
|
+
*/
|
|
21091
|
+
function isCoralBridgeAction(action) {
|
|
21092
|
+
return (action.type === ActionType.RFQ &&
|
|
21093
|
+
// TODO: update types
|
|
21094
|
+
action.provider?.toLowerCase() === "coral");
|
|
21095
|
+
}
|
|
21096
|
+
function sleep(ms) {
|
|
21097
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21098
|
+
}
|
|
21099
|
+
const isDepositRoute = (route) => {
|
|
21100
|
+
return (!!route &&
|
|
21101
|
+
route.transactionRequest?.type === SquidDataType.ChainflipDepositAddress);
|
|
21102
|
+
};
|
|
21103
|
+
/**
|
|
21104
|
+
* Checks if the route contains a Chainflip bridge action
|
|
21105
|
+
*/
|
|
21106
|
+
function isChainflipBridgeTransaction(actions = []) {
|
|
21107
|
+
return actions.some((action) => action.type === ActionType.BRIDGE &&
|
|
21108
|
+
action.data?.type === BridgeType.CHAINFLIP);
|
|
21109
|
+
}
|
|
21110
|
+
/**
|
|
21111
|
+
* Checks if a route is of type {@link OnChainExecutionData}
|
|
21112
|
+
*
|
|
21113
|
+
* On-chain routes require calling a smart contract to execute
|
|
21114
|
+
*/
|
|
21115
|
+
function isOnChainTxData(squidData) {
|
|
21116
|
+
return [
|
|
21117
|
+
SquidDataType.OnChainExecution,
|
|
21118
|
+
SquidDataType.DepositAddressWithSignature,
|
|
21119
|
+
].includes(squidData.type);
|
|
21120
|
+
}
|
|
21121
|
+
/**
|
|
21122
|
+
* Checks if a route is of type deposit-with-signature
|
|
21123
|
+
*
|
|
21124
|
+
* deposit-with-signature routes are on-chain routes
|
|
21125
|
+
* that require a signature from the user to execute
|
|
21126
|
+
*/
|
|
21127
|
+
function isDepositWithSignatureTxData(squidData) {
|
|
21128
|
+
return squidData.type === SquidDataType.DepositAddressWithSignature;
|
|
21129
|
+
}
|
|
21130
|
+
function getHistoryTransactionId(tx) {
|
|
21131
|
+
switch (tx.txType) {
|
|
21132
|
+
case HistoryTxType.SWAP:
|
|
21133
|
+
return tx.data.transactionId;
|
|
21134
|
+
case HistoryTxType.BUY:
|
|
21135
|
+
return tx.data.orderId;
|
|
21136
|
+
case HistoryTxType.SEND:
|
|
21137
|
+
return tx.data.hash;
|
|
21138
|
+
}
|
|
21139
|
+
}
|
|
21140
|
+
|
|
20837
21141
|
const STANDARD_FEATURES = [
|
|
20838
21142
|
"standard:connect",
|
|
20839
21143
|
"standard:events",
|
|
@@ -21010,7 +21314,7 @@ const isSolanaAddressValid = (address) => {
|
|
|
21010
21314
|
* This will be used for the swap flow - Using Jupiter Dex under the hood
|
|
21011
21315
|
*/
|
|
21012
21316
|
const executeSolanaSwap = async ({ route, signer, connection, onSigned, }) => {
|
|
21013
|
-
if (!route
|
|
21317
|
+
if (!route.transactionRequest || !isOnChainTxData(route.transactionRequest)) {
|
|
21014
21318
|
throw new Error("Invalid parameters");
|
|
21015
21319
|
}
|
|
21016
21320
|
const swapRequest = route.transactionRequest.data;
|
|
@@ -21885,285 +22189,6 @@ async function getXummClient() {
|
|
|
21885
22189
|
return xummClient;
|
|
21886
22190
|
}
|
|
21887
22191
|
|
|
21888
|
-
const getQueryHeaders = (integratorId, requestId) => {
|
|
21889
|
-
return {
|
|
21890
|
-
...(integratorId ? { "X-Integrator-Id": integratorId } : {}),
|
|
21891
|
-
...(requestId ? { "X-Request-Id": requestId } : {}),
|
|
21892
|
-
};
|
|
21893
|
-
};
|
|
21894
|
-
const getStatusCode = (error) => {
|
|
21895
|
-
if (axios.isAxiosError(error)) {
|
|
21896
|
-
return error.response?.status;
|
|
21897
|
-
}
|
|
21898
|
-
return undefined;
|
|
21899
|
-
};
|
|
21900
|
-
const is404Error = (error) => {
|
|
21901
|
-
const statusCode = getStatusCode(error);
|
|
21902
|
-
if (statusCode === 404) {
|
|
21903
|
-
return true;
|
|
21904
|
-
}
|
|
21905
|
-
return false;
|
|
21906
|
-
};
|
|
21907
|
-
|
|
21908
|
-
var HistoryTxType;
|
|
21909
|
-
(function (HistoryTxType) {
|
|
21910
|
-
HistoryTxType[HistoryTxType["SWAP"] = 0] = "SWAP";
|
|
21911
|
-
HistoryTxType[HistoryTxType["BUY"] = 1] = "BUY";
|
|
21912
|
-
HistoryTxType[HistoryTxType["SEND"] = 2] = "SEND";
|
|
21913
|
-
})(HistoryTxType || (HistoryTxType = {}));
|
|
21914
|
-
|
|
21915
|
-
var TransactionType;
|
|
21916
|
-
(function (TransactionType) {
|
|
21917
|
-
TransactionType["BRIDGE"] = "BRIDGE";
|
|
21918
|
-
TransactionType["BRIDGE_CALL"] = "BRIDGE_CALL";
|
|
21919
|
-
TransactionType["CALL_BRIDGE"] = "CALL_BRIDGE";
|
|
21920
|
-
TransactionType["CALL_BRIDGE_CALL"] = "CALL_BRIDGE_CALL";
|
|
21921
|
-
})(TransactionType || (TransactionType = {}));
|
|
21922
|
-
var AxelarStatusResponseType;
|
|
21923
|
-
(function (AxelarStatusResponseType) {
|
|
21924
|
-
AxelarStatusResponseType["GAS_PAID_NOT_ENOUGH_GAS"] = "gas_paid_not_enough_gas";
|
|
21925
|
-
AxelarStatusResponseType["DESTINATION_EXECUTED"] = "destination_executed";
|
|
21926
|
-
AxelarStatusResponseType["EXPRESS_EXECUTED"] = "express_executed";
|
|
21927
|
-
AxelarStatusResponseType["CROSS_MULTICALL_EXECUTED"] = "CrossMulticallExecuted";
|
|
21928
|
-
AxelarStatusResponseType["CROSS_MULTICALL_FAILED"] = "CrossMulticallFailed";
|
|
21929
|
-
AxelarStatusResponseType["SRC_GATEWAY_CALLED"] = "source_gateway_called";
|
|
21930
|
-
AxelarStatusResponseType["DEST_GATEWAY_APPROVED"] = "destination_gateway_approved";
|
|
21931
|
-
AxelarStatusResponseType["DESTINATION_EXECUTE_ERROR"] = "destination_execute_error";
|
|
21932
|
-
AxelarStatusResponseType["DESTINATION_EXECUTING"] = "executing";
|
|
21933
|
-
AxelarStatusResponseType["UNKNOWN_ERROR"] = "unknown_error";
|
|
21934
|
-
AxelarStatusResponseType["CANNOT_FETCH_STATUS"] = "cannot_fetch_status";
|
|
21935
|
-
AxelarStatusResponseType["ERROR"] = "error";
|
|
21936
|
-
})(AxelarStatusResponseType || (AxelarStatusResponseType = {}));
|
|
21937
|
-
var TransactionStatus;
|
|
21938
|
-
(function (TransactionStatus) {
|
|
21939
|
-
// Submitted transaction, returned by squid axelar
|
|
21940
|
-
TransactionStatus["SUCCESS"] = "success";
|
|
21941
|
-
TransactionStatus["NEEDS_GAS"] = "needs_gas";
|
|
21942
|
-
TransactionStatus["ONGOING"] = "ongoing";
|
|
21943
|
-
TransactionStatus["PARTIAL_SUCCESS"] = "partial_success";
|
|
21944
|
-
TransactionStatus["NOT_FOUND"] = "not_found";
|
|
21945
|
-
// Unsubmitted Transaction, can be status from wallet
|
|
21946
|
-
TransactionStatus["INITIAL_LOADING"] = "initialLoading";
|
|
21947
|
-
TransactionStatus["GENERATING_DEPOSIT"] = "generating_deposit";
|
|
21948
|
-
TransactionStatus["ERROR"] = "error";
|
|
21949
|
-
TransactionStatus["WARNING"] = "warning";
|
|
21950
|
-
TransactionStatus["PENDING"] = "pending";
|
|
21951
|
-
TransactionStatus["REJECTED"] = "rejected";
|
|
21952
|
-
// Coral refund
|
|
21953
|
-
TransactionStatus["REFUNDED"] = "refunded";
|
|
21954
|
-
})(TransactionStatus || (TransactionStatus = {}));
|
|
21955
|
-
var SendTransactionStatus;
|
|
21956
|
-
(function (SendTransactionStatus) {
|
|
21957
|
-
SendTransactionStatus[SendTransactionStatus["ONGOING"] = 0] = "ONGOING";
|
|
21958
|
-
SendTransactionStatus[SendTransactionStatus["SUCCESS"] = 1] = "SUCCESS";
|
|
21959
|
-
SendTransactionStatus[SendTransactionStatus["ERROR"] = 2] = "ERROR";
|
|
21960
|
-
})(SendTransactionStatus || (SendTransactionStatus = {}));
|
|
21961
|
-
|
|
21962
|
-
const formatTransactionHistoryDate = (transaction) => {
|
|
21963
|
-
if (!transaction?.timestamp)
|
|
21964
|
-
return undefined;
|
|
21965
|
-
try {
|
|
21966
|
-
const date = new Date(Number(transaction.timestamp));
|
|
21967
|
-
// Format date to: MMM DD. Examples:
|
|
21968
|
-
// Jan 01
|
|
21969
|
-
// May 12
|
|
21970
|
-
const month = new Intl.DateTimeFormat(DEFAULT_LOCALE, {
|
|
21971
|
-
month: "short",
|
|
21972
|
-
}).format(date);
|
|
21973
|
-
const day = date.toLocaleString(DEFAULT_LOCALE, { day: "2-digit" });
|
|
21974
|
-
return { month, day };
|
|
21975
|
-
}
|
|
21976
|
-
catch (error) {
|
|
21977
|
-
console.error("Error formatting date:", error);
|
|
21978
|
-
return undefined;
|
|
21979
|
-
}
|
|
21980
|
-
};
|
|
21981
|
-
const getAxelarExplorerTxUrl = (urlPrefix, routeType, txID) => {
|
|
21982
|
-
if (!urlPrefix) {
|
|
21983
|
-
return undefined;
|
|
21984
|
-
}
|
|
21985
|
-
const txType = routeType ?? TransactionType.BRIDGE;
|
|
21986
|
-
if (txType === TransactionType.CALL_BRIDGE ||
|
|
21987
|
-
txType === TransactionType.BRIDGE) {
|
|
21988
|
-
return `${urlPrefix}transfer/${txID}`;
|
|
21989
|
-
}
|
|
21990
|
-
return `${urlPrefix}gmp/${txID}`;
|
|
21991
|
-
};
|
|
21992
|
-
const getSourceExplorerTxUrl = (chain, txID) => {
|
|
21993
|
-
if (!chain || !chain.blockExplorerUrls[0] || !txID) {
|
|
21994
|
-
return undefined;
|
|
21995
|
-
}
|
|
21996
|
-
let txSuffix;
|
|
21997
|
-
switch (chain.chainId) {
|
|
21998
|
-
case CHAIN_IDS.AGORIC:
|
|
21999
|
-
case CHAIN_IDS.XRPL:
|
|
22000
|
-
case CHAIN_IDS.XRPL_TESTNET:
|
|
22001
|
-
txSuffix = "/transactions/";
|
|
22002
|
-
break;
|
|
22003
|
-
default:
|
|
22004
|
-
txSuffix = "/tx/";
|
|
22005
|
-
}
|
|
22006
|
-
if (chain.blockExplorerUrls[0].endsWith("/")) {
|
|
22007
|
-
txSuffix = txSuffix.slice(1);
|
|
22008
|
-
}
|
|
22009
|
-
return `${chain.blockExplorerUrls[0]}${txSuffix}${txID}`;
|
|
22010
|
-
};
|
|
22011
|
-
const getMainExplorerUrl = (transaction) => {
|
|
22012
|
-
// The most accurate one is coming from squid /status api
|
|
22013
|
-
if (transaction?.statusResponse?.axelarTransactionUrl) {
|
|
22014
|
-
return transaction?.statusResponse.axelarTransactionUrl;
|
|
22015
|
-
}
|
|
22016
|
-
// If not, we can try to get it from the source chain
|
|
22017
|
-
if (transaction?.sourceTxExplorerUrl) {
|
|
22018
|
-
return transaction?.sourceTxExplorerUrl;
|
|
22019
|
-
}
|
|
22020
|
-
// If not, we can try to guess it from the transaction type
|
|
22021
|
-
if (transaction && transaction?.transactionId) {
|
|
22022
|
-
return getAxelarExplorerTxUrl(transaction.statusResponse?.axelarTransactionUrl, transaction.routeType, transaction.transactionId);
|
|
22023
|
-
}
|
|
22024
|
-
return undefined;
|
|
22025
|
-
};
|
|
22026
|
-
const formatDistance = (date, baseDate, options) => {
|
|
22027
|
-
const { includeSeconds = false, addSuffix = false, locale = { locale: DEFAULT_LOCALE }, } = options || {};
|
|
22028
|
-
const elapsedMilliseconds = Math.abs(new Date(date).getTime() - new Date(baseDate).getTime());
|
|
22029
|
-
const seconds = Math.round(elapsedMilliseconds / 1000);
|
|
22030
|
-
const minutes = Math.round(seconds / 60);
|
|
22031
|
-
const hours = Math.round(minutes / 60);
|
|
22032
|
-
const days = Math.round(hours / 24);
|
|
22033
|
-
const months = Math.round(days / 30.44);
|
|
22034
|
-
const years = Math.round(days / 365.25);
|
|
22035
|
-
const rtf = new Intl.RelativeTimeFormat(locale.locale, { numeric: "auto" });
|
|
22036
|
-
let formatted = "";
|
|
22037
|
-
if (includeSeconds && seconds < 45) {
|
|
22038
|
-
const unit = addSuffix ? "second" : "seconds";
|
|
22039
|
-
formatted = rtf.format(-seconds, unit);
|
|
22040
|
-
}
|
|
22041
|
-
else if (minutes < 60) {
|
|
22042
|
-
formatted = rtf.format(-minutes, "minutes");
|
|
22043
|
-
}
|
|
22044
|
-
else if (hours < 24) {
|
|
22045
|
-
formatted = rtf.format(-hours, "hours");
|
|
22046
|
-
}
|
|
22047
|
-
else if (days < 30) {
|
|
22048
|
-
formatted = rtf.format(-days, "days");
|
|
22049
|
-
}
|
|
22050
|
-
else if (months < 12) {
|
|
22051
|
-
formatted = rtf.format(-months, "months");
|
|
22052
|
-
}
|
|
22053
|
-
else {
|
|
22054
|
-
formatted = rtf.format(-years, "years");
|
|
22055
|
-
}
|
|
22056
|
-
// remove "ago" from the string
|
|
22057
|
-
// before: "2 minutes ago"
|
|
22058
|
-
// after: "2 minutes"
|
|
22059
|
-
return addSuffix ? formatted : formatted.replace(/\b(?:ago)\b/, "").trim();
|
|
22060
|
-
};
|
|
22061
|
-
const formatSeconds = (seconds, secondsTemplate = "s", minutesTemplate = "m", hoursTemplate = "h") => {
|
|
22062
|
-
let duration = "";
|
|
22063
|
-
if (seconds < 60) {
|
|
22064
|
-
duration = `${seconds.toString()}${secondsTemplate}`;
|
|
22065
|
-
}
|
|
22066
|
-
else {
|
|
22067
|
-
duration = formatDistance(0, seconds * 1000, { includeSeconds: true });
|
|
22068
|
-
}
|
|
22069
|
-
const result = duration.startsWith("1 ")
|
|
22070
|
-
? duration
|
|
22071
|
-
.replace(" minute", minutesTemplate)
|
|
22072
|
-
.replace(" hour", hoursTemplate)
|
|
22073
|
-
: duration
|
|
22074
|
-
.replace(" minutes", minutesTemplate)
|
|
22075
|
-
.replace(" hours", hoursTemplate);
|
|
22076
|
-
return result;
|
|
22077
|
-
};
|
|
22078
|
-
/**
|
|
22079
|
-
* Remove the chainData from statusResponse to gain some storage space
|
|
22080
|
-
*/
|
|
22081
|
-
const formatSwapTxStatusResponseForStorage = (sr) => {
|
|
22082
|
-
if (!sr) {
|
|
22083
|
-
return sr;
|
|
22084
|
-
}
|
|
22085
|
-
return {
|
|
22086
|
-
axelarTransactionUrl: sr.axelarTransactionUrl,
|
|
22087
|
-
toChain: sr.toChain?.transactionUrl
|
|
22088
|
-
? {
|
|
22089
|
-
transactionUrl: sr.toChain?.transactionUrl,
|
|
22090
|
-
}
|
|
22091
|
-
: undefined,
|
|
22092
|
-
};
|
|
22093
|
-
};
|
|
22094
|
-
const simplifyRouteAction = (action) => {
|
|
22095
|
-
return {
|
|
22096
|
-
type: action.type,
|
|
22097
|
-
provider: action.provider,
|
|
22098
|
-
data: {
|
|
22099
|
-
type: action.data?.type,
|
|
22100
|
-
},
|
|
22101
|
-
...(action.coralV2Order ? { isCoralV2: true } : undefined),
|
|
22102
|
-
};
|
|
22103
|
-
};
|
|
22104
|
-
const fetchSwapTransactionStatus = async ({ transaction, integratorId, apiUrl, }) => {
|
|
22105
|
-
const statusEndpoint = `${apiUrl}/v2/status`;
|
|
22106
|
-
try {
|
|
22107
|
-
const response = await axios.get(statusEndpoint, {
|
|
22108
|
-
params: {
|
|
22109
|
-
transactionId: transaction?.transactionIdForStatus ?? transaction?.transactionId,
|
|
22110
|
-
fromChainId: transaction?.fromChain,
|
|
22111
|
-
toChainId: transaction?.toChain,
|
|
22112
|
-
bridgeType: transaction?.bridgeType,
|
|
22113
|
-
quoteId: transaction?.quoteId,
|
|
22114
|
-
},
|
|
22115
|
-
headers: getQueryHeaders(integratorId, transaction?.quoteId),
|
|
22116
|
-
});
|
|
22117
|
-
return response.data;
|
|
22118
|
-
}
|
|
22119
|
-
catch (error) {
|
|
22120
|
-
if (error) {
|
|
22121
|
-
throw new Error("Fetch transaction status failed", { cause: error });
|
|
22122
|
-
}
|
|
22123
|
-
throw new Error("Fetch transaction status failed", { cause: undefined });
|
|
22124
|
-
}
|
|
22125
|
-
};
|
|
22126
|
-
const compareTransactionIds = (idA, idB) => {
|
|
22127
|
-
if (!idA || !idB) {
|
|
22128
|
-
return false;
|
|
22129
|
-
}
|
|
22130
|
-
const normalizedA = idA.toLowerCase();
|
|
22131
|
-
const normalizedB = idB.toLowerCase();
|
|
22132
|
-
return normalizedA.includes(normalizedB) || normalizedB.includes(normalizedA);
|
|
22133
|
-
};
|
|
22134
|
-
/**
|
|
22135
|
-
* Checks if the provided action is Coral bridge action
|
|
22136
|
-
*/
|
|
22137
|
-
function isCoralBridgeAction(action) {
|
|
22138
|
-
return (action.type === ActionType.RFQ &&
|
|
22139
|
-
// TODO: update types
|
|
22140
|
-
action.provider?.toLowerCase() === "coral");
|
|
22141
|
-
}
|
|
22142
|
-
function sleep(ms) {
|
|
22143
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
22144
|
-
}
|
|
22145
|
-
const isDepositRoute = (route) => {
|
|
22146
|
-
return (!!route &&
|
|
22147
|
-
route.transactionRequest?.type === SquidDataType.ChainflipDepositAddress);
|
|
22148
|
-
};
|
|
22149
|
-
/**
|
|
22150
|
-
* Checks if the route contains a Chainflip bridge action
|
|
22151
|
-
*/
|
|
22152
|
-
function isChainflipBridgeTransaction(actions = []) {
|
|
22153
|
-
return actions.some((action) => action.type === ActionType.BRIDGE &&
|
|
22154
|
-
action.data?.type === BridgeType.CHAINFLIP);
|
|
22155
|
-
}
|
|
22156
|
-
function getHistoryTransactionId(tx) {
|
|
22157
|
-
switch (tx.txType) {
|
|
22158
|
-
case HistoryTxType.SWAP:
|
|
22159
|
-
return tx.data.transactionId;
|
|
22160
|
-
case HistoryTxType.BUY:
|
|
22161
|
-
return tx.data.orderId;
|
|
22162
|
-
case HistoryTxType.SEND:
|
|
22163
|
-
return tx.data.hash;
|
|
22164
|
-
}
|
|
22165
|
-
}
|
|
22166
|
-
|
|
22167
22192
|
var QueryKeys;
|
|
22168
22193
|
(function (QueryKeys) {
|
|
22169
22194
|
QueryKeys["All"] = "all";
|
|
@@ -23132,7 +23157,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23132
23157
|
};
|
|
23133
23158
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23134
23159
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23135
|
-
const { fetchAllSecretBalances } = await import('./secretService-
|
|
23160
|
+
const { fetchAllSecretBalances } = await import('./secretService-D0xrwhEv.js');
|
|
23136
23161
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23137
23162
|
};
|
|
23138
23163
|
function getTokenAssetsKey(token) {
|
|
@@ -24604,6 +24629,37 @@ function convertHederaAccountIdToEvmAddress(accId) {
|
|
|
24604
24629
|
function convertEvmAddressToHederaAccountId(address) {
|
|
24605
24630
|
return "0.0." + Number(address);
|
|
24606
24631
|
}
|
|
24632
|
+
/**
|
|
24633
|
+
* In Hedera, native HBAR has 8 decimals, but when handling `value` or gas in the EVM we need to use 18 decimals.
|
|
24634
|
+
* To handle this we need to multiply/divide the 1e8 HBAR by 10^10 to get the scaled 1e18/1e8 HBAR value.
|
|
24635
|
+
* @see https://docs.hedera.com/hedera/core-concepts/smart-contracts/understanding-hederas-evm-differences-and-compatibility/for-evm-developers-migrating-to-hedera/decimal-handling-8-vs.-18-decimals
|
|
24636
|
+
*/
|
|
24637
|
+
const HBAR_SCALING_FACTOR = BigInt(10 ** 10);
|
|
24638
|
+
function scaleHbarToWei(hbar) {
|
|
24639
|
+
return hbar * HBAR_SCALING_FACTOR;
|
|
24640
|
+
}
|
|
24641
|
+
function scaleWeiToHbar(wei) {
|
|
24642
|
+
return wei / HBAR_SCALING_FACTOR;
|
|
24643
|
+
}
|
|
24644
|
+
|
|
24645
|
+
/**
|
|
24646
|
+
* Return the expiry of a route in milliseconds
|
|
24647
|
+
*
|
|
24648
|
+
* @param route - Squid route
|
|
24649
|
+
* @returns expiry in milliseconds
|
|
24650
|
+
*/
|
|
24651
|
+
function getRouteExpiry(route) {
|
|
24652
|
+
if (!route?.transactionRequest)
|
|
24653
|
+
return DEFAULT_ROUTE_REFETCH_INTERVAL;
|
|
24654
|
+
if (!isOnChainTxData(route.transactionRequest)) {
|
|
24655
|
+
return DEFAULT_ROUTE_REFETCH_INTERVAL;
|
|
24656
|
+
}
|
|
24657
|
+
const { expiryOffset } = route.transactionRequest;
|
|
24658
|
+
if (expiryOffset != null && Number(expiryOffset) >= 0) {
|
|
24659
|
+
return Number(expiryOffset) * 1_000;
|
|
24660
|
+
}
|
|
24661
|
+
return DEFAULT_ROUTE_REFETCH_INTERVAL;
|
|
24662
|
+
}
|
|
24607
24663
|
|
|
24608
24664
|
/**
|
|
24609
24665
|
* Minimum length of a search query to search by address
|
|
@@ -26417,7 +26473,7 @@ function useStellarWallets() {
|
|
|
26417
26473
|
try {
|
|
26418
26474
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26419
26475
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
|
|
26420
|
-
const { formatStellarWallet } = await import('./stellarService.client-
|
|
26476
|
+
const { formatStellarWallet } = await import('./stellarService.client-xMf7fjCz.js');
|
|
26421
26477
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26422
26478
|
const promises = modules.map(async (module) => {
|
|
26423
26479
|
const isAvailable = await module.isAvailable();
|
|
@@ -27917,7 +27973,7 @@ function hederaWalletConnect(parameters) {
|
|
|
27917
27973
|
const optionalChains = config.chains.map((x) => x.id);
|
|
27918
27974
|
if (!optionalChains.length)
|
|
27919
27975
|
return;
|
|
27920
|
-
const { EthereumProvider } = await import('./index.es-
|
|
27976
|
+
const { EthereumProvider } = await import('./index.es-CFf55ppw.js');
|
|
27921
27977
|
const rawProvider = await EthereumProvider.init({
|
|
27922
27978
|
...restParameters,
|
|
27923
27979
|
disableProviderPing: true,
|
|
@@ -29678,6 +29734,490 @@ function useStellarAccountActivation({ address, chain, token, }) {
|
|
|
29678
29734
|
};
|
|
29679
29735
|
}
|
|
29680
29736
|
|
|
29737
|
+
const DEFAULT_REFRESH_INTERVAL_MS = 15000;
|
|
29738
|
+
const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29739
|
+
const { isChainTypeConnected } = useWallet();
|
|
29740
|
+
const isNativeToken = token?.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
|
|
29741
|
+
const userAddressParsed = userAddress;
|
|
29742
|
+
// Only fetch using useBalance if it's a native token
|
|
29743
|
+
const { data: nativeBalance, isLoading: isNativeTokenLoading } = useBalance({
|
|
29744
|
+
address: userAddressParsed,
|
|
29745
|
+
chainId: Number(chain?.chainId),
|
|
29746
|
+
query: {
|
|
29747
|
+
enabled: enabled &&
|
|
29748
|
+
!!userAddress &&
|
|
29749
|
+
isNativeToken &&
|
|
29750
|
+
!!chain &&
|
|
29751
|
+
chain.chainType === ChainType.EVM &&
|
|
29752
|
+
isChainTypeConnected(chain.chainType),
|
|
29753
|
+
refetchInterval: refreshIntervalMs,
|
|
29754
|
+
retry: 2,
|
|
29755
|
+
},
|
|
29756
|
+
});
|
|
29757
|
+
// Only fetch using useReadContract if it's not a native token
|
|
29758
|
+
// This is temporary, because of wagmi error: https://github.com/wevm/wagmi/issues/4353
|
|
29759
|
+
const { data: erc20Balance, isLoading: isErc20Loading } = useReadContract({
|
|
29760
|
+
address: token?.address,
|
|
29761
|
+
abi: erc20Abi,
|
|
29762
|
+
functionName: "balanceOf",
|
|
29763
|
+
args: [userAddressParsed],
|
|
29764
|
+
chainId: Number(chain?.chainId),
|
|
29765
|
+
query: {
|
|
29766
|
+
enabled: isChainTypeConnected(ChainType.EVM) &&
|
|
29767
|
+
enabled &&
|
|
29768
|
+
!!userAddress &&
|
|
29769
|
+
!isNativeToken,
|
|
29770
|
+
refetchInterval: refreshIntervalMs,
|
|
29771
|
+
retry: 2,
|
|
29772
|
+
},
|
|
29773
|
+
});
|
|
29774
|
+
if (isNativeToken) {
|
|
29775
|
+
return {
|
|
29776
|
+
isLoading: isNativeTokenLoading,
|
|
29777
|
+
balance: nativeBalance
|
|
29778
|
+
? formatBNToReadable(nativeBalance.value, nativeBalance.decimals)
|
|
29779
|
+
: "0",
|
|
29780
|
+
};
|
|
29781
|
+
}
|
|
29782
|
+
return {
|
|
29783
|
+
balance: erc20Balance && token
|
|
29784
|
+
? formatBNToReadable(erc20Balance, token.decimals)
|
|
29785
|
+
: "0",
|
|
29786
|
+
isLoading: isErc20Loading,
|
|
29787
|
+
};
|
|
29788
|
+
};
|
|
29789
|
+
const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29790
|
+
const { isConnected } = useCosmosContext();
|
|
29791
|
+
const { data: balance = "0", isLoading } = useQuery({
|
|
29792
|
+
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29793
|
+
queryFn: async () => {
|
|
29794
|
+
if (!userAddress || !token || chain?.chainType !== ChainType.COSMOS) {
|
|
29795
|
+
return "0";
|
|
29796
|
+
}
|
|
29797
|
+
const isAddressValid = isCosmosAddressValid(chain.bech32Config.bech32PrefixAccAddr, userAddress);
|
|
29798
|
+
if (!isAddressValid)
|
|
29799
|
+
return "0";
|
|
29800
|
+
const balanceBn = await getCosmosTokenBalance(chain, userAddress, token.address);
|
|
29801
|
+
return formatBNToReadable(balanceBn, token.decimals);
|
|
29802
|
+
},
|
|
29803
|
+
enabled: isConnected &&
|
|
29804
|
+
enabled &&
|
|
29805
|
+
!!userAddress &&
|
|
29806
|
+
!!token &&
|
|
29807
|
+
chain?.chainType === ChainType.COSMOS,
|
|
29808
|
+
refetchInterval: refreshIntervalMs,
|
|
29809
|
+
retry: 2,
|
|
29810
|
+
});
|
|
29811
|
+
return { balance, isLoading };
|
|
29812
|
+
};
|
|
29813
|
+
const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29814
|
+
const { data: balance = "0", isLoading } = useQuery({
|
|
29815
|
+
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29816
|
+
queryFn: async () => {
|
|
29817
|
+
if (!userAddress || !token)
|
|
29818
|
+
return "0";
|
|
29819
|
+
const balanceBn = await getSolanaTokenBalance(userAddress, token.address);
|
|
29820
|
+
return formatBNToReadable(balanceBn, token.decimals);
|
|
29821
|
+
},
|
|
29822
|
+
enabled: enabled &&
|
|
29823
|
+
!!userAddress &&
|
|
29824
|
+
!!token &&
|
|
29825
|
+
chain?.chainType === ChainType.SOLANA,
|
|
29826
|
+
refetchInterval: refreshIntervalMs,
|
|
29827
|
+
retry: 2,
|
|
29828
|
+
});
|
|
29829
|
+
return { balance, isLoading };
|
|
29830
|
+
};
|
|
29831
|
+
// TODO: implement fetching balances for all bitcoin tokens
|
|
29832
|
+
const useBitcoinBalance = ({ userAddress, chain, }) => {
|
|
29833
|
+
const { balance: balanceBn, isLoading } = useBitcoinNativeBalance({
|
|
29834
|
+
address: userAddress,
|
|
29835
|
+
chain,
|
|
29836
|
+
});
|
|
29837
|
+
const balance = useMemo(() => {
|
|
29838
|
+
if (!balanceBn)
|
|
29839
|
+
return "0";
|
|
29840
|
+
return formatBNToReadable(balanceBn?.value, balanceBn?.decimals);
|
|
29841
|
+
}, [balanceBn]);
|
|
29842
|
+
return { balance, isLoading };
|
|
29843
|
+
};
|
|
29844
|
+
const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29845
|
+
const { data: balance = "0", isLoading } = useQuery({
|
|
29846
|
+
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29847
|
+
queryFn: async () => {
|
|
29848
|
+
if (!userAddress ||
|
|
29849
|
+
token?.type !== ChainType.SUI ||
|
|
29850
|
+
chain?.chainType !== ChainType.SUI) {
|
|
29851
|
+
throw new Error("Invalid SUI balance query parameters");
|
|
29852
|
+
}
|
|
29853
|
+
const balanceBn = await getSuiTokenBalance(userAddress, token.address, chain.rpc);
|
|
29854
|
+
return formatBNToReadable(balanceBn, token.decimals) ?? "0";
|
|
29855
|
+
},
|
|
29856
|
+
enabled: enabled &&
|
|
29857
|
+
!!userAddress &&
|
|
29858
|
+
!!chain?.rpc &&
|
|
29859
|
+
token?.type === ChainType.SUI &&
|
|
29860
|
+
chain?.chainType === ChainType.SUI &&
|
|
29861
|
+
isSuiAddressValid(userAddress),
|
|
29862
|
+
refetchInterval: refreshIntervalMs,
|
|
29863
|
+
retry: 2,
|
|
29864
|
+
});
|
|
29865
|
+
return { balance, isLoading };
|
|
29866
|
+
};
|
|
29867
|
+
const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29868
|
+
const { data: balance = "0", isLoading } = useQuery({
|
|
29869
|
+
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29870
|
+
queryFn: async () => {
|
|
29871
|
+
if (!userAddress || !token || !chain)
|
|
29872
|
+
return "0";
|
|
29873
|
+
const balanceBn = await getXrplTokenBalance(userAddress, token, chain);
|
|
29874
|
+
return formatBNToReadable(balanceBn, token.decimals) ?? "0";
|
|
29875
|
+
},
|
|
29876
|
+
enabled: enabled &&
|
|
29877
|
+
!!userAddress &&
|
|
29878
|
+
!!token &&
|
|
29879
|
+
!!chain?.rpc &&
|
|
29880
|
+
chain?.chainType === ChainType.XRPL &&
|
|
29881
|
+
isXrplAddressValid(userAddress),
|
|
29882
|
+
refetchInterval: refreshIntervalMs,
|
|
29883
|
+
retry: 2,
|
|
29884
|
+
});
|
|
29885
|
+
return { balance, isLoading };
|
|
29886
|
+
};
|
|
29887
|
+
const useStellarBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29888
|
+
const { data: balance = "0", isLoading } = useQuery({
|
|
29889
|
+
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29890
|
+
queryFn: async () => {
|
|
29891
|
+
if (!userAddress || !token || !chain)
|
|
29892
|
+
return "0";
|
|
29893
|
+
const balanceBn = await getStellarTokenBalance(userAddress, token, chain);
|
|
29894
|
+
return formatBNToReadable(balanceBn, token.decimals) ?? "0";
|
|
29895
|
+
},
|
|
29896
|
+
enabled: enabled &&
|
|
29897
|
+
!!userAddress &&
|
|
29898
|
+
!!token &&
|
|
29899
|
+
!!chain?.rpc &&
|
|
29900
|
+
chain?.chainType === ChainType.STELLAR &&
|
|
29901
|
+
isStellarAddressValid(userAddress),
|
|
29902
|
+
refetchInterval: refreshIntervalMs,
|
|
29903
|
+
retry: 2,
|
|
29904
|
+
});
|
|
29905
|
+
return { balance, isLoading };
|
|
29906
|
+
};
|
|
29907
|
+
|
|
29908
|
+
function useNativeTokenForChain(chain) {
|
|
29909
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens();
|
|
29910
|
+
const getTokensForChainType = () => {
|
|
29911
|
+
if (!chain?.chainType)
|
|
29912
|
+
return [];
|
|
29913
|
+
switch (chain.chainType) {
|
|
29914
|
+
case ChainType.EVM:
|
|
29915
|
+
return evmTokens;
|
|
29916
|
+
case ChainType.COSMOS:
|
|
29917
|
+
return cosmosTokens;
|
|
29918
|
+
case ChainType.SOLANA:
|
|
29919
|
+
return solanaTokens;
|
|
29920
|
+
case ChainType.BTC:
|
|
29921
|
+
return bitcoinTokens;
|
|
29922
|
+
case ChainType.SUI:
|
|
29923
|
+
return suiTokens;
|
|
29924
|
+
case ChainType.XRPL:
|
|
29925
|
+
return xrplTokens;
|
|
29926
|
+
case ChainType.STELLAR:
|
|
29927
|
+
return stellarTokens;
|
|
29928
|
+
}
|
|
29929
|
+
};
|
|
29930
|
+
const nativeTokenForChainType = useMemo(() => {
|
|
29931
|
+
return findNativeToken(getTokensForChainType(), chain);
|
|
29932
|
+
}, [chain]);
|
|
29933
|
+
return { nativeToken: nativeTokenForChainType };
|
|
29934
|
+
}
|
|
29935
|
+
|
|
29936
|
+
const useEvmNativeBalance = ({ address, chain, }) => {
|
|
29937
|
+
const { isChainTypeConnected } = useWallet();
|
|
29938
|
+
const { data: nativeEvmBalance, isLoading } = useBalance({
|
|
29939
|
+
address: address,
|
|
29940
|
+
chainId: Number(chain?.chainId),
|
|
29941
|
+
query: {
|
|
29942
|
+
enabled: isChainTypeConnected(ChainType.EVM) && !!address,
|
|
29943
|
+
refetchInterval: 10000,
|
|
29944
|
+
staleTime: 5000,
|
|
29945
|
+
refetchOnWindowFocus: true,
|
|
29946
|
+
refetchOnMount: true,
|
|
29947
|
+
},
|
|
29948
|
+
});
|
|
29949
|
+
const balance = useMemo(() => {
|
|
29950
|
+
if (nativeEvmBalance?.decimals && nativeEvmBalance?.value) {
|
|
29951
|
+
return {
|
|
29952
|
+
decimals: nativeEvmBalance.decimals,
|
|
29953
|
+
value: nativeEvmBalance.value,
|
|
29954
|
+
};
|
|
29955
|
+
}
|
|
29956
|
+
return;
|
|
29957
|
+
}, [nativeEvmBalance?.decimals, nativeEvmBalance?.value]);
|
|
29958
|
+
return {
|
|
29959
|
+
balance,
|
|
29960
|
+
isLoading,
|
|
29961
|
+
};
|
|
29962
|
+
};
|
|
29963
|
+
const useCosmosNativeBalance = ({ address, chain, }) => {
|
|
29964
|
+
const { isConnected: isCosmosConnected } = useCosmosContext();
|
|
29965
|
+
const { nativeToken: nativeCosmosToken } = useNativeTokenForChain(chain);
|
|
29966
|
+
const { balance: rawBalance, isLoading } = useCosmosBalance({
|
|
29967
|
+
chain,
|
|
29968
|
+
token: nativeCosmosToken,
|
|
29969
|
+
userAddress: address,
|
|
29970
|
+
enabled: isCosmosConnected && chain?.chainType === ChainType.COSMOS,
|
|
29971
|
+
refreshIntervalMs: 10000,
|
|
29972
|
+
});
|
|
29973
|
+
const balance = useMemo(() => {
|
|
29974
|
+
if (nativeCosmosToken?.decimals && rawBalance) {
|
|
29975
|
+
return {
|
|
29976
|
+
decimals: nativeCosmosToken.decimals,
|
|
29977
|
+
value: parseToBigInt(rawBalance, nativeCosmosToken.decimals),
|
|
29978
|
+
};
|
|
29979
|
+
}
|
|
29980
|
+
}, [nativeCosmosToken?.decimals, rawBalance]);
|
|
29981
|
+
return { balance, isLoading };
|
|
29982
|
+
};
|
|
29983
|
+
const useBitcoinNativeBalance = ({ chain, address, }) => {
|
|
29984
|
+
const { nativeToken } = useNativeTokenForChain(chain);
|
|
29985
|
+
const { data: rawBalance = "0", isLoading } = useQuery(keys().balance(chain?.chainId, nativeToken?.address, address), async () => {
|
|
29986
|
+
if (!address || !nativeToken)
|
|
29987
|
+
return "0";
|
|
29988
|
+
const balance = await getBitcoinNativeBalance(address);
|
|
29989
|
+
return formatBNToReadable(balance, nativeToken.decimals);
|
|
29990
|
+
}, {
|
|
29991
|
+
enabled: chain?.chainType === ChainType.BTC &&
|
|
29992
|
+
nativeToken?.decimals != null &&
|
|
29993
|
+
isWalletAddressValid(chain, address),
|
|
29994
|
+
refetchInterval: 40000,
|
|
29995
|
+
staleTime: 20000,
|
|
29996
|
+
refetchOnWindowFocus: true,
|
|
29997
|
+
refetchOnMount: true,
|
|
29998
|
+
});
|
|
29999
|
+
const balance = useMemo(() => {
|
|
30000
|
+
if (nativeToken?.decimals && rawBalance) {
|
|
30001
|
+
return {
|
|
30002
|
+
decimals: nativeToken.decimals,
|
|
30003
|
+
value: parseToBigInt(rawBalance, nativeToken.decimals),
|
|
30004
|
+
};
|
|
30005
|
+
}
|
|
30006
|
+
}, [nativeToken?.decimals, rawBalance]);
|
|
30007
|
+
return {
|
|
30008
|
+
balance,
|
|
30009
|
+
isLoading,
|
|
30010
|
+
};
|
|
30011
|
+
};
|
|
30012
|
+
const useSolanaNativeBalance = ({ chain, address, }) => {
|
|
30013
|
+
const { nativeToken } = useNativeTokenForChain(chain);
|
|
30014
|
+
const { data: rawBalance, isLoading } = useQuery(keys().balance(chain?.chainId, nativeToken?.address, address), async () => {
|
|
30015
|
+
const balance = await getSolanaNativeBalance(address);
|
|
30016
|
+
return formatBNToReadable(balance, nativeToken.decimals);
|
|
30017
|
+
}, {
|
|
30018
|
+
enabled: !!address &&
|
|
30019
|
+
nativeToken?.decimals != null &&
|
|
30020
|
+
chain?.chainType === ChainType.SOLANA,
|
|
30021
|
+
refetchInterval: 40000,
|
|
30022
|
+
staleTime: 20000,
|
|
30023
|
+
refetchOnWindowFocus: true,
|
|
30024
|
+
refetchOnMount: true,
|
|
30025
|
+
});
|
|
30026
|
+
const balance = useMemo(() => {
|
|
30027
|
+
if (nativeToken?.decimals && rawBalance) {
|
|
30028
|
+
return {
|
|
30029
|
+
decimals: nativeToken.decimals,
|
|
30030
|
+
value: parseToBigInt(rawBalance, nativeToken.decimals),
|
|
30031
|
+
};
|
|
30032
|
+
}
|
|
30033
|
+
}, [nativeToken?.decimals, rawBalance]);
|
|
30034
|
+
return {
|
|
30035
|
+
balance,
|
|
30036
|
+
isLoading,
|
|
30037
|
+
};
|
|
30038
|
+
};
|
|
30039
|
+
const useSuiNativeBalance = ({ address, chain, }) => {
|
|
30040
|
+
const { nativeToken } = useNativeTokenForChain(chain);
|
|
30041
|
+
const { balance: rawBalance, isLoading } = useSuiBalance({
|
|
30042
|
+
chain,
|
|
30043
|
+
token: nativeToken,
|
|
30044
|
+
userAddress: address,
|
|
30045
|
+
});
|
|
30046
|
+
const balance = useMemo(() => {
|
|
30047
|
+
if (nativeToken?.decimals && rawBalance) {
|
|
30048
|
+
return {
|
|
30049
|
+
decimals: nativeToken.decimals,
|
|
30050
|
+
value: parseToBigInt(rawBalance, nativeToken.decimals),
|
|
30051
|
+
};
|
|
30052
|
+
}
|
|
30053
|
+
}, [nativeToken?.decimals, rawBalance]);
|
|
30054
|
+
return {
|
|
30055
|
+
balance,
|
|
30056
|
+
isLoading,
|
|
30057
|
+
};
|
|
30058
|
+
};
|
|
30059
|
+
const useXrplNativeBalance = ({ address, chain, }) => {
|
|
30060
|
+
const { nativeToken } = useNativeTokenForChain(chain);
|
|
30061
|
+
const { balance: rawBalance, isLoading } = useXrplBalance({
|
|
30062
|
+
chain,
|
|
30063
|
+
token: nativeToken,
|
|
30064
|
+
userAddress: address,
|
|
30065
|
+
enabled: chain?.chainType === ChainType.XRPL,
|
|
30066
|
+
});
|
|
30067
|
+
const balance = useMemo(() => {
|
|
30068
|
+
if (nativeToken?.decimals && rawBalance) {
|
|
30069
|
+
return {
|
|
30070
|
+
decimals: nativeToken.decimals,
|
|
30071
|
+
value: parseToBigInt(rawBalance, nativeToken.decimals),
|
|
30072
|
+
};
|
|
30073
|
+
}
|
|
30074
|
+
}, [nativeToken?.decimals, rawBalance]);
|
|
30075
|
+
return {
|
|
30076
|
+
balance,
|
|
30077
|
+
isLoading,
|
|
30078
|
+
};
|
|
30079
|
+
};
|
|
30080
|
+
const useStellarNativeBalance = ({ address, chain, }) => {
|
|
30081
|
+
const { nativeToken } = useNativeTokenForChain(chain);
|
|
30082
|
+
const { balance: rawBalance, isLoading } = useStellarBalance({
|
|
30083
|
+
chain,
|
|
30084
|
+
token: nativeToken,
|
|
30085
|
+
userAddress: address,
|
|
30086
|
+
enabled: chain?.chainType === ChainType.STELLAR,
|
|
30087
|
+
});
|
|
30088
|
+
const balance = useMemo(() => {
|
|
30089
|
+
if (nativeToken?.decimals && rawBalance) {
|
|
30090
|
+
return {
|
|
30091
|
+
decimals: nativeToken.decimals,
|
|
30092
|
+
value: parseToBigInt(rawBalance, nativeToken.decimals),
|
|
30093
|
+
};
|
|
30094
|
+
}
|
|
30095
|
+
}, [nativeToken?.decimals, rawBalance]);
|
|
30096
|
+
return {
|
|
30097
|
+
balance,
|
|
30098
|
+
isLoading,
|
|
30099
|
+
};
|
|
30100
|
+
};
|
|
30101
|
+
const useNativeBalance = (chain) => {
|
|
30102
|
+
const { connectedAddresses } = useWallet();
|
|
30103
|
+
const { data: cosmosAddressForChain } = useCosmosForChain(chain);
|
|
30104
|
+
// Cosmos is a special case because the address changes on every chain
|
|
30105
|
+
// so we can't use the default cosmos connected address
|
|
30106
|
+
const { balance: nativeCosmosBalance, isLoading: isCosmosLoading } = useCosmosNativeBalance({
|
|
30107
|
+
address: cosmosAddressForChain,
|
|
30108
|
+
chain,
|
|
30109
|
+
});
|
|
30110
|
+
const { balance: nativeEvmBalance, isLoading: isEvmLoading } = useEvmNativeBalance({ address: connectedAddresses[ChainType.EVM], chain });
|
|
30111
|
+
const { balance: nativeBitcoinBalance, isLoading: isBitcoinLoading } = useBitcoinNativeBalance({
|
|
30112
|
+
address: connectedAddresses[ChainType.BTC],
|
|
30113
|
+
chain,
|
|
30114
|
+
});
|
|
30115
|
+
const { balance: nativeSolanaBalance, isLoading: isSolanaLoading } = useSolanaNativeBalance({
|
|
30116
|
+
address: connectedAddresses[ChainType.SOLANA],
|
|
30117
|
+
chain,
|
|
30118
|
+
});
|
|
30119
|
+
const { balance: nativeSuiBalance, isLoading: isSuiLoading } = useSuiNativeBalance({
|
|
30120
|
+
address: connectedAddresses[ChainType.SUI],
|
|
30121
|
+
chain,
|
|
30122
|
+
});
|
|
30123
|
+
const { balance: nativeXrplBalance, isLoading: isXrpLoading } = useXrplNativeBalance({
|
|
30124
|
+
address: connectedAddresses[ChainType.XRPL],
|
|
30125
|
+
chain,
|
|
30126
|
+
});
|
|
30127
|
+
const { balance: nativeStellarBalance, isLoading: isStellarLoading } = useStellarNativeBalance({
|
|
30128
|
+
address: connectedAddresses[ChainType.STELLAR],
|
|
30129
|
+
chain,
|
|
30130
|
+
});
|
|
30131
|
+
const { nativeBalance, nativeBalanceFormatted } = useMemo(() => {
|
|
30132
|
+
let balance;
|
|
30133
|
+
switch (chain?.chainType) {
|
|
30134
|
+
case ChainType.EVM:
|
|
30135
|
+
balance = nativeEvmBalance;
|
|
30136
|
+
break;
|
|
30137
|
+
case ChainType.COSMOS:
|
|
30138
|
+
balance = nativeCosmosBalance;
|
|
30139
|
+
break;
|
|
30140
|
+
case ChainType.BTC:
|
|
30141
|
+
balance = nativeBitcoinBalance;
|
|
30142
|
+
break;
|
|
30143
|
+
case ChainType.SOLANA:
|
|
30144
|
+
balance = nativeSolanaBalance;
|
|
30145
|
+
break;
|
|
30146
|
+
case ChainType.SUI:
|
|
30147
|
+
balance = nativeSuiBalance;
|
|
30148
|
+
break;
|
|
30149
|
+
case ChainType.XRPL:
|
|
30150
|
+
balance = nativeXrplBalance;
|
|
30151
|
+
break;
|
|
30152
|
+
case ChainType.STELLAR:
|
|
30153
|
+
balance = nativeStellarBalance;
|
|
30154
|
+
}
|
|
30155
|
+
const balanceFormatted = !!balance
|
|
30156
|
+
? formatBNToReadable(balance.value, balance.decimals)
|
|
30157
|
+
: undefined;
|
|
30158
|
+
return {
|
|
30159
|
+
nativeBalance: balance,
|
|
30160
|
+
nativeBalanceFormatted: balanceFormatted,
|
|
30161
|
+
};
|
|
30162
|
+
}, [
|
|
30163
|
+
chain?.chainType,
|
|
30164
|
+
nativeEvmBalance,
|
|
30165
|
+
nativeCosmosBalance,
|
|
30166
|
+
nativeBitcoinBalance,
|
|
30167
|
+
nativeSolanaBalance,
|
|
30168
|
+
nativeSuiBalance,
|
|
30169
|
+
nativeXrplBalance,
|
|
30170
|
+
nativeStellarBalance,
|
|
30171
|
+
]);
|
|
30172
|
+
const isLoading = useMemo(() => {
|
|
30173
|
+
if (!chain?.chainType)
|
|
30174
|
+
return false;
|
|
30175
|
+
switch (chain.chainType) {
|
|
30176
|
+
case ChainType.EVM:
|
|
30177
|
+
return isEvmLoading;
|
|
30178
|
+
case ChainType.COSMOS:
|
|
30179
|
+
return isCosmosLoading;
|
|
30180
|
+
case ChainType.BTC:
|
|
30181
|
+
return isBitcoinLoading;
|
|
30182
|
+
case ChainType.SOLANA:
|
|
30183
|
+
return isSolanaLoading;
|
|
30184
|
+
case ChainType.SUI:
|
|
30185
|
+
return isSuiLoading;
|
|
30186
|
+
case ChainType.XRPL:
|
|
30187
|
+
return isXrpLoading;
|
|
30188
|
+
case ChainType.STELLAR:
|
|
30189
|
+
return isStellarLoading;
|
|
30190
|
+
}
|
|
30191
|
+
}, [
|
|
30192
|
+
chain?.chainType,
|
|
30193
|
+
isEvmLoading,
|
|
30194
|
+
isCosmosLoading,
|
|
30195
|
+
isBitcoinLoading,
|
|
30196
|
+
isSolanaLoading,
|
|
30197
|
+
isSuiLoading,
|
|
30198
|
+
isXrpLoading,
|
|
30199
|
+
isStellarLoading,
|
|
30200
|
+
]);
|
|
30201
|
+
return { nativeBalance, nativeBalanceFormatted, isLoading };
|
|
30202
|
+
};
|
|
30203
|
+
|
|
30204
|
+
function useHederaAccountActivation({ address, chain, token }) {
|
|
30205
|
+
const { balance: destNativeEvmBalance } = useEvmNativeBalance({
|
|
30206
|
+
chain,
|
|
30207
|
+
address,
|
|
30208
|
+
});
|
|
30209
|
+
const isHederaAccountActivated = useMemo(() => {
|
|
30210
|
+
if (token?.chainId !== CHAIN_IDS.HEDERA)
|
|
30211
|
+
return true;
|
|
30212
|
+
if (token.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase())
|
|
30213
|
+
return true;
|
|
30214
|
+
return (!!destNativeEvmBalance?.value && destNativeEvmBalance.value > BigInt(0));
|
|
30215
|
+
}, [token?.chainId, token?.address, destNativeEvmBalance?.value]);
|
|
30216
|
+
return {
|
|
30217
|
+
isHederaAccountActivated,
|
|
30218
|
+
};
|
|
30219
|
+
}
|
|
30220
|
+
|
|
29681
30221
|
const useAddressBookStore = create(persist((set) => ({
|
|
29682
30222
|
addressBook: [],
|
|
29683
30223
|
add: (newAddressData) => {
|
|
@@ -30043,473 +30583,6 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
30043
30583
|
};
|
|
30044
30584
|
};
|
|
30045
30585
|
|
|
30046
|
-
function useNativeTokenForChain(chain) {
|
|
30047
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens();
|
|
30048
|
-
const getTokensForChainType = () => {
|
|
30049
|
-
if (!chain?.chainType)
|
|
30050
|
-
return [];
|
|
30051
|
-
switch (chain.chainType) {
|
|
30052
|
-
case ChainType.EVM:
|
|
30053
|
-
return evmTokens;
|
|
30054
|
-
case ChainType.COSMOS:
|
|
30055
|
-
return cosmosTokens;
|
|
30056
|
-
case ChainType.SOLANA:
|
|
30057
|
-
return solanaTokens;
|
|
30058
|
-
case ChainType.BTC:
|
|
30059
|
-
return bitcoinTokens;
|
|
30060
|
-
case ChainType.SUI:
|
|
30061
|
-
return suiTokens;
|
|
30062
|
-
case ChainType.XRPL:
|
|
30063
|
-
return xrplTokens;
|
|
30064
|
-
case ChainType.STELLAR:
|
|
30065
|
-
return stellarTokens;
|
|
30066
|
-
}
|
|
30067
|
-
};
|
|
30068
|
-
const nativeTokenForChainType = useMemo(() => {
|
|
30069
|
-
return findNativeToken(getTokensForChainType(), chain);
|
|
30070
|
-
}, [chain]);
|
|
30071
|
-
return { nativeToken: nativeTokenForChainType };
|
|
30072
|
-
}
|
|
30073
|
-
|
|
30074
|
-
const useEvmNativeBalance = ({ address, chain, }) => {
|
|
30075
|
-
const { isChainTypeConnected } = useWallet();
|
|
30076
|
-
const { data: nativeEvmBalance, isLoading } = useBalance({
|
|
30077
|
-
address: address,
|
|
30078
|
-
chainId: Number(chain?.chainId),
|
|
30079
|
-
query: {
|
|
30080
|
-
enabled: isChainTypeConnected(ChainType.EVM) && !!address,
|
|
30081
|
-
refetchInterval: 10000,
|
|
30082
|
-
staleTime: 5000,
|
|
30083
|
-
refetchOnWindowFocus: true,
|
|
30084
|
-
refetchOnMount: true,
|
|
30085
|
-
},
|
|
30086
|
-
});
|
|
30087
|
-
const balance = useMemo(() => {
|
|
30088
|
-
if (nativeEvmBalance?.decimals && nativeEvmBalance?.value) {
|
|
30089
|
-
return {
|
|
30090
|
-
decimals: nativeEvmBalance.decimals,
|
|
30091
|
-
value: nativeEvmBalance.value,
|
|
30092
|
-
};
|
|
30093
|
-
}
|
|
30094
|
-
return;
|
|
30095
|
-
}, [nativeEvmBalance?.decimals, nativeEvmBalance?.value]);
|
|
30096
|
-
return {
|
|
30097
|
-
balance,
|
|
30098
|
-
isLoading,
|
|
30099
|
-
};
|
|
30100
|
-
};
|
|
30101
|
-
const useCosmosNativeBalance = ({ address, chain, }) => {
|
|
30102
|
-
const { isConnected: isCosmosConnected } = useCosmosContext();
|
|
30103
|
-
const { nativeToken: nativeCosmosToken } = useNativeTokenForChain(chain);
|
|
30104
|
-
const { balance: rawBalance, isLoading } = useCosmosBalance({
|
|
30105
|
-
chain,
|
|
30106
|
-
token: nativeCosmosToken,
|
|
30107
|
-
userAddress: address,
|
|
30108
|
-
enabled: isCosmosConnected && chain?.chainType === ChainType.COSMOS,
|
|
30109
|
-
refreshIntervalMs: 10000,
|
|
30110
|
-
});
|
|
30111
|
-
const balance = useMemo(() => {
|
|
30112
|
-
if (nativeCosmosToken?.decimals && rawBalance) {
|
|
30113
|
-
return {
|
|
30114
|
-
decimals: nativeCosmosToken.decimals,
|
|
30115
|
-
value: parseToBigInt(rawBalance, nativeCosmosToken.decimals),
|
|
30116
|
-
};
|
|
30117
|
-
}
|
|
30118
|
-
}, [nativeCosmosToken?.decimals, rawBalance]);
|
|
30119
|
-
return { balance, isLoading };
|
|
30120
|
-
};
|
|
30121
|
-
const useBitcoinNativeBalance = ({ chain, address, }) => {
|
|
30122
|
-
const { nativeToken } = useNativeTokenForChain(chain);
|
|
30123
|
-
const { data: rawBalance = "0", isLoading } = useQuery(keys().balance(chain?.chainId, nativeToken?.address, address), async () => {
|
|
30124
|
-
if (!address || !nativeToken)
|
|
30125
|
-
return "0";
|
|
30126
|
-
const balance = await getBitcoinNativeBalance(address);
|
|
30127
|
-
return formatBNToReadable(balance, nativeToken.decimals);
|
|
30128
|
-
}, {
|
|
30129
|
-
enabled: chain?.chainType === ChainType.BTC &&
|
|
30130
|
-
nativeToken?.decimals != null &&
|
|
30131
|
-
isWalletAddressValid(chain, address),
|
|
30132
|
-
refetchInterval: 40000,
|
|
30133
|
-
staleTime: 20000,
|
|
30134
|
-
refetchOnWindowFocus: true,
|
|
30135
|
-
refetchOnMount: true,
|
|
30136
|
-
});
|
|
30137
|
-
const balance = useMemo(() => {
|
|
30138
|
-
if (nativeToken?.decimals && rawBalance) {
|
|
30139
|
-
return {
|
|
30140
|
-
decimals: nativeToken.decimals,
|
|
30141
|
-
value: parseToBigInt(rawBalance, nativeToken.decimals),
|
|
30142
|
-
};
|
|
30143
|
-
}
|
|
30144
|
-
}, [nativeToken?.decimals, rawBalance]);
|
|
30145
|
-
return {
|
|
30146
|
-
balance,
|
|
30147
|
-
isLoading,
|
|
30148
|
-
};
|
|
30149
|
-
};
|
|
30150
|
-
const useSolanaNativeBalance = ({ chain, address, }) => {
|
|
30151
|
-
const { nativeToken } = useNativeTokenForChain(chain);
|
|
30152
|
-
const { data: rawBalance, isLoading } = useQuery(keys().balance(chain?.chainId, nativeToken?.address, address), async () => {
|
|
30153
|
-
const balance = await getSolanaNativeBalance(address);
|
|
30154
|
-
return formatBNToReadable(balance, nativeToken.decimals);
|
|
30155
|
-
}, {
|
|
30156
|
-
enabled: !!address &&
|
|
30157
|
-
nativeToken?.decimals != null &&
|
|
30158
|
-
chain?.chainType === ChainType.SOLANA,
|
|
30159
|
-
refetchInterval: 40000,
|
|
30160
|
-
staleTime: 20000,
|
|
30161
|
-
refetchOnWindowFocus: true,
|
|
30162
|
-
refetchOnMount: true,
|
|
30163
|
-
});
|
|
30164
|
-
const balance = useMemo(() => {
|
|
30165
|
-
if (nativeToken?.decimals && rawBalance) {
|
|
30166
|
-
return {
|
|
30167
|
-
decimals: nativeToken.decimals,
|
|
30168
|
-
value: parseToBigInt(rawBalance, nativeToken.decimals),
|
|
30169
|
-
};
|
|
30170
|
-
}
|
|
30171
|
-
}, [nativeToken?.decimals, rawBalance]);
|
|
30172
|
-
return {
|
|
30173
|
-
balance,
|
|
30174
|
-
isLoading,
|
|
30175
|
-
};
|
|
30176
|
-
};
|
|
30177
|
-
const useSuiNativeBalance = ({ address, chain, }) => {
|
|
30178
|
-
const { nativeToken } = useNativeTokenForChain(chain);
|
|
30179
|
-
const { balance: rawBalance, isLoading } = useSuiBalance({
|
|
30180
|
-
chain,
|
|
30181
|
-
token: nativeToken,
|
|
30182
|
-
userAddress: address,
|
|
30183
|
-
});
|
|
30184
|
-
const balance = useMemo(() => {
|
|
30185
|
-
if (nativeToken?.decimals && rawBalance) {
|
|
30186
|
-
return {
|
|
30187
|
-
decimals: nativeToken.decimals,
|
|
30188
|
-
value: parseToBigInt(rawBalance, nativeToken.decimals),
|
|
30189
|
-
};
|
|
30190
|
-
}
|
|
30191
|
-
}, [nativeToken?.decimals, rawBalance]);
|
|
30192
|
-
return {
|
|
30193
|
-
balance,
|
|
30194
|
-
isLoading,
|
|
30195
|
-
};
|
|
30196
|
-
};
|
|
30197
|
-
const useXrplNativeBalance = ({ address, chain, }) => {
|
|
30198
|
-
const { nativeToken } = useNativeTokenForChain(chain);
|
|
30199
|
-
const { balance: rawBalance, isLoading } = useXrplBalance({
|
|
30200
|
-
chain,
|
|
30201
|
-
token: nativeToken,
|
|
30202
|
-
userAddress: address,
|
|
30203
|
-
enabled: chain?.chainType === ChainType.XRPL,
|
|
30204
|
-
});
|
|
30205
|
-
const balance = useMemo(() => {
|
|
30206
|
-
if (nativeToken?.decimals && rawBalance) {
|
|
30207
|
-
return {
|
|
30208
|
-
decimals: nativeToken.decimals,
|
|
30209
|
-
value: parseToBigInt(rawBalance, nativeToken.decimals),
|
|
30210
|
-
};
|
|
30211
|
-
}
|
|
30212
|
-
}, [nativeToken?.decimals, rawBalance]);
|
|
30213
|
-
return {
|
|
30214
|
-
balance,
|
|
30215
|
-
isLoading,
|
|
30216
|
-
};
|
|
30217
|
-
};
|
|
30218
|
-
const useStellarNativeBalance = ({ address, chain, }) => {
|
|
30219
|
-
const { nativeToken } = useNativeTokenForChain(chain);
|
|
30220
|
-
const { balance: rawBalance, isLoading } = useStellarBalance({
|
|
30221
|
-
chain,
|
|
30222
|
-
token: nativeToken,
|
|
30223
|
-
userAddress: address,
|
|
30224
|
-
enabled: chain?.chainType === ChainType.STELLAR,
|
|
30225
|
-
});
|
|
30226
|
-
const balance = useMemo(() => {
|
|
30227
|
-
if (nativeToken?.decimals && rawBalance) {
|
|
30228
|
-
return {
|
|
30229
|
-
decimals: nativeToken.decimals,
|
|
30230
|
-
value: parseToBigInt(rawBalance, nativeToken.decimals),
|
|
30231
|
-
};
|
|
30232
|
-
}
|
|
30233
|
-
}, [nativeToken?.decimals, rawBalance]);
|
|
30234
|
-
return {
|
|
30235
|
-
balance,
|
|
30236
|
-
isLoading,
|
|
30237
|
-
};
|
|
30238
|
-
};
|
|
30239
|
-
const useNativeBalance = (chain) => {
|
|
30240
|
-
const { connectedAddresses } = useWallet();
|
|
30241
|
-
const { data: cosmosAddressForChain } = useCosmosForChain(chain);
|
|
30242
|
-
// Cosmos is a special case because the address changes on every chain
|
|
30243
|
-
// so we can't use the default cosmos connected address
|
|
30244
|
-
const { balance: nativeCosmosBalance, isLoading: isCosmosLoading } = useCosmosNativeBalance({
|
|
30245
|
-
address: cosmosAddressForChain,
|
|
30246
|
-
chain,
|
|
30247
|
-
});
|
|
30248
|
-
const { balance: nativeEvmBalance, isLoading: isEvmLoading } = useEvmNativeBalance({ address: connectedAddresses[ChainType.EVM], chain });
|
|
30249
|
-
const { balance: nativeBitcoinBalance, isLoading: isBitcoinLoading } = useBitcoinNativeBalance({
|
|
30250
|
-
address: connectedAddresses[ChainType.BTC],
|
|
30251
|
-
chain,
|
|
30252
|
-
});
|
|
30253
|
-
const { balance: nativeSolanaBalance, isLoading: isSolanaLoading } = useSolanaNativeBalance({
|
|
30254
|
-
address: connectedAddresses[ChainType.SOLANA],
|
|
30255
|
-
chain,
|
|
30256
|
-
});
|
|
30257
|
-
const { balance: nativeSuiBalance, isLoading: isSuiLoading } = useSuiNativeBalance({
|
|
30258
|
-
address: connectedAddresses[ChainType.SUI],
|
|
30259
|
-
chain,
|
|
30260
|
-
});
|
|
30261
|
-
const { balance: nativeXrplBalance, isLoading: isXrpLoading } = useXrplNativeBalance({
|
|
30262
|
-
address: connectedAddresses[ChainType.XRPL],
|
|
30263
|
-
chain,
|
|
30264
|
-
});
|
|
30265
|
-
const { balance: nativeStellarBalance, isLoading: isStellarLoading } = useStellarNativeBalance({
|
|
30266
|
-
address: connectedAddresses[ChainType.STELLAR],
|
|
30267
|
-
chain,
|
|
30268
|
-
});
|
|
30269
|
-
const { nativeBalance, nativeBalanceFormatted } = useMemo(() => {
|
|
30270
|
-
let balance;
|
|
30271
|
-
switch (chain?.chainType) {
|
|
30272
|
-
case ChainType.EVM:
|
|
30273
|
-
balance = nativeEvmBalance;
|
|
30274
|
-
break;
|
|
30275
|
-
case ChainType.COSMOS:
|
|
30276
|
-
balance = nativeCosmosBalance;
|
|
30277
|
-
break;
|
|
30278
|
-
case ChainType.BTC:
|
|
30279
|
-
balance = nativeBitcoinBalance;
|
|
30280
|
-
break;
|
|
30281
|
-
case ChainType.SOLANA:
|
|
30282
|
-
balance = nativeSolanaBalance;
|
|
30283
|
-
break;
|
|
30284
|
-
case ChainType.SUI:
|
|
30285
|
-
balance = nativeSuiBalance;
|
|
30286
|
-
break;
|
|
30287
|
-
case ChainType.XRPL:
|
|
30288
|
-
balance = nativeXrplBalance;
|
|
30289
|
-
break;
|
|
30290
|
-
case ChainType.STELLAR:
|
|
30291
|
-
balance = nativeStellarBalance;
|
|
30292
|
-
}
|
|
30293
|
-
const balanceFormatted = !!balance
|
|
30294
|
-
? formatBNToReadable(balance.value, balance.decimals)
|
|
30295
|
-
: undefined;
|
|
30296
|
-
return {
|
|
30297
|
-
nativeBalance: balance,
|
|
30298
|
-
nativeBalanceFormatted: balanceFormatted,
|
|
30299
|
-
};
|
|
30300
|
-
}, [
|
|
30301
|
-
chain?.chainType,
|
|
30302
|
-
nativeEvmBalance,
|
|
30303
|
-
nativeCosmosBalance,
|
|
30304
|
-
nativeBitcoinBalance,
|
|
30305
|
-
nativeSolanaBalance,
|
|
30306
|
-
nativeSuiBalance,
|
|
30307
|
-
nativeXrplBalance,
|
|
30308
|
-
nativeStellarBalance,
|
|
30309
|
-
]);
|
|
30310
|
-
const isLoading = useMemo(() => {
|
|
30311
|
-
if (!chain?.chainType)
|
|
30312
|
-
return false;
|
|
30313
|
-
switch (chain.chainType) {
|
|
30314
|
-
case ChainType.EVM:
|
|
30315
|
-
return isEvmLoading;
|
|
30316
|
-
case ChainType.COSMOS:
|
|
30317
|
-
return isCosmosLoading;
|
|
30318
|
-
case ChainType.BTC:
|
|
30319
|
-
return isBitcoinLoading;
|
|
30320
|
-
case ChainType.SOLANA:
|
|
30321
|
-
return isSolanaLoading;
|
|
30322
|
-
case ChainType.SUI:
|
|
30323
|
-
return isSuiLoading;
|
|
30324
|
-
case ChainType.XRPL:
|
|
30325
|
-
return isXrpLoading;
|
|
30326
|
-
case ChainType.STELLAR:
|
|
30327
|
-
return isStellarLoading;
|
|
30328
|
-
}
|
|
30329
|
-
}, [
|
|
30330
|
-
chain?.chainType,
|
|
30331
|
-
isEvmLoading,
|
|
30332
|
-
isCosmosLoading,
|
|
30333
|
-
isBitcoinLoading,
|
|
30334
|
-
isSolanaLoading,
|
|
30335
|
-
isSuiLoading,
|
|
30336
|
-
isXrpLoading,
|
|
30337
|
-
isStellarLoading,
|
|
30338
|
-
]);
|
|
30339
|
-
return { nativeBalance, nativeBalanceFormatted, isLoading };
|
|
30340
|
-
};
|
|
30341
|
-
|
|
30342
|
-
const DEFAULT_REFRESH_INTERVAL_MS = 15000;
|
|
30343
|
-
const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
30344
|
-
const { isChainTypeConnected } = useWallet();
|
|
30345
|
-
const isNativeToken = token?.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
|
|
30346
|
-
const userAddressParsed = userAddress;
|
|
30347
|
-
// Only fetch using useBalance if it's a native token
|
|
30348
|
-
const { data: nativeBalance, isLoading: isNativeTokenLoading } = useBalance({
|
|
30349
|
-
address: userAddressParsed,
|
|
30350
|
-
chainId: Number(chain?.chainId),
|
|
30351
|
-
query: {
|
|
30352
|
-
enabled: enabled &&
|
|
30353
|
-
!!userAddress &&
|
|
30354
|
-
isNativeToken &&
|
|
30355
|
-
!!chain &&
|
|
30356
|
-
chain.chainType === ChainType.EVM &&
|
|
30357
|
-
isChainTypeConnected(chain.chainType),
|
|
30358
|
-
refetchInterval: refreshIntervalMs,
|
|
30359
|
-
retry: 2,
|
|
30360
|
-
},
|
|
30361
|
-
});
|
|
30362
|
-
// Only fetch using useReadContract if it's not a native token
|
|
30363
|
-
// This is temporary, because of wagmi error: https://github.com/wevm/wagmi/issues/4353
|
|
30364
|
-
const { data: erc20Balance, isLoading: isErc20Loading } = useReadContract({
|
|
30365
|
-
address: token?.address,
|
|
30366
|
-
abi: erc20Abi,
|
|
30367
|
-
functionName: "balanceOf",
|
|
30368
|
-
args: [userAddressParsed],
|
|
30369
|
-
chainId: Number(chain?.chainId),
|
|
30370
|
-
query: {
|
|
30371
|
-
enabled: isChainTypeConnected(ChainType.EVM) &&
|
|
30372
|
-
enabled &&
|
|
30373
|
-
!!userAddress &&
|
|
30374
|
-
!isNativeToken,
|
|
30375
|
-
refetchInterval: refreshIntervalMs,
|
|
30376
|
-
retry: 2,
|
|
30377
|
-
},
|
|
30378
|
-
});
|
|
30379
|
-
if (isNativeToken) {
|
|
30380
|
-
return {
|
|
30381
|
-
isLoading: isNativeTokenLoading,
|
|
30382
|
-
balance: nativeBalance
|
|
30383
|
-
? formatBNToReadable(nativeBalance.value, nativeBalance.decimals)
|
|
30384
|
-
: "0",
|
|
30385
|
-
};
|
|
30386
|
-
}
|
|
30387
|
-
return {
|
|
30388
|
-
balance: erc20Balance && token
|
|
30389
|
-
? formatBNToReadable(erc20Balance, token.decimals)
|
|
30390
|
-
: "0",
|
|
30391
|
-
isLoading: isErc20Loading,
|
|
30392
|
-
};
|
|
30393
|
-
};
|
|
30394
|
-
const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
30395
|
-
const { isConnected } = useCosmosContext();
|
|
30396
|
-
const { data: balance = "0", isLoading } = useQuery({
|
|
30397
|
-
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
30398
|
-
queryFn: async () => {
|
|
30399
|
-
if (!userAddress || !token || chain?.chainType !== ChainType.COSMOS) {
|
|
30400
|
-
return "0";
|
|
30401
|
-
}
|
|
30402
|
-
const isAddressValid = isCosmosAddressValid(chain.bech32Config.bech32PrefixAccAddr, userAddress);
|
|
30403
|
-
if (!isAddressValid)
|
|
30404
|
-
return "0";
|
|
30405
|
-
const balanceBn = await getCosmosTokenBalance(chain, userAddress, token.address);
|
|
30406
|
-
return formatBNToReadable(balanceBn, token.decimals);
|
|
30407
|
-
},
|
|
30408
|
-
enabled: isConnected &&
|
|
30409
|
-
enabled &&
|
|
30410
|
-
!!userAddress &&
|
|
30411
|
-
!!token &&
|
|
30412
|
-
chain?.chainType === ChainType.COSMOS,
|
|
30413
|
-
refetchInterval: refreshIntervalMs,
|
|
30414
|
-
retry: 2,
|
|
30415
|
-
});
|
|
30416
|
-
return { balance, isLoading };
|
|
30417
|
-
};
|
|
30418
|
-
const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
30419
|
-
const { data: balance = "0", isLoading } = useQuery({
|
|
30420
|
-
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
30421
|
-
queryFn: async () => {
|
|
30422
|
-
if (!userAddress || !token)
|
|
30423
|
-
return "0";
|
|
30424
|
-
const balanceBn = await getSolanaTokenBalance(userAddress, token.address);
|
|
30425
|
-
return formatBNToReadable(balanceBn, token.decimals);
|
|
30426
|
-
},
|
|
30427
|
-
enabled: enabled &&
|
|
30428
|
-
!!userAddress &&
|
|
30429
|
-
!!token &&
|
|
30430
|
-
chain?.chainType === ChainType.SOLANA,
|
|
30431
|
-
refetchInterval: refreshIntervalMs,
|
|
30432
|
-
retry: 2,
|
|
30433
|
-
});
|
|
30434
|
-
return { balance, isLoading };
|
|
30435
|
-
};
|
|
30436
|
-
// TODO: implement fetching balances for all bitcoin tokens
|
|
30437
|
-
const useBitcoinBalance = ({ userAddress, chain, }) => {
|
|
30438
|
-
const { balance: balanceBn, isLoading } = useBitcoinNativeBalance({
|
|
30439
|
-
address: userAddress,
|
|
30440
|
-
chain,
|
|
30441
|
-
});
|
|
30442
|
-
const balance = useMemo(() => {
|
|
30443
|
-
if (!balanceBn)
|
|
30444
|
-
return "0";
|
|
30445
|
-
return formatBNToReadable(balanceBn?.value, balanceBn?.decimals);
|
|
30446
|
-
}, [balanceBn]);
|
|
30447
|
-
return { balance, isLoading };
|
|
30448
|
-
};
|
|
30449
|
-
const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
30450
|
-
const { data: balance = "0", isLoading } = useQuery({
|
|
30451
|
-
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
30452
|
-
queryFn: async () => {
|
|
30453
|
-
if (!userAddress ||
|
|
30454
|
-
token?.type !== ChainType.SUI ||
|
|
30455
|
-
chain?.chainType !== ChainType.SUI) {
|
|
30456
|
-
throw new Error("Invalid SUI balance query parameters");
|
|
30457
|
-
}
|
|
30458
|
-
const balanceBn = await getSuiTokenBalance(userAddress, token.address, chain.rpc);
|
|
30459
|
-
return formatBNToReadable(balanceBn, token.decimals) ?? "0";
|
|
30460
|
-
},
|
|
30461
|
-
enabled: enabled &&
|
|
30462
|
-
!!userAddress &&
|
|
30463
|
-
!!chain?.rpc &&
|
|
30464
|
-
token?.type === ChainType.SUI &&
|
|
30465
|
-
chain?.chainType === ChainType.SUI &&
|
|
30466
|
-
isSuiAddressValid(userAddress),
|
|
30467
|
-
refetchInterval: refreshIntervalMs,
|
|
30468
|
-
retry: 2,
|
|
30469
|
-
});
|
|
30470
|
-
return { balance, isLoading };
|
|
30471
|
-
};
|
|
30472
|
-
const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
30473
|
-
const { data: balance = "0", isLoading } = useQuery({
|
|
30474
|
-
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
30475
|
-
queryFn: async () => {
|
|
30476
|
-
if (!userAddress || !token || !chain)
|
|
30477
|
-
return "0";
|
|
30478
|
-
const balanceBn = await getXrplTokenBalance(userAddress, token, chain);
|
|
30479
|
-
return formatBNToReadable(balanceBn, token.decimals) ?? "0";
|
|
30480
|
-
},
|
|
30481
|
-
enabled: enabled &&
|
|
30482
|
-
!!userAddress &&
|
|
30483
|
-
!!token &&
|
|
30484
|
-
!!chain?.rpc &&
|
|
30485
|
-
chain?.chainType === ChainType.XRPL &&
|
|
30486
|
-
isXrplAddressValid(userAddress),
|
|
30487
|
-
refetchInterval: refreshIntervalMs,
|
|
30488
|
-
retry: 2,
|
|
30489
|
-
});
|
|
30490
|
-
return { balance, isLoading };
|
|
30491
|
-
};
|
|
30492
|
-
const useStellarBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
30493
|
-
const { data: balance = "0", isLoading } = useQuery({
|
|
30494
|
-
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
30495
|
-
queryFn: async () => {
|
|
30496
|
-
if (!userAddress || !token || !chain)
|
|
30497
|
-
return "0";
|
|
30498
|
-
const balanceBn = await getStellarTokenBalance(userAddress, token, chain);
|
|
30499
|
-
return formatBNToReadable(balanceBn, token.decimals) ?? "0";
|
|
30500
|
-
},
|
|
30501
|
-
enabled: enabled &&
|
|
30502
|
-
!!userAddress &&
|
|
30503
|
-
!!token &&
|
|
30504
|
-
!!chain?.rpc &&
|
|
30505
|
-
chain?.chainType === ChainType.STELLAR &&
|
|
30506
|
-
isStellarAddressValid(userAddress),
|
|
30507
|
-
refetchInterval: refreshIntervalMs,
|
|
30508
|
-
retry: 2,
|
|
30509
|
-
});
|
|
30510
|
-
return { balance, isLoading };
|
|
30511
|
-
};
|
|
30512
|
-
|
|
30513
30586
|
/**
|
|
30514
30587
|
* Hook to get balance depending on the chain type
|
|
30515
30588
|
* @param {ChainData} chain
|
|
@@ -31022,6 +31095,10 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
31022
31095
|
const feeData = await client.getFeeData();
|
|
31023
31096
|
if (!feeData.maxFeePerGas)
|
|
31024
31097
|
return BigInt(0);
|
|
31098
|
+
let maxFeePerGas = feeData.maxFeePerGas;
|
|
31099
|
+
if (token.chainId === CHAIN_IDS.HEDERA) {
|
|
31100
|
+
maxFeePerGas = scaleWeiToHbar(BigInt(feeData.maxFeePerGas));
|
|
31101
|
+
}
|
|
31025
31102
|
const dummyAddress = "0x1111111111111111111111111111111111111111";
|
|
31026
31103
|
// Some RPC providers require the sender to have enough balance, otherwise estimation reverts
|
|
31027
31104
|
// so we'll try to use the user provided address when possible
|
|
@@ -31033,7 +31110,7 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
31033
31110
|
value: 1,
|
|
31034
31111
|
chainId: chain.chainId,
|
|
31035
31112
|
});
|
|
31036
|
-
return gas *
|
|
31113
|
+
return gas * maxFeePerGas;
|
|
31037
31114
|
}
|
|
31038
31115
|
const erc20Interface = new Interface(erc20Abi);
|
|
31039
31116
|
const data = erc20Interface.encodeFunctionData("transfer", [
|
|
@@ -31046,7 +31123,7 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
31046
31123
|
data,
|
|
31047
31124
|
chainId: chain.chainId,
|
|
31048
31125
|
});
|
|
31049
|
-
return gas *
|
|
31126
|
+
return gas * maxFeePerGas;
|
|
31050
31127
|
}
|
|
31051
31128
|
case ChainType.COSMOS: {
|
|
31052
31129
|
// TODO: get gas estimation from backend
|
|
@@ -31142,9 +31219,13 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
|
31142
31219
|
async function sendTransactionEvm({ to, amount, token, signer, rpcUrl, }) {
|
|
31143
31220
|
const isNativeToken = token.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
|
|
31144
31221
|
if (isNativeToken) {
|
|
31222
|
+
let value = amount;
|
|
31223
|
+
if (token.chainId === CHAIN_IDS.HEDERA) {
|
|
31224
|
+
value = scaleHbarToWei(BigInt(amount)).toString();
|
|
31225
|
+
}
|
|
31145
31226
|
const tx = await signer.sendTransaction({
|
|
31146
31227
|
to,
|
|
31147
|
-
value
|
|
31228
|
+
value,
|
|
31148
31229
|
chainId: Number(token.chainId),
|
|
31149
31230
|
});
|
|
31150
31231
|
return {
|
|
@@ -31972,7 +32053,12 @@ const useErc20Allowance = ({ tokenAddress, ownerAddress, spenderAddress, amount
|
|
|
31972
32053
|
const parsedOwnerAddress = parseEvmAddress(ownerAddress);
|
|
31973
32054
|
const parsedSpenderAddress = parseEvmAddress(spenderAddress);
|
|
31974
32055
|
const isNativeToken = parsedTokenAddress?.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
|
|
31975
|
-
const isDepositAddressTx = transactionType
|
|
32056
|
+
const isDepositAddressTx = !!transactionType &&
|
|
32057
|
+
[
|
|
32058
|
+
SquidDataType.DepositAddressCalldata,
|
|
32059
|
+
SquidDataType.DepositAddressWithSignature,
|
|
32060
|
+
SquidDataType.DepositAddressWithMemo,
|
|
32061
|
+
].includes(transactionType);
|
|
31976
32062
|
const result = useReadContract({
|
|
31977
32063
|
abi: erc20Abi,
|
|
31978
32064
|
address: parsedTokenAddress ?? undefined,
|
|
@@ -35258,7 +35344,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
35258
35344
|
* Set the transaction state in the store
|
|
35259
35345
|
* This is useful to access the latest transaction from any hook
|
|
35260
35346
|
*/
|
|
35261
|
-
const setTransactionState = useCallback(({ route, txHash, transactionIdForStatus, nonce, status, sourceStatus, userAddress, axelarUrl, id, }) => {
|
|
35347
|
+
const setTransactionState = useCallback(({ route, txHash, transactionIdForStatus, nonce, status, sourceStatus, userAddress, axelarUrl, id, depositTxVerificationSignature, }) => {
|
|
35262
35348
|
if (!route?.transactionRequest)
|
|
35263
35349
|
return undefined;
|
|
35264
35350
|
const { quoteId } = route;
|
|
@@ -35277,10 +35363,11 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
35277
35363
|
sourceTxExplorerUrl: getSourceExplorerTxUrl(fromChain, txHash),
|
|
35278
35364
|
sourceExplorerImgUrl: fromChain?.chainIconURI,
|
|
35279
35365
|
axelarUrl,
|
|
35366
|
+
depositTxVerificationSignature,
|
|
35280
35367
|
};
|
|
35281
35368
|
setTransactionStoreState(id, tx);
|
|
35282
35369
|
return tx;
|
|
35283
|
-
}, [fromChain,
|
|
35370
|
+
}, [fromChain, toChain, setTransactionStoreState]);
|
|
35284
35371
|
const getCosmosSignerClient = useCallback(async () => {
|
|
35285
35372
|
if (!fromChain)
|
|
35286
35373
|
return null;
|
|
@@ -35458,6 +35545,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
35458
35545
|
sourceStatus: TransactionStatus.ONGOING,
|
|
35459
35546
|
axelarUrl: undefined,
|
|
35460
35547
|
id,
|
|
35548
|
+
depositTxVerificationSignature: txResponse.depositTxVerificationSignature,
|
|
35461
35549
|
});
|
|
35462
35550
|
if (txParams) {
|
|
35463
35551
|
addSwapTransaction({
|
|
@@ -35652,7 +35740,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
35652
35740
|
if (!route?.transactionRequest || !xrplSigner) {
|
|
35653
35741
|
throw new Error("Need all parameters");
|
|
35654
35742
|
}
|
|
35655
|
-
if (route.transactionRequest
|
|
35743
|
+
if (!isOnChainTxData(route.transactionRequest)) {
|
|
35656
35744
|
throw new Error("Invalid route type");
|
|
35657
35745
|
}
|
|
35658
35746
|
const { data } = route.transactionRequest;
|
|
@@ -35688,10 +35776,10 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
35688
35776
|
}
|
|
35689
35777
|
}, {});
|
|
35690
35778
|
const swapMutationSui = useMutation(async ({ id, route }) => {
|
|
35691
|
-
if (!route || !suiSigner || !fromChain) {
|
|
35779
|
+
if (!route?.transactionRequest || !suiSigner || !fromChain) {
|
|
35692
35780
|
throw new Error("Need all parameters");
|
|
35693
35781
|
}
|
|
35694
|
-
if (route.transactionRequest
|
|
35782
|
+
if (!isOnChainTxData(route.transactionRequest)) {
|
|
35695
35783
|
throw new Error("Invalid route type");
|
|
35696
35784
|
}
|
|
35697
35785
|
const suiWalletState = connectedWalletsByChainType[ChainType.SUI];
|
|
@@ -35742,9 +35830,15 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
35742
35830
|
});
|
|
35743
35831
|
}, {});
|
|
35744
35832
|
const swapMutationStellar = useMutation(async ({ id, route }) => {
|
|
35745
|
-
if (!stellarSigner ||
|
|
35833
|
+
if (!stellarSigner ||
|
|
35834
|
+
!route?.transactionRequest ||
|
|
35835
|
+
!squid ||
|
|
35836
|
+
!fromChain) {
|
|
35746
35837
|
throw new Error("Need all parameters");
|
|
35747
35838
|
}
|
|
35839
|
+
if (!isOnChainTxData(route.transactionRequest)) {
|
|
35840
|
+
throw new Error("Invalid route type");
|
|
35841
|
+
}
|
|
35748
35842
|
const fromChainId = route.params.fromChain;
|
|
35749
35843
|
const stellarNetwork = getStellarNetwork(fromChainId);
|
|
35750
35844
|
if (stellarNetwork == null) {
|
|
@@ -35847,11 +35941,13 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
35847
35941
|
squidRoute,
|
|
35848
35942
|
]);
|
|
35849
35943
|
const swapMutation = useMutation(async (mutationParams) => {
|
|
35850
|
-
if (!mutationParams.route)
|
|
35851
|
-
throw new Error("
|
|
35944
|
+
if (!mutationParams.route?.transactionRequest) {
|
|
35945
|
+
throw new Error("Route is required");
|
|
35946
|
+
}
|
|
35852
35947
|
const sourceChain = findChain(mutationParams.route.params?.fromChain);
|
|
35853
35948
|
if (!sourceChain)
|
|
35854
35949
|
throw new Error("Could not find source chain");
|
|
35950
|
+
// After getting signature (if needed), continue with the swap flow
|
|
35855
35951
|
switch (sourceChain.chainType) {
|
|
35856
35952
|
case ChainType.COSMOS: {
|
|
35857
35953
|
return swapMutationCosmos.mutateAsync(mutationParams);
|
|
@@ -36040,7 +36136,7 @@ const useGetRoute = () => {
|
|
|
36040
36136
|
};
|
|
36041
36137
|
const useGetRouteWrapper = ({ enabled, cacheTime = 5 * 60 * 1000, // 5 minutes
|
|
36042
36138
|
staleTime = 60 * 1000, // 1 minute
|
|
36043
|
-
refetchOnWindowFocus = (query) => Date.now() - query.state.dataUpdatedAt >
|
|
36139
|
+
refetchOnWindowFocus = (query) => Date.now() - query.state.dataUpdatedAt > DEFAULT_ROUTE_REFETCH_INTERVAL, // Update if older than default refetch interval, when window is focused
|
|
36044
36140
|
refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true, }) => {
|
|
36045
36141
|
const config = useConfigStore((state) => state.config);
|
|
36046
36142
|
const squid = useSquidStore((state) => state.squid);
|
|
@@ -36792,5 +36888,5 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
36792
36888
|
React.createElement(CosmosProvider, null, children)))))))))) : (placeholder);
|
|
36793
36889
|
};
|
|
36794
36890
|
|
|
36795
|
-
export {
|
|
36796
|
-
//# sourceMappingURL=index-
|
|
36891
|
+
export { useSwap as $, AxelarStatusResponseType as A, useKeyboardNavigation as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useSquidQueryClient as E, useSquid as F, useStellarAccountActivation as G, HistoryTxType as H, useHederaAccountActivation as I, useAddressBookStore as J, useAssetsColorsStore as K, useFavoriteTokensStore as L, useHistoryStore as M, Nr as N, useSendTransactionStore as O, useConfigStore as P, QueryKeys as Q, useSquidStore as R, SquidStatusErrorType as S, TransactionErrorType as T, useSwapRoutePersistStore as U, useTransactionStore as V, Wo as W, XamanXrplNetwork as X, ConnectingWalletStatus as Y, useWalletStore as Z, useDepositAddress as _, WindowWalletFlag as a, getXummClient as a$, useAllConnectedWalletBalances as a0, useAllTokensWithBalanceForChainType as a1, useCosmosBalance as a2, useEvmBalance as a3, useMultiChainBalance as a4, useMultipleTokenPrices as a5, useBitcoinNativeBalance as a6, useCosmosNativeBalance as a7, useEvmNativeBalance as a8, useNativeBalance as a9, useAddToken as aA, useAutoConnect as aB, useEnsDataForAddress as aC, useEnsSearch as aD, useGnosisContext as aE, useIsSameAddressAndGnosisContext as aF, useIntegratorContext as aG, useMultiChainWallet as aH, useSigner as aI, useWallet as aJ, useWallets as aK, useXrplTrustLine as aL, TX_STATUS_CONSTANTS as aM, FINAL_TRANSACTION_STATUSES as aN, useGetFiatQuote as aO, useGetOnRampConfig as aP, useExecuteFiatQuote as aQ, useFiatOnRampTxStatus as aR, useFiatTransactions as aS, useCurrencyDetails as aT, useCountryDetails as aU, useAvailableQuotes as aV, useRecommendedQuote as aW, useGetOnrampPaymentTypes as aX, useSuggestedFiatAmounts as aY, SquidProvider as aZ, EnsService as a_, useSolanaNativeBalance as aa, useStellarNativeBalance as ab, useSuiNativeBalance as ac, useXrplNativeBalance as ad, useNativeTokenForChain as ae, useSingleTokenPrice as af, useSquidTokens as ag, useHistoricalData as ah, useTokensData as ai, useEstimateSendTransaction as aj, useSendTransaction as ak, useSendTransactionGas as al, useAllTransactionsStatus as am, useApproval as an, useEstimate as ao, useEstimatePriceImpact as ap, useExecuteTransaction as aq, useGetRoute as ar, useGetRouteWrapper as as, useRouteWarnings as at, useSendTransactionStatus as au, useSwapTransactionStatus as av, useAvatar as aw, useHistory as ax, useUserParams as ay, useDebouncedValue as az, chainTypeToZeroAddressMap as b, adaptiveRound as b$, isXamanXAppContext as b0, getQueryHeaders as b1, getStatusCode as b2, is404Error as b3, assetsBaseUrl as b4, shareSubgraphId as b5, sortTokensBySharedSubgraphIds as b6, getSupportedChainIdsForDirection as b7, filterChains as b8, filterTokens as b9, getCosmosKey as bA, getKeysSettled as bB, getAllKeysForSupportedCosmosChains as bC, isCosmosAddressValid as bD, getCosmosSigningClient as bE, getCosmosChainInfosObject as bF, connectCosmosWallet as bG, isFallbackAddressNeeded as bH, suggestChainOrThrow as bI, normalizeError as bJ, transactionErrorCode as bK, isUserRejectionError as bL, getTransactionError as bM, handleTransactionErrorEvents as bN, isSwapRouteError as bO, isStatusError as bP, createQuoteRequestParamsHash as bQ, WidgetEvents as bR, EvmNetworkNotSupportedErrorCode as bS, addEthereumChain as bT, parseEvmAddress as bU, formatEvmWallet as bV, filterWagmiConnector as bW, waitForReceiptWithRetry as bX, getUserCountry as bY, getCountryData as bZ, getCurrencyData as b_, getTokenImage as ba, getNewSwapParamsFromInput as bb, sortAllTokens as bc, findToken as bd, findNativeToken as be, normalizeIbcAddress as bf, groupTokensBySymbol as bg, groupTokensByChainId as bh, filterViewableTokens as bi, getSecretNetworkBalances as bj, getTokenAssetsKey as bk, fetchAssetsColors as bl, initializeSquidWithAssetsColors as bm, isEmptyObject as bn, normalizeTokenSymbol as bo, areTokenSymbolsCompatible as bp, isEvmosChain as bq, getConfigWithDefaults as br, randomIntFromInterval as bs, getTokensForChain as bt, getFirstAvailableChainId as bu, fetchHighestBalanceToken as bv, getInitialOrDefaultTokenAddressForChain as bw, getInitialTokenAddressForChain as bx, filterTokensForDestination as by, getInitialChainIdFromConfig as bz, chainTypeToNativeTokenAddressMap as c, addTokenToWallet as c$, getSuggestedAmountsForCurrency as c0, HederaExtensionHelper as c1, convertHederaAccountIdToEvmAddress as c2, convertEvmAddressToHederaAccountId as c3, scaleHbarToWei as c4, scaleWeiToHbar as c5, parseToBigInt as c6, roundNumericValue as c7, formatUnitsRounded as c8, formatTokenAmount as c9, isChainflipBridgeTransaction as cA, isOnChainTxData as cB, isDepositWithSignatureTxData as cC, getHistoryTransactionId as cD, getStepStatuses as cE, getHalfSuccessState as cF, getStepsInfos as cG, getSwapTxStatusRefetchInterval as cH, getSendTxStatusRefetchInterval as cI, chainflipMultihopBridgeType as cJ, getBridgeType as cK, getTransactionStatus as cL, getTransactionEndStatus as cM, isHistoryTransactionPending as cN, isHistoryTransactionFailed as cO, isHistoryTransactionWarning as cP, isHistoryTransactionEnded as cQ, formatHash as cR, isWalletAddressValid as cS, redirectToExtensionsStore as cT, accessProperty as cU, populateWallets as cV, getDefaultChain as cW, sortWallets as cX, areSameAddress as cY, sortAddressBook as cZ, calculateTotalUsdBalanceUSD as c_, formatUsdAmount as ca, trimExtraDecimals as cb, getNumericValue as cc, cleanAmount as cd, convertTokenAmountToUSD as ce, convertUSDToTokenAmount as cf, calculateTotal24hChange as cg, getRouteExpiry as ch, searchTokens as ci, filterSolanaWallets as cj, isSolanaAddressValid as ck, executeSolanaSwap as cl, executeSolanaTransfer as cm, formatTransactionHistoryDate as cn, getAxelarExplorerTxUrl as co, getSourceExplorerTxUrl as cp, getMainExplorerUrl as cq, formatDistance as cr, formatSeconds as cs, formatSwapTxStatusResponseForStorage as ct, simplifyRouteAction as cu, fetchSwapTransactionStatus as cv, compareTransactionIds as cw, isCoralBridgeAction as cx, sleep as cy, isDepositRoute as cz, definedInWindow as d, isEvmChainNotSupportedError as d0, getWalletSupportedChainTypes as d1, getConnectorForChainType as d2, walletSupportsChainType as d3, connectWallet as d4, cancelConnectWallet as d5, isProblematicConnector as d6, mergeWallets as d7, isXionSmartContractAddress as d8, isXrplAddressValid as d9, buildXrplTrustSetTx as da, getXrplNetwork as db, parseXrplPaymentTx as dc, er as e, formatBNToReadable as f, DEFAULT_ROUTE_REFETCH_INTERVAL as g, destinationAddressResetValue as h, fallbackAddressResetValue as i, nativeCosmosTokenAddress as j, nativeEvmTokenAddress as k, nativeSolanaTokenAddress as l, nativeStellarTokenAddress as m, nativeBitcoinTokenAddress as n, nativeSuiTokenAddress as o, nativeXrplTokenAddress as p, CosmosProvider as q, SendTransactionStatus as r, TransactionStatus as s, useTrackSearchEmpty as t, useCosmosContext as u, useSquidChains as v, walletIconBaseUrl as w, useClient as x, useCosmosForChain as y, useHederaTokenAssociations as z };
|
|
36892
|
+
//# sourceMappingURL=index-BxJVsDEs.js.map
|