Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updatable Metadata #3

Merged
Merged
7 changes: 4 additions & 3 deletions clients/js-solita/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"postpublish": "git push origin && git push origin --tags",
"build:docs": "typedoc",
"build": "rimraf dist && tsc -p tsconfig.json",
"start-validator": "solana-test-validator -ud --quiet --reset -c cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK -c 4VTQredsAmr1yzRJugLV6Mt6eu6XMeCwdkZ73wwVMWHv -c noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV -c 3RHkdjCwWyK2firrwFQGvXCxbUpBky1GTmb9EDK9hUnX -c metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s -c PwDiXFxQsGra4sFFTT8r1QWRMd4vfumiWC1jfWNfdYT --bpf-program BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY ../../programs/.bin/mpl_bubblegum.so",
"start-validator": "solana-test-validator -ud --quiet --reset -c cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK -c 4VTQredsAmr1yzRJugLV6Mt6eu6XMeCwdkZ73wwVMWHv -c noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV -c 3RHkdjCwWyK2firrwFQGvXCxbUpBky1GTmb9EDK9hUnX -c metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s -c PwDiXFxQsGra4sFFTT8r1QWRMd4vfumiWC1jfWNfdYT -c TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA -c ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL --bpf-program BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY ../../programs/.bin/mpl_bubblegum.so",
samwise2 marked this conversation as resolved.
Show resolved Hide resolved
"run-tests": "jest tests --detectOpenHandles",
"test": "start-server-and-test start-validator http://localhost:8899/health run-tests",
"api:gen": "DEBUG='(solita|rustbin):(info|error)' solita",
Expand Down Expand Up @@ -54,12 +54,13 @@
"@metaplex-foundation/amman": "0.12.1",
"@metaplex-foundation/rustbin": "^0.3.5",
"@metaplex-foundation/solita": "0.20.0",
"@metaplex-foundation/js": "^0.19.4",
"@solana/spl-account-compression": "^0.1.4",
"@types/bn.js": "^5.1.1",
"@types/chai": "^4.3.0",
"@types/jest": "^29.1.1",
"@types/mocha": "^9.0.0",
"@types/tape": "^4.13.2",
"@types/bn.js": "^5.1.1",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"chai": "^4.3.4",
Expand All @@ -80,4 +81,4 @@
"typescript": "^4.3.5",
"typescript-collections": "^1.3.3"
}
}
}
100 changes: 100 additions & 0 deletions clients/js-solita/src/generated/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,106 @@ export class DecompressionDisabledError extends Error {
createErrorFromCodeLookup.set(0x1791, () => new DecompressionDisabledError());
createErrorFromNameLookup.set('DecompressionDisabled', () => new DecompressionDisabledError());

/**
* MetadataImmutable: 'Metadata not mutable'
*
* @category Errors
* @category generated
*/
export class MetadataImmutableError extends Error {
readonly code: number = 0x1792;
readonly name: string = 'MetadataImmutable';
constructor() {
super('Metadata not mutable');
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, MetadataImmutableError);
}
}
}

createErrorFromCodeLookup.set(0x1792, () => new MetadataImmutableError());
createErrorFromNameLookup.set('MetadataImmutable', () => new MetadataImmutableError());

/**
* CollectionMismatch: 'Collection mismatch'
*
* @category Errors
* @category generated
*/
export class CollectionMismatchError extends Error {
readonly code: number = 0x1793;
readonly name: string = 'CollectionMismatch';
constructor() {
super('Collection mismatch');
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, CollectionMismatchError);
}
}
}

createErrorFromCodeLookup.set(0x1793, () => new CollectionMismatchError());
createErrorFromNameLookup.set('CollectionMismatch', () => new CollectionMismatchError());

/**
* MetadataArgsAmbiguous: 'MetadataArgs ambiguous'
*
* @category Errors
* @category generated
*/
export class MetadataArgsAmbiguousError extends Error {
readonly code: number = 0x1794;
readonly name: string = 'MetadataArgsAmbiguous';
constructor() {
super('MetadataArgs ambiguous');
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, MetadataArgsAmbiguousError);
}
}
}

createErrorFromCodeLookup.set(0x1794, () => new MetadataArgsAmbiguousError());
createErrorFromNameLookup.set('MetadataArgsAmbiguous', () => new MetadataArgsAmbiguousError());

/**
* MetadataArgsMissing: 'MetadataArgs missing'
*
* @category Errors
* @category generated
*/
export class MetadataArgsMissingError extends Error {
readonly code: number = 0x1795;
readonly name: string = 'MetadataArgsMissing';
constructor() {
super('MetadataArgs missing');
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, MetadataArgsMissingError);
}
}
}

createErrorFromCodeLookup.set(0x1795, () => new MetadataArgsMissingError());
createErrorFromNameLookup.set('MetadataArgsMissing', () => new MetadataArgsMissingError());

/**
* NFTLinkedToCollection: 'NFT linked to collection'
*
* @category Errors
* @category generated
*/
export class NFTLinkedToCollectionError extends Error {
readonly code: number = 0x1796;
readonly name: string = 'NFTLinkedToCollection';
constructor() {
super('NFT linked to collection');
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, NFTLinkedToCollectionError);
}
}
}

createErrorFromCodeLookup.set(0x1796, () => new NFTLinkedToCollectionError());
createErrorFromNameLookup.set('NFTLinkedToCollection', () => new NFTLinkedToCollectionError());

