0

i have made an nft collection through candy machine i am trying to mint an nft in my rust code and trying to mint to that same collection but i am getting an error saying wrong update authority.while i am passing the same update authority that i've got on the solana explorer for the nft minted by candy machine. what am i doing wrong. Below is the code: it("Bridge In", async () => { try { console.log( "Searching for: ", https://api.testnet.wormholescan.io/api/v1/vaas/5/000000000000000000000000c9c07b583e25ea776f7543a1c366400770f65e49/24 );

    const vaaBytes = await axios.get(
      `https://api.testnet.wormholescan.io/api/v1/vaas/5/000000000000000000000000c9c07b583e25ea776f7543a1c366400770f65e49/24`
    );
    VAA = vaaBytes.data.data.vaa;
    console.log(VAA)

    // await postVaaSolanaWithRetry(
    //   provider.connection,
    //   async (tx) => {
    //     tx.partialSign(newOwner);
    //     return tx;
    //   },
    //   CORE_BRIDGE_PID,
    //   newOwner.publicKey.toString(),
    //   Buffer.from(VAA, "base64"),
    //   10
    // );

    const parsedVAA = parseVaa(Buffer.from(VAA, 'base64'));
    const payload = getParsedPayload(parsedVAA.payload);
    console.log(payload)
    const postedVAAKey = derivePostedVaaKey(CORE_BRIDGE_PID, parsedVAA.hash);
    const recievedKey = PublicKey.findProgramAddressSync(
      [
        Buffer.from("received"),
        (() => {
          const buf = Buffer.alloc(10);
          buf.writeUInt16LE(parsedVAA.emitterChain, 0);
          buf.writeBigInt64LE(parsedVAA.sequence, 2);
          return buf;
        })(),
      ], SPL_CAT_PID)[0];


    const [configAcc, configBmp] = PublicKey.findProgramAddressSync([
      Buffer.from("config")
    ], SPL_CAT_PID);

   const configInfo = await program.account.config.fetch(configAcc);
   const nativeCollection = configInfo.nativeCollection.toString()

   
    const foreignChainId = Buffer.alloc(8);
    foreignChainId.writeBigUInt64LE(BigInt(5)); //enter the source token wormhole chain id

    const [emitterAcc, emitterBmp] = PublicKey.findProgramAddressSync([
      Buffer.from("foreign_emitter"),
      foreignChainId,
    ], SPL_CAT_PID)

    const mint = anchor.web3.Keypair.generate();

    const metadataPDA = metaplex
      .nfts()
      .pdas()
      .metadata({ mint: mint.publicKey });

    const collectionMetadataPDA = metaplex
      .nfts()
      .pdas()
      .metadata({ mint: collectionPDA });

    const collectionMasterEditionPDA = metaplex
      .nfts()
      .pdas()
      .masterEdition({ mint: collectionPDA });

                console.log(collectionMasterEditionPDA)


    const tokenAccount = getAssociatedTokenAddressSync(
      mint.publicKey,
      newOwner.publicKey
    );

    const masterEditionPDA = metaplex
    .nfts()
    .pdas()
    .masterEdition({ mint: mint.publicKey });

    const method = program.methods.bridgeIn({
      vaaHash: Array.from(parsedVAA.hash),
      chain: new anchor.BN(parsedVAA.emitterChain)
    }).accounts({
      owner: newOwner.publicKey,
      update:masterEditionPDA,
      nativeCollectionAccount: nativeCollection, 
      collectionMetadataAccount: collectionMetadataPDA,
      collectionMasterEdition: collectionMasterEditionPDA,
      nftMint: mint.publicKey,
      metadataAccount: metadataPDA,
      masterEdition: masterEditionPDA,
      tokenAccount: tokenAccount,
      metadataProgram: METADATA_PROGRAM_ID,
      tokenProgram: TOKEN_PROGRAM_ID,
      associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
      config: configAcc,
      wormholeProgram: CORE_BRIDGE_PID,
      posted: postedVAAKey,
      received: recievedKey,
      foreignEmitter: emitterAcc,
      systemProgram: anchor.web3.SystemProgram.programId,
    }).signers([newOwner,mint]);

    const modifyComputeUnits =
      anchor.web3.ComputeBudgetProgram.setComputeUnitLimit({
        units: 900_000,
      });

    const tx = new anchor.web3.Transaction();
    tx.add(
      modifyComputeUnits,
      await method.transaction()
    )
    // const tx = await method.transaction();

    tx.recentBlockhash = (await provider.connection.getLatestBlockhash()).blockhash;
    tx.feePayer = newOwner.publicKey;
    const message = tx.compileMessage();

    const fee = await provider.connection.getFeeForMessage(message, 'confirmed');
    console.log("Transaction Fee: ", fee.value / LAMPORTS_PER_SOL);

    const simulate = await provider.connection.simulateTransaction(tx);
    console.log("Simulated Fee: ", simulate.value.unitsConsumed / LAMPORTS_PER_SOL);

    // const rpc = await method.rpc();
    // console.log("Your transaction signature", rpc);

    const txSig = await anchor.web3.sendAndConfirmTransaction(
      provider.connection,
      tx,
      [newOwner, mint],
      // { skipPreflight: false }
    );
    console.log("Your transaction signature", txSig);

  } catch (e: any) {
    console.log(e);
  }
});

});

});

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.