chang47 / Anchor-Mint-and-Transfer-Smart-Contract

18 stars 10 forks source link

Property 'parsed' does not exist on type 'Buffer | ParsedAccountData'. Property 'parsed' does not exist on type 'Buffer'.ts(2339) #1

Open ViktorKirjanov opened 2 years ago

ViktorKirjanov commented 2 years ago

Hi, Thank you for your tutorials. But i have a question about Mint a token" test. it works fine but i got an error in VS Code, it says that there is something wrong with parsed field

Property 'parsed' does not exist on type 'Buffer | ParsedAccountData'.
  Property 'parsed' does not exist on type 'Buffer'.ts(2339
    // Get minted token amount on the ATA for our anchor wallet
    const minted = (
      await program.provider.connection.getParsedAccountInfo(
        associatedTokenAccount
      )
    ).value.data.parsed.info.tokenAmount.amount;
    assert.equal(minted, 10);
ViktorKirjanov commented 2 years ago

Ok. i found where is the problem

you should import

import { ParsedAccountData } from "@solana/web3.js";

and add as ParsedAccountData

    // Get minted token amount on the ATA for our anchor wallet
    const tokenAccount = await program.provider.connection.getParsedAccountInfo(
      associatedTokenAccount
    );
    const accountData = (tokenAccount.value?.data as ParsedAccountData).parsed;
    assert.equal(accountData.info.tokenAmount.amount, 10);