Skip to content

Commit

Permalink
Adding set_and_verify_collection instruction to Bubblegum
Browse files Browse the repository at this point in the history
- Require that either the tree authority signed this transaction,
or the tree authority is the collection update authority.
- Add `payer` to both creator and collection verification
instructions.
- Regenerating API.
- Renaming `bubblegum_program_authority` to `bubblegum_signer`
and adding a PDA seed.
- Some additional minor changes to existing logic.
  • Loading branch information
danenbm committed Aug 29, 2022
1 parent 046c6b5 commit 8d0ac5b
Show file tree
Hide file tree
Showing 13 changed files with 637 additions and 106 deletions.
187 changes: 183 additions & 4 deletions bubblegum/js/idl/bubblegum.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@
"isMut": false,
"isSigner": false
},
{
"name": "payer",
"isMut": false,
"isSigner": true
},
{
"name": "creator",
"isMut": false,
Expand Down Expand Up @@ -375,6 +380,11 @@
"isMut": false,
"isSigner": false
},
{
"name": "payer",
"isMut": false,
"isSigner": true
},
{
"name": "creator",
"isMut": false,
Expand Down Expand Up @@ -458,6 +468,20 @@
"isMut": false,
"isSigner": false
},
{
"name": "payer",
"isMut": false,
"isSigner": true
},
{
"name": "treeDelegate",
"isMut": false,
"isSigner": false,
"docs": [
"the case of `set_and_verify_collection` where",
"we are actually changing the NFT metadata."
]
},
{
"name": "collectionAuthority",
"isMut": false,
Expand All @@ -479,7 +503,7 @@
"isSigner": false
},
{
"name": "bubblegumProgramAuthority",
"name": "bubblegumSigner",
"isMut": false,
"isSigner": false
},
Expand Down Expand Up @@ -566,6 +590,20 @@
"isMut": false,
"isSigner": false
},
{
"name": "payer",
"isMut": false,
"isSigner": true
},
{
"name": "treeDelegate",
"isMut": false,
"isSigner": false,
"docs": [
"the case of `set_and_verify_collection` where",
"we are actually changing the NFT metadata."
]
},
{
"name": "collectionAuthority",
"isMut": false,
Expand All @@ -587,7 +625,7 @@
"isSigner": false
},
{
"name": "bubblegumProgramAuthority",
"name": "bubblegumSigner",
"isMut": false,
"isSigner": false
},
Expand Down Expand Up @@ -656,6 +694,137 @@
}
]
},
{
"name": "setAndVerifyCollection",
"accounts": [
{
"name": "authority",
"isMut": false,
"isSigner": false
},
{
"name": "owner",
"isMut": false,
"isSigner": false
},
{
"name": "delegate",
"isMut": false,
"isSigner": false
},
{
"name": "payer",
"isMut": false,
"isSigner": true
},
{
"name": "treeDelegate",
"isMut": false,
"isSigner": false,
"docs": [
"the case of `set_and_verify_collection` where",
"we are actually changing the NFT metadata."
]
},
{
"name": "collectionAuthority",
"isMut": false,
"isSigner": true
},
{
"name": "collectionMint",
"isMut": false,
"isSigner": false
},
{
"name": "collectionMetadata",
"isMut": false,
"isSigner": false
},
{
"name": "editionAccount",
"isMut": false,
"isSigner": false
},
{
"name": "bubblegumSigner",
"isMut": false,
"isSigner": false
},
{
"name": "candyWrapper",
"isMut": false,
"isSigner": false
},
{
"name": "gummyrollProgram",
"isMut": false,
"isSigner": false
},
{
"name": "merkleSlab",
"isMut": true,
"isSigner": false
},
{
"name": "tokenMetadataProgram",
"isMut": false,
"isSigner": false
}
],
"args": [
{
"name": "root",
"type": {
"array": [
"u8",
32
]
}
},
{
"name": "dataHash",
"type": {
"array": [
"u8",
32
]
}
},
{
"name": "creatorHash",
"type": {
"array": [
"u8",
32
]
}
},
{
"name": "nonce",
"type": "u64"
},
{
"name": "index",
"type": "u32"
},
{
"name": "message",
"type": {
"defined": "MetadataArgs"
}
},
{
"name": "collection",
"type": {
"array": [
"u8",
32
]
}
}
]
},
{
"name": "transfer",
"accounts": [
Expand Down Expand Up @@ -1727,17 +1896,27 @@
{
"code": 6021,
"name": "CollectionCannotBeVerifiedInThisInstruction",
"msg": "Cannont Verify Collection in this Instruction"
"msg": "Cannot Verify Collection in this Instruction"
},
{
"code": 6022,
"name": "CollectionNotFound",
"msg": "Collection Not Found on Metadata"
},
{
"code": 6023,
"name": "AlreadyVerified",
"msg": "Collection item is already verified."
},
{
"code": 6023,
"code": 6024,
"name": "AlreadyUnverified",
"msg": "Collection item is already unverified."
},
{
"code": 6025,
"name": "UpdateAuthorityIncorrect",
"msg": "Incorrect leaf metadata update authority."
}
],
"metadata": {
Expand Down
58 changes: 52 additions & 6 deletions bubblegum/js/src/generated/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ createErrorFromCodeLookup.set(0x1784, () => new IncorrectOwnerError())
createErrorFromNameLookup.set('IncorrectOwner', () => new IncorrectOwnerError())

/**
* CollectionCannotBeVerifiedInThisInstruction: 'Cannont Verify Collection in this Instruction'
* CollectionCannotBeVerifiedInThisInstruction: 'Cannot Verify Collection in this Instruction'
*
* @category Errors
* @category generated
Expand All @@ -510,7 +510,7 @@ export class CollectionCannotBeVerifiedInThisInstructionError extends Error {
readonly code: number = 0x1785
readonly name: string = 'CollectionCannotBeVerifiedInThisInstruction'
constructor() {
super('Cannont Verify Collection in this Instruction')
super('Cannot Verify Collection in this Instruction')
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(
this,
Expand All @@ -529,14 +529,37 @@ createErrorFromNameLookup.set(
() => new CollectionCannotBeVerifiedInThisInstructionError()
)

/**
* CollectionNotFound: 'Collection Not Found on Metadata'
*
* @category Errors
* @category generated
*/
export class CollectionNotFoundError extends Error {
readonly code: number = 0x1786
readonly name: string = 'CollectionNotFound'
constructor() {
super('Collection Not Found on Metadata')
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, CollectionNotFoundError)
}
}
}

