metaplex-foundation / js

A JavaScript SDK for interacting with Metaplex's programs
357 stars 182 forks source link

Errors upgrading from metaplex 0.15.0 to 0.18.0 #464

Closed mikemaccana closed 1 year ago

mikemaccana commented 1 year ago

The following code works perfectly on metaplex 0.15.0:

let createOutput = await metaplexNFTs.create({
  uri: uploadResponse.uri, 
  name: "Token name",
  sellerFeeBasisPoints: 0, 
});

(original code also has .run() which I understand is no longer necessary and have removed)

However I'd like to move to a newer and better supported metaplex release.

I have downloaded the latest metaplex JS 0.18.0 and ran it on my local validator - can I confirm I need to do this? I imagine the on-chain app needs to be upgraded when the JS package does.

solana program dump -u m "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" metaplex_token_metadata_program.so
solana-test-validator --bpf-program "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" on-chain-programs/metaplex_token_metadata_program.so

In Metaplex JS 0.18.0 the code gives the following output:

  $ npx jest -t 'identity token for Alice'
 FAIL  src/backend/minting-tokens.test.ts (6.772 s)
  ● identity tokens › we can mint a token for Alice

    ParsedProgramError: The program [TokenMetadataProgram] at address [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s] raised an error of code [12] that translates to "Symbol too long".

    Source: Program > TokenMetadataProgram [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s]

    Caused By: SymbolTooLong: Symbol too long

    Program Logs:
    | Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]
    | Program log: Instruction: Token Metadata Create
    | Program log: Initializing mint account
    | Program 11111111111111111111111111111111 invoke [2]
    | Program 11111111111111111111111111111111 success
    | Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]
    | Program log: Error: Invalid instruction
    | Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 797 of 383537 compute units
    | Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: custom program error: 0xc
    | Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 17260 of 400000 compute units
    | Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0xc

      74 |   let createOutput: CreateNftOutput;
      75 |   try {
    > 76 |     createOutput = await metaplexNFTs.create({
         |                    ^
      77 |       uri: uploadResponse.uri, // "https://arweave.net/123",
      78 |       name: IDENTITY_TOKEN_NAME,
      79 |       sellerFeeBasisPoints: 0, // 500 would represent 5.00%.

      at RpcClient.parseProgramError (node_modules/@metaplex-foundation/js/src/plugins/rpcModule/RpcClient.ts:366:9)
      at RpcClient.sendTransaction (node_modules/@metaplex-foundation/js/src/plugins/rpcModule/RpcClient.ts:128:18)
      at async RpcClient.sendAndConfirmTransaction (node_modules/@metaplex-foundation/js/src/plugins/rpcModule/RpcClient.ts:164:23)
      at async TransactionBuilder.sendAndConfirm (node_modules/@metaplex-foundation/js/src/utils/TransactionBuilder.ts:197:22)
      at async Object.handle (node_modules/@metaplex-foundation/js/src/plugins/nftModule/operations/createNft.ts:333:20)
      at async Disposable.run (node_modules/@metaplex-foundation/js/src/utils/Disposable.ts:33:14)
      at async mintToken (src/backend/identity-tokens.ts:76:20)
      at async Object.<anonymous> (src/backend/minting-tokens.test.ts:83:26)

By the way, it's quite possible I've missed something else I need to do after a Metaplex upgrade - I can see https://github.com/metaplex-foundation/js/releases and the README but things like upgrading the metaplex program above I'm just guessing at. Happy to send PRs if the docs just need to be written.

mikemaccana commented 1 year ago

Closing this. New Metaplex upgraded SPL, SPL needed a new version of the local validator installed. See https://solana.stackexchange.com/questions/4933/solana-spl-token-createmint-is-broken-with-custom-program-error-0xc-invali/5806#5806 for the solution.