|
@@ -14,13 +14,15 @@ describe("mint-token", () => {
|
|
|
const payer = provider.wallet as anchor.Wallet;
|
|
|
const program = anchor.workspace.MintTokenTo as anchor.Program<MintTokenTo>;
|
|
|
|
|
|
- it("Mint!", async () => {
|
|
|
+ const mintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate();
|
|
|
+ console.log(`New token: ${mintKeypair.publicKey}`);
|
|
|
|
|
|
- const mintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate();
|
|
|
- console.log(`New token: ${mintKeypair.publicKey}`);
|
|
|
+ const testTokenTitle = "Solana Gold";
|
|
|
+ const testTokenSymbol = "GOLDSOL";
|
|
|
+ const testTokenUri = "https://raw.githubusercontent.com/solana-developers/program-examples/main/tokens/token_metadata.json";
|
|
|
+
|
|
|
+ it("Mint!", async () => {
|
|
|
|
|
|
- // Derive the metadata account's address and set the metadata
|
|
|
- //
|
|
|
const metadataAddress = (await anchor.web3.PublicKey.findProgramAddress(
|
|
|
[
|
|
|
Buffer.from("metadata"),
|
|
@@ -29,13 +31,10 @@ describe("mint-token", () => {
|
|
|
],
|
|
|
TOKEN_METADATA_PROGRAM_ID
|
|
|
))[0];
|
|
|
- const testTokenTitle = "Solana Gold";
|
|
|
- const testTokenSymbol = "GOLDSOL";
|
|
|
- const testTokenUri = "https://raw.githubusercontent.com/solana-developers/program-examples/main/tokens/mint/native/assets/token_metadata.json";
|
|
|
|
|
|
- // Transact with the "mint_token" function in our on-chain program
|
|
|
+ // Transact with the "create_token_mint" function in our on-chain program
|
|
|
//
|
|
|
- await program.methods.mintToken(
|
|
|
+ await program.methods.createTokenMint(
|
|
|
testTokenTitle, testTokenSymbol, testTokenUri
|
|
|
)
|
|
|
.accounts({
|
|
@@ -49,4 +48,28 @@ describe("mint-token", () => {
|
|
|
.signers([payer.payer, mintKeypair])
|
|
|
.rpc();
|
|
|
});
|
|
|
+
|
|
|
+ it("Mint to a wallet!", async () => {
|
|
|
+
|
|
|
+ const amountToMint = 1;
|
|
|
+
|
|
|
+ const tokenAddress = await anchor.utils.token.associatedAddress({
|
|
|
+ mint: mintKeypair.publicKey,
|
|
|
+ owner: payer.publicKey
|
|
|
+ });
|
|
|
+
|
|
|
+ // Transact with the "mint_to_wallet" function in our on-chain program
|
|
|
+ //
|
|
|
+ await program.methods.mintToWallet(new anchor.BN(amountToMint))
|
|
|
+ .accounts({
|
|
|
+ mintAccount: mintKeypair.publicKey,
|
|
|
+ tokenAccount: tokenAddress,
|
|
|
+ mintAuthority: payer.publicKey,
|
|
|
+ systemProgram: anchor.web3.SystemProgram.programId,
|
|
|
+ tokenProgram: anchor.utils.token.TOKEN_PROGRAM_ID,
|
|
|
+ associatedTokenProgram: anchor.utils.token.ASSOCIATED_PROGRAM_ID,
|
|
|
+ })
|
|
|
+ .signers([payer.payer, mintKeypair])
|
|
|
+ .rpc();
|
|
|
+});
|
|
|
});
|