From 54635fce6244b685f6eca12d2acf13929c35c0b0 Mon Sep 17 00:00:00 2001 From: Sam Orend Date: Fri, 16 Jun 2023 23:41:33 -0400 Subject: [PATCH] generate api --- bubblegum/js/idl/bubblegum.json | 542 +++++++++++++++++- bubblegum/js/src/generated/errors/index.ts | 40 ++ .../js/src/generated/instructions/index.ts | 1 + .../generated/instructions/updateMetadata.ts | 198 +++++++ .../js/src/generated/types/InstructionName.ts | 1 + 5 files changed, 751 insertions(+), 31 deletions(-) create mode 100644 bubblegum/js/src/generated/instructions/updateMetadata.ts diff --git a/bubblegum/js/idl/bubblegum.json b/bubblegum/js/idl/bubblegum.json index c49cfd7535..99313382da 100644 --- a/bubblegum/js/idl/bubblegum.json +++ b/bubblegum/js/idl/bubblegum.json @@ -8,7 +8,16 @@ { "name": "treeAuthority", "isMut": true, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } }, { "name": "merkleTree", @@ -64,7 +73,19 @@ { "name": "treeAuthority", "isMut": true, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + }, + "relations": [ + "tree_creator" + ] }, { "name": "treeCreator", @@ -95,7 +116,16 @@ { "name": "treeAuthority", "isMut": true, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } }, { "name": "leafOwner", @@ -153,7 +183,16 @@ { "name": "treeAuthority", "isMut": true, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } }, { "name": "leafOwner", @@ -188,7 +227,11 @@ { "name": "collectionAuthorityRecordPda", "isMut": false, - "isSigner": false + "isSigner": false, + "docs": [ + "If there is no collecton authority record PDA then", + "this must be the Bubblegum program address." + ] }, { "name": "collectionMint", @@ -208,7 +251,16 @@ { "name": "bubblegumSigner", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "const", + "type": "string", + "value": "collection_cpi" + } + ] + } }, { "name": "logWrapper", @@ -246,7 +298,16 @@ { "name": "treeAuthority", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } }, { "name": "leafOwner", @@ -339,7 +400,16 @@ { "name": "treeAuthority", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } }, { "name": "leafOwner", @@ -432,7 +502,16 @@ { "name": "treeAuthority", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } }, { "name": "leafOwner", @@ -457,7 +536,11 @@ { "name": "treeDelegate", "isMut": false, - "isSigner": false + "isSigner": false, + "docs": [ + "the case of `set_and_verify_collection` where", + "we are actually changing the NFT metadata." + ] }, { "name": "collectionAuthority", @@ -467,7 +550,11 @@ { "name": "collectionAuthorityRecordPda", "isMut": false, - "isSigner": false + "isSigner": false, + "docs": [ + "If there is no collecton authority record PDA then", + "this must be the Bubblegum program address." + ] }, { "name": "collectionMint", @@ -487,7 +574,16 @@ { "name": "bubblegumSigner", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "const", + "type": "string", + "value": "collection_cpi" + } + ] + } }, { "name": "logWrapper", @@ -560,7 +656,16 @@ { "name": "treeAuthority", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } }, { "name": "leafOwner", @@ -585,7 +690,11 @@ { "name": "treeDelegate", "isMut": false, - "isSigner": false + "isSigner": false, + "docs": [ + "the case of `set_and_verify_collection` where", + "we are actually changing the NFT metadata." + ] }, { "name": "collectionAuthority", @@ -595,7 +704,11 @@ { "name": "collectionAuthorityRecordPda", "isMut": false, - "isSigner": false + "isSigner": false, + "docs": [ + "If there is no collecton authority record PDA then", + "this must be the Bubblegum program address." + ] }, { "name": "collectionMint", @@ -615,7 +728,16 @@ { "name": "bubblegumSigner", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "const", + "type": "string", + "value": "collection_cpi" + } + ] + } }, { "name": "logWrapper", @@ -688,7 +810,16 @@ { "name": "treeAuthority", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } }, { "name": "leafOwner", @@ -713,7 +844,11 @@ { "name": "treeDelegate", "isMut": false, - "isSigner": false + "isSigner": false, + "docs": [ + "the case of `set_and_verify_collection` where", + "we are actually changing the NFT metadata." + ] }, { "name": "collectionAuthority", @@ -723,7 +858,11 @@ { "name": "collectionAuthorityRecordPda", "isMut": false, - "isSigner": false + "isSigner": false, + "docs": [ + "If there is no collecton authority record PDA then", + "this must be the Bubblegum program address." + ] }, { "name": "collectionMint", @@ -743,7 +882,16 @@ { "name": "bubblegumSigner", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "const", + "type": "string", + "value": "collection_cpi" + } + ] + } }, { "name": "logWrapper", @@ -815,11 +963,45 @@ ] }, { - "name": "transfer", + "name": "updateMetadata", "accounts": [ { "name": "treeAuthority", "isMut": false, + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } + }, + { + "name": "treeDelegate", + "isMut": false, + "isSigner": true + }, + { + "name": "collectionAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "collectionMint", + "isMut": false, + "isSigner": false + }, + { + "name": "collectionMetadata", + "isMut": false, + "isSigner": false + }, + { + "name": "collectionAuthorityRecordPda", + "isMut": false, "isSigner": false }, { @@ -832,6 +1014,126 @@ "isMut": false, "isSigner": false }, + { + "name": "payer", + "isMut": false, + "isSigner": true + }, + { + "name": "merkleTree", + "isMut": true, + "isSigner": false + }, + { + "name": "logWrapper", + "isMut": false, + "isSigner": false + }, + { + "name": "compressionProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenMetadataProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "root", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "oldMetadata", + "type": { + "defined": "MetadataArgs" + } + }, + { + "name": "newName", + "type": { + "option": "string" + } + }, + { + "name": "newSymbol", + "type": { + "option": "string" + } + }, + { + "name": "newUri", + "type": { + "option": "string" + } + }, + { + "name": "newSellerFeeBasisPoints", + "type": { + "option": "u16" + } + }, + { + "name": "newPrimarySaleHappened", + "type": { + "option": "bool" + } + }, + { + "name": "newIsMutable", + "type": { + "option": "bool" + } + }, + { + "name": "nonce", + "type": "u64" + }, + { + "name": "index", + "type": "u32" + } + ] + }, + { + "name": "transfer", + "accounts": [ + { + "name": "treeAuthority", + "isMut": false, + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } + }, + { + "name": "leafOwner", + "isMut": false, + "isSigner": false + }, + { + "name": "leafDelegate", + "isMut": false, + "isSigner": false + }, { "name": "newLeafOwner", "isMut": false, @@ -902,7 +1204,16 @@ { "name": "treeAuthority", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } }, { "name": "leafOwner", @@ -984,7 +1295,16 @@ { "name": "treeAuthority", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } }, { "name": "leafOwner", @@ -1061,7 +1381,16 @@ { "name": "treeAuthority", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } }, { "name": "leafOwner", @@ -1081,7 +1410,26 @@ { "name": "voucher", "isMut": true, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "const", + "type": "string", + "value": "voucher" + }, + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + }, + { + "kind": "arg", + "type": "u64", + "path": "nonce" + } + ] + } }, { "name": "logWrapper", @@ -1143,7 +1491,16 @@ { "name": "treeAuthority", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } }, { "name": "leafOwner", @@ -1158,7 +1515,29 @@ { "name": "voucher", "isMut": true, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "const", + "type": "string", + "value": "voucher" + }, + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + }, + { + "kind": "account", + "type": { + "defined": "LeafSchema" + }, + "account": "Voucher", + "path": "voucher.leaf_schema" + } + ] + } }, { "name": "logWrapper", @@ -1194,7 +1573,30 @@ { "name": "voucher", "isMut": true, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "const", + "type": "string", + "value": "voucher" + }, + { + "kind": "account", + "type": "publicKey", + "account": "Voucher", + "path": "voucher.merkle_tree" + }, + { + "kind": "account", + "type": { + "defined": "LeafSchema" + }, + "account": "Voucher", + "path": "voucher.leaf_schema" + } + ] + } }, { "name": "leafOwner", @@ -1209,12 +1611,44 @@ { "name": "mint", "isMut": true, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "const", + "type": "string", + "value": "asset" + }, + { + "kind": "account", + "type": "publicKey", + "account": "Voucher", + "path": "voucher.merkle_tree" + }, + { + "kind": "account", + "type": { + "defined": "LeafSchema" + }, + "account": "Voucher", + "path": "voucher.leaf_schema" + } + ] + } }, { "name": "mintAuthority", "isMut": true, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "mint" + } + ] + } }, { "name": "metadata", @@ -1272,7 +1706,16 @@ { "name": "treeAuthority", "isMut": false, - "isSigner": false + "isSigner": false, + "pda": { + "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "merkle_tree" + } + ] + } }, { "name": "leafOwner", @@ -1461,18 +1904,30 @@ "fields": [ { "name": "name", + "docs": [ + "The name of the asset" + ], "type": "string" }, { "name": "symbol", + "docs": [ + "The symbol for the asset" + ], "type": "string" }, { "name": "uri", + "docs": [ + "URI pointing to JSON representing the asset" + ], "type": "string" }, { "name": "sellerFeeBasisPoints", + "docs": [ + "Royalty basis points that goes to creators in secondary sales (0-10000)" + ], "type": "u16" }, { @@ -1485,12 +1940,18 @@ }, { "name": "editionNonce", + "docs": [ + "nonce for easy calculation of editions, if present" + ], "type": { "option": "u8" } }, { "name": "tokenStandard", + "docs": [ + "Since we cannot easily change Metadata, we add the new DataV2 fields here at the end." + ], "type": { "option": { "defined": "TokenStandard" @@ -1499,6 +1960,9 @@ }, { "name": "collection", + "docs": [ + "Collection" + ], "type": { "option": { "defined": "Collection" @@ -1507,6 +1971,9 @@ }, { "name": "uses", + "docs": [ + "Uses" + ], "type": { "option": { "defined": "Uses" @@ -1705,6 +2172,9 @@ }, { "name": "MintToCollectionV1" + }, + { + "name": "UpdateMetadata" } ] } @@ -1845,6 +2315,16 @@ "code": 6026, "name": "CollectionMustBeSized", "msg": "Collection Not Compatable with Compression, Must be Sized" + }, + { + "code": 6027, + "name": "MetadataImmutable", + "msg": "Metadata Not Mutable" + }, + { + "code": 6028, + "name": "CollectionMismatch", + "msg": "Collection mismatch" } ], "metadata": { diff --git a/bubblegum/js/src/generated/errors/index.ts b/bubblegum/js/src/generated/errors/index.ts index f8df0bf115..cb56e45b67 100644 --- a/bubblegum/js/src/generated/errors/index.ts +++ b/bubblegum/js/src/generated/errors/index.ts @@ -569,6 +569,46 @@ export class CollectionMustBeSizedError extends Error { createErrorFromCodeLookup.set(0x178a, () => new CollectionMustBeSizedError()); createErrorFromNameLookup.set('CollectionMustBeSized', () => new CollectionMustBeSizedError()); +/** + * MetadataImmutable: 'Metadata Not Mutable' + * + * @category Errors + * @category generated + */ +export class MetadataImmutableError extends Error { + readonly code: number = 0x178b; + readonly name: string = 'MetadataImmutable'; + constructor() { + super('Metadata Not Mutable'); + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, MetadataImmutableError); + } + } +} + +createErrorFromCodeLookup.set(0x178b, () => new MetadataImmutableError()); +createErrorFromNameLookup.set('MetadataImmutable', () => new MetadataImmutableError()); + +/** + * CollectionMismatch: 'Collection mismatch' + * + * @category Errors + * @category generated + */ +export class CollectionMismatchError extends Error { + readonly code: number = 0x178c; + readonly name: string = 'CollectionMismatch'; + constructor() { + super('Collection mismatch'); + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, CollectionMismatchError); + } + } +} + +createErrorFromCodeLookup.set(0x178c, () => new CollectionMismatchError()); +createErrorFromNameLookup.set('CollectionMismatch', () => new CollectionMismatchError()); + /** * Attempts to resolve a custom program error from the provided error code. * @category Errors diff --git a/bubblegum/js/src/generated/instructions/index.ts b/bubblegum/js/src/generated/instructions/index.ts index 71ee2b26ce..6752c4a13b 100644 --- a/bubblegum/js/src/generated/instructions/index.ts +++ b/bubblegum/js/src/generated/instructions/index.ts @@ -12,5 +12,6 @@ export * from './setTreeDelegate'; export * from './transfer'; export * from './unverifyCollection'; export * from './unverifyCreator'; +export * from './updateMetadata'; export * from './verifyCollection'; export * from './verifyCreator'; diff --git a/bubblegum/js/src/generated/instructions/updateMetadata.ts b/bubblegum/js/src/generated/instructions/updateMetadata.ts new file mode 100644 index 0000000000..97ad40182e --- /dev/null +++ b/bubblegum/js/src/generated/instructions/updateMetadata.ts @@ -0,0 +1,198 @@ +/** + * 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'; + +/** + * @category Instructions + * @category UpdateMetadata + * @category generated + */ +export type UpdateMetadataInstructionArgs = { + root: number[] /* size: 32 */; + oldMetadata: MetadataArgs; + newName: beet.COption; + newSymbol: beet.COption; + newUri: beet.COption; + newSellerFeeBasisPoints: beet.COption; + newPrimarySaleHappened: beet.COption; + newIsMutable: beet.COption; + 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', metadataArgsBeet], + ['newName', beet.coption(beet.utf8String)], + ['newSymbol', beet.coption(beet.utf8String)], + ['newUri', beet.coption(beet.utf8String)], + ['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 [] treeAuthority + * @property [**signer**] treeDelegate + * @property [] collectionAuthority + * @property [] collectionMint + * @property [] collectionMetadata + * @property [] collectionAuthorityRecordPda + * @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 = { + treeAuthority: web3.PublicKey; + treeDelegate: web3.PublicKey; + collectionAuthority: web3.PublicKey; + collectionMint: web3.PublicKey; + collectionMetadata: web3.PublicKey; + collectionAuthorityRecordPda: 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.treeAuthority, + isWritable: false, + isSigner: false, + }, + { + pubkey: accounts.treeDelegate, + isWritable: false, + isSigner: true, + }, + { + pubkey: accounts.collectionAuthority, + isWritable: false, + isSigner: false, + }, + { + pubkey: accounts.collectionMint, + isWritable: false, + isSigner: false, + }, + { + pubkey: accounts.collectionMetadata, + isWritable: false, + isSigner: false, + }, + { + pubkey: accounts.collectionAuthorityRecordPda, + isWritable: false, + isSigner: false, + }, + { + 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; +} diff --git a/bubblegum/js/src/generated/types/InstructionName.ts b/bubblegum/js/src/generated/types/InstructionName.ts index 16f5f4f58a..5ea8bf7097 100644 --- a/bubblegum/js/src/generated/types/InstructionName.ts +++ b/bubblegum/js/src/generated/types/InstructionName.ts @@ -27,6 +27,7 @@ export enum InstructionName { UnverifyCollection, SetAndVerifyCollection, MintToCollectionV1, + UpdateMetadata, } /**