Skip to content

Commit

Permalink
fix and test for collectioV2
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyboylehub committed Jul 15, 2024
1 parent 9676a21 commit 43882dc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions clients/js/test/createV1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,32 @@ test('it can create a collection NonFungible', async (t) => {
});
});

test('it can create a collectionV2 NonFungible', async (t) => {
// Given a new mint Signer.
const umi = await createUmi();
const mint = generateSigner(umi);

const collectionV2Padding = new Array(8).fill(0);

// When we create a new NonFungible at this address.
await createV1(umi, {
mint,
name: 'My Collection NFT',
uri: 'https://example.com/my-collection-nft.json',
sellerFeeBasisPoints: percentAmount(5.5),
isCollection: true,
collectionDetails: collectionDetails('V2', { padding: collectionV2Padding }),
}).sendAndConfirm(umi);

// Then a Metadata account was created with the collection details set.
const metadata = findMetadataPda(umi, { mint: mint.publicKey });
const metadataAccount = await fetchMetadata(umi, metadata);
t.like(metadataAccount, <Metadata>{
publicKey: publicKey(metadata),
collectionDetails: some(collectionDetails('V2', { padding: collectionV2Padding })),
});
});

test('it can create a NonFungible from an existing mint', async (t) => {
// Given an existing mint account.
const umi = await createUmi();
Expand Down
2 changes: 1 addition & 1 deletion programs/token-metadata/program/src/utils/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub fn process_create_metadata_accounts_logic(
metadata.collection_details = Some(CollectionDetails::V1 { size: 0 });
}
CollectionDetails::V2 { padding: _ } => {
metadata.collection_details = None;
metadata.collection_details = Some(CollectionDetails::V2 { padding: [0; 8] });
}
}
} else {
Expand Down

0 comments on commit 43882dc

Please sign in to comment.