@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
|
@@ -18,7 +18,7 @@ enum OrderStatus {
|
|
|
18
18
|
// Processing States
|
|
19
19
|
SENDING_TOKEN_FROM_VAULT = "sending_token_from_vault",
|
|
20
20
|
RELAY = "relay",
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
// Success States
|
|
23
23
|
EXECUTED = "executed",
|
|
24
24
|
|
|
@@ -90,13 +90,13 @@ function PaymentComponent() {
|
|
|
90
90
|
const { createOrder, isCreatingOrder } = useAnyspendCreateOrder({
|
|
91
91
|
onError: (error) => {
|
|
92
92
|
console.error("Payment failed:", error);
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
// Handle specific errors
|
|
95
95
|
switch (error.message) {
|
|
96
96
|
case "INSUFFICIENT_BALANCE":
|
|
97
97
|
setError("Insufficient balance. Please add funds to your wallet.");
|
|
98
98
|
break;
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
case "SLIPPAGE":
|
|
101
101
|
if (retryCount < 3) {
|
|
102
102
|
setError("Price moved unfavorably. Retrying...");
|
|
@@ -108,16 +108,16 @@ function PaymentComponent() {
|
|
|
108
108
|
setError("Price too volatile. Please try again later.");
|
|
109
109
|
}
|
|
110
110
|
break;
|
|
111
|
-
|
|
111
|
+
|
|
112
112
|
case "NETWORK_ERROR":
|
|
113
113
|
setError("Network issue. Please check your connection and try again.");
|
|
114
114
|
break;
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
case "QUOTE_EXPIRED":
|
|
117
117
|
setError("Price quote expired. Getting fresh quote...");
|
|
118
118
|
refreshQuote();
|
|
119
119
|
break;
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
default:
|
|
122
122
|
setError("Payment failed. Please try again or contact support.");
|
|
123
123
|
}
|
|
@@ -129,7 +129,7 @@ function PaymentComponent() {
|
|
|
129
129
|
timestamp: new Date().toISOString(),
|
|
130
130
|
});
|
|
131
131
|
},
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
onSuccess: () => {
|
|
134
134
|
setError(null);
|
|
135
135
|
setRetryCount(0);
|
|
@@ -145,9 +145,9 @@ function PaymentComponent() {
|
|
|
145
145
|
<button onClick={() => setError(null)}>Dismiss</button>
|
|
146
146
|
</div>
|
|
147
147
|
)}
|
|
148
|
-
|
|
149
|
-
<button
|
|
150
|
-
onClick={handlePayment}
|
|
148
|
+
|
|
149
|
+
<button
|
|
150
|
+
onClick={handlePayment}
|
|
151
151
|
disabled={isCreatingOrder}
|
|
152
152
|
>
|
|
153
153
|
{isCreatingOrder ? "Processing..." : "Pay Now"}
|
|
@@ -163,8 +163,8 @@ function PaymentComponent() {
|
|
|
163
163
|
import { useAnyspendOrderAndTransactions } from "@b3dotfun/sdk/anyspend";
|
|
164
164
|
|
|
165
165
|
function OrderStatusMonitor({ orderId }: { orderId: string }) {
|
|
166
|
-
const { orderAndTransactions, getOrderAndTransactionsError } =
|
|
167
|
-
useAnyspendOrderAndTransactions(
|
|
166
|
+
const { orderAndTransactions, getOrderAndTransactionsError } =
|
|
167
|
+
useAnyspendOrderAndTransactions(orderId);
|
|
168
168
|
|
|
169
169
|
if (getOrderAndTransactionsError) {
|
|
170
170
|
return (
|
|
@@ -194,7 +194,7 @@ function OrderStatusMonitor({ orderId }: { orderId: string }) {
|
|
|
194
194
|
<h3>⏳ Waiting for payment confirmation</h3>
|
|
195
195
|
<p>This usually takes 1-2 minutes. Please don't close this window.</p>
|
|
196
196
|
{depositTxs.length > 0 && (
|
|
197
|
-
<a
|
|
197
|
+
<a
|
|
198
198
|
href={getExplorerUrl(depositTxs[0].txHash, depositTxs[0].chainId)}
|
|
199
199
|
target="_blank"
|
|
200
200
|
rel="noopener noreferrer"
|
|
@@ -225,7 +225,7 @@ function OrderStatusMonitor({ orderId }: { orderId: string }) {
|
|
|
225
225
|
<h3>Transaction completed successfully!</h3>
|
|
226
226
|
<p>Your order has been processed.</p>
|
|
227
227
|
{executeTx && (
|
|
228
|
-
<a
|
|
228
|
+
<a
|
|
229
229
|
href={getExplorerUrl(executeTx.txHash, executeTx.chainId)}
|
|
230
230
|
target="_blank"
|
|
231
231
|
rel="noopener noreferrer"
|
|
@@ -265,7 +265,7 @@ function OrderStatusMonitor({ orderId }: { orderId: string }) {
|
|
|
265
265
|
<h3>Refund processed</h3>
|
|
266
266
|
<p>Your payment has been refunded automatically.</p>
|
|
267
267
|
{refundTxs.length > 0 && (
|
|
268
|
-
<a
|
|
268
|
+
<a
|
|
269
269
|
href={getExplorerUrl(refundTxs[0].txHash, refundTxs[0].chainId)}
|
|
270
270
|
target="_blank"
|
|
271
271
|
rel="noopener noreferrer"
|
|
@@ -355,7 +355,7 @@ class AnySpendErrorBoundary extends Component<Props, State> {
|
|
|
355
355
|
|
|
356
356
|
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
|
357
357
|
console.error("AnySpend Error Boundary caught an error:", error, errorInfo);
|
|
358
|
-
|
|
358
|
+
|
|
359
359
|
// Report to error tracking service
|
|
360
360
|
if (typeof window !== "undefined") {
|
|
361
361
|
// Example: Sentry.captureException(error, { contexts: { errorInfo } });
|
|
@@ -370,9 +370,9 @@ class AnySpendErrorBoundary extends Component<Props, State> {
|
|
|
370
370
|
if (this.state.hasError) {
|
|
371
371
|
const FallbackComponent = this.props.fallback || DefaultErrorFallback;
|
|
372
372
|
return (
|
|
373
|
-
<FallbackComponent
|
|
374
|
-
error={this.state.error!}
|
|
375
|
-
resetError={this.resetError}
|
|
373
|
+
<FallbackComponent
|
|
374
|
+
error={this.state.error!}
|
|
375
|
+
resetError={this.resetError}
|
|
376
376
|
/>
|
|
377
377
|
);
|
|
378
378
|
}
|
|
@@ -433,42 +433,42 @@ function DiagnoseQuoteIssue() {
|
|
|
433
433
|
// Check if tokens are valid
|
|
434
434
|
const srcTokenValid = await validateToken(quoteRequest.srcTokenAddress, quoteRequest.srcChain);
|
|
435
435
|
const dstTokenValid = await validateToken(quoteRequest.dstTokenAddress, quoteRequest.dstChain);
|
|
436
|
-
|
|
436
|
+
|
|
437
437
|
if (!srcTokenValid) {
|
|
438
438
|
setDiagnosis("Source token address is invalid or not supported");
|
|
439
439
|
return;
|
|
440
440
|
}
|
|
441
|
-
|
|
441
|
+
|
|
442
442
|
if (!dstTokenValid) {
|
|
443
443
|
setDiagnosis("Destination token address is invalid or not supported");
|
|
444
444
|
return;
|
|
445
445
|
}
|
|
446
|
-
|
|
446
|
+
|
|
447
447
|
// Check if amount is within limits
|
|
448
448
|
const amount = parseFloat(quoteRequest.amount);
|
|
449
449
|
if (amount < MIN_SWAP_AMOUNT) {
|
|
450
450
|
setDiagnosis(`Amount too small. Minimum: ${MIN_SWAP_AMOUNT}`);
|
|
451
451
|
return;
|
|
452
452
|
}
|
|
453
|
-
|
|
453
|
+
|
|
454
454
|
if (amount > MAX_SWAP_AMOUNT) {
|
|
455
455
|
setDiagnosis(`Amount too large. Maximum: ${MAX_SWAP_AMOUNT}`);
|
|
456
456
|
return;
|
|
457
457
|
}
|
|
458
|
-
|
|
458
|
+
|
|
459
459
|
// Check if chain pair is supported
|
|
460
460
|
const chainPairSupported = await checkChainPairSupport(
|
|
461
|
-
quoteRequest.srcChain,
|
|
461
|
+
quoteRequest.srcChain,
|
|
462
462
|
quoteRequest.dstChain
|
|
463
463
|
);
|
|
464
|
-
|
|
464
|
+
|
|
465
465
|
if (!chainPairSupported) {
|
|
466
466
|
setDiagnosis("This chain pair is not currently supported");
|
|
467
467
|
return;
|
|
468
468
|
}
|
|
469
|
-
|
|
469
|
+
|
|
470
470
|
setDiagnosis("All checks passed. Try refreshing the quote.");
|
|
471
|
-
|
|
471
|
+
|
|
472
472
|
} catch (error) {
|
|
473
473
|
setDiagnosis(`Network error: ${error.message}`);
|
|
474
474
|
}
|
|
@@ -498,8 +498,8 @@ function DepositDiagnostics({ orderId }: { orderId: string }) {
|
|
|
498
498
|
|
|
499
499
|
const diagnoseDespositIssue = async () => {
|
|
500
500
|
try {
|
|
501
|
-
const order = await anyspendService.getOrder(
|
|
502
|
-
|
|
501
|
+
const order = await anyspendService.getOrder(orderId);
|
|
502
|
+
|
|
503
503
|
if (!order.depositAddress) {
|
|
504
504
|
setDepositDiag({
|
|
505
505
|
issue: "No deposit address generated",
|
|
@@ -507,11 +507,11 @@ function DepositDiagnostics({ orderId }: { orderId: string }) {
|
|
|
507
507
|
});
|
|
508
508
|
return;
|
|
509
509
|
}
|
|
510
|
-
|
|
510
|
+
|
|
511
511
|
// Check if payment was sent to correct address
|
|
512
512
|
const expectedAddress = order.depositAddress;
|
|
513
513
|
const userTxs = await getTransactionsToAddress(expectedAddress);
|
|
514
|
-
|
|
514
|
+
|
|
515
515
|
if (userTxs.length === 0) {
|
|
516
516
|
setDepositDiag({
|
|
517
517
|
issue: "No payment received at deposit address",
|
|
@@ -519,11 +519,11 @@ function DepositDiagnostics({ orderId }: { orderId: string }) {
|
|
|
519
519
|
});
|
|
520
520
|
return;
|
|
521
521
|
}
|
|
522
|
-
|
|
522
|
+
|
|
523
523
|
// Check if amount matches
|
|
524
524
|
const expectedAmount = order.srcAmount;
|
|
525
525
|
const receivedAmount = userTxs[0].amount;
|
|
526
|
-
|
|
526
|
+
|
|
527
527
|
if (receivedAmount !== expectedAmount) {
|
|
528
528
|
setDepositDiag({
|
|
529
529
|
issue: `Amount mismatch. Expected: ${expectedAmount}, Received: ${receivedAmount}`,
|
|
@@ -531,11 +531,11 @@ function DepositDiagnostics({ orderId }: { orderId: string }) {
|
|
|
531
531
|
});
|
|
532
532
|
return;
|
|
533
533
|
}
|
|
534
|
-
|
|
534
|
+
|
|
535
535
|
// Check transaction confirmations
|
|
536
536
|
const confirmations = await getTransactionConfirmations(userTxs[0].hash);
|
|
537
537
|
const requiredConfirmations = getRequiredConfirmations(order.srcChain);
|
|
538
|
-
|
|
538
|
+
|
|
539
539
|
if (confirmations < requiredConfirmations) {
|
|
540
540
|
setDepositDiag({
|
|
541
541
|
issue: `Waiting for confirmations: ${confirmations}/${requiredConfirmations}`,
|
|
@@ -543,12 +543,12 @@ function DepositDiagnostics({ orderId }: { orderId: string }) {
|
|
|
543
543
|
});
|
|
544
544
|
return;
|
|
545
545
|
}
|
|
546
|
-
|
|
546
|
+
|
|
547
547
|
setDepositDiag({
|
|
548
548
|
issue: "Payment detected but not processed",
|
|
549
549
|
solution: "This may be a system delay. Contact support if it persists."
|
|
550
550
|
});
|
|
551
|
-
|
|
551
|
+
|
|
552
552
|
} catch (error) {
|
|
553
553
|
setDepositDiag({
|
|
554
554
|
issue: "Unable to diagnose",
|
|
@@ -562,7 +562,7 @@ function DepositDiagnostics({ orderId }: { orderId: string }) {
|
|
|
562
562
|
<button onClick={diagnoseDespositIssue}>
|
|
563
563
|
Diagnose Deposit Issue
|
|
564
564
|
</button>
|
|
565
|
-
|
|
565
|
+
|
|
566
566
|
{depositDiag && (
|
|
567
567
|
<div className="diagnosis-result">
|
|
568
568
|
<h4>Issue: {depositDiag.issue}</h4>
|
|
@@ -651,19 +651,19 @@ function DebugInfo({ orderId }: { orderId: string }) {
|
|
|
651
651
|
userAgent: navigator.userAgent,
|
|
652
652
|
url: window.location.href,
|
|
653
653
|
orderId,
|
|
654
|
-
|
|
654
|
+
|
|
655
655
|
// Network info
|
|
656
656
|
connection: (navigator as any).connection,
|
|
657
|
-
|
|
657
|
+
|
|
658
658
|
// Order data
|
|
659
|
-
order: await anyspendService.getOrder(
|
|
660
|
-
|
|
659
|
+
order: await anyspendService.getOrder(orderId),
|
|
660
|
+
|
|
661
661
|
// Browser storage
|
|
662
662
|
localStorage: { ...localStorage },
|
|
663
|
-
|
|
663
|
+
|
|
664
664
|
// Console errors
|
|
665
665
|
recentErrors: getRecentConsoleErrors(),
|
|
666
|
-
|
|
666
|
+
|
|
667
667
|
// SDK version
|
|
668
668
|
sdkVersion: process.env.REACT_APP_SDK_VERSION,
|
|
669
669
|
};
|
|
@@ -681,7 +681,7 @@ function DebugInfo({ orderId }: { orderId: string }) {
|
|
|
681
681
|
<button onClick={collectDebugInfo}>
|
|
682
682
|
Collect Debug Info
|
|
683
683
|
</button>
|
|
684
|
-
|
|
684
|
+
|
|
685
685
|
{debugData && (
|
|
686
686
|
<div>
|
|
687
687
|
<button onClick={copyDebugInfo}>
|
|
@@ -732,4 +732,4 @@ interface BugReport {
|
|
|
732
732
|
|
|
733
733
|
- [View Installation Guide →](./installation.md)
|
|
734
734
|
- [Explore Components →](./components.md)
|
|
735
|
-
- [See Examples →](./examples.md)
|
|
735
|
+
- [See Examples →](./examples.md)
|
|
@@ -43,13 +43,13 @@ function TokenSwapPage() {
|
|
|
43
43
|
onSuccess={(txHash) => {
|
|
44
44
|
// Update user's portfolio
|
|
45
45
|
toast.success("Swap completed successfully!");
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
// Optional: Track analytics
|
|
48
48
|
analytics.track("swap_completed", {
|
|
49
49
|
txHash,
|
|
50
50
|
userAddress,
|
|
51
51
|
});
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
// Refresh user balances
|
|
54
54
|
queryClient.invalidateQueries(['user-balances', userAddress]);
|
|
55
55
|
}}
|
|
@@ -80,7 +80,7 @@ function AdvancedSwapInterface() {
|
|
|
80
80
|
amount: parseUnits(amount || "0", fromToken.decimals).toString(),
|
|
81
81
|
}), [fromToken, toToken, amount]);
|
|
82
82
|
|
|
83
|
-
const { anyspendQuote, isLoadingAnyspendQuote } = useAnyspendQuote(
|
|
83
|
+
const { anyspendQuote, isLoadingAnyspendQuote } = useAnyspendQuote(quoteRequest);
|
|
84
84
|
|
|
85
85
|
return (
|
|
86
86
|
<div className="advanced-swap">
|
|
@@ -92,12 +92,12 @@ function AdvancedSwapInterface() {
|
|
|
92
92
|
onTokenChange={setFromToken}
|
|
93
93
|
onAmountChange={setAmount}
|
|
94
94
|
/>
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
<SwapArrowButton onClick={() => {
|
|
97
97
|
setFromToken(toToken);
|
|
98
98
|
setToToken(fromToken);
|
|
99
99
|
}} />
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
<TokenInput
|
|
102
102
|
label="To"
|
|
103
103
|
token={toToken}
|
|
@@ -105,7 +105,7 @@ function AdvancedSwapInterface() {
|
|
|
105
105
|
onTokenChange={setToToken}
|
|
106
106
|
readOnly
|
|
107
107
|
/>
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
{anyspendQuote && (
|
|
110
110
|
<div className="quote-details">
|
|
111
111
|
<div>Rate: 1 {fromToken.symbol} = {anyspendQuote.rate} {toToken.symbol}</div>
|
|
@@ -114,7 +114,7 @@ function AdvancedSwapInterface() {
|
|
|
114
114
|
<div>Total: ${anyspendQuote.totalUsdCost}</div>
|
|
115
115
|
</div>
|
|
116
116
|
)}
|
|
117
|
-
|
|
117
|
+
|
|
118
118
|
<button
|
|
119
119
|
onClick={() => setIsSwapOpen(true)}
|
|
120
120
|
disabled={isLoadingAnyspendQuote || !anyspendQuote}
|
|
@@ -172,7 +172,7 @@ function NFTCard({ nft }: { nft: NFTListing }) {
|
|
|
172
172
|
<div className="price">
|
|
173
173
|
{nft.priceFormatted} {nft.currency.symbol}
|
|
174
174
|
</div>
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
{isOwned ? (
|
|
177
177
|
<div className="owned-badge">✅ Owned</div>
|
|
178
178
|
) : (
|
|
@@ -181,10 +181,10 @@ function NFTCard({ nft }: { nft: NFTListing }) {
|
|
|
181
181
|
recipientAddress={userAddress}
|
|
182
182
|
onSuccess={(txHash) => {
|
|
183
183
|
setIsOwned(true);
|
|
184
|
-
|
|
184
|
+
|
|
185
185
|
// Update user's NFT collection
|
|
186
186
|
queryClient.invalidateQueries(['user-nfts', userAddress]);
|
|
187
|
-
|
|
187
|
+
|
|
188
188
|
// Show success message with explorer link
|
|
189
189
|
toast.success(
|
|
190
190
|
<div>
|
|
@@ -224,8 +224,8 @@ function NFTMarketplace() {
|
|
|
224
224
|
<div className="marketplace">
|
|
225
225
|
<div className="nft-grid">
|
|
226
226
|
{nfts.map((nft) => (
|
|
227
|
-
<NFTCard
|
|
228
|
-
key={nft.id}
|
|
227
|
+
<NFTCard
|
|
228
|
+
key={nft.id}
|
|
229
229
|
nft={nft}
|
|
230
230
|
onSelect={(selected) => {
|
|
231
231
|
if (selected) {
|
|
@@ -237,7 +237,7 @@ function NFTMarketplace() {
|
|
|
237
237
|
/>
|
|
238
238
|
))}
|
|
239
239
|
</div>
|
|
240
|
-
|
|
240
|
+
|
|
241
241
|
{selectedNFTs.length > 0 && (
|
|
242
242
|
<div className="bulk-purchase">
|
|
243
243
|
<p>Selected: {selectedNFTs.length} NFTs</p>
|
|
@@ -267,9 +267,9 @@ function StakingPool({ pool }: { pool: StakingPool }) {
|
|
|
267
267
|
|
|
268
268
|
const stakingCalldata = useMemo(() => {
|
|
269
269
|
if (!stakeAmount) return "0x";
|
|
270
|
-
|
|
270
|
+
|
|
271
271
|
const amountWei = parseUnits(stakeAmount, pool.token.decimals);
|
|
272
|
-
|
|
272
|
+
|
|
273
273
|
return encodeFunctionData({
|
|
274
274
|
abi: stakingPoolABI,
|
|
275
275
|
functionName: "stake",
|
|
@@ -350,10 +350,10 @@ function StakingPool({ pool }: { pool: StakingPool }) {
|
|
|
350
350
|
)}
|
|
351
351
|
onSuccess={(txHash) => {
|
|
352
352
|
toast.success("Staking successful!");
|
|
353
|
-
|
|
353
|
+
|
|
354
354
|
// Update user's staking positions
|
|
355
355
|
queryClient.invalidateQueries(['staking-positions', userAddress]);
|
|
356
|
-
|
|
356
|
+
|
|
357
357
|
// Reset form
|
|
358
358
|
setStakeAmount("");
|
|
359
359
|
}}
|
|
@@ -401,7 +401,7 @@ function SpinWheel({ game }: { game: GameConfig }) {
|
|
|
401
401
|
// Listen for spin result event
|
|
402
402
|
listenForSpinResult(txHash).then((result) => {
|
|
403
403
|
setSpinHistory([result, ...spinHistory]);
|
|
404
|
-
|
|
404
|
+
|
|
405
405
|
if (result.isWinner) {
|
|
406
406
|
toast.success(`You won ${result.prize.name}!`);
|
|
407
407
|
} else {
|
|
@@ -435,7 +435,7 @@ import { AnySpendTournament } from "@b3dotfun/sdk/anyspend/react";
|
|
|
435
435
|
function TournamentCard({ tournament }: { tournament: Tournament }) {
|
|
436
436
|
const [userAddress] = useWallet();
|
|
437
437
|
const [isRegistered, setIsRegistered] = useState(false);
|
|
438
|
-
|
|
438
|
+
|
|
439
439
|
const timeUntilStart = tournament.startTime - Date.now();
|
|
440
440
|
const isStartingSoon = timeUntilStart < 60 * 60 * 1000; // 1 hour
|
|
441
441
|
|
|
@@ -460,12 +460,12 @@ function TournamentCard({ tournament }: { tournament: Tournament }) {
|
|
|
460
460
|
<h4>Prize Pool</h4>
|
|
461
461
|
<p>{tournament.prizePool} {tournament.currency.symbol}</p>
|
|
462
462
|
</div>
|
|
463
|
-
|
|
463
|
+
|
|
464
464
|
<div className="participants">
|
|
465
465
|
<h4>Participants</h4>
|
|
466
466
|
<p>{tournament.currentParticipants} / {tournament.maxParticipants}</p>
|
|
467
467
|
</div>
|
|
468
|
-
|
|
468
|
+
|
|
469
469
|
<div className="entry-fee">
|
|
470
470
|
<h4>Entry Fee</h4>
|
|
471
471
|
<p>{tournament.entryFee} {tournament.currency.symbol}</p>
|
|
@@ -484,7 +484,7 @@ function TournamentCard({ tournament }: { tournament: Tournament }) {
|
|
|
484
484
|
onSuccess={() => {
|
|
485
485
|
setIsRegistered(true);
|
|
486
486
|
toast.success("Successfully registered for tournament!");
|
|
487
|
-
|
|
487
|
+
|
|
488
488
|
// Update tournament data
|
|
489
489
|
queryClient.invalidateQueries(['tournament', tournament.id]);
|
|
490
490
|
}}
|
|
@@ -523,14 +523,14 @@ function FiatOnramp({ targetToken }: { targetToken: Token }) {
|
|
|
523
523
|
onSuccess={(txHash) => {
|
|
524
524
|
// Welcome new user
|
|
525
525
|
toast.success("Welcome to crypto! Your purchase was successful.");
|
|
526
|
-
|
|
526
|
+
|
|
527
527
|
// Track onboarding completion
|
|
528
528
|
analytics.track("onramp_completed", {
|
|
529
529
|
userAddress,
|
|
530
530
|
token: targetToken.symbol,
|
|
531
531
|
txHash,
|
|
532
532
|
});
|
|
533
|
-
|
|
533
|
+
|
|
534
534
|
// Redirect to main app
|
|
535
535
|
router.push("/dashboard");
|
|
536
536
|
}}
|
|
@@ -557,7 +557,7 @@ function OnboardingWizard() {
|
|
|
557
557
|
</div>
|
|
558
558
|
|
|
559
559
|
{step === 1 && (
|
|
560
|
-
<WalletConnectionStep
|
|
560
|
+
<WalletConnectionStep
|
|
561
561
|
onConnect={(address) => {
|
|
562
562
|
setUserAddress(address);
|
|
563
563
|
setStep(2);
|
|
@@ -647,10 +647,10 @@ function CryptoCheckout({ order }: { order: Order }) {
|
|
|
647
647
|
onSuccess={(txHash) => {
|
|
648
648
|
// Process order fulfillment
|
|
649
649
|
processOrder(order.id, txHash);
|
|
650
|
-
|
|
650
|
+
|
|
651
651
|
// Send confirmation email
|
|
652
652
|
sendOrderConfirmation(order, txHash);
|
|
653
|
-
|
|
653
|
+
|
|
654
654
|
// Redirect to success page
|
|
655
655
|
router.push(`/order-confirmation/${order.id}`);
|
|
656
656
|
}}
|
|
@@ -680,7 +680,7 @@ function PortfolioRebalancer() {
|
|
|
680
680
|
return (
|
|
681
681
|
<div className="portfolio-rebalancer">
|
|
682
682
|
<h2>Portfolio Rebalancing</h2>
|
|
683
|
-
|
|
683
|
+
|
|
684
684
|
<div className="current-allocation">
|
|
685
685
|
<h3>Current Allocation</h3>
|
|
686
686
|
<AllocationChart balances={currentBalances} />
|
|
@@ -724,4 +724,4 @@ function PortfolioRebalancer() {
|
|
|
724
724
|
|
|
725
725
|
- [Error Handling Guide →](./error-handling.md)
|
|
726
726
|
- [Components Reference →](./components.md)
|
|
727
|
-
- [Hooks Reference →](./hooks.md)
|
|
727
|
+
- [Hooks Reference →](./hooks.md)
|
|
@@ -16,14 +16,13 @@ const {
|
|
|
16
16
|
isLoadingAnyspendQuote,
|
|
17
17
|
getAnyspendQuoteError,
|
|
18
18
|
refetchAnyspendQuote
|
|
19
|
-
} = useAnyspendQuote(
|
|
19
|
+
} = useAnyspendQuote(quoteRequest);
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
#### Parameters
|
|
23
23
|
|
|
24
24
|
| Parameter | Type | Description |
|
|
25
25
|
|-----------|------|-------------|
|
|
26
|
-
| `isMainnet` | `boolean` | Use mainnet or testnet environment |
|
|
27
26
|
| `quoteRequest` | `QuoteRequest` | Quote configuration object |
|
|
28
27
|
|
|
29
28
|
#### QuoteRequest Interface
|
|
@@ -63,8 +62,8 @@ function SwapQuote() {
|
|
|
63
62
|
amount: "1000000", // 1 USDC (6 decimals)
|
|
64
63
|
};
|
|
65
64
|
|
|
66
|
-
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } =
|
|
67
|
-
useAnyspendQuote(
|
|
65
|
+
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } =
|
|
66
|
+
useAnyspendQuote(quoteRequest);
|
|
68
67
|
|
|
69
68
|
if (isLoadingAnyspendQuote) return <div>Getting best price...</div>;
|
|
70
69
|
if (getAnyspendQuoteError) return <div>Failed to get quote</div>;
|
|
@@ -138,7 +137,6 @@ function PaymentForm() {
|
|
|
138
137
|
|
|
139
138
|
const handlePayment = () => {
|
|
140
139
|
createOrder({
|
|
141
|
-
isMainnet: true,
|
|
142
140
|
recipientAddress: userWalletAddress,
|
|
143
141
|
orderType: "swap",
|
|
144
142
|
srcChain: 1,
|
|
@@ -164,8 +162,8 @@ function PaymentForm() {
|
|
|
164
162
|
};
|
|
165
163
|
|
|
166
164
|
return (
|
|
167
|
-
<button
|
|
168
|
-
onClick={handlePayment}
|
|
165
|
+
<button
|
|
166
|
+
onClick={handlePayment}
|
|
169
167
|
disabled={isCreatingOrder}
|
|
170
168
|
>
|
|
171
169
|
{isCreatingOrder ? "Processing..." : "Pay with Crypto"}
|
|
@@ -187,14 +185,13 @@ const {
|
|
|
187
185
|
orderAndTransactions,
|
|
188
186
|
isLoadingOrderAndTransactions,
|
|
189
187
|
getOrderAndTransactionsError
|
|
190
|
-
} = useAnyspendOrderAndTransactions(
|
|
188
|
+
} = useAnyspendOrderAndTransactions(orderId);
|
|
191
189
|
```
|
|
192
190
|
|
|
193
191
|
#### Parameters
|
|
194
192
|
|
|
195
193
|
| Parameter | Type | Description |
|
|
196
194
|
|-----------|------|-------------|
|
|
197
|
-
| `isMainnet` | `boolean` | Environment selection |
|
|
198
195
|
| `orderId` | `string` | Order ID to track |
|
|
199
196
|
|
|
200
197
|
#### Return Values
|
|
@@ -223,8 +220,8 @@ interface OrderWithTransactions {
|
|
|
223
220
|
|
|
224
221
|
```tsx
|
|
225
222
|
function OrderTracker({ orderId }: { orderId: string }) {
|
|
226
|
-
const { orderAndTransactions, isLoadingOrderAndTransactions } =
|
|
227
|
-
useAnyspendOrderAndTransactions(
|
|
223
|
+
const { orderAndTransactions, isLoadingOrderAndTransactions } =
|
|
224
|
+
useAnyspendOrderAndTransactions(orderId);
|
|
228
225
|
|
|
229
226
|
if (isLoadingOrderAndTransactions) {
|
|
230
227
|
return <div>Loading order status...</div>;
|
|
@@ -255,11 +252,11 @@ function OrderTracker({ orderId }: { orderId: string }) {
|
|
|
255
252
|
<div className="order-status">
|
|
256
253
|
<h2>Order #{orderId.slice(0, 8)}</h2>
|
|
257
254
|
<p>{getStatusMessage(order.status)}</p>
|
|
258
|
-
|
|
255
|
+
|
|
259
256
|
{depositTxs.length > 0 && (
|
|
260
257
|
<div>
|
|
261
258
|
<h3>Payment Transaction</h3>
|
|
262
|
-
<a
|
|
259
|
+
<a
|
|
263
260
|
href={`https://etherscan.io/tx/${depositTxs[0].txHash}`}
|
|
264
261
|
target="_blank"
|
|
265
262
|
rel="noopener noreferrer"
|
|
@@ -272,7 +269,7 @@ function OrderTracker({ orderId }: { orderId: string }) {
|
|
|
272
269
|
{executeTx && (
|
|
273
270
|
<div>
|
|
274
271
|
<h3>Execution Transaction</h3>
|
|
275
|
-
<a
|
|
272
|
+
<a
|
|
276
273
|
href={`https://explorer.b3.fun/tx/${executeTx.txHash}`}
|
|
277
274
|
target="_blank"
|
|
278
275
|
rel="noopener noreferrer"
|
|
@@ -305,14 +302,13 @@ const {
|
|
|
305
302
|
orderHistory,
|
|
306
303
|
isLoadingOrderHistory,
|
|
307
304
|
getOrderHistoryError
|
|
308
|
-
} = useAnyspendOrderHistory(
|
|
305
|
+
} = useAnyspendOrderHistory(creatorAddress, limit, offset);
|
|
309
306
|
```
|
|
310
307
|
|
|
311
308
|
#### Parameters
|
|
312
309
|
|
|
313
310
|
| Parameter | Type | Description |
|
|
314
311
|
|-----------|------|-------------|
|
|
315
|
-
| `isMainnet` | `boolean` | Environment selection |
|
|
316
312
|
| `creatorAddress` | `string` | User wallet address |
|
|
317
313
|
| `limit` | `number` | Number of orders to fetch (max 100) |
|
|
318
314
|
| `offset` | `number` | Pagination offset |
|
|
@@ -325,7 +321,6 @@ function OrderHistory({ userAddress }: { userAddress: string }) {
|
|
|
325
321
|
const pageSize = 10;
|
|
326
322
|
|
|
327
323
|
const { orderHistory, isLoadingOrderHistory } = useAnyspendOrderHistory(
|
|
328
|
-
true,
|
|
329
324
|
userAddress,
|
|
330
325
|
pageSize,
|
|
331
326
|
page * pageSize
|
|
@@ -346,14 +341,14 @@ function OrderHistory({ userAddress }: { userAddress: string }) {
|
|
|
346
341
|
<p>Date: {new Date(order.createdAt).toLocaleDateString()}</p>
|
|
347
342
|
</div>
|
|
348
343
|
))}
|
|
349
|
-
|
|
350
|
-
<button
|
|
351
|
-
onClick={() => setPage(page - 1)}
|
|
344
|
+
|
|
345
|
+
<button
|
|
346
|
+
onClick={() => setPage(page - 1)}
|
|
352
347
|
disabled={page === 0}
|
|
353
348
|
>
|
|
354
349
|
Previous
|
|
355
350
|
</button>
|
|
356
|
-
<button
|
|
351
|
+
<button
|
|
357
352
|
onClick={() => setPage(page + 1)}
|
|
358
353
|
disabled={!orderHistory?.data || orderHistory.data.length < pageSize}
|
|
359
354
|
>
|
|
@@ -371,7 +366,7 @@ function OrderHistory({ userAddress }: { userAddress: string }) {
|
|
|
371
366
|
Get available tokens for a specific chain.
|
|
372
367
|
|
|
373
368
|
```tsx
|
|
374
|
-
const { tokens, isLoadingTokens } = useAnyspendTokens(
|
|
369
|
+
const { tokens, isLoadingTokens } = useAnyspendTokens(1, "USDC");
|
|
375
370
|
```
|
|
376
371
|
|
|
377
372
|
### `useCoinbaseOnrampOptions`
|
|
@@ -400,7 +395,7 @@ function PaymentComponent() {
|
|
|
400
395
|
onError: (error) => {
|
|
401
396
|
// Log error for debugging
|
|
402
397
|
console.error("Payment failed:", error);
|
|
403
|
-
|
|
398
|
+
|
|
404
399
|
// Show user-friendly message
|
|
405
400
|
switch (error.message) {
|
|
406
401
|
case "INSUFFICIENT_BALANCE":
|
|
@@ -423,7 +418,7 @@ function PaymentComponent() {
|
|
|
423
418
|
|
|
424
419
|
```tsx
|
|
425
420
|
function SwapInterface() {
|
|
426
|
-
const { anyspendQuote, isLoadingAnyspendQuote } = useAnyspendQuote(
|
|
421
|
+
const { anyspendQuote, isLoadingAnyspendQuote } = useAnyspendQuote(quoteRequest);
|
|
427
422
|
const { createOrder, isCreatingOrder } = useAnyspendCreateOrder();
|
|
428
423
|
|
|
429
424
|
const isLoading = isLoadingAnyspendQuote || isCreatingOrder;
|
|
@@ -441,7 +436,7 @@ function SwapInterface() {
|
|
|
441
436
|
|
|
442
437
|
```tsx
|
|
443
438
|
function OrderStatus({ orderId }: { orderId: string }) {
|
|
444
|
-
const { orderAndTransactions } = useAnyspendOrderAndTransactions(
|
|
439
|
+
const { orderAndTransactions } = useAnyspendOrderAndTransactions(orderId);
|
|
445
440
|
|
|
446
441
|
// Auto-refresh every 5 seconds for pending orders
|
|
447
442
|
useEffect(() => {
|
|
@@ -449,7 +444,7 @@ function OrderStatus({ orderId }: { orderId: string }) {
|
|
|
449
444
|
const interval = setInterval(() => {
|
|
450
445
|
// Refetch is handled automatically by the hook
|
|
451
446
|
}, 5000);
|
|
452
|
-
|
|
447
|
+
|
|
453
448
|
return () => clearInterval(interval);
|
|
454
449
|
}
|
|
455
450
|
}, [orderAndTransactions?.data.order.status]);
|
|
@@ -462,4 +457,4 @@ function OrderStatus({ orderId }: { orderId: string }) {
|
|
|
462
457
|
|
|
463
458
|
- [See Examples →](./examples.md)
|
|
464
459
|
- [Error Handling →](./error-handling.md)
|
|
465
|
-
- [Components Reference →](./components.md)
|
|
460
|
+
- [Components Reference →](./components.md)
|