createErrorFromCodeLookup.set(0x1786, () => new CollectionNotFoundError())
createErrorFromNameLookup.set(
'CollectionNotFound',
() => new CollectionNotFoundError()
)

/**
* AlreadyVerified: 'Collection item is already verified.'
*
* @category Errors
* @category generated
*/
export class AlreadyVerifiedError extends Error {
readonly code: number = 0x1786
readonly code: number = 0x1787
readonly name: string = 'AlreadyVerified'
constructor() {
super('Collection item is already verified.')
Expand All @@ -546,7 +569,7 @@ export class AlreadyVerifiedError extends Error {
}
}

createErrorFromCodeLookup.set(0x1786, () => new AlreadyVerifiedError())
createErrorFromCodeLookup.set(0x1787, () => new AlreadyVerifiedError())
createErrorFromNameLookup.set(
'AlreadyVerified',
() => new AlreadyVerifiedError()
Expand All @@ -559,7 +582,7 @@ createErrorFromNameLookup.set(
* @category generated
*/
export class AlreadyUnverifiedError extends Error {
readonly code: number = 0x1787
readonly code: number = 0x1788
readonly name: string = 'AlreadyUnverified'
constructor() {
super('Collection item is already unverified.')
Expand All @@ -569,12 +592,35 @@ export class AlreadyUnverifiedError extends Error {
}
}

createErrorFromCodeLookup.set(0x1787, () => new AlreadyUnverifiedError())
createErrorFromCodeLookup.set(0x1788, () => new AlreadyUnverifiedError())
createErrorFromNameLookup.set(
'AlreadyUnverified',
() => new AlreadyUnverifiedError()
)

/**
* UpdateAuthorityIncorrect: 'Incorrect leaf metadata update authority.'
*
* @category Errors
* @category generated
*/
export class UpdateAuthorityIncorrectError extends Error {
readonly code: number = 0x1789
readonly name: string = 'UpdateAuthorityIncorrect'
constructor() {
super('Incorrect leaf metadata update authority.')
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, UpdateAuthorityIncorrectError)
}
}
}

createErrorFromCodeLookup.set(0x1789, () => new UpdateAuthorityIncorrectError())
createErrorFromNameLookup.set(
'UpdateAuthorityIncorrect',
() => new UpdateAuthorityIncorrectError()
)

/**
* Attempts to resolve a custom program error from the provided error code.
* @category Errors
Expand Down
1 change: 1 addition & 0 deletions bubblegum/js/src/generated/instructions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export * from './delegate'
export * from './mintV1'
export * from './redeem'
export * from './requestMintAuthority'
export * from './setAndVerifyCollection'
export * from './setTreeDelegate'
export * from './transfer'
export * from './unverifyCollection'
Expand Down
Loading

0 comments on commit 8d0ac5b

Please sign in to comment.