@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
|
@@ -3,12 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OrderStatus = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const anyspend_1 = require("../../../../anyspend");
|
|
6
|
+
const react_1 = require("../../../../shared/react");
|
|
6
7
|
const lucide_react_1 = require("lucide-react");
|
|
7
|
-
const
|
|
8
|
+
const react_2 = require("react");
|
|
8
9
|
const StepProgress_1 = require("./StepProgress");
|
|
9
|
-
exports.OrderStatus = (0,
|
|
10
|
+
exports.OrderStatus = (0, react_2.memo)(function OrderStatus({ order }) {
|
|
10
11
|
const isComplete = order.status === "executed";
|
|
11
12
|
const { text, status: displayStatus, description } = (0, anyspend_1.getStatusDisplay)(order);
|
|
13
|
+
const searchParams = (0, react_1.useSearchParams)();
|
|
14
|
+
const cryptoPaymentMethod = searchParams.get("cryptoPaymentMethod");
|
|
12
15
|
console.log("OrderStatus", displayStatus);
|
|
13
16
|
console.log("OrderStatus", order);
|
|
14
17
|
const paymentSteps = [
|
|
@@ -24,7 +27,10 @@ exports.OrderStatus = (0, react_1.memo)(function OrderStatus({ order }) {
|
|
|
24
27
|
},
|
|
25
28
|
];
|
|
26
29
|
if (["waiting_stripe_payment", "scanning_deposit_transaction"].includes(order.status)) {
|
|
27
|
-
|
|
30
|
+
// hide step if order is scanning_deposit_transaction and crypto payment method is transfer_crypto
|
|
31
|
+
if (!(order.status === "scanning_deposit_transaction" && cryptoPaymentMethod === "transfer_crypto")) {
|
|
32
|
+
return (0, jsx_runtime_1.jsx)(StepProgress_1.StepProgress, { steps: paymentSteps, currentStepIndex: 0 });
|
|
33
|
+
}
|
|
28
34
|
}
|
|
29
35
|
if (["relay", "sending_token_from_vault"].includes(order.status)) {
|
|
30
36
|
return (0, jsx_runtime_1.jsx)(StepProgress_1.StepProgress, { steps: paymentSteps, currentStepIndex: 1 });
|
|
@@ -14,7 +14,7 @@ const FiatPaymentMethod_1 = require("./FiatPaymentMethod");
|
|
|
14
14
|
const OrderTokenAmountFiat_1 = require("./OrderTokenAmountFiat");
|
|
15
15
|
function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, selectedPaymentMethod, setActivePanel, _recipientAddress, destinationToken, destinationChainId, destinationAmount, onDestinationTokenChange, onDestinationChainChange, }) {
|
|
16
16
|
// Get geo-based onramp options to access fee information
|
|
17
|
-
const { stripeWeb2Support } = (0, react_1.useGeoOnrampOptions)(
|
|
17
|
+
const { stripeWeb2Support } = (0, react_1.useGeoOnrampOptions)(srcAmountOnRamp);
|
|
18
18
|
// Helper function to get fees from API data
|
|
19
19
|
const getFeeFromApi = (paymentMethod) => {
|
|
20
20
|
switch (paymentMethod) {
|
|
@@ -48,7 +48,7 @@ function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, selectedPaymentMetho
|
|
|
48
48
|
};
|
|
49
49
|
// Get geo data for onramp availability
|
|
50
50
|
const { geoData } = (0, react_2.useGetGeo)();
|
|
51
|
-
const { coinbaseOnrampOptions } = (0, react_1.useCoinbaseOnrampOptions)(
|
|
51
|
+
const { coinbaseOnrampOptions } = (0, react_1.useCoinbaseOnrampOptions)(geoData?.country || "US");
|
|
52
52
|
// Get recipient profile for displaying name
|
|
53
53
|
const recipientProfile = (0, react_2.useProfile)({ address: _recipientAddress });
|
|
54
54
|
const recipientName = recipientProfile.data?.name;
|
|
@@ -18,8 +18,8 @@ function PanelOnrampPayment(props) {
|
|
|
18
18
|
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(PanelOnrampPaymentInner, { ...props }) }));
|
|
19
19
|
}
|
|
20
20
|
function PanelOnrampPaymentInner(props) {
|
|
21
|
-
const { srcAmountOnRamp, recipientAddress,
|
|
22
|
-
const { geoData, coinbaseOnrampOptions, coinbaseAvailablePaymentMethods, stripeWeb2Support, isLoading: isLoadingGeoOnramp, } = (0, react_1.useGeoOnrampOptions)(
|
|
21
|
+
const { srcAmountOnRamp, recipientAddress, isBuyMode, destinationTokenChainId, destinationTokenAddress, selectedDstChainId, selectedDstToken, anyspendQuote, globalAddress, onOrderCreated, onBack, orderType, nft, tournament, payload, recipientEnsName, recipientImageUrl, } = props;
|
|
22
|
+
const { geoData, coinbaseOnrampOptions, coinbaseAvailablePaymentMethods, stripeWeb2Support, isLoading: isLoadingGeoOnramp, } = (0, react_1.useGeoOnrampOptions)(srcAmountOnRamp);
|
|
23
23
|
const isLoading = isLoadingGeoOnramp;
|
|
24
24
|
const { createOrder, isCreatingOrder } = (0, react_1.useAnyspendCreateOnrampOrder)({
|
|
25
25
|
onSuccess: data => {
|
|
@@ -65,7 +65,6 @@ function PanelOnrampPaymentInner(props) {
|
|
|
65
65
|
return selectedDstToken;
|
|
66
66
|
};
|
|
67
67
|
createOrder({
|
|
68
|
-
isMainnet,
|
|
69
68
|
recipientAddress,
|
|
70
69
|
orderType,
|
|
71
70
|
dstChain: getDstToken().chainId,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { components } from "../../../../anyspend/types/api";
|
|
2
2
|
interface PaymentStripeWeb2Props {
|
|
3
|
-
isMainnet: boolean;
|
|
4
3
|
order: components["schemas"]["Order"];
|
|
5
4
|
onPaymentSuccess?: (paymentIntent: any) => void;
|
|
6
5
|
}
|
|
7
|
-
export default function PaymentStripeWeb2({
|
|
6
|
+
export default function PaymentStripeWeb2({ order, onPaymentSuccess }: PaymentStripeWeb2Props): import("react/jsx-runtime").JSX.Element;
|
|
8
7
|
export {};
|
|
@@ -18,10 +18,10 @@ const AnySpendFingerprintWrapper_1 = require("../AnySpendFingerprintWrapper");
|
|
|
18
18
|
const HowItWorks_1 = __importDefault(require("./HowItWorks"));
|
|
19
19
|
const PaymentMethodIcons_1 = __importDefault(require("./PaymentMethodIcons"));
|
|
20
20
|
const stripePromise = (0, stripe_js_1.loadStripe)(constants_1.STRIPE_CONFIG.publishableKey);
|
|
21
|
-
function PaymentStripeWeb2({
|
|
21
|
+
function PaymentStripeWeb2({ order, onPaymentSuccess }) {
|
|
22
22
|
const { theme } = (0, react_2.useB3)();
|
|
23
23
|
const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
|
|
24
|
-
const { clientSecret, isLoadingStripeClientSecret, stripeClientSecretError } = (0, react_1.useStripeClientSecret)(
|
|
24
|
+
const { clientSecret, isLoadingStripeClientSecret, stripeClientSecretError } = (0, react_1.useStripeClientSecret)(order.stripePaymentIntentId);
|
|
25
25
|
if (isLoadingStripeClientSecret) {
|
|
26
26
|
return (0, jsx_runtime_1.jsx)(StripeLoadingState, {});
|
|
27
27
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { components } from "../../../../anyspend/types/api";
|
|
2
2
|
interface PaymentVendorUIProps {
|
|
3
|
-
isMainnet: boolean;
|
|
4
3
|
order: components["schemas"]["Order"];
|
|
5
4
|
dstTokenSymbol: string;
|
|
6
5
|
}
|
|
7
|
-
export default function PaymentVendorUI({
|
|
6
|
+
export default function PaymentVendorUI({ order, dstTokenSymbol }: PaymentVendorUIProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
7
|
export {};
|
|
@@ -7,7 +7,7 @@ exports.default = PaymentVendorUI;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const PaymentOneClick_1 = __importDefault(require("./PaymentOneClick"));
|
|
9
9
|
const PaymentStripeWeb2_1 = __importDefault(require("./PaymentStripeWeb2"));
|
|
10
|
-
function PaymentVendorUI({
|
|
10
|
+
function PaymentVendorUI({ order, dstTokenSymbol }) {
|
|
11
11
|
const vendor = order.onrampMetadata?.vendor;
|
|
12
12
|
// Handle one-click payment flows (Coinbase, Stripe redirect)
|
|
13
13
|
if (order.oneClickBuyUrl) {
|
|
@@ -15,7 +15,7 @@ function PaymentVendorUI({ isMainnet, order, dstTokenSymbol }) {
|
|
|
15
15
|
}
|
|
16
16
|
// Handle Stripe Web2 payment flow
|
|
17
17
|
if (vendor === "stripe-web2") {
|
|
18
|
-
return (0, jsx_runtime_1.jsx)(PaymentStripeWeb2_1.default, {
|
|
18
|
+
return (0, jsx_runtime_1.jsx)(PaymentStripeWeb2_1.default, { order: order });
|
|
19
19
|
}
|
|
20
20
|
// Return null for unsupported vendors
|
|
21
21
|
return null;
|
|
@@ -32,5 +32,5 @@ function RecipientSelection({ initialValue = "", placeholder = "Enter recipient
|
|
|
32
32
|
};
|
|
33
33
|
const isAddressValid = !validateAddress || !recipientAddress || validateAddress(recipientAddress);
|
|
34
34
|
const canConfirm = recipientAddress && isAddressValid;
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "mx-auto w-[460px] max-w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex justify-around", children: [(0, jsx_runtime_1.jsx)("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, { className: "h-6 w-6" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex-1 text-center", children: [(0, jsx_runtime_1.jsx)("h2", { className: "text-as-primary text-lg font-semibold", children: title }), (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/60 text-sm", children: description })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "bg-as-surface-secondary border-as-border-secondary flex h-12 w-full overflow-hidden rounded-xl border", children: [(0, jsx_runtime_1.jsx)("input", { type: "text", placeholder: placeholder, value: recipientAddress, onChange: e => setRecipientAddress(e.target.value), onKeyDown: handleKeyDown, className: "text-as-primary placeholder:text-as-primary/50 flex-1 bg-transparent px-4 text-base focus:outline-none", autoFocus: autoFocus }), (0, jsx_runtime_1.jsx)("div", { className: "border-as-border-secondary border-l", children: (0, jsx_runtime_1.jsx)("button", { onClick: handlePaste, className: "text-as-primary/70 hover:text-as-primary hover:bg-as-surface-primary h-full px-4 font-semibold transition-colors", children: "Paste" }) })] }), recipientAddress && !isAddressValid && ((0, jsx_runtime_1.jsx)("div", { className: "text-as-red text-sm", children: "Please enter a valid address" })), (0, jsx_runtime_1.jsx)("button", { onClick: handleConfirm, disabled: !canConfirm, className: "bg-as-brand hover:bg-as-brand/90 disabled:bg-as-on-surface-2 disabled:text-as-secondary h-12 w-full rounded-xl font-medium text-white transition-colors disabled:cursor-not-allowed", children: confirmText })] })] }) }));
|
|
35
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "recipient-selection mx-auto w-[460px] max-w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex justify-around", children: [(0, jsx_runtime_1.jsx)("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, { className: "h-6 w-6" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex-1 text-center", children: [(0, jsx_runtime_1.jsx)("h2", { className: "text-as-primary text-lg font-semibold", children: title }), (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/60 text-sm", children: description })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "bg-as-surface-secondary border-as-border-secondary flex h-12 w-full overflow-hidden rounded-xl border", children: [(0, jsx_runtime_1.jsx)("input", { type: "text", placeholder: placeholder, value: recipientAddress, onChange: e => setRecipientAddress(e.target.value), onKeyDown: handleKeyDown, className: "text-as-primary placeholder:text-as-primary/50 flex-1 bg-transparent px-4 text-base focus:outline-none", autoFocus: autoFocus }), (0, jsx_runtime_1.jsx)("div", { className: "border-as-border-secondary border-l", children: (0, jsx_runtime_1.jsx)("button", { onClick: handlePaste, className: "text-as-primary/70 hover:text-as-primary hover:bg-as-surface-primary h-full px-4 font-semibold transition-colors", children: "Paste" }) })] }), recipientAddress && !isAddressValid && ((0, jsx_runtime_1.jsx)("div", { className: "text-as-red text-sm", children: "Please enter a valid address" })), (0, jsx_runtime_1.jsx)("button", { onClick: handleConfirm, disabled: !canConfirm, className: "bg-as-brand hover:bg-as-brand/90 disabled:bg-as-on-surface-2 disabled:text-as-secondary h-12 w-full rounded-xl font-medium text-white transition-colors disabled:cursor-not-allowed", children: confirmText })] })] }) }));
|
|
36
36
|
}
|
|
@@ -93,7 +93,7 @@ function StripePaymentForm({ order, onPaymentSuccess, }) {
|
|
|
93
93
|
function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId, partnerId, }) {
|
|
94
94
|
const [createdOrder, setCreatedOrder] = (0, react_3.useState)(null);
|
|
95
95
|
const orderCreationAttempted = (0, react_3.useRef)(false);
|
|
96
|
-
const { geoData, stripeWeb2Support, isLoading: isLoadingGeoOnramp } = (0, react_1.useGeoOnrampOptions)(
|
|
96
|
+
const { geoData, stripeWeb2Support, isLoading: isLoadingGeoOnramp } = (0, react_1.useGeoOnrampOptions)(srcAmountOnRamp);
|
|
97
97
|
const { createOrder, isCreatingOrder } = (0, react_1.useAnyspendCreateOnrampOrder)({
|
|
98
98
|
onSuccess: data => {
|
|
99
99
|
setCreatedOrder(data.data);
|
|
@@ -103,7 +103,7 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
|
|
|
103
103
|
sonner_1.toast.error("Failed to create order: " + error.message);
|
|
104
104
|
},
|
|
105
105
|
});
|
|
106
|
-
const { clientSecret, isLoadingStripeClientSecret } = (0, react_1.useStripeClientSecret)(
|
|
106
|
+
const { clientSecret, isLoadingStripeClientSecret } = (0, react_1.useStripeClientSecret)(createdOrder?.stripePaymentIntentId || "");
|
|
107
107
|
// Create order when component mounts and all required data is available
|
|
108
108
|
(0, react_3.useEffect)(() => {
|
|
109
109
|
const createOrderIfPossible = async () => {
|
|
@@ -124,7 +124,6 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
|
|
|
124
124
|
};
|
|
125
125
|
};
|
|
126
126
|
createOrder({
|
|
127
|
-
isMainnet: true,
|
|
128
127
|
recipientAddress,
|
|
129
128
|
orderType: "swap",
|
|
130
129
|
dstChain: getDstToken().chainId,
|
|
@@ -22,7 +22,7 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
22
22
|
};
|
|
23
23
|
const { mutate: createOrder, isPending } = (0, react_query_1.useMutation)({
|
|
24
24
|
mutationFn: async (params) => {
|
|
25
|
-
const {
|
|
25
|
+
const { recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, partnerId, } = params;
|
|
26
26
|
try {
|
|
27
27
|
// Validate required onramp fields
|
|
28
28
|
if (!onramp.vendor || !onramp.country) {
|
|
@@ -33,7 +33,6 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
33
33
|
// Create order with USDC on Base as source
|
|
34
34
|
const srcAmountOnRampInWei = (0, viem_1.parseUnits)(srcFiatAmount, constants_1.USDC_BASE.decimals);
|
|
35
35
|
return await anyspend_1.anyspendService.createOrder({
|
|
36
|
-
isMainnet,
|
|
37
36
|
recipientAddress: (0, utils_1.normalizeAddress)(recipientAddress),
|
|
38
37
|
type: orderType,
|
|
39
38
|
srcChain,
|
|
@@ -20,10 +20,9 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
20
20
|
};
|
|
21
21
|
const { mutate: createOrder, isPending } = (0, react_query_1.useMutation)({
|
|
22
22
|
mutationFn: async (params) => {
|
|
23
|
-
const {
|
|
23
|
+
const { recipientAddress, orderType, srcChain, dstChain, srcToken, dstToken, srcAmount, creatorAddress } = params;
|
|
24
24
|
try {
|
|
25
25
|
return await anyspend_1.anyspendService.createOrder({
|
|
26
|
-
isMainnet,
|
|
27
26
|
recipientAddress: (0, utils_1.normalizeAddress)(recipientAddress),
|
|
28
27
|
type: orderType,
|
|
29
28
|
srcChain,
|
|
@@ -24,7 +24,7 @@ function customDeepEqual(oldData, newData) {
|
|
|
24
24
|
return oldData === newData;
|
|
25
25
|
}
|
|
26
26
|
// Hook to fetch and auto-refresh order status and transaction details
|
|
27
|
-
function useAnyspendOrderAndTransactions(
|
|
27
|
+
function useAnyspendOrderAndTransactions(orderId) {
|
|
28
28
|
const selectFn = (0, react_1.useCallback)((data) => {
|
|
29
29
|
if (!data)
|
|
30
30
|
return undefined;
|
|
@@ -32,7 +32,7 @@ function useAnyspendOrderAndTransactions(isMainnet, orderId) {
|
|
|
32
32
|
}, []);
|
|
33
33
|
const { data, isLoading, refetch, error } = (0, react_query_1.useQuery)({
|
|
34
34
|
queryKey: ["getAnyspendOrderAndTransactions", orderId],
|
|
35
|
-
queryFn: () => anyspend_1.anyspendService.getOrderAndTransactions(
|
|
35
|
+
queryFn: () => anyspend_1.anyspendService.getOrderAndTransactions(orderId),
|
|
36
36
|
enabled: !!orderId,
|
|
37
37
|
refetchInterval: 3000,
|
|
38
38
|
staleTime: 1000,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function useAnyspendOrderHistory(
|
|
1
|
+
export declare function useAnyspendOrderHistory(creatorAddress: string | undefined, limit?: number, offset?: number): {
|
|
2
2
|
orderHistory: (({
|
|
3
3
|
id: string;
|
|
4
4
|
recipientAddress: string;
|
|
@@ -4,11 +4,11 @@ exports.useAnyspendOrderHistory = useAnyspendOrderHistory;
|
|
|
4
4
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
5
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
function useAnyspendOrderHistory(
|
|
7
|
+
function useAnyspendOrderHistory(creatorAddress, limit = 100, offset = 0) {
|
|
8
8
|
const { data: rawData = [], isLoading, refetch, error, } = (0, react_query_1.useQuery)({
|
|
9
9
|
queryKey: ["getOrderHistory", creatorAddress, limit, offset],
|
|
10
10
|
queryFn: async () => {
|
|
11
|
-
const response = await anyspend_1.anyspendService.getOrderHistory(
|
|
11
|
+
const response = await anyspend_1.anyspendService.getOrderHistory(creatorAddress, limit, offset);
|
|
12
12
|
return response.data;
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -2,7 +2,6 @@ import { GetQuoteRequest, GetQuoteResponse } from "../../types/api_req_res";
|
|
|
2
2
|
/**
|
|
3
3
|
* React hook to fetch the price or rate for a relay swap using Anyspend.
|
|
4
4
|
*
|
|
5
|
-
* @param isMainnet - Whether to use mainnet or testnet endpoints.
|
|
6
5
|
* @param req - The request object containing source/destination chain, token addresses, and amount/price.
|
|
7
6
|
* @remarks The query is enabled only if all required fields in `req` are present and the amount/price is non-zero.
|
|
8
7
|
*/
|
|
@@ -12,4 +11,4 @@ export type UseAnyspendQuoteResult = {
|
|
|
12
11
|
getAnyspendQuoteError: Error | null;
|
|
13
12
|
refetchAnyspendQuote: () => void;
|
|
14
13
|
};
|
|
15
|
-
export declare function useAnyspendQuote(
|
|
14
|
+
export declare function useAnyspendQuote(req: GetQuoteRequest): UseAnyspendQuoteResult;
|
|
@@ -4,11 +4,11 @@ exports.useAnyspendQuote = useAnyspendQuote;
|
|
|
4
4
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
5
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
function useAnyspendQuote(
|
|
7
|
+
function useAnyspendQuote(req) {
|
|
8
8
|
const { data, isLoading, refetch, error } = (0, react_query_1.useQuery)({
|
|
9
|
-
queryKey: ["useAnyspendQuote",
|
|
9
|
+
queryKey: ["useAnyspendQuote", JSON.stringify(req)],
|
|
10
10
|
queryFn: () => {
|
|
11
|
-
return anyspend_1.anyspendService.getQuote(
|
|
11
|
+
return anyspend_1.anyspendService.getQuote(req);
|
|
12
12
|
},
|
|
13
13
|
enabled: Boolean(req.srcChain &&
|
|
14
14
|
req.dstChain &&
|
|
@@ -4,10 +4,10 @@ exports.useAnyspendTokenList = useAnyspendTokenList;
|
|
|
4
4
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
5
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
function useAnyspendTokenList(
|
|
7
|
+
function useAnyspendTokenList(chainId, query) {
|
|
8
8
|
const { data = [], isLoading, refetch, } = (0, react_query_1.useQuery)({
|
|
9
9
|
queryKey: ["getAnyspendTokenList", chainId, query],
|
|
10
|
-
queryFn: () => anyspend_1.anyspendService.getTokenList(
|
|
10
|
+
queryFn: () => anyspend_1.anyspendService.getTokenList(chainId, query),
|
|
11
11
|
enabled: true,
|
|
12
12
|
});
|
|
13
13
|
return (0, react_1.useMemo)(() => ({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VisitorData } from "../../../anyspend/types/fingerprint";
|
|
2
|
-
export declare function useCoinbaseOnrampOptions(
|
|
2
|
+
export declare function useCoinbaseOnrampOptions(country?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean): {
|
|
3
3
|
coinbaseOnrampOptions: {
|
|
4
4
|
paymentCurrencies: {
|
|
5
5
|
id?: string;
|
|
@@ -4,10 +4,10 @@ exports.useCoinbaseOnrampOptions = useCoinbaseOnrampOptions;
|
|
|
4
4
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
5
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
function useCoinbaseOnrampOptions(
|
|
7
|
+
function useCoinbaseOnrampOptions(country, visitorData, isLoadingVisitorData) {
|
|
8
8
|
const { data, isLoading, error, refetch } = (0, react_query_1.useQuery)({
|
|
9
|
-
queryKey: ["getCoinbaseOnrampOptions",
|
|
10
|
-
queryFn: () => anyspend_1.anyspendService.getCoinbaseOnrampOptions(
|
|
9
|
+
queryKey: ["getCoinbaseOnrampOptions", country, visitorData],
|
|
10
|
+
queryFn: () => anyspend_1.anyspendService.getCoinbaseOnrampOptions(country, visitorData),
|
|
11
11
|
enabled: Boolean(country) && !isLoadingVisitorData,
|
|
12
12
|
});
|
|
13
13
|
return (0, react_1.useMemo)(() => ({
|
|
@@ -6,7 +6,7 @@ const react_1 = require("react");
|
|
|
6
6
|
const useCoinbaseOnrampOptions_1 = require("./useCoinbaseOnrampOptions");
|
|
7
7
|
const useGetGeo_1 = require("./useGetGeo");
|
|
8
8
|
const useStripeSupport_1 = require("./useStripeSupport");
|
|
9
|
-
function useGeoOnrampOptions(
|
|
9
|
+
function useGeoOnrampOptions(srcFiatAmount) {
|
|
10
10
|
// Get fingerprint data
|
|
11
11
|
const { data: fpData, isLoading: isLoadingVisitorData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
|
|
12
12
|
const visitorData = fpData && {
|
|
@@ -15,8 +15,8 @@ function useGeoOnrampOptions(isMainnet, srcFiatAmount) {
|
|
|
15
15
|
};
|
|
16
16
|
// Use existing hooks
|
|
17
17
|
const { geoData, loading: isLoadingGeo, error: geoError } = (0, useGetGeo_1.useGetGeo)();
|
|
18
|
-
const { coinbaseOnrampOptions, isLoadingCoinbaseOnrampOptions, coinbaseOnrampOptionsError } = (0, useCoinbaseOnrampOptions_1.useCoinbaseOnrampOptions)(
|
|
19
|
-
const { stripeWeb2Support, isLoadingStripeSupport, stripeSupportError } = (0, useStripeSupport_1.useStripeSupport)(
|
|
18
|
+
const { coinbaseOnrampOptions, isLoadingCoinbaseOnrampOptions, coinbaseOnrampOptionsError } = (0, useCoinbaseOnrampOptions_1.useCoinbaseOnrampOptions)(geoData?.country, visitorData);
|
|
19
|
+
const { stripeWeb2Support, isLoadingStripeSupport, stripeSupportError } = (0, useStripeSupport_1.useStripeSupport)(srcFiatAmount, visitorData);
|
|
20
20
|
// Calculate available payment methods based on the amount
|
|
21
21
|
const coinbaseAvailablePaymentMethods = (0, react_1.useMemo)(() => {
|
|
22
22
|
if (!coinbaseOnrampOptions?.paymentCurrencies?.[0]?.limits || !srcFiatAmount)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function useStripeClientSecret(
|
|
1
|
+
export declare function useStripeClientSecret(paymentIntentId: string): {
|
|
2
2
|
clientSecret: string | null;
|
|
3
3
|
isLoadingStripeClientSecret: boolean;
|
|
4
4
|
stripeClientSecretError: Error | null;
|
|
@@ -4,10 +4,10 @@ exports.useStripeClientSecret = useStripeClientSecret;
|
|
|
4
4
|
const react_query_1 = require("@tanstack/react-query");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
7
|
-
function useStripeClientSecret(
|
|
7
|
+
function useStripeClientSecret(paymentIntentId) {
|
|
8
8
|
const { data, isLoading, error, refetch } = (0, react_query_1.useQuery)({
|
|
9
|
-
queryKey: ["stripeClientSecret",
|
|
10
|
-
queryFn: () => anyspend_1.anyspendService.getStripeClientSecret(
|
|
9
|
+
queryKey: ["stripeClientSecret", paymentIntentId],
|
|
10
|
+
queryFn: () => anyspend_1.anyspendService.getStripeClientSecret(paymentIntentId),
|
|
11
11
|
});
|
|
12
12
|
return (0, react_1.useMemo)(() => ({
|
|
13
13
|
clientSecret: data || null,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VisitorData } from "../../../anyspend/types/fingerprint";
|
|
2
|
-
export declare function useStripeSupport(
|
|
2
|
+
export declare function useStripeSupport(usdAmount?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean): {
|
|
3
3
|
stripeWeb2Support: {
|
|
4
4
|
isSupport: false;
|
|
5
5
|
} | {
|
|
@@ -4,10 +4,10 @@ exports.useStripeSupport = useStripeSupport;
|
|
|
4
4
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
5
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
function useStripeSupport(
|
|
7
|
+
function useStripeSupport(usdAmount, visitorData, isLoadingVisitorData) {
|
|
8
8
|
const { data, isLoading, error, refetch } = (0, react_query_1.useQuery)({
|
|
9
|
-
queryKey: ["useStripeSupport",
|
|
10
|
-
queryFn: () => anyspend_1.anyspendService.checkStripeSupport(
|
|
9
|
+
queryKey: ["useStripeSupport", usdAmount, visitorData?.requestId, visitorData?.visitorId],
|
|
10
|
+
queryFn: () => anyspend_1.anyspendService.checkStripeSupport(usdAmount, visitorData),
|
|
11
11
|
enabled: !isLoadingVisitorData,
|
|
12
12
|
});
|
|
13
13
|
return (0, react_1.useMemo)(() => ({
|
|
@@ -3,11 +3,10 @@ import { components } from "../types/api";
|
|
|
3
3
|
import { GetCoinbaseOnrampOptionsResponse, GetOrderAndTxsResponse, GetOrderHistoryResponse, GetQuoteRequest, GetQuoteResponse } from "../types/api_req_res";
|
|
4
4
|
import { VisitorData } from "../types/fingerprint";
|
|
5
5
|
export declare const anyspendService: {
|
|
6
|
-
getTokenList: (
|
|
7
|
-
getToken: (
|
|
8
|
-
getQuote: (
|
|
9
|
-
createOrder: ({
|
|
10
|
-
isMainnet: boolean;
|
|
6
|
+
getTokenList: (chainId: number, query: string) => Promise<components["schemas"]["Token"][]>;
|
|
7
|
+
getToken: (chainId: number, tokenAddress: string) => Promise<components["schemas"]["Token"]>;
|
|
8
|
+
getQuote: (req: GetQuoteRequest) => Promise<GetQuoteResponse>;
|
|
9
|
+
createOrder: ({ recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, visitorData, }: {
|
|
11
10
|
recipientAddress: string;
|
|
12
11
|
type: string;
|
|
13
12
|
srcChain: number;
|
|
@@ -27,12 +26,12 @@ export declare const anyspendService: {
|
|
|
27
26
|
data: components["schemas"]["Order"];
|
|
28
27
|
statusCode: number;
|
|
29
28
|
}>;
|
|
30
|
-
getOrderAndTransactions: (
|
|
31
|
-
getOrderHistory: (
|
|
32
|
-
getCoinbaseOnrampOptions: (
|
|
33
|
-
checkStripeSupport: (
|
|
29
|
+
getOrderAndTransactions: (orderId: string | undefined) => Promise<GetOrderAndTxsResponse>;
|
|
30
|
+
getOrderHistory: (creatorAddress: string | undefined, limit?: number, offset?: number) => Promise<GetOrderHistoryResponse>;
|
|
31
|
+
getCoinbaseOnrampOptions: (country: string, visitorData?: VisitorData) => Promise<GetCoinbaseOnrampOptionsResponse>;
|
|
32
|
+
checkStripeSupport: (usdAmount?: string, visitorData?: VisitorData) => Promise<{
|
|
34
33
|
stripeOnramp: boolean;
|
|
35
34
|
stripeWeb2: components["schemas"]["StripeWeb2Support"];
|
|
36
35
|
}>;
|
|
37
|
-
getStripeClientSecret: (
|
|
36
|
+
getStripeClientSecret: (paymentIntentId: string) => Promise<string | null>;
|
|
38
37
|
};
|
|
@@ -9,25 +9,25 @@ const utils_1 = require("../../anyspend/utils");
|
|
|
9
9
|
const invariant_1 = __importDefault(require("invariant"));
|
|
10
10
|
// Service functions
|
|
11
11
|
exports.anyspendService = {
|
|
12
|
-
getTokenList: async (
|
|
13
|
-
const response = await fetch(`${
|
|
12
|
+
getTokenList: async (chainId, query) => {
|
|
13
|
+
const response = await fetch(`${constants_1.ANYSPEND_MAINNET_BASE_URL}/chains/${chainId}/tokens?limit=100&term=${query}`);
|
|
14
14
|
const body = await response.json();
|
|
15
15
|
(0, invariant_1.default)(response.status === 200, `Failed to fetch token list for chain ${chainId}`);
|
|
16
16
|
return body.data;
|
|
17
17
|
},
|
|
18
|
-
getToken: async (
|
|
18
|
+
getToken: async (chainId, tokenAddress) => {
|
|
19
19
|
if ((0, utils_1.isNativeToken)(tokenAddress)) {
|
|
20
20
|
return (0, utils_1.getNativeToken)(chainId);
|
|
21
21
|
}
|
|
22
|
-
const tokenList = await exports.anyspendService.getTokenList(
|
|
22
|
+
const tokenList = await exports.anyspendService.getTokenList(chainId, tokenAddress);
|
|
23
23
|
const token = tokenList.find((t) => t.address.toLowerCase() === tokenAddress.toLowerCase());
|
|
24
24
|
if (!token) {
|
|
25
25
|
throw new Error(`Token ${tokenAddress} not found on chain ${chainId}`);
|
|
26
26
|
}
|
|
27
27
|
return token;
|
|
28
28
|
},
|
|
29
|
-
getQuote: async (
|
|
30
|
-
const url = `${
|
|
29
|
+
getQuote: async (req) => {
|
|
30
|
+
const url = `${constants_1.ANYSPEND_MAINNET_BASE_URL}/orders/quote`;
|
|
31
31
|
const response = await fetch(url, {
|
|
32
32
|
method: "POST",
|
|
33
33
|
headers: {
|
|
@@ -41,8 +41,8 @@ exports.anyspendService = {
|
|
|
41
41
|
return data;
|
|
42
42
|
},
|
|
43
43
|
// Order related
|
|
44
|
-
createOrder: async ({
|
|
45
|
-
const response = await fetch(`${
|
|
44
|
+
createOrder: async ({ recipientAddress, type, srcChain, dstChain, srcTokenAddress, dstTokenAddress, srcAmount, payload, onramp, metadata, creatorAddress, partnerId, visitorData, }) => {
|
|
45
|
+
const response = await fetch(`${constants_1.ANYSPEND_MAINNET_BASE_URL}/orders`, {
|
|
46
46
|
method: "POST",
|
|
47
47
|
headers: {
|
|
48
48
|
"Content-Type": "application/json",
|
|
@@ -68,12 +68,12 @@ exports.anyspendService = {
|
|
|
68
68
|
(0, invariant_1.default)(response.status === 200, data.message);
|
|
69
69
|
return data;
|
|
70
70
|
},
|
|
71
|
-
getOrderAndTransactions: async (
|
|
72
|
-
const response = await fetch(`${
|
|
71
|
+
getOrderAndTransactions: async (orderId) => {
|
|
72
|
+
const response = await fetch(`${constants_1.ANYSPEND_MAINNET_BASE_URL}/orders/${orderId}`);
|
|
73
73
|
const data = await response.json();
|
|
74
74
|
return data;
|
|
75
75
|
},
|
|
76
|
-
getOrderHistory: async (
|
|
76
|
+
getOrderHistory: async (creatorAddress, limit = 100, offset = 0) => {
|
|
77
77
|
const params = new URLSearchParams({
|
|
78
78
|
limit: limit.toString(),
|
|
79
79
|
offset: offset.toString(),
|
|
@@ -81,26 +81,26 @@ exports.anyspendService = {
|
|
|
81
81
|
if (creatorAddress) {
|
|
82
82
|
params.append("creatorAddress", creatorAddress);
|
|
83
83
|
}
|
|
84
|
-
const response = await fetch(`${
|
|
84
|
+
const response = await fetch(`${constants_1.ANYSPEND_MAINNET_BASE_URL}/orders?${params.toString()}`);
|
|
85
85
|
const data = await response.json();
|
|
86
86
|
return data;
|
|
87
87
|
},
|
|
88
|
-
getCoinbaseOnrampOptions: async (
|
|
88
|
+
getCoinbaseOnrampOptions: async (country, visitorData) => {
|
|
89
89
|
const params = new URLSearchParams({
|
|
90
90
|
country,
|
|
91
91
|
// include fingerprintId and requestId in the query params
|
|
92
92
|
...(visitorData?.requestId && { requestId: visitorData.requestId }),
|
|
93
93
|
...(visitorData?.visitorId && { fingerprintId: visitorData.visitorId }),
|
|
94
94
|
});
|
|
95
|
-
const response = await fetch(`${
|
|
95
|
+
const response = await fetch(`${constants_1.ANYSPEND_MAINNET_BASE_URL}/onramp/coinbase/options?${params.toString()}`);
|
|
96
96
|
const data = await response.json();
|
|
97
97
|
return data;
|
|
98
98
|
},
|
|
99
|
-
checkStripeSupport: async (
|
|
99
|
+
checkStripeSupport: async (usdAmount, visitorData) => {
|
|
100
100
|
const params = new URLSearchParams({
|
|
101
101
|
usdAmount: usdAmount || "",
|
|
102
102
|
});
|
|
103
|
-
const response = await fetch(`${
|
|
103
|
+
const response = await fetch(`${constants_1.ANYSPEND_MAINNET_BASE_URL}/onramp/stripe/supported?${params.toString()}`, {
|
|
104
104
|
headers: {
|
|
105
105
|
...(visitorData?.requestId && { "X-Fingerprint-Request-Id": visitorData.requestId }),
|
|
106
106
|
...(visitorData?.visitorId && { "X-Fingerprint-Visitor-Id": visitorData.visitorId }),
|
|
@@ -110,8 +110,8 @@ exports.anyspendService = {
|
|
|
110
110
|
(0, invariant_1.default)(response.status === 200, "Failed to check Stripe support");
|
|
111
111
|
return data.data;
|
|
112
112
|
},
|
|
113
|
-
getStripeClientSecret: async (
|
|
114
|
-
const response = await fetch(`${
|
|
113
|
+
getStripeClientSecret: async (paymentIntentId) => {
|
|
114
|
+
const response = await fetch(`${constants_1.ANYSPEND_MAINNET_BASE_URL}/stripe/clientSecret?paymentIntentId=${paymentIntentId}`);
|
|
115
115
|
const data = await response.json();
|
|
116
116
|
(0, invariant_1.default)(response.status === 200, "Failed to get Stripe client secret");
|
|
117
117
|
return data.data;
|