@b3dotfun/sdk 0.0.24 → 0.0.25
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/README.md +3 -8
- package/dist/cjs/anyspend/constants/index.d.ts +0 -1
- package/dist/cjs/anyspend/constants/index.js +1 -2
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +0 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +11 -15
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +9 -10
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendTournament.d.ts +0 -2
- package/dist/cjs/anyspend/react/components/AnySpendTournament.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +4 -4
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +5 -5
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +0 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderHistory.js +1 -2
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +9 -3
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.d.ts +0 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +2 -3
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PaymentVendorUI.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/common/PaymentVendorUI.js +2 -2
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +2 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +0 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderAndTransactions.js +2 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.js +2 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendQuote.d.ts +1 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendQuote.js +3 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendTokens.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendTokens.js +2 -2
- package/dist/cjs/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useCoinbaseOnrampOptions.js +3 -3
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.js +3 -3
- package/dist/cjs/anyspend/react/hooks/useStripeClientSecret.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useStripeClientSecret.js +3 -3
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.js +3 -3
- package/dist/cjs/anyspend/services/anyspend.d.ts +9 -10
- package/dist/cjs/anyspend/services/anyspend.js +18 -18
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +13 -15
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +1 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +1 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +1 -3
- package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
- package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +4 -4
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.d.ts +1 -0
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +31 -20
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/cjs/global-account/react/components/custom/CopyToClipboard.d.ts +2 -1
- package/dist/cjs/global-account/react/components/custom/CopyToClipboard.js +3 -2
- package/dist/cjs/global-account/react/components/icons/BankIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/BankIcon.js +8 -0
- package/dist/cjs/global-account/react/components/icons/EditIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/EditIcon.js +8 -0
- package/dist/cjs/global-account/react/components/icons/SignOutIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/SignOutIcon.js +8 -0
- package/dist/cjs/global-account/react/components/icons/SwapIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/SwapIcon.js +8 -0
- package/dist/cjs/global-account/react/hooks/useB3BalanceFromAddresses.d.ts +6 -0
- package/dist/cjs/global-account/react/hooks/useB3BalanceFromAddresses.js +11 -0
- package/dist/cjs/global-account/react/hooks/useNativeBalance.d.ts +6 -0
- package/dist/cjs/global-account/react/hooks/useNativeBalance.js +39 -6
- package/dist/cjs/global-account/react/hooks/useTokenPrice.d.ts +10 -0
- package/dist/cjs/global-account/react/hooks/useTokenPrice.js +81 -2
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +6 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +1 -1
- package/dist/esm/anyspend/constants/index.d.ts +0 -1
- package/dist/esm/anyspend/constants/index.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +0 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +13 -17
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +10 -11
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendTournament.d.ts +0 -2
- package/dist/esm/anyspend/react/components/AnySpendTournament.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +4 -4
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.d.ts +1 -2
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +5 -5
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +0 -1
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderHistory.js +1 -2
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +7 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.d.ts +0 -1
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +2 -3
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.d.ts +1 -2
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +2 -2
- package/dist/esm/anyspend/react/components/common/PaymentVendorUI.d.ts +1 -2
- package/dist/esm/anyspend/react/components/common/PaymentVendorUI.js +2 -2
- package/dist/esm/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +2 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +0 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderAndTransactions.js +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.js +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendQuote.d.ts +1 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendQuote.js +3 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendTokens.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendTokens.js +2 -2
- package/dist/esm/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useCoinbaseOnrampOptions.js +3 -3
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.js +3 -3
- package/dist/esm/anyspend/react/hooks/useStripeClientSecret.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useStripeClientSecret.js +3 -3
- package/dist/esm/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useStripeSupport.js +3 -3
- package/dist/esm/anyspend/services/anyspend.d.ts +9 -10
- package/dist/esm/anyspend/services/anyspend.js +19 -19
- package/dist/esm/global-account/react/components/B3DynamicModal.js +13 -15
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +1 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +1 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +1 -3
- package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
- package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +5 -5
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.d.ts +1 -0
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +33 -22
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/esm/global-account/react/components/custom/CopyToClipboard.d.ts +2 -1
- package/dist/esm/global-account/react/components/custom/CopyToClipboard.js +4 -3
- package/dist/esm/global-account/react/components/icons/BankIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/BankIcon.js +5 -0
- package/dist/esm/global-account/react/components/icons/EditIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/EditIcon.js +5 -0
- package/dist/esm/global-account/react/components/icons/SignOutIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/SignOutIcon.js +5 -0
- package/dist/esm/global-account/react/components/icons/SwapIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/SwapIcon.js +5 -0
- package/dist/esm/global-account/react/hooks/useB3BalanceFromAddresses.d.ts +6 -0
- package/dist/esm/global-account/react/hooks/useB3BalanceFromAddresses.js +11 -0
- package/dist/esm/global-account/react/hooks/useNativeBalance.d.ts +6 -0
- package/dist/esm/global-account/react/hooks/useNativeBalance.js +39 -6
- package/dist/esm/global-account/react/hooks/useTokenPrice.d.ts +10 -0
- package/dist/esm/global-account/react/hooks/useTokenPrice.js +78 -3
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +6 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/index.d.ts +0 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +0 -1
- package/dist/types/anyspend/react/components/AnySpendBuySpin.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +0 -1
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnySpendStakeB3.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnySpendTournament.d.ts +0 -2
- package/dist/types/anyspend/react/components/common/FiatPaymentMethod.d.ts +1 -2
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +0 -1
- package/dist/types/anyspend/react/components/common/PanelOnrampPayment.d.ts +0 -1
- package/dist/types/anyspend/react/components/common/PaymentStripeWeb2.d.ts +1 -2
- package/dist/types/anyspend/react/components/common/PaymentVendorUI.d.ts +1 -2
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +0 -1
- package/dist/types/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useAnyspendQuote.d.ts +1 -2
- package/dist/types/anyspend/react/hooks/useAnyspendTokens.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useStripeClientSecret.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
- package/dist/types/anyspend/services/anyspend.d.ts +9 -10
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +1 -2
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +1 -2
- package/dist/types/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
- package/dist/types/global-account/react/components/ManageAccount/ManageAccount.d.ts +1 -0
- package/dist/types/global-account/react/components/custom/CopyToClipboard.d.ts +2 -1
- package/dist/types/global-account/react/components/icons/BankIcon.d.ts +9 -0
- package/dist/types/global-account/react/components/icons/EditIcon.d.ts +9 -0
- package/dist/types/global-account/react/components/icons/SignOutIcon.d.ts +9 -0
- package/dist/types/global-account/react/components/icons/SwapIcon.d.ts +9 -0
- package/dist/types/global-account/react/hooks/useB3BalanceFromAddresses.d.ts +6 -0
- package/dist/types/global-account/react/hooks/useNativeBalance.d.ts +6 -0
- package/dist/types/global-account/react/hooks/useTokenPrice.d.ts +10 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +1 -1
- package/package.json +2 -1
- package/src/anyspend/constants/index.ts +0 -1
- package/src/anyspend/docs/components.md +1 -5
- package/src/anyspend/docs/error-handling.md +47 -47
- package/src/anyspend/docs/examples.md +29 -29
- package/src/anyspend/docs/hooks.md +22 -27
- package/src/anyspend/docs/installation.md +1 -5
- package/src/anyspend/react/components/AnySpend.tsx +8 -28
- package/src/anyspend/react/components/AnySpendBondKit.tsx +0 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -3
- package/src/anyspend/react/components/AnySpendCustom.tsx +8 -16
- package/src/anyspend/react/components/AnySpendNFT.tsx +0 -3
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -3
- package/src/anyspend/react/components/AnySpendTournament.tsx +0 -4
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +0 -1
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +7 -7
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +5 -7
- package/src/anyspend/react/components/common/OrderDetails.tsx +1 -3
- package/src/anyspend/react/components/common/OrderHistory.tsx +1 -3
- package/src/anyspend/react/components/common/OrderStatus.tsx +7 -1
- package/src/anyspend/react/components/common/PanelOnramp.tsx +2 -2
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +1 -4
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +1 -3
- package/src/anyspend/react/components/common/PaymentVendorUI.tsx +2 -3
- package/src/anyspend/react/components/common/RecipientSelection.tsx +1 -1
- package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +1 -3
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +0 -2
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +1 -13
- package/src/anyspend/react/hooks/useAnyspendOrderAndTransactions.ts +2 -2
- package/src/anyspend/react/hooks/useAnyspendOrderHistory.ts +2 -7
- package/src/anyspend/react/hooks/useAnyspendQuote.ts +3 -4
- package/src/anyspend/react/hooks/useAnyspendTokens.ts +2 -2
- package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +3 -8
- package/src/anyspend/react/hooks/useGeoOnrampOptions.ts +2 -3
- package/src/anyspend/react/hooks/useStripeClientSecret.ts +3 -3
- package/src/anyspend/react/hooks/useStripeSupport.ts +3 -8
- package/src/anyspend/services/anyspend.ts +19 -45
- package/src/global-account/react/components/B3DynamicModal.tsx +66 -39
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +1 -4
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +1 -3
- package/src/global-account/react/components/B3Provider/RelayKitProviderWrapper.tsx +4 -6
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +309 -137
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +4 -3
- package/src/global-account/react/components/custom/CopyToClipboard.tsx +7 -4
- package/src/global-account/react/components/icons/BankIcon.tsx +38 -0
- package/src/global-account/react/components/icons/EditIcon.tsx +33 -0
- package/src/global-account/react/components/icons/SignOutIcon.tsx +28 -0
- package/src/global-account/react/components/icons/SwapIcon.tsx +41 -0
- package/src/global-account/react/hooks/useB3BalanceFromAddresses.ts +18 -0
- package/src/global-account/react/hooks/useNativeBalance.tsx +51 -6
- package/src/global-account/react/hooks/useTokenPrice.tsx +138 -3
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +9 -3
- package/src/global-account/react/stores/useModalStore.ts +1 -1
- package/src/styles/index.css +328 -0
|
@@ -1,15 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.fetchNativeTokenPriceUsd = fetchNativeTokenPriceUsd;
|
|
5
|
+
exports.fetchNativeTokenPriceWithChange = fetchNativeTokenPriceWithChange;
|
|
6
|
+
exports.fetchTokenPrice = fetchTokenPrice;
|
|
7
|
+
exports.fetchTokenPriceWithChange = fetchTokenPriceWithChange;
|
|
4
8
|
exports.useTokenPrice = useTokenPrice;
|
|
5
9
|
const chainPlatformMap_1 = require("../../../shared/constants/chains/chainPlatformMap");
|
|
6
10
|
const react_query_1 = require("@tanstack/react-query");
|
|
11
|
+
async function fetchNativeTokenPriceUsd(contractAddress, network) {
|
|
12
|
+
const response = await fetch(`https://coingecko-api.sean-430.workers.dev?localkey=${process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET}&url=https://pro-api.coingecko.com/api/v3/onchain/simple/networks/${network}/token_price/${contractAddress}`, {
|
|
13
|
+
headers: {
|
|
14
|
+
accept: "application/json",
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
throw new Error(`Failed to fetch native token price: ${response.status} ${response.statusText}`);
|
|
19
|
+
}
|
|
20
|
+
const data = await response.json();
|
|
21
|
+
// Find the price using case-insensitive address comparison
|
|
22
|
+
const prices = data.data?.attributes?.token_prices || {};
|
|
23
|
+
const price = Object.entries(prices).find(([address]) => address.toLowerCase() === contractAddress.toLowerCase())?.[1];
|
|
24
|
+
if (!price) {
|
|
25
|
+
throw new Error(`No price data found for native token: ${contractAddress}`);
|
|
26
|
+
}
|
|
27
|
+
// Convert string price to number
|
|
28
|
+
const numericPrice = Number(price);
|
|
29
|
+
if (isNaN(numericPrice)) {
|
|
30
|
+
throw new Error(`Invalid price data for native token: ${contractAddress}`);
|
|
31
|
+
}
|
|
32
|
+
return numericPrice;
|
|
33
|
+
}
|
|
34
|
+
async function fetchNativeTokenPriceWithChange(network) {
|
|
35
|
+
// For ETH, use the regular simple price API instead of on-chain API to get price changes
|
|
36
|
+
const coinId = network === "eth" ? "ethereum" : network;
|
|
37
|
+
const response = await fetch(`https://coingecko-api.sean-430.workers.dev?localkey=${process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET}&url=https://pro-api.coingecko.com/api/v3/simple/price?ids=${coinId}&vs_currencies=usd&include_24hr_change=true`, {
|
|
38
|
+
headers: {
|
|
39
|
+
accept: "application/json",
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
throw new Error(`Failed to fetch native token price with change: ${response.status} ${response.statusText}`);
|
|
44
|
+
}
|
|
45
|
+
const data = await response.json();
|
|
46
|
+
if (!data[coinId]) {
|
|
47
|
+
throw new Error(`No price data found for coin: ${coinId}`);
|
|
48
|
+
}
|
|
49
|
+
const price = data[coinId].usd;
|
|
50
|
+
const priceChange = data[coinId].usd_24h_change;
|
|
51
|
+
if (typeof price !== "number") {
|
|
52
|
+
throw new Error(`Invalid price data for coin: ${coinId}`);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
price,
|
|
56
|
+
priceChange24h: priceChange || null,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
7
59
|
async function fetchTokenPrice(contractAddress, chainId, vsCurrency = "usd") {
|
|
8
60
|
const platformId = (0, chainPlatformMap_1.getPlatformId)(chainId);
|
|
9
|
-
const response = await fetch(`https://pro-api.coingecko.com/api/v3/simple/token_price/${platformId}?contract_addresses=${contractAddress}&vs_currencies=${vsCurrency}`, {
|
|
61
|
+
const response = await fetch(`https://coingecko-api.sean-430.workers.dev?localkey=${process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET}&url=https://pro-api.coingecko.com/api/v3/simple/token_price/${platformId}?contract_addresses=${contractAddress}&vs_currencies=${vsCurrency}`, {
|
|
10
62
|
headers: {
|
|
11
63
|
accept: "application/json",
|
|
12
|
-
"x-cg-pro-api-key": process.env.COINGECKO_API_KEY,
|
|
13
64
|
},
|
|
14
65
|
});
|
|
15
66
|
if (!response.ok) {
|
|
@@ -27,6 +78,34 @@ async function fetchTokenPrice(contractAddress, chainId, vsCurrency = "usd") {
|
|
|
27
78
|
// Return the price with proper type checking
|
|
28
79
|
return data[contractAddress][vsCurrency];
|
|
29
80
|
}
|
|
81
|
+
async function fetchTokenPriceWithChange(contractAddress, chainId, vsCurrency = "usd") {
|
|
82
|
+
const platformId = (0, chainPlatformMap_1.getPlatformId)(chainId);
|
|
83
|
+
const response = await fetch(`https://coingecko-api.sean-430.workers.dev?localkey=${process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET}&url=https://pro-api.coingecko.com/api/v3/simple/token_price/${platformId}?contract_addresses=${contractAddress}&vs_currencies=${vsCurrency}&include_24hr_change=true`, {
|
|
84
|
+
headers: {
|
|
85
|
+
accept: "application/json",
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
if (!response.ok) {
|
|
89
|
+
throw new Error(`Failed to fetch token price with change: ${response.status} ${response.statusText}`);
|
|
90
|
+
}
|
|
91
|
+
const data = await response.json();
|
|
92
|
+
// Check if the contract address exists in the response
|
|
93
|
+
if (!data[contractAddress]) {
|
|
94
|
+
throw new Error(`No price data found for contract address: ${contractAddress}`);
|
|
95
|
+
}
|
|
96
|
+
// Check if the requested currency exists in the response
|
|
97
|
+
if (typeof data[contractAddress][vsCurrency] !== "number") {
|
|
98
|
+
throw new Error(`No price data found for currency: ${vsCurrency}`);
|
|
99
|
+
}
|
|
100
|
+
// Get the price change key (e.g., "usd_24h_change")
|
|
101
|
+
const priceChangeKey = `${vsCurrency}_24h_change`;
|
|
102
|
+
const priceChange = data[contractAddress][priceChangeKey];
|
|
103
|
+
// Return the price and price change with proper type checking
|
|
104
|
+
return {
|
|
105
|
+
price: data[contractAddress][vsCurrency],
|
|
106
|
+
priceChange24h: priceChange || null,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
30
109
|
function useTokenPrice({ contractAddress, chainId = 8453, // Default to Base
|
|
31
110
|
vsCurrency = "usd", refreshInterval = 30000, queryOptions = {}, }) {
|
|
32
111
|
const { data: price = 0, isLoading, error, refetch, } = (0, react_query_1.useQuery)({
|
|
@@ -15,6 +15,11 @@ const thirdweb_2 = require("thirdweb");
|
|
|
15
15
|
const wagmi_1 = require("wagmi");
|
|
16
16
|
const components_1 = require("../components");
|
|
17
17
|
const useAccountWallet_1 = require("./useAccountWallet");
|
|
18
|
+
const partnerId = String(process.env.PUBLIC_THIRDWEB_PARTNER_ID ||
|
|
19
|
+
process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID ||
|
|
20
|
+
process.env.PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID ||
|
|
21
|
+
process.env.NEXT_PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID);
|
|
22
|
+
(0, invariant_1.default)(partnerId, "Partner ID is required");
|
|
18
23
|
function useUnifiedChainSwitchAndExecute() {
|
|
19
24
|
const { data: walletClient } = (0, wagmi_1.useWalletClient)();
|
|
20
25
|
const { switchChainAsync } = (0, wagmi_1.useSwitchChain)();
|
|
@@ -110,7 +115,7 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
110
115
|
// Check if we can use global-accounts-intents, if yes, create an intent.
|
|
111
116
|
try {
|
|
112
117
|
await app_1.default.service("global-accounts-intents").create({
|
|
113
|
-
partnerId:
|
|
118
|
+
partnerId: partnerId,
|
|
114
119
|
chainId: targetChainId,
|
|
115
120
|
to: params.to,
|
|
116
121
|
data: params.data || "0x",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GenerateSigMintResponse } from "../../../anyspend/types/signatureMint";
|
|
2
1
|
import { components } from "../../../anyspend/types/api";
|
|
2
|
+
import { GenerateSigMintResponse } from "../../../anyspend/types/signatureMint";
|
|
3
3
|
import { AllowedStrategy } from "../../../global-account/react";
|
|
4
4
|
import { PermissionsConfig } from "../../../global-account/types/permissions";
|
|
5
5
|
import { Address, Chain } from "thirdweb";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { components } from "../types/api";
|
|
2
2
|
export declare const ANYSPEND_MAINNET_BASE_URL: string;
|
|
3
|
-
export declare const ANYSPEND_TESTNET_BASE_URL: string;
|
|
4
3
|
export declare const RELAY_ETH_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
5
4
|
export declare const RELAY_SOL_ADDRESS = "11111111111111111111111111111111";
|
|
6
5
|
export declare const RELAY_SOLANA_MAINNET_CHAIN_ID = 792703809;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { base } from "viem/chains";
|
|
2
2
|
export const ANYSPEND_MAINNET_BASE_URL = process.env.NEXT_PUBLIC_ANYSPEND_BASE_URL || "https://mainnet.anyspend.com";
|
|
3
|
-
export const ANYSPEND_TESTNET_BASE_URL = process.env.NEXT_PUBLIC_ANYSPEND_BASE_URL || "https://testnet.anyspend.com";
|
|
4
3
|
export const RELAY_ETH_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
5
4
|
export const RELAY_SOL_ADDRESS = "11111111111111111111111111111111";
|
|
6
5
|
export const RELAY_SOLANA_MAINNET_CHAIN_ID = 792703809;
|
|
@@ -8,12 +8,12 @@ import { cn } from "../../../shared/utils/cn.js";
|
|
|
8
8
|
import { shortenAddress } from "../../../shared/utils/formatAddress.js";
|
|
9
9
|
import { formatDisplayNumber, formatTokenAmount } from "../../../shared/utils/number.js";
|
|
10
10
|
import invariant from "invariant";
|
|
11
|
-
import { ArrowDown, ChevronRight,
|
|
11
|
+
import { ArrowDown, ChevronRight, CircleAlert, HistoryIcon } from "lucide-react";
|
|
12
12
|
import { motion } from "motion/react";
|
|
13
13
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
14
14
|
import { toast } from "sonner";
|
|
15
15
|
import { parseUnits } from "viem";
|
|
16
|
-
import {
|
|
16
|
+
import { base, mainnet } from "viem/chains";
|
|
17
17
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper.js";
|
|
18
18
|
import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod.js";
|
|
19
19
|
import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod.js";
|
|
@@ -41,7 +41,7 @@ export function AnySpend(props) {
|
|
|
41
41
|
const fingerprintConfig = getFingerprintConfig();
|
|
42
42
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendInner, { ...props }) }));
|
|
43
43
|
}
|
|
44
|
-
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId,
|
|
44
|
+
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, }) {
|
|
45
45
|
const searchParams = useSearchParamsSSR();
|
|
46
46
|
const router = useRouter();
|
|
47
47
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
@@ -51,7 +51,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
51
51
|
const lastUrlUpdate = useRef(null);
|
|
52
52
|
const [activeTab, setActiveTab] = useState(defaultActiveTab);
|
|
53
53
|
const [orderId, setOrderId] = useState(loadOrder);
|
|
54
|
-
const { orderAndTransactions: oat, getOrderAndTransactionsError } = useAnyspendOrderAndTransactions(
|
|
54
|
+
const { orderAndTransactions: oat, getOrderAndTransactionsError } = useAnyspendOrderAndTransactions(orderId);
|
|
55
55
|
!!getOrderAndTransactionsError && console.log("getOrderAndTransactionsError", getOrderAndTransactionsError);
|
|
56
56
|
const [activePanel, setActivePanel] = useState(loadOrder ? PanelView.ORDER_DETAILS : PanelView.MAIN);
|
|
57
57
|
const [customRecipients, setCustomRecipients] = useState([]);
|
|
@@ -62,9 +62,8 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
62
62
|
// const [newRecipientAddress, setNewRecipientAddress] = useState("");
|
|
63
63
|
// const recipientInputRef = useRef<HTMLInputElement>(null);
|
|
64
64
|
// Get initial chain IDs from URL or defaults
|
|
65
|
-
const initialSrcChainId = parseInt(searchParams.get("fromChainId") || "0") ||
|
|
66
|
-
const initialDstChainId = parseInt(searchParams.get("toChainId") || "0") ||
|
|
67
|
-
(isBuyMode ? destinationTokenChainId : isMainnet ? base.id : b3Sepolia.id);
|
|
65
|
+
const initialSrcChainId = parseInt(searchParams.get("fromChainId") || "0") || mainnet.id;
|
|
66
|
+
const initialDstChainId = parseInt(searchParams.get("toChainId") || "0") || (isBuyMode ? destinationTokenChainId : base.id);
|
|
68
67
|
// State for source chain/token selection
|
|
69
68
|
const [selectedSrcChainId, setSelectedSrcChainId] = useState(initialSrcChainId);
|
|
70
69
|
const defaultSrcToken = getDefaultToken(selectedSrcChainId);
|
|
@@ -294,7 +293,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
294
293
|
setRecipientAddress(recipientAddressFromProps || globalAddress);
|
|
295
294
|
}, [recipientAddressFromProps, globalAddress]);
|
|
296
295
|
// Get geo-based onramp options for fiat payments
|
|
297
|
-
const { geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support } = useGeoOnrampOptions(
|
|
296
|
+
const { geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support } = useGeoOnrampOptions(srcAmountOnRamp);
|
|
298
297
|
// Helper function to map payment method to onramp vendor
|
|
299
298
|
const getOnrampVendor = (paymentMethod) => {
|
|
300
299
|
switch (paymentMethod) {
|
|
@@ -315,7 +314,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
315
314
|
? parseUnits(srcAmount.replace(/,/g, ""), selectedSrcToken.decimals).toString()
|
|
316
315
|
: parseUnits(dstAmount.replace(/,/g, ""), selectedDstToken.decimals).toString();
|
|
317
316
|
const srcAmountOnrampInWei = parseUnits(srcAmountOnRamp.replace(/,/g, ""), USDC_BASE.decimals).toString();
|
|
318
|
-
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } = useAnyspendQuote(
|
|
317
|
+
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } = useAnyspendQuote(activeTab === "crypto"
|
|
319
318
|
? {
|
|
320
319
|
srcChain: selectedSrcChainId,
|
|
321
320
|
dstChain: isBuyMode ? destinationTokenChainId : selectedDstChainId,
|
|
@@ -395,7 +394,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
395
394
|
// invariant(anyspendPrice, "Relay price is not found");
|
|
396
395
|
// const srcAmountBigInt = parseUnits(srcAmount.replace(/,/g, ""), selectedSrcToken.decimals);
|
|
397
396
|
// createOrder({
|
|
398
|
-
// isMainnet,
|
|
399
397
|
// recipientAddress,
|
|
400
398
|
// orderType: "swap",
|
|
401
399
|
// srcChain: selectedSrcChainId,
|
|
@@ -642,7 +640,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
642
640
|
console.log("handleCryptoSwap - selectedCryptoPaymentMethod state:", selectedCryptoPaymentMethod);
|
|
643
641
|
const srcAmountBigInt = parseUnits(srcAmount.replace(/,/g, ""), selectedSrcToken.decimals);
|
|
644
642
|
createOrder({
|
|
645
|
-
isMainnet,
|
|
646
643
|
recipientAddress,
|
|
647
644
|
orderType: "swap",
|
|
648
645
|
srcChain: selectedSrcChainId,
|
|
@@ -705,7 +702,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
705
702
|
return selectedDstToken;
|
|
706
703
|
};
|
|
707
704
|
createOnrampOrder({
|
|
708
|
-
isMainnet,
|
|
709
705
|
recipientAddress,
|
|
710
706
|
orderType: "swap",
|
|
711
707
|
dstChain: getDstToken().chainId,
|
|
@@ -784,7 +780,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
784
780
|
// Add state for rate details toggle
|
|
785
781
|
// const [showRateDetails, setShowRateDetails] = useState(false);
|
|
786
782
|
const historyView = (_jsx("div", { className: "mx-auto flex w-[560px] max-w-full flex-col items-center", children: _jsx(OrderHistory, { mode: mode, onBack: () => setActivePanel(PanelView.MAIN), onSelectOrder: onSelectOrder }) }));
|
|
787
|
-
const orderDetailsView = (_jsx("div", { className: "mx-auto w-[460px] max-w-full", children: _jsx("div", { className: "relative flex flex-col gap-4", children: oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: oat.data.order }), _jsx(OrderDetails, {
|
|
783
|
+
const orderDetailsView = (_jsx("div", { className: "mx-auto w-[460px] max-w-full", children: _jsx("div", { className: "relative flex flex-col gap-4", children: oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: oat.data.order }), _jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, onBack: () => {
|
|
788
784
|
setOrderId(undefined);
|
|
789
785
|
setActivePanel(PanelView.MAIN);
|
|
790
786
|
setSelectedCryptoPaymentMethod(CryptoPaymentMethodType.NONE); // Reset payment method when going back
|
|
@@ -839,8 +835,8 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
839
835
|
}
|
|
840
836
|
// Using inline style to ensure color displays
|
|
841
837
|
return (_jsxs("span", { className: "ml-2", style: { color: percentageNum >= 10 ? "red" : "#FFD700" }, children: ["(", isNegative ? "-" : "", percentage, "%)"] }));
|
|
842
|
-
})()] })] }))] }), getAnyspendQuoteError && (_jsxs("div", { className: "bg-as-on-surface-1 flex w-full max-w-[460px] items-center gap-2 rounded-2xl px-4 py-2", children: [_jsx(CircleAlert, { className: "bg-as-red h-4 min-h-4 w-4 min-w-4 rounded-full p-0 text-sm font-medium text-white" }), _jsx("div", { className: "text-as-red text-sm", children: getAnyspendQuoteError.message })] })), _jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: [
|
|
843
|
-
const onrampPaymentView = (_jsx(PanelOnrampPayment, { srcAmountOnRamp: srcAmountOnRamp, recipientName: recipientName || undefined, recipientAddress: recipientAddress,
|
|
838
|
+
})()] })] }))] }), getAnyspendQuoteError && (_jsxs("div", { className: "bg-as-on-surface-1 flex w-full max-w-[460px] items-center gap-2 rounded-2xl px-4 py-2", children: [_jsx(CircleAlert, { className: "bg-as-red h-4 min-h-4 w-4 min-w-4 rounded-full p-0 text-sm font-medium text-white" }), _jsx("div", { className: "text-as-red text-sm", children: getAnyspendQuoteError.message })] })), _jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: [_jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: cn("as-main-button relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: btnInfo.text }), !hideTransactionHistoryButton && (globalAddress || recipientAddress) ? (_jsxs(Button, { variant: "link", onClick: onClickHistory, className: "text-as-primary/50 hover:text-as-primary flex items-center gap-1 transition-colors", children: [_jsx(HistoryIcon, { className: "h-4 w-4" }), " ", _jsx("span", { className: "pr-4", children: "Transaction History" })] })) : null] })] }));
|
|
839
|
+
const onrampPaymentView = (_jsx(PanelOnrampPayment, { srcAmountOnRamp: srcAmountOnRamp, recipientName: recipientName || undefined, recipientAddress: recipientAddress, isBuyMode: isBuyMode, destinationTokenChainId: destinationTokenChainId, destinationTokenAddress: destinationTokenAddress, selectedDstChainId: selectedDstChainId, selectedDstToken: selectedDstToken, orderType: "swap", anyspendQuote: anyspendQuote, globalAddress: globalAddress, onOrderCreated: orderId => {
|
|
844
840
|
setOrderId(orderId);
|
|
845
841
|
setActivePanel(PanelView.ORDER_DETAILS);
|
|
846
842
|
// Add orderId and payment method to URL for persistence
|
|
@@ -866,9 +862,9 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
866
862
|
const fiatPaymentMethodView = (_jsx(FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack: () => setActivePanel(PanelView.MAIN), onSelectPaymentMethod: (method) => {
|
|
867
863
|
setSelectedFiatPaymentMethod(method);
|
|
868
864
|
setActivePanel(PanelView.MAIN); // Go back to main panel to show updated pricing
|
|
869
|
-
}, srcAmountOnRamp: srcAmountOnRamp
|
|
865
|
+
}, srcAmountOnRamp: srcAmountOnRamp }));
|
|
870
866
|
// Add tabs to the main component when no order is loaded
|
|
871
|
-
return (_jsx(StyleRoot, { children: _jsx("div", { className: cn("mx-auto w-full max-w-[460px]", mode === "page" &&
|
|
867
|
+
return (_jsx(StyleRoot, { children: _jsx("div", { className: cn("anyspend-container font-inter mx-auto w-full max-w-[460px]", mode === "page" &&
|
|
872
868
|
"bg-as-surface-primary border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsx(TransitionPanel, { activeIndex: orderId
|
|
873
869
|
? oat
|
|
874
870
|
? PanelView.ORDER_DETAILS
|
|
@@ -199,7 +199,7 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
199
199
|
functionName: "buyFor",
|
|
200
200
|
args: [recipientAddress, BigInt(minTokensOut)],
|
|
201
201
|
});
|
|
202
|
-
return (_jsx(AnySpendCustom, {
|
|
202
|
+
return (_jsx(AnySpendCustom, { mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: baseMainnet.id, dstToken: dstToken, dstAmount: parseEther(ethAmount).toString(), contractAddress: contractAddress, encodedData: encodedData, metadata: {
|
|
203
203
|
type: "custom",
|
|
204
204
|
action: "BondKit Buy",
|
|
205
205
|
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export declare function AnySpendBuySpin({
|
|
2
|
-
isMainnet?: boolean;
|
|
1
|
+
export declare function AnySpendBuySpin({ loadOrder, mode, spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess, }: {
|
|
3
2
|
loadOrder?: string;
|
|
4
3
|
mode?: "modal" | "page";
|
|
5
4
|
spinwheelContractAddress: string;
|
|
@@ -84,7 +84,7 @@ const basePublicClient = createPublicClient({
|
|
|
84
84
|
chain: baseMainnet,
|
|
85
85
|
transport: http(),
|
|
86
86
|
});
|
|
87
|
-
export function AnySpendBuySpin({
|
|
87
|
+
export function AnySpendBuySpin({ loadOrder, mode = "modal", spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess, }) {
|
|
88
88
|
const hasMounted = useHasMounted();
|
|
89
89
|
const { setB3ModalOpen } = useModalStore();
|
|
90
90
|
// Payment config state
|
|
@@ -388,7 +388,7 @@ export function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", s
|
|
|
388
388
|
}
|
|
389
389
|
// AnySpend flow for when user needs to swap to B3
|
|
390
390
|
const encodedData = generateEncodedDataForBuyEntriesAndSpin(address || "", userSpinQuantity);
|
|
391
|
-
return (_jsx(AnySpendCustom, {
|
|
391
|
+
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: chainId, dstToken: B3_TOKEN, dstAmount: totalCost.toString(), contractAddress: spinwheelContractAddress, spenderAddress: paymentConfig.entryModule, encodedData: encodedData, metadata: {
|
|
392
392
|
type: "custom",
|
|
393
393
|
action: `buy ${userSpinQuantity} spin${userSpinQuantity !== "1" ? "s" : ""}`,
|
|
394
394
|
}, header: header, onSuccess: txHash => onSuccess?.(txHash), showRecipient: false }));
|
|
@@ -2,7 +2,6 @@ import { components } from "../../../anyspend/types/api";
|
|
|
2
2
|
import { GetQuoteResponse } from "../../../anyspend/types/api_req_res";
|
|
3
3
|
import React from "react";
|
|
4
4
|
export declare function AnySpendCustom(props: {
|
|
5
|
-
isMainnet?: boolean;
|
|
6
5
|
loadOrder?: string;
|
|
7
6
|
mode?: "modal" | "page";
|
|
8
7
|
recipientAddress?: string;
|
|
@@ -12,7 +12,7 @@ import { ChevronRight, ChevronRightCircle, Loader2 } from "lucide-react";
|
|
|
12
12
|
import { motion } from "motion/react";
|
|
13
13
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
14
14
|
import { toast } from "sonner";
|
|
15
|
-
import { base
|
|
15
|
+
import { base } from "viem/chains";
|
|
16
16
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper.js";
|
|
17
17
|
import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod.js";
|
|
18
18
|
import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod.js";
|
|
@@ -92,7 +92,7 @@ export function AnySpendCustom(props) {
|
|
|
92
92
|
const fingerprintConfig = getFingerprintConfig();
|
|
93
93
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendCustomInner, { ...props }) }));
|
|
94
94
|
}
|
|
95
|
-
function AnySpendCustomInner({
|
|
95
|
+
function AnySpendCustomInner({ loadOrder, mode = "modal", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, }) {
|
|
96
96
|
const hasMounted = useHasMounted();
|
|
97
97
|
const searchParams = useSearchParamsSSR();
|
|
98
98
|
const router = useRouter();
|
|
@@ -108,10 +108,10 @@ function AnySpendCustomInner({ isMainnet = true, loadOrder, mode = "modal", reci
|
|
|
108
108
|
// Update recipient logic to use custom recipient
|
|
109
109
|
const recipientAddress = customRecipientAddress || currentWallet.address;
|
|
110
110
|
const [orderId, setOrderId] = useState(loadOrder);
|
|
111
|
-
const [srcChainId, setSrcChainId] = useState(
|
|
111
|
+
const [srcChainId, setSrcChainId] = useState(base.id);
|
|
112
112
|
// Get token list for token balance check
|
|
113
113
|
const chainName = useMemo(() => simpleHashChainToChainName(srcChainId), [srcChainId]);
|
|
114
|
-
const { data: tokenList } = useAnyspendTokenList(
|
|
114
|
+
const { data: tokenList } = useAnyspendTokenList(srcChainId, "");
|
|
115
115
|
// Get token balances for the selected chain
|
|
116
116
|
const { nativeTokens, fungibleTokens } = useTokenBalancesByChain({
|
|
117
117
|
address: currentWallet?.wallet?.address || "",
|
|
@@ -190,8 +190,8 @@ function AnySpendCustomInner({ isMainnet = true, loadOrder, mode = "modal", reci
|
|
|
190
190
|
srcChainId,
|
|
191
191
|
srcToken,
|
|
192
192
|
]);
|
|
193
|
-
const { anyspendQuote, isLoadingAnyspendQuote } = useAnyspendQuote(
|
|
194
|
-
const { orderAndTransactions: oat } = useAnyspendOrderAndTransactions(
|
|
193
|
+
const { anyspendQuote, isLoadingAnyspendQuote } = useAnyspendQuote(getRelayQuoteRequest);
|
|
194
|
+
const { orderAndTransactions: oat } = useAnyspendOrderAndTransactions(orderId);
|
|
195
195
|
const onSelectOrder = (selectedOrderId) => {
|
|
196
196
|
setActivePanel(PanelView.ORDER_DETAILS);
|
|
197
197
|
setOrderId(selectedOrderId);
|
|
@@ -218,7 +218,7 @@ function AnySpendCustomInner({ isMainnet = true, loadOrder, mode = "modal", reci
|
|
|
218
218
|
const formattedSrcAmount = srcAmount ? formatTokenAmount(srcAmount, srcToken.decimals, 6, false) : null;
|
|
219
219
|
const srcFiatAmount = useMemo(() => (activeTab === "fiat" && srcAmount ? formatUnits(srcAmount.toString(), USDC_BASE.decimals) : "0"), [activeTab, srcAmount]);
|
|
220
220
|
// Get geo data and onramp options (after quote is available)
|
|
221
|
-
const { geoData, isOnrampSupported, coinbaseAvailablePaymentMethods, stripeWeb2Support } = useGeoOnrampOptions(
|
|
221
|
+
const { geoData, isOnrampSupported, coinbaseAvailablePaymentMethods, stripeWeb2Support } = useGeoOnrampOptions(srcFiatAmount);
|
|
222
222
|
useEffect(() => {
|
|
223
223
|
if (oat?.data?.order.status === "executed") {
|
|
224
224
|
console.log("Calling onSuccess");
|
|
@@ -253,7 +253,6 @@ function AnySpendCustomInner({ isMainnet = true, loadOrder, mode = "modal", reci
|
|
|
253
253
|
invariant(anyspendQuote, "Relay price is not found");
|
|
254
254
|
invariant(srcAmount, "Src amount is null");
|
|
255
255
|
const createOrderParams = {
|
|
256
|
-
isMainnet: isMainnet,
|
|
257
256
|
orderType: orderType,
|
|
258
257
|
srcChain: activeTab === "fiat" ? base.id : srcChainId,
|
|
259
258
|
dstChain: dstChainId,
|
|
@@ -413,7 +412,7 @@ function AnySpendCustomInner({ isMainnet = true, loadOrder, mode = "modal", reci
|
|
|
413
412
|
const historyView = (_jsx("div", { className: cn("mx-auto flex w-full max-w-2xl flex-col items-center p-5", mode === "modal" && "bg-b3-react-background"), children: _jsx(OrderHistory, { mode: mode, onBack: () => {
|
|
414
413
|
setActivePanel(PanelView.HISTORY);
|
|
415
414
|
}, onSelectOrder: onSelectOrder }) }));
|
|
416
|
-
const orderDetailsView = (_jsxs("div", { className: cn("mx-auto flex w-full flex-col items-center gap-4 p-5", mode === "modal" && "bg-b3-react-background rounded-xl"), children: [oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatusDisplay, { order: oat.data.order }), _jsx(OrderDetails, {
|
|
415
|
+
const orderDetailsView = (_jsxs("div", { className: cn("mx-auto flex w-full flex-col items-center gap-4 p-5", mode === "modal" && "bg-b3-react-background rounded-xl"), children: [oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatusDisplay, { order: oat.data.order }), _jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, cryptoPaymentMethod: activeTab === "fiat" ? CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, onBack: () => {
|
|
417
416
|
setOrderId(undefined);
|
|
418
417
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
419
418
|
// Remove orderId from URL when canceling
|
|
@@ -484,7 +483,7 @@ function AnySpendCustomInner({ isMainnet = true, loadOrder, mode = "modal", reci
|
|
|
484
483
|
const fiatPaymentMethodView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4"), children: _jsx(FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack: () => setActivePanel(PanelView.CONFIRM_ORDER), onSelectPaymentMethod: (method) => {
|
|
485
484
|
setSelectedFiatPaymentMethod(method);
|
|
486
485
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
487
|
-
}, srcAmountOnRamp: srcFiatAmount
|
|
486
|
+
}, srcAmountOnRamp: srcFiatAmount }) }));
|
|
488
487
|
// Return the TransitionPanel with all views
|
|
489
488
|
return (_jsx(StyleRoot, { children: _jsx(TransitionPanel, { activeIndex: orderId
|
|
490
489
|
? oat
|
|
@@ -492,7 +491,7 @@ function AnySpendCustomInner({ isMainnet = true, loadOrder, mode = "modal", reci
|
|
|
492
491
|
: PanelView.LOADING
|
|
493
492
|
: activePanel === PanelView.ORDER_DETAILS
|
|
494
493
|
? PanelView.CONFIRM_ORDER
|
|
495
|
-
: activePanel, className: cn("w-full"), variants: {
|
|
494
|
+
: activePanel, className: cn("anyspend-container font-inter w-full"), variants: {
|
|
496
495
|
enter: { x: 300, opacity: 0 },
|
|
497
496
|
center: { x: 0, opacity: 1 },
|
|
498
497
|
exit: { x: -300, opacity: 0 },
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../anyspend/types/api";
|
|
2
|
-
export declare function AnySpendNFT({
|
|
3
|
-
isMainnet?: boolean;
|
|
2
|
+
export declare function AnySpendNFT({ loadOrder, mode, recipientAddress, nftContract, onSuccess, }: {
|
|
4
3
|
loadOrder?: string;
|
|
5
4
|
mode?: "modal" | "page";
|
|
6
5
|
recipientAddress?: string;
|
|
@@ -26,7 +26,7 @@ const CONTRACT_URI_ABI = [
|
|
|
26
26
|
type: "function",
|
|
27
27
|
},
|
|
28
28
|
];
|
|
29
|
-
export function AnySpendNFT({
|
|
29
|
+
export function AnySpendNFT({ loadOrder, mode = "modal", recipientAddress, nftContract, onSuccess, }) {
|
|
30
30
|
const [imageUrlWithFallback, setFallbackImageUrl] = useState(nftContract.imageUrl);
|
|
31
31
|
const [isLoadingFallback, setIsLoadingFallback] = useState(false);
|
|
32
32
|
// Fetch contract metadata when imageUrl is empty
|
|
@@ -83,7 +83,7 @@ export function AnySpendNFT({ isMainnet = true, loadOrder, mode = "modal", recip
|
|
|
83
83
|
const header = ({ anyspendPrice, isLoadingAnyspendPrice, }) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "relative size-[200px]", children: [_jsx("div", { className: "absolute inset-0 scale-95 bg-black/30 blur-md" }), _jsxs(GlareCard, { className: "overflow-hidden", children: [imageUrlWithFallback && (_jsx("img", { src: imageUrlWithFallback, alt: nftContract.name, className: "size-full object-cover" })), _jsx("div", { className: "absolute inset-0 rounded-xl border border-white/10" })] }), _jsx(DropdownMenu, { nftContract: nftContract })] }), _jsxs("div", { className: "from-b3-react-background to-as-on-surface-1 -mb-5 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [_jsx("div", { className: "h-[100px] w-full" }), _jsxs("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: [_jsx("span", { className: "font-sf-rounded text-2xl font-semibold", children: nftContract.name }), _jsx("div", { className: "flex w-fit items-center gap-1", children: anyspendPrice ? (_jsx(AnimatePresence, { mode: "wait", children: _jsx("div", { className: cn("text-as-primary group flex items-center text-3xl font-semibold transition-all", {
|
|
84
84
|
"opacity-0": isLoadingAnyspendPrice,
|
|
85
85
|
}), children: formatDisplayNumber(anyspendPrice?.data?.currencyIn?.amountUsd, { style: "currency" }) }) })) : (_jsx("div", { className: "h-[36px] w-full" })) })] })] })] }));
|
|
86
|
-
return (_jsx(AnySpendCustom, {
|
|
86
|
+
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: "mint_nft", dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
87
87
|
type: "mint_nft",
|
|
88
88
|
nftContract: nftContract,
|
|
89
89
|
}, header: header, onSuccess: onSuccess }));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export declare function AnySpendStakeB3({
|
|
2
|
-
isMainnet?: boolean;
|
|
1
|
+
export declare function AnySpendStakeB3({ loadOrder, mode, recipientAddress, stakeAmount, onSuccess, }: {
|
|
3
2
|
loadOrder?: string;
|
|
4
3
|
mode?: "modal" | "page";
|
|
5
4
|
recipientAddress: string;
|
|
@@ -28,7 +28,7 @@ function generateEncodedDataForStakingB3(amount, beneficiary) {
|
|
|
28
28
|
});
|
|
29
29
|
return encodedData;
|
|
30
30
|
}
|
|
31
|
-
export function AnySpendStakeB3({
|
|
31
|
+
export function AnySpendStakeB3({ loadOrder, mode = "modal", recipientAddress, stakeAmount, onSuccess, }) {
|
|
32
32
|
const hasMounted = useHasMounted();
|
|
33
33
|
const { setB3ModalOpen } = useModalStore();
|
|
34
34
|
// Fetch B3 token balance
|
|
@@ -256,7 +256,7 @@ export function AnySpendStakeB3({ isMainnet = true, loadOrder, mode = "modal", r
|
|
|
256
256
|
}, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary h-14 w-full rounded-xl text-lg font-medium", children: "Done" })] })] }) }));
|
|
257
257
|
}
|
|
258
258
|
const encodedData = generateEncodedDataForStakingB3(userStakeAmount, recipientAddress);
|
|
259
|
-
return (_jsx(AnySpendCustom, {
|
|
259
|
+
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: base.id, dstToken: B3_TOKEN, dstAmount: userStakeAmount, contractAddress: ERC20Staking, encodedData: encodedData, metadata: {
|
|
260
260
|
type: "custom",
|
|
261
261
|
action: "stake B3",
|
|
262
262
|
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../anyspend/types/api";
|
|
2
2
|
type AnySpendTournamentProps = {
|
|
3
|
-
isMainnet?: boolean;
|
|
4
3
|
mode?: "modal" | "page";
|
|
5
4
|
action: "join";
|
|
6
5
|
joinFor: string;
|
|
@@ -12,7 +11,6 @@ type AnySpendTournamentProps = {
|
|
|
12
11
|
tournamentEntryFee: string;
|
|
13
12
|
onSuccess?: () => void;
|
|
14
13
|
} | {
|
|
15
|
-
isMainnet?: boolean;
|
|
16
14
|
mode?: "modal" | "page";
|
|
17
15
|
action: "fund";
|
|
18
16
|
loadOrder?: string;
|
|
@@ -4,13 +4,13 @@ import { formatDisplayNumber, formatTokenAmount } from "../../../shared/utils/nu
|
|
|
4
4
|
import { AnimatePresence } from "motion/react";
|
|
5
5
|
import { AnySpendCustom } from "./AnySpendCustom.js";
|
|
6
6
|
export function AnySpendTournament(props) {
|
|
7
|
-
const {
|
|
7
|
+
const { mode = "modal", action, loadOrder, tournamentChainId, tournamentContractAddress, tournamentMetadata, onSuccess, } = props;
|
|
8
8
|
const dstToken = action === "join" ? props.tournamentEntryToken : props.tournamentFundToken;
|
|
9
9
|
const dstAmount = action === "join" ? props.tournamentEntryFee : props.tournamentFundAmount;
|
|
10
10
|
const header = ({ anyspendPrice, isLoadingAnyspendPrice, }) => (_jsxs(_Fragment, { children: [_jsx("div", { className: "z-10 mt-[-100px] flex h-[270px] w-full items-end justify-center", children: _jsx("img", { src: "https://cdn.b3.fun/tournament-play.svg", alt: "Tournament Play", className: "h-[200px] w-[360px] object-cover object-center" }) }), _jsxs("div", { className: "from-b3-react-background to-as-on-surface-1 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [_jsx("div", { className: "h-[100px] w-full" }), _jsxs("div", { className: "flex w-full flex-col items-center gap-1 p-6 pt-0", children: [_jsxs("span", { className: "font-sf-rounded text-center text-lg font-semibold", children: [action === "join" ? "Pay entry fee to join " : "Pay to fund ", " ", tournamentMetadata.name] }), _jsx("div", { className: "mt-2 flex w-fit items-center gap-1", children: anyspendPrice ? (_jsx(AnimatePresence, { mode: "wait", children: _jsxs("div", { className: cn("text-as-primary group flex items-center text-2xl font-semibold transition-all", {
|
|
11
11
|
"opacity-0": isLoadingAnyspendPrice,
|
|
12
12
|
}), children: [formatDisplayNumber(anyspendPrice?.data?.currencyIn?.amountUsd, { style: "currency" }), " (", formatTokenAmount(BigInt(dstAmount), dstToken.decimals, 6, true), " ", dstToken.symbol, ")"] }) })) : (_jsx("div", { className: "h-[32px] w-full" })) })] })] })] }));
|
|
13
|
-
return (_jsx(AnySpendCustom, {
|
|
13
|
+
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: action === "join" ? props.joinFor : undefined, orderType: action === "join" ? "join_tournament" : "fund_tournament", dstChainId: tournamentChainId, dstToken: dstToken, dstAmount: dstAmount, contractAddress: tournamentContractAddress, encodedData: "0x", metadata: {
|
|
14
14
|
type: action === "join" ? "join_tournament" : "fund_tournament",
|
|
15
15
|
tournament: tournamentMetadata,
|
|
16
16
|
}, header: header, onSuccess: onSuccess, showRecipient: action === "join" }));
|
|
@@ -66,7 +66,7 @@ export function AnyspendSignatureMint({ loadOrder, mode = "modal", signatureData
|
|
|
66
66
|
}
|
|
67
67
|
const encodedData = generateEncodedDataForSignatureMint(signatureData);
|
|
68
68
|
const price = parseEther(signatureData.payload.price?.toString() || "0");
|
|
69
|
-
return (_jsx(AnySpendCustom, {
|
|
69
|
+
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: signatureData.payload.to, orderType: "custom", dstChainId: signatureData.collection.chainId, dstToken: dstToken, dstAmount: price.toString(), contractAddress: signatureData.collection.address, encodedData: encodedData, metadata: {
|
|
70
70
|
type: "custom",
|
|
71
71
|
action: "Signature Mint",
|
|
72
72
|
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
@@ -33,11 +33,11 @@ export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentM
|
|
|
33
33
|
createWallet("io.rabby"),
|
|
34
34
|
createWallet("app.phantom"),
|
|
35
35
|
];
|
|
36
|
-
return (_jsxs("div", { className: "mx-auto h-fit w-[460px] max-w-full", children: [_jsxs("div", { className: cn("relative flex flex-col gap-10"), children: [_jsx("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary absolute flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: _jsx(ChevronLeft, { className: "h-6 w-6" }) }), _jsx("div", { className: "flex items-center justify-around gap-4", children: _jsx("div", { className: "flex-1 text-center", children: _jsx("h2", { className: "text-as-primary text-lg font-semibold", children: "Choose payment method" }) }) }), _jsxs("div", { className: "flex flex-col gap-3", children: [!activeWallet ? (
|
|
36
|
+
return (_jsxs("div", { className: "crypto-payment-method mx-auto h-fit w-[460px] max-w-full", children: [_jsxs("div", { className: cn("relative flex flex-col gap-10"), children: [_jsx("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary absolute flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: _jsx(ChevronLeft, { className: "h-6 w-6" }) }), _jsx("div", { className: "flex items-center justify-around gap-4", children: _jsx("div", { className: "flex-1 text-center", children: _jsx("h2", { className: "text-as-primary text-lg font-semibold", children: "Choose payment method" }) }) }), _jsxs("div", { className: "crypto-payment-methods flex flex-col gap-3", children: [!activeWallet ? (
|
|
37
37
|
// Not connected - show single connect button
|
|
38
|
-
_jsxs("button", { onClick: () => setShowWalletModal(true), className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-blue-100", children: _jsx(Wallet, { className: "h-4 w-4 text-blue-600" }) }), _jsxs("div", { className: "flex flex-col items-start text-left", children: [_jsx("h4", { className: "text-as-primary font-semibold", children: "Connect wallet" }), _jsx("p", { className: "text-as-primary/60 text-sm", children: "Choose from multiple wallet options" })] })] }), _jsx(ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })) : (
|
|
38
|
+
_jsxs("button", { onClick: () => setShowWalletModal(true), className: "crypto-payment-method-connect-wallet bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-blue-100", children: _jsx(Wallet, { className: "h-4 w-4 text-blue-600" }) }), _jsxs("div", { className: "flex flex-col items-start text-left", children: [_jsx("h4", { className: "text-as-primary font-semibold", children: "Connect wallet" }), _jsx("p", { className: "text-as-primary/60 text-sm", children: "Choose from multiple wallet options" })] })] }), _jsx(ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })) : (
|
|
39
39
|
// Connected - show wallet info
|
|
40
|
-
_jsx("div", { className: "bg-as-surface-primary border-as-border-secondary rounded-xl border", children: _jsxs("div", { className: "flex items-center justify-between p-4", children: [_jsxs("div", { className: "flex items-center gap-3", children: [globalWallet?.meta?.icon ? (_jsx("img", { src: globalWallet.meta.icon, alt: "Connected Wallet", className: "h-8 w-8 rounded-full" })) : (_jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-green-100", children: _jsx(Wallet, { className: "h-4 w-4 text-green-600" }) })), _jsxs("div", { className: "flex flex-col", children: [_jsx("span", { className: "text-as-primary font-semibold", children: "Connected Wallet" }), _jsx("span", { className: "text-as-primary/60 text-sm", children: shortenAddress(activeWallet.getAccount()?.address || "") })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("button", { onClick: () => {
|
|
40
|
+
_jsx("div", { className: "crypto-payment-method-connect-wallet wallet-connected bg-as-surface-primary border-as-border-secondary rounded-xl border", children: _jsxs("div", { className: "flex items-center justify-between p-4", children: [_jsxs("div", { className: "flex items-center gap-3", children: [globalWallet?.meta?.icon ? (_jsx("img", { src: globalWallet.meta.icon, alt: "Connected Wallet", className: "h-8 w-8 rounded-full" })) : (_jsx("div", { className: "wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-green-100", children: _jsx(Wallet, { className: "h-4 w-4 text-green-600" }) })), _jsxs("div", { className: "flex flex-col", children: [_jsx("span", { className: "text-as-primary font-semibold", children: "Connected Wallet" }), _jsx("span", { className: "text-as-primary/60 text-sm", children: shortenAddress(activeWallet.getAccount()?.address || "") })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("button", { onClick: () => {
|
|
41
41
|
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
42
42
|
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
43
43
|
}, className: "bg-as-brand hover:bg-as-brand/90 rounded-lg px-3 py-1.5 text-sm font-medium text-white transition-colors", children: "Use Wallet" }), _jsx("button", { onClick: async () => {
|
|
@@ -50,7 +50,7 @@ export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentM
|
|
|
50
50
|
}, className: "text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors", children: _jsx(X, { className: "h-4 w-4" }) })] })] }) })), _jsxs("button", { onClick: () => {
|
|
51
51
|
setSelectedPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
52
52
|
onSelectPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
53
|
-
}, disabled: isCreatingOrder, className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [_jsx("div", { className: "flex flex-col items-start text-left", children: _jsx("h4", { className: "text-as-primary font-semibold", children: "Transfer crypto" }) }), _jsx(ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })] })] }), showWalletModal &&
|
|
53
|
+
}, disabled: isCreatingOrder, className: "crypto-payment-method-transfer bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [_jsx("div", { className: "flex flex-col items-start text-left", children: _jsx("h4", { className: "text-as-primary font-semibold", children: "Transfer crypto" }) }), _jsx(ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })] })] }), showWalletModal &&
|
|
54
54
|
createPortal(_jsx("div", { className: "pointer-events-auto fixed inset-0 z-[9999] flex items-center justify-center bg-black/50", children: _jsxs("div", { className: "max-h-[80vh] w-[400px] max-w-[90vw] overflow-auto rounded-xl bg-white p-6 dark:bg-gray-900", children: [_jsxs("div", { className: "mb-4 flex items-center justify-between", children: [_jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: "Connect Wallet" }), _jsx("button", { onClick: () => setShowWalletModal(false), className: "text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200", children: _jsx(X, { className: "h-5 w-5" }) })] }), _jsx(ConnectEmbed, { client: client, chain: thirdwebB3Mainnet, wallets: availableWallets, showThirdwebBranding: false, theme: lightTheme(), onConnect: async (wallet) => {
|
|
55
55
|
console.log("Wallet connected:", wallet);
|
|
56
56
|
// setShowWalletModal(false);
|
|
@@ -9,7 +9,6 @@ interface FiatPaymentMethodProps {
|
|
|
9
9
|
onBack: () => void;
|
|
10
10
|
onSelectPaymentMethod: (method: FiatPaymentMethod) => void;
|
|
11
11
|
srcAmountOnRamp: string;
|
|
12
|
-
isMainnet: boolean;
|
|
13
12
|
}
|
|
14
|
-
export declare function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedPaymentMethod, onBack, onSelectPaymentMethod, srcAmountOnRamp,
|
|
13
|
+
export declare function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedPaymentMethod, onBack, onSelectPaymentMethod, srcAmountOnRamp, }: FiatPaymentMethodProps): import("react/jsx-runtime").JSX.Element;
|
|
15
14
|
export {};
|