@@ -38,27 +38,19 @@ describe("SPL Token Minter", () => {
3838 `${ require ( "node:os" ) . homedir ( ) } /.config/solana/id.json` ,
3939 ) ;
4040
41- const MINT = Buffer . from ( "mint" ) ;
42- const MINT_NOISE = Buffer . from ( [
43- 89 , 157 , 88 , 232 , 243 , 249 , 197 , 132 , 199 , 49 , 19 , 234 , 91 , 94 , 150 , 41 ,
44- ] ) ;
41+ const mintKeypair : Keypair = Keypair . generate ( ) ;
4542
4643 const PROGRAM_ID = new PublicKey (
4744 "8V26fyhrQobKbvkRCV3KvT6jZQLzviovdARfGrw8kUdG" ,
4845 ) ;
4946
5047 it ( "Create SPL Token" , async ( ) => {
5148 try {
52- const [ mintPDA ] = PublicKey . findProgramAddressSync (
53- [ MINT , MINT_NOISE ] ,
54- PROGRAM_ID ,
55- ) ;
56-
5749 const [ metadataPDA ] = PublicKey . findProgramAddressSync (
5850 [
5951 Buffer . from ( "metadata" ) ,
6052 TOKEN_METADATA_PROGRAM_ID . toBuffer ( ) ,
61- mintPDA . toBuffer ( ) ,
53+ mintKeypair . publicKey . toBuffer ( ) ,
6254 ] ,
6355 TOKEN_METADATA_PROGRAM_ID ,
6456 ) ;
@@ -72,7 +64,7 @@ describe("SPL Token Minter", () => {
7264 const createTokenIx = new TransactionInstruction ( {
7365 keys : [
7466 { pubkey : payer . publicKey , isSigner : true , isWritable : true } ,
75- { pubkey : mintPDA , isSigner : false , isWritable : true } ,
67+ { pubkey : mintKeypair . publicKey , isSigner : true , isWritable : true } ,
7668 { pubkey : metadataPDA , isSigner : false , isWritable : true } ,
7769 {
7870 pubkey : SystemProgram . programId ,
@@ -94,7 +86,7 @@ describe("SPL Token Minter", () => {
9486 const signature = await sendAndConfirmTransaction (
9587 connection ,
9688 new Transaction ( ) . add ( createTokenIx ) ,
97- [ payer ] ,
89+ [ payer , mintKeypair ] ,
9890 { skipPreflight : true } ,
9991 ) ;
10092 console . log ( "Create transaction:" , signature ) ;
@@ -108,13 +100,8 @@ describe("SPL Token Minter", () => {
108100
109101 it ( "Mint tokens" , async ( ) => {
110102 try {
111- const [ mintPDA ] = PublicKey . findProgramAddressSync (
112- [ MINT , MINT_NOISE ] ,
113- PROGRAM_ID ,
114- ) ;
115-
116103 const recipientATA = await getAssociatedTokenAddress (
117- mintPDA ,
104+ mintKeypair . publicKey ,
118105 payer . publicKey ,
119106 ) ;
120107
@@ -126,7 +113,7 @@ describe("SPL Token Minter", () => {
126113 payer . publicKey , // Payer
127114 recipientATA , // ATA Address
128115 payer . publicKey , // Owner
129- mintPDA , // Mint
116+ mintKeypair . publicKey , // Mint
130117 ) ,
131118 ) ;
132119 }
@@ -137,7 +124,7 @@ describe("SPL Token Minter", () => {
137124 keys : [
138125 { pubkey : payer . publicKey , isSigner : true , isWritable : true } , // mint_authority
139126 { pubkey : payer . publicKey , isSigner : false , isWritable : false } , // recipient
140- { pubkey : mintPDA , isSigner : false , isWritable : true } , // mint_pda must be writable
127+ { pubkey : mintKeypair . publicKey , isSigner : false , isWritable : true } , // mint_pda must be writable
141128 { pubkey : recipientATA , isSigner : false , isWritable : true } , // associated_token_account must be writable
142129 { pubkey : TOKEN_PROGRAM_ID , isSigner : false , isWritable : false } , // spl_token::ID
143130 {
0 commit comments