@b3dotfun/sdk 0.1.68 → 0.1.69-alpha.1
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/B3Provider/AuthenticationProvider.d.ts +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
- 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/useAutoSelectWallet.d.ts +6 -3
- package/dist/cjs/global-account/react/hooks/useAutoSelectWallet.js +31 -3
- 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/B3Provider/AuthenticationProvider.d.ts +3 -1
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- 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/useAutoSelectWallet.d.ts +6 -3
- package/dist/esm/global-account/react/hooks/useAutoSelectWallet.js +33 -5
- 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/B3Provider/AuthenticationProvider.d.ts +3 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
- 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/hooks/useAutoSelectWallet.d.ts +6 -3
- 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/B3Provider/AuthenticationProvider.tsx +4 -0
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +9 -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/useAutoSelectWallet.ts +40 -6
- 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>
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
import { EIP1193 } from "thirdweb/wallets";
|
|
1
2
|
import { useAuthentication } from "../../hooks";
|
|
2
3
|
import { useAutoSelectWallet } from "../../hooks/useAutoSelectWallet";
|
|
3
4
|
|
|
4
5
|
const AuthenticationProvider = ({
|
|
5
6
|
partnerId,
|
|
6
7
|
automaticallySetFirstEoa,
|
|
8
|
+
defaultEoaProvider,
|
|
7
9
|
}: {
|
|
8
10
|
partnerId: string;
|
|
9
11
|
automaticallySetFirstEoa: boolean;
|
|
12
|
+
defaultEoaProvider?: EIP1193.EIP1193Provider;
|
|
10
13
|
}) => {
|
|
11
14
|
useAuthentication(partnerId);
|
|
12
15
|
useAutoSelectWallet({
|
|
13
16
|
enabled: automaticallySetFirstEoa,
|
|
17
|
+
defaultEoaProvider,
|
|
14
18
|
});
|
|
15
19
|
|
|
16
20
|
return null;
|
|
@@ -8,7 +8,7 @@ import "@relayprotocol/relay-kit-ui/styles.css";
|
|
|
8
8
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
9
9
|
import { useEffect, useMemo } from "react";
|
|
10
10
|
import { ThirdwebProvider } from "thirdweb/react";
|
|
11
|
-
import { Account, Wallet } from "thirdweb/wallets";
|
|
11
|
+
import { Account, EIP1193, Wallet } from "thirdweb/wallets";
|
|
12
12
|
import { CreateConnectorFn, WagmiProvider } from "wagmi";
|
|
13
13
|
import { ClientType, setClientType } from "../../../client-manager";
|
|
14
14
|
import { StyleRoot } from "../StyleRoot";
|
|
@@ -29,6 +29,7 @@ export function B3Provider({
|
|
|
29
29
|
accountOverride,
|
|
30
30
|
environment,
|
|
31
31
|
automaticallySetFirstEoa,
|
|
32
|
+
defaultEoaProvider,
|
|
32
33
|
simDuneApiKey,
|
|
33
34
|
// deprecated since v0.0.87
|
|
34
35
|
toaster: _toaster,
|
|
@@ -48,6 +49,8 @@ export function B3Provider({
|
|
|
48
49
|
accountOverride?: Account;
|
|
49
50
|
environment?: "development" | "production";
|
|
50
51
|
automaticallySetFirstEoa?: boolean;
|
|
52
|
+
/** EIP-1193 provider to auto-connect as the default EOA wallet (e.g., Farcaster frame wallet) */
|
|
53
|
+
defaultEoaProvider?: EIP1193.EIP1193Provider;
|
|
51
54
|
simDuneApiKey?: string;
|
|
52
55
|
toaster?: {
|
|
53
56
|
position?: "top-center" | "top-right" | "bottom-center" | "bottom-right";
|
|
@@ -104,7 +107,11 @@ export function B3Provider({
|
|
|
104
107
|
{/* For the modal https://github.com/b3-fun/b3/blob/main/packages/sdk/src/global-account/react/components/ui/dialog.tsx#L46 */}
|
|
105
108
|
<StyleRoot id="b3-root" />
|
|
106
109
|
</RelayKitProviderWrapper>
|
|
107
|
-
<AuthenticationProvider
|
|
110
|
+
<AuthenticationProvider
|
|
111
|
+
partnerId={partnerId}
|
|
112
|
+
automaticallySetFirstEoa={!!automaticallySetFirstEoa}
|
|
113
|
+
defaultEoaProvider={defaultEoaProvider}
|
|
114
|
+
/>
|
|
108
115
|
</B3ConfigProvider>
|
|
109
116
|
</LocalSDKProvider>
|
|
110
117
|
</ToastProvider>
|