@b3dotfun/sdk 0.0.24 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -8
- package/dist/cjs/anyspend/constants/index.d.ts +0 -1
- package/dist/cjs/anyspend/constants/index.js +1 -2
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +0 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +11 -15
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +9 -10
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendTournament.d.ts +0 -2
- package/dist/cjs/anyspend/react/components/AnySpendTournament.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +4 -4
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +5 -5
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +0 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderHistory.js +1 -2
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +9 -3
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.d.ts +0 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +2 -3
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PaymentVendorUI.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/common/PaymentVendorUI.js +2 -2
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +2 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +0 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderAndTransactions.js +2 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.js +2 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendQuote.d.ts +1 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendQuote.js +3 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendTokens.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendTokens.js +2 -2
- package/dist/cjs/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useCoinbaseOnrampOptions.js +3 -3
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.js +3 -3
- package/dist/cjs/anyspend/react/hooks/useStripeClientSecret.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useStripeClientSecret.js +3 -3
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.js +3 -3
- package/dist/cjs/anyspend/services/anyspend.d.ts +9 -10
- package/dist/cjs/anyspend/services/anyspend.js +18 -18
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +13 -15
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +1 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +1 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +1 -3
- package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
- package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +4 -4
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.d.ts +1 -0
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +31 -20
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/cjs/global-account/react/components/custom/CopyToClipboard.d.ts +2 -1
- package/dist/cjs/global-account/react/components/custom/CopyToClipboard.js +3 -2
- package/dist/cjs/global-account/react/components/icons/BankIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/BankIcon.js +8 -0
- package/dist/cjs/global-account/react/components/icons/EditIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/EditIcon.js +8 -0
- package/dist/cjs/global-account/react/components/icons/SignOutIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/SignOutIcon.js +8 -0
- package/dist/cjs/global-account/react/components/icons/SwapIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/SwapIcon.js +8 -0
- package/dist/cjs/global-account/react/hooks/useB3BalanceFromAddresses.d.ts +6 -0
- package/dist/cjs/global-account/react/hooks/useB3BalanceFromAddresses.js +11 -0
- package/dist/cjs/global-account/react/hooks/useNativeBalance.d.ts +6 -0
- package/dist/cjs/global-account/react/hooks/useNativeBalance.js +39 -6
- package/dist/cjs/global-account/react/hooks/useTokenPrice.d.ts +10 -0
- package/dist/cjs/global-account/react/hooks/useTokenPrice.js +81 -2
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +6 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +1 -1
- package/dist/esm/anyspend/constants/index.d.ts +0 -1
- package/dist/esm/anyspend/constants/index.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +0 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +13 -17
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +10 -11
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendTournament.d.ts +0 -2
- package/dist/esm/anyspend/react/components/AnySpendTournament.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +4 -4
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.d.ts +1 -2
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +5 -5
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +0 -1
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderHistory.js +1 -2
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +7 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.d.ts +0 -1
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +2 -3
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.d.ts +1 -2
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +2 -2
- package/dist/esm/anyspend/react/components/common/PaymentVendorUI.d.ts +1 -2
- package/dist/esm/anyspend/react/components/common/PaymentVendorUI.js +2 -2
- package/dist/esm/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +2 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +0 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderAndTransactions.js +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.js +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendQuote.d.ts +1 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendQuote.js +3 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendTokens.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendTokens.js +2 -2
- package/dist/esm/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useCoinbaseOnrampOptions.js +3 -3
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.js +3 -3
- package/dist/esm/anyspend/react/hooks/useStripeClientSecret.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useStripeClientSecret.js +3 -3
- package/dist/esm/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useStripeSupport.js +3 -3
- package/dist/esm/anyspend/services/anyspend.d.ts +9 -10
- package/dist/esm/anyspend/services/anyspend.js +19 -19
- package/dist/esm/global-account/react/components/B3DynamicModal.js +13 -15
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +1 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +1 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +1 -3
- package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
- package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +5 -5
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.d.ts +1 -0
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +33 -22
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/esm/global-account/react/components/custom/CopyToClipboard.d.ts +2 -1
- package/dist/esm/global-account/react/components/custom/CopyToClipboard.js +4 -3
- package/dist/esm/global-account/react/components/icons/BankIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/BankIcon.js +5 -0
- package/dist/esm/global-account/react/components/icons/EditIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/EditIcon.js +5 -0
- package/dist/esm/global-account/react/components/icons/SignOutIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/SignOutIcon.js +5 -0
- package/dist/esm/global-account/react/components/icons/SwapIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/SwapIcon.js +5 -0
- package/dist/esm/global-account/react/hooks/useB3BalanceFromAddresses.d.ts +6 -0
- package/dist/esm/global-account/react/hooks/useB3BalanceFromAddresses.js +11 -0
- package/dist/esm/global-account/react/hooks/useNativeBalance.d.ts +6 -0
- package/dist/esm/global-account/react/hooks/useNativeBalance.js +39 -6
- package/dist/esm/global-account/react/hooks/useTokenPrice.d.ts +10 -0
- package/dist/esm/global-account/react/hooks/useTokenPrice.js +78 -3
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +6 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/index.d.ts +0 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +0 -1
- package/dist/types/anyspend/react/components/AnySpendBuySpin.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +0 -1
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnySpendStakeB3.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnySpendTournament.d.ts +0 -2
- package/dist/types/anyspend/react/components/common/FiatPaymentMethod.d.ts +1 -2
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +0 -1
- package/dist/types/anyspend/react/components/common/PanelOnrampPayment.d.ts +0 -1
- package/dist/types/anyspend/react/components/common/PaymentStripeWeb2.d.ts +1 -2
- package/dist/types/anyspend/react/components/common/PaymentVendorUI.d.ts +1 -2
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +0 -1
- package/dist/types/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useAnyspendQuote.d.ts +1 -2
- package/dist/types/anyspend/react/hooks/useAnyspendTokens.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useCoinbaseOnrampOptions.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useGeoOnrampOptions.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useStripeClientSecret.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
- package/dist/types/anyspend/services/anyspend.d.ts +9 -10
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +1 -2
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +1 -2
- package/dist/types/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
- package/dist/types/global-account/react/components/ManageAccount/ManageAccount.d.ts +1 -0
- package/dist/types/global-account/react/components/custom/CopyToClipboard.d.ts +2 -1
- package/dist/types/global-account/react/components/icons/BankIcon.d.ts +9 -0
- package/dist/types/global-account/react/components/icons/EditIcon.d.ts +9 -0
- package/dist/types/global-account/react/components/icons/SignOutIcon.d.ts +9 -0
- package/dist/types/global-account/react/components/icons/SwapIcon.d.ts +9 -0
- package/dist/types/global-account/react/hooks/useB3BalanceFromAddresses.d.ts +6 -0
- package/dist/types/global-account/react/hooks/useNativeBalance.d.ts +6 -0
- package/dist/types/global-account/react/hooks/useTokenPrice.d.ts +10 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +1 -1
- package/package.json +2 -1
- package/src/anyspend/constants/index.ts +0 -1
- package/src/anyspend/docs/components.md +1 -5
- package/src/anyspend/docs/error-handling.md +47 -47
- package/src/anyspend/docs/examples.md +29 -29
- package/src/anyspend/docs/hooks.md +22 -27
- package/src/anyspend/docs/installation.md +1 -5
- package/src/anyspend/react/components/AnySpend.tsx +8 -28
- package/src/anyspend/react/components/AnySpendBondKit.tsx +0 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -3
- package/src/anyspend/react/components/AnySpendCustom.tsx +8 -16
- package/src/anyspend/react/components/AnySpendNFT.tsx +0 -3
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -3
- package/src/anyspend/react/components/AnySpendTournament.tsx +0 -4
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +0 -1
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +7 -7
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +5 -7
- package/src/anyspend/react/components/common/OrderDetails.tsx +1 -3
- package/src/anyspend/react/components/common/OrderHistory.tsx +1 -3
- package/src/anyspend/react/components/common/OrderStatus.tsx +7 -1
- package/src/anyspend/react/components/common/PanelOnramp.tsx +2 -2
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +1 -4
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +1 -3
- package/src/anyspend/react/components/common/PaymentVendorUI.tsx +2 -3
- package/src/anyspend/react/components/common/RecipientSelection.tsx +1 -1
- package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +1 -3
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +0 -2
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +1 -13
- package/src/anyspend/react/hooks/useAnyspendOrderAndTransactions.ts +2 -2
- package/src/anyspend/react/hooks/useAnyspendOrderHistory.ts +2 -7
- package/src/anyspend/react/hooks/useAnyspendQuote.ts +3 -4
- package/src/anyspend/react/hooks/useAnyspendTokens.ts +2 -2
- package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +3 -8
- package/src/anyspend/react/hooks/useGeoOnrampOptions.ts +2 -3
- package/src/anyspend/react/hooks/useStripeClientSecret.ts +3 -3
- package/src/anyspend/react/hooks/useStripeSupport.ts +3 -8
- package/src/anyspend/services/anyspend.ts +19 -45
- package/src/global-account/react/components/B3DynamicModal.tsx +66 -39
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +1 -4
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +1 -3
- package/src/global-account/react/components/B3Provider/RelayKitProviderWrapper.tsx +4 -6
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +309 -137
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +4 -3
- package/src/global-account/react/components/custom/CopyToClipboard.tsx +7 -4
- package/src/global-account/react/components/icons/BankIcon.tsx +38 -0
- package/src/global-account/react/components/icons/EditIcon.tsx +33 -0
- package/src/global-account/react/components/icons/SignOutIcon.tsx +28 -0
- package/src/global-account/react/components/icons/SwapIcon.tsx +41 -0
- package/src/global-account/react/hooks/useB3BalanceFromAddresses.ts +18 -0
- package/src/global-account/react/hooks/useNativeBalance.tsx +51 -6
- package/src/global-account/react/hooks/useTokenPrice.tsx +138 -3
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +9 -3
- package/src/global-account/react/stores/useModalStore.ts +1 -1
- package/src/styles/index.css +328 -0
|
@@ -3,12 +3,11 @@ import PaymentOneClick from "./PaymentOneClick";
|
|
|
3
3
|
import PaymentStripeWeb2 from "./PaymentStripeWeb2";
|
|
4
4
|
|
|
5
5
|
interface PaymentVendorUIProps {
|
|
6
|
-
isMainnet: boolean;
|
|
7
6
|
order: components["schemas"]["Order"];
|
|
8
7
|
dstTokenSymbol: string;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
export default function PaymentVendorUI({
|
|
10
|
+
export default function PaymentVendorUI({ order, dstTokenSymbol }: PaymentVendorUIProps) {
|
|
12
11
|
const vendor = order.onrampMetadata?.vendor;
|
|
13
12
|
|
|
14
13
|
// Handle one-click payment flows (Coinbase, Stripe redirect)
|
|
@@ -18,7 +17,7 @@ export default function PaymentVendorUI({ isMainnet, order, dstTokenSymbol }: Pa
|
|
|
18
17
|
|
|
19
18
|
// Handle Stripe Web2 payment flow
|
|
20
19
|
if (vendor === "stripe-web2") {
|
|
21
|
-
return <PaymentStripeWeb2
|
|
20
|
+
return <PaymentStripeWeb2 order={order} />;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
// Return null for unsupported vendors
|
|
@@ -88,7 +88,7 @@ export function RecipientSelection({
|
|
|
88
88
|
const canConfirm = recipientAddress && isAddressValid;
|
|
89
89
|
|
|
90
90
|
return (
|
|
91
|
-
<div className="mx-auto w-[460px] max-w-full">
|
|
91
|
+
<div className="recipient-selection mx-auto w-[460px] max-w-full">
|
|
92
92
|
<div className="flex flex-col gap-6">
|
|
93
93
|
{/* Header */}
|
|
94
94
|
<div className="flex justify-around">
|
|
@@ -162,7 +162,7 @@ function WebviewOnrampPaymentInner({
|
|
|
162
162
|
const [createdOrder, setCreatedOrder] = useState<components["schemas"]["Order"] | null>(null);
|
|
163
163
|
const orderCreationAttempted = useRef(false);
|
|
164
164
|
|
|
165
|
-
const { geoData, stripeWeb2Support, isLoading: isLoadingGeoOnramp } = useGeoOnrampOptions(
|
|
165
|
+
const { geoData, stripeWeb2Support, isLoading: isLoadingGeoOnramp } = useGeoOnrampOptions(srcAmountOnRamp);
|
|
166
166
|
|
|
167
167
|
const { createOrder, isCreatingOrder } = useAnyspendCreateOnrampOrder({
|
|
168
168
|
onSuccess: data => {
|
|
@@ -175,7 +175,6 @@ function WebviewOnrampPaymentInner({
|
|
|
175
175
|
});
|
|
176
176
|
|
|
177
177
|
const { clientSecret, isLoadingStripeClientSecret } = useStripeClientSecret(
|
|
178
|
-
true,
|
|
179
178
|
createdOrder?.stripePaymentIntentId || "",
|
|
180
179
|
);
|
|
181
180
|
|
|
@@ -203,7 +202,6 @@ function WebviewOnrampPaymentInner({
|
|
|
203
202
|
};
|
|
204
203
|
|
|
205
204
|
createOrder({
|
|
206
|
-
isMainnet: true,
|
|
207
205
|
recipientAddress,
|
|
208
206
|
orderType: "swap",
|
|
209
207
|
dstChain: getDstToken().chainId,
|
|
@@ -43,7 +43,6 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
|
|
|
43
43
|
const { mutate: createOrder, isPending } = useMutation({
|
|
44
44
|
mutationFn: async (params: CreateOnrampOrderParams) => {
|
|
45
45
|
const {
|
|
46
|
-
isMainnet,
|
|
47
46
|
recipientAddress,
|
|
48
47
|
orderType,
|
|
49
48
|
dstChain,
|
|
@@ -71,7 +70,6 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
|
|
|
71
70
|
const srcAmountOnRampInWei = parseUnits(srcFiatAmount, USDC_BASE.decimals);
|
|
72
71
|
|
|
73
72
|
return await anyspendService.createOrder({
|
|
74
|
-
isMainnet,
|
|
75
73
|
recipientAddress: normalizeAddress(recipientAddress),
|
|
76
74
|
type: orderType,
|
|
77
75
|
srcChain,
|
|
@@ -7,7 +7,6 @@ import { useMutation } from "@tanstack/react-query";
|
|
|
7
7
|
import { useMemo } from "react";
|
|
8
8
|
|
|
9
9
|
export type CreateOrderParams = {
|
|
10
|
-
isMainnet: boolean;
|
|
11
10
|
recipientAddress: string;
|
|
12
11
|
orderType: components["schemas"]["Order"]["type"];
|
|
13
12
|
srcChain: number;
|
|
@@ -42,21 +41,10 @@ export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreate
|
|
|
42
41
|
};
|
|
43
42
|
const { mutate: createOrder, isPending } = useMutation({
|
|
44
43
|
mutationFn: async (params: CreateOrderParams) => {
|
|
45
|
-
const {
|
|
46
|
-
isMainnet,
|
|
47
|
-
recipientAddress,
|
|
48
|
-
orderType,
|
|
49
|
-
srcChain,
|
|
50
|
-
dstChain,
|
|
51
|
-
srcToken,
|
|
52
|
-
dstToken,
|
|
53
|
-
srcAmount,
|
|
54
|
-
creatorAddress,
|
|
55
|
-
} = params;
|
|
44
|
+
const { recipientAddress, orderType, srcChain, dstChain, srcToken, dstToken, srcAmount, creatorAddress } = params;
|
|
56
45
|
|
|
57
46
|
try {
|
|
58
47
|
return await anyspendService.createOrder({
|
|
59
|
-
isMainnet,
|
|
60
48
|
recipientAddress: normalizeAddress(recipientAddress),
|
|
61
49
|
type: orderType,
|
|
62
50
|
srcChain,
|
|
@@ -27,7 +27,7 @@ function customDeepEqual(oldData: any, newData: any): boolean {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// Hook to fetch and auto-refresh order status and transaction details
|
|
30
|
-
export function useAnyspendOrderAndTransactions(
|
|
30
|
+
export function useAnyspendOrderAndTransactions(orderId: string | undefined) {
|
|
31
31
|
const selectFn = useCallback((data: any) => {
|
|
32
32
|
if (!data) return undefined;
|
|
33
33
|
return data;
|
|
@@ -35,7 +35,7 @@ export function useAnyspendOrderAndTransactions(isMainnet: boolean, orderId: str
|
|
|
35
35
|
|
|
36
36
|
const { data, isLoading, refetch, error } = useQuery<GetOrderAndTxsResponse>({
|
|
37
37
|
queryKey: ["getAnyspendOrderAndTransactions", orderId],
|
|
38
|
-
queryFn: () => anyspendService.getOrderAndTransactions(
|
|
38
|
+
queryFn: () => anyspendService.getOrderAndTransactions(orderId!),
|
|
39
39
|
enabled: !!orderId,
|
|
40
40
|
refetchInterval: 3000,
|
|
41
41
|
staleTime: 1000,
|
|
@@ -2,12 +2,7 @@ import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
|
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
|
|
5
|
-
export function useAnyspendOrderHistory(
|
|
6
|
-
isMainnet: boolean,
|
|
7
|
-
creatorAddress: string | undefined,
|
|
8
|
-
limit = 100,
|
|
9
|
-
offset = 0,
|
|
10
|
-
) {
|
|
5
|
+
export function useAnyspendOrderHistory(creatorAddress: string | undefined, limit = 100, offset = 0) {
|
|
11
6
|
const {
|
|
12
7
|
data: rawData = [],
|
|
13
8
|
isLoading,
|
|
@@ -16,7 +11,7 @@ export function useAnyspendOrderHistory(
|
|
|
16
11
|
} = useQuery({
|
|
17
12
|
queryKey: ["getOrderHistory", creatorAddress, limit, offset],
|
|
18
13
|
queryFn: async () => {
|
|
19
|
-
const response = await anyspendService.getOrderHistory(
|
|
14
|
+
const response = await anyspendService.getOrderHistory(creatorAddress, limit, offset);
|
|
20
15
|
return response.data;
|
|
21
16
|
},
|
|
22
17
|
});
|
|
@@ -6,7 +6,6 @@ import { GetQuoteRequest, GetQuoteResponse } from "../../types/api_req_res";
|
|
|
6
6
|
/**
|
|
7
7
|
* React hook to fetch the price or rate for a relay swap using Anyspend.
|
|
8
8
|
*
|
|
9
|
-
* @param isMainnet - Whether to use mainnet or testnet endpoints.
|
|
10
9
|
* @param req - The request object containing source/destination chain, token addresses, and amount/price.
|
|
11
10
|
* @remarks The query is enabled only if all required fields in `req` are present and the amount/price is non-zero.
|
|
12
11
|
*/
|
|
@@ -16,11 +15,11 @@ export type UseAnyspendQuoteResult = {
|
|
|
16
15
|
getAnyspendQuoteError: Error | null;
|
|
17
16
|
refetchAnyspendQuote: () => void;
|
|
18
17
|
};
|
|
19
|
-
export function useAnyspendQuote(
|
|
18
|
+
export function useAnyspendQuote(req: GetQuoteRequest): UseAnyspendQuoteResult {
|
|
20
19
|
const { data, isLoading, refetch, error } = useQuery({
|
|
21
|
-
queryKey: ["useAnyspendQuote",
|
|
20
|
+
queryKey: ["useAnyspendQuote", JSON.stringify(req)],
|
|
22
21
|
queryFn: (): Promise<GetQuoteResponse> => {
|
|
23
|
-
return anyspendService.getQuote(
|
|
22
|
+
return anyspendService.getQuote(req);
|
|
24
23
|
},
|
|
25
24
|
enabled: Boolean(
|
|
26
25
|
req.srcChain &&
|
|
@@ -2,14 +2,14 @@ import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
|
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
|
|
5
|
-
export function useAnyspendTokenList(
|
|
5
|
+
export function useAnyspendTokenList(chainId: number, query: string) {
|
|
6
6
|
const {
|
|
7
7
|
data = [],
|
|
8
8
|
isLoading,
|
|
9
9
|
refetch,
|
|
10
10
|
} = useQuery({
|
|
11
11
|
queryKey: ["getAnyspendTokenList", chainId, query],
|
|
12
|
-
queryFn: () => anyspendService.getTokenList(
|
|
12
|
+
queryFn: () => anyspendService.getTokenList(chainId, query),
|
|
13
13
|
enabled: true,
|
|
14
14
|
});
|
|
15
15
|
|
|
@@ -3,15 +3,10 @@ import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
|
|
|
3
3
|
import { useQuery } from "@tanstack/react-query";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
|
|
6
|
-
export function useCoinbaseOnrampOptions(
|
|
7
|
-
isMainnet: boolean,
|
|
8
|
-
country?: string,
|
|
9
|
-
visitorData?: VisitorData,
|
|
10
|
-
isLoadingVisitorData?: boolean,
|
|
11
|
-
) {
|
|
6
|
+
export function useCoinbaseOnrampOptions(country?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean) {
|
|
12
7
|
const { data, isLoading, error, refetch } = useQuery({
|
|
13
|
-
queryKey: ["getCoinbaseOnrampOptions",
|
|
14
|
-
queryFn: () => anyspendService.getCoinbaseOnrampOptions(
|
|
8
|
+
queryKey: ["getCoinbaseOnrampOptions", country, visitorData],
|
|
9
|
+
queryFn: () => anyspendService.getCoinbaseOnrampOptions(country!, visitorData),
|
|
15
10
|
enabled: Boolean(country) && !isLoadingVisitorData,
|
|
16
11
|
});
|
|
17
12
|
|
|
@@ -5,7 +5,7 @@ import { useCoinbaseOnrampOptions } from "./useCoinbaseOnrampOptions";
|
|
|
5
5
|
import { useGetGeo } from "./useGetGeo";
|
|
6
6
|
import { useStripeSupport } from "./useStripeSupport";
|
|
7
7
|
|
|
8
|
-
export function useGeoOnrampOptions(
|
|
8
|
+
export function useGeoOnrampOptions(srcFiatAmount: string) {
|
|
9
9
|
// Get fingerprint data
|
|
10
10
|
const { data: fpData, isLoading: isLoadingVisitorData } = useVisitorData(
|
|
11
11
|
{ extendedResult: true },
|
|
@@ -19,9 +19,8 @@ export function useGeoOnrampOptions(isMainnet: boolean, srcFiatAmount: string) {
|
|
|
19
19
|
// Use existing hooks
|
|
20
20
|
const { geoData, loading: isLoadingGeo, error: geoError } = useGetGeo();
|
|
21
21
|
const { coinbaseOnrampOptions, isLoadingCoinbaseOnrampOptions, coinbaseOnrampOptionsError } =
|
|
22
|
-
useCoinbaseOnrampOptions(
|
|
22
|
+
useCoinbaseOnrampOptions(geoData?.country, visitorData);
|
|
23
23
|
const { stripeWeb2Support, isLoadingStripeSupport, stripeSupportError } = useStripeSupport(
|
|
24
|
-
isMainnet,
|
|
25
24
|
srcFiatAmount,
|
|
26
25
|
visitorData,
|
|
27
26
|
);
|
|
@@ -2,10 +2,10 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
|
|
4
4
|
|
|
5
|
-
export function useStripeClientSecret(
|
|
5
|
+
export function useStripeClientSecret(paymentIntentId: string) {
|
|
6
6
|
const { data, isLoading, error, refetch } = useQuery({
|
|
7
|
-
queryKey: ["stripeClientSecret",
|
|
8
|
-
queryFn: () => anyspendService.getStripeClientSecret(
|
|
7
|
+
queryKey: ["stripeClientSecret", paymentIntentId],
|
|
8
|
+
queryFn: () => anyspendService.getStripeClientSecret(paymentIntentId),
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
return useMemo(
|
|
@@ -3,15 +3,10 @@ import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
|
|
|
3
3
|
import { useQuery } from "@tanstack/react-query";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
|
|
6
|
-
export function useStripeSupport(
|
|
7
|
-
isMainnet: boolean,
|
|
8
|
-
usdAmount?: string,
|
|
9
|
-
visitorData?: VisitorData,
|
|
10
|
-
isLoadingVisitorData?: boolean,
|
|
11
|
-
) {
|
|
6
|
+
export function useStripeSupport(usdAmount?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean) {
|
|
12
7
|
const { data, isLoading, error, refetch } = useQuery({
|
|
13
|
-
queryKey: ["useStripeSupport",
|
|
14
|
-
queryFn: () => anyspendService.checkStripeSupport(
|
|
8
|
+
queryKey: ["useStripeSupport", usdAmount, visitorData?.requestId, visitorData?.visitorId],
|
|
9
|
+
queryFn: () => anyspendService.checkStripeSupport(usdAmount, visitorData),
|
|
15
10
|
enabled: !isLoadingVisitorData,
|
|
16
11
|
});
|
|
17
12
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ANYSPEND_MAINNET_BASE_URL
|
|
1
|
+
import { ANYSPEND_MAINNET_BASE_URL } from "@b3dotfun/sdk/anyspend/constants";
|
|
2
2
|
import { OnrampOptions } from "@b3dotfun/sdk/anyspend/react";
|
|
3
3
|
import { getNativeToken, isNativeToken } from "@b3dotfun/sdk/anyspend/utils";
|
|
4
4
|
import invariant from "invariant";
|
|
@@ -18,28 +18,18 @@ import { VisitorData } from "../types/fingerprint";
|
|
|
18
18
|
|
|
19
19
|
// Service functions
|
|
20
20
|
export const anyspendService = {
|
|
21
|
-
getTokenList: async (
|
|
22
|
-
|
|
23
|
-
chainId: number,
|
|
24
|
-
query: string,
|
|
25
|
-
): Promise<components["schemas"]["Token"][]> => {
|
|
26
|
-
const response = await fetch(
|
|
27
|
-
`${isMainnet ? ANYSPEND_MAINNET_BASE_URL : ANYSPEND_TESTNET_BASE_URL}/chains/${chainId}/tokens?limit=100&term=${query}`,
|
|
28
|
-
);
|
|
21
|
+
getTokenList: async (chainId: number, query: string): Promise<components["schemas"]["Token"][]> => {
|
|
22
|
+
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/chains/${chainId}/tokens?limit=100&term=${query}`);
|
|
29
23
|
const body: GetTokenListResponse = await response.json();
|
|
30
24
|
invariant(response.status === 200, `Failed to fetch token list for chain ${chainId}`);
|
|
31
25
|
return body.data;
|
|
32
26
|
},
|
|
33
27
|
|
|
34
|
-
getToken: async (
|
|
35
|
-
isMainnet: boolean,
|
|
36
|
-
chainId: number,
|
|
37
|
-
tokenAddress: string,
|
|
38
|
-
): Promise<components["schemas"]["Token"]> => {
|
|
28
|
+
getToken: async (chainId: number, tokenAddress: string): Promise<components["schemas"]["Token"]> => {
|
|
39
29
|
if (isNativeToken(tokenAddress)) {
|
|
40
30
|
return getNativeToken(chainId);
|
|
41
31
|
}
|
|
42
|
-
const tokenList = await anyspendService.getTokenList(
|
|
32
|
+
const tokenList = await anyspendService.getTokenList(chainId, tokenAddress);
|
|
43
33
|
const token = tokenList.find(
|
|
44
34
|
(t: components["schemas"]["Token"]) => t.address.toLowerCase() === tokenAddress.toLowerCase(),
|
|
45
35
|
);
|
|
@@ -49,8 +39,8 @@ export const anyspendService = {
|
|
|
49
39
|
return token;
|
|
50
40
|
},
|
|
51
41
|
|
|
52
|
-
getQuote: async (
|
|
53
|
-
const url = `${
|
|
42
|
+
getQuote: async (req: GetQuoteRequest): Promise<GetQuoteResponse> => {
|
|
43
|
+
const url = `${ANYSPEND_MAINNET_BASE_URL}/orders/quote`;
|
|
54
44
|
const response = await fetch(url, {
|
|
55
45
|
method: "POST",
|
|
56
46
|
headers: {
|
|
@@ -65,7 +55,6 @@ export const anyspendService = {
|
|
|
65
55
|
|
|
66
56
|
// Order related
|
|
67
57
|
createOrder: async ({
|
|
68
|
-
isMainnet,
|
|
69
58
|
recipientAddress,
|
|
70
59
|
type,
|
|
71
60
|
srcChain,
|
|
@@ -80,7 +69,6 @@ export const anyspendService = {
|
|
|
80
69
|
partnerId,
|
|
81
70
|
visitorData,
|
|
82
71
|
}: {
|
|
83
|
-
isMainnet: boolean;
|
|
84
72
|
recipientAddress: string;
|
|
85
73
|
type: string;
|
|
86
74
|
srcChain: number;
|
|
@@ -95,7 +83,7 @@ export const anyspendService = {
|
|
|
95
83
|
partnerId?: string;
|
|
96
84
|
visitorData?: VisitorData;
|
|
97
85
|
}) => {
|
|
98
|
-
const response = await fetch(`${
|
|
86
|
+
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/orders`, {
|
|
99
87
|
method: "POST",
|
|
100
88
|
headers: {
|
|
101
89
|
"Content-Type": "application/json",
|
|
@@ -122,16 +110,13 @@ export const anyspendService = {
|
|
|
122
110
|
return data;
|
|
123
111
|
},
|
|
124
112
|
|
|
125
|
-
getOrderAndTransactions: async (
|
|
126
|
-
const response = await fetch(
|
|
127
|
-
`${isMainnet ? ANYSPEND_MAINNET_BASE_URL : ANYSPEND_TESTNET_BASE_URL}/orders/${orderId}`,
|
|
128
|
-
);
|
|
113
|
+
getOrderAndTransactions: async (orderId: string | undefined): Promise<GetOrderAndTxsResponse> => {
|
|
114
|
+
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/orders/${orderId}`);
|
|
129
115
|
const data: GetOrderAndTxsResponse = await response.json();
|
|
130
116
|
return data;
|
|
131
117
|
},
|
|
132
118
|
|
|
133
119
|
getOrderHistory: async (
|
|
134
|
-
isMainnet: boolean,
|
|
135
120
|
creatorAddress: string | undefined,
|
|
136
121
|
limit = 100,
|
|
137
122
|
offset = 0,
|
|
@@ -143,15 +128,12 @@ export const anyspendService = {
|
|
|
143
128
|
if (creatorAddress) {
|
|
144
129
|
params.append("creatorAddress", creatorAddress);
|
|
145
130
|
}
|
|
146
|
-
const response = await fetch(
|
|
147
|
-
`${isMainnet ? ANYSPEND_MAINNET_BASE_URL : ANYSPEND_TESTNET_BASE_URL}/orders?${params.toString()}`,
|
|
148
|
-
);
|
|
131
|
+
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/orders?${params.toString()}`);
|
|
149
132
|
const data: GetOrderHistoryResponse = await response.json();
|
|
150
133
|
return data;
|
|
151
134
|
},
|
|
152
135
|
|
|
153
136
|
getCoinbaseOnrampOptions: async (
|
|
154
|
-
isMainnet: boolean,
|
|
155
137
|
country: string,
|
|
156
138
|
visitorData?: VisitorData,
|
|
157
139
|
): Promise<GetCoinbaseOnrampOptionsResponse> => {
|
|
@@ -161,39 +143,31 @@ export const anyspendService = {
|
|
|
161
143
|
...(visitorData?.requestId && { requestId: visitorData.requestId }),
|
|
162
144
|
...(visitorData?.visitorId && { fingerprintId: visitorData.visitorId }),
|
|
163
145
|
});
|
|
164
|
-
const response = await fetch(
|
|
165
|
-
`${isMainnet ? ANYSPEND_MAINNET_BASE_URL : ANYSPEND_TESTNET_BASE_URL}/onramp/coinbase/options?${params.toString()}`,
|
|
166
|
-
);
|
|
146
|
+
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/onramp/coinbase/options?${params.toString()}`);
|
|
167
147
|
const data: GetCoinbaseOnrampOptionsResponse = await response.json();
|
|
168
148
|
return data;
|
|
169
149
|
},
|
|
170
150
|
|
|
171
151
|
checkStripeSupport: async (
|
|
172
|
-
isMainnet: boolean,
|
|
173
152
|
usdAmount?: string,
|
|
174
153
|
visitorData?: VisitorData,
|
|
175
154
|
): Promise<{ stripeOnramp: boolean; stripeWeb2: components["schemas"]["StripeWeb2Support"] }> => {
|
|
176
155
|
const params = new URLSearchParams({
|
|
177
156
|
usdAmount: usdAmount || "",
|
|
178
157
|
});
|
|
179
|
-
const response = await fetch(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
...(visitorData?.requestId && { "X-Fingerprint-Request-Id": visitorData.requestId }),
|
|
184
|
-
...(visitorData?.visitorId && { "X-Fingerprint-Visitor-Id": visitorData.visitorId }),
|
|
185
|
-
},
|
|
158
|
+
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/onramp/stripe/supported?${params.toString()}`, {
|
|
159
|
+
headers: {
|
|
160
|
+
...(visitorData?.requestId && { "X-Fingerprint-Request-Id": visitorData.requestId }),
|
|
161
|
+
...(visitorData?.visitorId && { "X-Fingerprint-Visitor-Id": visitorData.visitorId }),
|
|
186
162
|
},
|
|
187
|
-
);
|
|
163
|
+
});
|
|
188
164
|
const data: GetStripeSupportedResponse = await response.json();
|
|
189
165
|
invariant(response.status === 200, "Failed to check Stripe support");
|
|
190
166
|
return data.data;
|
|
191
167
|
},
|
|
192
168
|
|
|
193
|
-
getStripeClientSecret: async (
|
|
194
|
-
const response = await fetch(
|
|
195
|
-
`${isMainnet ? ANYSPEND_MAINNET_BASE_URL : ANYSPEND_TESTNET_BASE_URL}/stripe/clientSecret?paymentIntentId=${paymentIntentId}`,
|
|
196
|
-
);
|
|
169
|
+
getStripeClientSecret: async (paymentIntentId: string): Promise<string | null> => {
|
|
170
|
+
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/stripe/clientSecret?paymentIntentId=${paymentIntentId}`);
|
|
197
171
|
const data: GetStripeClientSecret = await response.json();
|
|
198
172
|
invariant(response.status === 200, "Failed to get Stripe client secret");
|
|
199
173
|
return data.data;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
OrderHistory,
|
|
10
10
|
} from "@b3dotfun/sdk/anyspend/react";
|
|
11
11
|
import { useIsMobile, useModalStore } from "@b3dotfun/sdk/global-account/react";
|
|
12
|
+
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
12
13
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
13
14
|
import { useB3 } from "./B3Provider/useB3";
|
|
14
15
|
import { ManageAccount } from "./ManageAccount/ManageAccount";
|
|
@@ -25,47 +26,49 @@ export function B3DynamicModal() {
|
|
|
25
26
|
const { theme } = useB3();
|
|
26
27
|
const isMobile = useIsMobile();
|
|
27
28
|
|
|
28
|
-
let contentClass = `b3-modal ${theme === "dark" ? "dark" : ""}`;
|
|
29
29
|
let hideCloseButton = false;
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
// Define arrays for different modal type groups
|
|
32
|
+
const fullWidthTypes = [
|
|
33
|
+
"anySpend",
|
|
34
|
+
"anySpendNft",
|
|
35
|
+
"anySpendJoinTournament",
|
|
36
|
+
"anySpendFundTournament",
|
|
37
|
+
"anySpendStakeB3",
|
|
38
|
+
"anySpendBuySpin",
|
|
39
|
+
"anySpendOrderHistory",
|
|
40
|
+
"signInWithB3",
|
|
41
|
+
"anySpendSignatureMint",
|
|
42
|
+
"anySpendBondKit",
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const freestyleTypes = [
|
|
46
|
+
"anySpendNft",
|
|
47
|
+
"anySpendJoinTournament",
|
|
48
|
+
"anySpendFundTournament",
|
|
49
|
+
"anySpendStakeB3",
|
|
50
|
+
"anySpendBuySpin",
|
|
51
|
+
"anySpendSignatureMint",
|
|
52
|
+
"anySpendBondKit",
|
|
53
|
+
];
|
|
47
54
|
|
|
48
|
-
if
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"anySpendJoinTournament",
|
|
52
|
-
"anySpendFundTournament",
|
|
53
|
-
"anySpendStakeB3",
|
|
54
|
-
"anySpendBuySpin",
|
|
55
|
-
"anySpendSignatureMint",
|
|
56
|
-
"anySpendBondKit",
|
|
57
|
-
].find(type => contentType?.type === type)
|
|
58
|
-
) {
|
|
59
|
-
// Due to the dynamic of (Pay with crypto),(Pay with fiat), we want the height fixed to 90dvh but still scrollable.
|
|
60
|
-
// NOTE: Just leave it here in case we want the fixed height
|
|
61
|
-
// contentClass += " min-h-[90dvh] b3-modal-freestyle";
|
|
62
|
-
contentClass += " b3-modal-freestyle";
|
|
55
|
+
// Check if current content type is in freestyle types
|
|
56
|
+
const isFreestyleType = freestyleTypes.includes(contentType?.type as string);
|
|
57
|
+
if (isFreestyleType) {
|
|
63
58
|
hideCloseButton = true;
|
|
64
59
|
}
|
|
65
60
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
// Build content class using cn utility
|
|
62
|
+
// eslint-disable-next-line tailwindcss/no-custom-classname
|
|
63
|
+
const contentClass = cn(
|
|
64
|
+
"b3-modal",
|
|
65
|
+
theme === "dark" && "dark",
|
|
66
|
+
fullWidthTypes.includes(contentType?.type as string) && "w-full",
|
|
67
|
+
isFreestyleType && "b3-modal-freestyle",
|
|
68
|
+
contentType?.type === "signInWithB3" && "p-0",
|
|
69
|
+
contentType?.type === "anySpend" && "md:px-6",
|
|
70
|
+
contentType?.type === "transak" && "transak-modal",
|
|
71
|
+
);
|
|
69
72
|
|
|
70
73
|
debug("contentType", contentType);
|
|
71
74
|
const renderContent = () => {
|
|
@@ -113,17 +116,41 @@ export function B3DynamicModal() {
|
|
|
113
116
|
|
|
114
117
|
return (
|
|
115
118
|
<ModalComponent open={isOpen} onOpenChange={setB3ModalOpen}>
|
|
116
|
-
<ModalContent
|
|
119
|
+
<ModalContent
|
|
120
|
+
className={cn(
|
|
121
|
+
contentClass,
|
|
122
|
+
"rounded-2xl bg-white shadow-xl dark:bg-gray-900",
|
|
123
|
+
"border border-gray-200 dark:border-gray-800",
|
|
124
|
+
"mx-auto w-full max-w-md",
|
|
125
|
+
"sm:max-w-lg",
|
|
126
|
+
)}
|
|
127
|
+
hideCloseButton={hideCloseButton}
|
|
128
|
+
>
|
|
117
129
|
<ModalTitle className="sr-only hidden">{contentType?.type || "Modal"}</ModalTitle>
|
|
118
130
|
<ModalDescription className="sr-only hidden">{contentType?.type || "Modal Body"}</ModalDescription>
|
|
119
131
|
<div className="no-scrollbar max-h-[90dvh] overflow-auto sm:max-h-[80dvh]">
|
|
120
132
|
{history.length > 0 && contentType?.showBackButton && (
|
|
121
133
|
<button
|
|
122
134
|
onClick={navigateBack}
|
|
123
|
-
className="
|
|
135
|
+
className="flex items-center gap-2 px-6 py-4 text-gray-600 transition-colors hover:text-gray-900 dark:text-gray-400 dark:hover:text-white"
|
|
124
136
|
>
|
|
125
|
-
<
|
|
126
|
-
|
|
137
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
138
|
+
<path
|
|
139
|
+
d="M15.8337 10H4.16699"
|
|
140
|
+
stroke="currentColor"
|
|
141
|
+
strokeWidth="1.5"
|
|
142
|
+
strokeLinecap="round"
|
|
143
|
+
strokeLinejoin="round"
|
|
144
|
+
/>
|
|
145
|
+
<path
|
|
146
|
+
d="M10.0003 15.8334L4.16699 10L10.0003 4.16669"
|
|
147
|
+
stroke="currentColor"
|
|
148
|
+
strokeWidth="1.5"
|
|
149
|
+
strokeLinecap="round"
|
|
150
|
+
strokeLinejoin="round"
|
|
151
|
+
/>
|
|
152
|
+
</svg>
|
|
153
|
+
<span className="text-sm font-medium">Back</span>
|
|
127
154
|
</button>
|
|
128
155
|
)}
|
|
129
156
|
{renderContent()}
|
|
@@ -24,14 +24,11 @@ const queryClient = new QueryClient();
|
|
|
24
24
|
* Main B3Provider component
|
|
25
25
|
*/
|
|
26
26
|
export function B3Provider({
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
-
isMainnetAnySpend = true,
|
|
29
27
|
theme = "light",
|
|
30
28
|
children,
|
|
31
29
|
accountOverride,
|
|
32
30
|
environment,
|
|
33
31
|
}: {
|
|
34
|
-
isMainnetAnySpend?: boolean;
|
|
35
32
|
theme: "light" | "dark";
|
|
36
33
|
children: React.ReactNode;
|
|
37
34
|
accountOverride?: Account;
|
|
@@ -41,7 +38,7 @@ export function B3Provider({
|
|
|
41
38
|
<QueryClientProvider client={queryClient}>
|
|
42
39
|
<ThirdwebProvider>
|
|
43
40
|
<InnerProvider accountOverride={accountOverride} environment={environment} theme={theme}>
|
|
44
|
-
{/* <RelayKitProviderWrapper
|
|
41
|
+
{/* <RelayKitProviderWrapper> */}
|
|
45
42
|
{children}
|
|
46
43
|
{/* </RelayKitProviderWrapper> */}
|
|
47
44
|
</InnerProvider>
|
|
@@ -41,7 +41,6 @@ const queryClient = new QueryClient();
|
|
|
41
41
|
* Main B3Provider component
|
|
42
42
|
*/
|
|
43
43
|
export function B3Provider({
|
|
44
|
-
isMainnetAnySpend = true,
|
|
45
44
|
theme = "light",
|
|
46
45
|
children,
|
|
47
46
|
accountOverride,
|
|
@@ -50,7 +49,6 @@ export function B3Provider({
|
|
|
50
49
|
simDuneApiKey,
|
|
51
50
|
toaster,
|
|
52
51
|
}: {
|
|
53
|
-
isMainnetAnySpend?: boolean;
|
|
54
52
|
theme: "light" | "dark";
|
|
55
53
|
children: React.ReactNode;
|
|
56
54
|
accountOverride?: Account;
|
|
@@ -73,7 +71,7 @@ export function B3Provider({
|
|
|
73
71
|
theme={theme}
|
|
74
72
|
automaticallySetFirstEoa={!!automaticallySetFirstEoa}
|
|
75
73
|
>
|
|
76
|
-
<RelayKitProviderWrapper
|
|
74
|
+
<RelayKitProviderWrapper simDuneApiKey={simDuneApiKey}>
|
|
77
75
|
{children}
|
|
78
76
|
{/* For the modal https://github.com/b3-fun/b3/blob/main/packages/sdk/src/global-account/react/components/ui/dialog.tsx#L46 */}
|
|
79
77
|
<StyleRoot id="b3-root" />
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { RelayKitProvider } from "@reservoir0x/relay-kit-ui";
|
|
2
|
-
import { fetchChainConfigs, MAINNET_RELAY_API, RelayChain
|
|
2
|
+
import { fetchChainConfigs, MAINNET_RELAY_API, RelayChain } from "@reservoir0x/relay-sdk";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
|
|
5
5
|
export function RelayKitProviderWrapper({
|
|
6
|
-
isMainnet,
|
|
7
6
|
children,
|
|
8
7
|
simDuneApiKey,
|
|
9
8
|
}: {
|
|
10
|
-
isMainnet: boolean;
|
|
11
9
|
children: React.ReactNode;
|
|
12
10
|
simDuneApiKey?: string;
|
|
13
11
|
}) {
|
|
@@ -15,16 +13,16 @@ export function RelayKitProviderWrapper({
|
|
|
15
13
|
|
|
16
14
|
useEffect(() => {
|
|
17
15
|
const fetchChains = async () => {
|
|
18
|
-
const chains = await fetchChainConfigs(
|
|
16
|
+
const chains = await fetchChainConfigs(MAINNET_RELAY_API);
|
|
19
17
|
setRelayChains(chains);
|
|
20
18
|
};
|
|
21
19
|
fetchChains();
|
|
22
|
-
}, [
|
|
20
|
+
}, []);
|
|
23
21
|
|
|
24
22
|
return (
|
|
25
23
|
<RelayKitProvider
|
|
26
24
|
options={{
|
|
27
|
-
baseApiUrl:
|
|
25
|
+
baseApiUrl: MAINNET_RELAY_API,
|
|
28
26
|
source: "anyspend",
|
|
29
27
|
duneConfig: {
|
|
30
28
|
apiKey: simDuneApiKey,
|