Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit c062243

Browse files
authored
Update Token Metadata (#508)
1 parent 4c2c4ea commit c062243

File tree

11 files changed

+28
-113
lines changed

11 files changed

+28
-113
lines changed

.changeset/dull-jars-listen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@metaplex-foundation/js': patch
3+
---
4+
5+
Update Token Metadata program to v1.11.0

packages/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@metaplex-foundation/mpl-candy-guard": "^0.3.0",
5050
"@metaplex-foundation/mpl-candy-machine": "^5.0.0",
5151
"@metaplex-foundation/mpl-candy-machine-core": "^0.1.2",
52-
"@metaplex-foundation/mpl-token-metadata": "^2.8.6",
52+
"@metaplex-foundation/mpl-token-metadata": "^2.11.0",
5353
"@noble/ed25519": "^1.7.1",
5454
"@noble/hashes": "^1.1.3",
5555
"@solana/spl-account-compression": "^0.1.8",

packages/js/src/plugins/nftModule/DelegateType.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ export type TokenDelegateType =
1414
| 'UtilityV1'
1515
| 'StakingV1';
1616
export type MetadataDelegateType =
17-
// | 'AuthorityV1'
17+
// | 'AuthorityItemV1'
1818
| 'CollectionV1'
1919
// | 'UseV1'
20-
| 'UpdateV1'
20+
| 'DataV1'
2121
| 'ProgrammableConfigV1';
2222

2323
const tokenDelegateRoleMap: Record<TokenDelegateType, TokenDelegateRole> = {
@@ -33,30 +33,33 @@ const metadataDelegateRoleMap: Record<
3333
MetadataDelegateType,
3434
MetadataDelegateRole
3535
> = {
36-
// AuthorityV1: MetadataDelegateRole.Authority,
36+
// AuthorityItemV1: MetadataDelegateRole.AuthorityItem,
3737
CollectionV1: MetadataDelegateRole.Collection,
3838
// UseV1: MetadataDelegateRole.Use,
39-
UpdateV1: MetadataDelegateRole.Update,
39+
DataV1: MetadataDelegateRole.Data,
4040
ProgrammableConfigV1: MetadataDelegateRole.ProgrammableConfig,
4141
};
4242

4343
const metadataDelegateSeedMap: Record<MetadataDelegateRole, string> = {
44-
[MetadataDelegateRole.Authority]: 'authority_delegate',
44+
[MetadataDelegateRole.AuthorityItem]: 'authority_item_delegate',
4545
[MetadataDelegateRole.Collection]: 'collection_delegate',
4646
[MetadataDelegateRole.Use]: 'use_delegate',
47-
[MetadataDelegateRole.Update]: 'update_delegate',
47+
[MetadataDelegateRole.Data]: 'data_delegate',
4848
[MetadataDelegateRole.ProgrammableConfig]: 'programmable_config_delegate',
49+
[MetadataDelegateRole.DataItem]: 'data_item_delegate',
50+
[MetadataDelegateRole.CollectionItem]: 'collection_item_delegate',
51+
[MetadataDelegateRole.ProgrammableConfigItem]: 'prog_config_item_delegate',
4952
};
5053

5154
const delegateCustomDataMap: Record<
5255
TokenDelegateType | MetadataDelegateType,
5356
boolean
5457
> = {
5558
// Metadata.
56-
// AuthorityV1: false,
59+
// AuthorityItemV1: false,
5760
CollectionV1: false,
5861
// UseV1: false,
59-
UpdateV1: false,
62+
DataV1: false,
6063
ProgrammableConfigV1: false,
6164
// Token
6265
StandardV1: true,

packages/js/src/plugins/nftModule/operations/updateNft.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,9 @@ export const updateNftBuilder = (
431431
authorizationRules: auth.accounts.authorizationRules,
432432
authorizationRulesProgram: TOKEN_AUTH_RULES_ID,
433433
},
434-
{ updateArgs: { ...updateInstructionData, ...auth.data } },
434+
{
435+
updateArgs: { ...updateInstructionData, ...auth.data } as any,
436+
},
435437
tokenMetadataProgram.address
436438
),
437439
signers: [payer, ...auth.signers],
@@ -491,7 +493,7 @@ const toInstructionData = (
491493
};
492494
});
493495

