@0xsequence/checkout 5.2.1 → 5.2.3
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/cjs/contexts/SelectPaymentModal.d.ts +2 -0
- package/dist/cjs/contexts/SelectPaymentModal.d.ts.map +1 -1
- package/dist/cjs/contexts/SelectPaymentModal.js.map +1 -1
- package/dist/cjs/contexts/SwapModal.d.ts +3 -2
- package/dist/cjs/contexts/SwapModal.d.ts.map +1 -1
- package/dist/cjs/contexts/SwapModal.js.map +1 -1
- package/dist/cjs/hooks/useCheckoutUI/index.d.ts +2 -1
- package/dist/cjs/hooks/useCheckoutUI/index.d.ts.map +1 -1
- package/dist/cjs/hooks/useCheckoutUI/index.js +3 -2
- package/dist/cjs/hooks/useCheckoutUI/index.js.map +1 -1
- package/dist/cjs/hooks/useCheckoutUI/useCryptoPayment.d.ts +7 -6
- package/dist/cjs/hooks/useCheckoutUI/useCryptoPayment.d.ts.map +1 -1
- package/dist/cjs/hooks/useCheckoutUI/useCryptoPayment.js +49 -51
- package/dist/cjs/hooks/useCheckoutUI/useCryptoPayment.js.map +1 -1
- package/dist/cjs/views/PaymentSelection/PayWithCrypto/index.d.ts.map +1 -1
- package/dist/cjs/views/PaymentSelection/PayWithCrypto/index.js +148 -81
- package/dist/cjs/views/PaymentSelection/PayWithCrypto/index.js.map +1 -1
- package/dist/cjs/views/PaymentSelection/index.d.ts.map +1 -1
- package/dist/cjs/views/PaymentSelection/index.js +27 -20
- package/dist/cjs/views/PaymentSelection/index.js.map +1 -1
- package/dist/cjs/views/Swap/index.d.ts.map +1 -1
- package/dist/cjs/views/Swap/index.js +94 -48
- package/dist/cjs/views/Swap/index.js.map +1 -1
- package/dist/esm/contexts/SelectPaymentModal.d.ts +2 -0
- package/dist/esm/contexts/SelectPaymentModal.d.ts.map +1 -1
- package/dist/esm/contexts/SelectPaymentModal.js.map +1 -1
- package/dist/esm/contexts/SwapModal.d.ts +3 -2
- package/dist/esm/contexts/SwapModal.d.ts.map +1 -1
- package/dist/esm/contexts/SwapModal.js.map +1 -1
- package/dist/esm/hooks/useCheckoutUI/index.d.ts +2 -1
- package/dist/esm/hooks/useCheckoutUI/index.d.ts.map +1 -1
- package/dist/esm/hooks/useCheckoutUI/index.js +3 -2
- package/dist/esm/hooks/useCheckoutUI/index.js.map +1 -1
- package/dist/esm/hooks/useCheckoutUI/useCryptoPayment.d.ts +7 -6
- package/dist/esm/hooks/useCheckoutUI/useCryptoPayment.d.ts.map +1 -1
- package/dist/esm/hooks/useCheckoutUI/useCryptoPayment.js +50 -52
- package/dist/esm/hooks/useCheckoutUI/useCryptoPayment.js.map +1 -1
- package/dist/esm/views/PaymentSelection/PayWithCrypto/index.d.ts.map +1 -1
- package/dist/esm/views/PaymentSelection/PayWithCrypto/index.js +150 -83
- package/dist/esm/views/PaymentSelection/PayWithCrypto/index.js.map +1 -1
- package/dist/esm/views/PaymentSelection/index.d.ts.map +1 -1
- package/dist/esm/views/PaymentSelection/index.js +28 -21
- package/dist/esm/views/PaymentSelection/index.js.map +1 -1
- package/dist/esm/views/Swap/index.d.ts.map +1 -1
- package/dist/esm/views/Swap/index.js +96 -50
- package/dist/esm/views/Swap/index.js.map +1 -1
- package/package.json +16 -16
|
@@ -14,53 +14,101 @@ const hooks_2 = require("../../hooks");
|
|
|
14
14
|
const Swap = () => {
|
|
15
15
|
const { openTransactionStatusModal } = (0, hooks_2.useTransactionStatusModal)();
|
|
16
16
|
const { swapModalSettings, closeSwapModal } = (0, hooks_2.useSwapModal)();
|
|
17
|
-
const {
|
|
17
|
+
const { toTokenAddress, toTokenAmount, chainId, disableMainCurrency = true, description, slippageBps, postSwapTransactions, blockConfirmations, customSwapErrorMessage, onSuccess = () => { } } = swapModalSettings;
|
|
18
18
|
const { address: userAddress, connector } = (0, wagmi_1.useAccount)();
|
|
19
19
|
const [isTxsPending, setIsTxsPending] = (0, react_1.useState)(false);
|
|
20
20
|
const [isError, setIsError] = (0, react_1.useState)(false);
|
|
21
21
|
const [selectedCurrency, setSelectedCurrency] = (0, react_1.useState)();
|
|
22
22
|
const publicClient = (0, wagmi_1.usePublicClient)({ chainId });
|
|
23
23
|
const { data: walletClient } = (0, wagmi_1.useWalletClient)({ chainId });
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
chainId: chainId,
|
|
31
|
-
buyAmount: currencyAmount,
|
|
32
|
-
withContractInfo: true
|
|
24
|
+
const { data: currencyInfoData, isLoading: isLoadingCurrencyInfo, isError: isErrorCurrencyInfo } = (0, hooks_1.useGetContractInfo)({ chainID: String(chainId), contractAddress: toTokenAddress });
|
|
25
|
+
const { data: swapRoutes = [], isLoading: swapRoutesIsLoading, isError: isErrorSwapRoutes } = (0, hooks_1.useGetSwapRoutes)({
|
|
26
|
+
chainId,
|
|
27
|
+
toTokenAddress,
|
|
28
|
+
toTokenAmount,
|
|
29
|
+
walletAddress: userAddress ?? ''
|
|
33
30
|
});
|
|
31
|
+
const { data: tokenBalances, isLoading: isLoadingTokenBalances } = (0, hooks_1.useGetTokenBalancesSummary)({
|
|
32
|
+
chainIds: [chainId],
|
|
33
|
+
filter: {
|
|
34
|
+
accountAddresses: [userAddress ?? ''],
|
|
35
|
+
omitNativeBalances: false,
|
|
36
|
+
contractWhitelist: swapRoutes.flatMap(route => route.fromTokens).map(fromToken => fromToken.address)
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const tokensBalancesMap = (0, react_1.useMemo)(() => {
|
|
40
|
+
const map = new Map();
|
|
41
|
+
tokenBalances?.pages?.forEach(page => {
|
|
42
|
+
page.balances?.forEach(balanceData => {
|
|
43
|
+
if (balanceData.contractAddress && balanceData.balance) {
|
|
44
|
+
map.set(balanceData.contractAddress.toLowerCase(), BigInt(balanceData.balance));
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return map;
|
|
49
|
+
}, [tokenBalances]);
|
|
34
50
|
(0, react_1.useEffect)(() => {
|
|
51
|
+
// Only attempt to select a currency if none is currently selected
|
|
52
|
+
const selectedCurrencyBalance = tokensBalancesMap.get(selectedCurrency?.toLowerCase() || '');
|
|
53
|
+
if ((selectedCurrency && BigInt(selectedCurrencyBalance || '0') > 0) || isLoadingTokenBalances || swapRoutesIsLoading) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
35
56
|
if (!disableMainCurrency) {
|
|
36
|
-
|
|
57
|
+
const balance = tokensBalancesMap.get(toTokenAddress.toLowerCase());
|
|
58
|
+
const mainCurrencyOptionPrice = toTokenAmount;
|
|
59
|
+
if (mainCurrencyOptionPrice && balance && BigInt(balance) >= BigInt(mainCurrencyOptionPrice)) {
|
|
60
|
+
setSelectedCurrency(toTokenAddress);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
37
63
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
64
|
+
const validSwapOptions = swapRoutes.flatMap(route => route.fromTokens);
|
|
65
|
+
if (!validSwapOptions.length) {
|
|
66
|
+
return;
|
|
41
67
|
}
|
|
42
|
-
|
|
43
|
-
|
|
68
|
+
// Try to find the first token with sufficient balance
|
|
69
|
+
const optionWithSufficientBalance = validSwapOptions.find(option => {
|
|
70
|
+
if (!option.price) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const balance = tokensBalancesMap.get(option.address.toLowerCase());
|
|
74
|
+
return balance ? BigInt(balance) >= BigInt(option.price) : false;
|
|
75
|
+
});
|
|
76
|
+
if (optionWithSufficientBalance) {
|
|
77
|
+
setSelectedCurrency(optionWithSufficientBalance.address);
|
|
78
|
+
}
|
|
79
|
+
}, [
|
|
80
|
+
swapRoutesIsLoading,
|
|
81
|
+
isLoadingTokenBalances,
|
|
82
|
+
swapRoutes,
|
|
83
|
+
tokensBalancesMap,
|
|
84
|
+
disableMainCurrency,
|
|
85
|
+
toTokenAddress,
|
|
86
|
+
selectedCurrency
|
|
87
|
+
]);
|
|
88
|
+
const isNativeCurrency = (0, connect_1.compareAddress)(toTokenAddress, viem_1.zeroAddress);
|
|
44
89
|
const network = (0, network_1.findSupportedNetwork)(chainId);
|
|
45
90
|
const mainCurrencyName = isNativeCurrency ? network?.nativeToken.name : currencyInfoData?.name;
|
|
46
91
|
const mainCurrencyLogo = isNativeCurrency ? network?.logoURI : currencyInfoData?.logoURI;
|
|
47
92
|
const mainCurrencySymbol = isNativeCurrency ? network?.nativeToken.symbol : currencyInfoData?.symbol;
|
|
48
93
|
const mainCurrencyDecimals = isNativeCurrency ? network?.nativeToken.decimals : currencyInfoData?.decimals;
|
|
49
|
-
const disableSwapQuote = !selectedCurrency || (0, connect_1.compareAddress)(selectedCurrency,
|
|
94
|
+
const disableSwapQuote = !selectedCurrency || (0, connect_1.compareAddress)(selectedCurrency, toTokenAddress);
|
|
50
95
|
const { data: swapQuote, isLoading: isLoadingSwapQuote, isError: isErrorSwapQuote } = (0, hooks_1.useGetSwapQuote)({
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
96
|
+
params: {
|
|
97
|
+
walletAddress: userAddress ?? '',
|
|
98
|
+
toTokenAddress,
|
|
99
|
+
toTokenAmount,
|
|
100
|
+
fromTokenAddress: selectedCurrency || '',
|
|
101
|
+
chainId: chainId,
|
|
102
|
+
includeApprove: true,
|
|
103
|
+
slippageBps: slippageBps || 100
|
|
104
|
+
}
|
|
57
105
|
}, {
|
|
58
106
|
disabled: disableSwapQuote
|
|
59
107
|
});
|
|
60
108
|
const indexerClient = (0, hooks_1.useIndexerClient)(chainId);
|
|
61
|
-
const isMainCurrencySelected = (0, connect_1.compareAddress)(selectedCurrency || '',
|
|
109
|
+
const isMainCurrencySelected = (0, connect_1.compareAddress)(selectedCurrency || '', toTokenAddress);
|
|
62
110
|
const quoteFetchInProgress = isLoadingSwapQuote && !isMainCurrencySelected;
|
|
63
|
-
const isLoading = isLoadingCurrencyInfo ||
|
|
111
|
+
const isLoading = isLoadingCurrencyInfo || swapRoutesIsLoading;
|
|
64
112
|
const onClickProceed = async () => {
|
|
65
113
|
if (!userAddress || !publicClient || !walletClient || !connector) {
|
|
66
114
|
return;
|
|
@@ -68,10 +116,10 @@ const Swap = () => {
|
|
|
68
116
|
setIsError(false);
|
|
69
117
|
setIsTxsPending(true);
|
|
70
118
|
try {
|
|
71
|
-
const
|
|
72
|
-
const isSwapNativeToken = (0, connect_1.compareAddress)(viem_1.zeroAddress,
|
|
119
|
+
const swapOption = swapRoutes.flatMap(route => route.fromTokens).find(option => option.address === selectedCurrency);
|
|
120
|
+
const isSwapNativeToken = (0, connect_1.compareAddress)(viem_1.zeroAddress, swapOption?.address || '');
|
|
73
121
|
const getSwapTransactions = () => {
|
|
74
|
-
if (isMainCurrencySelected || !swapQuote || !
|
|
122
|
+
if (isMainCurrencySelected || !swapQuote || !swapOption) {
|
|
75
123
|
return [];
|
|
76
124
|
}
|
|
77
125
|
const swapTransactions = [
|
|
@@ -79,7 +127,7 @@ const Swap = () => {
|
|
|
79
127
|
...(swapQuote?.approveData && !isSwapNativeToken
|
|
80
128
|
? [
|
|
81
129
|
{
|
|
82
|
-
to:
|
|
130
|
+
to: swapOption.address,
|
|
83
131
|
data: swapQuote.approveData,
|
|
84
132
|
chain: chainId
|
|
85
133
|
}
|
|
@@ -128,13 +176,13 @@ const Swap = () => {
|
|
|
128
176
|
console.error('Failed to send transactions', e);
|
|
129
177
|
}
|
|
130
178
|
};
|
|
131
|
-
const
|
|
132
|
-
const noOptionsFound = disableMainCurrency &&
|
|
179
|
+
const isErrorFetchingOptions = isErrorSwapRoutes || isErrorCurrencyInfo;
|
|
180
|
+
const noOptionsFound = disableMainCurrency && swapRoutes.flatMap(route => route.fromTokens).length === 0;
|
|
133
181
|
const SwapContent = () => {
|
|
134
|
-
if (isLoading) {
|
|
182
|
+
if (isLoading || isLoadingTokenBalances) {
|
|
135
183
|
return ((0, jsx_runtime_1.jsx)("div", { className: "flex w-full justify-center items-center", children: (0, jsx_runtime_1.jsx)(design_system_1.Spinner, {}) }));
|
|
136
184
|
}
|
|
137
|
-
else if (
|
|
185
|
+
else if (isErrorFetchingOptions) {
|
|
138
186
|
return ((0, jsx_runtime_1.jsx)("div", { className: "flex w-full justify-center items-center", children: (0, jsx_runtime_1.jsx)(design_system_1.Text, { variant: "normal", color: "negative", children: "An error occurred while fetching the swap options." }) }));
|
|
139
187
|
}
|
|
140
188
|
else if (noOptionsFound) {
|
|
@@ -142,28 +190,26 @@ const Swap = () => {
|
|
|
142
190
|
'No swap options found on your wallet, please ensure you hold an eligible token for the swap.' }) }));
|
|
143
191
|
}
|
|
144
192
|
else {
|
|
145
|
-
const formattedPrice = (0, viem_1.formatUnits)(BigInt(
|
|
193
|
+
const formattedPrice = (0, viem_1.formatUnits)(BigInt(toTokenAmount), mainCurrencyDecimals || 0);
|
|
146
194
|
const displayPrice = (0, connect_1.formatDisplay)(formattedPrice, {
|
|
147
195
|
disableScientificNotation: true,
|
|
148
196
|
disableCompactNotation: true,
|
|
149
197
|
significantDigits: 6
|
|
150
198
|
});
|
|
151
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex w-full gap-3 flex-col", children: [(0, jsx_runtime_1.jsx)(design_system_1.Text, { variant: "normal", color: "primary", children: description }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col gap-2", children: [!disableMainCurrency && ((0, jsx_runtime_1.jsx)(connect_1.CryptoOption, { chainId: chainId, currencyName: mainCurrencyName || mainCurrencySymbol || '', price: displayPrice, iconUrl: mainCurrencyLogo, symbol: mainCurrencySymbol || '', isSelected: (0, connect_1.compareAddress)(selectedCurrency || '',
|
|
199
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex w-full gap-3 flex-col", children: [(0, jsx_runtime_1.jsx)(design_system_1.Text, { variant: "normal", color: "primary", children: description }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col gap-2", children: [!disableMainCurrency && ((0, jsx_runtime_1.jsx)(connect_1.CryptoOption, { chainId: chainId, currencyName: mainCurrencyName || mainCurrencySymbol || '', price: displayPrice, iconUrl: mainCurrencyLogo, symbol: mainCurrencySymbol || '', isSelected: (0, connect_1.compareAddress)(selectedCurrency || '', toTokenAddress), onClick: () => {
|
|
152
200
|
setIsError(false);
|
|
153
|
-
setSelectedCurrency(
|
|
154
|
-
}, disabled: isTxsPending },
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const displayPrice = (0,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
});
|
|
162
|
-
return ((0, jsx_runtime_1.jsx)(connect_1.CryptoOption, { chainId: chainId, currencyName: swapPrice.info?.name || swapPrice.info?.symbol || '', symbol: swapPrice.info?.symbol || '', isSelected: (0, connect_1.compareAddress)(selectedCurrency || '', sellCurrencyAddress), iconUrl: swapPrice.info?.logoURI, price: displayPrice, onClick: () => {
|
|
201
|
+
setSelectedCurrency(toTokenAddress);
|
|
202
|
+
}, disabled: isTxsPending }, toTokenAddress)), swapRoutes
|
|
203
|
+
.flatMap(route => route.fromTokens)
|
|
204
|
+
.map(tokenOption => {
|
|
205
|
+
const displayPrice = (0, viem_1.formatUnits)(BigInt(tokenOption.price || '0'), tokenOption.decimals || 0);
|
|
206
|
+
const balance = tokensBalancesMap.get(tokenOption.address.toLowerCase());
|
|
207
|
+
const insufficientFunds = balance ? BigInt(balance) < BigInt(tokenOption.price || '0') : false;
|
|
208
|
+
return ((0, jsx_runtime_1.jsx)(connect_1.CryptoOption, { chainId: chainId, currencyName: tokenOption.name || tokenOption.symbol || '', symbol: tokenOption.symbol || '', isSelected: (0, connect_1.compareAddress)(selectedCurrency || '', tokenOption.address), iconUrl: tokenOption.logoUri, price: displayPrice, showInsufficientFundsWarning: insufficientFunds, onClick: () => {
|
|
163
209
|
setIsError(false);
|
|
164
|
-
setSelectedCurrency(
|
|
165
|
-
}, disabled: isTxsPending },
|
|
166
|
-
})] }), isError && ((0, jsx_runtime_1.jsx)("div", { className: "w-full", children: (0, jsx_runtime_1.jsx)(design_system_1.Text, { color: "negative", variant: "small", children: "A problem occurred while executing the transaction." }) })), isErrorSwapQuote && ((0, jsx_runtime_1.jsx)("div", { className: "w-full", children: (0, jsx_runtime_1.jsx)(design_system_1.Text, { color: "negative", variant: "small", children: "A problem occurred while fetching the swap quote." }) })), (0, jsx_runtime_1.jsx)(design_system_1.Button, { disabled: noOptionsFound || !selectedCurrency || quoteFetchInProgress || isTxsPending || isErrorSwapQuote, variant: "primary", label: quoteFetchInProgress ? 'Preparing swap...' : 'Proceed', onClick: onClickProceed })] }));
|
|
210
|
+
setSelectedCurrency(tokenOption.address);
|
|
211
|
+
}, disabled: isTxsPending }, tokenOption.address));
|
|
212
|
+
})] }), isError && ((0, jsx_runtime_1.jsx)("div", { className: "w-full", children: (0, jsx_runtime_1.jsx)(design_system_1.Text, { color: "negative", variant: "small", children: "A problem occurred while executing the transaction." }) })), isErrorSwapQuote && ((0, jsx_runtime_1.jsx)("div", { className: "w-full", children: (0, jsx_runtime_1.jsx)(design_system_1.Text, { color: "negative", variant: "small", children: "A problem occurred while fetching the swap quote." }) })), (0, jsx_runtime_1.jsx)(design_system_1.Button, { disabled: noOptionsFound || !selectedCurrency || quoteFetchInProgress || isTxsPending || isErrorSwapQuote, variant: "primary", label: quoteFetchInProgress ? 'Preparing swap...' : isTxsPending ? 'Preparing transaction...' : 'Proceed', onClick: onClickProceed })] }));
|
|
167
213
|
}
|
|
168
214
|
};
|
|
169
215
|
return ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-2 items-start pb-6 px-6", style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/views/Swap/index.tsx"],"names":[],"mappings":";;;;AAAA,iDAAmG;AACnG,6DAAiE;AACjE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/views/Swap/index.tsx"],"names":[],"mappings":";;;;AAAA,iD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C,EACvE,OAAO,EAAE,WAAW,CAAC,OAAO,EAC5B,KAAK,EAAE,YAAY,EACnB,4BAA4B,EAAE,iBAAiB,EAC/C,OAAO,EAAE,GAAG,EAAE;wCACZ,UAAU,CAAC,KAAK,CAAC,CAAA;wCACjB,mBAAmB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;oCAC1C,CAAC,EACD,QAAQ,EAAE,YAAY,IAZjB,WAAW,CAAC,OAAO,CAaxB,CACH,CAAA;4BACH,CAAC,CAAC,IACA,EACL,OAAO,IAAI,CACV,gCAAK,SAAS,EAAC,QAAQ,YACrB,uBAAC,oBAAI,IAAC,KAAK,EAAC,UAAU,EAAC,OAAO,EAAC,OAAO,oEAE/B,GACH,CACP,EACA,gBAAgB,IAAI,CACnB,gCAAK,SAAS,EAAC,QAAQ,YACrB,uBAAC,oBAAI,IAAC,KAAK,EAAC,UAAU,EAAC,OAAO,EAAC,OAAO,kEAE/B,GACH,CACP,EACD,uBAAC,sBAAM,IACL,QAAQ,EAAE,cAAc,IAAI,CAAC,gBAAgB,IAAI,oBAAoB,IAAI,YAAY,IAAI,gBAAgB,EACzG,OAAO,EAAC,SAAS,EACjB,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,SAAS,EACzG,OAAO,EAAE,cAAc,GACvB,IACE,CACP,CAAA;QACH,CAAC;IACH,CAAC,CAAA;IAED,OAAO,CACL,gCACE,SAAS,EAAC,2CAA2C,EACrD,KAAK,EAAE;YACL,UAAU,EAAE,yBAAa;SAC1B,YAED,uBAAC,WAAW,KAAG,GACX,CACP,CAAA;AACH,CAAC,CAAA;AA7UY,QAAA,IAAI,QA6UhB"}
|
|
@@ -39,6 +39,8 @@ export interface SelectPaymentSettings {
|
|
|
39
39
|
customProviderCallback?: (onSuccess: (txHash: string) => void, onError: (error: Error) => void, onClose: () => void) => void;
|
|
40
40
|
supplementaryAnalyticsInfo?: SupplementaryAnalyticsInfo;
|
|
41
41
|
skipNativeBalanceCheck?: boolean;
|
|
42
|
+
slippageBps?: number;
|
|
43
|
+
nativeTokenAddress?: string;
|
|
42
44
|
}
|
|
43
45
|
type SelectPaymentModalContext = {
|
|
44
46
|
openSelectPaymentModal: (settings: SelectPaymentSettings) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPaymentModal.d.ts","sourceRoot":"","sources":["../../../src/contexts/SelectPaymentModal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAI9D,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,SAAS,CAAA;AAEvD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,0BAA0B;IACzC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,sBAAsB,CAAC,EAAE,MAAM,CAAA;CAChC;AAED,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,WAAW,EAAE,CAAA;IAC3B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,GAAG,GAAG,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,qBAAqB,EAAE,MAAM,GAAG,GAAG,CAAA;IACnC,MAAM,EAAE,GAAG,CAAA;IACX,iBAAiB,EAAE,MAAM,GAAG,GAAG,CAAA;IAC/B,gBAAgB,EAAE,MAAM,GAAG,GAAG,CAAA;IAC9B,sBAAsB,CAAC,EAAE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,KAAK,IAAI,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;IAC5H,0BAA0B,CAAC,EAAE,0BAA0B,CAAA;IACvD,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,KAAK,yBAAyB,GAAG;IAC/B,sBAAsB,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,CAAA;IACjE,uBAAuB,EAAE,MAAM,IAAI,CAAA;IACnC,qBAAqB,CAAC,EAAE,qBAAqB,CAAA;CAC9C,CAAA;AAED,QAAA,MAAO,uBAAuB,mCAAE,4BAA4B,iEAAqD,CAAA;AAEjH,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPaymentModal.js","sourceRoot":"","sources":["../../../src/contexts/SelectPaymentModal.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"SelectPaymentModal.js","sourceRoot":"","sources":["../../../src/contexts/SelectPaymentModal.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAsDvD,MAAM,CAAC,uBAAuB,EAAE,4BAA4B,CAAC,GAAG,oBAAoB,EAA6B,CAAA;AAEjH,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,CAAA"}
|
|
@@ -6,8 +6,9 @@ interface Transaction {
|
|
|
6
6
|
}
|
|
7
7
|
export interface SwapModalSettings {
|
|
8
8
|
chainId: number;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
toTokenAddress: string;
|
|
10
|
+
toTokenAmount: string;
|
|
11
|
+
slippageBps?: number;
|
|
11
12
|
title?: string;
|
|
12
13
|
description?: string;
|
|
13
14
|
disableMainCurrency?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwapModal.d.ts","sourceRoot":"","sources":["../../../src/contexts/SwapModal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAI1B,UAAU,WAAW;IACnB,EAAE,EAAE,GAAG,CAAA;IACP,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,
|
|
1
|
+
{"version":3,"file":"SwapModal.d.ts","sourceRoot":"","sources":["../../../src/contexts/SwapModal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAI1B,UAAU,WAAW;IACnB,EAAE,EAAE,GAAG,CAAA;IACP,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,oBAAoB,CAAC,EAAE,WAAW,EAAE,CAAA;IACpC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CACrC;AAED,KAAK,gBAAgB,GAAG;IACtB,eAAe,EAAE,OAAO,CAAA;IACxB,aAAa,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAA;IACpD,cAAc,EAAE,MAAM,IAAI,CAAA;IAC1B,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;CACtC,CAAA;AAED,QAAA,MAAO,mBAAmB,0BAAE,wBAAwB,wDAA4C,CAAA;AAEhG,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwapModal.js","sourceRoot":"","sources":["../../../src/contexts/SwapModal.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAIZ,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"SwapModal.js","sourceRoot":"","sources":["../../../src/contexts/SwapModal.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAIZ,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AA6BvD,MAAM,CAAC,mBAAmB,EAAE,wBAAwB,CAAC,GAAG,oBAAoB,EAAoB,CAAA;AAEhG,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,CAAA"}
|
|
@@ -14,6 +14,7 @@ interface UseCheckoutUIArgs {
|
|
|
14
14
|
targetContractAddress: string;
|
|
15
15
|
txData: Hex;
|
|
16
16
|
transactionConfirmations?: number;
|
|
17
|
+
slippageBps?: number;
|
|
17
18
|
creditCardProvider?: CreditCardProviders;
|
|
18
19
|
transakConfig?: TransakConfig;
|
|
19
20
|
onSuccess?: (txHash: string) => void;
|
|
@@ -24,6 +25,6 @@ interface UseCheckoutUIReturn {
|
|
|
24
25
|
creditCardPayment: UseCreditCardPaymentReturn;
|
|
25
26
|
cryptoPayment: UseCryptoPaymentReturn;
|
|
26
27
|
}
|
|
27
|
-
export declare const useCheckoutUI: ({ chain, currencyAddress, totalPriceRaw, collectible, collectionAddress, recipientAddress, targetContractAddress, txData, transactionConfirmations, creditCardProvider, transakConfig, onSuccess, onError }: UseCheckoutUIArgs) => UseCheckoutUIReturn;
|
|
28
|
+
export declare const useCheckoutUI: ({ chain, currencyAddress, totalPriceRaw, collectible, collectionAddress, recipientAddress, targetContractAddress, txData, transactionConfirmations, creditCardProvider, transakConfig, slippageBps, onSuccess, onError }: UseCheckoutUIArgs) => UseCheckoutUIReturn;
|
|
28
29
|
export {};
|
|
29
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCheckoutUI/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAEpF,OAAO,EAAwB,KAAK,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;AAC9F,OAAO,EAAoB,KAAK,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAClF,OAAO,EAAmB,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE/E,UAAU,iBAAiB;IACzB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,WAAW,CAAA;IACxB,iBAAiB,EAAE,MAAM,CAAA;IACzB,gBAAgB,EAAE,MAAM,CAAA;IACxB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,MAAM,EAAE,GAAG,CAAA;IACX,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,kBAAkB,CAAC,EAAE,mBAAmB,CAAA;IACxC,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;CACjC;AAED,UAAU,mBAAmB;IAC3B,YAAY,EAAE,qBAAqB,CAAA;IACnC,iBAAi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C;AAED,eAAO,MAAM,aAAa,GAAI,0NAe3B,iBAAiB,KAAG,mBAsGtB,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { findSupportedNetwork } from '@0xsequence/network';
|
|
|
3
3
|
import { useCreditCardPayment } from './useCreditCardPayment';
|
|
4
4
|
import { useCryptoPayment } from './useCryptoPayment';
|
|
5
5
|
import { useOrderSummary } from './useOrderSummary';
|
|
6
|
-
export const useCheckoutUI = ({ chain, currencyAddress, totalPriceRaw, collectible, collectionAddress, recipientAddress, targetContractAddress, txData, transactionConfirmations, creditCardProvider, transakConfig, onSuccess, onError }) => {
|
|
6
|
+
export const useCheckoutUI = ({ chain, currencyAddress, totalPriceRaw, collectible, collectionAddress, recipientAddress, targetContractAddress, txData, transactionConfirmations, creditCardProvider, transakConfig, slippageBps, onSuccess, onError }) => {
|
|
7
7
|
const network = findSupportedNetwork(chain);
|
|
8
8
|
const chainId = network?.chainId || 137;
|
|
9
9
|
const { data: tokenMetadatas, isLoading: isLoadingTokenMetadatas, error: errorTokenMetadata } = useGetTokenMetadata({
|
|
@@ -78,7 +78,8 @@ export const useCheckoutUI = ({ chain, currencyAddress, totalPriceRaw, collectib
|
|
|
78
78
|
isLoadingTokenMetadatas,
|
|
79
79
|
errorTokenMetadata,
|
|
80
80
|
isLoadingCurrencyInfo,
|
|
81
|
-
errorCurrencyInfo
|
|
81
|
+
errorCurrencyInfo,
|
|
82
|
+
slippageBps
|
|
82
83
|
});
|
|
83
84
|
return {
|
|
84
85
|
orderSummary,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/useCheckoutUI/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAM1D,OAAO,EAAE,oBAAoB,EAAmC,MAAM,wBAAwB,CAAA;AAC9F,O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-22,10 +22,11 @@ export interface UseCryptoPaymentArgs {
|
|
|
22
22
|
errorTokenMetadata: Error | null;
|
|
23
23
|
isLoadingCurrencyInfo: boolean;
|
|
24
24
|
errorCurrencyInfo: Error | null;
|
|
25
|
+
slippageBps?: number;
|
|
25
26
|
}
|
|
26
27
|
export interface UseCryptoPaymentReturn {
|
|
27
28
|
cryptoOptions: {
|
|
28
|
-
data:
|
|
29
|
+
data: CryptoOption[];
|
|
29
30
|
isLoading: boolean;
|
|
30
31
|
error: Error | null;
|
|
31
32
|
};
|
|
@@ -36,18 +37,18 @@ export interface UseCryptoPaymentReturn {
|
|
|
36
37
|
setSelectedCurrencyAddress: (currencyAddress: string) => void;
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
|
-
interface
|
|
40
|
+
interface CryptoOption {
|
|
40
41
|
chainId: number;
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
address: string;
|
|
43
|
+
name: string;
|
|
43
44
|
totalPriceRaw: string;
|
|
44
45
|
symbol: string;
|
|
45
46
|
decimals: number;
|
|
46
47
|
totalPriceDisplay: string;
|
|
47
|
-
|
|
48
|
+
logoUrl?: string;
|
|
48
49
|
isInsufficientFunds: boolean;
|
|
49
50
|
isSelected: boolean;
|
|
50
51
|
}
|
|
51
|
-
export declare const useCryptoPayment: ({ chain, currencyAddress, totalPriceRaw, targetContractAddress, txData, transactionConfirmations, onSuccess, onError, currencyInfo, isLoadingCurrencyInfo, errorCurrencyInfo }: UseCryptoPaymentArgs) => UseCryptoPaymentReturn;
|
|
52
|
+
export declare const useCryptoPayment: ({ chain, currencyAddress, totalPriceRaw, targetContractAddress, txData, transactionConfirmations, onSuccess, onError, currencyInfo, isLoadingCurrencyInfo, errorCurrencyInfo, slippageBps }: UseCryptoPaymentArgs) => UseCryptoPaymentReturn;
|
|
52
53
|
export {};
|
|
53
54
|
//# sourceMappingURL=useCryptoPayment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCryptoPayment.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCheckoutUI/useCryptoPayment.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGlE,OAAO,EAAE,GAAG,EAAgD,MAAM,MAAM,CAAA;AAIxE,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAE/D,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,WAAW,CAAA;IACxB,iBAAiB,EAAE,MAAM,CAAA;IACzB,gBAAgB,EAAE,MAAM,CAAA;IACxB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,MAAM,EAAE,GAAG,CAAA;IACX,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,YAAY,EAAE,YAAY,GAAG,SAAS,CAAA;IACtC,cAAc,EAAE,aAAa,EAAE,GAAG,SAAS,CAAA;IAC3C,kBAAkB,EAAE,YAAY,GAAG,SAAS,CAAA;IAC5C,uBAAuB,EAAE,OAAO,CAAA;IAChC,mBAAmB,EAAE,KAAK,GAAG,IAAI,CAAA;IACjC,uBAAuB,EAAE,OAAO,CAAA;IAChC,kBAAkB,EAAE,KAAK,GAAG,IAAI,CAAA;IAChC,qBAAqB,EAAE,OAAO,CAAA;IAC9B,iBAAiB,EAAE,KAAK,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"useCryptoPayment.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCheckoutUI/useCryptoPayment.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAA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E,OAAO,CAAA;QAChB,uBAAuB,EAAE,MAAM,GAAG,SAAS,CAAA;QAC3C,0BAA0B,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,IAAI,CAAA;KAC9D,CAAA;CACF;AAED,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,iBAAiB,EAAE,MAAM,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,UAAU,EAAE,OAAO,CAAA;CACpB;AAED,eAAO,MAAM,gBAAgB,GAAI,6LAa9B,oBAAoB,KAAG,sBA0SzB,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { compareAddress, ContractVerificationStatus, formatDisplay, sendTransactions } from '@0xsequence/connect';
|
|
2
|
-
import { useIndexerClient, useGetTokenBalancesSummary,
|
|
2
|
+
import { useIndexerClient, useGetTokenBalancesSummary, useGetSwapQuote, useGetSwapRoutes } from '@0xsequence/hooks';
|
|
3
3
|
import { findSupportedNetwork } from '@0xsequence/network';
|
|
4
4
|
import { useState } from 'react';
|
|
5
5
|
import { encodeFunctionData, formatUnits, zeroAddress } from 'viem';
|
|
6
6
|
import { usePublicClient, useAccount, useReadContract, useWalletClient } from 'wagmi';
|
|
7
7
|
import { ERC_20_CONTRACT_ABI } from '../../constants/abi';
|
|
8
|
-
export const useCryptoPayment = ({ chain, currencyAddress, totalPriceRaw, targetContractAddress, txData, transactionConfirmations, onSuccess, onError, currencyInfo, isLoadingCurrencyInfo, errorCurrencyInfo }) => {
|
|
8
|
+
export const useCryptoPayment = ({ chain, currencyAddress, totalPriceRaw, targetContractAddress, txData, transactionConfirmations, onSuccess, onError, currencyInfo, isLoadingCurrencyInfo, errorCurrencyInfo, slippageBps }) => {
|
|
9
9
|
const [selectedCurrencyAddress, setSelectedCurrencyAddress] = useState(undefined);
|
|
10
10
|
const { address: userAddress, connector } = useAccount();
|
|
11
11
|
const network = findSupportedNetwork(chain);
|
|
@@ -32,38 +32,40 @@ export const useCryptoPayment = ({ chain, currencyAddress, totalPriceRaw, target
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
const isApproved = allowanceData >= BigInt(totalPriceRaw) || isNativeCurrency;
|
|
35
|
+
const buyCurrencyAddress = currencyAddress;
|
|
36
|
+
const { data: swapRoutes = [], isLoading: swapRoutesIsLoading, error: swapRoutesError } = useGetSwapRoutes({
|
|
37
|
+
walletAddress: userAddress ?? '',
|
|
38
|
+
toTokenAmount: totalPriceRaw,
|
|
39
|
+
toTokenAddress: currencyAddress || '',
|
|
40
|
+
chainId: chainId
|
|
41
|
+
});
|
|
35
42
|
const { data: currencyBalanceDataPaginated, isLoading: currencyBalanceIsLoading } = useGetTokenBalancesSummary({
|
|
36
43
|
chainIds: [chainId],
|
|
37
44
|
filter: {
|
|
38
45
|
accountAddresses: userAddress ? [userAddress] : [],
|
|
39
46
|
contractStatus: ContractVerificationStatus.ALL,
|
|
40
|
-
contractWhitelist: [currencyAddress],
|
|
47
|
+
contractWhitelist: [currencyAddress, ...swapRoutes.flatMap(swapRoute => swapRoute.fromTokens.map(token => token.address))],
|
|
41
48
|
omitNativeBalances: false
|
|
42
49
|
},
|
|
43
50
|
omitMetadata: true
|
|
44
51
|
});
|
|
45
52
|
const currencyBalanceData = currencyBalanceDataPaginated?.pages?.flatMap(page => page.balances);
|
|
46
|
-
const buyCurrencyAddress = currencyAddress;
|
|
47
|
-
const sellCurrencyAddress = selectedCurrencyAddress || '';
|
|
48
|
-
const { data: swapPrices = [], isLoading: swapPricesIsLoading, error: swapPricesError } = useGetSwapPrices({
|
|
49
|
-
userAddress: userAddress ?? '',
|
|
50
|
-
buyCurrencyAddress,
|
|
51
|
-
chainId: chainId,
|
|
52
|
-
buyAmount: totalPriceRaw,
|
|
53
|
-
withContractInfo: true
|
|
54
|
-
});
|
|
55
53
|
const disableSwapQuote = !selectedCurrencyAddress || compareAddress(selectedCurrencyAddress, buyCurrencyAddress);
|
|
56
54
|
const { data: swapQuote, isLoading: isLoadingSwapQuote } = useGetSwapQuote({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
params: {
|
|
56
|
+
walletAddress: userAddress ?? '',
|
|
57
|
+
toTokenAddress: currencyAddress,
|
|
58
|
+
toTokenAmount: totalPriceRaw,
|
|
59
|
+
fromTokenAddress: selectedCurrencyAddress || '',
|
|
60
|
+
fromTokenAmount: '0',
|
|
61
|
+
chainId: chainId,
|
|
62
|
+
includeApprove: true,
|
|
63
|
+
slippageBps: slippageBps || 100
|
|
64
|
+
}
|
|
63
65
|
}, {
|
|
64
66
|
disabled: disableSwapQuote
|
|
65
67
|
});
|
|
66
|
-
const mainCurrencyBalance = currencyBalanceData?.
|
|
68
|
+
const mainCurrencyBalance = currencyBalanceData?.find(balance => balance.contractAddress === currencyAddress.toLowerCase())?.balance || '0';
|
|
67
69
|
const priceFormatted = formatUnits(BigInt(totalPriceRaw), currencyInfo?.decimals || 0);
|
|
68
70
|
const priceDisplay = formatDisplay(priceFormatted, {
|
|
69
71
|
disableScientificNotation: true,
|
|
@@ -74,40 +76,18 @@ export const useCryptoPayment = ({ chain, currencyAddress, totalPriceRaw, target
|
|
|
74
76
|
? [
|
|
75
77
|
{
|
|
76
78
|
chainId,
|
|
77
|
-
currencyAddress,
|
|
78
|
-
|
|
79
|
+
address: currencyAddress,
|
|
80
|
+
name: currencyInfo?.name || 'unknown',
|
|
79
81
|
totalPriceRaw: totalPriceRaw,
|
|
80
82
|
decimals: currencyDecimals || 18,
|
|
81
83
|
totalPriceDisplay: priceDisplay,
|
|
82
|
-
|
|
84
|
+
logoUrl: currencyInfo?.logoURI,
|
|
83
85
|
symbol: currencySymbol || '',
|
|
84
86
|
isInsufficientFunds: Number(mainCurrencyBalance) < Number(totalPriceRaw),
|
|
85
87
|
isSelected: compareAddress(currencyAddress, selectedCurrencyAddress || '')
|
|
86
88
|
}
|
|
87
89
|
]
|
|
88
90
|
: [];
|
|
89
|
-
const swapOptions = swapPrices.map(swapPrice => {
|
|
90
|
-
const swapQuotePriceFormatted = formatUnits(BigInt(swapPrice.price.price), swapPrice.info?.decimals || 18);
|
|
91
|
-
const swapQuoteAddress = swapPrice.info?.address || '';
|
|
92
|
-
const swapQuotePriceDisplay = formatDisplay(swapQuotePriceFormatted, {
|
|
93
|
-
disableScientificNotation: true,
|
|
94
|
-
disableCompactNotation: true,
|
|
95
|
-
significantDigits: 6
|
|
96
|
-
});
|
|
97
|
-
return {
|
|
98
|
-
chainId,
|
|
99
|
-
currencyAddress: swapQuoteAddress,
|
|
100
|
-
currencyName: swapPrice.info?.name || 'unknown',
|
|
101
|
-
totalPriceRaw: swapPrice.price.price,
|
|
102
|
-
totalPriceDisplay: swapQuotePriceDisplay,
|
|
103
|
-
currrencyLogoUrl: swapPrice.info?.logoURI,
|
|
104
|
-
symbol: swapPrice.info?.symbol || '',
|
|
105
|
-
decimals: swapPrice.info?.decimals || 18,
|
|
106
|
-
// The balance check is done at the API level
|
|
107
|
-
isInsufficientFunds: false,
|
|
108
|
-
isSelected: compareAddress(swapQuoteAddress, selectedCurrencyAddress || '')
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
91
|
const purchaseAction = async () => {
|
|
112
92
|
if (!selectedCurrencyAddress) {
|
|
113
93
|
throw new Error('No currency selected');
|
|
@@ -171,9 +151,11 @@ export const useCryptoPayment = ({ chain, currencyAddress, totalPriceRaw, target
|
|
|
171
151
|
return txHash;
|
|
172
152
|
}
|
|
173
153
|
else {
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
154
|
+
const swapOption = swapRoutes
|
|
155
|
+
.flatMap(route => route.fromTokens)
|
|
156
|
+
.find(token => compareAddress(token.address, selectedCurrencyAddress));
|
|
157
|
+
if (!swapOption) {
|
|
158
|
+
throw new Error('No swap option found');
|
|
177
159
|
}
|
|
178
160
|
if (!swapQuote) {
|
|
179
161
|
throw new Error('No swap quote found');
|
|
@@ -187,13 +169,13 @@ export const useCryptoPayment = ({ chain, currencyAddress, totalPriceRaw, target
|
|
|
187
169
|
functionName: 'approve',
|
|
188
170
|
args: [targetContractAddress, totalPriceRaw]
|
|
189
171
|
});
|
|
190
|
-
const isSwapNativeToken = compareAddress(zeroAddress,
|
|
172
|
+
const isSwapNativeToken = compareAddress(zeroAddress, swapOption.address);
|
|
191
173
|
const transactions = [
|
|
192
174
|
// Swap quote optional approve step
|
|
193
175
|
...(swapQuote?.approveData && !isSwapNativeToken
|
|
194
176
|
? [
|
|
195
177
|
{
|
|
196
|
-
to:
|
|
178
|
+
to: swapOption.address,
|
|
197
179
|
data: swapQuote.approveData,
|
|
198
180
|
chain: chainId
|
|
199
181
|
}
|
|
@@ -252,11 +234,27 @@ export const useCryptoPayment = ({ chain, currencyAddress, totalPriceRaw, target
|
|
|
252
234
|
throw error;
|
|
253
235
|
}
|
|
254
236
|
};
|
|
237
|
+
const swapOptionsFormatted = swapRoutes
|
|
238
|
+
.flatMap(route => route.fromTokens)
|
|
239
|
+
.map(fromToken => ({
|
|
240
|
+
...fromToken,
|
|
241
|
+
totalPriceRaw: fromToken.price || '0',
|
|
242
|
+
isSelected: compareAddress(fromToken.address, selectedCurrencyAddress || ''),
|
|
243
|
+
isInsufficientFunds: Number(currencyBalanceData?.find(balance => balance.contractAddress.toLowerCase() === fromToken.address.toLowerCase())
|
|
244
|
+
?.balance || '0') < Number(fromToken.price || '0'),
|
|
245
|
+
totalPriceDisplay: fromToken.price
|
|
246
|
+
? formatDisplay(formatUnits(BigInt(fromToken.price || '0'), fromToken.decimals || 18), {
|
|
247
|
+
disableScientificNotation: true,
|
|
248
|
+
disableCompactNotation: true,
|
|
249
|
+
significantDigits: 6
|
|
250
|
+
})
|
|
251
|
+
: '0'
|
|
252
|
+
}));
|
|
255
253
|
return {
|
|
256
254
|
cryptoOptions: {
|
|
257
|
-
data: [...mainCurrencyOption, ...
|
|
258
|
-
isLoading: isLoadingCurrencyInfo ||
|
|
259
|
-
error: errorCurrencyInfo ||
|
|
255
|
+
data: [...mainCurrencyOption, ...swapOptionsFormatted],
|
|
256
|
+
isLoading: isLoadingCurrencyInfo || swapRoutesIsLoading || currencyBalanceIsLoading,
|
|
257
|
+
error: errorCurrencyInfo || swapRoutesError
|
|
260
258
|
},
|
|
261
259
|
purchaseAction: {
|
|
262
260
|
action: purchaseAction,
|