diff --git a/apps/anyspend-demo-nextjs/src/app/components/CustomDepositButton.tsx b/apps/anyspend-demo-nextjs/src/app/components/CustomDepositButton.tsx index b4bdd8e4..895d7359 100644 --- a/apps/anyspend-demo-nextjs/src/app/components/CustomDepositButton.tsx +++ b/apps/anyspend-demo-nextjs/src/app/components/CustomDepositButton.tsx @@ -49,7 +49,7 @@ const STAKING_CONTRACT = "0xEf80AafFbf4cF5c8a5e1D4c61838987D5973DAab"; type DepositType = "simple" | "contract" | "hyperliquid" | "eth-base"; export function CustomDepositButton() { - const { address } = useAccountWallet(); + const { address = "0x0000000000000000000000000000000000000000" } = useAccountWallet(); const [isModalOpen, setIsModalOpen] = useState(false); const [depositType, setDepositType] = useState("simple"); @@ -70,7 +70,7 @@ export function CustomDepositButton() { const customExactInConfig = { functionAbi: STAKE_FOR_FUNCTION_ABI, functionName: "stakeFor", - functionArgs: [normalizeAddress(address || ""), "{{amount_out}}"], + functionArgs: [normalizeAddress(address), "{{amount_out}}"], to: STAKING_CONTRACT, spenderAddress: STAKING_CONTRACT, action: `stake USDC`, diff --git a/apps/anyspend-demo-nextjs/src/app/components/FixedAmountDepositButton.tsx b/apps/anyspend-demo-nextjs/src/app/components/FixedAmountDepositButton.tsx new file mode 100644 index 00000000..3b607fba --- /dev/null +++ b/apps/anyspend-demo-nextjs/src/app/components/FixedAmountDepositButton.tsx @@ -0,0 +1,73 @@ +"use client"; + +import { AnySpendDeposit } from "@b3dotfun/sdk/anyspend/react"; +import { useAccountWallet } from "@b3dotfun/sdk/global-account/react"; +import { useState } from "react"; +import { parseUnits } from "viem"; +import { base } from "viem/chains"; + +// USDC on Base (6 decimals) +const USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"; + +export function FixedAmountDepositButton() { + const { address = "0x0000000000000000000000000000000000000000" } = useAccountWallet(); + const [isModalOpen, setIsModalOpen] = useState(false); + + const handleClose = () => setIsModalOpen(false); + + const handleSuccess = (amount: string) => { + console.log(`Fixed amount deposit successful! Amount: ${amount}`); + handleClose(); + }; + + // Fixed amount: 10 USDC (in wei/smallest unit) + const fixedAmount = parseUnits("10", 6).toString(); + + return ( + <> + + + {isModalOpen && ( +
+
+ {!address ? ( +
+ +
+

Please sign in first to use the deposit feature.

+
+
+ ) : ( + + )} +
+
+ )} + + ); +} diff --git a/apps/anyspend-demo-nextjs/src/app/page.tsx b/apps/anyspend-demo-nextjs/src/app/page.tsx index 8e2d7256..084d4ac9 100644 --- a/apps/anyspend-demo-nextjs/src/app/page.tsx +++ b/apps/anyspend-demo-nextjs/src/app/page.tsx @@ -8,6 +8,7 @@ import { CollectorClubPurchaseButton } from "./components/CollectorClubPurchaseB import { CustomClassesDepositButton } from "./components/CustomClassesDepositButton"; import { CustomDepositButton } from "./components/CustomDepositButton"; import { DepositHypeButton } from "./components/DepositHypeButton"; +import { FixedAmountDepositButton } from "./components/FixedAmountDepositButton"; import { GetB3TokenButton } from "./components/GetB3TokenButton"; import { MintNftButton } from "./components/MintNftButton"; import { OrderDetailsButton } from "./components/OrderDetailsButton"; @@ -61,6 +62,7 @@ export default function Home() { + diff --git a/packages/sdk/src/anyspend/react/components/AnySpend.tsx b/packages/sdk/src/anyspend/react/components/AnySpend.tsx index 1e782dfd..747af866 100644 --- a/packages/sdk/src/anyspend/react/components/AnySpend.tsx +++ b/packages/sdk/src/anyspend/react/components/AnySpend.tsx @@ -1215,6 +1215,7 @@ function AnySpendInner({ onTokenSelect={onTokenSelect} onShowFeeDetail={() => navigateToPanel(PanelView.FEE_DETAIL, "forward")} skipAutoMaxOnTokenChange={!!destinationTokenAmount} + disableAmountInput={!!destinationTokenAmount} /> ) : ( ) : (
@@ -154,6 +158,7 @@ export function CryptoPaySection({ setIsSrcInputDirty(true); setSrcAmount(value); }} + hideMaxButton={disableAmountInput} />
diff --git a/packages/sdk/src/anyspend/react/components/common/TokenBalance.tsx b/packages/sdk/src/anyspend/react/components/common/TokenBalance.tsx index dafd80cd..c9eb7638 100644 --- a/packages/sdk/src/anyspend/react/components/common/TokenBalance.tsx +++ b/packages/sdk/src/anyspend/react/components/common/TokenBalance.tsx @@ -10,10 +10,12 @@ export function TokenBalance({ token, walletAddress, onChangeInput, + hideMaxButton = false, }: { token: components["schemas"]["Token"]; walletAddress: string | undefined; onChangeInput: (value: string) => void; + hideMaxButton?: boolean; }) { const tokenAddress = isNativeToken(token.address) ? "native" : token.address; const { data, isLoading } = useSimTokenBalance(walletAddress, tokenAddress, token.chainId); @@ -62,7 +64,7 @@ export function TokenBalance({ {rawBalance ? `Balance: ${formattedBalance}` : `Balance: 0`} - {!!rawBalance && ( + {!!rawBalance && !hideMaxButton && ( <> {/*