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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage
Expand All @@ -23,10 +24,13 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
373 changes: 0 additions & 373 deletions LICENSE

This file was deleted.

10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.

[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

Expand Down
3 changes: 3 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
24 changes: 24 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";

const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body suppressHydrationWarning={true} className={inter.className}>
{children}
</body>
</html>
);
}
2 changes: 1 addition & 1 deletion pages/index.tsx → app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CreateTokenAccountForm } from "../components/CreateTokenAccount";
import { CreateMintForm } from "../components/CreateMint";
import Head from "next/head";

const Home: NextPage = (props) => {
const Home: NextPage = () => {
return (
<div className={styles.App}>
<Head>
Expand Down
3 changes: 2 additions & 1 deletion components/AppBar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import { FC } from "react";
import styles from "../styles/Home.module.css";
import { WalletMultiButton } from "@solana/wallet-adapter-react-ui";
Expand All @@ -6,7 +7,7 @@ import Image from "next/image";
export const AppBar: FC = () => {
return (
<div className={styles.AppHeader}>
<Image src="/solanaLogo.png" height={30} width={200} />
<Image src="/solanaLogo.png" height={30} width={200} alt="sol logo" />
<span>Token Program</span>
<WalletMultiButton />
</div>
Expand Down
2 changes: 2 additions & 0 deletions components/BalanceDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import { useConnection, useWallet } from "@solana/wallet-adapter-react";
import { LAMPORTS_PER_SOL } from "@solana/web3.js";
import { FC, useEffect, useState } from "react";
Expand All @@ -13,6 +14,7 @@ export const BalanceDisplay: FC = () => {
}

connection.getAccountInfo(publicKey).then((info) => {
if (!info) return;
setBalance(info.lamports);
});
}, [connection, publicKey]);
Expand Down
17 changes: 5 additions & 12 deletions components/CreateMint.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";
import { useConnection, useWallet } from "@solana/wallet-adapter-react";
import * as web3 from "@solana/web3.js";
import { FC, useState } from "react";
import { FC, FormEvent, useState } from "react";
import styles from "../styles/Home.module.css";
import {
MINT_SIZE,
Expand All @@ -16,12 +17,10 @@ export const CreateMintForm: FC = () => {
const { connection } = useConnection();
const { publicKey, sendTransaction } = useWallet();
const link = () => {
return txSig
? `https://explorer.solana.com/tx/${txSig}?cluster=devnet`
: "";
return txSig ? `https://explorer.solana.com/tx/${txSig}?cluster=devnet` : "";
};

const createMint = async (event) => {
const createMint = async (event: FormEvent) => {
event.preventDefault();
if (!connection || !publicKey) {
return;
Expand All @@ -41,13 +40,7 @@ export const CreateMintForm: FC = () => {
lamports,
programId: TOKEN_PROGRAM_ID,
}),
createInitializeMintInstruction(
mint.publicKey,
0,
publicKey,
publicKey,
TOKEN_PROGRAM_ID
)
createInitializeMintInstruction(mint.publicKey, 0, publicKey, publicKey, TOKEN_PROGRAM_ID)
);

sendTransaction(transaction, connection, {
Expand Down
17 changes: 5 additions & 12 deletions components/CreateTokenAccount.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use client";
import { useConnection, useWallet } from "@solana/wallet-adapter-react";
import * as web3 from "@solana/web3.js";
import { LAMPORTS_PER_SOL } from "@solana/web3.js";
import { FC, useState } from "react";
import { FC, FormEvent, useState } from "react";
import styles from "../styles/Home.module.css";

import {
Expand All @@ -17,12 +18,10 @@ export const CreateTokenAccountForm: FC = () => {
const { connection } = useConnection();
const { publicKey, sendTransaction } = useWallet();
const link = () => {
return txSig
? `https://explorer.solana.com/tx/${txSig}?cluster=devnet`
: "";
return txSig ? `https://explorer.solana.com/tx/${txSig}?cluster=devnet` : "";
};

const createTokenAccount = async (event) => {
const createTokenAccount = async (event: any) => {
event.preventDefault();
if (!connection || !publicKey) {
return;
Expand Down Expand Up @@ -62,13 +61,7 @@ export const CreateTokenAccountForm: FC = () => {
{publicKey ? (
<form onSubmit={createTokenAccount} className={styles.form}>
<label htmlFor="owner">Token Mint:</label>
<input
id="mint"
type="text"
className={styles.formField}
placeholder="Enter Token Mint"
required
/>
<input id="mint" type="text" className={styles.formField} placeholder="Enter Token Mint" required />
<label htmlFor="owner">Token Account Owner:</label>
<input
id="owner"
Expand Down
27 changes: 6 additions & 21 deletions components/MintToForm.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import { useConnection, useWallet } from "@solana/wallet-adapter-react";
import * as web3 from "@solana/web3.js";
import { LAMPORTS_PER_SOL } from "@solana/web3.js";
Expand All @@ -18,12 +19,10 @@ export const MintToForm: FC = () => {
const { connection } = useConnection();
const { publicKey, sendTransaction } = useWallet();
const link = () => {
return txSig
? `https://explorer.solana.com/tx/${txSig}?cluster=devnet`
: "";
return txSig ? `https://explorer.solana.com/tx/${txSig}?cluster=devnet` : "";
};

const mintTo = async (event) => {
const mintTo = async (event: any) => {
event.preventDefault();
if (!connection || !publicKey) {
return;
Expand All @@ -42,9 +41,7 @@ export const MintToForm: FC = () => {
ASSOCIATED_TOKEN_PROGRAM_ID
);

transaction.add(
createMintToInstruction(mintPubKey, associatedToken, publicKey, amount)
);
transaction.add(createMintToInstruction(mintPubKey, associatedToken, publicKey, amount));

const signature = await sendTransaction(transaction, connection);

Expand All @@ -63,13 +60,7 @@ export const MintToForm: FC = () => {
{publicKey ? (
<form onSubmit={mintTo} className={styles.form}>
<label htmlFor="mint">Token Mint:</label>
<input
id="mint"
type="text"
className={styles.formField}
placeholder="Enter Token Mint"
required
/>
<input id="mint" type="text" className={styles.formField} placeholder="Enter Token Mint" required />
<label htmlFor="recipient">Recipient:</label>
<input
id="recipient"
Expand All @@ -79,13 +70,7 @@ export const MintToForm: FC = () => {
required
/>
<label htmlFor="amount">Amount Tokens to Mint:</label>
<input
id="amount"
type="text"
className={styles.formField}
placeholder="e.g. 100"
required
/>
<input id="amount" type="text" className={styles.formField} placeholder="e.g. 100" required />
<button type="submit" className={styles.formButton}>
Mint Tokens
</button>
Expand Down
6 changes: 2 additions & 4 deletions components/WalletContextProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"use client";
import { FC, ReactNode } from "react";
import {
ConnectionProvider,
WalletProvider,
} from "@solana/wallet-adapter-react";
import { ConnectionProvider, WalletProvider } from "@solana/wallet-adapter-react";
import { WalletModalProvider } from "@solana/wallet-adapter-react-ui";
import * as web3 from "@solana/web3.js";
import { PhantomWalletAdapter } from "@solana/wallet-adapter-wallets";
Expand Down
6 changes: 0 additions & 6 deletions next.config.js

This file was deleted.

4 changes: 4 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

export default nextConfig;
Loading