From 7acca82883f90a65156de1d602db0a55d5f5d865 Mon Sep 17 00:00:00 2001 From: Tristan Date: Wed, 15 May 2024 21:07:51 +0800 Subject: [PATCH] fix option account of verify collection --- .../metaplex/token_metadata/instruction.go | 8 +++++ .../token_metadata/instruction_test.go | 29 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/program/metaplex/token_metadata/instruction.go b/program/metaplex/token_metadata/instruction.go index 9d9ca58c..b9dcd097 100644 --- a/program/metaplex/token_metadata/instruction.go +++ b/program/metaplex/token_metadata/instruction.go @@ -649,6 +649,7 @@ type VerifyCollectionParams struct { CollectionMint common.PublicKey Collection common.PublicKey CollectionMasterEditionAccount common.PublicKey + CollectionAuthorityRecord *common.PublicKey } func CreateVerifyCollection(param VerifyCollectionParams) types.Instruction { @@ -692,6 +693,13 @@ func CreateVerifyCollection(param VerifyCollectionParams) types.Instruction { IsSigner: false, }, } + if param.CollectionAuthorityRecord != nil { + accounts = append(accounts, types.AccountMeta{ + PubKey: *param.CollectionAuthorityRecord, + IsWritable: false, + IsSigner: false, + }) + } return types.Instruction{ ProgramID: common.MetaplexTokenMetaProgramID, Accounts: accounts, diff --git a/program/metaplex/token_metadata/instruction_test.go b/program/metaplex/token_metadata/instruction_test.go index f159c89b..bf00b023 100644 --- a/program/metaplex/token_metadata/instruction_test.go +++ b/program/metaplex/token_metadata/instruction_test.go @@ -489,6 +489,35 @@ func TestCreateVerifyCollection(t *testing.T) { Data: []byte{18}, }, }, + { + args: args{ + param: VerifyCollectionParams{ + Metadata: common.PublicKeyFromString("MetaData11111111111111111111111111111111111"), + CollectionUpdateAuthority: common.PublicKeyFromString("CollectionUpdateAuthority111111111111111111"), + Payer: common.PublicKeyFromString("payer11111111111111111111111111111111111111"), + CollectionMint: common.PublicKeyFromString("CollectionMint11111111111111111111111111111"), + Collection: common.PublicKeyFromString("Collection111111111111111111111111111111111"), + CollectionMasterEditionAccount: common.PublicKeyFromString("CollectionMasterEditionAccount1111111111111"), + CollectionAuthorityRecord: func() *common.PublicKey { + r := common.PublicKeyFromString("CollectionAuthorityRecord111111111111111111") + return &r + }(), + }, + }, + want: types.Instruction{ + ProgramID: common.MetaplexTokenMetaProgramID, + Accounts: []types.AccountMeta{ + {PubKey: common.PublicKeyFromString("MetaData11111111111111111111111111111111111"), IsSigner: false, IsWritable: true}, + {PubKey: common.PublicKeyFromString("CollectionUpdateAuthority111111111111111111"), IsSigner: true, IsWritable: true}, + {PubKey: common.PublicKeyFromString("payer11111111111111111111111111111111111111"), IsSigner: true, IsWritable: true}, + {PubKey: common.PublicKeyFromString("CollectionMint11111111111111111111111111111"), IsSigner: false, IsWritable: false}, + {PubKey: common.PublicKeyFromString("Collection111111111111111111111111111111111"), IsSigner: false, IsWritable: false}, + {PubKey: common.PublicKeyFromString("CollectionMasterEditionAccount1111111111111"), IsSigner: false, IsWritable: false}, + {PubKey: common.PublicKeyFromString("CollectionAuthorityRecord111111111111111111"), IsSigner: false, IsWritable: false}, + }, + Data: []byte{18}, + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {