Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/anyspend-demo-nextjs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ const nextConfig = {
env: {
NEXT_PUBLIC_THIRDWEB_CLIENT_ID: process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID || "eb17a5ec4314526d42fc567821aeb9a6",
NEXT_PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID:
process.env.NEXT_PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID || "ceba2f84-45ff-4717-b3e9-0acf0d062abd",
process.env.NEXT_PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID || "b9aac999-efef-4625-96d6-8043f20ec615",
NEXT_PUBLIC_THIRDWEB_ECOSYSTEM_ID: process.env.NEXT_PUBLIC_THIRDWEB_ECOSYSTEM_ID || "ecosystem.b3dotfun",
NEXT_PUBLIC_B3_API: process.env.NEXT_PUBLIC_B3_API || "https://b3-api-development.up.railway.app",
NEXT_PUBLIC_ANYSPEND_BASE_URL: process.env.NEXT_PUBLIC_ANYSPEND_BASE_URL || "https://mainnet.anyspend.com",
NEXT_PUBLIC_DEVMODE_SHARED_SECRET:
process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET || "k1c4Ep6agmoejiBinKE70B6bzb8vSdm8",
Comment on lines +12 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-critical critical

A potentially sensitive shared secret is hardcoded as a default value. Hardcoding secrets in source code is a critical security vulnerability, as it exposes them to anyone with access to the repository. Additionally, the NEXT_PUBLIC_ prefix makes this variable accessible on the client-side, increasing the risk. Secrets should be loaded exclusively from environment variables, and the application should be configured to fail at build time if a required secret is missing in production environments.

Suggested change
NEXT_PUBLIC_DEVMODE_SHARED_SECRET:
process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET || "k1c4Ep6agmoejiBinKE70B6bzb8vSdm8",
NEXT_PUBLIC_DEVMODE_SHARED_SECRET:
process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET,

},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"use client";

import { AnySpendOrderlyDeposit } from "@b3dotfun/sdk/anyspend/react";
import { useAccountWallet } from "@b3dotfun/sdk/global-account/react";
import { useState } from "react";

// Demo broker ID - replace with your actual broker ID from Orderly
const DEMO_BROKER_ID = "volt";

export function AnySpendOrderlyDepositButton() {
const { address } = useAccountWallet();
const [isModalOpen, setIsModalOpen] = useState(false);

const handleOpenModal = () => {
setIsModalOpen(true);
};

const handleCloseModal = () => {
setIsModalOpen(false);
};

const handleSuccess = (amount: string) => {
console.log("Orderly deposit successful! Amount:", amount);
};

return (
<>
<button
onClick={handleOpenModal}
className="group flex h-40 w-full flex-col justify-between overflow-hidden rounded-lg border border-gray-100 bg-white p-6 text-left shadow-sm transition-all hover:border-green-100 hover:shadow-md"
>
<div>
<h3 className="text-lg font-medium text-gray-900">AnySpend + Orderly</h3>
<p className="mt-1 text-sm text-gray-500">Deposit any token to Orderly on Arbitrum</p>
</div>
<div className="flex items-center gap-2">
<span className="rounded bg-green-100 px-2 py-1 text-xs text-green-700">Any token</span>
<span className="rounded bg-blue-100 px-2 py-1 text-xs text-blue-700">Arbitrum</span>
</div>
</button>

{/* Modal */}
{isModalOpen && (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
<div className="mx-4 w-full max-w-lg">
{/* AnySpend Orderly Deposit Component */}
{address ? (
<AnySpendOrderlyDeposit
brokerId={DEMO_BROKER_ID}
mode="page"
onSuccess={handleSuccess}
onClose={handleCloseModal}
minAmount={1}
/>
) : (
<div className="rounded-lg bg-white p-6 text-center shadow-xl">
<p className="text-sm text-gray-500">Connect wallet to deposit</p>
<button
onClick={handleCloseModal}
className="mt-4 rounded-lg border border-gray-300 px-4 py-2 text-sm text-gray-600 hover:bg-gray-50"
>
Close
</button>
</div>
)}
</div>
</div>
)}
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
"use client";

import { OrderlyDeposit } from "@b3dotfun/sdk/anyspend/react";
import { useAccountWallet } from "@b3dotfun/sdk/global-account/react";
import { useState } from "react";

// Demo broker ID - replace with your actual broker ID from Orderly
const DEMO_BROKER_ID = "volt";

// Available chains for the demo
const DEMO_CHAINS = [
{ id: 42161, name: "Arbitrum" },
{ id: 10, name: "Optimism" },
{ id: 8453, name: "Base" },
{ id: 1, name: "Ethereum" },
{ id: 137, name: "Polygon" },
];

export function OrderlyDepositButton() {
const { address } = useAccountWallet();

const [isModalOpen, setIsModalOpen] = useState(false);
const [selectedChainId, setSelectedChainId] = useState(42161);
const [amount, setAmount] = useState("10");

const handleOpenModal = () => {
setIsModalOpen(true);
};

const handleCloseModal = () => {
setIsModalOpen(false);
};

const handleSuccess = (txHash: string) => {
console.log("Orderly deposit successful!", txHash);
// Optionally close modal after success
// setIsModalOpen(false);
};

const handleError = (error: Error) => {
console.error("Orderly deposit failed:", error);
};

return (
<>
<button
onClick={handleOpenModal}
className="group flex h-40 w-full flex-col justify-between overflow-hidden rounded-lg border border-gray-100 bg-white p-6 text-left shadow-sm transition-all hover:border-purple-100 hover:shadow-md"
>
<div>
<h3 className="text-lg font-medium text-gray-900">Orderly Deposit</h3>
<p className="mt-1 text-sm text-gray-500">Deposit USDC to Orderly Network vault (omnichain)</p>
</div>
<div className="flex items-center gap-2">
<span className="rounded bg-purple-100 px-2 py-1 text-xs text-purple-700">16 chains supported</span>
</div>
</button>

{/* Modal */}
{isModalOpen && (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
<div className="mx-4 w-full max-w-md rounded-lg bg-white p-6 shadow-xl">
{/* Header */}
<div className="mb-4 flex items-center justify-between">
<h3 className="text-lg font-medium text-gray-900">Orderly Deposit</h3>
<button onClick={handleCloseModal} className="text-gray-400 hover:text-gray-600">
<svg className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>

{/* Chain selector */}
<div className="mb-4">
<label className="mb-1 block text-sm font-medium text-gray-700">Chain</label>
<select
value={selectedChainId}
onChange={e => setSelectedChainId(Number(e.target.value))}
className="w-full rounded-md border border-gray-300 px-3 py-2 focus:border-purple-500 focus:outline-none focus:ring-2 focus:ring-purple-500"
>
{DEMO_CHAINS.map(chain => (
<option key={chain.id} value={chain.id}>
{chain.name}
</option>
))}
</select>
</div>

{/* Amount input */}
<div className="mb-4">
<label className="mb-1 block text-sm font-medium text-gray-700">Amount (USDC)</label>
<input
type="number"
value={amount}
onChange={e => setAmount(e.target.value)}
placeholder="Enter amount"
className="w-full rounded-md border border-gray-300 px-3 py-2 focus:border-purple-500 focus:outline-none focus:ring-2 focus:ring-purple-500"
/>
<div className="mt-2 flex gap-2">
{["10", "50", "100", "500"].map(val => (
<button
key={val}
onClick={() => setAmount(val)}
className={`flex-1 rounded border px-2 py-1 text-sm ${
amount === val
? "border-purple-500 bg-purple-50 text-purple-700"
: "border-gray-300 text-gray-600 hover:border-purple-300"
}`}
>
${val}
</button>
))}
</div>
</div>

{/* Orderly Deposit Component */}
{address ? (
<OrderlyDeposit
brokerId={DEMO_BROKER_ID}
chainId={selectedChainId}
amount={amount}
onSuccess={handleSuccess}
onError={handleError}
showFeeBreakdown={true}
/>
) : (
<div className="rounded-lg bg-gray-100 p-4 text-center text-sm text-gray-500">
Connect wallet to deposit
</div>
)}
</div>
</div>
)}
</>
);
}
4 changes: 4 additions & 0 deletions apps/anyspend-demo-nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { DepositHypeButton } from "./components/DepositHypeButton";
import { GetB3TokenButton } from "./components/GetB3TokenButton";
import { MintNftButton } from "./components/MintNftButton";
import { OrderDetailsButton } from "./components/OrderDetailsButton";
import { OrderlyDepositButton } from "./components/OrderlyDepositButton";
import { AnySpendOrderlyDepositButton } from "./components/AnySpendOrderlyDepositButton";
import { SignInButton } from "./components/SignInButton";
import { SignatureMintButton } from "./components/SignatureMintButton";
import { SignatureMintModal } from "./components/SignatureMintModal";
Expand Down Expand Up @@ -60,6 +62,8 @@ export default function Home() {
<BuyHyperliquidUSDCButton />
<CollectorClubPurchaseButton />
<OrderDetailsButton />
<OrderlyDepositButton />
<AnySpendOrderlyDepositButton />
<CustomClassesDepositButton />
</div>
</div>
Expand Down
Loading
Loading