@0xsquid/react-hooks 6.8.0-celo-minipay-beta.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 +3 -2
- package/dist/core/constants.js +2 -1
- 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 +20 -27
- package/dist/core/queries/queries-keys.js +55 -76
- package/dist/core/queries/queries-keys.js.map +1 -1
- package/dist/core/types/config.d.ts +2 -0
- 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/core/wagmiConfig.js +0 -2
- package/dist/core/wagmiConfig.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 -2
- package/dist/hooks/index.js +8 -2
- 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/tokens/useNativeBalance.d.ts +1 -1
- 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 +3 -3
- package/dist/hooks/transaction/useApproval.js.map +1 -1
- package/dist/hooks/transaction/useEstimate.d.ts +2 -2
- package/dist/hooks/transaction/useEstimate.js +3 -20
- package/dist/hooks/transaction/useEstimate.js.map +1 -1
- package/dist/hooks/transaction/useExecuteTransaction.js +52 -99
- package/dist/hooks/transaction/useExecuteTransaction.js.map +1 -1
- package/dist/hooks/transaction/useGetRoute.d.ts +3 -0
- package/dist/hooks/transaction/useGetRoute.js +9 -3
- package/dist/hooks/transaction/useGetRoute.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/useAutoConnect.js +1 -4
- package/dist/hooks/wallet/useAutoConnect.js.map +1 -1
- 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/useGnosisContext.js +2 -3
- package/dist/hooks/wallet/useGnosisContext.js.map +1 -1
- package/dist/hooks/wallet/useIntegratorContext.d.ts +1 -0
- package/dist/hooks/wallet/useIntegratorContext.js +9 -8
- package/dist/hooks/wallet/useIntegratorContext.js.map +1 -1
- package/dist/hooks/wallet/useMultiChainWallet.d.ts +3 -0
- package/dist/hooks/wallet/useMultiChainWallet.js +38 -3
- 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/hooks/wallet/useWallet.js +3 -18
- package/dist/hooks/wallet/useWallet.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 +3 -1
- package/dist/services/internal/assetsService.js +6 -0
- package/dist/services/internal/assetsService.js.map +1 -1
- package/dist/services/internal/configService.js +3 -0
- package/dist/services/internal/configService.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.d.ts +3 -8
- package/dist/services/internal/estimateService.js +15 -46
- 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/estimateService.test.js +0 -1
- package/dist/tests/estimateService.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/core/connectors/evm/MiniPay.d.ts +0 -7
- package/dist/core/connectors/evm/MiniPay.js +0 -57
- package/dist/core/connectors/evm/MiniPay.js.map +0 -1
- package/dist/hooks/transaction/useSingleTransaction.d.ts +0 -10
- package/dist/hooks/transaction/useSingleTransaction.js.map +0 -1
- package/dist/hooks/wallet/useCeloFeeToken.d.ts +0 -5
- package/dist/hooks/wallet/useCeloFeeToken.js +0 -21
- package/dist/hooks/wallet/useCeloFeeToken.js.map +0 -1
- package/dist/hooks/wallet/useMiniPayContext.d.ts +0 -6
- package/dist/hooks/wallet/useMiniPayContext.js +0 -21
- package/dist/hooks/wallet/useMiniPayContext.js.map +0 -1
- package/dist/services/internal/celoService.d.ts +0 -11
- package/dist/services/internal/celoService.js +0 -26
- package/dist/services/internal/celoService.js.map +0 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ChainType, StatusResponse } from "@0xsquid/squid-types";
|
|
2
|
+
import { OnRampTransactionStatusType } from "./onramps";
|
|
3
|
+
import { SendTransactionStatus, SimplifiedRouteAction, TransactionStatus } from "./transaction";
|
|
4
|
+
type SimplifiedStatusResponse = Pick<StatusResponse, "axelarTransactionUrl"> & {
|
|
5
|
+
toChain?: Pick<NonNullable<StatusResponse["toChain"]>, "transactionUrl"> | undefined;
|
|
6
|
+
};
|
|
7
|
+
export type SwapTransactionHistory = {
|
|
8
|
+
fromChain: string;
|
|
9
|
+
fromToken: string;
|
|
10
|
+
fromAddress: string;
|
|
11
|
+
fromAmount: string;
|
|
12
|
+
toChain: string;
|
|
13
|
+
toToken: string;
|
|
14
|
+
transactionId: string;
|
|
15
|
+
transactionIdForStatus?: string;
|
|
16
|
+
requestId: string | undefined;
|
|
17
|
+
toAddress: string;
|
|
18
|
+
toAmount: string;
|
|
19
|
+
status: TransactionStatus;
|
|
20
|
+
timestamp: number;
|
|
21
|
+
nonce?: number;
|
|
22
|
+
routeType: string | undefined;
|
|
23
|
+
statusResponse?: SimplifiedStatusResponse;
|
|
24
|
+
sourceTxExplorerUrl?: string;
|
|
25
|
+
bridgeType?: string;
|
|
26
|
+
actions?: SimplifiedRouteAction[];
|
|
27
|
+
};
|
|
28
|
+
export type SendTransactionHistory = {
|
|
29
|
+
toAddress: string;
|
|
30
|
+
token: {
|
|
31
|
+
address: string;
|
|
32
|
+
symbol: string;
|
|
33
|
+
decimals: number;
|
|
34
|
+
chainId: string;
|
|
35
|
+
type: ChainType;
|
|
36
|
+
};
|
|
37
|
+
timestamp: number;
|
|
38
|
+
status: SendTransactionStatus;
|
|
39
|
+
hash: string;
|
|
40
|
+
amount: string;
|
|
41
|
+
};
|
|
42
|
+
export type FiatTransactionHistory = {
|
|
43
|
+
fromCountryCode: string;
|
|
44
|
+
orderId: string;
|
|
45
|
+
fromFiatCurrency: string;
|
|
46
|
+
fromAmount: string;
|
|
47
|
+
toCryptoCurrencyID: string;
|
|
48
|
+
toTokenAddress: string;
|
|
49
|
+
toCryptoAmount: string;
|
|
50
|
+
toChainId: string;
|
|
51
|
+
toAddress: string;
|
|
52
|
+
status: OnRampTransactionStatusType;
|
|
53
|
+
timestamp: number;
|
|
54
|
+
transactionHash?: string;
|
|
55
|
+
errorMessage?: string;
|
|
56
|
+
providerId: string;
|
|
57
|
+
};
|
|
58
|
+
export declare enum HistoryTxType {
|
|
59
|
+
SWAP = 0,
|
|
60
|
+
BUY = 1,
|
|
61
|
+
SEND = 2
|
|
62
|
+
}
|
|
63
|
+
export type TxTypeToStatusMap = {
|
|
64
|
+
[HistoryTxType.SWAP]: TransactionStatus;
|
|
65
|
+
[HistoryTxType.BUY]: OnRampTransactionStatusType;
|
|
66
|
+
[HistoryTxType.SEND]: SendTransactionStatus;
|
|
67
|
+
};
|
|
68
|
+
export type StatusForTxType<T extends HistoryTxType> = T extends keyof TxTypeToStatusMap ? TxTypeToStatusMap[T] : never;
|
|
69
|
+
export type TxTypeToTransactionMap = {
|
|
70
|
+
[HistoryTxType.SWAP]: {
|
|
71
|
+
data: SwapTransactionHistory;
|
|
72
|
+
txType: HistoryTxType.SWAP;
|
|
73
|
+
};
|
|
74
|
+
[HistoryTxType.BUY]: {
|
|
75
|
+
data: FiatTransactionHistory;
|
|
76
|
+
txType: HistoryTxType.BUY;
|
|
77
|
+
};
|
|
78
|
+
[HistoryTxType.SEND]: {
|
|
79
|
+
data: SendTransactionHistory;
|
|
80
|
+
txType: HistoryTxType.SEND;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
export type HistoryTransaction = TxTypeToTransactionMap[HistoryTxType];
|
|
84
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var HistoryTxType;
|
|
2
|
+
(function (HistoryTxType) {
|
|
3
|
+
HistoryTxType[HistoryTxType["SWAP"] = 0] = "SWAP";
|
|
4
|
+
HistoryTxType[HistoryTxType["BUY"] = 1] = "BUY";
|
|
5
|
+
HistoryTxType[HistoryTxType["SEND"] = 2] = "SEND";
|
|
6
|
+
})(HistoryTxType || (HistoryTxType = {}));
|
|
7
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../../src/core/types/history.ts"],"names":[],"mappings":"AAoEA,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,iDAAI,CAAA;IACJ,+CAAG,CAAA;IACH,iDAAI,CAAA;AACN,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB"}
|
|
@@ -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"}
|
package/dist/core/wagmiConfig.js
CHANGED
|
@@ -3,7 +3,6 @@ import { BrowserProvider, JsonRpcSigner } from "ethers";
|
|
|
3
3
|
import { defineChain, } from "viem";
|
|
4
4
|
import { createConfig, http } from "wagmi";
|
|
5
5
|
import { injected, safe } from "wagmi/connectors";
|
|
6
|
-
import { miniPay } from "./connectors/evm/MiniPay";
|
|
7
6
|
export const createWagmiConfig = (squidChains) => {
|
|
8
7
|
const filteredEvmChains = squidChains.filter((chain) => chain.chainType === ChainType.EVM);
|
|
9
8
|
if (filteredEvmChains.length === 0) {
|
|
@@ -39,7 +38,6 @@ export const createWagmiConfig = (squidChains) => {
|
|
|
39
38
|
safe({
|
|
40
39
|
allowedDomains: [/app.safe.global$/],
|
|
41
40
|
}),
|
|
42
|
-
miniPay(),
|
|
43
41
|
],
|
|
44
42
|
});
|
|
45
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wagmiConfig.js","sourceRoot":"","sources":["../../src/core/wagmiConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EACL,WAAW,GAKZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAU,YAAY,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"wagmiConfig.js","sourceRoot":"","sources":["../../src/core/wagmiConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EACL,WAAW,GAKZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAU,YAAY,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,WAAwB,EAAU,EAAE;IACpE,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,CAC1C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,GAAG,CAC7C,CAAC;IAEF,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;KACnD;IAED,MAAM,WAAW,GAAY,iBAAiB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3D,OAAO,WAAW,CAAC;YACjB,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;YACzB,IAAI,EAAE,KAAK,CAAC,WAAW;YACvB,cAAc,EAAE;gBACd,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC,IAAI;gBAC/B,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM;gBACnC,QAAQ,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ;aACxC;YACD,OAAO,EAAE;gBACP,MAAM,EAAE;oBACN,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;iBAClB;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;iBAClB;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;QAClB,MAAM,EAAE,WAAkC;QAC1C,UAAU,EAAE,MAAM,CAAC,WAAW,CAC5B,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;YACzB,KAAK,CAAC,EAAE;YACR,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACzC,CAAC,CACH;QAED,UAAU,EAAE;YACV,QAAQ,EAAE;YACV,IAAI,CAAC;gBACH,cAAc,EAAE,CAAC,kBAAkB,CAAC;aACrC,CAAC;SACH;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,wBAAwB;AACxB,uCAAuC;AACvC,MAAM,UAAU,cAAc,CAAC,MAAyC;IACtE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAC7C,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE;QACpC,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,OAAO,GAAG;QACd,OAAO,EAAE,KAAK,CAAC,EAAE;QACjB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,UAAU,EAAE,KAAK,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO;KAClD,CAAC;IACF,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -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,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACL,CAAC;AAEF,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,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;QACrC,QAAQ,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE;QAC1B,OAAO,EAAE,cAAc;QACvB,OAAO,EAAE,QAAQ;QACjB,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,UAAU;QACrB,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,WAAW,EAAE,WAAW,IAAI,oBAAoB,CAAC;IAErE,6CAA6C;IAC7C,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE;QAC5B,MAAM,gBAAgB,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;QAEnD,sCAAsC;QACtC,IAAI,YAAY,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;YAC3C,OAAO,KAAK,CAAC;SACd;QAED,gDAAgD;QAChD,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,CACzC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,KAAK,gBAAgB,CACxD,CAAC;QACF,OAAO,WAAW,EAAE,YAAY,IAAI,KAAK,CAAC;IAC5C,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;AAClE,CAAC,CAAC"}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
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
|
+
};
|