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

account.fetch does not fetch an existing account. #3541

Open
HareemSaad opened this issue Feb 6, 2025 · 0 comments
Open

account.fetch does not fetch an existing account. #3541

HareemSaad opened this issue Feb 6, 2025 · 0 comments

Comments

@HareemSaad
Copy link

try {
      await program.methods
      .initializeVesting(
        seedString,
        totalAmount,
        startTime,
        endTime,
        cliffPeriod,
      )
      .accounts({
        payer: signer.publicKey,
        mint: mint,
        beneficiary: signer.publicKey,
      })
      .signers([signer])
      .rpc();
    } catch (error) {
      console.log(error)
    }

    await delay(1000);

    const x = await connection.getAccountInfo(vestingAccount);
    console.log(x);

    const account = await program.account.vestingAccount.fetch(vestingAccount, "finalized");

    assert.ok(account.amount.eq(totalAmount), "Amounts do not match");

The issue is simple. I call this initializeVesting method, It is successful, as indicated by logs. and if i use connection.getAccountInfo I get a fully created account

{
  data: <Buffer 66 49 0a e9 c8 bc e4 d8 e8 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 7c a4 67 00 00 00 00 06 09 cc 67 00 00 00 00 80 3a 09 00 00 00 00 00 24 c1 ... 94 more bytes>,
  executable: false,
  lamports: 1893120,
  owner: PublicKey [PublicKey(Aneu8onPp2ZGtZLhSx7YxCLYTVb1g9sN8npVyegMk6Dt)] {
    _bn: <BN: 916b2bcfa4a9c9351e6a6b89ea7e270ac40dc5ade1e29677d2cd291c301acb37>
  },
  rentEpoch: 18446744073709552000,
  space: 144
}

but when fetching accounts using program.account.vestingAccount.fetch it produces error

Error: Account does not exist or has no data 7GRFYmNcig5UMoLbigNAX1d1pNhaErYtrV97fHXKTvQL
      at AccountClient.fetch (node_modules/@coral-xyz/anchor/src/program/namespace/account.ts:168:13)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

my library versions are the following

  "dependencies": {
    "@coral-xyz/anchor": "^0.30.1",
    "@solana/spl-token": "^0.4.12",
    "dotenv": "^16.4.7"
  },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant