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

generate_cpi_crate proc macro panicked #83

Open
ClaudeZsb opened this issue Jul 11, 2024 · 0 comments
Open

generate_cpi_crate proc macro panicked #83

ClaudeZsb opened this issue Jul 11, 2024 · 0 comments

Comments

@ClaudeZsb
Copy link

Just a newbie to rust and solana.

I'm finding ways to let my program interact with other programs. While there is interface in solidity and you only need to know the address that you wanna call and apply the appropriate interface to that address, I may need IDL to do the similar thing in solana.

I've read the guide of anchor for cross program invocation. Just really don't like it. It means you have to clone other program's source code into your project. Then I found IDL to work like an interface that could solve the problem of source code. And then I found this tool for generating rust code from the IDL json file. So I'm trying to split the examples in anchor guide puppet and puppet-master into two seperate repos. And I'm trying to use anchor-gen within puppet-master repo in order to invoke puppet. But I ran into this error

puppet within puppet-master repo

anchor_gen::generate_cpi_crate!("idl.json");

declare_id!("9ceHBqVGkYRNJ2uRZG3xvbuU4BQbRKESSs8Q3sWQ74Z9");

image

what i'm using

[dependencies]
anchor-gen = "0.3.1"
anchor-lang = "0.30.1"

puppet idl json

{
  "address": "9ceHBqVGkYRNJ2uRZG3xvbuU4BQbRKESSs8Q3sWQ74Z9",
  "metadata": {
    "name": "hello_anchor",
    "version": "0.1.0",
    "spec": "0.1.0",
    "description": "Created with Anchor"
  },
  "instructions": [
    {
      "name": "initialize",
      "discriminator": [
        175,
        175,
        109,
        31,
        13,
        152,
        155,
        237
      ],
      "accounts": [
        {
          "name": "new_account",
          "writable": true,
          "signer": true
        },
        {
          "name": "signer",
          "writable": true,
          "signer": true
        },
        {
          "name": "system_program",
          "address": "11111111111111111111111111111111"
        }
      ],
      "args": [
        {
          "name": "data",
          "type": "u64"
        }
      ]
    },
    {
      "name": "set",
      "discriminator": [
        198,
        51,
        53,
        241,
        116,
        29,
        126,
        194
      ],
      "accounts": [
        {
          "name": "new_account",
          "writable": true
        }
      ],
      "args": [
        {
          "name": "data",
          "type": "u64"
        }
      ]
    },
    {
      "name": "sol_transfer",
      "discriminator": [
        135,
        254,
        247,
        202,
        217,
        48,
        184,
        165
      ],
      "accounts": [
        {
          "name": "from",
          "writable": true,
          "signer": true
        },
        {
          "name": "to",
          "writable": true
        },
        {
          "name": "system_program",
          "address": "11111111111111111111111111111111"
        }
      ],
      "args": [
        {
          "name": "lamport",
          "type": "u64"
        }
      ]
    }
  ],
  "accounts": [
    {
      "name": "NewAccount",
      "discriminator": [
        176,
        95,
        4,
        118,
        91,
        177,
        125,
        232
      ]
    }
  ],
  "types": [
    {
      "name": "NewAccount",
      "type": {
        "kind": "struct",
        "fields": [
          {
            "name": "data",
            "type": "u64"
          }
        ]
      }
    }
  ]
}
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