494-
return {
496+
return <Omit<UpdateArgs, 'authorityType' | 'authorizationData'>>{
495497
__kind: 'V1',
496498
newUpdateAuthority: input.newUpdateAuthority ?? null,
497499
data: {

packages/js/test/plugins/candyMachineV2Module/createCandyMachineV2.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
CandyMachineV2,
2121
CandyMachineV2Program,
2222
CreateCandyMachineV2Input,
23-
getCandyMachineV2UuidFromAddress,
2423
sol,
2524
toBigNumber,
2625
token,
@@ -61,7 +60,6 @@ test('[candyMachineV2Module] create with minimal input', async (t) => {
6160
version: 2,
6261
tokenMintAddress: null,
6362
collectionMintAddress: null,
64-
uuid: getCandyMachineV2UuidFromAddress(candyMachine.address),
6563
price: spokSameAmount(sol(1.25)),
6664
symbol: '',
6765
sellerFeeBasisPoints: 500,
@@ -302,7 +300,6 @@ test('[candyMachineV2Module] create with whitelistMint settings', async (t) => {
302300

303301
// Then a Candy Machine was created with ...
304302
await tc.assertSuccess(t, response.signature);
305-
console.log(candyMachine.whitelistMintSettings?.discountPrice);
306303
spok(t, candyMachine, {
307304
$topic: 'Candy Machine',
308305
model: 'candyMachineV2',

packages/js/test/plugins/nftModule/createNft.test.ts

Lines changed: 2 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import {
2-
createCreateMasterEditionV3Instruction,
3-
createCreateMetadataAccountV2Instruction,
42
TokenStandard,
53
UseMethod,
64
} from '@metaplex-foundation/mpl-token-metadata';
5+
import { AccountState } from '@solana/spl-token';
76
import { Keypair } from '@solana/web3.js';
87
import spok, { Specifications } from 'spok';
98
import test, { Test } from 'tape';
10-
import { AccountState } from '@solana/spl-token';
119
import {
12-
amman,
1310
assertThrows,
1411
createCollectionNft,
1512
createWallet,
@@ -23,14 +20,7 @@ import {
2320
assertCollectionHasSize,
2421
assertRefreshedCollectionHasSize,
2522
} from './helpers';
26-
import {
27-
Nft,
28-
NftWithToken,
29-
toBigNumber,
30-
token,
31-
toMetaplexFile,
32-
TransactionBuilder,
33-
} from '@/index';
23+
import { Nft, NftWithToken, toBigNumber, token, toMetaplexFile } from '@/index';
3424

3525
killStuckProcess();
3626

@@ -472,85 +462,3 @@ const minimalInput = () => ({
472462
name: 'My NFT',
473463
sellerFeeBasisPoints: 200,
474464
});
475-
476-
/*
477-
* Regression test.
478-
* @see https://github.com/metaplex-foundation/metaplex-program-library/issues/383
479-
*/
480-
test('[nftModule] it works when we give an explicit payer for the create metadata ix only', async (t: Test) => {
481-
// Given we have everything we need to create a Metadata account.
482-
const mx = await metaplex();
483-
const mint = Keypair.generate();
484-
const metadata = mx.nfts().pdas().metadata({ mint: mint.publicKey });
485-
const edition = mx.nfts().pdas().masterEdition({ mint: mint.publicKey });
486-
const { uri } = await mx.nfts().uploadMetadata({ name: 'Metadata Name' });
487-
488-
const data = {
489-
name: 'My NFT',
490-
symbol: 'MNFT',
491-
sellerFeeBasisPoints: 10,
492-
uri,
493-
creators: [
494-
{
495-
address: mx.identity().publicKey,
496-
share: 100,
497-
verified: false,
498-
},
499-
],
500-
collection: null,
501-
uses: null,
502-
};
503-
504-
// And an explicit payer account that is only used to pay for the Metadata account storage.
505-
const explicitPayer = Keypair.generate();
506-
await amman.airdrop(mx.connection, explicitPayer.publicKey, 1);
507-
508-
// When we assemble that transaction.
509-
const tx = TransactionBuilder.make()
510-
.add(
511-
await mx
512-
.tokens()
513-
.builders()
514-
.createTokenWithMint(
515-
{ initialSupply: token(1), mint },
516-
{ payer: mx.identity() }
517-
)
518-
)
519-
.add({
520-
instruction: createCreateMetadataAccountV2Instruction(
521-
{
522-
metadata,
523-
mint: mint.publicKey,
524-
mintAuthority: mx.identity().publicKey,
525-
payer: explicitPayer.publicKey,
526-
updateAuthority: mx.identity().publicKey,
527-
},
528-
{ createMetadataAccountArgsV2: { data, isMutable: false } }
529-
),
530-
signers: [explicitPayer],
531-
})
532-
.add({
533-
instruction: createCreateMasterEditionV3Instruction(
534-
{
535-
edition,
536-
mint: mint.publicKey,
537-
updateAuthority: mx.identity().publicKey,
538-
mintAuthority: mx.identity().publicKey,
539-
payer: explicitPayer.publicKey,
540-
metadata,
541-
},
542-
{
543-
createMasterEditionArgs: { maxSupply: 0 },
544-
}
545-
),
546-
signers: [explicitPayer],
547-
});
548-
549-
// And send it with confirmation.
550-
await mx.rpc().sendAndConfirmTransaction(tx);
551-
552-
// Then the transaction succeeded and the NFT was created.
553-
const nft = await mx.nfts().findByMint({ mintAddress: mint.publicKey });
554-
t.equal(nft.name, 'My NFT');
555-
t.equal(nft.metadataAddress.toBase58(), metadata.toBase58());
556-
});

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

programs/mpl_candy_guard.so

-155 KB
Binary file not shown.

programs/mpl_candy_machine.so

93.9 KB
Binary file not shown.

programs/mpl_candy_machine_core.so

297 KB
Binary file not shown.

0 commit comments

Comments
 (0)