@@ -366,6 +366,55 @@ describe('Token-2022 Transfer Hook — Account Data As Seed (Pinocchio)', () =>
366366 assert . equal ( counterValue ( ) , 2n , 'the counter advanced to two' ) ;
367367 } ) ;
368368
369+ it ( 'Configures a second mint against the existing counter' , async ( ) => {
370+ // The counter is keyed by owner, not by mint, so setting up a second
371+ // mint for the same payer must reuse it. Creating it again would fail
372+ // and roll the whole setup back, leaving every mint after the first
373+ // unable to use this hook.
374+ const secondMint = await generateKeyPairSigner ( ) ;
375+ const initIx = {
376+ programAddress : programId ,
377+ accounts : [
378+ { address : payer . address , role : AccountRole . WRITABLE_SIGNER , signer : payer } ,
379+ { address : secondMint . address , role : AccountRole . WRITABLE_SIGNER , signer : secondMint } ,
380+ { address : TOKEN_2022_PROGRAM_ADDRESS , role : AccountRole . READONLY } ,
381+ { address : SYSTEM_PROGRAM_ADDRESS , role : AccountRole . READONLY } ,
382+ ] ,
383+ data : Uint8Array . of ( INITIALIZE_DISCRIMINATOR , DECIMALS ) ,
384+ } ;
385+ send ( await tx ( [ initIx ] ) , 'initialize second mint' ) ;
386+
387+ const [ secondMetaList ] = await getProgramDerivedAddress ( {
388+ programAddress : programId ,
389+ seeds : [ 'extra-account-metas' , addressEncoder . encode ( secondMint . address ) ] ,
390+ } ) ;
391+ const countBefore = counterValue ( ) ;
392+
393+ const metasIx = {
394+ programAddress : programId ,
395+ accounts : [
396+ { address : payer . address , role : AccountRole . WRITABLE_SIGNER , signer : payer } ,
397+ { address : secondMetaList , role : AccountRole . WRITABLE } ,
398+ { address : secondMint . address , role : AccountRole . READONLY } ,
399+ { address : counter , role : AccountRole . WRITABLE } ,
400+ { address : TOKEN_2022_PROGRAM_ADDRESS , role : AccountRole . READONLY } ,
401+ { address : ASSOCIATED_TOKEN_PROGRAM_ADDRESS , role : AccountRole . READONLY } ,
402+ { address : SYSTEM_PROGRAM_ADDRESS , role : AccountRole . READONLY } ,
403+ ] ,
404+ data : INITIALIZE_EXTRA_ACCOUNT_META_LIST_DISCRIMINATOR ,
405+ } ;
406+ send ( await tx ( [ metasIx ] ) , 'initialize second extra account meta list' ) ;
407+
408+ const account = svm . getAccount ( secondMetaList ) ;
409+ if ( ! account ?. exists ) throw new Error ( 'second extra account meta list not found' ) ;
410+ assert . deepEqual (
411+ Array . from ( account . data ) ,
412+ Array . from ( EXPECTED_EXTRA_ACCOUNT_METAS ) ,
413+ 'the second mint got its own list' ,
414+ ) ;
415+ assert . equal ( counterValue ( ) , countBefore , "the owner's counter kept its value" ) ;
416+ } ) ;
417+
369418 it ( 'Rejects calling the hook outside a transfer' , async ( ) => {
370419 // Same accounts Token-2022 would pass, but invoked directly. The source
371420 // account's `transferring` flag is only set mid-transfer, so this fails.
0 commit comments