Skip to content

Commit

Permalink
Minor UI/UX style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
pindaroso committed Oct 16, 2024
1 parent da55ecb commit e14a74e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
35 changes: 16 additions & 19 deletions packages/app/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ declare global {
}

const defaultNetwork =
process.env.NODE_ENV === 'development' ? 'localnet' : 'devnet'
process.env.NODE_ENV === 'development' ? 'Localnet' : 'Devnet'

export default function Home() {
const { publicKey, disconnect } = useWallet()
Expand Down Expand Up @@ -110,9 +110,9 @@ export default function Home() {

return (
<div className="flex flex-col min-h-screen">
<nav className="p-4">
<nav className="p-3 px-4 border-b border-1 border-zinc-200 dark:border-zinc-800">
<div className="flex justify-between items-center">
<div className="flex items-center gap-6 text-zinc-700 dark:text-zinc-300">
<div className="flex items-center text-sm gap-6 text-zinc-700 dark:text-zinc-300">
<Link href="/" className="text-primary text-lg">
Solana ZK Starter
</Link>
Expand Down Expand Up @@ -144,16 +144,13 @@ export default function Home() {
<div className="flex items-center">
{publicKey ? (
<>
<Button
variant="ghost"
className="mr-2 text-zinc-700 dark:text-zinc-300"
>
<Button variant="ghost" className="mr-2 font-normal">
{balance !== null ? balance.toFixed(2) + ' SOL' : '-'}
</Button>
<div className="flex flex-row">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline" className="w-24">
<Button variant="outline" className="w-24 font-normal">
{networkActive ? (
<span className="text-green-400 mr-2">&bull;</span>
) : (
Expand All @@ -164,35 +161,35 @@ export default function Home() {
</DropdownMenuTrigger>
<DropdownMenuContent
defaultValue={network}
className="bg-background w-56"
className="w-56"
>
<DropdownMenuLabel>Network</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuRadioGroup
value={endpoint}
onValueChange={(value) => {
const endpoints = {
localnet: 'http://127.0.0.1:8899',
devnet: 'https://api.devnet.solana.com',
testnet: 'https://api.testnet.solana.com',
mainnet: 'https://api.mainnet-beta.solana.com',
Localnet: 'http://127.0.0.1:8899',
Devnet: 'https://api.devnet.solana.com',
Testnet: 'https://api.testnet.solana.com',
Mainnet: 'https://api.mainnet-beta.solana.com',
}
setEndpoint(
endpoints[value as keyof typeof endpoints]
)
setNetwork(value)
}}
>
<DropdownMenuRadioItem value="localnet">
<DropdownMenuRadioItem value="Localnet">
Localnet
</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="devnet">
<DropdownMenuRadioItem value="Devnet">
Devnet
</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="testnet">
<DropdownMenuRadioItem value="Testnet">
Testnet
</DropdownMenuRadioItem>
<DropdownMenuRadioItem disabled value="mainnet">
<DropdownMenuRadioItem disabled value="Mainnet">
Mainnet
</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
Expand Down Expand Up @@ -280,8 +277,8 @@ export default function Home() {
</>
)}
{hash === '' && (
<div className="flex flex-col mt-2 text-center gap-2">
<h1 className="text-primary text-4xl">zkgm</h1>
<div className="flex flex-col mt-2 text-center gap-2 text-zinc-700 dark:text-zinc-300">
<h1 className="text-4xl">zkgm</h1>
<p>Say hello to your new zk compresison app.</p>
</div>
)}
Expand Down
5 changes: 5 additions & 0 deletions packages/app/src/components/buttons/create-mint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ export const CreateMintButton: FC<{ className?: string }> = ({ className }) => {
const onClick = useCallback(async () => {
if (!wallet) throw new WalletNotConnectedError()

toast.error('Not Implemented')
return

// @ts-ignore
try {
const rpc = createRpc(endpoint)
const { transactionSignature } = await createMint(
rpc,
wallet as unknown as Signer, // TODO: Fix this
// @ts-ignore
wallet.publicKey,
9
)
Expand Down
9 changes: 9 additions & 0 deletions packages/app/src/components/buttons/send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ export const SendButton: FC<{ className?: string }> = ({ className }) => {

const connection = createRpc(endpoint)

toast.error('Not Implemented')
return

const compressInstruction = await LightSystemProgram.compress({
// @ts-ignore
payer: publicKey,
// @ts-ignore
toAddress: publicKey,
lamports: 1e8,
outputStateTree: defaultTestStateTreeAccounts().merkleTree,
Expand All @@ -47,6 +52,7 @@ export const SendButton: FC<{ className?: string }> = ({ className }) => {
value: blockhashCtx,
} = await connection.getLatestBlockhashAndContext()

// @ts-ignore
const tx = buildTx(compressInstructions, publicKey, blockhashCtx.blockhash)
const signature = await sendTransaction(tx, connection, {
minContextSlot,
Expand All @@ -65,6 +71,7 @@ export const SendButton: FC<{ className?: string }> = ({ className }) => {
// Send compressed SOL to a random address
const recipient = Keypair.generate().publicKey

// @ts-ignore
const accounts = await connection.getCompressedAccountsByOwner(publicKey)
const [selectedAccounts, _] = selectMinCompressedSolAccountsForTransfer(
accounts.items,
Expand All @@ -78,6 +85,7 @@ export const SendButton: FC<{ className?: string }> = ({ className }) => {

// Create and send compressed transfer
const sendInstruction = await LightSystemProgram.transfer({
// @ts-ignore
payer: publicKey,
toAddress: recipient,
lamports: 1e7,
Expand All @@ -100,6 +108,7 @@ export const SendButton: FC<{ className?: string }> = ({ className }) => {
} = await connection.getLatestBlockhashAndContext()

const messageV0Send = new TransactionMessage({
// @ts-ignore
payerKey: publicKey,
recentBlockhash: blockhashSend,
instructions: sendInstructions,
Expand Down

0 comments on commit e14a74e

Please sign in to comment.