无效的帐户鉴别器下载元副词集合

发布于 2025-02-09 20:33:21 字数 1136 浏览 1 评论 0原文

我从Anchor 0.17更新到版本0.24,从那以后,获取收集帐户失败,锚误差如下: 错误:无效的帐户歧视

这是我的代码,

export const getCollectionPDA = async (candyMachineAddress: string): Promise<anchor.web3.PublicKey> => {
    return (
        await anchor.web3.PublicKey.findProgramAddress(
            [Buffer.from("collection"), new PublicKey(candyMachineAddress).toBuffer()],
            new PublicKey(CANDY_MACHINE_PROGRAM_V2)
        )
    )[0];
};

const provider = new AnchorProvider(connection, getmywallet(), {
       preflightCommitment: "finalized",
       commitment: "finalized",
});

const idl = await Program.fetchIdl(CANDY_MACHINE_PROGRAM_V2, provider);
const anchorProgram = new Program(idl, CANDY_MACHINE_PROGRAM_V2, provider);

const candyMachineId = "63gzhYWxJ4Yfc5QahLxV6NChSjJZNWW93Sy9CHz8YkCe";
const collectionPDA = await getCollectionPDA(candyMachineId);
const collectionPDAAccount = await connection.getAccountInfo(collectionPDA);

const collectionData = await anchorProgram.account.collectionPda.fetch(new PublicKey(collectionPDA.toString()));

我想知道这里发生了什么。也许收集帐户结构已更新,区块链包含旧结构?直到最近,Anchor才开始检查吗?

I updated from anchor 0.17 to version 0.24, and since then, fetching a collection account fails with an anchor error like:
Error: Invalid account discriminator

This is my code

export const getCollectionPDA = async (candyMachineAddress: string): Promise<anchor.web3.PublicKey> => {
    return (
        await anchor.web3.PublicKey.findProgramAddress(
            [Buffer.from("collection"), new PublicKey(candyMachineAddress).toBuffer()],
            new PublicKey(CANDY_MACHINE_PROGRAM_V2)
        )
    )[0];
};

const provider = new AnchorProvider(connection, getmywallet(), {
       preflightCommitment: "finalized",
       commitment: "finalized",
});

const idl = await Program.fetchIdl(CANDY_MACHINE_PROGRAM_V2, provider);
const anchorProgram = new Program(idl, CANDY_MACHINE_PROGRAM_V2, provider);

const candyMachineId = "63gzhYWxJ4Yfc5QahLxV6NChSjJZNWW93Sy9CHz8YkCe";
const collectionPDA = await getCollectionPDA(candyMachineId);
const collectionPDAAccount = await connection.getAccountInfo(collectionPDA);

const collectionData = await anchorProgram.account.collectionPda.fetch(new PublicKey(collectionPDA.toString()));

I wonder what's going on here. Perhaps the Collection account struct has been updated and the blockchain contains old structs? And only recently anchor started checking for that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文