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

Commit b6d9571

Browse files
authored
Update Token Metadata program (#487)
* Update Token Metadata program * Fix build * Add optional token account to metadata authority
1 parent 2c6980d commit b6d9571

File tree

7 files changed

+28
-9
lines changed

7 files changed

+28
-9
lines changed

.changeset/honest-swans-shake.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

packages/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@metaplex-foundation/mpl-candy-guard": "^0.3.0",
4949
"@metaplex-foundation/mpl-candy-machine": "^5.0.0",
5050
"@metaplex-foundation/mpl-candy-machine-core": "^0.1.2",
51-
"@metaplex-foundation/mpl-token-metadata": "^2.7.0",
51+
"@metaplex-foundation/mpl-token-metadata": "^2.8.6",
5252
"@noble/ed25519": "^1.7.1",
5353
"@noble/hashes": "^1.1.3",
5454
"@solana/spl-token": "^0.3.5",

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type TokenMetadataAuthority =
3131
export type TokenMetadataAuthorityMetadata = {
3232
__kind: 'metadata';
3333
updateAuthority: Signer;
34+
token?: PublicKey;
3435
};
3536

3637
/** An approved delegate authority of the metadata account for a given action. */
@@ -79,7 +80,7 @@ export type ParsedTokenMetadataAuthorization = {
7980
approver?: PublicKey;
8081
/**
8182
* If "delegate" authority, the address of the token record
82-
* or the metdata delegate record PDA depending on the type.
83+
* or the metadata delegate record PDA depending on the type.
8384
*/
8485
delegateRecord?: PublicKey;
8586
/** If any auth rules are provided, the address of the auth rule account. */
@@ -109,6 +110,7 @@ export const parseTokenMetadataAuthorization = (
109110

110111
if (input.authority.__kind === 'metadata') {
111112
auth.accounts.authority = input.authority.updateAuthority.publicKey;
113+
auth.accounts.token = input.authority.token;
112114
auth.signers.push(input.authority.updateAuthority);
113115
auth.data.authorityType = AuthorityType.Metadata;
114116
} else if (input.authority.__kind === 'metadataDelegate') {
@@ -122,7 +124,7 @@ export const parseTokenMetadataAuthorization = (
122124
auth.accounts.delegateRecord = delegateRecord;
123125
auth.accounts.approver = approver;
124126
auth.signers.push(input.authority.delegate);
125-
auth.data.authorityType = AuthorityType.Delegate;
127+
auth.data.authorityType = AuthorityType.MetadataDelegate;
126128
} else if (input.authority.__kind === 'tokenDelegate') {
127129
const { delegateRecord, approver, tokenAccount } =
128130
parseTokenMetadataDelegateInput(
@@ -136,7 +138,7 @@ export const parseTokenMetadataAuthorization = (
136138
auth.accounts.delegateRecord = delegateRecord;
137139
auth.accounts.approver = approver;
138140
auth.signers.push(input.authority.delegate);
139-
auth.data.authorityType = AuthorityType.Delegate;
141+
auth.data.authorityType = AuthorityType.TokenDelegate;
140142
} else if (input.authority.__kind === 'holder') {
141143
auth.accounts.authority = input.authority.owner.publicKey;
142144
auth.accounts.token = input.authority.token;

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@ import { UnreachableCaseError } from '@/errors';
99
export type TokenDelegateType =
1010
| 'StandardV1'
1111
| 'TransferV1'
12+
| 'LockedTransferV1'
1213
| 'SaleV1'
1314
| 'UtilityV1'
1415
| 'StakingV1';
1516
export type MetadataDelegateType =
1617
// | 'AuthorityV1'
1718
| 'CollectionV1'
1819
// | 'UseV1'
19-
| 'UpdateV1';
20+
| 'UpdateV1'
21+
| 'ProgrammableConfigV1';
2022

2123
const tokenDelegateRoleMap: Record<TokenDelegateType, TokenDelegateRole> = {
2224
StandardV1: TokenDelegateRole.Standard,
2325
TransferV1: TokenDelegateRole.Transfer,
26+
LockedTransferV1: TokenDelegateRole.LockedTransfer,
2427
SaleV1: TokenDelegateRole.Sale,
2528
UtilityV1: TokenDelegateRole.Utility,
2629
StakingV1: TokenDelegateRole.Staking,
@@ -34,13 +37,15 @@ const metadataDelegateRoleMap: Record<
3437
CollectionV1: MetadataDelegateRole.Collection,
3538
// UseV1: MetadataDelegateRole.Use,
3639
UpdateV1: MetadataDelegateRole.Update,
40+
ProgrammableConfigV1: MetadataDelegateRole.ProgrammableConfig,
3741
};
3842

3943
const metadataDelegateSeedMap: Record<MetadataDelegateRole, string> = {
4044
[MetadataDelegateRole.Authority]: 'authority_delegate',
4145
[MetadataDelegateRole.Collection]: 'collection_delegate',
4246
[MetadataDelegateRole.Use]: 'use_delegate',
4347
[MetadataDelegateRole.Update]: 'update_delegate',
48+
[MetadataDelegateRole.ProgrammableConfig]: 'programmable_config_delegate',
4449
};
4550

4651
const delegateCustomDataMap: Record<
@@ -52,12 +57,14 @@ const delegateCustomDataMap: Record<
5257
CollectionV1: false,
5358
// UseV1: false,
5459
UpdateV1: false,
60+
ProgrammableConfigV1: false,
5561
// Token
5662
StandardV1: true,
5763
TransferV1: true,
5864
SaleV1: true,
5965
UtilityV1: true,
6066
StakingV1: true,
67+
LockedTransferV1: true,
6168
};
6269

6370
export const getTokenDelegateRole = (

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,11 @@ test('[nftModule] it can add rulesets to programmable NFTs', async (t: Test) =>
471471
await mx.nfts().update({
472472
nftOrSft: nft,
473473
ruleSet: ruleSet.publicKey,
474+
authority: {
475+
__kind: 'metadata',
476+
updateAuthority: mx.identity(),
477+
token: nft.token.address,
478+
},
474479
});
475480

476481
// Then the updated NFT has a new programmable configs containing that ruleset.

pnpm-lock.yaml

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

programs/mpl_token_metadata.so

-62.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)