@b3dotfun/sdk 0.1.68 → 0.1.69-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/platform/client.d.ts +35 -0
- package/dist/cjs/anyspend/platform/client.js +158 -0
- package/dist/cjs/anyspend/platform/errors.d.ts +38 -0
- package/dist/cjs/anyspend/platform/errors.js +77 -0
- package/dist/cjs/anyspend/platform/index.d.ts +87 -0
- package/dist/cjs/anyspend/platform/index.js +85 -0
- package/dist/cjs/anyspend/platform/resources/analytics.d.ts +7 -0
- package/dist/cjs/anyspend/platform/resources/analytics.js +12 -0
- package/dist/cjs/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
- package/dist/cjs/anyspend/platform/resources/checkout-sessions.js +27 -0
- package/dist/cjs/anyspend/platform/resources/customers.d.ts +19 -0
- package/dist/cjs/anyspend/platform/resources/customers.js +34 -0
- package/dist/cjs/anyspend/platform/resources/discount-codes.d.ts +29 -0
- package/dist/cjs/anyspend/platform/resources/discount-codes.js +31 -0
- package/dist/cjs/anyspend/platform/resources/events.d.ts +14 -0
- package/dist/cjs/anyspend/platform/resources/events.js +16 -0
- package/dist/cjs/anyspend/platform/resources/notifications.d.ts +18 -0
- package/dist/cjs/anyspend/platform/resources/notifications.js +27 -0
- package/dist/cjs/anyspend/platform/resources/organization.d.ts +17 -0
- package/dist/cjs/anyspend/platform/resources/organization.js +15 -0
- package/dist/cjs/anyspend/platform/resources/payment-links.d.ts +21 -0
- package/dist/cjs/anyspend/platform/resources/payment-links.js +49 -0
- package/dist/cjs/anyspend/platform/resources/products.d.ts +27 -0
- package/dist/cjs/anyspend/platform/resources/products.js +31 -0
- package/dist/cjs/anyspend/platform/resources/transactions.d.ts +11 -0
- package/dist/cjs/anyspend/platform/resources/transactions.js +25 -0
- package/dist/cjs/anyspend/platform/resources/webhooks.d.ts +14 -0
- package/dist/cjs/anyspend/platform/resources/webhooks.js +33 -0
- package/dist/cjs/anyspend/platform/resources/widgets.d.ts +38 -0
- package/dist/cjs/anyspend/platform/resources/widgets.js +31 -0
- package/dist/cjs/anyspend/platform/types.d.ts +478 -0
- package/dist/cjs/anyspend/platform/types.js +5 -0
- package/dist/cjs/anyspend/platform/utils/idempotency.d.ts +4 -0
- package/dist/cjs/anyspend/platform/utils/idempotency.js +17 -0
- package/dist/cjs/anyspend/platform/utils/pagination.d.ts +12 -0
- package/dist/cjs/anyspend/platform/utils/pagination.js +22 -0
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +127 -16
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +4 -4
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +55 -8
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +48 -16
- package/dist/cjs/anyspend/react/components/checkout/KycGate.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/checkout/KycGate.js +203 -0
- package/dist/cjs/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
- package/dist/cjs/anyspend/react/components/checkout/VariablePricingInput.js +145 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +1 -1
- package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/cjs/anyspend/react/components/index.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/index.js +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -0
- package/dist/cjs/anyspend/react/hooks/useKycStatus.d.ts +47 -0
- package/dist/cjs/anyspend/react/hooks/useKycStatus.js +124 -0
- package/dist/cjs/anyspend/services/anyspend.d.ts +4 -1
- package/dist/cjs/anyspend/services/anyspend.js +3 -1
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/BottomNavigation.js +3 -3
- package/dist/cjs/global-account/react/components/ManageAccount/HomeActions.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -5
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +21 -24
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
- package/dist/cjs/global-account/react/hooks/useAuth.js +1 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +3 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +94 -24
- package/dist/cjs/global-account/react/hooks/useGetAllTWSigners.js +2 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/cjs/global-account/react/stores/useModalStore.js +2 -0
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +18 -0
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +17 -0
- package/dist/esm/anyspend/platform/client.d.ts +35 -0
- package/dist/esm/anyspend/platform/client.js +153 -0
- package/dist/esm/anyspend/platform/errors.d.ts +38 -0
- package/dist/esm/anyspend/platform/errors.js +67 -0
- package/dist/esm/anyspend/platform/index.d.ts +87 -0
- package/dist/esm/anyspend/platform/index.js +75 -0
- package/dist/esm/anyspend/platform/resources/analytics.d.ts +7 -0
- package/dist/esm/anyspend/platform/resources/analytics.js +8 -0
- package/dist/esm/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
- package/dist/esm/anyspend/platform/resources/checkout-sessions.js +23 -0
- package/dist/esm/anyspend/platform/resources/customers.d.ts +19 -0
- package/dist/esm/anyspend/platform/resources/customers.js +30 -0
- package/dist/esm/anyspend/platform/resources/discount-codes.d.ts +29 -0
- package/dist/esm/anyspend/platform/resources/discount-codes.js +27 -0
- package/dist/esm/anyspend/platform/resources/events.d.ts +14 -0
- package/dist/esm/anyspend/platform/resources/events.js +12 -0
- package/dist/esm/anyspend/platform/resources/notifications.d.ts +18 -0
- package/dist/esm/anyspend/platform/resources/notifications.js +23 -0
- package/dist/esm/anyspend/platform/resources/organization.d.ts +17 -0
- package/dist/esm/anyspend/platform/resources/organization.js +11 -0
- package/dist/esm/anyspend/platform/resources/payment-links.d.ts +21 -0
- package/dist/esm/anyspend/platform/resources/payment-links.js +45 -0
- package/dist/esm/anyspend/platform/resources/products.d.ts +27 -0
- package/dist/esm/anyspend/platform/resources/products.js +27 -0
- package/dist/esm/anyspend/platform/resources/transactions.d.ts +11 -0
- package/dist/esm/anyspend/platform/resources/transactions.js +21 -0
- package/dist/esm/anyspend/platform/resources/webhooks.d.ts +14 -0
- package/dist/esm/anyspend/platform/resources/webhooks.js +29 -0
- package/dist/esm/anyspend/platform/resources/widgets.d.ts +38 -0
- package/dist/esm/anyspend/platform/resources/widgets.js +27 -0
- package/dist/esm/anyspend/platform/types.d.ts +478 -0
- package/dist/esm/anyspend/platform/types.js +4 -0
- package/dist/esm/anyspend/platform/utils/idempotency.d.ts +4 -0
- package/dist/esm/anyspend/platform/utils/idempotency.js +14 -0
- package/dist/esm/anyspend/platform/utils/pagination.d.ts +12 -0
- package/dist/esm/anyspend/platform/utils/pagination.js +19 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +5 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +128 -17
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +4 -4
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +55 -8
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +1 -1
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +50 -18
- package/dist/esm/anyspend/react/components/checkout/KycGate.d.ts +11 -0
- package/dist/esm/anyspend/react/components/checkout/KycGate.js +167 -0
- package/dist/esm/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
- package/dist/esm/anyspend/react/components/checkout/VariablePricingInput.js +142 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +1 -1
- package/dist/esm/anyspend/react/components/common/FeeDetailPanel.js +1 -1
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +1 -1
- package/dist/esm/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/esm/anyspend/react/components/index.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -0
- package/dist/esm/anyspend/react/hooks/useKycStatus.d.ts +47 -0
- package/dist/esm/anyspend/react/hooks/useKycStatus.js +117 -0
- package/dist/esm/anyspend/services/anyspend.d.ts +4 -1
- package/dist/esm/anyspend/services/anyspend.js +3 -1
- package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/esm/global-account/react/components/ManageAccount/BottomNavigation.js +3 -3
- package/dist/esm/global-account/react/components/ManageAccount/HomeActions.js +1 -1
- package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -5
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +21 -24
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
- package/dist/esm/global-account/react/hooks/useAuth.js +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +3 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.js +94 -24
- package/dist/esm/global-account/react/hooks/useGetAllTWSigners.js +2 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/esm/global-account/react/stores/useModalStore.js +2 -0
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +18 -0
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +16 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/platform/client.d.ts +35 -0
- package/dist/types/anyspend/platform/errors.d.ts +38 -0
- package/dist/types/anyspend/platform/index.d.ts +87 -0
- package/dist/types/anyspend/platform/resources/analytics.d.ts +7 -0
- package/dist/types/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
- package/dist/types/anyspend/platform/resources/customers.d.ts +19 -0
- package/dist/types/anyspend/platform/resources/discount-codes.d.ts +29 -0
- package/dist/types/anyspend/platform/resources/events.d.ts +14 -0
- package/dist/types/anyspend/platform/resources/notifications.d.ts +18 -0
- package/dist/types/anyspend/platform/resources/organization.d.ts +17 -0
- package/dist/types/anyspend/platform/resources/payment-links.d.ts +21 -0
- package/dist/types/anyspend/platform/resources/products.d.ts +27 -0
- package/dist/types/anyspend/platform/resources/transactions.d.ts +11 -0
- package/dist/types/anyspend/platform/resources/webhooks.d.ts +14 -0
- package/dist/types/anyspend/platform/resources/widgets.d.ts +38 -0
- package/dist/types/anyspend/platform/types.d.ts +478 -0
- package/dist/types/anyspend/platform/utils/idempotency.d.ts +4 -0
- package/dist/types/anyspend/platform/utils/pagination.d.ts +12 -0
- package/dist/types/anyspend/react/components/AnySpend.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/KycGate.d.ts +11 -0
- package/dist/types/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
- package/dist/types/anyspend/react/components/index.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useKycStatus.d.ts +47 -0
- package/dist/types/anyspend/services/anyspend.d.ts +4 -1
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +3 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +18 -0
- package/package.json +7 -1
- package/src/anyspend/docs/checkout-sessions.md +20 -3
- package/src/anyspend/platform/client.ts +198 -0
- package/src/anyspend/platform/errors.ts +92 -0
- package/src/anyspend/platform/index.ts +129 -0
- package/src/anyspend/platform/resources/analytics.ts +10 -0
- package/src/anyspend/platform/resources/checkout-sessions.ts +36 -0
- package/src/anyspend/platform/resources/customers.ts +54 -0
- package/src/anyspend/platform/resources/discount-codes.ts +63 -0
- package/src/anyspend/platform/resources/events.ts +22 -0
- package/src/anyspend/platform/resources/notifications.ts +37 -0
- package/src/anyspend/platform/resources/organization.ts +24 -0
- package/src/anyspend/platform/resources/payment-links.ts +74 -0
- package/src/anyspend/platform/resources/products.ts +59 -0
- package/src/anyspend/platform/resources/transactions.ts +33 -0
- package/src/anyspend/platform/resources/webhooks.ts +47 -0
- package/src/anyspend/platform/resources/widgets.ts +63 -0
- package/src/anyspend/platform/types.ts +532 -0
- package/src/anyspend/platform/utils/idempotency.ts +15 -0
- package/src/anyspend/platform/utils/pagination.ts +32 -0
- package/src/anyspend/react/components/AnySpend.tsx +152 -18
- package/src/anyspend/react/components/AnySpendCustom.tsx +4 -4
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +2 -2
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +81 -18
- package/src/anyspend/react/components/checkout/AnySpendCheckoutTrigger.tsx +4 -0
- package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +8 -0
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +4 -13
- package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +86 -17
- package/src/anyspend/react/components/checkout/KycGate.tsx +387 -0
- package/src/anyspend/react/components/checkout/VariablePricingInput.tsx +247 -0
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +1 -1
- package/src/anyspend/react/components/common/FeeDetailPanel.tsx +1 -1
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +1 -1
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +1 -1
- package/src/anyspend/react/components/common/RecipientSelection.tsx +1 -1
- package/src/anyspend/react/components/index.ts +1 -0
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +17 -0
- package/src/anyspend/react/hooks/useKycStatus.ts +150 -0
- package/src/anyspend/services/anyspend.ts +7 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +0 -2
- package/src/global-account/react/components/ManageAccount/BottomNavigation.tsx +7 -7
- package/src/global-account/react/components/ManageAccount/HomeActions.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +7 -7
- package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -5
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +35 -25
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +1 -1
- package/src/global-account/react/hooks/useAuth.ts +2 -2
- package/src/global-account/react/hooks/useAuthentication.ts +92 -27
- package/src/global-account/react/hooks/useGetAllTWSigners.tsx +2 -1
- package/src/global-account/react/stores/useModalStore.ts +6 -0
- package/src/global-account/react/utils/createWagmiConfig.tsx +18 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
4
|
+
import { formatUnits } from "@b3dotfun/sdk/shared/utils/number";
|
|
5
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
6
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
7
|
+
|
|
8
|
+
export interface VariablePricingConfig {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
minAmount?: string;
|
|
11
|
+
maxAmount?: string;
|
|
12
|
+
suggestedAmount?: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
currency?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface VariablePricingInputProps {
|
|
18
|
+
config: VariablePricingConfig;
|
|
19
|
+
tokenDecimals: number;
|
|
20
|
+
tokenSymbol: string;
|
|
21
|
+
themeColor?: string;
|
|
22
|
+
onChange: (amountWei: string) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function VariablePricingInput({
|
|
26
|
+
config,
|
|
27
|
+
tokenDecimals,
|
|
28
|
+
tokenSymbol,
|
|
29
|
+
themeColor,
|
|
30
|
+
onChange,
|
|
31
|
+
}: VariablePricingInputProps) {
|
|
32
|
+
const currency = config.currency || tokenSymbol;
|
|
33
|
+
|
|
34
|
+
// Convert suggested amount from wei to display
|
|
35
|
+
const initialValue = useMemo(() => {
|
|
36
|
+
if (config.suggestedAmount) {
|
|
37
|
+
try {
|
|
38
|
+
return formatUnits(config.suggestedAmount, tokenDecimals);
|
|
39
|
+
} catch {
|
|
40
|
+
return "";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return "";
|
|
44
|
+
}, [config.suggestedAmount, tokenDecimals]);
|
|
45
|
+
|
|
46
|
+
const [displayValue, setDisplayValue] = useState(initialValue);
|
|
47
|
+
const [error, setError] = useState<string | null>(null);
|
|
48
|
+
|
|
49
|
+
// Min/max in display units
|
|
50
|
+
const minDisplay = useMemo(() => {
|
|
51
|
+
if (!config.minAmount) return null;
|
|
52
|
+
try {
|
|
53
|
+
return parseFloat(formatUnits(config.minAmount, tokenDecimals));
|
|
54
|
+
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}, [config.minAmount, tokenDecimals]);
|
|
58
|
+
|
|
59
|
+
const maxDisplay = useMemo(() => {
|
|
60
|
+
if (!config.maxAmount) return null;
|
|
61
|
+
try {
|
|
62
|
+
return parseFloat(formatUnits(config.maxAmount, tokenDecimals));
|
|
63
|
+
} catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}, [config.maxAmount, tokenDecimals]);
|
|
67
|
+
|
|
68
|
+
// Preset amounts
|
|
69
|
+
const presetAmounts = useMemo(() => {
|
|
70
|
+
const presets: { label: string; value: string }[] = [];
|
|
71
|
+
|
|
72
|
+
if (config.suggestedAmount) {
|
|
73
|
+
try {
|
|
74
|
+
const suggested = parseFloat(formatUnits(config.suggestedAmount, tokenDecimals));
|
|
75
|
+
const candidates = [suggested / 2, suggested, suggested * 2];
|
|
76
|
+
|
|
77
|
+
for (const val of candidates) {
|
|
78
|
+
if (val <= 0) continue;
|
|
79
|
+
if (minDisplay !== null && val < minDisplay) continue;
|
|
80
|
+
if (maxDisplay !== null && val > maxDisplay) continue;
|
|
81
|
+
const display = val % 1 === 0 ? val.toString() : val.toFixed(2);
|
|
82
|
+
presets.push({ label: `${display}`, value: display });
|
|
83
|
+
}
|
|
84
|
+
} catch {
|
|
85
|
+
// skip presets
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return presets;
|
|
89
|
+
}, [config.suggestedAmount, tokenDecimals, minDisplay, maxDisplay]);
|
|
90
|
+
|
|
91
|
+
const validate = useCallback(
|
|
92
|
+
(value: string): string | null => {
|
|
93
|
+
const parsed = parseFloat(value);
|
|
94
|
+
if (!value || isNaN(parsed)) return "Please enter a valid number";
|
|
95
|
+
if (parsed <= 0) return "Please enter an amount";
|
|
96
|
+
if (minDisplay !== null && parsed < minDisplay) {
|
|
97
|
+
const display = minDisplay % 1 === 0 ? minDisplay.toString() : minDisplay.toFixed(2);
|
|
98
|
+
return `Minimum amount is ${display} ${currency}`;
|
|
99
|
+
}
|
|
100
|
+
if (maxDisplay !== null && parsed > maxDisplay) {
|
|
101
|
+
const display = maxDisplay % 1 === 0 ? maxDisplay.toString() : maxDisplay.toFixed(2);
|
|
102
|
+
return `Maximum amount is ${display} ${currency}`;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
},
|
|
106
|
+
[minDisplay, maxDisplay, currency],
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const convertToWei = useCallback(
|
|
110
|
+
(value: string): string => {
|
|
111
|
+
try {
|
|
112
|
+
const [whole, frac = ""] = value.split(".");
|
|
113
|
+
const paddedFrac = frac.padEnd(tokenDecimals, "0").slice(0, tokenDecimals);
|
|
114
|
+
const factor = BigInt(10) ** BigInt(tokenDecimals);
|
|
115
|
+
return (BigInt(whole || "0") * factor + BigInt(paddedFrac)).toString();
|
|
116
|
+
} catch {
|
|
117
|
+
return "0";
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
[tokenDecimals],
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const handleChange = useCallback(
|
|
124
|
+
(value: string) => {
|
|
125
|
+
setDisplayValue(value);
|
|
126
|
+
const validationError = validate(value);
|
|
127
|
+
setError(validationError);
|
|
128
|
+
|
|
129
|
+
if (!validationError && value && parseFloat(value) > 0) {
|
|
130
|
+
onChange(convertToWei(value));
|
|
131
|
+
} else {
|
|
132
|
+
onChange("0");
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
[validate, convertToWei, onChange],
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const handlePresetClick = useCallback(
|
|
139
|
+
(value: string) => {
|
|
140
|
+
setDisplayValue(value);
|
|
141
|
+
setError(null);
|
|
142
|
+
onChange(convertToWei(value));
|
|
143
|
+
},
|
|
144
|
+
[convertToWei, onChange],
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
// Notify parent with initial value on mount
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
if (initialValue && !validate(initialValue)) {
|
|
150
|
+
onChange(convertToWei(initialValue));
|
|
151
|
+
}
|
|
152
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
153
|
+
}, []);
|
|
154
|
+
|
|
155
|
+
const formatHint = () => {
|
|
156
|
+
if (minDisplay !== null && maxDisplay !== null) {
|
|
157
|
+
const minStr = minDisplay % 1 === 0 ? minDisplay.toString() : minDisplay.toFixed(2);
|
|
158
|
+
const maxStr = maxDisplay % 1 === 0 ? maxDisplay.toString() : maxDisplay.toFixed(2);
|
|
159
|
+
return `${minStr} – ${maxStr} ${currency}`;
|
|
160
|
+
}
|
|
161
|
+
if (minDisplay !== null) {
|
|
162
|
+
const minStr = minDisplay % 1 === 0 ? minDisplay.toString() : minDisplay.toFixed(2);
|
|
163
|
+
return `Min: ${minStr} ${currency}`;
|
|
164
|
+
}
|
|
165
|
+
if (maxDisplay !== null) {
|
|
166
|
+
const maxStr = maxDisplay % 1 === 0 ? maxDisplay.toString() : maxDisplay.toFixed(2);
|
|
167
|
+
return `Max: ${maxStr} ${currency}`;
|
|
168
|
+
}
|
|
169
|
+
return null;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const hint = formatHint();
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<div className="anyspend-variable-pricing mb-6">
|
|
176
|
+
<label
|
|
177
|
+
htmlFor="variable-pricing-amount"
|
|
178
|
+
className="mb-3 block text-lg font-semibold text-gray-900 dark:text-gray-100"
|
|
179
|
+
>
|
|
180
|
+
{config.label || "Enter amount"}
|
|
181
|
+
</label>
|
|
182
|
+
|
|
183
|
+
{/* Preset buttons */}
|
|
184
|
+
{presetAmounts.length > 0 && (
|
|
185
|
+
<div className="mb-3 flex flex-wrap gap-2">
|
|
186
|
+
{presetAmounts.map(preset => (
|
|
187
|
+
<button
|
|
188
|
+
key={preset.value}
|
|
189
|
+
type="button"
|
|
190
|
+
onClick={() => handlePresetClick(preset.value)}
|
|
191
|
+
className={cn(
|
|
192
|
+
"rounded-full border px-4 py-2 text-sm font-medium transition-colors",
|
|
193
|
+
displayValue === preset.value
|
|
194
|
+
? "border-transparent text-white"
|
|
195
|
+
: "border-gray-200 text-gray-700 hover:bg-gray-50 dark:border-neutral-600 dark:text-gray-300 dark:hover:bg-neutral-800",
|
|
196
|
+
)}
|
|
197
|
+
style={
|
|
198
|
+
displayValue === preset.value ? { backgroundColor: themeColor || "hsl(var(--as-brand))" } : undefined
|
|
199
|
+
}
|
|
200
|
+
>
|
|
201
|
+
{preset.label} {currency}
|
|
202
|
+
</button>
|
|
203
|
+
))}
|
|
204
|
+
</div>
|
|
205
|
+
)}
|
|
206
|
+
|
|
207
|
+
{/* Input */}
|
|
208
|
+
<div className="relative">
|
|
209
|
+
<input
|
|
210
|
+
id="variable-pricing-amount"
|
|
211
|
+
type="text"
|
|
212
|
+
inputMode="decimal"
|
|
213
|
+
value={displayValue}
|
|
214
|
+
onChange={e => {
|
|
215
|
+
// Normalize comma decimal separators for locale compatibility
|
|
216
|
+
const normalized = e.target.value.replace(",", ".");
|
|
217
|
+
handleChange(normalized);
|
|
218
|
+
}}
|
|
219
|
+
className="w-full rounded-xl border border-gray-200 bg-gray-50 px-4 py-3.5 pr-16 text-lg font-semibold text-gray-900 placeholder:text-gray-300 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-neutral-600 dark:bg-neutral-800 dark:text-gray-100 dark:placeholder:text-neutral-600 dark:focus:border-blue-400"
|
|
220
|
+
placeholder="0.00"
|
|
221
|
+
/>
|
|
222
|
+
<span className="absolute right-4 top-1/2 -translate-y-1/2 text-sm font-medium text-gray-400 dark:text-gray-500">
|
|
223
|
+
{currency}
|
|
224
|
+
</span>
|
|
225
|
+
</div>
|
|
226
|
+
|
|
227
|
+
{/* Hint */}
|
|
228
|
+
{hint && <p className="mt-1.5 text-xs text-gray-500 dark:text-gray-400">{hint}</p>}
|
|
229
|
+
|
|
230
|
+
{/* Error */}
|
|
231
|
+
<AnimatePresence initial={false}>
|
|
232
|
+
{error && (
|
|
233
|
+
<motion.p
|
|
234
|
+
key="variable-price-error"
|
|
235
|
+
initial={{ opacity: 0, height: 0 }}
|
|
236
|
+
animate={{ opacity: 1, height: "auto" }}
|
|
237
|
+
exit={{ opacity: 0, height: 0 }}
|
|
238
|
+
transition={{ duration: 0.15, ease: "easeOut" }}
|
|
239
|
+
className="mt-1.5 text-sm text-red-500"
|
|
240
|
+
>
|
|
241
|
+
{error}
|
|
242
|
+
</motion.p>
|
|
243
|
+
)}
|
|
244
|
+
</AnimatePresence>
|
|
245
|
+
</div>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
@@ -101,7 +101,7 @@ export function CryptoPaymentMethod({
|
|
|
101
101
|
return (
|
|
102
102
|
<div
|
|
103
103
|
className={
|
|
104
|
-
classes?.container || "crypto-payment-method mx-auto h-fit w-
|
|
104
|
+
classes?.container || "crypto-payment-method mx-auto h-fit w-full max-w-[460px] px-5 pb-5 pt-5 sm:px-0 sm:pt-5"
|
|
105
105
|
}
|
|
106
106
|
>
|
|
107
107
|
<div className={cn("relative flex flex-col gap-10")}>
|
|
@@ -85,7 +85,7 @@ export function FeeDetailPanel({ fee, transactionAmountUsd, onBack, classes }: F
|
|
|
85
85
|
const [showAllDiscountTiers, setShowAllDiscountTiers] = useState(false);
|
|
86
86
|
|
|
87
87
|
return (
|
|
88
|
-
<div className={classes?.container || "mx-auto flex w-
|
|
88
|
+
<div className={classes?.container || "mx-auto flex w-full max-w-[460px] flex-col items-center gap-3 px-5"}>
|
|
89
89
|
<div className="flex w-full flex-col gap-3">
|
|
90
90
|
<div className="text-center">
|
|
91
91
|
<h3 className={classes?.title || "text-as-primary text-lg font-bold"}>Fee Breakdown</h3>
|
|
@@ -110,7 +110,7 @@ export function FiatPaymentMethodComponent({
|
|
|
110
110
|
// Show loading state while checking geo availability
|
|
111
111
|
if (isLoadingGeoOnramp) {
|
|
112
112
|
return (
|
|
113
|
-
<div className={classes?.container || "fiat-payment-method mx-auto w-
|
|
113
|
+
<div className={classes?.container || "fiat-payment-method mx-auto w-full max-w-[460px] p-5"}>
|
|
114
114
|
<div className="flex flex-col gap-6">
|
|
115
115
|
<div className={classes?.header || "flex items-center gap-4"}>
|
|
116
116
|
<button
|
|
@@ -136,7 +136,7 @@ export function FiatPaymentMethodComponent({
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
return (
|
|
139
|
-
<div className={classes?.container || "fiat-payment-method mx-auto w-
|
|
139
|
+
<div className={classes?.container || "fiat-payment-method mx-auto w-full max-w-[460px] p-5"}>
|
|
140
140
|
<div className="flex flex-col gap-6">
|
|
141
141
|
{/* Header */}
|
|
142
142
|
<div className={classes?.header || "flex items-center gap-4"}>
|
|
@@ -1235,7 +1235,7 @@ function TransactionDetails({
|
|
|
1235
1235
|
}
|
|
1236
1236
|
|
|
1237
1237
|
export const OrderDetailsLoadingView = (
|
|
1238
|
-
<div className={"mx-auto flex w-
|
|
1238
|
+
<div className={"mx-auto flex w-full max-w-[460px] flex-col items-center gap-4"}>
|
|
1239
1239
|
{/* Status Badge */}
|
|
1240
1240
|
<Badge
|
|
1241
1241
|
variant="default"
|
|
@@ -11,7 +11,7 @@ interface PointsDetailPanelProps {
|
|
|
11
11
|
|
|
12
12
|
export function PointsDetailPanel({ pointsAmount = 0, onBack, classes }: PointsDetailPanelProps) {
|
|
13
13
|
return (
|
|
14
|
-
<div className={classes?.container || "mx-auto flex w-
|
|
14
|
+
<div className={classes?.container || "mx-auto flex w-full max-w-[460px] flex-col items-center gap-4 px-5"}>
|
|
15
15
|
<div className="flex flex-col items-center gap-4 text-center">
|
|
16
16
|
<h3 className={classes?.title || "text-as-primary text-xl font-bold"}>Earn Points with Every Swap</h3>
|
|
17
17
|
<p className={classes?.description || "text-as-primary/70 text-balance text-sm leading-relaxed"}>
|
|
@@ -94,7 +94,7 @@ export function RecipientSelection({
|
|
|
94
94
|
const canConfirm = recipientAddress && isAddressValid;
|
|
95
95
|
|
|
96
96
|
return (
|
|
97
|
-
<div className={classes?.container || "recipient-selection mx-auto w-
|
|
97
|
+
<div className={classes?.container || "recipient-selection mx-auto w-full max-w-[460px] p-5"}>
|
|
98
98
|
<div className="flex flex-col gap-6">
|
|
99
99
|
{/* Header */}
|
|
100
100
|
<div className={classes?.header || "flex justify-around"}>
|
|
@@ -10,6 +10,7 @@ export type {
|
|
|
10
10
|
ShippingOption,
|
|
11
11
|
DiscountResult,
|
|
12
12
|
AddressData,
|
|
13
|
+
VariablePricingConfig,
|
|
13
14
|
} from "./checkout/AnySpendCheckout";
|
|
14
15
|
export { AnySpendCheckoutTrigger } from "./checkout/AnySpendCheckoutTrigger";
|
|
15
16
|
export type { AnySpendCheckoutTriggerProps } from "./checkout/AnySpendCheckoutTrigger";
|
|
@@ -11,7 +11,9 @@ import { useMemo } from "react";
|
|
|
11
11
|
|
|
12
12
|
import { parseUnits } from "viem";
|
|
13
13
|
import { base } from "viem/chains";
|
|
14
|
+
import { useAccount } from "wagmi";
|
|
14
15
|
import { CreateOrderParams } from "./useAnyspendCreateOrder";
|
|
16
|
+
import { getCachedWalletHeaders } from "./useKycStatus";
|
|
15
17
|
import { useValidatedClientReferenceId } from "./useValidatedClientReferenceId";
|
|
16
18
|
|
|
17
19
|
export type OnrampOptions = {
|
|
@@ -24,6 +26,8 @@ export type OnrampOptions = {
|
|
|
24
26
|
export type CreateOnrampOrderParams = Omit<CreateOrderParams, "srcChain" | "srcToken" | "srcAmount"> & {
|
|
25
27
|
srcFiatAmount: string;
|
|
26
28
|
onramp: OnrampOptions;
|
|
29
|
+
/** When true, fees are added on top of srcAmount (payer pays more, receiver gets exact amount) */
|
|
30
|
+
feeOnTop?: boolean;
|
|
27
31
|
};
|
|
28
32
|
|
|
29
33
|
export type UseAnyspendCreateOnrampOrderProps = {
|
|
@@ -38,6 +42,7 @@ export type UseAnyspendCreateOnrampOrderProps = {
|
|
|
38
42
|
export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspendCreateOnrampOrderProps = {}) {
|
|
39
43
|
// Get B3 context values
|
|
40
44
|
const { partnerId } = useB3Config();
|
|
45
|
+
const { address } = useAccount();
|
|
41
46
|
|
|
42
47
|
// Get validated client reference ID from B3 context
|
|
43
48
|
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
@@ -79,6 +84,16 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
|
|
|
79
84
|
// Create order with USDC on Base as source
|
|
80
85
|
const srcAmountOnRampInWei = parseUnits(srcFiatAmount, USDC_BASE.decimals);
|
|
81
86
|
|
|
87
|
+
// For card payments, include wallet auth headers so the backend can verify
|
|
88
|
+
// KYC by the signing wallet address (may differ from the B3 JWT address).
|
|
89
|
+
// Only use already-cached headers — never trigger a fresh wallet signature
|
|
90
|
+
// here, as that would prompt the user without their explicit consent.
|
|
91
|
+
// KycGate pre-caches the headers in the "Continue to Verify" user-gesture.
|
|
92
|
+
let kycWalletHeaders: Record<string, string> | undefined;
|
|
93
|
+
if (onramp.vendor === "stripe-web2" && address) {
|
|
94
|
+
kycWalletHeaders = getCachedWalletHeaders(address);
|
|
95
|
+
}
|
|
96
|
+
|
|
82
97
|
return await anyspendService.createOrder({
|
|
83
98
|
recipientAddress: normalizeAddress(recipientAddress),
|
|
84
99
|
type: orderType,
|
|
@@ -115,6 +130,8 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
|
|
|
115
130
|
clientReferenceId,
|
|
116
131
|
visitorData,
|
|
117
132
|
callbackMetadata: params.callbackMetadata,
|
|
133
|
+
feeOnTop: params.feeOnTop,
|
|
134
|
+
kycWalletHeaders,
|
|
118
135
|
});
|
|
119
136
|
} catch (error: any) {
|
|
120
137
|
// If the error has a response with message and statusCode, throw that
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { ANYSPEND_MAINNET_BASE_URL } from "@b3dotfun/sdk/anyspend/constants";
|
|
4
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
5
|
+
import { useCallback } from "react";
|
|
6
|
+
import { useAccount, useSignMessage } from "wagmi";
|
|
7
|
+
|
|
8
|
+
export interface KycStatusResponse {
|
|
9
|
+
kycRequired: boolean;
|
|
10
|
+
status: "not_verified" | "pending" | "completed" | "approved" | "declined" | "needs_review" | "expired";
|
|
11
|
+
inquiry?: {
|
|
12
|
+
inquiryId: string;
|
|
13
|
+
sessionToken: string;
|
|
14
|
+
};
|
|
15
|
+
config?: {
|
|
16
|
+
templateId: string;
|
|
17
|
+
environment: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface KycInquiryResponse {
|
|
22
|
+
inquiryId: string;
|
|
23
|
+
sessionToken: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface KycVerifyResponse {
|
|
27
|
+
status: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function buildWalletAuthMessage(walletAddress: string, timestamp: number): string {
|
|
31
|
+
return `AnySpend wants to verify your identity for card payments.\n\nThis signature does not trigger a blockchain transaction or cost any gas.\n\nWallet: ${walletAddress.toLowerCase()}\nNonce: ${timestamp}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Module-level signature cache to avoid repeated wallet prompts within the 5-minute window. */
|
|
35
|
+
const headerCache = new Map<string, { headers: Record<string, string>; expiresAt: number }>();
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Returns cached wallet auth headers without triggering a wallet signature prompt.
|
|
39
|
+
* Returns undefined if no valid cache exists for the given address.
|
|
40
|
+
*/
|
|
41
|
+
export function getCachedWalletHeaders(address: string): Record<string, string> | undefined {
|
|
42
|
+
const cached = headerCache.get(address.toLowerCase());
|
|
43
|
+
if (cached && Date.now() < cached.expiresAt) return cached.headers;
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Returns a function that builds the wallet-signature auth headers.
|
|
49
|
+
* Caches signatures for 4 minutes (server allows 5-minute window).
|
|
50
|
+
*/
|
|
51
|
+
export function useWalletAuthHeaders() {
|
|
52
|
+
const { address } = useAccount();
|
|
53
|
+
const { signMessageAsync } = useSignMessage();
|
|
54
|
+
|
|
55
|
+
const getHeaders = useCallback(async (): Promise<Record<string, string>> => {
|
|
56
|
+
if (!address) throw new Error("No wallet connected");
|
|
57
|
+
const walletAddress = address.toLowerCase();
|
|
58
|
+
|
|
59
|
+
const cached = headerCache.get(walletAddress);
|
|
60
|
+
if (cached && Date.now() < cached.expiresAt) return cached.headers;
|
|
61
|
+
|
|
62
|
+
const timestamp = Math.floor(Date.now() / 1000);
|
|
63
|
+
const message = buildWalletAuthMessage(walletAddress, timestamp);
|
|
64
|
+
const signature = await signMessageAsync({ message });
|
|
65
|
+
|
|
66
|
+
const headers = {
|
|
67
|
+
"X-Wallet-Address": walletAddress,
|
|
68
|
+
"X-Wallet-Signature": signature,
|
|
69
|
+
"X-Wallet-Timestamp": String(timestamp),
|
|
70
|
+
};
|
|
71
|
+
// Cache for 4 minutes so repeated fetches don't re-prompt the user
|
|
72
|
+
headerCache.set(walletAddress, { headers, expiresAt: Date.now() + 4 * 60 * 1000 });
|
|
73
|
+
return headers;
|
|
74
|
+
}, [address, signMessageAsync]);
|
|
75
|
+
|
|
76
|
+
return { address, getHeaders };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function useKycStatus(enabled = true) {
|
|
80
|
+
const { address, getHeaders } = useWalletAuthHeaders();
|
|
81
|
+
|
|
82
|
+
const { data, isLoading, error, refetch } = useQuery({
|
|
83
|
+
queryKey: ["kyc-status", address],
|
|
84
|
+
queryFn: async () => {
|
|
85
|
+
const headers = await getHeaders();
|
|
86
|
+
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/kyc/status`, { headers });
|
|
87
|
+
const json = await response.json();
|
|
88
|
+
if (!response.ok) throw new Error(json.message || "Failed to fetch KYC status");
|
|
89
|
+
return json.data as KycStatusResponse;
|
|
90
|
+
},
|
|
91
|
+
enabled: enabled && !!address,
|
|
92
|
+
staleTime: 30_000,
|
|
93
|
+
retry: 0,
|
|
94
|
+
refetchOnWindowFocus: false,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
kycStatus: data || null,
|
|
99
|
+
isLoadingKycStatus: isLoading,
|
|
100
|
+
kycStatusError: error,
|
|
101
|
+
refetchKycStatus: refetch,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function useCreateKycInquiry() {
|
|
106
|
+
const { address, getHeaders } = useWalletAuthHeaders();
|
|
107
|
+
|
|
108
|
+
const { mutateAsync, isPending } = useMutation({
|
|
109
|
+
mutationFn: async () => {
|
|
110
|
+
if (!address) throw new Error("No wallet connected");
|
|
111
|
+
const headers = await getHeaders();
|
|
112
|
+
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/kyc/inquiry`, {
|
|
113
|
+
method: "POST",
|
|
114
|
+
headers: { "Content-Type": "application/json", ...headers },
|
|
115
|
+
});
|
|
116
|
+
const json = await response.json();
|
|
117
|
+
if (!response.ok) throw new Error(json.message || "Failed to create KYC inquiry");
|
|
118
|
+
return json.data as KycInquiryResponse;
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
createInquiry: mutateAsync,
|
|
124
|
+
isCreatingInquiry: isPending,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function useVerifyKyc() {
|
|
129
|
+
const { address, getHeaders } = useWalletAuthHeaders();
|
|
130
|
+
|
|
131
|
+
const { mutateAsync, isPending } = useMutation({
|
|
132
|
+
mutationFn: async (inquiryId: string) => {
|
|
133
|
+
if (!address) throw new Error("No wallet connected");
|
|
134
|
+
const headers = await getHeaders();
|
|
135
|
+
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/kyc/verify`, {
|
|
136
|
+
method: "POST",
|
|
137
|
+
headers: { "Content-Type": "application/json", ...headers },
|
|
138
|
+
body: JSON.stringify({ inquiryId }),
|
|
139
|
+
});
|
|
140
|
+
const json = await response.json();
|
|
141
|
+
if (!response.ok) throw new Error(json.message || "Failed to verify KYC");
|
|
142
|
+
return json.data as KycVerifyResponse;
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
verifyKyc: mutateAsync,
|
|
148
|
+
isVerifying: isPending,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -72,6 +72,8 @@ export const anyspendService = {
|
|
|
72
72
|
clientReferenceId,
|
|
73
73
|
visitorData,
|
|
74
74
|
callbackMetadata,
|
|
75
|
+
feeOnTop,
|
|
76
|
+
kycWalletHeaders,
|
|
75
77
|
}: {
|
|
76
78
|
recipientAddress: string;
|
|
77
79
|
type: string;
|
|
@@ -88,6 +90,9 @@ export const anyspendService = {
|
|
|
88
90
|
clientReferenceId?: string;
|
|
89
91
|
visitorData?: VisitorData;
|
|
90
92
|
callbackMetadata?: Record<string, unknown>;
|
|
93
|
+
feeOnTop?: boolean;
|
|
94
|
+
/** Wallet signature auth headers for KYC lookup (stripe-web2 orders only). */
|
|
95
|
+
kycWalletHeaders?: Record<string, string>;
|
|
91
96
|
}) => {
|
|
92
97
|
const accessToken = await app.authentication.getAccessToken();
|
|
93
98
|
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/orders`, {
|
|
@@ -97,6 +102,7 @@ export const anyspendService = {
|
|
|
97
102
|
...(visitorData?.requestId && { "X-Fingerprint-Request-Id": visitorData.requestId }),
|
|
98
103
|
...(visitorData?.visitorId && { "X-Fingerprint-Visitor-Id": visitorData.visitorId }),
|
|
99
104
|
...(accessToken && { Authorization: `Bearer ${accessToken}` }),
|
|
105
|
+
...kycWalletHeaders,
|
|
100
106
|
},
|
|
101
107
|
body: JSON.stringify({
|
|
102
108
|
recipientAddress,
|
|
@@ -113,6 +119,7 @@ export const anyspendService = {
|
|
|
113
119
|
partnerId,
|
|
114
120
|
...(clientReferenceId && { clientReferenceId }),
|
|
115
121
|
...(callbackMetadata && { callbackMetadata }),
|
|
122
|
+
...(feeOnTop != null && { feeOnTop }),
|
|
116
123
|
}),
|
|
117
124
|
});
|
|
118
125
|
const data: CreateOrderResponse = await response.json();
|
|
@@ -210,8 +210,6 @@ export function B3DynamicModal() {
|
|
|
210
210
|
hideCloseButton={hideCloseButton}
|
|
211
211
|
hideGABranding={isAnySpendType}
|
|
212
212
|
onEscapeKeyDown={!isClosable ? e => e.preventDefault() : undefined}
|
|
213
|
-
onPointerDownOutside={!isClosable ? e => e.preventDefault() : undefined}
|
|
214
|
-
onInteractOutside={!isClosable ? e => e.preventDefault() : undefined}
|
|
215
213
|
>
|
|
216
214
|
<ModalTitle className="sr-only hidden">{contentType?.type || "Modal"}</ModalTitle>
|
|
217
215
|
<ModalDescription className="sr-only hidden">{contentType?.type || "Modal Body"}</ModalDescription>
|
|
@@ -4,8 +4,8 @@ const HomeIcon = () => {
|
|
|
4
4
|
return (
|
|
5
5
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
6
6
|
<path
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
fillRule="evenodd"
|
|
8
|
+
clipRule="evenodd"
|
|
9
9
|
d="M12.5227 1.33636C12.1804 1.24368 11.8196 1.24368 11.4773 1.33636C11.08 1.44395 10.7454 1.7066 10.4784 1.91623L10.4038 1.97465L3.54376 7.31012C3.16713 7.6024 2.83532 7.85991 2.58806 8.19421C2.37107 8.48759 2.20942 8.8181 2.11106 9.1695C1.99898 9.56992 1.99943 9.98993 1.99995 10.4667L2.00002 17.8385C2 18.3657 1.99998 18.8204 2.03059 19.195C2.06289 19.5904 2.1342 19.9836 2.327 20.362C2.61462 20.9264 3.07356 21.3854 3.63805 21.673C4.01643 21.8658 4.40964 21.9371 4.80499 21.9694C5.17956 22 5.63431 22 6.16145 22H17.8386C18.3657 22 18.8205 22 19.195 21.9694C19.5904 21.9371 19.9836 21.8658 20.362 21.673C20.9265 21.3854 21.3854 20.9264 21.673 20.362C21.8658 19.9836 21.9371 19.5904 21.9694 19.195C22.0001 18.8204 22 18.3657 22 17.8386L22.0001 10.4667C22.0006 9.98993 22.0011 9.56992 21.889 9.1695C21.7906 8.8181 21.629 8.48759 21.412 8.19421C21.1647 7.8599 20.8329 7.6024 20.4563 7.31011L13.5963 1.97465L13.5216 1.91623C13.2546 1.7066 12.9201 1.44395 12.5227 1.33636ZM8.00003 16C7.44775 16 7.00003 16.4477 7.00003 17C7.00003 17.5523 7.44775 18 8.00003 18H16C16.5523 18 17 17.5523 17 17C17 16.4477 16.5523 16 16 16H8.00003Z"
|
|
10
10
|
fill="currentColor"
|
|
11
11
|
/>
|
|
@@ -19,9 +19,9 @@ const SwapIcon = () => {
|
|
|
19
19
|
<path
|
|
20
20
|
d="M20.4533 12.893C20.1755 15.5029 18.6968 17.9487 16.2498 19.3614C12.1843 21.7086 6.98576 20.3157 4.63855 16.2502L4.38855 15.8172M3.5465 11.107C3.8243 8.49711 5.30309 6.05138 7.75007 4.63862C11.8156 2.29141 17.0141 3.68434 19.3613 7.74983L19.6113 8.18285M3.49353 18.0661L4.22558 15.334L6.95763 16.0661M17.0428 7.93401L19.7748 8.66606L20.5069 5.93401"
|
|
21
21
|
stroke="currentColor"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
strokeWidth="2"
|
|
23
|
+
strokeLinecap="round"
|
|
24
|
+
strokeLinejoin="round"
|
|
25
25
|
/>
|
|
26
26
|
</svg>
|
|
27
27
|
);
|
|
@@ -31,8 +31,8 @@ const SettingsIcon = () => {
|
|
|
31
31
|
return (
|
|
32
32
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
33
33
|
<path
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
fillRule="evenodd"
|
|
35
|
+
clipRule="evenodd"
|
|
36
36
|
d="M19.286 15.9606C19.2272 15.6362 19.2669 15.3016 19.4 15C19.5268 14.7042 19.7372 14.452 20.0055 14.2743C20.2738 14.0966 20.5882 14.0013 20.91 14H21C21.5304 14 22.0391 13.7893 22.4142 13.4142C22.7893 13.0391 23 12.5304 23 12C23 11.4696 22.7893 10.9609 22.4142 10.5858C22.0391 10.2107 21.5304 10 21 10H20.83C20.5082 9.99872 20.1938 9.90337 19.9255 9.72569C19.6572 9.54802 19.4468 9.29577 19.32 9V8.92C19.1869 8.61838 19.1472 8.28381 19.206 7.95941C19.2648 7.63502 19.4195 7.33568 19.65 7.1L19.71 7.04C19.896 6.85425 20.0435 6.63368 20.1441 6.39088C20.2448 6.14808 20.2966 5.88783 20.2966 5.625C20.2966 5.36217 20.2448 5.10192 20.1441 4.85912C20.0435 4.61632 19.896 4.39575 19.71 4.21C19.5243 4.02405 19.3037 3.87653 19.0609 3.77588C18.8181 3.67523 18.5578 3.62343 18.295 3.62343C18.0322 3.62343 17.7719 3.67523 17.5291 3.77588C17.2863 3.87653 17.0657 4.02405 16.88 4.21L16.82 4.27C16.5843 4.50054 16.285 4.65519 15.9606 4.714C15.6362 4.77282 15.3016 4.73312 15 4.6C14.7042 4.47324 14.452 4.26276 14.2743 3.99447C14.0966 3.72618 14.0013 3.41179 14 3.09V3C14 2.46957 13.7893 1.96086 13.4142 1.58579C13.0391 1.21071 12.5304 1 12 1C11.4696 1 10.9609 1.21071 10.5858 1.58579C10.2107 1.96086 10 2.46957 10 3V3.17C9.99872 3.49179 9.90337 3.80618 9.72569 4.07447C9.54802 4.34276 9.29577 4.55324 9 4.68H8.92C8.61838 4.81312 8.28381 4.85282 7.95941 4.794C7.63502 4.73519 7.33568 4.58054 7.1 4.35L7.04 4.29C6.85425 4.10405 6.63368 3.95653 6.39088 3.85588C6.14808 3.75523 5.88783 3.70343 5.625 3.70343C5.36217 3.70343 5.10192 3.75523 4.85912 3.85588C4.61632 3.95653 4.39575 4.10405 4.21 4.29C4.02405 4.47575 3.87653 4.69632 3.77588 4.93912C3.67523 5.18192 3.62343 5.44217 3.62343 5.705C3.62343 5.96783 3.67523 6.22808 3.77588 6.47088C3.87653 6.71368 4.02405 6.93425 4.21 7.12L4.27 7.18C4.50054 7.41568 4.65519 7.71502 4.714 8.03941C4.77282 8.36381 4.73312 8.69838 4.6 9C4.48572 9.31074 4.28059 9.5799 4.0113 9.77251C3.742 9.96512 3.42099 10.0723 3.09 10.08H3C2.46957 10.08 1.96086 10.2907 1.58579 10.6658C1.21071 11.0409 1 11.5496 1 12.08C1 12.6104 1.21071 13.1191 1.58579 13.4942C1.96086 13.8693 2.46957 14.08 3 14.08H3.17C3.49179 14.0813 3.80618 14.1766 4.07447 14.3543C4.34276 14.532 4.55324 14.7842 4.68 15.08C4.81312 15.3816 4.85282 15.7162 4.794 16.0406C4.73519 16.365 4.58054 16.6643 4.35 16.9L4.29 16.96C4.10405 17.1457 3.95653 17.3663 3.85588 17.6091C3.75523 17.8519 3.70343 18.1122 3.70343 18.375C3.70343 18.6378 3.75523 18.8981 3.85588 19.1409C3.95653 19.3837 4.10405 19.6043 4.29 19.79C4.47575 19.976 4.69632 20.1235 4.93912 20.2241C5.18192 20.3248 5.44217 20.3766 5.705 20.3766C5.96783 20.3766 6.22808 20.3248 6.47088 20.2241C6.71368 20.1235 6.93425 19.976 7.12 19.79L7.18 19.73C7.41568 19.4995 7.71502 19.3448 8.03941 19.286C8.36381 19.2272 8.69838 19.2669 9 19.4C9.31074 19.5143 9.5799 19.7194 9.77251 19.9887C9.96512 20.258 10.0723 20.579 10.08 20.91V21C10.08 21.5304 10.2907 22.0391 10.6658 22.4142C11.0409 22.7893 11.5496 23 12.08 23C12.6104 23 13.1191 22.7893 13.4942 22.4142C13.8693 22.0391 14.08 21.5304 14.08 21V20.83C14.0813 20.5082 14.1766 20.1938 14.3543 19.9255C14.532 19.6572 14.7842 19.4468 15.08 19.32C15.3816 19.1869 15.7162 19.1472 16.0406 19.206C16.365 19.2648 16.6643 19.4195 16.9 19.65L16.96 19.71C17.1457 19.896 17.3663 20.0435 17.6091 20.1441C17.8519 20.2448 18.1122 20.2966 18.375 20.2966C18.6378 20.2966 18.8981 20.2448 19.1409 20.1441C19.3837 20.0435 19.6043 19.896 19.79 19.71C19.976 19.5243 20.1235 19.3037 20.2241 19.0609C20.3248 18.8181 20.3766 18.5578 20.3766 18.295C20.3766 18.0322 20.3248 17.7719 20.2241 17.5291C20.1235 17.2863 19.976 17.0657 19.79 16.88L19.73 16.82C19.4995 16.5843 19.3448 16.285 19.286 15.9606ZM15 12C15 13.6569 13.6569 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6569 9 15 10.3431 15 12Z"
|
|
37
37
|
fill="currentColor"
|
|
38
38
|
/>
|
|
@@ -19,8 +19,8 @@ const BuyIcon = () => (
|
|
|
19
19
|
fill="#0C68E9"
|
|
20
20
|
/>
|
|
21
21
|
<path
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
fillRule="evenodd"
|
|
23
|
+
clipRule="evenodd"
|
|
24
24
|
d="M14.1666 2.5C12.3642 2.5 10.8013 2.95205 9.44241 3.37018L9.18862 3.44844C7.90485 3.84476 6.86213 4.16667 5.83332 4.16667C5.09512 4.16667 4.43564 4.08819 3.88041 3.98151L3.85421 3.97647C3.44746 3.89831 3.10585 3.83267 2.84038 3.79758C2.60748 3.76679 2.26236 3.7302 1.94675 3.84126C1.78134 3.89947 1.60242 3.98249 1.43327 4.12224C1.26411 4.26199 1.14882 4.42202 1.06045 4.57348C0.898119 4.85168 0.864329 5.167 0.849347 5.3925C0.833297 5.63407 0.833306 5.94132 0.833317 6.29588L0.833315 15.2922C0.833263 15.4565 0.833201 15.6516 0.932434 15.9263C0.981719 16.0628 1.06288 16.1945 1.10974 16.2664C1.15659 16.3383 1.24436 16.4657 1.34932 16.5659C1.41718 16.6306 1.49456 16.6992 1.58722 16.76C1.67809 16.8196 1.76087 16.8559 1.79699 16.8717L1.80356 16.8746C2.48669 17.1759 3.71203 17.5 5.83332 17.5C7.63579 17.5 9.19862 17.0479 10.5576 16.6298L10.8113 16.5516C12.0951 16.1552 13.1378 15.8333 14.1666 15.8333C14.9048 15.8333 15.5643 15.9118 16.1196 16.0185L16.1458 16.0235C16.5525 16.1017 16.8941 16.1673 17.1596 16.2024C17.3925 16.2332 17.7376 16.2698 18.0532 16.1587C18.2186 16.1005 18.3975 16.0175 18.5667 15.8778C18.7359 15.738 18.8511 15.578 18.9395 15.4265C19.1018 15.1483 19.1356 14.833 19.1506 14.6075C19.1667 14.3659 19.1667 14.0587 19.1666 13.7041L19.1667 4.70776C19.1667 4.54347 19.1668 4.34839 19.0675 4.07365C19.0182 3.9372 18.9371 3.80547 18.8902 3.73359C18.8434 3.6617 18.7556 3.53428 18.6507 3.43412C18.5828 3.36935 18.5054 3.30084 18.4127 3.24003C18.3219 3.1804 18.2391 3.14413 18.203 3.1283L18.1964 3.12542C17.5133 2.82409 16.2879 2.5 14.1666 2.5ZM15.8333 7.5C15.8333 7.03976 15.4602 6.66667 15 6.66667C14.5397 6.66667 14.1666 7.03976 14.1666 7.5V10.8333C14.1666 11.2936 14.5397 11.6667 15 11.6667C15.4602 11.6667 15.8333 11.2936 15.8333 10.8333V7.5ZM7.08331 10C7.08331 8.38917 8.38915 7.08333 9.99998 7.08333C11.6108 7.08333 12.9166 8.38917 12.9166 10C12.9166 11.6108 11.6108 12.9167 9.99998 12.9167C8.38915 12.9167 7.08331 11.6108 7.08331 10ZM4.99998 8.33333C5.46022 8.33333 5.83331 8.70643 5.83331 9.16667V12.5C5.83331 12.9602 5.46022 13.3333 4.99998 13.3333C4.53974 13.3333 4.16665 12.9602 4.16665 12.5V9.16667C4.16665 8.70643 4.53974 8.33333 4.99998 8.33333Z"
|
|
25
25
|
fill="#0C68E9"
|
|
26
26
|
/>
|