|
1 | 1 | import { useRef, useState } from "react"; |
2 | 2 | import Link from "next/link"; |
3 | 3 | import { NetworkOptions } from "./NetworkOptions"; |
4 | | -import { FundButton } from "@coinbase/onchainkit/fund"; |
| 4 | +import { FundButton, getOnrampBuyUrl } from "@coinbase/onchainkit/fund"; |
5 | 5 | import { Avatar, Badge, Identity, Name } from "@coinbase/onchainkit/identity"; |
6 | 6 | import CopyToClipboard from "react-copy-to-clipboard"; |
7 | 7 | import { getAddress } from "viem"; |
@@ -37,7 +37,18 @@ export const AddressInfoDropdown = ({ address, blockExplorerAddressLink }: Addre |
37 | 37 | const [addressCopied, setAddressCopied] = useState(false); |
38 | 38 |
|
39 | 39 | const [selectingNetwork, setSelectingNetwork] = useState(false); |
| 40 | + |
40 | 41 | const dropdownRef = useRef<HTMLDetailsElement>(null); |
| 42 | + |
| 43 | + const projectId = process.env.NEXT_PUBLIC_CDP_PROJECT_ID || ""; |
| 44 | + |
| 45 | + const onrampBuyUrl = getOnrampBuyUrl({ |
| 46 | + projectId, |
| 47 | + addresses: { connectedAddress: ["base"] }, |
| 48 | + assets: ["USDC", "ETH"], |
| 49 | + presetFiatAmount: 20, |
| 50 | + fiatCurrency: "USD", |
| 51 | + }); |
41 | 52 | const closeDropdown = () => { |
42 | 53 | setSelectingNetwork(false); |
43 | 54 | dropdownRef.current?.removeAttribute("open"); |
@@ -84,7 +95,11 @@ export const AddressInfoDropdown = ({ address, blockExplorerAddressLink }: Addre |
84 | 95 | </Link> |
85 | 96 | </div> |
86 | 97 | </li> |
87 | | - <FundButton text="Add funds" className="py-1 px-3.5 gap-1 text-md rounded-xl justify-start font-normal" /> |
| 98 | + <FundButton |
| 99 | + text="Add funds" |
| 100 | + fundingUrl={onrampBuyUrl} |
| 101 | + className="py-1 px-3.5 gap-1 text-md rounded-xl justify-start font-normal" |
| 102 | + /> |
88 | 103 | <li className={selectingNetwork ? "hidden" : ""}> |
89 | 104 | <button |
90 | 105 | className="menu-item btn-sm !rounded-xl bg-[#4f46e5] hover:bg-[#4338CA] active:bg-[#4338CA] flex gap-3 py-3" |
|
0 commit comments