@b3dotfun/sdk 0.0.62 → 0.0.63-test.0-alpha.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/cjs/anyspend/react/components/AnySpend.js +61 -23
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +3 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +275 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +5 -4
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +9 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +288 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +33 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +4 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +4 -6
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +9 -17
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +6 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +11 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +66 -147
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -3
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +39 -15
- package/dist/cjs/anyspend/react/components/common/PaySection.js +1 -1
- package/dist/cjs/anyspend/react/components/common/TokenBalance.js +1 -1
- package/dist/cjs/anyspend/react/components/index.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/index.js +11 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +25 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +42 -19
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendQuote.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +26 -0
- package/dist/cjs/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.js +56 -0
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +10 -0
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +73 -0
- package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +14 -0
- package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.js +57 -0
- package/dist/cjs/anyspend/react/hooks/usePhantomTransfer.d.ts +36 -0
- package/dist/cjs/anyspend/react/hooks/usePhantomTransfer.js +211 -0
- package/dist/cjs/anyspend/types/api.d.ts +665 -3
- package/dist/cjs/anyspend/utils/orderPayload.js +4 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +10 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +3 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/cjs/global-account/react/hooks/index.d.ts +2 -1
- package/dist/cjs/global-account/react/hooks/index.js +5 -3
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +7 -2
- package/dist/cjs/global-account/react/hooks/useSimBalance.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +6 -5
- package/dist/cjs/global-account/react/hooks/useTokenBalanceDirect.d.ts +12 -0
- package/dist/cjs/global-account/react/hooks/useTokenBalanceDirect.js +62 -0
- package/dist/cjs/global-account/react/hooks/useTokenFromUrl.js +4 -3
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +31 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +62 -24
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +269 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +7 -6
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +9 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +285 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +11 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +30 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +4 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +5 -7
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +9 -17
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +6 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +11 -1
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +67 -148
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -3
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +40 -16
- package/dist/esm/anyspend/react/components/common/PaySection.js +1 -1
- package/dist/esm/anyspend/react/components/common/TokenBalance.js +2 -2
- package/dist/esm/anyspend/react/components/index.d.ts +5 -1
- package/dist/esm/anyspend/react/components/index.js +5 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +25 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +42 -19
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendQuote.js +1 -1
- package/dist/esm/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +26 -0
- package/dist/esm/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.js +53 -0
- package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +10 -0
- package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +70 -0
- package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +14 -0
- package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.js +54 -0
- package/dist/esm/anyspend/react/hooks/usePhantomTransfer.d.ts +36 -0
- package/dist/esm/anyspend/react/hooks/usePhantomTransfer.js +208 -0
- package/dist/esm/anyspend/types/api.d.ts +665 -3
- package/dist/esm/anyspend/utils/orderPayload.js +4 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +11 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +3 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/esm/global-account/react/hooks/index.d.ts +2 -1
- package/dist/esm/global-account/react/hooks/index.js +2 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +7 -2
- package/dist/esm/global-account/react/hooks/useSimBalance.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useSimBalance.js +6 -5
- package/dist/esm/global-account/react/hooks/useTokenBalanceDirect.d.ts +12 -0
- package/dist/esm/global-account/react/hooks/useTokenBalanceDirect.js +59 -0
- package/dist/esm/global-account/react/hooks/useTokenFromUrl.js +4 -3
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +31 -1
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
- package/dist/types/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +9 -0
- package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +11 -0
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +6 -1
- package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +2 -1
- package/dist/types/anyspend/react/components/index.d.ts +5 -1
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +25 -3
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
- package/dist/types/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +26 -0
- package/dist/types/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +10 -0
- package/dist/types/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +14 -0
- package/dist/types/anyspend/react/hooks/usePhantomTransfer.d.ts +36 -0
- package/dist/types/anyspend/types/api.d.ts +665 -3
- package/dist/types/global-account/react/hooks/index.d.ts +2 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useSimBalance.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useTokenBalanceDirect.d.ts +12 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +31 -1
- package/package.json +3 -2
- package/src/anyspend/react/components/AnySpend.tsx +73 -22
- package/src/anyspend/react/components/AnySpendCustom.tsx +4 -0
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +595 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +8 -11
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +522 -0
- package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +73 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +7 -3
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +5 -7
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +9 -18
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +22 -0
- package/src/anyspend/react/components/common/OrderDetails.tsx +76 -190
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +2 -3
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +48 -17
- package/src/anyspend/react/components/common/PaySection.tsx +1 -0
- package/src/anyspend/react/components/common/TokenBalance.tsx +2 -2
- package/src/anyspend/react/components/index.ts +5 -1
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +51 -18
- package/src/anyspend/react/hooks/useAnyspendQuote.ts +1 -1
- package/src/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.ts +72 -0
- package/src/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.ts +80 -0
- package/src/anyspend/react/hooks/useConnectedWalletDisplay.ts +69 -0
- package/src/anyspend/react/hooks/usePhantomTransfer.ts +301 -0
- package/src/anyspend/types/api.ts +669 -1
- package/src/anyspend/utils/orderPayload.ts +5 -1
- package/src/global-account/react/components/B3DynamicModal.tsx +11 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +3 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +2 -2
- package/src/global-account/react/hooks/index.ts +2 -1
- package/src/global-account/react/hooks/useAuthentication.ts +10 -2
- package/src/global-account/react/hooks/useSimBalance.ts +6 -5
- package/src/global-account/react/hooks/useTokenBalanceDirect.tsx +84 -0
- package/src/global-account/react/hooks/useTokenFromUrl.tsx +6 -5
- package/src/global-account/react/stores/useModalStore.ts +34 -0
|
@@ -12,8 +12,6 @@ const hooks_1 = require("../../../../shared/react/hooks");
|
|
|
12
12
|
const utils_1 = require("../../../../shared/utils");
|
|
13
13
|
const centerTruncate_1 = __importDefault(require("../../../../shared/utils/centerTruncate"));
|
|
14
14
|
const number_1 = require("../../../../shared/utils/number");
|
|
15
|
-
const spl_token_1 = require("@solana/spl-token");
|
|
16
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
17
15
|
const react_2 = require("@web3icons/react");
|
|
18
16
|
const lucide_react_1 = require("lucide-react");
|
|
19
17
|
const react_3 = require("motion/react");
|
|
@@ -24,6 +22,7 @@ const sonner_1 = require("sonner");
|
|
|
24
22
|
const viem_1 = require("viem");
|
|
25
23
|
const chains_1 = require("viem/chains");
|
|
26
24
|
const wagmi_1 = require("wagmi");
|
|
25
|
+
const usePhantomTransfer_1 = require("../../hooks/usePhantomTransfer");
|
|
27
26
|
const Accordion_1 = require("./Accordion");
|
|
28
27
|
const ConnectWalletPayment_1 = __importDefault(require("./ConnectWalletPayment"));
|
|
29
28
|
const CryptoPaymentMethod_1 = require("./CryptoPaymentMethod");
|
|
@@ -55,6 +54,12 @@ function getOrderSuccessText({ order, tournament, formattedActualDstAmount, form
|
|
|
55
54
|
case "custom":
|
|
56
55
|
actionText = order.metadata.action || `executed contract`;
|
|
57
56
|
return `Successfully ${actionText}`;
|
|
57
|
+
case "x402_swap":
|
|
58
|
+
actionText = `sent ${formattedActualDstAmount || "--"} ${dstToken.symbol}`;
|
|
59
|
+
return `Successfully ${actionText} to ${recipient}`;
|
|
60
|
+
case "custom_exact_in":
|
|
61
|
+
actionText = `executed contract`;
|
|
62
|
+
return `Successfully ${actionText}`;
|
|
58
63
|
default:
|
|
59
64
|
throw new Error("Invalid order type");
|
|
60
65
|
}
|
|
@@ -155,6 +160,10 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ mode = "modal",
|
|
|
155
160
|
const [showQRCode, setShowQRCode] = (0, react_4.useState)(false);
|
|
156
161
|
const { isLoading: txLoading, isSuccess: txSuccess } = (0, wagmi_1.useWaitForTransactionReceipt)({ hash: txHash });
|
|
157
162
|
const { switchChainAndExecuteWithEOA, switchChainAndExecute, isSwitchingOrExecuting } = (0, react_1.useUnifiedChainSwitchAndExecute)();
|
|
163
|
+
// Track if auto-payment was attempted to avoid re-triggering
|
|
164
|
+
const autoPaymentAttempted = (0, react_4.useRef)(false);
|
|
165
|
+
// Track if component is ready for auto-payment (all data loaded)
|
|
166
|
+
const [isComponentReady, setIsComponentReady] = (0, react_4.useState)(false);
|
|
158
167
|
const roundedUpSrcAmount = (0, react_4.useMemo)(() => {
|
|
159
168
|
// Display the full transfer amount without rounding since users need to see the exact value they're transferring.
|
|
160
169
|
// Use 21 significant digits (max allowed by Intl.NumberFormat)
|
|
@@ -210,19 +219,25 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ mode = "modal",
|
|
|
210
219
|
setTxHash(txHash);
|
|
211
220
|
}
|
|
212
221
|
}, [order, switchChainAndExecuteWithEOA, switchChainAndExecute, depositDeficit, effectiveCryptoPaymentMethod]);
|
|
222
|
+
// Use Phantom transfer hook for Solana payments
|
|
223
|
+
const { initiateTransfer: initiatePhantomTransfer, getConnectedAddress: getPhantomAddress } = (0, usePhantomTransfer_1.usePhantomTransfer)();
|
|
213
224
|
// Main payment handler that triggers chain switch and payment
|
|
214
|
-
const handlePayment = async () => {
|
|
225
|
+
const handlePayment = (0, react_4.useCallback)(async () => {
|
|
215
226
|
console.log("Initiating payment process. Target chain:", order.srcChain, "Current chain:", walletClient?.chain?.id);
|
|
216
227
|
if (order.srcChain === anyspend_1.RELAY_SOLANA_MAINNET_CHAIN_ID) {
|
|
217
228
|
// Use the existing depositDeficit calculation to determine amount to send
|
|
218
229
|
const amountToSend = depositDeficit > BigInt(0) ? depositDeficit.toString() : order.srcAmount;
|
|
219
|
-
await initiatePhantomTransfer(
|
|
230
|
+
await initiatePhantomTransfer({
|
|
231
|
+
amountLamports: amountToSend,
|
|
232
|
+
tokenAddress: order.srcTokenAddress,
|
|
233
|
+
recipientAddress: order.globalAddress,
|
|
234
|
+
});
|
|
220
235
|
}
|
|
221
236
|
else {
|
|
222
237
|
// Use unified payment process for both EOA and AA wallets
|
|
223
238
|
await handleUnifiedPaymentProcess();
|
|
224
239
|
}
|
|
225
|
-
};
|
|
240
|
+
}, [order, walletClient?.chain?.id, depositDeficit, handleUnifiedPaymentProcess, initiatePhantomTransfer]);
|
|
226
241
|
// When waitingForDeposit is true, we show a message to the user to wait for the deposit to be processed.
|
|
227
242
|
const setWaitingForDeposit = (0, react_4.useCallback)(() => {
|
|
228
243
|
if (disableUrlParamManagement)
|
|
@@ -260,16 +275,50 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ mode = "modal",
|
|
|
260
275
|
setTxHash(undefined);
|
|
261
276
|
}
|
|
262
277
|
}, [setWaitingForDeposit, txSuccess]);
|
|
263
|
-
const isPhantomMobile = (0, react_4.useMemo)(() => navigator.userAgent.includes("Phantom"), []);
|
|
264
|
-
const isPhantomBrowser = (0, react_4.useMemo)(() => window.phantom?.solana?.isPhantom, []);
|
|
265
278
|
// Get connected Phantom wallet address if available
|
|
266
|
-
const phantomWalletAddress = (0, react_4.useMemo)(() =>
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
279
|
+
const phantomWalletAddress = (0, react_4.useMemo)(() => getPhantomAddress(), [getPhantomAddress]);
|
|
280
|
+
// Calculate status display before using it
|
|
281
|
+
const { text: statusText, status: statusDisplay } = (0, anyspend_1.getStatusDisplay)(order);
|
|
282
|
+
// Memoize the payable state calculation to avoid recalculating on every render
|
|
283
|
+
const isPayableState = (0, react_4.useMemo)(() => {
|
|
284
|
+
const waitingForDeposit = new URLSearchParams(window.location.search).get("waitingForDeposit") === "true";
|
|
285
|
+
return (refundTxs.length === 0 &&
|
|
286
|
+
!executeTx &&
|
|
287
|
+
!(relayTxs.length > 0 && relayTxs.every(tx => tx.status === "success")) &&
|
|
288
|
+
!depositTxs?.length &&
|
|
289
|
+
!waitingForDeposit &&
|
|
290
|
+
statusDisplay === "processing" &&
|
|
291
|
+
!order.onrampMetadata &&
|
|
292
|
+
(effectiveCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET ||
|
|
293
|
+
effectiveCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.GLOBAL_WALLET));
|
|
294
|
+
}, [
|
|
295
|
+
refundTxs.length,
|
|
296
|
+
executeTx,
|
|
297
|
+
relayTxs,
|
|
298
|
+
depositTxs?.length,
|
|
299
|
+
statusDisplay,
|
|
300
|
+
order.onrampMetadata,
|
|
301
|
+
effectiveCryptoPaymentMethod,
|
|
302
|
+
]);
|
|
303
|
+
// Mark component as ready once all critical data is available
|
|
304
|
+
// This ensures we don't trigger payment before the component has fully initialized
|
|
305
|
+
(0, react_4.useEffect)(() => {
|
|
306
|
+
if (!isComponentReady && srcToken && dstToken && statusDisplay) {
|
|
307
|
+
setIsComponentReady(true);
|
|
270
308
|
}
|
|
271
|
-
|
|
272
|
-
|
|
309
|
+
}, [isComponentReady, srcToken, dstToken, statusDisplay]);
|
|
310
|
+
// Auto-trigger payment when component is ready and order is in payable state
|
|
311
|
+
// This effect only runs when isPayableState or isComponentReady changes
|
|
312
|
+
(0, react_4.useEffect)(() => {
|
|
313
|
+
// Only trigger payment if:
|
|
314
|
+
// 1. We haven't attempted payment yet
|
|
315
|
+
// 2. Component is fully ready (all data loaded)
|
|
316
|
+
// 3. Order is in a payable state
|
|
317
|
+
if (!autoPaymentAttempted.current && isComponentReady && isPayableState) {
|
|
318
|
+
autoPaymentAttempted.current = true;
|
|
319
|
+
handlePayment();
|
|
320
|
+
}
|
|
321
|
+
}, [isPayableState, isComponentReady, handlePayment]);
|
|
273
322
|
if (!srcToken || !dstToken) {
|
|
274
323
|
return (0, jsx_runtime_1.jsx)("div", { children: "Loading..." });
|
|
275
324
|
}
|
|
@@ -284,138 +333,6 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ mode = "modal",
|
|
|
284
333
|
const formattedActualDstAmount = actualDstAmount
|
|
285
334
|
? (0, number_1.formatTokenAmount)(BigInt(actualDstAmount), dstToken.decimals)
|
|
286
335
|
: undefined;
|
|
287
|
-
const { text: statusText, status: statusDisplay } = (0, anyspend_1.getStatusDisplay)(order);
|
|
288
|
-
const initiatePhantomTransfer = async (amountLamports, tokenAddress, recipientAddress) => {
|
|
289
|
-
try {
|
|
290
|
-
if (!isPhantomBrowser && !isPhantomMobile) {
|
|
291
|
-
sonner_1.toast.error("Phantom wallet not installed. Please install Phantom wallet to continue.");
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
// Step 2: Ensure Phantom is connected/unlocked
|
|
295
|
-
const phantom = window.phantom?.solana;
|
|
296
|
-
if (!phantom) {
|
|
297
|
-
sonner_1.toast.error("Phantom wallet not accessible");
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
// Connect and unlock wallet if needed
|
|
301
|
-
let publicKey;
|
|
302
|
-
try {
|
|
303
|
-
const connection = await phantom.connect();
|
|
304
|
-
publicKey = connection.publicKey;
|
|
305
|
-
}
|
|
306
|
-
catch (connectError) {
|
|
307
|
-
sonner_1.toast.error("Failed to connect to Phantom wallet");
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
// Step 3: Create transaction with priority fees
|
|
311
|
-
const connection = new web3_js_1.Connection("https://mainnet.helius-rpc.com/?api-key=efafd9b3-1807-4cf8-8aa4-3d984f56d8fb");
|
|
312
|
-
const fromPubkey = new web3_js_1.PublicKey(publicKey.toString());
|
|
313
|
-
const toPubkey = new web3_js_1.PublicKey(recipientAddress);
|
|
314
|
-
const amount = BigInt(amountLamports);
|
|
315
|
-
// Step 4: Get recent priority fees to determine optimal pricing
|
|
316
|
-
let priorityFee = 10000; // Default fallback (10,000 micro-lamports)
|
|
317
|
-
try {
|
|
318
|
-
const recentFees = await connection.getRecentPrioritizationFees({
|
|
319
|
-
lockedWritableAccounts: [fromPubkey],
|
|
320
|
-
});
|
|
321
|
-
if (recentFees && recentFees.length > 0) {
|
|
322
|
-
// Use 75th percentile of recent fees for good priority
|
|
323
|
-
const sortedFees = recentFees.map(fee => fee.prioritizationFee).sort((a, b) => a - b);
|
|
324
|
-
const percentile75Index = Math.floor(sortedFees.length * 0.75);
|
|
325
|
-
priorityFee = Math.max(sortedFees[percentile75Index] || 10000, 10000);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
catch (feeError) {
|
|
329
|
-
console.warn("Failed to fetch recent priority fees, using default:", feeError);
|
|
330
|
-
}
|
|
331
|
-
let transaction;
|
|
332
|
-
// Check if this is native SOL transfer
|
|
333
|
-
if (tokenAddress === "11111111111111111111111111111111") {
|
|
334
|
-
// Native SOL transfer with priority fees
|
|
335
|
-
const computeUnitLimit = 1000; // SOL transfer + compute budget instructions need ~600-800 CU
|
|
336
|
-
const computeUnitPrice = Math.min(priorityFee, 100000); // Cap at 100k micro-lamports for safety
|
|
337
|
-
transaction = new web3_js_1.Transaction()
|
|
338
|
-
.add(
|
|
339
|
-
// Set compute unit limit first (must come before other instructions)
|
|
340
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
|
|
341
|
-
units: computeUnitLimit,
|
|
342
|
-
}))
|
|
343
|
-
.add(
|
|
344
|
-
// Set priority fee
|
|
345
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
346
|
-
microLamports: computeUnitPrice,
|
|
347
|
-
}))
|
|
348
|
-
.add(
|
|
349
|
-
// Actual transfer instruction
|
|
350
|
-
web3_js_1.SystemProgram.transfer({
|
|
351
|
-
fromPubkey,
|
|
352
|
-
toPubkey,
|
|
353
|
-
lamports: Number(amount),
|
|
354
|
-
}));
|
|
355
|
-
console.log(`Using priority fee: ${computeUnitPrice} micro-lamports per CU, limit: ${computeUnitLimit} CU`);
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
// SPL Token transfer with priority fees
|
|
359
|
-
const mintPubkey = new web3_js_1.PublicKey(tokenAddress);
|
|
360
|
-
// Get associated token accounts
|
|
361
|
-
const fromTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(mintPubkey, fromPubkey);
|
|
362
|
-
const toTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(mintPubkey, toPubkey);
|
|
363
|
-
// Check if destination token account exists
|
|
364
|
-
const toTokenAccountInfo = await connection.getAccountInfo(toTokenAccount);
|
|
365
|
-
const needsDestinationAccount = !toTokenAccountInfo;
|
|
366
|
-
// Get mint info to determine decimals
|
|
367
|
-
const mintInfo = await connection.getParsedAccountInfo(mintPubkey);
|
|
368
|
-
const decimals = mintInfo.value?.data?.parsed?.info?.decimals || 9;
|
|
369
|
-
// SPL transfers need more compute units than SOL transfers
|
|
370
|
-
// Add extra CU if we need to create destination account
|
|
371
|
-
const computeUnitLimit = needsDestinationAccount ? 40000 : 20000;
|
|
372
|
-
const computeUnitPrice = Math.min(priorityFee, 100000);
|
|
373
|
-
// Create transfer instruction
|
|
374
|
-
const transferInstruction = (0, spl_token_1.createTransferCheckedInstruction)(fromTokenAccount, mintPubkey, toTokenAccount, fromPubkey, Number(amount), decimals);
|
|
375
|
-
transaction = new web3_js_1.Transaction()
|
|
376
|
-
.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
|
|
377
|
-
units: computeUnitLimit,
|
|
378
|
-
}))
|
|
379
|
-
.add(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
380
|
-
microLamports: computeUnitPrice,
|
|
381
|
-
}));
|
|
382
|
-
// Add create destination account instruction if needed
|
|
383
|
-
if (needsDestinationAccount) {
|
|
384
|
-
transaction.add((0, spl_token_1.createAssociatedTokenAccountInstruction)(fromPubkey, // payer
|
|
385
|
-
toTokenAccount, // ata
|
|
386
|
-
toPubkey, // owner
|
|
387
|
-
mintPubkey));
|
|
388
|
-
}
|
|
389
|
-
// Add the transfer instruction
|
|
390
|
-
transaction.add(transferInstruction);
|
|
391
|
-
console.log(`SPL Token transfer: ${computeUnitPrice} micro-lamports per CU, limit: ${computeUnitLimit} CU, creating destination: ${needsDestinationAccount}`);
|
|
392
|
-
}
|
|
393
|
-
// Step 5: Get latest blockhash and simulate transaction to verify
|
|
394
|
-
const { blockhash } = await connection.getLatestBlockhash("confirmed");
|
|
395
|
-
transaction.recentBlockhash = blockhash;
|
|
396
|
-
transaction.feePayer = fromPubkey;
|
|
397
|
-
// Step 6: Sign and send transaction with priority fees
|
|
398
|
-
const signedTransaction = await phantom.signAndSendTransaction(transaction);
|
|
399
|
-
sonner_1.toast.success(`Transaction successful! Signature: ${signedTransaction.signature}`);
|
|
400
|
-
console.log("Transaction sent with priority fees. Signature:", signedTransaction.signature);
|
|
401
|
-
}
|
|
402
|
-
catch (error) {
|
|
403
|
-
console.error("Transfer error:", error);
|
|
404
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
405
|
-
if (errorMessage.includes("User rejected")) {
|
|
406
|
-
sonner_1.toast.error("Transaction was cancelled by user");
|
|
407
|
-
}
|
|
408
|
-
else if (errorMessage.includes("insufficient")) {
|
|
409
|
-
sonner_1.toast.error("Insufficient balance for this transaction");
|
|
410
|
-
}
|
|
411
|
-
else if (errorMessage.includes("blockhash not found")) {
|
|
412
|
-
sonner_1.toast.error("Network congestion detected. Please try again in a moment.");
|
|
413
|
-
}
|
|
414
|
-
else {
|
|
415
|
-
sonner_1.toast.error(`Transfer failed: ${errorMessage}`);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
336
|
if (refundTxs.length > 0) {
|
|
420
337
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: order, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount, points: points }), (0, jsx_runtime_1.jsx)(Accordion_1.Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: (0, jsx_runtime_1.jsxs)(Accordion_1.AccordionItem, { value: "refund-details", className: "order-details-refund-item", children: [(0, jsx_runtime_1.jsx)(Accordion_1.AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), (0, jsx_runtime_1.jsx)(Accordion_1.AccordionContent, { className: "accordion-content pl-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_3.motion.div, { className: "bg-as-border-primary absolute left-[2px] top-0 z-10 w-[3px]", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
421
338
|
? depositTxs.map(dTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
@@ -455,7 +372,7 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ mode = "modal",
|
|
|
455
372
|
? depositTxs.map(dTxs => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
|
|
456
373
|
? `Received payment`
|
|
457
374
|
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
|
|
458
|
-
: null, relayTxs.map(relayTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: "Processed Transaction", chainId: relayTx.chain, isProcessing: false, tx: relayTx, delay: 0.5 }))), order.status === "executing" && ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.type === "swap"
|
|
375
|
+
: null, relayTxs.map(relayTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: "Processed Transaction", chainId: relayTx.chain, isProcessing: false, tx: relayTx, delay: 0.5 }))), order.status === "executing" && ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.type === "swap" || order.type === "x402_swap"
|
|
459
376
|
? "Processing Swap"
|
|
460
377
|
: order.type === "mint_nft"
|
|
461
378
|
? "Minting NFT"
|
|
@@ -465,7 +382,9 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ mode = "modal",
|
|
|
465
382
|
? "Funding Tournament"
|
|
466
383
|
: order.type === "hype_duel"
|
|
467
384
|
? "Depositing Hype Duel"
|
|
468
|
-
:
|
|
385
|
+
: order.type === "custom" || order.type === "custom_exact_in"
|
|
386
|
+
? "Executing Contract"
|
|
387
|
+
: "Processing Bridge", chainId: order.dstChain, isProcessing: true, tx: null, delay: 1 }))] }) })] }) }), order.type === "join_tournament" && order.status === "executed" && ((0, jsx_runtime_1.jsxs)(react_1.ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "flex w-full items-center gap-2", disabled: txLoading || isSwitchingOrExecuting, onClick: handleCloseModal, children: [(0, jsx_runtime_1.jsx)("span", { className: "pl-4", children: "Continue to Tournament" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })), order.status === "executed" && ((0, jsx_runtime_1.jsx)("button", { className: "order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white", onClick: mode === "page" ? handleBack : handleCloseModal, children: mode === "page" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Return to Home ", (0, jsx_runtime_1.jsx)(lucide_react_1.Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") }))] }));
|
|
469
388
|
}
|
|
470
389
|
// This boolean indicates that user finish payment, and waiting for the deposit to be confirmed. We get this from query params (waitingForDeposit=true)
|
|
471
390
|
const waitingForDeposit = new URLSearchParams(window.location.search).get("waitingForDeposit") === "true";
|
|
@@ -23,8 +23,7 @@ exports.OrderDetailsCollapsible = (0, react_3.memo)(function OrderDetailsCollaps
|
|
|
23
23
|
const expectedDstAmount = order.type === "mint_nft" ||
|
|
24
24
|
order.type === "join_tournament" ||
|
|
25
25
|
order.type === "fund_tournament" ||
|
|
26
|
-
order.type === "custom"
|
|
27
|
-
order.type === "hype_duel"
|
|
26
|
+
order.type === "custom"
|
|
28
27
|
? "0"
|
|
29
28
|
: order.payload.expectedDstAmount.toString();
|
|
30
29
|
const finalFormattedExpectedDstAmount = formattedExpectedDstAmount || (0, number_1.formatTokenAmount)(BigInt(expectedDstAmount), dstToken.decimals);
|
|
@@ -36,7 +35,7 @@ exports.OrderDetailsCollapsible = (0, react_3.memo)(function OrderDetailsCollaps
|
|
|
36
35
|
? "Join tournament"
|
|
37
36
|
: order.type === "fund_tournament"
|
|
38
37
|
? "Fund tournament"
|
|
39
|
-
: order.type === "custom"
|
|
38
|
+
: order.type === "custom" || order.type === "custom_exact_in"
|
|
40
39
|
? order.metadata.action
|
|
41
40
|
? (0, anyspend_1.capitalizeFirstLetter)(order.metadata.action)
|
|
42
41
|
: "Contract execution"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../../anyspend/types/api";
|
|
2
|
-
export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect, canEditAmount, className, innerClassName, amountClassName, tokenSelectClassName, onTokenSelect, }: {
|
|
2
|
+
export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect, canEditAmount, className, innerClassName, amountClassName, tokenSelectClassName, onTokenSelect, walletAddress, }: {
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
inputValue: string;
|
|
5
5
|
onChangeInput: (value: string) => void;
|
|
@@ -18,4 +18,5 @@ export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput,
|
|
|
18
18
|
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
19
19
|
preventDefault: () => void;
|
|
20
20
|
}) => void;
|
|
21
|
+
walletAddress?: string | undefined;
|
|
21
22
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,27 +6,55 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
const lucide_react_1 = require("lucide-react");
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const react_number_format_1 = require("react-number-format");
|
|
9
|
+
const viem_1 = require("viem");
|
|
9
10
|
const anyspend_1 = require("../../../../anyspend");
|
|
11
|
+
const chain_1 = require("../../../../anyspend/utils/chain");
|
|
12
|
+
const token_1 = require("../../../../anyspend/utils/token");
|
|
10
13
|
const react_2 = require("../../../../global-account/react");
|
|
11
14
|
const utils_1 = require("../../../../shared/utils");
|
|
12
15
|
const relay_kit_ui_1 = require("@relayprotocol/relay-kit-ui");
|
|
13
16
|
const ChainTokenIcon_1 = require("./ChainTokenIcon");
|
|
14
|
-
function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect = false, canEditAmount = true, className, innerClassName, amountClassName, tokenSelectClassName, onTokenSelect, }) {
|
|
17
|
+
function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect = false, canEditAmount = true, className, innerClassName, amountClassName, tokenSelectClassName, onTokenSelect, walletAddress, }) {
|
|
15
18
|
// Track previous token to detect changes
|
|
16
19
|
const prevTokenRef = (0, react_1.useRef)(token.address);
|
|
20
|
+
// Track if initial balance has been set
|
|
21
|
+
const initialBalanceSetRef = (0, react_1.useRef)(false);
|
|
22
|
+
// Only get token balance when context is "from" (for setting max amount)
|
|
23
|
+
const { rawBalance } = (0, react_2.useTokenBalance)({
|
|
24
|
+
token,
|
|
25
|
+
address: context === "from" && walletAddress ? walletAddress : undefined,
|
|
26
|
+
});
|
|
27
|
+
// Reset balance ref when token address or chain changes
|
|
17
28
|
(0, react_1.useEffect)(() => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
initialBalanceSetRef.current = false;
|
|
30
|
+
}, [token.address, token.chainId]);
|
|
31
|
+
(0, react_1.useEffect)(() => {
|
|
32
|
+
// Only handle "from" context
|
|
33
|
+
if (context !== "from")
|
|
34
|
+
return;
|
|
35
|
+
// Check if token changed or if this is the initial load with balance
|
|
36
|
+
const isTokenChanged = prevTokenRef.current !== token.address;
|
|
37
|
+
const isInitialLoad = !initialBalanceSetRef.current && rawBalance;
|
|
38
|
+
if ((isTokenChanged || isInitialLoad) && rawBalance) {
|
|
39
|
+
console.log(`Setting max balance - Token: ${token.address}, Changed: ${isTokenChanged}, Initial: ${isInitialLoad}`);
|
|
40
|
+
// Calculate max amount with gas reserve for native tokens
|
|
41
|
+
let maxAmount;
|
|
42
|
+
if ((0, token_1.isNativeToken)(token.address)) {
|
|
43
|
+
const gasReserve = (0, chain_1.getNativeRequired)(token.chainId);
|
|
44
|
+
// Ensure we don't go negative
|
|
45
|
+
maxAmount = rawBalance > gasReserve ? rawBalance - gasReserve : BigInt(0);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// For ERC20 tokens, use full balance
|
|
49
|
+
maxAmount = rawBalance;
|
|
25
50
|
}
|
|
26
|
-
//
|
|
51
|
+
// Set the max amount as input value
|
|
52
|
+
onChangeInput((0, viem_1.formatUnits)(maxAmount, token.decimals));
|
|
53
|
+
// Update refs
|
|
27
54
|
prevTokenRef.current = token.address;
|
|
55
|
+
initialBalanceSetRef.current = true;
|
|
28
56
|
}
|
|
29
|
-
}, [token.address, chainId, context, onChangeInput]);
|
|
57
|
+
}, [token.address, token.chainId, token.decimals, chainId, context, onChangeInput, rawBalance]);
|
|
30
58
|
const handleTokenSelect = (newToken) => {
|
|
31
59
|
const token = {
|
|
32
60
|
address: newToken.address,
|
|
@@ -53,12 +81,8 @@ function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, addres
|
|
|
53
81
|
prevTokenRef.current = "changing"; // Temporary value to force effect
|
|
54
82
|
// Set the chain ID first
|
|
55
83
|
setChainId(newToken.chainId);
|
|
56
|
-
// Then set the new token
|
|
84
|
+
// Then set the new token - the useEffect will handle setting the max balance
|
|
57
85
|
setToken(token);
|
|
58
|
-
// If this is the source token, reset the amount immediately
|
|
59
|
-
if (context === "from") {
|
|
60
|
-
onChangeInput("0.01");
|
|
61
|
-
}
|
|
62
86
|
};
|
|
63
87
|
return ((0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("border-as-stroke flex w-full flex-col gap-2 rounded-xl", className), children: (0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("flex items-center justify-between gap-3", innerClassName), children: [!canEditAmount ? ((0, jsx_runtime_1.jsx)("h2", { className: (0, utils_1.cn)("text-3xl font-medium text-white", amountClassName), children: inputValue || "--" })) : ((0, jsx_runtime_1.jsx)(react_number_format_1.NumericFormat, { decimalSeparator: ".", allowedDecimalSeparators: [","], thousandSeparator: true, inputMode: "decimal", autoComplete: "off", autoCorrect: "off", type: "text", placeholder: "0.00", minLength: 1, maxLength: 30, spellCheck: "false", className: (0, utils_1.cn)("placeholder:text-as-primary/70 disabled:text-as-primary/70 text-as-primary w-full bg-transparent text-4xl font-semibold leading-[42px] outline-none sm:text-[30px]", amountClassName), pattern: "^[0-9]*[.,]?[0-9]*$", disabled: disabled, value: inputValue, allowNegative: false, onChange: e => onChangeInput(e.currentTarget.value) }, `input-${token.address}-${chainId}`)), !hideTokenSelect && ((0, jsx_runtime_1.jsx)(relay_kit_ui_1.TokenSelector, { address: address, chainIdsFilter: Object.values(anyspend_1.ALL_CHAINS).map(chain => chain.id), context: context, fromChainWalletVMSupported: true, isValidAddress: true, lockedChainIds: Object.values(anyspend_1.ALL_CHAINS).map(chain => chain.id), multiWalletSupportEnabled: true, onAnalyticEvent: undefined, popularChainIds: [1, 8453, anyspend_1.RELAY_SOLANA_MAINNET_CHAIN_ID], setToken: handleTokenSelect, supportedWalletVMs: ["evm", "svm"], token: undefined, trigger: (0, jsx_runtime_1.jsxs)(react_2.Button, { variant: "outline", role: "combobox", className: (0, utils_1.cn)("token-selector-button bg-b3-react-background border-as-stroke flex h-auto w-fit shrink-0 items-center justify-center gap-2 rounded-xl border-2 px-2 py-1 pr-2 text-center", tokenSelectClassName), children: [token.metadata.logoURI ? ((0, jsx_runtime_1.jsx)(ChainTokenIcon_1.ChainTokenIcon, { chainUrl: anyspend_1.ALL_CHAINS[chainId].logoUrl, tokenUrl: token.metadata.logoURI, className: "h-8 min-h-8 w-8 min-w-8" })) : ((0, jsx_runtime_1.jsx)("div", { className: "h-8 w-8 rounded-full bg-gray-700" })), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-0", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary font-semibold", children: token.symbol }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/70 text-xs", children: anyspend_1.ALL_CHAINS[chainId].name })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsUpDown, { className: "h-4 w-4 shrink-0 opacity-70" })] }) }, `selector-${context}-${token.address}-${chainId}`))] }) }, `${context}-${token.address}-${chainId}`));
|
|
64
88
|
}
|
|
@@ -42,7 +42,7 @@ function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedS
|
|
|
42
42
|
(0, react_3.useEffect)(() => {
|
|
43
43
|
appliedSrcMetadataRef.current = false;
|
|
44
44
|
}, [selectedSrcToken.address, selectedSrcToken.chainId]);
|
|
45
|
-
return ((0, jsx_runtime_1.jsxs)(react_2.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "pay-section bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none", onClick: onSelectCryptoPaymentMethod, children: selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isConnected ? ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-1", children: connectedName ? (0, utils_1.formatUsername)(connectedName) : (0, formatAddress_1.shortenAddress)(connectedAddress || "") })) : ("Connect wallet"), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.GLOBAL_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Global Account", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.TRANSFER_CRYPTO ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Transfer crypto", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Select payment method", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) })] }), (0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: connectedAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
|
|
45
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "pay-section bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none", onClick: onSelectCryptoPaymentMethod, children: selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isConnected ? ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-1", children: connectedName ? (0, utils_1.formatUsername)(connectedName) : (0, formatAddress_1.shortenAddress)(connectedAddress || "") })) : ("Connect wallet"), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.GLOBAL_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Global Account", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.TRANSFER_CRYPTO ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Transfer crypto", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Select payment method", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) })] }), (0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: connectedAddress, walletAddress: connectedAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
|
|
46
46
|
setIsSrcInputDirty(true);
|
|
47
47
|
setSrcAmount(value);
|
|
48
48
|
}, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-5 items-center text-sm", children: (0, number_1.formatDisplayNumber)(anyspendQuote?.data?.currencyIn?.amountUsd, {
|
|
@@ -7,7 +7,7 @@ const token_1 = require("../../../../anyspend/utils/token");
|
|
|
7
7
|
const react_1 = require("../../../../global-account/react");
|
|
8
8
|
const viem_1 = require("viem");
|
|
9
9
|
function TokenBalance({ token, walletAddress, onChangeInput, }) {
|
|
10
|
-
const { rawBalance, formattedBalance, isLoading } = (0, react_1.
|
|
10
|
+
const { rawBalance, formattedBalance, isLoading } = (0, react_1.useTokenBalanceDirect)({
|
|
11
11
|
token,
|
|
12
12
|
address: walletAddress,
|
|
13
13
|
});
|
|
@@ -2,11 +2,15 @@ export { AnySpend } from "./AnySpend";
|
|
|
2
2
|
export { AnySpendBondKit } from "./AnySpendBondKit";
|
|
3
3
|
export { AnySpendBuySpin } from "./AnySpendBuySpin";
|
|
4
4
|
export { AnySpendCustom } from "./AnySpendCustom";
|
|
5
|
+
export { AnySpendCustomExactIn } from "./AnySpendCustomExactIn";
|
|
5
6
|
export * from "./AnySpendFingerprintWrapper";
|
|
6
7
|
export { AnySpendNFT } from "./AnySpendNFT";
|
|
8
|
+
export { AnyspendSignatureMint } from "./AnyspendSignatureMint";
|
|
7
9
|
export { AnySpendStakeB3 } from "./AnySpendStakeB3";
|
|
10
|
+
export { AnySpendStakeB3ExactIn } from "./AnySpendStakeB3ExactIn";
|
|
11
|
+
export { AnySpendStakeUpside } from "./AnySpendStakeUpside";
|
|
12
|
+
export { AnySpendStakeUpsideExactIn } from "./AnySpendStakeUpsideExactIn";
|
|
8
13
|
export { AnySpendTournament } from "./AnySpendTournament";
|
|
9
|
-
export { AnyspendSignatureMint } from "./AnyspendSignatureMint";
|
|
10
14
|
export { AnySpendNFTButton } from "./common/AnySpendNFTButton";
|
|
11
15
|
export { ChainTokenIcon } from "./common/ChainTokenIcon";
|
|
12
16
|
export { CryptoPaySection } from "./common/CryptoPaySection";
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.WebviewOnrampPayment = exports.WebviewOnrampOrderStatus = exports.TransferCryptoDetails = exports.TokenBalance = exports.StepProgress = exports.RecipientSelection = exports.OrderTokenAmount = exports.OrderToken = exports.OrderStatus = exports.OrderHistoryItem = exports.OrderHistory = exports.OrderDetailsCollapsible = exports.OrderDetails = exports.CryptoReceiveSection = exports.CryptoPaySection = exports.ChainTokenIcon = exports.AnySpendNFTButton = exports.
|
|
17
|
+
exports.WebviewOnrampPayment = exports.WebviewOnrampOrderStatus = exports.TransferCryptoDetails = exports.TokenBalance = exports.StepProgress = exports.RecipientSelection = exports.OrderTokenAmount = exports.OrderToken = exports.OrderStatus = exports.OrderHistoryItem = exports.OrderHistory = exports.OrderDetailsCollapsible = exports.OrderDetails = exports.CryptoReceiveSection = exports.CryptoPaySection = exports.ChainTokenIcon = exports.AnySpendNFTButton = exports.AnySpendTournament = exports.AnySpendStakeUpsideExactIn = exports.AnySpendStakeUpside = exports.AnySpendStakeB3ExactIn = exports.AnySpendStakeB3 = exports.AnyspendSignatureMint = exports.AnySpendNFT = exports.AnySpendCustomExactIn = exports.AnySpendCustom = exports.AnySpendBuySpin = exports.AnySpendBondKit = exports.AnySpend = void 0;
|
|
18
18
|
// Components
|
|
19
19
|
var AnySpend_1 = require("./AnySpend");
|
|
20
20
|
Object.defineProperty(exports, "AnySpend", { enumerable: true, get: function () { return AnySpend_1.AnySpend; } });
|
|
@@ -24,15 +24,23 @@ var AnySpendBuySpin_1 = require("./AnySpendBuySpin");
|
|
|
24
24
|
Object.defineProperty(exports, "AnySpendBuySpin", { enumerable: true, get: function () { return AnySpendBuySpin_1.AnySpendBuySpin; } });
|
|
25
25
|
var AnySpendCustom_1 = require("./AnySpendCustom");
|
|
26
26
|
Object.defineProperty(exports, "AnySpendCustom", { enumerable: true, get: function () { return AnySpendCustom_1.AnySpendCustom; } });
|
|
27
|
+
var AnySpendCustomExactIn_1 = require("./AnySpendCustomExactIn");
|
|
28
|
+
Object.defineProperty(exports, "AnySpendCustomExactIn", { enumerable: true, get: function () { return AnySpendCustomExactIn_1.AnySpendCustomExactIn; } });
|
|
27
29
|
__exportStar(require("./AnySpendFingerprintWrapper"), exports);
|
|
28
30
|
var AnySpendNFT_1 = require("./AnySpendNFT");
|
|
29
31
|
Object.defineProperty(exports, "AnySpendNFT", { enumerable: true, get: function () { return AnySpendNFT_1.AnySpendNFT; } });
|
|
32
|
+
var AnyspendSignatureMint_1 = require("./AnyspendSignatureMint");
|
|
33
|
+
Object.defineProperty(exports, "AnyspendSignatureMint", { enumerable: true, get: function () { return AnyspendSignatureMint_1.AnyspendSignatureMint; } });
|
|
30
34
|
var AnySpendStakeB3_1 = require("./AnySpendStakeB3");
|
|
31
35
|
Object.defineProperty(exports, "AnySpendStakeB3", { enumerable: true, get: function () { return AnySpendStakeB3_1.AnySpendStakeB3; } });
|
|
36
|
+
var AnySpendStakeB3ExactIn_1 = require("./AnySpendStakeB3ExactIn");
|
|
37
|
+
Object.defineProperty(exports, "AnySpendStakeB3ExactIn", { enumerable: true, get: function () { return AnySpendStakeB3ExactIn_1.AnySpendStakeB3ExactIn; } });
|
|
38
|
+
var AnySpendStakeUpside_1 = require("./AnySpendStakeUpside");
|
|
39
|
+
Object.defineProperty(exports, "AnySpendStakeUpside", { enumerable: true, get: function () { return AnySpendStakeUpside_1.AnySpendStakeUpside; } });
|
|
40
|
+
var AnySpendStakeUpsideExactIn_1 = require("./AnySpendStakeUpsideExactIn");
|
|
41
|
+
Object.defineProperty(exports, "AnySpendStakeUpsideExactIn", { enumerable: true, get: function () { return AnySpendStakeUpsideExactIn_1.AnySpendStakeUpsideExactIn; } });
|
|
32
42
|
var AnySpendTournament_1 = require("./AnySpendTournament");
|
|
33
43
|
Object.defineProperty(exports, "AnySpendTournament", { enumerable: true, get: function () { return AnySpendTournament_1.AnySpendTournament; } });
|
|
34
|
-
var AnyspendSignatureMint_1 = require("./AnyspendSignatureMint");
|
|
35
|
-
Object.defineProperty(exports, "AnyspendSignatureMint", { enumerable: true, get: function () { return AnyspendSignatureMint_1.AnyspendSignatureMint; } });
|
|
36
44
|
var AnySpendNFTButton_1 = require("./common/AnySpendNFTButton");
|
|
37
45
|
Object.defineProperty(exports, "AnySpendNFTButton", { enumerable: true, get: function () { return AnySpendNFTButton_1.AnySpendNFTButton; } });
|
|
38
46
|
// Common Components
|
|
@@ -17,13 +17,16 @@ interface UseAnyspendFlowProps {
|
|
|
17
17
|
loadOrder?: string;
|
|
18
18
|
isDepositMode?: boolean;
|
|
19
19
|
onOrderSuccess?: (orderId: string) => void;
|
|
20
|
-
onTransactionSuccess?: (amount
|
|
20
|
+
onTransactionSuccess?: (amount: string) => void;
|
|
21
21
|
sourceTokenAddress?: string;
|
|
22
22
|
sourceTokenChainId?: number;
|
|
23
|
+
destinationTokenAddress?: string;
|
|
24
|
+
destinationTokenChainId?: number;
|
|
23
25
|
slippage?: number;
|
|
24
26
|
disableUrlParamManagement?: boolean;
|
|
27
|
+
orderType?: "hype_duel" | "custom_exact_in";
|
|
25
28
|
}
|
|
26
|
-
export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrder, isDepositMode, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, slippage, disableUrlParamManagement, }: UseAnyspendFlowProps): {
|
|
29
|
+
export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrder, isDepositMode, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, destinationTokenAddress, destinationTokenChainId, slippage, disableUrlParamManagement, orderType, }: UseAnyspendFlowProps): {
|
|
27
30
|
activePanel: PanelView;
|
|
28
31
|
setActivePanel: import("react").Dispatch<import("react").SetStateAction<PanelView>>;
|
|
29
32
|
orderId: string | undefined;
|
|
@@ -44,7 +47,6 @@ export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrd
|
|
|
44
47
|
selectedSrcChainId: number;
|
|
45
48
|
setSelectedSrcChainId: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
46
49
|
selectedDstChainId: number;
|
|
47
|
-
setSelectedDstChainId: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
48
50
|
selectedSrcToken: {
|
|
49
51
|
chainId: number;
|
|
50
52
|
address: string;
|
|
@@ -65,6 +67,26 @@ export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrd
|
|
|
65
67
|
logoURI?: string;
|
|
66
68
|
};
|
|
67
69
|
}>>;
|
|
70
|
+
selectedDstToken: {
|
|
71
|
+
chainId: number;
|
|
72
|
+
address: string;
|
|
73
|
+
symbol: string;
|
|
74
|
+
name: string;
|
|
75
|
+
decimals: number;
|
|
76
|
+
metadata: {
|
|
77
|
+
logoURI?: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
setSelectedDstToken: import("react").Dispatch<import("react").SetStateAction<{
|
|
81
|
+
chainId: number;
|
|
82
|
+
address: string;
|
|
83
|
+
symbol: string;
|
|
84
|
+
name: string;
|
|
85
|
+
decimals: number;
|
|
86
|
+
metadata: {
|
|
87
|
+
logoURI?: string;
|
|
88
|
+
};
|
|
89
|
+
}>>;
|
|
68
90
|
srcAmount: string;
|
|
69
91
|
setSrcAmount: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
70
92
|
dstAmount: string;
|