/**
* Attempts to resolve a custom program error from the provided error code.
* @category Errors
Expand Down
2 changes: 2 additions & 0 deletions clients/js-solita/src/generated/instructions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ export * from './setTreeDelegate';
export * from './transfer';
export * from './unverifyCollection';
export * from './unverifyCreator';
export * from './updateMetadata';
export * from './updateMetadataCollectionNft';
export * from './verifyCollection';
export * from './verifyCreator';
180 changes: 180 additions & 0 deletions clients/js-solita/src/generated/instructions/updateMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/**
* This code was GENERATED using the solita package.
* Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality.
*
* See: https://github.com/metaplex-foundation/solita
*/

import * as beet from '@metaplex-foundation/beet';
import * as web3 from '@solana/web3.js';
import { MetadataArgs, metadataArgsBeet } from '../types/MetadataArgs';
import { Creator, creatorBeet } from '../types/Creator';

/**
* @category Instructions
* @category UpdateMetadata
* @category generated
*/
export type UpdateMetadataInstructionArgs = {
root: number[] /* size: 32 */;
oldMetadata: beet.COption<MetadataArgs>;
newName: beet.COption<string>;
newSymbol: beet.COption<string>;
newUri: beet.COption<string>;
newCreators: beet.COption<Creator[]>;
newSellerFeeBasisPoints: beet.COption<number>;
newPrimarySaleHappened: beet.COption<boolean>;
newIsMutable: beet.COption<boolean>;
nonce: beet.bignum;
index: number;
};
/**
* @category Instructions
* @category UpdateMetadata
* @category generated
*/
export const updateMetadataStruct = new beet.FixableBeetArgsStruct<
UpdateMetadataInstructionArgs & {
instructionDiscriminator: number[] /* size: 8 */;
}
>(
[
['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)],
['root', beet.uniformFixedSizeArray(beet.u8, 32)],
['oldMetadata', beet.coption(metadataArgsBeet)],
['newName', beet.coption(beet.utf8String)],
['newSymbol', beet.coption(beet.utf8String)],
['newUri', beet.coption(beet.utf8String)],
['newCreators', beet.coption(beet.array(creatorBeet))],
['newSellerFeeBasisPoints', beet.coption(beet.u16)],
['newPrimarySaleHappened', beet.coption(beet.bool)],
['newIsMutable', beet.coption(beet.bool)],
['nonce', beet.u64],
['index', beet.u32],
],
'UpdateMetadataInstructionArgs',
);
/**
* Accounts required by the _updateMetadata_ instruction
*
* @property [] oldMetadataAcct
* @property [] treeAuthority
* @property [**signer**] treeDelegate
* @property [] leafOwner
* @property [] leafDelegate
* @property [**signer**] payer
* @property [_writable_] merkleTree
* @property [] logWrapper
* @property [] compressionProgram
* @property [] tokenMetadataProgram
* @category Instructions
* @category UpdateMetadata
* @category generated
*/
export type UpdateMetadataInstructionAccounts = {
oldMetadataAcct: web3.PublicKey;
treeAuthority: web3.PublicKey;
treeDelegate: web3.PublicKey;
leafOwner: web3.PublicKey;
leafDelegate: web3.PublicKey;
payer: web3.PublicKey;
merkleTree: web3.PublicKey;
logWrapper: web3.PublicKey;
compressionProgram: web3.PublicKey;
tokenMetadataProgram: web3.PublicKey;
systemProgram?: web3.PublicKey;
anchorRemainingAccounts?: web3.AccountMeta[];
};

export const updateMetadataInstructionDiscriminator = [170, 182, 43, 239, 97, 78, 225, 186];

/**
* Creates a _UpdateMetadata_ instruction.
*
* @param accounts that will be accessed while the instruction is processed
* @param args to provide as instruction data to the program
*
* @category Instructions
* @category UpdateMetadata
* @category generated
*/
export function createUpdateMetadataInstruction(
accounts: UpdateMetadataInstructionAccounts,
args: UpdateMetadataInstructionArgs,
programId = new web3.PublicKey('BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY'),
) {
const [data] = updateMetadataStruct.serialize({
instructionDiscriminator: updateMetadataInstructionDiscriminator,
...args,
});
const keys: web3.AccountMeta[] = [
{
pubkey: accounts.oldMetadataAcct,
isWritable: false,
isSigner: false,
},
{
pubkey: accounts.treeAuthority,
isWritable: false,
isSigner: false,
},
{
pubkey: accounts.treeDelegate,
isWritable: false,
isSigner: true,
},
{
pubkey: accounts.leafOwner,
isWritable: false,
isSigner: false,
},
{
pubkey: accounts.leafDelegate,
isWritable: false,
isSigner: false,
},
{
pubkey: accounts.payer,
isWritable: false,
isSigner: true,
},
{
pubkey: accounts.merkleTree,
isWritable: true,
isSigner: false,
},
{
pubkey: accounts.logWrapper,
isWritable: false,
isSigner: false,
},
{
pubkey: accounts.compressionProgram,
isWritable: false,
isSigner: false,
},
{
pubkey: accounts.tokenMetadataProgram,
isWritable: false,
isSigner: false,
},
{
pubkey: accounts.systemProgram ?? web3.SystemProgram.programId,
isWritable: false,
isSigner: false,
},
];

if (accounts.anchorRemainingAccounts != null) {
for (const acc of accounts.anchorRemainingAccounts) {
keys.push(acc);
}
}

const ix = new web3.TransactionInstruction({
programId,
keys,
data,
});
return ix;
}
Loading