@b3dotfun/sdk 0.0.40-test.6 → 0.0.41-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/constants/index.d.ts +0 -1
- package/dist/cjs/anyspend/constants/index.js +1 -2
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +11 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +22 -10
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +41 -20
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +10 -8
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +7 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +24 -23
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +9 -8
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.js +24 -0
- package/dist/cjs/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsBadge.js +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +14 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +21 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +18 -8
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/cjs/anyspend/react/providers/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/providers/index.js +3 -0
- package/dist/cjs/anyspend/services/anyspend.d.ts +1 -1
- package/dist/cjs/anyspend/services/anyspend.js +2 -0
- package/dist/cjs/anyspend/types/api.d.ts +51 -1
- package/dist/cjs/anyspend/utils/chain.js +1 -1
- package/dist/cjs/anyspend/utils/orderPayload.js +3 -0
- package/dist/cjs/bondkit/bondkitToken.d.ts +37 -2
- package/dist/cjs/bondkit/bondkitToken.js +268 -2
- package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/cjs/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/cjs/bondkit/components/TradingView.js +3 -4
- package/dist/cjs/bondkit/config.d.ts +1 -1
- package/dist/cjs/bondkit/config.js +5 -2
- package/dist/cjs/bondkit/constants.d.ts +4 -0
- package/dist/cjs/bondkit/constants.js +6 -1
- package/dist/cjs/bondkit/index.d.ts +1 -0
- package/dist/cjs/bondkit/index.js +4 -1
- package/dist/cjs/bondkit/swapService.d.ts +43 -0
- package/dist/cjs/bondkit/swapService.js +376 -0
- package/dist/cjs/bondkit/types.d.ts +10 -4
- package/dist/cjs/bondkit/types.js +4 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +27 -28
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +63 -3
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/index.js +3 -1
- package/dist/cjs/global-account/react/hooks/useAccountAssets.js +5 -2
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +0 -12
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +2 -3
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.js +32 -0
- package/dist/cjs/global-account/react/hooks/useQueryB3.js +5 -2
- package/dist/cjs/global-account/react/hooks/useQueryBSMNT.js +5 -2
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/cjs/global-account/react/hooks/useTokenBalancesByChain.js +7 -1
- package/dist/cjs/global-account/react/hooks/useTokenFromUrl.js +2 -2
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +28 -24
- package/dist/cjs/shared/utils/fetchBalances.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 +11 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +23 -11
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +41 -20
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +11 -9
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +8 -5
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +25 -24
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +10 -9
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.js +21 -0
- package/dist/esm/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PointsBadge.js +4 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +8 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +17 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +18 -8
- package/dist/esm/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/esm/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/esm/anyspend/react/providers/index.d.ts +1 -0
- package/dist/esm/anyspend/react/providers/index.js +1 -0
- package/dist/esm/anyspend/services/anyspend.d.ts +1 -1
- package/dist/esm/anyspend/services/anyspend.js +2 -0
- package/dist/esm/anyspend/types/api.d.ts +51 -1
- package/dist/esm/anyspend/utils/chain.js +1 -1
- package/dist/esm/anyspend/utils/orderPayload.js +3 -0
- package/dist/esm/bondkit/bondkitToken.d.ts +37 -2
- package/dist/esm/bondkit/bondkitToken.js +268 -2
- package/dist/esm/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/esm/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/esm/bondkit/components/TradingView.js +3 -4
- package/dist/esm/bondkit/config.d.ts +1 -1
- package/dist/esm/bondkit/config.js +5 -2
- package/dist/esm/bondkit/constants.d.ts +4 -0
- package/dist/esm/bondkit/constants.js +5 -0
- package/dist/esm/bondkit/index.d.ts +1 -0
- package/dist/esm/bondkit/index.js +2 -0
- package/dist/esm/bondkit/swapService.d.ts +43 -0
- package/dist/esm/bondkit/swapService.js +372 -0
- package/dist/esm/bondkit/types.d.ts +10 -4
- package/dist/esm/bondkit/types.js +4 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +27 -28
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +65 -5
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/index.js +1 -0
- package/dist/esm/global-account/react/hooks/useAccountAssets.js +2 -2
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +0 -12
- package/dist/esm/global-account/react/hooks/useAuthentication.js +2 -3
- package/dist/esm/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/esm/global-account/react/hooks/useGlobalAccount.js +29 -0
- package/dist/esm/global-account/react/hooks/useQueryB3.js +5 -2
- package/dist/esm/global-account/react/hooks/useQueryBSMNT.js +5 -2
- package/dist/esm/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/esm/global-account/react/hooks/useTokenBalancesByChain.js +4 -1
- package/dist/esm/global-account/react/hooks/useTokenFromUrl.js +2 -2
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +29 -25
- package/dist/esm/shared/utils/fetchBalances.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 +11 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/types/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/types/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/types/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/types/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/types/anyspend/react/providers/index.d.ts +1 -0
- package/dist/types/anyspend/services/anyspend.d.ts +1 -1
- package/dist/types/anyspend/types/api.d.ts +51 -1
- package/dist/types/bondkit/bondkitToken.d.ts +37 -2
- package/dist/types/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/types/bondkit/config.d.ts +1 -1
- package/dist/types/bondkit/constants.d.ts +4 -0
- package/dist/types/bondkit/index.d.ts +1 -0
- package/dist/types/bondkit/swapService.d.ts +43 -0
- package/dist/types/bondkit/types.d.ts +10 -4
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/types/global-account/react/hooks/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/types/shared/utils/fetchBalances.d.ts +1 -1
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +0 -2
- package/src/anyspend/react/components/AnySpend.tsx +52 -18
- package/src/anyspend/react/components/AnySpendBondKit.tsx +0 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +82 -34
- package/src/anyspend/react/components/AnySpendNFT.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +38 -18
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +1 -2
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +12 -4
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +13 -8
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +170 -44
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +61 -45
- package/src/anyspend/react/components/common/OrderDetails.tsx +60 -47
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +62 -41
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +28 -8
- package/src/anyspend/react/components/common/PanelOnramp.tsx +28 -15
- package/src/anyspend/react/components/common/PaymentMethodSwitch.tsx +38 -0
- package/src/anyspend/react/components/common/PointsBadge.tsx +20 -0
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +65 -43
- package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +18 -8
- package/src/anyspend/react/hooks/useAnyspendOrderAndTransactions.ts +1 -1
- package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +1 -1
- package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
- package/src/anyspend/react/providers/index.ts +1 -0
- package/src/anyspend/services/anyspend.ts +3 -1
- package/src/anyspend/types/api.ts +51 -1
- package/src/anyspend/types/api_req_res.ts +6 -10
- package/src/anyspend/utils/chain.ts +1 -1
- package/src/anyspend/utils/orderPayload.ts +3 -0
- package/src/bondkit/bondkitToken.ts +323 -3
- package/src/bondkit/bondkitTokenFactory.ts +2 -2
- package/src/bondkit/components/TradingView.tsx +3 -5
- package/src/bondkit/config.ts +5 -2
- package/src/bondkit/constants.ts +7 -0
- package/src/bondkit/index.ts +3 -0
- package/src/bondkit/swapService.ts +464 -0
- package/src/bondkit/types.ts +12 -5
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +31 -32
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +106 -32
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +60 -5
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useAccountAssets.ts +4 -3
- package/src/global-account/react/hooks/useAccountWallet.tsx +0 -13
- package/src/global-account/react/hooks/useAuthentication.ts +2 -3
- package/src/global-account/react/hooks/useGlobalAccount.tsx +36 -0
- package/src/global-account/react/hooks/useOneBalance.tsx +1 -1
- package/src/global-account/react/hooks/useQueryB3.ts +22 -15
- package/src/global-account/react/hooks/useQueryBSMNT.ts +22 -15
- package/src/global-account/react/hooks/useSimBalance.ts +2 -2
- package/src/global-account/react/hooks/useTokenBalancesByChain.tsx +4 -1
- package/src/global-account/react/hooks/useTokenFromUrl.tsx +2 -2
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +30 -26
- package/src/shared/utils/fetchBalances.ts +1 -1
- package/dist/cjs/global-account/examples/client-selection-example.d.ts +0 -5
- package/dist/cjs/global-account/examples/client-selection-example.js +0 -96
- package/dist/esm/global-account/examples/client-selection-example.d.ts +0 -5
- package/dist/esm/global-account/examples/client-selection-example.js +0 -93
- package/dist/types/global-account/examples/client-selection-example.d.ts +0 -5
- package/src/global-account/docs/client-selection.md +0 -292
- package/src/global-account/examples/client-selection-example.tsx +0 -197
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
4
|
+
|
|
5
|
+
interface PaymentMethodSwitchProps {
|
|
6
|
+
currentMethod: CryptoPaymentMethodType;
|
|
7
|
+
onMethodChange?: (method: CryptoPaymentMethodType) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function PaymentMethodSwitch({ currentMethod, onMethodChange }: PaymentMethodSwitchProps) {
|
|
11
|
+
if (!onMethodChange) return null;
|
|
12
|
+
|
|
13
|
+
const isTransferCrypto = currentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO;
|
|
14
|
+
const isConnectWallet =
|
|
15
|
+
currentMethod === CryptoPaymentMethodType.CONNECT_WALLET || currentMethod === CryptoPaymentMethodType.GLOBAL_WALLET;
|
|
16
|
+
|
|
17
|
+
// Only show switch if we're in one of the payment states
|
|
18
|
+
if (!isTransferCrypto && !isConnectWallet) return null;
|
|
19
|
+
|
|
20
|
+
const handleSwitch = () => {
|
|
21
|
+
if (isTransferCrypto) {
|
|
22
|
+
onMethodChange(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
23
|
+
} else {
|
|
24
|
+
onMethodChange(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className="order-details-payment-switch-container flex items-center justify-center">
|
|
30
|
+
<button
|
|
31
|
+
onClick={handleSwitch}
|
|
32
|
+
className="order-details-payment-switch-btn text-as-primary/60 hover:text-as-primary text-sm underline transition-colors"
|
|
33
|
+
>
|
|
34
|
+
{isTransferCrypto ? "Switch to Connect Wallet" : "Switch to scan / manually send crypto"}
|
|
35
|
+
</button>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface PointsBadgeProps {
|
|
2
|
+
pointsAmount: number;
|
|
3
|
+
pointsMultiplier?: number;
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function PointsBadge({ pointsAmount, pointsMultiplier, onClick }: PointsBadgeProps) {
|
|
8
|
+
return (
|
|
9
|
+
<button
|
|
10
|
+
className="bg-as-brand hover:scale-102 active:scale-98 relative flex cursor-pointer items-center gap-1 rounded-lg px-2 py-1 transition-all"
|
|
11
|
+
onClick={onClick}
|
|
12
|
+
>
|
|
13
|
+
<div className="pointer-events-none absolute inset-0 h-full w-full rounded-lg border border-white/10 border-t-white/20 bg-gradient-to-b from-white/10 to-white/0" />
|
|
14
|
+
<span className="relative text-xs text-white">
|
|
15
|
+
+{pointsAmount.toLocaleString()} pts
|
|
16
|
+
{pointsMultiplier && pointsMultiplier > 1 && <span className="ml-1 opacity-80">({pointsMultiplier}x)</span>}
|
|
17
|
+
</span>
|
|
18
|
+
</button>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Button, ShinyButton } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
+
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
3
|
+
import { ArrowDown } from "lucide-react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
|
|
6
|
+
interface PointsDetailPanelProps {
|
|
7
|
+
pointsAmount?: number;
|
|
8
|
+
onBack: () => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function PointsDetailPanel({ pointsAmount = 0, onBack }: PointsDetailPanelProps) {
|
|
12
|
+
return (
|
|
13
|
+
<div className="mx-auto flex w-[460px] max-w-full flex-col items-center gap-4">
|
|
14
|
+
<div className="flex w-full items-center justify-between">
|
|
15
|
+
<Button
|
|
16
|
+
variant="ghost"
|
|
17
|
+
onClick={onBack}
|
|
18
|
+
className="text-as-primary/70 hover:text-as-primary flex items-center gap-2"
|
|
19
|
+
>
|
|
20
|
+
<ArrowDown className="h-4 w-4 rotate-90" />
|
|
21
|
+
Back
|
|
22
|
+
</Button>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div className="flex flex-col items-center gap-4 text-center">
|
|
26
|
+
<h3 className="text-as-primary text-xl font-bold">Earn Points with Every Swap</h3>
|
|
27
|
+
<p className="text-as-primary/70 text-balance text-sm leading-relaxed">
|
|
28
|
+
You'll earn <span className="text-as-brand font-semibold">+{pointsAmount.toLocaleString()} points</span>{" "}
|
|
29
|
+
towards the{" "}
|
|
30
|
+
<Link href="https://anyspend.com/points" target="_blank" className="text-as-brand underline">
|
|
31
|
+
next AnySpend airdrop
|
|
32
|
+
</Link>{" "}
|
|
33
|
+
when you complete this transaction.
|
|
34
|
+
</p>
|
|
35
|
+
<div className="bg-as-surface-primary border-as-border-secondary mt-2 w-full rounded-lg border p-4 text-left">
|
|
36
|
+
<h4 className="text-as-primary mb-2 font-semibold">How it works:</h4>
|
|
37
|
+
<ul className="text-as-primary/70 space-y-1 text-sm">
|
|
38
|
+
<li>• Points are earned based on transaction volume</li>
|
|
39
|
+
<li>• Higher volume = more points</li>
|
|
40
|
+
<li>• Points contribute to future airdrops</li>
|
|
41
|
+
<li>• Keep swapping to maximize your rewards</li>
|
|
42
|
+
</ul>
|
|
43
|
+
</div>
|
|
44
|
+
<ShinyButton
|
|
45
|
+
accentColor={"hsl(var(--as-brand))"}
|
|
46
|
+
onClick={onBack}
|
|
47
|
+
className={cn("as-main-button !bg-as-brand relative w-full")}
|
|
48
|
+
textClassName={cn("text-white")}
|
|
49
|
+
>
|
|
50
|
+
Back to Swap
|
|
51
|
+
</ShinyButton>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -11,7 +11,9 @@ import { QRCodeSVG } from "qrcode.react";
|
|
|
11
11
|
import { memo, useEffect, useMemo, useState } from "react";
|
|
12
12
|
import { toast } from "sonner";
|
|
13
13
|
import { b3 } from "viem/chains";
|
|
14
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
14
15
|
import { OrderDetailsCollapsible } from "./OrderDetailsCollapsible";
|
|
16
|
+
import { PaymentMethodSwitch } from "./PaymentMethodSwitch";
|
|
15
17
|
|
|
16
18
|
type Order = components["schemas"]["Order"];
|
|
17
19
|
type Token = components["schemas"]["Token"];
|
|
@@ -26,6 +28,7 @@ interface TransferCryptoDetailsProps {
|
|
|
26
28
|
nft?: NFT;
|
|
27
29
|
onBack: () => void;
|
|
28
30
|
recipientName?: string;
|
|
31
|
+
onPaymentMethodChange?: (method: CryptoPaymentMethodType) => void;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
@@ -36,6 +39,7 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
36
39
|
nft,
|
|
37
40
|
onBack,
|
|
38
41
|
recipientName,
|
|
42
|
+
onPaymentMethodChange,
|
|
39
43
|
}: TransferCryptoDetailsProps) {
|
|
40
44
|
const [timeLeft, setTimeLeft] = useState(0);
|
|
41
45
|
|
|
@@ -98,21 +102,21 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
98
102
|
};
|
|
99
103
|
|
|
100
104
|
return (
|
|
101
|
-
<div className="flex w-full flex-col gap-6">
|
|
105
|
+
<div className="order-transfer-crypto flex w-full flex-col gap-6">
|
|
102
106
|
{/* Header */}
|
|
103
|
-
<div className="flex items-center justify-between">
|
|
107
|
+
<div className="order-transfer-crypto-header flex items-center justify-between">
|
|
104
108
|
<button
|
|
105
109
|
onClick={onBack}
|
|
106
|
-
className="text-as-primary/60 hover:text-as-primary flex h-10 w-10 items-center justify-center rounded-full transition-colors"
|
|
110
|
+
className="order-transfer-crypto-back-btn text-as-primary/60 hover:text-as-primary flex h-10 w-10 items-center justify-center rounded-full transition-colors"
|
|
107
111
|
>
|
|
108
112
|
<ChevronLeft size={24} className="text-as-quaternary" />
|
|
109
113
|
</button>
|
|
110
114
|
|
|
111
|
-
<h2 className="text-as-primary text-lg font-semibold">Transfer crypto</h2>
|
|
115
|
+
<h2 className="order-transfer-crypto-title text-as-primary text-lg font-semibold">Transfer crypto</h2>
|
|
112
116
|
|
|
113
117
|
{/* Countdown Timer */}
|
|
114
|
-
<div className="relative flex h-11 w-11 items-center justify-center">
|
|
115
|
-
<svg className="h-11 w-11 -rotate-90" viewBox="0 0 44 44">
|
|
118
|
+
<div className="order-transfer-crypto-timer relative flex h-11 w-11 items-center justify-center">
|
|
119
|
+
<svg className="order-transfer-crypto-timer-svg h-11 w-11 -rotate-90" viewBox="0 0 44 44">
|
|
116
120
|
<circle
|
|
117
121
|
cx="22"
|
|
118
122
|
cy="22"
|
|
@@ -120,7 +124,7 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
120
124
|
stroke="currentColor"
|
|
121
125
|
strokeWidth="3"
|
|
122
126
|
fill="none"
|
|
123
|
-
className="text-gray-200"
|
|
127
|
+
className="order-transfer-crypto-timer-bg text-gray-200"
|
|
124
128
|
/>
|
|
125
129
|
<circle
|
|
126
130
|
cx="22"
|
|
@@ -130,7 +134,7 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
130
134
|
strokeWidth="3"
|
|
131
135
|
fill="none"
|
|
132
136
|
strokeLinecap="round"
|
|
133
|
-
className="text-blue-500"
|
|
137
|
+
className="order-transfer-crypto-timer-progress text-blue-500"
|
|
134
138
|
strokeDasharray={`${2 * Math.PI * 18}`}
|
|
135
139
|
strokeDashoffset={`${2 * Math.PI * 18 * (1 - timeLeft / totalTime)}`}
|
|
136
140
|
style={{
|
|
@@ -138,57 +142,66 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
138
142
|
}}
|
|
139
143
|
/>
|
|
140
144
|
</svg>
|
|
141
|
-
<div className="absolute inset-0 flex items-center justify-center">
|
|
145
|
+
<div className="order-transfer-crypto-timer-text absolute inset-0 flex items-center justify-center">
|
|
142
146
|
<span className="text-as-primary text-[10px] font-semibold">{formatTime(timeLeft)}</span>
|
|
143
147
|
</div>
|
|
144
148
|
</div>
|
|
145
149
|
</div>
|
|
146
150
|
|
|
147
151
|
{/* Main Content Cards */}
|
|
148
|
-
<div className="flex w-full flex-col gap-4">
|
|
152
|
+
<div className="order-transfer-crypto-content flex w-full flex-col gap-4">
|
|
149
153
|
{/* Amount Card */}
|
|
150
|
-
<div className="flex items-center gap-4">
|
|
151
|
-
<div className="w-full">
|
|
152
|
-
<span className="text-as-content-secondary text-sm font-medium">
|
|
153
|
-
|
|
154
|
+
<div className="order-transfer-crypto-cards flex items-center gap-4">
|
|
155
|
+
<div className="order-transfer-crypto-amount-card w-full">
|
|
156
|
+
<span className="order-transfer-crypto-amount-label text-as-content-secondary text-sm font-medium">
|
|
157
|
+
Amount
|
|
158
|
+
</span>
|
|
159
|
+
<div className="order-transfer-crypto-amount-container border-as-border-primary rounded-lg border p-2 shadow-sm">
|
|
154
160
|
<CopyToClipboard
|
|
155
161
|
text={roundedUpSrcAmount || ""}
|
|
156
162
|
onCopy={() => {
|
|
157
163
|
toast.success("Amount copied to clipboard");
|
|
158
164
|
}}
|
|
159
165
|
>
|
|
160
|
-
<div className="flex cursor-pointer items-center justify-between gap-2">
|
|
161
|
-
<strong className="text-as-primary font-semibold">
|
|
166
|
+
<div className="order-transfer-crypto-amount-copy flex cursor-pointer items-center justify-between gap-2">
|
|
167
|
+
<strong className="order-transfer-crypto-amount-text text-as-primary font-semibold">
|
|
162
168
|
{roundedUpSrcAmount} {srcToken.symbol}
|
|
163
169
|
</strong>
|
|
164
|
-
<Copy className="text-as-primary/50 hover:text-as-primary h-4 w-4 transition-all duration-200" />
|
|
170
|
+
<Copy className="order-transfer-crypto-amount-copy-icon text-as-primary/50 hover:text-as-primary h-4 w-4 transition-all duration-200" />
|
|
165
171
|
</div>
|
|
166
172
|
</CopyToClipboard>
|
|
167
173
|
</div>
|
|
168
174
|
</div>
|
|
169
175
|
|
|
170
176
|
{/* Chain Card */}
|
|
171
|
-
<div className="w-full">
|
|
172
|
-
<span className="text-as-content-secondary text-sm font-medium">
|
|
173
|
-
|
|
174
|
-
|
|
177
|
+
<div className="order-transfer-crypto-chain-card w-full">
|
|
178
|
+
<span className="order-transfer-crypto-chain-label text-as-content-secondary text-sm font-medium">
|
|
179
|
+
Chain
|
|
180
|
+
</span>
|
|
181
|
+
<div className="order-transfer-crypto-chain-container border-as-border-primary rounded-lg border p-2 shadow-sm">
|
|
182
|
+
<div className="order-transfer-crypto-chain-info flex items-center gap-2">
|
|
175
183
|
<img
|
|
176
184
|
src={ALL_CHAINS[order.srcChain].logoUrl}
|
|
177
185
|
alt={getChainName(order.srcChain)}
|
|
178
|
-
className={cn(
|
|
186
|
+
className={cn(
|
|
187
|
+
"order-transfer-crypto-chain-logo h-6 rounded-full",
|
|
188
|
+
order.srcChain === b3.id && "h-5 rounded-none",
|
|
189
|
+
)}
|
|
179
190
|
/>
|
|
180
|
-
<span className="text-as-primary text-sm font-semibold">
|
|
191
|
+
<span className="order-transfer-crypto-chain-name text-as-primary text-sm font-semibold">
|
|
192
|
+
{getChainName(order.srcChain)}
|
|
193
|
+
</span>
|
|
181
194
|
</div>
|
|
182
195
|
</div>
|
|
183
196
|
</div>
|
|
184
197
|
</div>
|
|
185
198
|
|
|
186
199
|
{/* QR Code and Deposit Address Card */}
|
|
187
|
-
<div className="border-b3-react-border bg-as-surface-secondary grid h-[220px] grid-cols-2 overflow-hidden rounded-xl border">
|
|
200
|
+
<div className="order-transfer-crypto-qr-deposit-card border-b3-react-border bg-as-surface-secondary grid h-[220px] grid-cols-2 overflow-hidden rounded-xl border">
|
|
188
201
|
{/* QR Code Section */}
|
|
189
|
-
<div className="border-as-border-primary h-full w-full border-r">
|
|
190
|
-
<div className="flex justify-center">
|
|
191
|
-
<div className="bg-as-surface-secondary flex flex-col items-center rounded-lg p-6">
|
|
202
|
+
<div className="order-transfer-crypto-qr-section border-as-border-primary h-full w-full border-r">
|
|
203
|
+
<div className="order-transfer-crypto-qr-wrapper flex justify-center">
|
|
204
|
+
<div className="order-transfer-crypto-qr-container bg-as-surface-secondary flex flex-col items-center rounded-lg p-6">
|
|
192
205
|
<QRCodeSVG
|
|
193
206
|
value={getPaymentUrl(
|
|
194
207
|
order.globalAddress,
|
|
@@ -197,15 +210,17 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
197
210
|
order.srcChain,
|
|
198
211
|
srcToken?.decimals,
|
|
199
212
|
)}
|
|
200
|
-
className="bg-as-surface-secondary max-h-48 max-w-48"
|
|
213
|
+
className="order-transfer-crypto-qr-code bg-as-surface-secondary max-h-48 max-w-48"
|
|
201
214
|
/>
|
|
202
|
-
<div className="mt-3 flex items-center justify-center gap-2 text-sm">
|
|
203
|
-
<span className="text-as-brand/70 text-sm font-medium">
|
|
215
|
+
<div className="order-transfer-crypto-wallet-hint mt-3 flex items-center justify-center gap-2 text-sm">
|
|
216
|
+
<span className="order-transfer-crypto-wallet-text text-as-brand/70 text-sm font-medium">
|
|
217
|
+
SCAN WITH
|
|
218
|
+
</span>
|
|
204
219
|
<TextLoop interval={3}>
|
|
205
|
-
<WalletMetamask className="h-5 w-5" variant="branded" />
|
|
206
|
-
<WalletCoinbase className="h-5 w-5" variant="branded" />
|
|
207
|
-
<WalletPhantom className="h-5 w-5" variant="branded" />
|
|
208
|
-
<WalletTrust className="h-5 w-5" variant="branded" />
|
|
220
|
+
<WalletMetamask className="order-transfer-crypto-wallet-icon h-5 w-5" variant="branded" />
|
|
221
|
+
<WalletCoinbase className="order-transfer-crypto-wallet-icon h-5 w-5" variant="branded" />
|
|
222
|
+
<WalletPhantom className="order-transfer-crypto-wallet-icon h-5 w-5" variant="branded" />
|
|
223
|
+
<WalletTrust className="order-transfer-crypto-wallet-icon h-5 w-5" variant="branded" />
|
|
209
224
|
</TextLoop>
|
|
210
225
|
</div>
|
|
211
226
|
</div>
|
|
@@ -213,17 +228,19 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
213
228
|
</div>
|
|
214
229
|
|
|
215
230
|
{/* Deposit Address Section */}
|
|
216
|
-
<div className="flex h-full w-full flex-col gap-2 p-6">
|
|
217
|
-
<span className="text-as-content-secondary text-sm font-medium">
|
|
231
|
+
<div className="order-transfer-crypto-address-section flex h-full w-full flex-col gap-2 p-6">
|
|
232
|
+
<span className="order-transfer-crypto-address-label text-as-content-secondary text-sm font-medium">
|
|
233
|
+
Deposit address:
|
|
234
|
+
</span>
|
|
218
235
|
<div
|
|
219
|
-
className="flex h-full cursor-pointer flex-col items-stretch justify-between gap-4"
|
|
236
|
+
className="order-transfer-crypto-address-copy flex h-full cursor-pointer flex-col items-stretch justify-between gap-4"
|
|
220
237
|
onClick={handleCopyAddress}
|
|
221
238
|
>
|
|
222
|
-
<div className="text-as-primary break-all font-mono text-sm font-semibold leading-relaxed">
|
|
239
|
+
<div className="order-transfer-crypto-address-text text-as-primary break-all font-mono text-sm font-semibold leading-relaxed">
|
|
223
240
|
{order.globalAddress}
|
|
224
241
|
</div>
|
|
225
|
-
<div className="place-self-end">
|
|
226
|
-
<Copy className="group-hover:text-as-brand text-as-tertiarry h-4 w-4 cursor-pointer transition-all duration-200" />
|
|
242
|
+
<div className="order-transfer-crypto-address-copy-icon-wrapper place-self-end">
|
|
243
|
+
<Copy className="order-transfer-crypto-address-copy-icon group-hover:text-as-brand text-as-tertiarry h-4 w-4 cursor-pointer transition-all duration-200" />
|
|
227
244
|
</div>
|
|
228
245
|
</div>
|
|
229
246
|
</div>
|
|
@@ -240,23 +257,28 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
240
257
|
</div>
|
|
241
258
|
|
|
242
259
|
{/* Action Buttons */}
|
|
243
|
-
<div className="flex flex-col gap-3">
|
|
260
|
+
<div className="order-transfer-crypto-actions flex flex-col gap-3">
|
|
244
261
|
<ShinyButton
|
|
245
262
|
accentColor="hsl(var(--as-brand))"
|
|
246
263
|
textColor="text-white"
|
|
247
|
-
className="w-full py-3"
|
|
264
|
+
className="order-transfer-crypto-copy-btn w-full py-3"
|
|
248
265
|
onClick={handleCopyAddress}
|
|
249
266
|
>
|
|
250
267
|
Copy deposit address
|
|
251
268
|
</ShinyButton>
|
|
252
269
|
|
|
253
270
|
{/* <button
|
|
254
|
-
className="text-as-primary/60 hover:text-as-primary flex w-full items-center justify-center gap-2 py-2 transition-colors"
|
|
271
|
+
className="order-transfer-crypto-cancel-btn text-as-primary/60 hover:text-as-primary flex w-full items-center justify-center gap-2 py-2 transition-colors"
|
|
255
272
|
onClick={onBack}
|
|
256
273
|
>
|
|
257
274
|
<RefreshCcw className="h-4 w-4" />
|
|
258
275
|
Cancel and start over
|
|
259
276
|
</button> */}
|
|
277
|
+
|
|
278
|
+
<PaymentMethodSwitch
|
|
279
|
+
currentMethod={CryptoPaymentMethodType.TRANSFER_CRYPTO}
|
|
280
|
+
onMethodChange={onPaymentMethodChange}
|
|
281
|
+
/>
|
|
260
282
|
</div>
|
|
261
283
|
</div>
|
|
262
284
|
);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
export interface FeatureFlags {
|
|
6
|
+
showPoints?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface FeatureFlagsContextType {
|
|
10
|
+
featureFlags: FeatureFlags;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const FeatureFlagsContext = createContext<FeatureFlagsContextType | undefined>(undefined);
|
|
14
|
+
|
|
15
|
+
interface FeatureFlagsProviderProps {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
featureFlags?: FeatureFlags;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const defaultFeatureFlags: FeatureFlags = {
|
|
21
|
+
showPoints: false,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function FeatureFlagsProvider({ children, featureFlags = defaultFeatureFlags }: FeatureFlagsProviderProps) {
|
|
25
|
+
return <FeatureFlagsContext.Provider value={{ featureFlags }}>{children}</FeatureFlagsContext.Provider>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function useFeatureFlags(): FeatureFlags {
|
|
29
|
+
const context = useContext(FeatureFlagsContext);
|
|
30
|
+
if (!context) {
|
|
31
|
+
return defaultFeatureFlags;
|
|
32
|
+
}
|
|
33
|
+
return context.featureFlags;
|
|
34
|
+
}
|
|
@@ -31,6 +31,7 @@ export enum PanelView {
|
|
|
31
31
|
RECIPIENT_SELECTION,
|
|
32
32
|
ORDER_DETAILS,
|
|
33
33
|
LOADING,
|
|
34
|
+
POINTS_DETAIL,
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
interface UseAnyspendFlowProps {
|
|
@@ -156,15 +157,17 @@ export function useAnyspendFlow({
|
|
|
156
157
|
};
|
|
157
158
|
|
|
158
159
|
// Get quote
|
|
159
|
-
|
|
160
|
+
// For fiat payments, always use USDC decimals (6) regardless of selectedSrcToken
|
|
161
|
+
const effectiveDecimals = paymentType === "fiat" ? USDC_BASE.decimals : selectedSrcToken.decimals;
|
|
162
|
+
const activeInputAmountInWei = parseUnits(srcAmount.replace(/,/g, ""), effectiveDecimals).toString();
|
|
160
163
|
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } = useAnyspendQuote({
|
|
161
164
|
srcChain: paymentType === "fiat" ? base.id : selectedSrcChainId,
|
|
162
165
|
dstChain: isDepositMode ? base.id : selectedDstChainId, // For deposits, always Base; for swaps, use selected destination
|
|
163
166
|
srcTokenAddress: paymentType === "fiat" ? USDC_BASE.address : selectedSrcToken.address,
|
|
164
167
|
dstTokenAddress: isDepositMode ? B3_TOKEN.address : selectedSrcToken.address, // For deposits, always B3
|
|
165
|
-
type: "
|
|
166
|
-
tradeType: "EXACT_INPUT",
|
|
168
|
+
type: "hype_duel",
|
|
167
169
|
amount: activeInputAmountInWei,
|
|
170
|
+
recipientAddress: selectedRecipientAddress,
|
|
168
171
|
onrampVendor: paymentType === "fiat" ? getOnrampVendor(selectedFiatPaymentMethod) : undefined,
|
|
169
172
|
});
|
|
170
173
|
|
|
@@ -244,12 +247,19 @@ export function useAnyspendFlow({
|
|
|
244
247
|
// Handle order completion
|
|
245
248
|
useEffect(() => {
|
|
246
249
|
if (oat?.data?.order.status === "executed") {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
|
|
250
|
+
// get the actualDstAmount if available from custompayload
|
|
251
|
+
const amount = (oat.data.order.payload as { actualDstAmount?: string })?.actualDstAmount;
|
|
252
|
+
const formattedActualDstAmount = amount
|
|
253
|
+
? formatTokenAmount(BigInt(amount), oat.data.order.metadata.dstToken.decimals)
|
|
254
|
+
: undefined;
|
|
255
|
+
onTransactionSuccess?.(formattedActualDstAmount);
|
|
251
256
|
}
|
|
252
|
-
}, [
|
|
257
|
+
}, [
|
|
258
|
+
oat?.data?.order.status,
|
|
259
|
+
oat?.data?.order.payload,
|
|
260
|
+
onTransactionSuccess,
|
|
261
|
+
oat?.data?.order.metadata.dstToken.decimals,
|
|
262
|
+
]);
|
|
253
263
|
|
|
254
264
|
return {
|
|
255
265
|
// State
|
|
@@ -35,7 +35,7 @@ export function useAnyspendOrderAndTransactions(orderId: string | undefined) {
|
|
|
35
35
|
|
|
36
36
|
const { data, isLoading, refetch, error } = useQuery<GetOrderAndTxsResponse>({
|
|
37
37
|
queryKey: ["getAnyspendOrderAndTransactions", orderId],
|
|
38
|
-
queryFn: () => anyspendService.getOrderAndTransactions(orderId
|
|
38
|
+
queryFn: () => anyspendService.getOrderAndTransactions(orderId),
|
|
39
39
|
enabled: !!orderId,
|
|
40
40
|
refetchInterval: 3000,
|
|
41
41
|
staleTime: 1000,
|
|
@@ -6,7 +6,7 @@ import { useMemo } from "react";
|
|
|
6
6
|
export function useCoinbaseOnrampOptions(country?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean) {
|
|
7
7
|
const { data, isLoading, error, refetch } = useQuery({
|
|
8
8
|
queryKey: ["getCoinbaseOnrampOptions", country, visitorData],
|
|
9
|
-
queryFn: () => anyspendService.getCoinbaseOnrampOptions(country
|
|
9
|
+
queryFn: () => anyspendService.getCoinbaseOnrampOptions(country, visitorData),
|
|
10
10
|
enabled: Boolean(country) && !isLoadingVisitorData,
|
|
11
11
|
});
|
|
12
12
|
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
import { TooltipProvider } from "@b3dotfun/sdk/global-account/react";
|
|
4
4
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
5
5
|
import { ReactNode, useState } from "react";
|
|
6
|
+
import { FeatureFlags, FeatureFlagsProvider } from "../contexts/FeatureFlagsContext";
|
|
6
7
|
import { StripeRedirectHandler } from "./StripeRedirectHandler";
|
|
7
8
|
|
|
8
9
|
interface AnyspendProviderProps {
|
|
9
10
|
children: ReactNode;
|
|
11
|
+
featureFlags?: FeatureFlags;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
const defaultQueryClientConfig = {
|
|
@@ -29,27 +31,30 @@ const defaultQueryClientConfig = {
|
|
|
29
31
|
* - Safe to use at the application root
|
|
30
32
|
* - Configures sensible defaults for query caching
|
|
31
33
|
* - Handles Stripe payment redirects and modal state
|
|
34
|
+
* - Provides feature flags configuration
|
|
32
35
|
*
|
|
33
36
|
* @example
|
|
34
37
|
* ```tsx
|
|
35
38
|
* function App() {
|
|
36
39
|
* return (
|
|
37
|
-
* <AnyspendProvider>
|
|
40
|
+
* <AnyspendProvider featureFlags={{ showPoints: true }}>
|
|
38
41
|
* <YourApp />
|
|
39
42
|
* </AnyspendProvider>
|
|
40
43
|
* );
|
|
41
44
|
* }
|
|
42
45
|
* ```
|
|
43
46
|
*/
|
|
44
|
-
export const AnyspendProvider = function AnyspendProvider({ children }: AnyspendProviderProps) {
|
|
47
|
+
export const AnyspendProvider = function AnyspendProvider({ children, featureFlags }: AnyspendProviderProps) {
|
|
45
48
|
const [queryClient] = useState(() => new QueryClient(defaultQueryClientConfig));
|
|
46
49
|
|
|
47
50
|
return (
|
|
48
51
|
<QueryClientProvider client={queryClient}>
|
|
49
|
-
<
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
<FeatureFlagsProvider featureFlags={featureFlags}>
|
|
53
|
+
<TooltipProvider>
|
|
54
|
+
<StripeRedirectHandler />
|
|
55
|
+
{children}
|
|
56
|
+
</TooltipProvider>
|
|
57
|
+
</FeatureFlagsProvider>
|
|
53
58
|
</QueryClientProvider>
|
|
54
59
|
);
|
|
55
60
|
};
|
|
@@ -111,6 +111,7 @@ export const anyspendService = {
|
|
|
111
111
|
},
|
|
112
112
|
|
|
113
113
|
getOrderAndTransactions: async (orderId: string | undefined): Promise<GetOrderAndTxsResponse> => {
|
|
114
|
+
invariant(orderId, "orderId is required");
|
|
114
115
|
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/orders/${orderId}`);
|
|
115
116
|
const data: GetOrderAndTxsResponse = await response.json();
|
|
116
117
|
return data;
|
|
@@ -134,9 +135,10 @@ export const anyspendService = {
|
|
|
134
135
|
},
|
|
135
136
|
|
|
136
137
|
getCoinbaseOnrampOptions: async (
|
|
137
|
-
country: string,
|
|
138
|
+
country: string | undefined,
|
|
138
139
|
visitorData?: VisitorData,
|
|
139
140
|
): Promise<GetCoinbaseOnrampOptionsResponse> => {
|
|
141
|
+
invariant(country, "country is required");
|
|
140
142
|
const params = new URLSearchParams({
|
|
141
143
|
country,
|
|
142
144
|
// include fingerprintId and requestId in the query params
|
|
@@ -505,11 +505,16 @@ export interface paths {
|
|
|
505
505
|
* @example 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
|
|
506
506
|
*/
|
|
507
507
|
dstTokenAddress: string;
|
|
508
|
+
/**
|
|
509
|
+
* @description Recipient address
|
|
510
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
511
|
+
*/
|
|
512
|
+
recipientAddress?: string;
|
|
508
513
|
/**
|
|
509
514
|
* @description Type of trade execution
|
|
510
515
|
* @enum {string}
|
|
511
516
|
*/
|
|
512
|
-
tradeType: "EXACT_INPUT" | "
|
|
517
|
+
tradeType: "EXACT_INPUT" | "EXACT_OUTPUT";
|
|
513
518
|
/**
|
|
514
519
|
* @description Amount to quote
|
|
515
520
|
* @example 1000000000000000000
|
|
@@ -547,6 +552,11 @@ export interface paths {
|
|
|
547
552
|
* @example 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
|
|
548
553
|
*/
|
|
549
554
|
dstTokenAddress: string;
|
|
555
|
+
/**
|
|
556
|
+
* @description Recipient address
|
|
557
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
558
|
+
*/
|
|
559
|
+
recipientAddress?: string;
|
|
550
560
|
/** @description Custom payload for execution */
|
|
551
561
|
payload: {
|
|
552
562
|
/** @description Encoded transaction data */
|
|
@@ -571,6 +581,11 @@ export interface paths {
|
|
|
571
581
|
dstChain: number;
|
|
572
582
|
srcTokenAddress: string;
|
|
573
583
|
dstTokenAddress: string;
|
|
584
|
+
/**
|
|
585
|
+
* @description Recipient address
|
|
586
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
587
|
+
*/
|
|
588
|
+
recipientAddress?: string;
|
|
574
589
|
/** @enum {string} */
|
|
575
590
|
onrampVendor?: "coinbase" | "stripe" | "stripe-web2";
|
|
576
591
|
contractAddress: string;
|
|
@@ -586,6 +601,11 @@ export interface paths {
|
|
|
586
601
|
dstChain: number;
|
|
587
602
|
srcTokenAddress: string;
|
|
588
603
|
dstTokenAddress: string;
|
|
604
|
+
/**
|
|
605
|
+
* @description Recipient address
|
|
606
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
607
|
+
*/
|
|
608
|
+
recipientAddress?: string;
|
|
589
609
|
/** @enum {string} */
|
|
590
610
|
onrampVendor?: "coinbase" | "stripe" | "stripe-web2";
|
|
591
611
|
contractAddress: string;
|
|
@@ -598,6 +618,11 @@ export interface paths {
|
|
|
598
618
|
dstChain: number;
|
|
599
619
|
srcTokenAddress: string;
|
|
600
620
|
dstTokenAddress: string;
|
|
621
|
+
/**
|
|
622
|
+
* @description Recipient address
|
|
623
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
624
|
+
*/
|
|
625
|
+
recipientAddress?: string;
|
|
601
626
|
/** @enum {string} */
|
|
602
627
|
onrampVendor?: "coinbase" | "stripe" | "stripe-web2";
|
|
603
628
|
contractAddress: string;
|
|
@@ -629,6 +654,11 @@ export interface paths {
|
|
|
629
654
|
* @example 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
|
|
630
655
|
*/
|
|
631
656
|
dstTokenAddress: string;
|
|
657
|
+
/**
|
|
658
|
+
* @description Recipient address
|
|
659
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
660
|
+
*/
|
|
661
|
+
recipientAddress?: string;
|
|
632
662
|
/**
|
|
633
663
|
* @description Amount to quote
|
|
634
664
|
* @example 1000000000000000000
|
|
@@ -805,6 +835,16 @@ export interface paths {
|
|
|
805
835
|
* @example 0
|
|
806
836
|
*/
|
|
807
837
|
userBalance?: string;
|
|
838
|
+
/**
|
|
839
|
+
* @description Anyspend points that will be awarded for the order
|
|
840
|
+
* @example 100
|
|
841
|
+
*/
|
|
842
|
+
pointsAmount?: number;
|
|
843
|
+
/**
|
|
844
|
+
* @description Multiplier applied to points that will be awarded for the order
|
|
845
|
+
* @example 1.5
|
|
846
|
+
*/
|
|
847
|
+
pointsMultiplier?: number;
|
|
808
848
|
};
|
|
809
849
|
/** @example 200 */
|
|
810
850
|
statusCode: number;
|
|
@@ -1084,6 +1124,11 @@ export interface components {
|
|
|
1084
1124
|
* @example 990000
|
|
1085
1125
|
*/
|
|
1086
1126
|
actualDstAmount: string | null;
|
|
1127
|
+
/**
|
|
1128
|
+
* @description Amount in after fee
|
|
1129
|
+
* @example 990000
|
|
1130
|
+
*/
|
|
1131
|
+
amountInAfterFee: string | null;
|
|
1087
1132
|
};
|
|
1088
1133
|
/** @description HypeDuel-specific payload */
|
|
1089
1134
|
HypeDuelPayload: {
|
|
@@ -1097,6 +1142,11 @@ export interface components {
|
|
|
1097
1142
|
* @example 990000
|
|
1098
1143
|
*/
|
|
1099
1144
|
actualDstAmount: string | null;
|
|
1145
|
+
/**
|
|
1146
|
+
* @description Amount in after fee
|
|
1147
|
+
* @example 990000
|
|
1148
|
+
*/
|
|
1149
|
+
amountInAfterFee: string | null;
|
|
1100
1150
|
};
|
|
1101
1151
|
/** @description Custom execution payload */
|
|
1102
1152
|
CustomPayload: {
|