@b3dotfun/sdk 0.0.40 → 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/react/components/AnySpend.d.ts +11 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +17 -4
- 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 +33 -11
- 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 +6 -3
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +5 -3
- 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.js +8 -11
- 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/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/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 +4 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +41 -9
- 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/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/react/components/AnySpend.d.ts +11 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +17 -4
- 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 +33 -11
- 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 +6 -3
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +6 -4
- 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.js +8 -11
- 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/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/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 +4 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +42 -9
- 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/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/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/CryptoPaySection.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- 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/PointsBadge.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -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 +4 -3
- 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 +6 -5
- package/src/anyspend/react/components/AnySpend.tsx +37 -1
- 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 +63 -13
- 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 +22 -0
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +1 -2
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +7 -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 +10 -14
- 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/PointsBadge.tsx +20 -0
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
- 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 +55 -15
- 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/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
|
@@ -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
|
+
}
|
|
@@ -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: {
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { paths } from "./api";
|
|
2
2
|
|
|
3
|
-
export type GetOrderAndTxsResponse =
|
|
4
|
-
paths["/orders/{orderId}"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
3
|
+
export type GetOrderAndTxsResponse = paths["/orders/{orderId}"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
5
4
|
export type GetQuoteRequest = paths["/orders/quote"]["post"]["requestBody"]["content"]["application/json"];
|
|
6
5
|
export type GetQuoteResponse = paths["/orders/quote"]["post"]["responses"]["200"]["content"]["application/json"];
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
export type GetCoinbaseOnrampOptionsResponse = paths["/onramp/coinbase/options"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
9
8
|
export type GetOrderHistoryResponse = paths["/orders"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
10
|
-
export type GetTokenListResponse =
|
|
11
|
-
paths["/chains/{chainId}/tokens"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
9
|
+
export type GetTokenListResponse = paths["/chains/{chainId}/tokens"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
12
10
|
export type CreateOrderResponse = paths["/orders"]["post"]["responses"]["200"]["content"]["application/json"];
|
|
13
|
-
export type GetStripeSupportedResponse =
|
|
14
|
-
|
|
15
|
-
export type GetStripeClientSecret =
|
|
16
|
-
paths["/stripe/clientSecret"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
11
|
+
export type GetStripeSupportedResponse = paths["/onramp/stripe/supported"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
12
|
+
export type GetStripeClientSecret = paths["/stripe/clientSecret"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
@@ -149,7 +149,7 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
149
149
|
name: bsc.name,
|
|
150
150
|
logoUrl: "https://avatars.githubusercontent.com/u/45615063?s=280&v=4",
|
|
151
151
|
type: ChainType.EVM,
|
|
152
|
-
nativeRequired: parseEther("0.
|
|
152
|
+
nativeRequired: parseEther("0.0001"),
|
|
153
153
|
canDepositNative: true,
|
|
154
154
|
defaultToken: getBnbToken(),
|
|
155
155
|
nativeToken: getBnbToken(),
|
|
@@ -18,6 +18,7 @@ export const buildPayload = (orderType: components["schemas"]["Order"]["type"],
|
|
|
18
18
|
return {
|
|
19
19
|
expectedDstAmount,
|
|
20
20
|
actualDstAmount: null,
|
|
21
|
+
amountInAfterFee: null,
|
|
21
22
|
};
|
|
22
23
|
case "mint_nft":
|
|
23
24
|
if (nft?.type === "erc1155") {
|
|
@@ -31,6 +32,7 @@ export const buildPayload = (orderType: components["schemas"]["Order"]["type"],
|
|
|
31
32
|
return {
|
|
32
33
|
contractAddress: normalizeAddress(nft.contractAddress),
|
|
33
34
|
nftPrice: nft?.price || "",
|
|
35
|
+
tokenId: null,
|
|
34
36
|
contractType: nft?.type,
|
|
35
37
|
};
|
|
36
38
|
} else {
|
|
@@ -52,6 +54,7 @@ export const buildPayload = (orderType: components["schemas"]["Order"]["type"],
|
|
|
52
54
|
return {
|
|
53
55
|
expectedDstAmount,
|
|
54
56
|
actualDstAmount: null,
|
|
57
|
+
amountInAfterFee: null,
|
|
55
58
|
};
|
|
56
59
|
default:
|
|
57
60
|
throw new Error(`Invalid order type: ${orderType}`);
|