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
108 changes: 66 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@solana/wallet-adapter-base": "^0.9.23",
"@solana/wallet-adapter-react": "^0.15.35",
"@solana/wallet-adapter-react-ui": "^0.9.35",
"@solana/web3.js": "1.91.9",
"@solana/web3.js": "^1.95.3",
"@tabler/icons-react": "3.5.0",
"@tailwindcss/typography": "0.5.13",
"@tanstack/react-query": "5.40.0",
Expand Down
34 changes: 2 additions & 32 deletions web/components/tokenaccount/CreateMint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,7 @@ export const CreateMintForm: FC = () => {
return;
}

const mint = web3.Keypair.generate();

const lamports = await getMinimumBalanceForRentExemptMint(connection);

const transaction = new web3.Transaction();

transaction.add(
web3.SystemProgram.createAccount({
fromPubkey: publicKey,
newAccountPubkey: mint.publicKey,
space: MINT_SIZE,
lamports,
programId: TOKEN_PROGRAM_ID,
}),
createInitializeMintInstruction(
mint.publicKey,
0,
publicKey,
publicKey,
TOKEN_PROGRAM_ID
)
);

sendTransaction(transaction, connection, {
signers: [mint],
}).then((sig) => {
setTxSig(sig);
setMint(mint.publicKey.toString());
});
// BUILD AND SEND CREATE MINT TRANSACTION HERE
};

return (
Expand All @@ -75,9 +47,7 @@ export const CreateMintForm: FC = () => {
<div>
<p>Token Mint Address: {mint}</p>
<p>View your transaction on </p>
<a className={styles.link} href={link()}>
Solana Explorer
</a>
<a href={link()}>Solana Explorer</a>
</div>
) : null}
</div>
Expand Down
32 changes: 3 additions & 29 deletions web/components/tokenaccount/CreateTokenAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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 styles from '../../app/styles/Home.module.css';

Expand All @@ -28,33 +29,8 @@ export const CreateTokenAccountForm: FC = () => {
if (!connection || !publicKey) {
return;
}
const transaction = new web3.Transaction();
const owner = new web3.PublicKey(event.target.owner.value);
const mint = new web3.PublicKey(event.target.mint.value);

const associatedToken = await getAssociatedTokenAddress(
mint,
owner,
false,
TOKEN_PROGRAM_ID,
ASSOCIATED_TOKEN_PROGRAM_ID
);

transaction.add(
createAssociatedTokenAccountInstruction(
publicKey,
associatedToken,
owner,
mint,
TOKEN_PROGRAM_ID,
ASSOCIATED_TOKEN_PROGRAM_ID
)
);

sendTransaction(transaction, connection).then((sig) => {
setTxSig(sig);
setTokenAccount(associatedToken.toString());
});
// BUILD AND SEND CREATE TOKEN ACCOUNT TRANSACTION HERE
};

return (
Expand Down Expand Up @@ -89,9 +65,7 @@ export const CreateTokenAccountForm: FC = () => {
<div>
<p>Token Account Address: {tokenAccount}</p>
<p>View your transaction on </p>
<a className={styles.link} href={link()}>
Solana Explorer
</a>
<a href={link()}>Solana Explorer</a>
</div>
) : null}
</div>
Expand Down
32 changes: 3 additions & 29 deletions web/components/tokenaccount/MintToForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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 styles from '../../app/styles/Home.module.css';
import {
Expand Down Expand Up @@ -29,33 +30,8 @@ export const MintToForm: FC = () => {
if (!connection || !publicKey) {
return;
}
const transaction = new web3.Transaction();

const mintPubKey = new web3.PublicKey(event.target.mint.value);
const recipientPubKey = new web3.PublicKey(event.target.recipient.value);
const amount = event.target.amount.value;

const associatedToken = await getAssociatedTokenAddress(
mintPubKey,
recipientPubKey,
false,
TOKEN_PROGRAM_ID,
ASSOCIATED_TOKEN_PROGRAM_ID
);

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

const signature = await sendTransaction(transaction, connection);

await connection.confirmTransaction(signature, 'confirmed');

setTxSig(signature);
setTokenAccount(associatedToken.toString());

const account = await getAccount(connection, associatedToken);
setBalance(account.amount.toString());
// BUILD AND SEND MINT TRANSACTION HERE
};

return (
Expand Down Expand Up @@ -98,9 +74,7 @@ export const MintToForm: FC = () => {
<div>
<p>Token Balance: {balance} </p>
<p>View your transaction on </p>
<a className={styles.link} href={link()}>
Solana Explorer
</a>
<a href={link()}>Solana Explorer</a>
</div>
) : null}
</div>
Expand Down