@0xsquid/react-hooks 8.7.2-beta-interactive-to-amount.0 → 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 -1
- 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 -8
- package/dist/{index-uUESkMSI.js → index-0fyTkU8o.js} +62 -63
- package/dist/index-0fyTkU8o.js.map +1 -0
- package/dist/{index-6eFn7nS3.js → index-DYs5b-an.js} +62 -63
- package/dist/index-DYs5b-an.js.map +1 -0
- package/dist/{index.es-CRHo3jIu.js → index.es-Bxk-BRsk.js} +2 -2
- package/dist/{index.es-CRHo3jIu.js.map → index.es-Bxk-BRsk.js.map} +1 -1
- package/dist/{index.es-C0R5BhSh.js → index.es-X0Xkh3ET.js} +2 -2
- package/dist/{index.es-C0R5BhSh.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-C8LsM_VG.js → secretService-BExN6uOo.js} +2 -2
- package/dist/{secretService-C8LsM_VG.js.map → secretService-BExN6uOo.js.map} +1 -1
- package/dist/{secretService-B87PUWJl.js → secretService-CJJobQlZ.js} +2 -2
- package/dist/{secretService-B87PUWJl.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-DidQHS07.js → stellarService.client-eIqTLitu.js} +3 -3
- package/dist/{stellarService.client-DidQHS07.js.map → stellarService.client-eIqTLitu.js.map} +1 -1
- package/dist/{stellarService.client-BFgOtfFI.js → stellarService.client-yODv6HFL.js} +3 -3
- package/dist/{stellarService.client-BFgOtfFI.js.map → stellarService.client-yODv6HFL.js.map} +1 -1
- package/package.json +3 -3
- package/dist/index-6eFn7nS3.js.map +0 -1
- package/dist/index-uUESkMSI.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,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,7 +16,6 @@ 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;
|
|
@@ -26,17 +26,17 @@ export declare const useGetRoute: () => import("@tanstack/react-query").UseMutat
|
|
|
26
26
|
export declare const useGetRouteWrapper: ({ enabled, cacheTime, staleTime, refetchOnWindowFocus, refetchIntervalInBackground, refetchInterval, quoteOnly, }: Pick<QueryObserverOptions<{
|
|
27
27
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
28
28
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
29
|
-
params: RouteRequest;
|
|
29
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
30
30
|
quoteId: string;
|
|
31
31
|
} | undefined, unknown, {
|
|
32
32
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
33
33
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
34
|
-
params: RouteRequest;
|
|
34
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
35
35
|
quoteId: string;
|
|
36
36
|
} | undefined, {
|
|
37
37
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
38
38
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
39
|
-
params: RouteRequest;
|
|
39
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
40
40
|
quoteId: string;
|
|
41
41
|
} | undefined, import("@tanstack/react-query").QueryKey>, "cacheTime" | "enabled" | "staleTime" | "refetchInterval" | "refetchIntervalInBackground" | "refetchOnWindowFocus"> & {
|
|
42
42
|
quoteOnly?: boolean | undefined;
|
|
@@ -44,7 +44,7 @@ export declare const useGetRouteWrapper: ({ enabled, cacheTime, staleTime, refet
|
|
|
44
44
|
squidRoute: import("@tanstack/react-query").UseQueryResult<{
|
|
45
45
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
46
46
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
47
|
-
params: RouteRequest;
|
|
47
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
48
48
|
quoteId: string;
|
|
49
49
|
} | undefined, unknown>;
|
|
50
50
|
showLoading: boolean;
|
|
@@ -52,7 +52,7 @@ export declare const useGetRouteWrapper: ({ enabled, cacheTime, staleTime, refet
|
|
|
52
52
|
routeData: {
|
|
53
53
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
54
54
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
55
|
-
params: RouteRequest;
|
|
55
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
56
56
|
quoteId: string;
|
|
57
57
|
} | undefined;
|
|
58
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,
|
|
@@ -23319,7 +23315,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23319
23315
|
};
|
|
23320
23316
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23321
23317
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23322
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23318
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-BExN6uOo.js'); });
|
|
23323
23319
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23324
23320
|
};
|
|
23325
23321
|
function getTokenAssetsKey(token) {
|
|
@@ -25176,7 +25172,10 @@ const useConfigStore = zustand.create(() => ({
|
|
|
25176
25172
|
isInitialized: false,
|
|
25177
25173
|
}));
|
|
25178
25174
|
const useTransactionStore = zustand.create((set, get) => ({
|
|
25175
|
+
fromPrice: undefined,
|
|
25176
|
+
txLocalId: undefined,
|
|
25179
25177
|
transactions: {},
|
|
25178
|
+
currentTransaction: undefined,
|
|
25180
25179
|
setTransactionState(txId, tx) {
|
|
25181
25180
|
if (!txId)
|
|
25182
25181
|
return;
|
|
@@ -26713,8 +26712,8 @@ function useStellarWallets() {
|
|
|
26713
26712
|
return;
|
|
26714
26713
|
try {
|
|
26715
26714
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26716
|
-
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
|
|
26717
|
-
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'); });
|
|
26718
26717
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26719
26718
|
const promises = modules.map(async (module) => {
|
|
26720
26719
|
const isAvailable = await module.isAvailable();
|
|
@@ -27613,8 +27612,7 @@ const useMultiChainWallet = (chain) => {
|
|
|
27613
27612
|
|
|
27614
27613
|
const useSwap = () => {
|
|
27615
27614
|
const { initialAssets, defaultTokensPerChain, disabledChains, availableChains, } = useConfigStore((state) => state.config);
|
|
27616
|
-
const
|
|
27617
|
-
const toAmount = useTransactionStore((state) => state.toAmount);
|
|
27615
|
+
const fromPrice = useTransactionStore((state) => state.fromPrice);
|
|
27618
27616
|
const { swapRoute } = useSwapRoutePersistStore();
|
|
27619
27617
|
const { tokens } = useSquidTokens();
|
|
27620
27618
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -27666,17 +27664,8 @@ const useSwap = () => {
|
|
|
27666
27664
|
}),
|
|
27667
27665
|
};
|
|
27668
27666
|
}, [destAddressData, destAddressEnsData.data, toChain?.chainType]);
|
|
27669
|
-
const
|
|
27670
|
-
useTransactionStore.setState({
|
|
27671
|
-
fromAmount: amount || undefined,
|
|
27672
|
-
toAmount: undefined,
|
|
27673
|
-
});
|
|
27674
|
-
}, []);
|
|
27675
|
-
const toAmountChanged = React.useCallback((amount) => {
|
|
27676
|
-
useTransactionStore.setState({
|
|
27677
|
-
toAmount: amount || undefined,
|
|
27678
|
-
fromAmount: undefined,
|
|
27679
|
-
});
|
|
27667
|
+
const fromPriceChanged = React.useCallback((price) => {
|
|
27668
|
+
useTransactionStore.setState({ fromPrice: price || undefined });
|
|
27680
27669
|
}, []);
|
|
27681
27670
|
/**
|
|
27682
27671
|
* When user changes something from the SwapView
|
|
@@ -27836,10 +27825,8 @@ const useSwap = () => {
|
|
|
27836
27825
|
tokenItems,
|
|
27837
27826
|
onSwapChange,
|
|
27838
27827
|
invertSwaps,
|
|
27839
|
-
|
|
27840
|
-
|
|
27841
|
-
fromAmountChanged,
|
|
27842
|
-
toAmountChanged,
|
|
27828
|
+
fromPrice,
|
|
27829
|
+
fromPriceChanged,
|
|
27843
27830
|
toToken,
|
|
27844
27831
|
fromToken,
|
|
27845
27832
|
fromChain,
|
|
@@ -30046,7 +30033,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30046
30033
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30047
30034
|
if (!optionalChains.length)
|
|
30048
30035
|
return;
|
|
30049
|
-
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'); });
|
|
30050
30037
|
const rawProvider = await EthereumProvider.init({
|
|
30051
30038
|
...restParameters,
|
|
30052
30039
|
disableProviderPing: true,
|
|
@@ -30183,6 +30170,7 @@ const createWagmiConfig = (squidChains, hederaExtensions) => {
|
|
|
30183
30170
|
description: SQUID_METADATA.description,
|
|
30184
30171
|
};
|
|
30185
30172
|
return wagmi.createConfig({
|
|
30173
|
+
ssr: true,
|
|
30186
30174
|
chains: wagmiChains,
|
|
30187
30175
|
transports: Object.fromEntries(wagmiChains.map((chain) => [
|
|
30188
30176
|
chain.id,
|
|
@@ -30676,6 +30664,32 @@ const useAddressBookStore = zustand.create(middleware.persist((set) => ({
|
|
|
30676
30664
|
name: "squid.addressbook.store",
|
|
30677
30665
|
}));
|
|
30678
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
|
+
|
|
30679
30693
|
const useFavoriteTokensStore = zustand.create(middleware.persist((set, get) => ({
|
|
30680
30694
|
favoriteTokens: [],
|
|
30681
30695
|
addFavoriteToken(token) {
|
|
@@ -32451,7 +32465,7 @@ const useHistory = (txType) => {
|
|
|
32451
32465
|
fromChain: tx.params.fromChain,
|
|
32452
32466
|
fromToken: tx.params.fromToken,
|
|
32453
32467
|
fromAddress: tx.params.fromAddress,
|
|
32454
|
-
fromAmount: tx.params.fromAmount
|
|
32468
|
+
fromAmount: tx.params.fromAmount,
|
|
32455
32469
|
toChain: tx.params.toChain,
|
|
32456
32470
|
toToken: tx.params.toToken,
|
|
32457
32471
|
toAddress: tx.params.toAddress,
|
|
@@ -32692,7 +32706,7 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32692
32706
|
const publicClient = wagmi.usePublicClient();
|
|
32693
32707
|
const queryClient = reactQuery.useQueryClient();
|
|
32694
32708
|
const squid = useSquidStore((state) => state.squid);
|
|
32695
|
-
const { fromChain, fromToken,
|
|
32709
|
+
const { fromChain, fromToken, fromPrice, isSameChain } = useSwap();
|
|
32696
32710
|
const { evmSigner } = useSigner({ chain: fromChain });
|
|
32697
32711
|
const { connector: activeConnector } = wagmi.useAccount();
|
|
32698
32712
|
const { getChainType } = useSquidChains();
|
|
@@ -32865,7 +32879,7 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32865
32879
|
// This is to ensure we're using the latest expiry timestamp
|
|
32866
32880
|
if (squidRoute) {
|
|
32867
32881
|
queryClient.refetchQueries({
|
|
32868
|
-
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,
|
|
32869
32883
|
// TODO: update types
|
|
32870
32884
|
squidRoute.params?.overrideGasRefundAddress),
|
|
32871
32885
|
});
|
|
@@ -32884,7 +32898,7 @@ const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/ass
|
|
|
32884
32898
|
const useEstimate = (squidRoute) => {
|
|
32885
32899
|
const collectFees = useConfigStore((state) => state.config.collectFees);
|
|
32886
32900
|
const { tokens } = useSquidTokens();
|
|
32887
|
-
const { fromChain, toChain,
|
|
32901
|
+
const { fromChain, toChain, fromPrice } = useSwap();
|
|
32888
32902
|
const fromToken = React.useMemo(() => findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken), [tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken]);
|
|
32889
32903
|
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
32890
32904
|
fromChain,
|
|
@@ -32980,9 +32994,9 @@ const useEstimate = (squidRoute) => {
|
|
|
32980
32994
|
const slippageFormatted = Number(squidRoute?.estimate?.aggregateSlippage ?? 0).toFixed(2) + "%";
|
|
32981
32995
|
const fromBalanceEnoughToSwap = React.useMemo(() => {
|
|
32982
32996
|
const fromBalanceNum = Number(fromBalanceFormatted ?? 0);
|
|
32983
|
-
const
|
|
32984
|
-
return fromBalanceNum >=
|
|
32985
|
-
}, [fromBalanceFormatted,
|
|
32997
|
+
const fromPriceNum = Number(fromPrice ?? 0);
|
|
32998
|
+
return fromBalanceNum >= fromPriceNum;
|
|
32999
|
+
}, [fromBalanceFormatted, fromPrice]);
|
|
32986
33000
|
return {
|
|
32987
33001
|
...estimateResults,
|
|
32988
33002
|
fromBalanceFormatted,
|
|
@@ -36201,12 +36215,8 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36201
36215
|
if (!depositData?.depositAddress) {
|
|
36202
36216
|
throw new Error("Deposit address is required");
|
|
36203
36217
|
}
|
|
36204
|
-
const fromAmount = route.params.fromAmount || route.estimate.fromAmount;
|
|
36205
|
-
if (isZeroAmount(fromAmount)) {
|
|
36206
|
-
throw new Error("fromAmount is required for Solana transfer");
|
|
36207
|
-
}
|
|
36208
36218
|
const signature = await executeSolanaTransfer({
|
|
36209
|
-
amount: BigInt(fromAmount),
|
|
36219
|
+
amount: BigInt(route.params.fromAmount),
|
|
36210
36220
|
target: depositData.depositAddress,
|
|
36211
36221
|
signer: solanaSigner,
|
|
36212
36222
|
connection: solanaConnection,
|
|
@@ -36716,12 +36726,8 @@ const useGetRoute = () => {
|
|
|
36716
36726
|
* These data will be used to trigger the transaction
|
|
36717
36727
|
* @returns {Route} Route data
|
|
36718
36728
|
*/
|
|
36719
|
-
return reactQuery.useMutation(async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice
|
|
36720
|
-
if (!fromChain ||
|
|
36721
|
-
!toChain ||
|
|
36722
|
-
!fromToken ||
|
|
36723
|
-
!toToken ||
|
|
36724
|
-
(!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) {
|
|
36725
36731
|
return undefined;
|
|
36726
36732
|
}
|
|
36727
36733
|
// Dispatch requestQuote event
|
|
@@ -36731,7 +36737,6 @@ const useGetRoute = () => {
|
|
|
36731
36737
|
fromToken: fromToken.address,
|
|
36732
36738
|
toToken: toToken.address,
|
|
36733
36739
|
fromAmount: fromPrice,
|
|
36734
|
-
toAmount: toPrice,
|
|
36735
36740
|
fromAddress: sourceUserAddress,
|
|
36736
36741
|
toAddress: destinationAddress,
|
|
36737
36742
|
});
|
|
@@ -36740,13 +36745,13 @@ const useGetRoute = () => {
|
|
|
36740
36745
|
const fromTokenAddress = fromToken.address;
|
|
36741
36746
|
const toTokenAddress = toToken.address;
|
|
36742
36747
|
const fromAmount = parseToBigInt(fromPrice?.toString() ?? "0", fromToken?.decimals).toString();
|
|
36743
|
-
const toAmount = parseToBigInt(toPrice?.toString() ?? "0", toToken?.decimals).toString();
|
|
36744
36748
|
const fromAddress = sourceUserAddress ??
|
|
36745
36749
|
chainTypeToZeroAddressMap[fromChainType ?? squidTypes.ChainType.EVM];
|
|
36746
36750
|
const params = {
|
|
36747
36751
|
fromChain,
|
|
36748
36752
|
fromToken: fromTokenAddress,
|
|
36749
36753
|
fromAddress,
|
|
36754
|
+
fromAmount,
|
|
36750
36755
|
toChain,
|
|
36751
36756
|
toToken: toTokenAddress,
|
|
36752
36757
|
toAddress: destinationAddress ?? "",
|
|
@@ -36763,18 +36768,12 @@ const useGetRoute = () => {
|
|
|
36763
36768
|
cosmosFallbackAddresses[0].address) {
|
|
36764
36769
|
params.fallbackAddresses = cosmosFallbackAddresses;
|
|
36765
36770
|
}
|
|
36766
|
-
if (!isZeroAmount(fromAmount)) {
|
|
36767
|
-
params.fromAmount = fromAmount;
|
|
36768
|
-
}
|
|
36769
|
-
else if (!isZeroAmount(toAmount)) {
|
|
36770
|
-
params.toAmount = toAmount;
|
|
36771
|
-
}
|
|
36772
36771
|
const { route } = await squid.getRoute({
|
|
36773
36772
|
...params,
|
|
36774
36773
|
});
|
|
36775
36774
|
// Cache the route data
|
|
36776
36775
|
// Useful when the getRoute mutation is called from another hook
|
|
36777
|
-
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);
|
|
36778
36777
|
return route;
|
|
36779
36778
|
});
|
|
36780
36779
|
};
|
|
@@ -36788,7 +36787,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36788
36787
|
const depositRefundAddress = useSwapRoutePersistStore((store) => store.swapRoute?.depositRefundAddress);
|
|
36789
36788
|
const { isAvailableAsPaymentMethod, isEnabled: isDepositAddressEnabled } = useDepositAddress();
|
|
36790
36789
|
const getRouteMutation = useGetRoute();
|
|
36791
|
-
const { fromChain, toChain,
|
|
36790
|
+
const { fromChain, toChain, fromPrice, destinationAddress: { address: destinationAddress } = {}, fromToken, toToken, } = useSwap();
|
|
36792
36791
|
const { connectedAddress: { address: sourceConnectedAddress }, } = useMultiChainWallet(fromChain);
|
|
36793
36792
|
// When the payment method is deposit address, users can specify a refund address on the source chain
|
|
36794
36793
|
// Tokens will be sent to this address in case of swap failure
|
|
@@ -36797,13 +36796,12 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36797
36796
|
const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
|
|
36798
36797
|
? depositRefundAddress ?? sourceConnectedAddress
|
|
36799
36798
|
: sourceConnectedAddress;
|
|
36800
|
-
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), [
|
|
36801
36800
|
fromChain?.chainId,
|
|
36802
36801
|
toChain?.chainId,
|
|
36803
36802
|
toToken?.address,
|
|
36804
36803
|
fromToken?.address,
|
|
36805
|
-
|
|
36806
|
-
toAmount,
|
|
36804
|
+
fromPrice,
|
|
36807
36805
|
config.slippage,
|
|
36808
36806
|
sourceUserAddress,
|
|
36809
36807
|
config.degenMode,
|
|
@@ -36818,7 +36816,8 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36818
36816
|
const queryEnabled = enabled != undefined
|
|
36819
36817
|
? enabled
|
|
36820
36818
|
: squid !== undefined &&
|
|
36821
|
-
|
|
36819
|
+
fromPrice !== undefined &&
|
|
36820
|
+
fromPrice !== "0" &&
|
|
36822
36821
|
toChain?.chainId !== undefined &&
|
|
36823
36822
|
toToken?.address !== undefined;
|
|
36824
36823
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -36836,8 +36835,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36836
36835
|
toToken,
|
|
36837
36836
|
sourceUserAddress,
|
|
36838
36837
|
destinationAddress,
|
|
36839
|
-
fromPrice
|
|
36840
|
-
toPrice: toAmount,
|
|
36838
|
+
fromPrice,
|
|
36841
36839
|
bypassGuardrails: config.degenMode,
|
|
36842
36840
|
quoteOnly,
|
|
36843
36841
|
fromChainType: fromChain?.chainType,
|
|
@@ -37465,6 +37463,7 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37465
37463
|
// Even with an error, we want wagmi to be defined so that we can display the maintenance mode layout
|
|
37466
37464
|
// Create wagmi config with mainnet as fallback in maintenance mode
|
|
37467
37465
|
const newWagmiConfig = wagmi.createConfig({
|
|
37466
|
+
ssr: true,
|
|
37468
37467
|
chains: [chains$1.mainnet],
|
|
37469
37468
|
connectors: [connectors.injected()],
|
|
37470
37469
|
transports: {
|
|
@@ -37644,7 +37643,6 @@ exports.isWalletAddressValid = isWalletAddressValid;
|
|
|
37644
37643
|
exports.isXamanXAppContext = isXamanXAppContext;
|
|
37645
37644
|
exports.isXionSmartContractAddress = isXionSmartContractAddress;
|
|
37646
37645
|
exports.isXrplAddressValid = isXrplAddressValid;
|
|
37647
|
-
exports.isZeroAmount = isZeroAmount;
|
|
37648
37646
|
exports.mergeWallets = mergeWallets;
|
|
37649
37647
|
exports.nativeBitcoinTokenAddress = nativeBitcoinTokenAddress;
|
|
37650
37648
|
exports.nativeCosmosTokenAddress = nativeCosmosTokenAddress;
|
|
@@ -37710,6 +37708,7 @@ exports.useEvmBalance = useEvmBalance;
|
|
|
37710
37708
|
exports.useEvmNativeBalance = useEvmNativeBalance;
|
|
37711
37709
|
exports.useExecuteFiatQuote = useExecuteFiatQuote;
|
|
37712
37710
|
exports.useExecuteTransaction = useExecuteTransaction;
|
|
37711
|
+
exports.useFavoriteChainsStore = useFavoriteChainsStore;
|
|
37713
37712
|
exports.useFavoriteTokensStore = useFavoriteTokensStore;
|
|
37714
37713
|
exports.useFiatOnRampTxStatus = useFiatOnRampTxStatus;
|
|
37715
37714
|
exports.useFiatTransactions = useFiatTransactions;
|
|
@@ -37767,4 +37766,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
37767
37766
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
37768
37767
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
37769
37768
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
37770
|
-
//# sourceMappingURL=index-
|
|
37769
|
+
//# sourceMappingURL=index-0fyTkU8o.js.map
|