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

Update metadata #44

Merged
merged 26 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c718251
fix protocol conflicts
samwise2 Aug 29, 2023
0494b7a
allow updating creators without new verifications
samwise2 Jun 26, 2023
922e3c5
cleanup
samwise2 Jun 26, 2023
b1e970d
conflicts
samwise2 Aug 29, 2023
fdc2fff
conflicts
samwise2 Aug 29, 2023
c71ac65
all tests included
samwise2 Aug 29, 2023
c8864df
regen solita and fix bugs
samwise2 Aug 29, 2023
4855ed4
small fixes
samwise2 Aug 29, 2023
3bd2532
nit
samwise2 Aug 29, 2023
a938436
address code review, without additional test
samwise2 Sep 3, 2023
950aa74
added creator verification test
samwise2 Sep 3, 2023
ec91fce
Regenerate js client
danenbm Sep 7, 2023
bd82228
Rename old_metadata to current_metadata
danenbm Sep 18, 2023
2d65a4b
Use UpdateArgs to group new metadata params
danenbm Sep 18, 2023
0173305
Prevent existing verified creators from being removed
danenbm Sep 19, 2023
367d3f3
Derive Default on UpdateArgs
danenbm Sep 22, 2023
eb72750
Fix typo
danenbm Sep 23, 2023
256e6ee
Merge pull request #3 from samwise2/samwise2/updatable-metadata
danenbm Sep 26, 2023
4e15775
Merge branch 'main' into update_metadata
danenbm Sep 29, 2023
6a31385
Regenerate IDL, Rust client and Umi client
danenbm Sep 29, 2023
bf6338b
Regenerate js-solita
danenbm Sep 29, 2023
e6db134
Add canopy to JS Solita test since it uses 2 nodes
danenbm Sep 30, 2023
c4b5c2a
Run CI on any PR
danenbm Oct 2, 2023
0471431
Removing SetDecompressableState from pub enum InstructionName
danenbm Oct 2, 2023
a331582
Merge branch 'main' into update_metadata
danenbm Oct 3, 2023
9652483
Remove `update_metadata_collection_nft` instruction (#47)
danenbm Oct 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [main]
pull_request:
branches: [main]

env:
CACHE: true
Expand Down
5 changes: 3 additions & 2 deletions clients/js-solita/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"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",
"lint": "eslint \"{src,test}/**/*.ts\" --format stylish",
"lint": "eslint \"{src,tests}/**/*.ts\" --format stylish",
"fix:lint": "yarn lint --fix",
"prettier": "prettier \"{src,test}/**/*.ts\" --check",
"fix:prettier": "prettier --write src/",
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 Down
123 changes: 123 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,129 @@ 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());

/**
* PrimarySaleCanOnlyBeFlippedToTrue: 'Can only update primary sale to true'
*
* @category Errors
* @category generated
*/
export class PrimarySaleCanOnlyBeFlippedToTrueError extends Error {
readonly code: number = 0x1796;
readonly name: string = 'PrimarySaleCanOnlyBeFlippedToTrue';
constructor() {
super('Can only update primary sale to true');
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, PrimarySaleCanOnlyBeFlippedToTrueError);
}
}
}

createErrorFromCodeLookup.set(0x1796, () => new PrimarySaleCanOnlyBeFlippedToTrueError());
createErrorFromNameLookup.set(
'PrimarySaleCanOnlyBeFlippedToTrue',
() => new PrimarySaleCanOnlyBeFlippedToTrueError(),
);

/**
* CreatorDidNotUnverify: 'Creator did not unverify the metadata'
*
* @category Errors
* @category generated
*/
export class CreatorDidNotUnverifyError extends Error {
readonly code: number = 0x1797;
readonly name: string = 'CreatorDidNotUnverify';
constructor() {
super('Creator did not unverify the metadata');
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, CreatorDidNotUnverifyError);
}
}
}

createErrorFromCodeLookup.set(0x1797, () => new CreatorDidNotUnverifyError());
createErrorFromNameLookup.set('CreatorDidNotUnverify', () => new CreatorDidNotUnverifyError());

/**
* Attempts to resolve a custom program error from the provided error code.
* @category Errors
Expand Down
1 change: 1 addition & 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,6 @@ export * from './setTreeDelegate';
export * from './transfer';
export * from './unverifyCollection';
export * from './unverifyCreator';
export * from './updateMetadata';
export * from './verifyCollection';
export * from './verifyCreator';
171 changes: 171 additions & 0 deletions clients/js-solita/src/generated/instructions/updateMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/**
* 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 { UpdateArgs, updateArgsBeet } from '../types/UpdateArgs';

/**
* @category Instructions
* @category UpdateMetadata
* @category generated
*/
export type UpdateMetadataInstructionArgs = {
root: number[] /* size: 32 */;
nonce: beet.bignum;
index: number;
currentMetadata: beet.COption<MetadataArgs>;
updateArgs: UpdateArgs;
};
/**
* @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)],
['nonce', beet.u64],
['index', beet.u32],
['currentMetadata', beet.coption(metadataArgsBeet)],
['updateArgs', updateArgsBeet],
],
'UpdateMetadataInstructionArgs',
);
/**
* Accounts required by the _updateMetadata_ instruction
*
* @property [] metadataBuffer (optional)
* @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 = {
metadataBuffer?: 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.
*
* Optional accounts that are not provided default to the program ID since
* this was indicated in the IDL from which this instruction was generated.
*
* @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.metadataBuffer ?? programId,
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;
}
35 changes: 35 additions & 0 deletions clients/js-solita/src/generated/types/UpdateArgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* 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 { Creator, creatorBeet } from './Creator';
export type UpdateArgs = {
name: beet.COption<string>;
symbol: beet.COption<string>;
uri: beet.COption<string>;
creators: beet.COption<Creator[]>;
sellerFeeBasisPoints: beet.COption<number>;
primarySaleHappened: beet.COption<boolean>;
isMutable: beet.COption<boolean>;
};

/**
* @category userTypes
* @category generated
*/
export const updateArgsBeet = new beet.FixableBeetArgsStruct<UpdateArgs>(
[
['name', beet.coption(beet.utf8String)],
['symbol', beet.coption(beet.utf8String)],
['uri', beet.coption(beet.utf8String)],
['creators', beet.coption(beet.array(creatorBeet))],
['sellerFeeBasisPoints', beet.coption(beet.u16)],
['primarySaleHappened', beet.coption(beet.bool)],
['isMutable', beet.coption(beet.bool)],
],
'UpdateArgs',
);
1 change: 1 addition & 0 deletions clients/js-solita/src/generated/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './LeafSchema';
export * from './MetadataArgs';
export * from './TokenProgramVersion';
export * from './TokenStandard';
export * from './UpdateArgs';
export * from './UseMethod';
export * from './Uses';
export * from './Version';
2 changes: 1 addition & 1 deletion clients/js-solita/src/mpl-bubblegum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function computeCreatorHash(creators: Creator[]) {
Buffer.from([creator.verified ? 1 : 0]),
Buffer.from([creator.share]),
]);
})
}),
);
return Buffer.from(keccak_256.digest(bufferOfCreatorData));
}
Expand Down
Loading
Loading