Skip to content

Commit

Permalink
added extra tests and changed resolver default to V2
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyboylehub committed Jul 17, 2024
1 parent c5e84bd commit 32710ae
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 3 additions & 1 deletion clients/js/src/hooked/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export const resolveCollectionDetails = (
args: { isCollection?: boolean },
...rest: any[]
): Option<CollectionDetailsArgs> =>
args.isCollection ? some(collectionDetails('V1', { size: 0 })) : none();
args.isCollection
? some(collectionDetails('V2', { padding: new Array(8).fill(0) }))
: none();

export const resolveIsNonFungible = (
context: any,
Expand Down
30 changes: 29 additions & 1 deletion clients/js/test/createV1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,13 @@ test('it can create a new FungibleAsset', async (t) => {
});
});

test('it can create a collection NonFungible', async (t) => {
test('it can create a collection and defaults to collectionV2', 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,
Expand All @@ -249,6 +251,32 @@ test('it can create a collection NonFungible', async (t) => {
isCollection: true,
}).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 collectionV1 NonFungible', async (t) => {
// Given a new mint Signer.
const umi = await createUmi();
const mint = generateSigner(umi);

// 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: some(collectionDetails('V1', { size: 0n })),
}).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);
Expand Down

0 comments on commit 32710ae

Please sign in to comment.