@0xsquid/react-hooks 8.7.2-beta-interactive-to-amount.1 → 8.7.2-beta-fav-chains.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/queries/queries-keys.d.ts +1 -1
- package/dist/core/types/config.d.ts +1 -2
- package/dist/core/types/event.d.ts +2 -1
- package/dist/core/types/route.d.ts +4 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/store/useFavoriteChainsStore.d.ts +20 -0
- package/dist/hooks/store/useSquidStore.d.ts +1 -2
- package/dist/hooks/swap/useSwap.d.ts +2 -4
- package/dist/hooks/transaction/useGetRoute.d.ts +8 -9
- package/dist/{index-B9EnYPpR.js → index-0fyTkU8o.js} +63 -69
- package/dist/index-0fyTkU8o.js.map +1 -0
- package/dist/{index-BL3rpZzC.js → index-DYs5b-an.js} +63 -69
- package/dist/index-DYs5b-an.js.map +1 -0
- package/dist/{index.es-Da6lPGPH.js → index.es-Bxk-BRsk.js} +2 -2
- package/dist/{index.es-Da6lPGPH.js.map → index.es-Bxk-BRsk.js.map} +1 -1
- package/dist/{index.es-C93MXP-M.js → index.es-X0Xkh3ET.js} +2 -2
- package/dist/{index.es-C93MXP-M.js.map → index.es-X0Xkh3ET.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{secretService-Bp_azQsY.js → secretService-BExN6uOo.js} +2 -2
- package/dist/{secretService-Bp_azQsY.js.map → secretService-BExN6uOo.js.map} +1 -1
- package/dist/{secretService-CO9haOur.js → secretService-CJJobQlZ.js} +2 -2
- package/dist/{secretService-CO9haOur.js.map → secretService-CJJobQlZ.js.map} +1 -1
- package/dist/services/internal/eventService.d.ts +2 -1
- package/dist/services/internal/numberService.d.ts +0 -1
- package/dist/{stellarService.client-B-EC09rP.js → stellarService.client-eIqTLitu.js} +3 -3
- package/dist/{stellarService.client-B-EC09rP.js.map → stellarService.client-eIqTLitu.js.map} +1 -1
- package/dist/{stellarService.client-CrlGBSG9.js → stellarService.client-yODv6HFL.js} +3 -3
- package/dist/{stellarService.client-CrlGBSG9.js.map → stellarService.client-yODv6HFL.js.map} +1 -1
- package/package.json +3 -3
- package/dist/index-B9EnYPpR.js.map +0 -1
- package/dist/index-BL3rpZzC.js.map +0 -1
|
@@ -56,7 +56,7 @@ export declare const keys: () => {
|
|
|
56
56
|
tokenData: (token?: TokenWithBalance) => (string | undefined)[];
|
|
57
57
|
balance: (chainId?: number | string, tokenAddress?: string, userAddress?: string) => (string | number | undefined)[];
|
|
58
58
|
allTokensBalance: (address: string | undefined, chainType: ChainType | undefined, direction?: SwapDirection) => (string | undefined)[];
|
|
59
|
-
transaction: (fromChainId: string | undefined, toChainId: string | undefined, toTokenAddress: string | undefined, fromTokenAddress: string | undefined,
|
|
59
|
+
transaction: (fromChainId: string | undefined, toChainId: string | undefined, toTokenAddress: string | undefined, fromTokenAddress: string | undefined, price: string | undefined, slippage: SlippageOption | undefined, sourceUserAddress: string | undefined, degenMode: boolean | undefined, destinationAddress: string | undefined, fallbackAddress: string | undefined, quoteOnly: boolean | undefined, fromChainType: ChainType | undefined, preHook: AppConfig["preHook"] | undefined, postHook: AppConfig["postHook"] | undefined, overrideGasRefundAddress: AppConfig["overrideGasRefundAddress"] | undefined) => (string | number | boolean | Omit<import("@0xsquid/squid-types").Hook, "fundAmount" | "fundToken"> | undefined)[];
|
|
60
60
|
swapTransactionStatus: (transactionId: string | undefined) => (string | undefined)[];
|
|
61
61
|
fiatToCryptoStatus: (transactionId?: string) => (string | undefined)[];
|
|
62
62
|
sendTransactionStatus: (txHash: string | undefined, chainId: string | undefined) => (string | undefined)[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RouteRequest } from "
|
|
1
|
+
import { RouteRequest } from "./route";
|
|
2
2
|
export type SlippageOption = RouteRequest["slippage"];
|
|
3
3
|
export type TokenConfig = {
|
|
4
4
|
address: string;
|
|
@@ -72,5 +72,4 @@ export interface AppConfig {
|
|
|
72
72
|
* Override the default gas refund address in Axelar routes
|
|
73
73
|
*/
|
|
74
74
|
overrideGasRefundAddress?: RouteRequest["overrideGasRefundAddress"];
|
|
75
|
-
prefer?: string[];
|
|
76
75
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RouteResponse } from "@0xsquid/squid-types";
|
|
2
2
|
import { TransactionErrorWithMessage } from "./error";
|
|
3
3
|
import { ExecuteQuoteServer } from "./onramps";
|
|
4
|
+
import { RouteRequest } from "./route";
|
|
4
5
|
type BaseSwapEventParams = Pick<RouteRequest, "fromAddress" | "toAddress" | "fromChain" | "toChain" | "fromToken" | "toToken" | "fromAmount">;
|
|
5
6
|
type BaseSendTransactionEventParams = {
|
|
6
7
|
fromAddress: string;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { useStellarAccountActivation } from "./stellar/useStellarAccountActivati
|
|
|
12
12
|
export { useStellarTrustLine } from "./stellar/useStellarTrustLine";
|
|
13
13
|
export { useAddressBookStore } from "./store/useAddressBookStore";
|
|
14
14
|
export { useAssetsColorsStore } from "./store/useAssetsColorsStore";
|
|
15
|
+
export { useFavoriteChainsStore, type FavoriteChain, } from "./store/useFavoriteChainsStore";
|
|
15
16
|
export { useFavoriteTokensStore, type FavoriteToken, } from "./store/useFavoriteTokensStore";
|
|
16
17
|
export { useHistoryStore } from "./store/useHistoryStore";
|
|
17
18
|
export { useSendTransactionStore } from "./store/useSendTransactionStore";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChainData } from "@0xsquid/squid-types";
|
|
2
|
+
export type FavoriteChain = Pick<ChainData, "chainId">;
|
|
3
|
+
interface FavoriteChainsStore {
|
|
4
|
+
favoriteChains: FavoriteChain[];
|
|
5
|
+
addFavoriteChain: (chain: FavoriteChain) => void;
|
|
6
|
+
removeFavoriteChain: (chain: FavoriteChain) => void;
|
|
7
|
+
toggleFavoriteChain: (chain: FavoriteChain) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const useFavoriteChainsStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<FavoriteChainsStore>, "persist"> & {
|
|
10
|
+
persist: {
|
|
11
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<FavoriteChainsStore, FavoriteChainsStore>>) => void;
|
|
12
|
+
clearStorage: () => void;
|
|
13
|
+
rehydrate: () => void | Promise<void>;
|
|
14
|
+
hasHydrated: () => boolean;
|
|
15
|
+
onHydrate: (fn: (state: FavoriteChainsStore) => void) => () => void;
|
|
16
|
+
onFinishHydration: (fn: (state: FavoriteChainsStore) => void) => () => void;
|
|
17
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<FavoriteChainsStore, FavoriteChainsStore>>;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|
|
@@ -21,8 +21,7 @@ export interface ConfigState {
|
|
|
21
21
|
}
|
|
22
22
|
export declare const useConfigStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ConfigState>>;
|
|
23
23
|
interface TransactionState {
|
|
24
|
-
|
|
25
|
-
toAmount?: string;
|
|
24
|
+
fromPrice?: string;
|
|
26
25
|
txLocalId?: string;
|
|
27
26
|
transactions: Record<string, TransactionParams>;
|
|
28
27
|
currentTransaction?: TransactionParams;
|
|
@@ -7,10 +7,8 @@ export declare const useSwap: () => {
|
|
|
7
7
|
};
|
|
8
8
|
onSwapChange: (inputSwapParams: SwapParams) => SwapParams;
|
|
9
9
|
invertSwaps: (() => SwapParams) | undefined;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
fromAmountChanged: (amount: string) => void;
|
|
13
|
-
toAmountChanged: (amount: string) => void;
|
|
10
|
+
fromPrice: string | undefined;
|
|
11
|
+
fromPriceChanged: (price: string) => void;
|
|
14
12
|
toToken: import("../../core").Token | undefined;
|
|
15
13
|
fromToken: import("../../core").Token | undefined;
|
|
16
14
|
fromChain: import("@0xsquid/squid-types").ChainData | undefined;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { RouteResponse } from "@0xsquid/sdk/dist/types";
|
|
2
|
-
import { ChainType,
|
|
2
|
+
import { ChainType, Token } from "@0xsquid/squid-types";
|
|
3
3
|
import { QueryObserverOptions } from "@tanstack/react-query";
|
|
4
4
|
import type { AppConfig } from "../../core/types/config";
|
|
5
|
+
import { RouteRequest } from "../../core/types/route";
|
|
5
6
|
export declare const useGetRoute: () => import("@tanstack/react-query").UseMutationResult<{
|
|
6
7
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
7
8
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
8
|
-
params: RouteRequest;
|
|
9
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
9
10
|
quoteId: string;
|
|
10
11
|
} | undefined, unknown, {
|
|
11
12
|
fromChain: RouteRequest["fromChain"] | undefined;
|
|
@@ -15,29 +16,27 @@ export declare const useGetRoute: () => import("@tanstack/react-query").UseMutat
|
|
|
15
16
|
sourceUserAddress: string | undefined;
|
|
16
17
|
destinationAddress: string | undefined;
|
|
17
18
|
fromPrice: string | undefined;
|
|
18
|
-
toPrice: string | undefined;
|
|
19
19
|
bypassGuardrails: RouteRequest["bypassGuardrails"] | undefined;
|
|
20
20
|
quoteOnly: boolean | undefined;
|
|
21
21
|
fromChainType: ChainType | undefined;
|
|
22
22
|
preHook: AppConfig["preHook"];
|
|
23
23
|
postHook: AppConfig["postHook"];
|
|
24
24
|
overrideGasRefundAddress: AppConfig["overrideGasRefundAddress"];
|
|
25
|
-
prefer: AppConfig["prefer"];
|
|
26
25
|
}, unknown>;
|
|
27
26
|
export declare const useGetRouteWrapper: ({ enabled, cacheTime, staleTime, refetchOnWindowFocus, refetchIntervalInBackground, refetchInterval, quoteOnly, }: Pick<QueryObserverOptions<{
|
|
28
27
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
29
28
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
30
|
-
params: RouteRequest;
|
|
29
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
31
30
|
quoteId: string;
|
|
32
31
|
} | undefined, unknown, {
|
|
33
32
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
34
33
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
35
|
-
params: RouteRequest;
|
|
34
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
36
35
|
quoteId: string;
|
|
37
36
|
} | undefined, {
|
|
38
37
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
39
38
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
40
|
-
params: RouteRequest;
|
|
39
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
41
40
|
quoteId: string;
|
|
42
41
|
} | undefined, import("@tanstack/react-query").QueryKey>, "cacheTime" | "enabled" | "staleTime" | "refetchInterval" | "refetchIntervalInBackground" | "refetchOnWindowFocus"> & {
|
|
43
42
|
quoteOnly?: boolean | undefined;
|
|
@@ -45,7 +44,7 @@ export declare const useGetRouteWrapper: ({ enabled, cacheTime, staleTime, refet
|
|
|
45
44
|
squidRoute: import("@tanstack/react-query").UseQueryResult<{
|
|
46
45
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
47
46
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
48
|
-
params: RouteRequest;
|
|
47
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
49
48
|
quoteId: string;
|
|
50
49
|
} | undefined, unknown>;
|
|
51
50
|
showLoading: boolean;
|
|
@@ -53,7 +52,7 @@ export declare const useGetRouteWrapper: ({ enabled, cacheTime, staleTime, refet
|
|
|
53
52
|
routeData: {
|
|
54
53
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
55
54
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
56
|
-
params: RouteRequest;
|
|
55
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
57
56
|
quoteId: string;
|
|
58
57
|
} | undefined;
|
|
59
58
|
};
|
|
@@ -3971,9 +3971,6 @@ const getNumericValue = ({ value, precision, useComaEvery3Digits = true, hideIfZ
|
|
|
3971
3971
|
const finalValue = `${isNegative ? "-" : ""}${prefix}${formattedIfVerySmall}${suffix ? ` ${suffix}` : ""}`;
|
|
3972
3972
|
return wrapInParens ? `(${finalValue})` : finalValue;
|
|
3973
3973
|
};
|
|
3974
|
-
function isZeroAmount(amount) {
|
|
3975
|
-
return !amount || amount === "0";
|
|
3976
|
-
}
|
|
3977
3974
|
|
|
3978
3975
|
/**
|
|
3979
3976
|
* Creates a hash string from quote request parameters to track changes
|
|
@@ -22416,15 +22413,14 @@ const keys = () => ({
|
|
|
22416
22413
|
// ============
|
|
22417
22414
|
// Transactions
|
|
22418
22415
|
// ============
|
|
22419
|
-
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress,
|
|
22416
|
+
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, price, slippage, sourceUserAddress, degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChainType, preHook, postHook, overrideGasRefundAddress) => [
|
|
22420
22417
|
...keys().transactions(),
|
|
22421
22418
|
exports.QueryKeys.Transaction,
|
|
22422
22419
|
fromChainId,
|
|
22423
22420
|
toChainId,
|
|
22424
22421
|
toTokenAddress,
|
|
22425
22422
|
fromTokenAddress,
|
|
22426
|
-
|
|
22427
|
-
toAmount,
|
|
22423
|
+
price,
|
|
22428
22424
|
slippage,
|
|
22429
22425
|
sourceUserAddress,
|
|
22430
22426
|
degenMode,
|
|
@@ -22435,7 +22431,6 @@ const keys = () => ({
|
|
|
22435
22431
|
preHook,
|
|
22436
22432
|
postHook,
|
|
22437
22433
|
overrideGasRefundAddress,
|
|
22438
|
-
prefer,
|
|
22439
22434
|
],
|
|
22440
22435
|
swapTransactionStatus: (transactionId) => [
|
|
22441
22436
|
...keys().transactions(),
|
|
@@ -22627,7 +22622,6 @@ const getConfigWithDefaults = (config) => {
|
|
|
22627
22622
|
preHook: get$2(config, "preHook", defaultConfigValues.preHook),
|
|
22628
22623
|
postHook: get$2(config, "postHook", defaultConfigValues.postHook),
|
|
22629
22624
|
overrideGasRefundAddress: get$2(config, "overrideGasRefundAddress", defaultConfigValues.overrideGasRefundAddress),
|
|
22630
|
-
prefer: get$2(config, "prefer", defaultConfigValues.prefer),
|
|
22631
22625
|
};
|
|
22632
22626
|
};
|
|
22633
22627
|
const randomIntFromInterval = (min, max) => {
|
|
@@ -23321,7 +23315,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23321
23315
|
};
|
|
23322
23316
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23323
23317
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23324
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23318
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-BExN6uOo.js'); });
|
|
23325
23319
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23326
23320
|
};
|
|
23327
23321
|
function getTokenAssetsKey(token) {
|
|
@@ -25178,7 +25172,10 @@ const useConfigStore = zustand.create(() => ({
|
|
|
25178
25172
|
isInitialized: false,
|
|
25179
25173
|
}));
|
|
25180
25174
|
const useTransactionStore = zustand.create((set, get) => ({
|
|
25175
|
+
fromPrice: undefined,
|
|
25176
|
+
txLocalId: undefined,
|
|
25181
25177
|
transactions: {},
|
|
25178
|
+
currentTransaction: undefined,
|
|
25182
25179
|
setTransactionState(txId, tx) {
|
|
25183
25180
|
if (!txId)
|
|
25184
25181
|
return;
|
|
@@ -26715,8 +26712,8 @@ function useStellarWallets() {
|
|
|
26715
26712
|
return;
|
|
26716
26713
|
try {
|
|
26717
26714
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26718
|
-
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
|
|
26719
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
26715
|
+
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
26716
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-yODv6HFL.js'); });
|
|
26720
26717
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26721
26718
|
const promises = modules.map(async (module) => {
|
|
26722
26719
|
const isAvailable = await module.isAvailable();
|
|
@@ -27615,8 +27612,7 @@ const useMultiChainWallet = (chain) => {
|
|
|
27615
27612
|
|
|
27616
27613
|
const useSwap = () => {
|
|
27617
27614
|
const { initialAssets, defaultTokensPerChain, disabledChains, availableChains, } = useConfigStore((state) => state.config);
|
|
27618
|
-
const
|
|
27619
|
-
const toAmount = useTransactionStore((state) => state.toAmount);
|
|
27615
|
+
const fromPrice = useTransactionStore((state) => state.fromPrice);
|
|
27620
27616
|
const { swapRoute } = useSwapRoutePersistStore();
|
|
27621
27617
|
const { tokens } = useSquidTokens();
|
|
27622
27618
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -27668,17 +27664,8 @@ const useSwap = () => {
|
|
|
27668
27664
|
}),
|
|
27669
27665
|
};
|
|
27670
27666
|
}, [destAddressData, destAddressEnsData.data, toChain?.chainType]);
|
|
27671
|
-
const
|
|
27672
|
-
useTransactionStore.setState({
|
|
27673
|
-
fromAmount: amount || undefined,
|
|
27674
|
-
toAmount: undefined,
|
|
27675
|
-
});
|
|
27676
|
-
}, []);
|
|
27677
|
-
const toAmountChanged = React.useCallback((amount) => {
|
|
27678
|
-
useTransactionStore.setState({
|
|
27679
|
-
toAmount: amount || undefined,
|
|
27680
|
-
fromAmount: undefined,
|
|
27681
|
-
});
|
|
27667
|
+
const fromPriceChanged = React.useCallback((price) => {
|
|
27668
|
+
useTransactionStore.setState({ fromPrice: price || undefined });
|
|
27682
27669
|
}, []);
|
|
27683
27670
|
/**
|
|
27684
27671
|
* When user changes something from the SwapView
|
|
@@ -27838,10 +27825,8 @@ const useSwap = () => {
|
|
|
27838
27825
|
tokenItems,
|
|
27839
27826
|
onSwapChange,
|
|
27840
27827
|
invertSwaps,
|
|
27841
|
-
|
|
27842
|
-
|
|
27843
|
-
fromAmountChanged,
|
|
27844
|
-
toAmountChanged,
|
|
27828
|
+
fromPrice,
|
|
27829
|
+
fromPriceChanged,
|
|
27845
27830
|
toToken,
|
|
27846
27831
|
fromToken,
|
|
27847
27832
|
fromChain,
|
|
@@ -30048,7 +30033,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30048
30033
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30049
30034
|
if (!optionalChains.length)
|
|
30050
30035
|
return;
|
|
30051
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
30036
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-X0Xkh3ET.js'); });
|
|
30052
30037
|
const rawProvider = await EthereumProvider.init({
|
|
30053
30038
|
...restParameters,
|
|
30054
30039
|
disableProviderPing: true,
|
|
@@ -30185,6 +30170,7 @@ const createWagmiConfig = (squidChains, hederaExtensions) => {
|
|
|
30185
30170
|
description: SQUID_METADATA.description,
|
|
30186
30171
|
};
|
|
30187
30172
|
return wagmi.createConfig({
|
|
30173
|
+
ssr: true,
|
|
30188
30174
|
chains: wagmiChains,
|
|
30189
30175
|
transports: Object.fromEntries(wagmiChains.map((chain) => [
|
|
30190
30176
|
chain.id,
|
|
@@ -30678,6 +30664,32 @@ const useAddressBookStore = zustand.create(middleware.persist((set) => ({
|
|
|
30678
30664
|
name: "squid.addressbook.store",
|
|
30679
30665
|
}));
|
|
30680
30666
|
|
|
30667
|
+
const useFavoriteChainsStore = zustand.create(middleware.persist((set, get) => ({
|
|
30668
|
+
favoriteChains: [],
|
|
30669
|
+
addFavoriteChain(chain) {
|
|
30670
|
+
set((state) => ({
|
|
30671
|
+
favoriteChains: [...state.favoriteChains, chain],
|
|
30672
|
+
}));
|
|
30673
|
+
},
|
|
30674
|
+
removeFavoriteChain(chain) {
|
|
30675
|
+
set((state) => ({
|
|
30676
|
+
favoriteChains: state.favoriteChains.filter((c) => c.chainId !== chain.chainId),
|
|
30677
|
+
}));
|
|
30678
|
+
},
|
|
30679
|
+
toggleFavoriteChain(chain) {
|
|
30680
|
+
const isFavorite = get().favoriteChains.some((c) => c.chainId === chain.chainId);
|
|
30681
|
+
if (isFavorite) {
|
|
30682
|
+
get().removeFavoriteChain(chain);
|
|
30683
|
+
}
|
|
30684
|
+
else {
|
|
30685
|
+
get().addFavoriteChain(chain);
|
|
30686
|
+
}
|
|
30687
|
+
},
|
|
30688
|
+
}), {
|
|
30689
|
+
name: "squid.favorite.chains.store",
|
|
30690
|
+
version: 1,
|
|
30691
|
+
}));
|
|
30692
|
+
|
|
30681
30693
|
const useFavoriteTokensStore = zustand.create(middleware.persist((set, get) => ({
|
|
30682
30694
|
favoriteTokens: [],
|
|
30683
30695
|
addFavoriteToken(token) {
|
|
@@ -32453,7 +32465,7 @@ const useHistory = (txType) => {
|
|
|
32453
32465
|
fromChain: tx.params.fromChain,
|
|
32454
32466
|
fromToken: tx.params.fromToken,
|
|
32455
32467
|
fromAddress: tx.params.fromAddress,
|
|
32456
|
-
fromAmount: tx.params.fromAmount
|
|
32468
|
+
fromAmount: tx.params.fromAmount,
|
|
32457
32469
|
toChain: tx.params.toChain,
|
|
32458
32470
|
toToken: tx.params.toToken,
|
|
32459
32471
|
toAddress: tx.params.toAddress,
|
|
@@ -32694,7 +32706,7 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32694
32706
|
const publicClient = wagmi.usePublicClient();
|
|
32695
32707
|
const queryClient = reactQuery.useQueryClient();
|
|
32696
32708
|
const squid = useSquidStore((state) => state.squid);
|
|
32697
|
-
const { fromChain, fromToken,
|
|
32709
|
+
const { fromChain, fromToken, fromPrice, isSameChain } = useSwap();
|
|
32698
32710
|
const { evmSigner } = useSigner({ chain: fromChain });
|
|
32699
32711
|
const { connector: activeConnector } = wagmi.useAccount();
|
|
32700
32712
|
const { getChainType } = useSquidChains();
|
|
@@ -32867,9 +32879,9 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32867
32879
|
// This is to ensure we're using the latest expiry timestamp
|
|
32868
32880
|
if (squidRoute) {
|
|
32869
32881
|
queryClient.refetchQueries({
|
|
32870
|
-
queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken,
|
|
32882
|
+
queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken, fromPrice, squidRoute.params.slippage, squidRoute.params.fromAddress, squidRoute.params.bypassGuardrails, squidRoute.params.toAddress, squidRoute.params.fallbackAddresses?.[0]?.address, squidRoute.params.quoteOnly, getChainType(squidRoute.params.fromChain), squidRoute.params.preHook, squidRoute.params.postHook,
|
|
32871
32883
|
// TODO: update types
|
|
32872
|
-
squidRoute.params?.overrideGasRefundAddress
|
|
32884
|
+
squidRoute.params?.overrideGasRefundAddress),
|
|
32873
32885
|
});
|
|
32874
32886
|
}
|
|
32875
32887
|
},
|
|
@@ -32886,7 +32898,7 @@ const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/ass
|
|
|
32886
32898
|
const useEstimate = (squidRoute) => {
|
|
32887
32899
|
const collectFees = useConfigStore((state) => state.config.collectFees);
|
|
32888
32900
|
const { tokens } = useSquidTokens();
|
|
32889
|
-
const { fromChain, toChain,
|
|
32901
|
+
const { fromChain, toChain, fromPrice } = useSwap();
|
|
32890
32902
|
const fromToken = React.useMemo(() => findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken), [tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken]);
|
|
32891
32903
|
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
32892
32904
|
fromChain,
|
|
@@ -32982,9 +32994,9 @@ const useEstimate = (squidRoute) => {
|
|
|
32982
32994
|
const slippageFormatted = Number(squidRoute?.estimate?.aggregateSlippage ?? 0).toFixed(2) + "%";
|
|
32983
32995
|
const fromBalanceEnoughToSwap = React.useMemo(() => {
|
|
32984
32996
|
const fromBalanceNum = Number(fromBalanceFormatted ?? 0);
|
|
32985
|
-
const
|
|
32986
|
-
return fromBalanceNum >=
|
|
32987
|
-
}, [fromBalanceFormatted,
|
|
32997
|
+
const fromPriceNum = Number(fromPrice ?? 0);
|
|
32998
|
+
return fromBalanceNum >= fromPriceNum;
|
|
32999
|
+
}, [fromBalanceFormatted, fromPrice]);
|
|
32988
33000
|
return {
|
|
32989
33001
|
...estimateResults,
|
|
32990
33002
|
fromBalanceFormatted,
|
|
@@ -36203,12 +36215,8 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36203
36215
|
if (!depositData?.depositAddress) {
|
|
36204
36216
|
throw new Error("Deposit address is required");
|
|
36205
36217
|
}
|
|
36206
|
-
const fromAmount = route.params.fromAmount || route.estimate.fromAmount;
|
|
36207
|
-
if (isZeroAmount(fromAmount)) {
|
|
36208
|
-
throw new Error("fromAmount is required for Solana transfer");
|
|
36209
|
-
}
|
|
36210
36218
|
const signature = await executeSolanaTransfer({
|
|
36211
|
-
amount: BigInt(fromAmount),
|
|
36219
|
+
amount: BigInt(route.params.fromAmount),
|
|
36212
36220
|
target: depositData.depositAddress,
|
|
36213
36221
|
signer: solanaSigner,
|
|
36214
36222
|
connection: solanaConnection,
|
|
@@ -36718,12 +36726,8 @@ const useGetRoute = () => {
|
|
|
36718
36726
|
* These data will be used to trigger the transaction
|
|
36719
36727
|
* @returns {Route} Route data
|
|
36720
36728
|
*/
|
|
36721
|
-
return reactQuery.useMutation(async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice
|
|
36722
|
-
if (!fromChain ||
|
|
36723
|
-
!toChain ||
|
|
36724
|
-
!fromToken ||
|
|
36725
|
-
!toToken ||
|
|
36726
|
-
(!fromPrice && !toPrice)) {
|
|
36729
|
+
return reactQuery.useMutation(async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice, bypassGuardrails, quoteOnly, fromChainType, postHook, preHook, overrideGasRefundAddress, }) => {
|
|
36730
|
+
if (!fromChain || !toChain || !fromToken || !toToken || !fromPrice) {
|
|
36727
36731
|
return undefined;
|
|
36728
36732
|
}
|
|
36729
36733
|
// Dispatch requestQuote event
|
|
@@ -36733,7 +36737,6 @@ const useGetRoute = () => {
|
|
|
36733
36737
|
fromToken: fromToken.address,
|
|
36734
36738
|
toToken: toToken.address,
|
|
36735
36739
|
fromAmount: fromPrice,
|
|
36736
|
-
toAmount: toPrice,
|
|
36737
36740
|
fromAddress: sourceUserAddress,
|
|
36738
36741
|
toAddress: destinationAddress,
|
|
36739
36742
|
});
|
|
@@ -36742,13 +36745,13 @@ const useGetRoute = () => {
|
|
|
36742
36745
|
const fromTokenAddress = fromToken.address;
|
|
36743
36746
|
const toTokenAddress = toToken.address;
|
|
36744
36747
|
const fromAmount = parseToBigInt(fromPrice?.toString() ?? "0", fromToken?.decimals).toString();
|
|
36745
|
-
const toAmount = parseToBigInt(toPrice?.toString() ?? "0", toToken?.decimals).toString();
|
|
36746
36748
|
const fromAddress = sourceUserAddress ??
|
|
36747
36749
|
chainTypeToZeroAddressMap[fromChainType ?? squidTypes.ChainType.EVM];
|
|
36748
36750
|
const params = {
|
|
36749
36751
|
fromChain,
|
|
36750
36752
|
fromToken: fromTokenAddress,
|
|
36751
36753
|
fromAddress,
|
|
36754
|
+
fromAmount,
|
|
36752
36755
|
toChain,
|
|
36753
36756
|
toToken: toTokenAddress,
|
|
36754
36757
|
toAddress: destinationAddress ?? "",
|
|
@@ -36765,19 +36768,12 @@ const useGetRoute = () => {
|
|
|
36765
36768
|
cosmosFallbackAddresses[0].address) {
|
|
36766
36769
|
params.fallbackAddresses = cosmosFallbackAddresses;
|
|
36767
36770
|
}
|
|
36768
|
-
if (!isZeroAmount(fromAmount)) {
|
|
36769
|
-
params.fromAmount = fromAmount;
|
|
36770
|
-
}
|
|
36771
|
-
else if (!isZeroAmount(toAmount)) {
|
|
36772
|
-
params.toAmount = toAmount;
|
|
36773
|
-
}
|
|
36774
36771
|
const { route } = await squid.getRoute({
|
|
36775
36772
|
...params,
|
|
36776
|
-
...(prefer ? { prefer } : {}),
|
|
36777
36773
|
});
|
|
36778
36774
|
// Cache the route data
|
|
36779
36775
|
// Useful when the getRoute mutation is called from another hook
|
|
36780
|
-
queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice,
|
|
36776
|
+
queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, swapRoute?.fallbackAddress, quoteOnly, fromChainType, config.preHook, config.postHook, overrideGasRefundAddress), route);
|
|
36781
36777
|
return route;
|
|
36782
36778
|
});
|
|
36783
36779
|
};
|
|
@@ -36791,7 +36787,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36791
36787
|
const depositRefundAddress = useSwapRoutePersistStore((store) => store.swapRoute?.depositRefundAddress);
|
|
36792
36788
|
const { isAvailableAsPaymentMethod, isEnabled: isDepositAddressEnabled } = useDepositAddress();
|
|
36793
36789
|
const getRouteMutation = useGetRoute();
|
|
36794
|
-
const { fromChain, toChain,
|
|
36790
|
+
const { fromChain, toChain, fromPrice, destinationAddress: { address: destinationAddress } = {}, fromToken, toToken, } = useSwap();
|
|
36795
36791
|
const { connectedAddress: { address: sourceConnectedAddress }, } = useMultiChainWallet(fromChain);
|
|
36796
36792
|
// When the payment method is deposit address, users can specify a refund address on the source chain
|
|
36797
36793
|
// Tokens will be sent to this address in case of swap failure
|
|
@@ -36800,13 +36796,12 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36800
36796
|
const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
|
|
36801
36797
|
? depositRefundAddress ?? sourceConnectedAddress
|
|
36802
36798
|
: sourceConnectedAddress;
|
|
36803
|
-
const squidRouteQueryKeys = React.useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address,
|
|
36799
|
+
const squidRouteQueryKeys = React.useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address, fromPrice, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChain?.chainType, config.preHook, config.postHook, config.overrideGasRefundAddress), [
|
|
36804
36800
|
fromChain?.chainId,
|
|
36805
36801
|
toChain?.chainId,
|
|
36806
36802
|
toToken?.address,
|
|
36807
36803
|
fromToken?.address,
|
|
36808
|
-
|
|
36809
|
-
toAmount,
|
|
36804
|
+
fromPrice,
|
|
36810
36805
|
config.slippage,
|
|
36811
36806
|
sourceUserAddress,
|
|
36812
36807
|
config.degenMode,
|
|
@@ -36817,12 +36812,12 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36817
36812
|
config.preHook,
|
|
36818
36813
|
config.postHook,
|
|
36819
36814
|
config.overrideGasRefundAddress,
|
|
36820
|
-
config.prefer,
|
|
36821
36815
|
]);
|
|
36822
36816
|
const queryEnabled = enabled != undefined
|
|
36823
36817
|
? enabled
|
|
36824
36818
|
: squid !== undefined &&
|
|
36825
|
-
|
|
36819
|
+
fromPrice !== undefined &&
|
|
36820
|
+
fromPrice !== "0" &&
|
|
36826
36821
|
toChain?.chainId !== undefined &&
|
|
36827
36822
|
toToken?.address !== undefined;
|
|
36828
36823
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -36840,15 +36835,13 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36840
36835
|
toToken,
|
|
36841
36836
|
sourceUserAddress,
|
|
36842
36837
|
destinationAddress,
|
|
36843
|
-
fromPrice
|
|
36844
|
-
toPrice: toAmount,
|
|
36838
|
+
fromPrice,
|
|
36845
36839
|
bypassGuardrails: config.degenMode,
|
|
36846
36840
|
quoteOnly,
|
|
36847
36841
|
fromChainType: fromChain?.chainType,
|
|
36848
36842
|
postHook: config.postHook,
|
|
36849
36843
|
preHook: config.preHook,
|
|
36850
36844
|
overrideGasRefundAddress: config.overrideGasRefundAddress,
|
|
36851
|
-
prefer: config.prefer,
|
|
36852
36845
|
});
|
|
36853
36846
|
return route;
|
|
36854
36847
|
}, {
|
|
@@ -37470,6 +37463,7 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37470
37463
|
// Even with an error, we want wagmi to be defined so that we can display the maintenance mode layout
|
|
37471
37464
|
// Create wagmi config with mainnet as fallback in maintenance mode
|
|
37472
37465
|
const newWagmiConfig = wagmi.createConfig({
|
|
37466
|
+
ssr: true,
|
|
37473
37467
|
chains: [chains$1.mainnet],
|
|
37474
37468
|
connectors: [connectors.injected()],
|
|
37475
37469
|
transports: {
|
|
@@ -37649,7 +37643,6 @@ exports.isWalletAddressValid = isWalletAddressValid;
|
|
|
37649
37643
|
exports.isXamanXAppContext = isXamanXAppContext;
|
|
37650
37644
|
exports.isXionSmartContractAddress = isXionSmartContractAddress;
|
|
37651
37645
|
exports.isXrplAddressValid = isXrplAddressValid;
|
|
37652
|
-
exports.isZeroAmount = isZeroAmount;
|
|
37653
37646
|
exports.mergeWallets = mergeWallets;
|
|
37654
37647
|
exports.nativeBitcoinTokenAddress = nativeBitcoinTokenAddress;
|
|
37655
37648
|
exports.nativeCosmosTokenAddress = nativeCosmosTokenAddress;
|
|
@@ -37715,6 +37708,7 @@ exports.useEvmBalance = useEvmBalance;
|
|
|
37715
37708
|
exports.useEvmNativeBalance = useEvmNativeBalance;
|
|
37716
37709
|
exports.useExecuteFiatQuote = useExecuteFiatQuote;
|
|
37717
37710
|
exports.useExecuteTransaction = useExecuteTransaction;
|
|
37711
|
+
exports.useFavoriteChainsStore = useFavoriteChainsStore;
|
|
37718
37712
|
exports.useFavoriteTokensStore = useFavoriteTokensStore;
|
|
37719
37713
|
exports.useFiatOnRampTxStatus = useFiatOnRampTxStatus;
|
|
37720
37714
|
exports.useFiatTransactions = useFiatTransactions;
|
|
@@ -37772,4 +37766,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
37772
37766
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
37773
37767
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
37774
37768
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
37775
|
-
//# sourceMappingURL=index-
|
|
37769
|
+
//# sourceMappingURL=index-0fyTkU8o.js.map
|