@0xsquid/react-hooks 6.7.0 → 7.0.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/client/index.d.ts +13 -0
- package/dist/core/client/index.js +32 -0
- package/dist/core/client/index.js.map +1 -0
- package/dist/core/connectors/bitcoin/helpers.d.ts +15 -0
- package/dist/core/connectors/bitcoin/helpers.js +6 -1
- package/dist/core/connectors/bitcoin/helpers.js.map +1 -1
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/constants.js +2 -0
- package/dist/core/constants.js.map +1 -1
- package/dist/core/providers/SolanaProvider.d.ts +0 -2
- package/dist/core/providers/SolanaProvider.js.map +1 -1
- package/dist/core/queries/queries-keys.d.ts +18 -25
- package/dist/core/queries/queries-keys.js +52 -75
- package/dist/core/queries/queries-keys.js.map +1 -1
- package/dist/core/types/error.d.ts +4 -3
- package/dist/core/types/error.js.map +1 -1
- package/dist/core/types/event.d.ts +8 -0
- package/dist/core/types/history.d.ts +84 -0
- package/dist/core/types/history.js +7 -0
- package/dist/core/types/history.js.map +1 -0
- package/dist/core/types/index.d.ts +4 -1
- package/dist/core/types/index.js +2 -1
- package/dist/core/types/index.js.map +1 -1
- package/dist/core/types/onramps/index.d.ts +2 -0
- package/dist/core/types/onramps/index.js +3 -0
- package/dist/core/types/onramps/index.js.map +1 -0
- package/dist/core/types/onramps/onramp.d.ts +157 -0
- package/dist/core/types/onramps/onramp.js +2 -0
- package/dist/core/types/onramps/onramp.js.map +1 -0
- package/dist/core/types/onramps/revolut.d.ts +92 -0
- package/dist/core/types/onramps/revolut.js +2 -0
- package/dist/core/types/onramps/revolut.js.map +1 -0
- package/dist/core/types/transaction.d.ts +9 -31
- package/dist/core/types/transaction.js +6 -0
- package/dist/core/types/transaction.js.map +1 -1
- package/dist/hooks/client/useClient.d.ts +2 -0
- package/dist/hooks/client/useClient.js +58 -1
- package/dist/hooks/client/useClient.js.map +1 -1
- package/dist/hooks/cosmos/useCosmos.d.ts +9 -0
- package/dist/hooks/cosmos/useCosmos.js +36 -33
- package/dist/hooks/cosmos/useCosmos.js.map +1 -1
- package/dist/hooks/cosmos/useCosmosForChain.d.ts +1 -1
- package/dist/hooks/cosmos/useCosmosForChain.js +9 -13
- package/dist/hooks/cosmos/useCosmosForChain.js.map +1 -1
- package/dist/hooks/index.d.ts +8 -1
- package/dist/hooks/index.js +8 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/onramp/useFiatToCrypto.d.ts +84 -0
- package/dist/hooks/onramp/useFiatToCrypto.js +316 -0
- package/dist/hooks/onramp/useFiatToCrypto.js.map +1 -0
- package/dist/hooks/solana/useSolana.d.ts +2 -1
- package/dist/hooks/solana/useSolana.js +4 -2
- package/dist/hooks/solana/useSolana.js.map +1 -1
- package/dist/hooks/store/useHistoryStore.d.ts +33 -13
- package/dist/hooks/store/useHistoryStore.js +120 -32
- package/dist/hooks/store/useHistoryStore.js.map +1 -1
- package/dist/hooks/store/useSendTransactionStore.d.ts +20 -0
- package/dist/hooks/store/useSendTransactionStore.js +21 -0
- package/dist/hooks/store/useSendTransactionStore.js.map +1 -0
- package/dist/hooks/transaction/send/useEstimateSendTransactionGas.d.ts +28 -0
- package/dist/hooks/transaction/send/useEstimateSendTransactionGas.js +58 -0
- package/dist/hooks/transaction/send/useEstimateSendTransactionGas.js.map +1 -0
- package/dist/hooks/transaction/send/useSendTransaction.d.ts +13 -0
- package/dist/hooks/transaction/send/useSendTransaction.js +157 -0
- package/dist/hooks/transaction/send/useSendTransaction.js.map +1 -0
- package/dist/hooks/transaction/send/useSendTransactionGas.d.ts +6 -0
- package/dist/hooks/transaction/send/useSendTransactionGas.js +73 -0
- package/dist/hooks/transaction/send/useSendTransactionGas.js.map +1 -0
- package/dist/hooks/transaction/useAllTransactionsStatus.d.ts +34 -2
- package/dist/hooks/transaction/useAllTransactionsStatus.js +111 -59
- package/dist/hooks/transaction/useAllTransactionsStatus.js.map +1 -1
- package/dist/hooks/transaction/useApproval.js +2 -2
- package/dist/hooks/transaction/useApproval.js.map +1 -1
- package/dist/hooks/transaction/useEstimate.d.ts +1 -1
- package/dist/hooks/transaction/useExecuteTransaction.js +39 -22
- package/dist/hooks/transaction/useExecuteTransaction.js.map +1 -1
- package/dist/hooks/transaction/useSendTransactionStatus.d.ts +11 -0
- package/dist/hooks/transaction/useSendTransactionStatus.js +53 -0
- package/dist/hooks/transaction/useSendTransactionStatus.js.map +1 -0
- package/dist/hooks/transaction/useSwapTransactionStatus.d.ts +15 -0
- package/dist/hooks/transaction/{useSingleTransaction.js → useSwapTransactionStatus.js} +39 -16
- package/dist/hooks/transaction/useSwapTransactionStatus.js.map +1 -0
- package/dist/hooks/user/useHistory.d.ts +12 -10
- package/dist/hooks/user/useHistory.js +49 -52
- package/dist/hooks/user/useHistory.js.map +1 -1
- package/dist/hooks/utils/useUtils.d.ts +7 -0
- package/dist/hooks/utils/useUtils.js +20 -0
- package/dist/hooks/utils/useUtils.js.map +1 -0
- package/dist/hooks/wallet/useEns.d.ts +0 -1
- package/dist/hooks/wallet/useEns.js +1 -13
- package/dist/hooks/wallet/useEns.js.map +1 -1
- package/dist/hooks/wallet/useMultiChainWallet.d.ts +3 -0
- package/dist/hooks/wallet/useMultiChainWallet.js +19 -0
- package/dist/hooks/wallet/useMultiChainWallet.js.map +1 -1
- package/dist/hooks/wallet/useSigner.d.ts +6 -5
- package/dist/hooks/wallet/useSigner.js +16 -14
- package/dist/hooks/wallet/useSigner.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/services/external/index.d.ts +1 -0
- package/dist/services/external/index.js +2 -0
- package/dist/services/external/index.js.map +1 -0
- package/dist/services/external/onrampAdapter.d.ts +12 -0
- package/dist/services/external/onrampAdapter.js +41 -0
- package/dist/services/external/onrampAdapter.js.map +1 -0
- package/dist/services/external/rpcService.d.ts +2 -2
- package/dist/services/external/rpcService.js +2 -5
- package/dist/services/external/rpcService.js.map +1 -1
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.js +2 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/internal/assetsService.d.ts +2 -0
- package/dist/services/internal/assetsService.js +6 -0
- package/dist/services/internal/assetsService.js.map +1 -1
- package/dist/services/internal/countryCurrencyMap.d.ts +13 -0
- package/dist/services/internal/countryCurrencyMap.js +1102 -0
- package/dist/services/internal/countryCurrencyMap.js.map +1 -0
- package/dist/services/internal/errorService.d.ts +3 -7
- package/dist/services/internal/errorService.js.map +1 -1
- package/dist/services/internal/estimateService.js +5 -5
- package/dist/services/internal/estimateService.js.map +1 -1
- package/dist/services/internal/eventService.d.ts +16 -0
- package/dist/services/internal/eventService.js +14 -0
- package/dist/services/internal/eventService.js.map +1 -1
- package/dist/services/internal/fiatToCryptoService.d.ts +29 -0
- package/dist/services/internal/fiatToCryptoService.js +84 -0
- package/dist/services/internal/fiatToCryptoService.js.map +1 -0
- package/dist/services/internal/fiatToCryptoService.test.d.ts +1 -0
- package/dist/services/internal/fiatToCryptoService.test.js +45 -0
- package/dist/services/internal/fiatToCryptoService.test.js.map +1 -0
- package/dist/services/internal/numberService.d.ts +1 -0
- package/dist/services/internal/numberService.js +15 -0
- package/dist/services/internal/numberService.js.map +1 -1
- package/dist/services/internal/searchService.d.ts +1 -1
- package/dist/services/internal/searchService.js +11 -11
- package/dist/services/internal/searchService.js.map +1 -1
- package/dist/services/internal/sendTransaction.d.ts +35 -0
- package/dist/services/internal/sendTransaction.js +66 -0
- package/dist/services/internal/sendTransaction.js.map +1 -0
- package/dist/services/internal/sendTransactionStatus.d.ts +6 -0
- package/dist/services/internal/sendTransactionStatus.js +98 -0
- package/dist/services/internal/sendTransactionStatus.js.map +1 -0
- package/dist/services/internal/transactionService.d.ts +8 -36
- package/dist/services/internal/transactionService.js +27 -26
- package/dist/services/internal/transactionService.js.map +1 -1
- package/dist/services/internal/transactionStatusService.d.ts +16 -5
- package/dist/services/internal/transactionStatusService.js +79 -5
- package/dist/services/internal/transactionStatusService.js.map +1 -1
- package/dist/tests/assetsService.test.js +13 -26
- package/dist/tests/assetsService.test.js.map +1 -1
- package/dist/tests/numberService.test.js +12 -1
- package/dist/tests/numberService.test.js.map +1 -1
- package/dist/tests/searchService.test.js +0 -6
- package/dist/tests/searchService.test.js.map +1 -1
- package/dist/tests/transactionService.test.js +18 -18
- package/dist/tests/transactionService.test.js.map +1 -1
- package/package.json +3 -1
- package/dist/hooks/transaction/useSingleTransaction.d.ts +0 -10
- package/dist/hooks/transaction/useSingleTransaction.js.map +0 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export type { AppConfig } from "./config";
|
|
2
|
+
export { SquidStatusErrorType, type SquidRouteError, type SquidRouteErrorType, type SquidStatusError, } from "./error";
|
|
3
|
+
export type * from "./history";
|
|
4
|
+
export type * from "./onramps/";
|
|
2
5
|
export type { SwapParams } from "./swap";
|
|
3
6
|
export type { Chain, Token } from "./tokens";
|
|
4
|
-
export { AxelarStatusResponseType,
|
|
7
|
+
export { AxelarStatusResponseType, SendTransactionStatus, TransactionStatus, type TransactionParams, } from "./transaction";
|
|
5
8
|
export type { BitcoinWallet, ConnectorID, CosmosWallet, EnsData, EnsSearchResult, FullAddressData, NetworkConfig, SolanaWallet, SupportedChain, Wallet, } from "./wallet";
|
package/dist/core/types/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/types/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,GAIrB,MAAM,SAAS,CAAC;AAKjB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,GAElB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/types/onramps/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { ChainData } from "@0xsquid/squid-types";
|
|
2
|
+
import { ICountry } from "countries-list";
|
|
3
|
+
import { Token } from "../tokens";
|
|
4
|
+
export type OnRampTransactionStatusType = "awaiting_payment" | "processing" | "completed" | "failed";
|
|
5
|
+
export type PaymentMethodType = "credit_card" | "bank_transfer";
|
|
6
|
+
export type OnRampProviderType = "revolut" | "onramper";
|
|
7
|
+
export type ExecuteFiatQuoteResult = {
|
|
8
|
+
redirectUrl: string | unknown;
|
|
9
|
+
orderId: string;
|
|
10
|
+
};
|
|
11
|
+
export type ExecuteFiatQuoteResultClient = ExecuteFiatQuoteResult & {
|
|
12
|
+
executeQuoteRequest: ExecuteQuoteClient;
|
|
13
|
+
toChain: ChainData | undefined;
|
|
14
|
+
};
|
|
15
|
+
export type OnRampQuoteResponse = {
|
|
16
|
+
fiatCurrency: string;
|
|
17
|
+
cryptoCurrencyID: string;
|
|
18
|
+
amount: number;
|
|
19
|
+
fees?: {
|
|
20
|
+
fixed?: number;
|
|
21
|
+
percentage?: number;
|
|
22
|
+
};
|
|
23
|
+
cryptoAmount: number;
|
|
24
|
+
};
|
|
25
|
+
export type OnRampQuoteParams = {
|
|
26
|
+
fiatCurrency: string;
|
|
27
|
+
cryptoCurrencyID: string;
|
|
28
|
+
amount: number | string;
|
|
29
|
+
paymentMethod?: string;
|
|
30
|
+
region?: string;
|
|
31
|
+
};
|
|
32
|
+
export type OnRampTransactionStatus = {
|
|
33
|
+
transactionId: string;
|
|
34
|
+
transactionHash?: string;
|
|
35
|
+
status: OnRampTransactionStatusType;
|
|
36
|
+
createdAt: string;
|
|
37
|
+
updatedAt: string;
|
|
38
|
+
errorMessage?: string | null;
|
|
39
|
+
};
|
|
40
|
+
export type ExecuteQuoteServer = {
|
|
41
|
+
orderId: string;
|
|
42
|
+
fiatCurrency: string;
|
|
43
|
+
cryptoCurrencyID: string;
|
|
44
|
+
amount: number;
|
|
45
|
+
walletAddress: string;
|
|
46
|
+
paymentMethod: PaymentMethodType;
|
|
47
|
+
region?: string;
|
|
48
|
+
onrampProviderId: string;
|
|
49
|
+
};
|
|
50
|
+
export type ExecuteQuoteClient = Omit<ExecuteQuoteServer, "paymentMethod"> & {
|
|
51
|
+
cryptoAmount: number;
|
|
52
|
+
squidToken?: {
|
|
53
|
+
address: string;
|
|
54
|
+
chainId: string;
|
|
55
|
+
};
|
|
56
|
+
providerId: string;
|
|
57
|
+
paymentMethod: PaymentMethodType | string;
|
|
58
|
+
};
|
|
59
|
+
export type FiatCurrency = {
|
|
60
|
+
denomination: string;
|
|
61
|
+
minLimit?: number;
|
|
62
|
+
maxLimit?: number;
|
|
63
|
+
};
|
|
64
|
+
export type FiatCurrencyEnhanced = FiatCurrency & {
|
|
65
|
+
symbol: string;
|
|
66
|
+
name?: string;
|
|
67
|
+
flagUrl?: string;
|
|
68
|
+
countryCode?: string;
|
|
69
|
+
};
|
|
70
|
+
export type OnRampCryptoAsset = {
|
|
71
|
+
tokenSymbol: string;
|
|
72
|
+
blockchain: string;
|
|
73
|
+
smartContractAddress?: string;
|
|
74
|
+
};
|
|
75
|
+
export type TokenWithOnRampID = Token & {
|
|
76
|
+
cryptoCurrencyID: string;
|
|
77
|
+
};
|
|
78
|
+
export type CountryWithCode = ICountry & {
|
|
79
|
+
code: string;
|
|
80
|
+
flagUrl?: string;
|
|
81
|
+
};
|
|
82
|
+
export type FiatToCryptoConfig = {
|
|
83
|
+
supportedPaymentMethods: string[];
|
|
84
|
+
supportedTokens: TokenWithOnRampID[];
|
|
85
|
+
supportedCurrencies: FiatCurrencyEnhanced[];
|
|
86
|
+
supportedCountries: CountryWithCode[];
|
|
87
|
+
};
|
|
88
|
+
export type OnrampPaymentMethodType = "credit_card" | "bank_transfer" | "apple_pay" | "google_pay" | "revolut";
|
|
89
|
+
export interface OnrampPaymentMethodLimits {
|
|
90
|
+
min: number;
|
|
91
|
+
max: number;
|
|
92
|
+
}
|
|
93
|
+
export interface OnrampPaymentMethodDetails {
|
|
94
|
+
currencyStatus: string;
|
|
95
|
+
limits: {
|
|
96
|
+
[provider: string]: OnrampPaymentMethodLimits;
|
|
97
|
+
aggregatedLimit: OnrampPaymentMethodLimits;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export interface OnrampPaymentMethod {
|
|
101
|
+
id: string;
|
|
102
|
+
name: string;
|
|
103
|
+
icon?: string;
|
|
104
|
+
isRecommended?: boolean;
|
|
105
|
+
details?: OnrampPaymentMethodDetails;
|
|
106
|
+
}
|
|
107
|
+
export type OnrampPaymentMethodRecommendation = "BestPrice" | "Fastest" | "LowestFee";
|
|
108
|
+
export interface OnrampQuoteResult {
|
|
109
|
+
internalProviderId: string;
|
|
110
|
+
onrampProviderId: string;
|
|
111
|
+
providerName: string;
|
|
112
|
+
providerIcon?: string;
|
|
113
|
+
recommendations?: OnrampPaymentMethodRecommendation[] | string[];
|
|
114
|
+
rate: number;
|
|
115
|
+
networkFee: number;
|
|
116
|
+
serviceFee: number;
|
|
117
|
+
totalFee: number;
|
|
118
|
+
receivedAmount: number;
|
|
119
|
+
paymentMethods: OnrampPaymentMethod[];
|
|
120
|
+
paymentMethodsRecommendation?: {
|
|
121
|
+
recommendedId: string;
|
|
122
|
+
reason?: string;
|
|
123
|
+
};
|
|
124
|
+
quoteId?: string;
|
|
125
|
+
}
|
|
126
|
+
export interface OnrampQuoteResponse {
|
|
127
|
+
quotes: OnrampQuoteResult[];
|
|
128
|
+
recommendedQuote?: {
|
|
129
|
+
internalProviderId: string;
|
|
130
|
+
onrampProviderId: string;
|
|
131
|
+
reason?: string;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export interface OnrampConfigResponse {
|
|
135
|
+
id: string;
|
|
136
|
+
name: string;
|
|
137
|
+
icon?: string;
|
|
138
|
+
supportedFiats: string[];
|
|
139
|
+
supportedCryptos: {
|
|
140
|
+
id: string;
|
|
141
|
+
address: string;
|
|
142
|
+
chainId: string;
|
|
143
|
+
}[];
|
|
144
|
+
supportedCountries: string[];
|
|
145
|
+
supportedPaymentMethods?: string[];
|
|
146
|
+
supportedOnramps?: {
|
|
147
|
+
id: string;
|
|
148
|
+
name: string;
|
|
149
|
+
icon?: string;
|
|
150
|
+
}[];
|
|
151
|
+
limits?: {
|
|
152
|
+
[key: string]: {
|
|
153
|
+
min: number;
|
|
154
|
+
max: number;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onramp.js","sourceRoot":"","sources":["../../../../src/core/types/onramps/onramp.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export interface RevolutQuoteResponse {
|
|
2
|
+
service_fee: {
|
|
3
|
+
amount: number;
|
|
4
|
+
currency: string;
|
|
5
|
+
};
|
|
6
|
+
network_fee: {
|
|
7
|
+
amount: number;
|
|
8
|
+
currency: string;
|
|
9
|
+
};
|
|
10
|
+
crypto: {
|
|
11
|
+
amount: number;
|
|
12
|
+
currencyId: string;
|
|
13
|
+
};
|
|
14
|
+
partner_fee: {
|
|
15
|
+
amount: number;
|
|
16
|
+
currency: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface RevolutRedirectResponse {
|
|
20
|
+
ramp_redirect_url: string;
|
|
21
|
+
}
|
|
22
|
+
export interface RevolutQuoteParams {
|
|
23
|
+
fiat: string;
|
|
24
|
+
crypto: string;
|
|
25
|
+
amount: string;
|
|
26
|
+
payment?: string;
|
|
27
|
+
region?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface RevolutCryptoAsset {
|
|
30
|
+
id: string;
|
|
31
|
+
currency: string;
|
|
32
|
+
blockchain: string;
|
|
33
|
+
smartContractAddress?: string;
|
|
34
|
+
feePercentages?: number[];
|
|
35
|
+
}
|
|
36
|
+
export interface RevolutConfig {
|
|
37
|
+
version: string;
|
|
38
|
+
countries: string[];
|
|
39
|
+
fiat: {
|
|
40
|
+
currency: string;
|
|
41
|
+
min_limit: number;
|
|
42
|
+
max_limit: number;
|
|
43
|
+
}[];
|
|
44
|
+
crypto: RevolutCryptoAsset[];
|
|
45
|
+
payment_methods: string[];
|
|
46
|
+
}
|
|
47
|
+
export interface RevolutOrderStatus {
|
|
48
|
+
id: string;
|
|
49
|
+
fiat: {
|
|
50
|
+
amount: number;
|
|
51
|
+
currency: string;
|
|
52
|
+
};
|
|
53
|
+
crypto: {
|
|
54
|
+
amount: number;
|
|
55
|
+
currencyId: string;
|
|
56
|
+
};
|
|
57
|
+
fees: {
|
|
58
|
+
ramp_fee: {
|
|
59
|
+
amount: number;
|
|
60
|
+
currency: string;
|
|
61
|
+
};
|
|
62
|
+
partner_fee: {
|
|
63
|
+
amount: number;
|
|
64
|
+
currency: string;
|
|
65
|
+
};
|
|
66
|
+
network_fee: {
|
|
67
|
+
amount: number;
|
|
68
|
+
currency: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
exchange_rate: number;
|
|
72
|
+
payment: string;
|
|
73
|
+
created_at: string;
|
|
74
|
+
updated_at: string;
|
|
75
|
+
status: string;
|
|
76
|
+
wallet: string;
|
|
77
|
+
transaction_hash?: string;
|
|
78
|
+
fees_partner_currency: {
|
|
79
|
+
ramp_fee: {
|
|
80
|
+
amount: number;
|
|
81
|
+
currency: string;
|
|
82
|
+
};
|
|
83
|
+
partner_fee: {
|
|
84
|
+
amount: number;
|
|
85
|
+
currency: string;
|
|
86
|
+
};
|
|
87
|
+
network_fee: {
|
|
88
|
+
amount: number;
|
|
89
|
+
currency: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revolut.js","sourceRoot":"","sources":["../../../../src/core/types/onramps/revolut.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { ChainData, RouteActionResponse, RouteResponse
|
|
1
|
+
import type { ChainData, RouteActionResponse, RouteResponse } from "@0xsquid/squid-types";
|
|
2
2
|
import type { UseQueryResult } from "@tanstack/react-query";
|
|
3
3
|
import type { TransactionErrorWithMessage } from "./error";
|
|
4
|
+
import { SwapTransactionHistory } from "./history";
|
|
4
5
|
export declare enum TransactionType {
|
|
5
6
|
BRIDGE = "BRIDGE",
|
|
6
7
|
BRIDGE_CALL = "BRIDGE_CALL",
|
|
@@ -35,6 +36,11 @@ export declare enum TransactionStatus {
|
|
|
35
36
|
REJECTED = "rejected",
|
|
36
37
|
REFUNDED = "refunded"
|
|
37
38
|
}
|
|
39
|
+
export declare enum SendTransactionStatus {
|
|
40
|
+
ONGOING = 0,
|
|
41
|
+
SUCCESS = 1,
|
|
42
|
+
ERROR = 2
|
|
43
|
+
}
|
|
38
44
|
export interface TransactionParams {
|
|
39
45
|
routeType: string;
|
|
40
46
|
fromChain?: ChainData;
|
|
@@ -53,7 +59,7 @@ export interface TransactionParams {
|
|
|
53
59
|
sourceTxExplorerUrl?: string;
|
|
54
60
|
sourceExplorerImgUrl?: string;
|
|
55
61
|
}
|
|
56
|
-
export type
|
|
62
|
+
export type SwapTransactionForHistoryStore = TransactionParams & Pick<RouteResponse["route"], "params" | "estimate">;
|
|
57
63
|
export interface StepStatusGetterProps {
|
|
58
64
|
transaction?: TransactionParams;
|
|
59
65
|
statusResponse?: UseQueryResult<any, unknown>;
|
|
@@ -62,35 +68,7 @@ export interface StepStatusGetterProps {
|
|
|
62
68
|
export interface PatchedRouteActionResponse extends Omit<RouteActionResponse, "data"> {
|
|
63
69
|
data?: RouteActionResponse["data"];
|
|
64
70
|
}
|
|
65
|
-
export type
|
|
71
|
+
export type SwapTransactionForStatus = Pick<SwapTransactionHistory, "fromChain" | "transactionId" | "toChain" | "status" | "fromAddress" | "bridgeType" | "transactionIdForStatus" | "actions" | "requestId">;
|
|
66
72
|
export type SimplifiedRouteAction = Pick<PatchedRouteActionResponse, "type" | "provider"> & {
|
|
67
73
|
data?: any;
|
|
68
74
|
};
|
|
69
|
-
export type SimplifiedTransactionHistory = {
|
|
70
|
-
fromChain: string;
|
|
71
|
-
fromToken: string;
|
|
72
|
-
fromAddress: string;
|
|
73
|
-
fromAmount: string;
|
|
74
|
-
toChain: string;
|
|
75
|
-
toToken: string;
|
|
76
|
-
transactionId: string;
|
|
77
|
-
transactionIdForStatus?: string;
|
|
78
|
-
requestId: string | undefined;
|
|
79
|
-
toAddress: string;
|
|
80
|
-
toAmount: string;
|
|
81
|
-
toAmountMin: string;
|
|
82
|
-
exchangeRate: string;
|
|
83
|
-
status: TransactionStatus;
|
|
84
|
-
aggregatePriceImpact?: string;
|
|
85
|
-
toAmountMinUSD?: string;
|
|
86
|
-
fromAmountUSD?: string;
|
|
87
|
-
toAmountUSD?: string;
|
|
88
|
-
timestamp: number;
|
|
89
|
-
slippage?: number;
|
|
90
|
-
nonce?: number;
|
|
91
|
-
routeType: string | undefined;
|
|
92
|
-
statusResponse?: StatusResponse;
|
|
93
|
-
sourceTxExplorerUrl?: string;
|
|
94
|
-
bridgeType?: string;
|
|
95
|
-
actions?: SimplifiedRouteAction[];
|
|
96
|
-
};
|
|
@@ -38,4 +38,10 @@ export var TransactionStatus;
|
|
|
38
38
|
// Coral refund
|
|
39
39
|
TransactionStatus["REFUNDED"] = "refunded";
|
|
40
40
|
})(TransactionStatus || (TransactionStatus = {}));
|
|
41
|
+
export var SendTransactionStatus;
|
|
42
|
+
(function (SendTransactionStatus) {
|
|
43
|
+
SendTransactionStatus[SendTransactionStatus["ONGOING"] = 0] = "ONGOING";
|
|
44
|
+
SendTransactionStatus[SendTransactionStatus["SUCCESS"] = 1] = "SUCCESS";
|
|
45
|
+
SendTransactionStatus[SendTransactionStatus["ERROR"] = 2] = "ERROR";
|
|
46
|
+
})(SendTransactionStatus || (SendTransactionStatus = {}));
|
|
41
47
|
//# sourceMappingURL=transaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/core/types/transaction.ts"],"names":[],"mappings":"AASA,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,8CAA2B,CAAA;IAC3B,8CAA2B,CAAA;IAC3B,wDAAqC,CAAA;AACvC,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B;AAED,MAAM,CAAN,IAAY,wBAaX;AAbD,WAAY,wBAAwB;IAClC,+EAAmD,CAAA;IACnD,yEAA6C,CAAA;IAC7C,iEAAqC,CAAA;IACrC,+EAAmD,CAAA;IACnD,2EAA+C,CAAA;IAC/C,wEAA4C,CAAA;IAC5C,kFAAsD,CAAA;IACtD,mFAAuD,CAAA;IACvD,+DAAmC,CAAA;IACnC,2DAA+B,CAAA;IAC/B,uEAA2C,CAAA;IAC3C,2CAAe,CAAA;AACjB,CAAC,EAbW,wBAAwB,KAAxB,wBAAwB,QAanC;AAED,MAAM,CAAN,IAAY,iBAgBX;AAhBD,WAAY,iBAAiB;IAC3B,kDAAkD;IAClD,wCAAmB,CAAA;IACnB,4CAAuB,CAAA;IACvB,wCAAmB,CAAA;IACnB,wDAAmC,CAAA;IACnC,4CAAuB,CAAA;IACvB,qDAAqD;IACrD,uDAAkC,CAAA;IAClC,8DAAyC,CAAA;IACzC,oCAAe,CAAA;IACf,wCAAmB,CAAA;IACnB,wCAAmB,CAAA;IACnB,0CAAqB,CAAA;IACrB,eAAe;IACf,0CAAqB,CAAA;AACvB,CAAC,EAhBW,iBAAiB,KAAjB,iBAAiB,QAgB5B"}
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/core/types/transaction.ts"],"names":[],"mappings":"AASA,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,8CAA2B,CAAA;IAC3B,8CAA2B,CAAA;IAC3B,wDAAqC,CAAA;AACvC,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B;AAED,MAAM,CAAN,IAAY,wBAaX;AAbD,WAAY,wBAAwB;IAClC,+EAAmD,CAAA;IACnD,yEAA6C,CAAA;IAC7C,iEAAqC,CAAA;IACrC,+EAAmD,CAAA;IACnD,2EAA+C,CAAA;IAC/C,wEAA4C,CAAA;IAC5C,kFAAsD,CAAA;IACtD,mFAAuD,CAAA;IACvD,+DAAmC,CAAA;IACnC,2DAA+B,CAAA;IAC/B,uEAA2C,CAAA;IAC3C,2CAAe,CAAA;AACjB,CAAC,EAbW,wBAAwB,KAAxB,wBAAwB,QAanC;AAED,MAAM,CAAN,IAAY,iBAgBX;AAhBD,WAAY,iBAAiB;IAC3B,kDAAkD;IAClD,wCAAmB,CAAA;IACnB,4CAAuB,CAAA;IACvB,wCAAmB,CAAA;IACnB,wDAAmC,CAAA;IACnC,4CAAuB,CAAA;IACvB,qDAAqD;IACrD,uDAAkC,CAAA;IAClC,8DAAyC,CAAA;IACzC,oCAAe,CAAA;IACf,wCAAmB,CAAA;IACnB,wCAAmB,CAAA;IACnB,0CAAqB,CAAA;IACrB,eAAe;IACf,0CAAqB,CAAA;AACvB,CAAC,EAhBW,iBAAiB,KAAjB,iBAAiB,QAgB5B;AAED,MAAM,CAAN,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,uEAAO,CAAA;IACP,uEAAO,CAAA;IACP,mEAAK,CAAA;AACP,CAAC,EAJW,qBAAqB,KAArB,qBAAqB,QAIhC"}
|
|
@@ -1,6 +1,63 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { DEFAULT_COUNTRY_CODE } from "../../core/constants";
|
|
3
|
+
import { keys } from "../../core/queries/queries-keys";
|
|
4
|
+
import { countryCurrencyMap } from "../../services/internal/countryCurrencyMap";
|
|
5
|
+
import { getUserCountry } from "../../services/internal/fiatToCryptoService";
|
|
6
|
+
const CACHE_TIME = 1000 * 60 * 60 * 24 * 2; // 2 days
|
|
7
|
+
const STALE_TIME = 1000 * 60 * 60 * 12; // 12 hours
|
|
8
|
+
// List of European Union country codes that use the Euro
|
|
9
|
+
const EU_COUNTRIES = [
|
|
10
|
+
"at",
|
|
11
|
+
"be",
|
|
12
|
+
"bg",
|
|
13
|
+
"hr",
|
|
14
|
+
"cy",
|
|
15
|
+
"cz",
|
|
16
|
+
"dk",
|
|
17
|
+
"ee",
|
|
18
|
+
"fi",
|
|
19
|
+
"fr",
|
|
20
|
+
"de",
|
|
21
|
+
"gr",
|
|
22
|
+
"hu",
|
|
23
|
+
"ie",
|
|
24
|
+
"it",
|
|
25
|
+
"lv",
|
|
26
|
+
"lt",
|
|
27
|
+
"lu",
|
|
28
|
+
"mt",
|
|
29
|
+
"nl",
|
|
30
|
+
"pl",
|
|
31
|
+
"pt",
|
|
32
|
+
"ro",
|
|
33
|
+
"sk",
|
|
34
|
+
"si",
|
|
35
|
+
"es",
|
|
36
|
+
"se",
|
|
37
|
+
];
|
|
1
38
|
export const useClient = () => {
|
|
2
39
|
const isClient = typeof window !== "undefined";
|
|
3
40
|
const clientWindow = isClient ? window : undefined;
|
|
4
|
-
|
|
41
|
+
const { data: countryData } = useQuery({
|
|
42
|
+
queryKey: keys().country(),
|
|
43
|
+
queryFn: getUserCountry,
|
|
44
|
+
enabled: isClient,
|
|
45
|
+
retry: false,
|
|
46
|
+
cacheTime: CACHE_TIME,
|
|
47
|
+
staleTime: STALE_TIME,
|
|
48
|
+
});
|
|
49
|
+
const userCountry = countryData?.countryCode || DEFAULT_COUNTRY_CODE;
|
|
50
|
+
// Get default currency based on user country
|
|
51
|
+
const defaultCurrency = (() => {
|
|
52
|
+
const userCountryLower = userCountry.toLowerCase();
|
|
53
|
+
// Check if user is from an EU country
|
|
54
|
+
if (EU_COUNTRIES.includes(userCountryLower)) {
|
|
55
|
+
return "EUR";
|
|
56
|
+
}
|
|
57
|
+
// Fall back to country-specific currency or USD
|
|
58
|
+
const countryInfo = countryCurrencyMap.find((c) => c.countryCode.toLowerCase() === userCountryLower);
|
|
59
|
+
return countryInfo?.currencyCode || "USD";
|
|
60
|
+
})();
|
|
61
|
+
return { clientWindow, isClient, userCountry, defaultCurrency };
|
|
5
62
|
};
|
|
6
63
|
//# sourceMappingURL=useClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClient.js","sourceRoot":"","sources":["../../../src/hooks/client/useClient.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;IAC/C,MAAM,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAEnD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"useClient.js","sourceRoot":"","sources":["../../../src/hooks/client/useClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAE7E,MAAM,UAAU,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS;AACrD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW;AAEnD,yDAAyD;AACzD,MAAM,YAAY,GAAG;IACnB,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAA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
|
+
import type { ChainData } from "@0xsquid/squid-types";
|
|
2
|
+
import { OfflineSigner } from "@cosmjs/proto-signing";
|
|
3
|
+
import type { Keplr } from "@keplr-wallet/types";
|
|
1
4
|
import { ICosmosContextData } from "../../core/providers/CosmosProvider";
|
|
2
5
|
export declare const useCosmos: () => ICosmosContextData;
|
|
6
|
+
export declare function useCosmosSigner({ chain }: {
|
|
7
|
+
chain: ChainData | undefined;
|
|
8
|
+
}): {
|
|
9
|
+
signer: OfflineSigner | undefined;
|
|
10
|
+
keplrTypeWallet: Keplr | undefined;
|
|
11
|
+
};
|
|
@@ -13,43 +13,16 @@ export const useCosmos = () => {
|
|
|
13
13
|
const cosmosWalletState = useWalletStore((state) => state.connectedWalletsByChainType[ChainType.COSMOS]);
|
|
14
14
|
const cosmosAddress = cosmosWalletState?.address;
|
|
15
15
|
const isConnected = !!cosmosAddress;
|
|
16
|
-
const cosmosConnectedWallet = cosmosWalletState
|
|
17
|
-
const [cosmosSigner, setCosmosSigner] = useState(undefined);
|
|
16
|
+
const cosmosConnectedWallet = cosmosWalletState.wallet;
|
|
18
17
|
const [cosmosChainId, setCosmosChainId] = useState();
|
|
19
18
|
const { swapRoute } = useSwapRoutePersistStore();
|
|
20
19
|
const { fromChain } = useSwap();
|
|
21
20
|
const { cosmosChains } = useSquidChains();
|
|
22
|
-
const { clientWindow
|
|
21
|
+
const { clientWindow } = useClient();
|
|
23
22
|
const { setConnectedWallet, disconnectWallet } = useWalletStore();
|
|
24
|
-
const keplrTypeWallet =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
const connector = getConnectorForChainType(cosmosWalletState.wallet, ChainType.COSMOS);
|
|
29
|
-
return connector?.()?.provider;
|
|
30
|
-
}, [cosmosWalletState.wallet, isClient]);
|
|
31
|
-
/**
|
|
32
|
-
* Get the appropriate Cosmos signer based on the chain
|
|
33
|
-
* Noble chain requires full signer for CCTP messages
|
|
34
|
-
* Other chains use Amino signer for Ledger compatibility
|
|
35
|
-
*/
|
|
36
|
-
const getCosmosSignerForChain = useCallback((chainId, wallet) => {
|
|
37
|
-
return chainId === CHAIN_IDS.NOBLE
|
|
38
|
-
? wallet.getOfflineSigner(chainId)
|
|
39
|
-
: wallet.getOfflineSignerOnlyAmino(chainId);
|
|
40
|
-
}, []);
|
|
41
|
-
// As soon as from chain changes, need to fetch the new signer
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (fromChain?.chainType === ChainType.COSMOS && keplrTypeWallet) {
|
|
44
|
-
const newCosmosSigner = getCosmosSignerForChain(fromChain.chainId.toString(), keplrTypeWallet);
|
|
45
|
-
setCosmosSigner(newCosmosSigner);
|
|
46
|
-
}
|
|
47
|
-
}, [
|
|
48
|
-
fromChain?.chainId,
|
|
49
|
-
fromChain?.chainType,
|
|
50
|
-
keplrTypeWallet,
|
|
51
|
-
getCosmosSignerForChain,
|
|
52
|
-
]);
|
|
23
|
+
const { keplrTypeWallet, signer: cosmosSigner } = useCosmosSigner({
|
|
24
|
+
chain: fromChain,
|
|
25
|
+
});
|
|
53
26
|
const getCosmosAddressForChain = useCallback(async (chainId) => {
|
|
54
27
|
return getCosmosKey(chainId, keplrTypeWallet);
|
|
55
28
|
}, [keplrTypeWallet]);
|
|
@@ -163,10 +136,40 @@ export const useCosmos = () => {
|
|
|
163
136
|
isConnected,
|
|
164
137
|
onCosmosChainChange,
|
|
165
138
|
cosmosConnectedWallet,
|
|
166
|
-
keplrTypeWallet,
|
|
167
139
|
cosmosSigner,
|
|
140
|
+
keplrTypeWallet,
|
|
168
141
|
getCosmosAddressForChain,
|
|
169
142
|
cosmosAddress,
|
|
170
143
|
};
|
|
171
144
|
};
|
|
145
|
+
export function useCosmosSigner({ chain }) {
|
|
146
|
+
const cosmosWalletState = useWalletStore((state) => state.connectedWalletsByChainType[ChainType.COSMOS]);
|
|
147
|
+
/**
|
|
148
|
+
* Get the appropriate Cosmos signer based on the chain
|
|
149
|
+
* Noble chain requires full signer for CCTP messages
|
|
150
|
+
* Other chains use Amino signer for Ledger compatibility
|
|
151
|
+
*/
|
|
152
|
+
const getCosmosSignerForChain = useCallback((chainId, wallet) => {
|
|
153
|
+
return chainId === CHAIN_IDS.NOBLE
|
|
154
|
+
? wallet.getOfflineSigner(chainId)
|
|
155
|
+
: wallet.getOfflineSignerOnlyAmino(chainId);
|
|
156
|
+
}, []);
|
|
157
|
+
const connector = useMemo(() => {
|
|
158
|
+
if (!cosmosWalletState?.wallet) {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
const cosmosConnector = getConnectorForChainType(cosmosWalletState.wallet, ChainType.COSMOS);
|
|
162
|
+
if (!cosmosConnector)
|
|
163
|
+
return undefined;
|
|
164
|
+
return cosmosConnector()?.provider;
|
|
165
|
+
}, [cosmosWalletState?.wallet]);
|
|
166
|
+
const signer = useMemo(() => {
|
|
167
|
+
if (!connector || chain?.chainType !== ChainType.COSMOS)
|
|
168
|
+
return;
|
|
169
|
+
// use Amino signer for Ledger compatibility
|
|
170
|
+
const newCosmosSigner = getCosmosSignerForChain(chain.chainId, connector);
|
|
171
|
+
return newCosmosSigner;
|
|
172
|
+
}, [chain?.chainId, chain?.chainType, connector]);
|
|
173
|
+
return { signer, keplrTypeWallet: connector };
|
|
174
|
+
}
|
|
172
175
|
//# sourceMappingURL=useCosmos.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCosmos.js","sourceRoot":"","sources":["../../../src/hooks/cosmos/useCosmos.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,mBAAmB,GACpB,MAAM,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|
import type { ChainData } from "@0xsquid/squid-types";
|
|
2
2
|
import { UseQueryResult } from "@tanstack/react-query";
|
|
3
|
-
export declare const useCosmosForChain: (
|
|
3
|
+
export declare const useCosmosForChain: (chain: ChainData | undefined) => UseQueryResult<string, unknown>;
|
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
import { ChainType } from "@0xsquid/squid-types";
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
|
-
import { useCosmosContext } from "../../core/providers/CosmosProvider";
|
|
4
3
|
import { keys } from "../../core/queries/queries-keys";
|
|
5
4
|
import { getCosmosKey, suggestChainOrThrow, } from "../../services/internal/cosmosService";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
5
|
+
import { useCosmosSigner } from "./useCosmos";
|
|
6
|
+
export const useCosmosForChain = (chain) => {
|
|
7
|
+
const { keplrTypeWallet } = useCosmosSigner({ chain });
|
|
8
|
+
const cosmosAddressQuery = useQuery(keys().cosmosAddress(chain?.chainId), async () => {
|
|
9
|
+
if (!chain || !keplrTypeWallet)
|
|
10
10
|
return "";
|
|
11
11
|
try {
|
|
12
|
-
const address = await getCosmosKey(
|
|
12
|
+
const address = await getCosmosKey(chain.chainId, keplrTypeWallet);
|
|
13
13
|
return address ?? "";
|
|
14
14
|
}
|
|
15
15
|
catch (error) {
|
|
16
16
|
await suggestChainOrThrow({
|
|
17
|
-
chain:
|
|
17
|
+
chain: chain,
|
|
18
18
|
error,
|
|
19
19
|
keplrTypeWallet,
|
|
20
20
|
});
|
|
21
|
-
const address = await getCosmosKey(
|
|
21
|
+
const address = await getCosmosKey(chain.chainId, keplrTypeWallet);
|
|
22
22
|
return address ?? "";
|
|
23
23
|
}
|
|
24
24
|
}, {
|
|
25
|
-
enabled:
|
|
26
|
-
!!keplrTypeWallet &&
|
|
27
|
-
!!chainId &&
|
|
28
|
-
!!cosmosAddress &&
|
|
29
|
-
chainData?.chainType === ChainType.COSMOS,
|
|
25
|
+
enabled: !!keplrTypeWallet && chain?.chainType === ChainType.COSMOS,
|
|
30
26
|
});
|
|
31
27
|
return cosmosAddressQuery;
|
|
32
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCosmosForChain.js","sourceRoot":"","sources":["../../../src/hooks/cosmos/useCosmosForChain.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAkB,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useCosmosForChain.js","sourceRoot":"","sources":["../../../src/hooks/cosmos/useCosmosForChain.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAkB,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AACvD,OAAO,EACL,YAAY,EACZ,mBAAmB,GACpB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,KAA4B,EACK,EAAE;IACnC,MAAM,EAAE,eAAe,EAAE,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAEvD,MAAM,kBAAkB,GAAG,QAAQ,CACjC,IAAI,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,EACpC,KAAK,IAAI,EAAE;QACT,IAAI,CAAC,KAAK,IAAI,CAAC,eAAe;YAAE,OAAO,EAAE,CAAC;QAE1C,IAAI;YACF,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;YAEnE,OAAO,OAAO,IAAI,EAAE,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,mBAAmB,CAAC;gBACxB,KAAK,EAA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