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

Error: Idl(MissingOrInvalidProgramItems("account mod: struct not found")) when running trident inti #160

Closed
cryptopapi997 opened this issue May 20, 2024 · 6 comments

Comments

@cryptopapi997
Copy link
Contributor

Hey guys,

I have a project using Anchor 0.30.0 on which I'm trying to run trident init. An important specification here is I have anchor-spl as a dependency and I have it as version 0.30.0 as downgrading to 0.29.0 (like the docs recommend) would break everything in my program. Additionally, I tested a different 0.30.0 program with anchor-spl at 0.30.0 as well and there it worked fine.

My issue is, when I try to run trident init on this project it keeps giving me Error: Idl(MissingOrInvalidProgramItems("account mod: struct not found")). I tried checking the source code, but I'm not exactly sure what this error means exactly. I tried deleting most of my program so that all that gets generated as an idl is the below, but still the same issue. Any tips on how to fix this?

{
  "address": "85R8U76mZMurovUW3Houj4oeJ4W3SH6PXbJuHoMzbQDZ",
  "metadata": {
    "name": "my_program",
    "version": "0.1.0",
    "spec": "0.1.0"
  },
  "docs": [
    "Some docs"
  ],
  "instructions": [],
  "errors": [
    {
      "code": 6000,
      "name": "MyError1"
    },
    {
      "code": 6001,
      "name": "MyError2"
    },
    {
      "code": 6002,
      "name": "MyError3"
    },
    {
      "code": 6003,
      "name": "MyError4"
    }
  ]
}
@lukacan
Copy link
Collaborator

lukacan commented May 21, 2024

Hello, we will look into it, do you have the source code available in any repository? :)

@cryptopapi997
Copy link
Contributor Author

Yes, but it's closed source. Let me try creating a MRE and get back to you

@cryptopapi997
Copy link
Contributor Author

Alright, added an MRE here:

https://github.com/cryptopapi997/trident-mre

I just tried it again with a fresh git clone and trident init and it throws the same error.

Small thing to note: This uses the latest commit from the anchor repo instead of the official 0.30.0 release. You can switch it to 0.30.0 if you'd like, it still throws the same error

@Ikrk
Copy link
Contributor

Ikrk commented May 21, 2024

The problem is in the name of the context struct InitPersistentMXE which is converted by Anchor to kebab case as init_persistent_mxe and then by Trident back to camel case as InitPersistentMxe which does not correspond to the original name and is thus not found.

As a temporary workaround, if you rename InitPersistentMXE to InitPersistentMxe, then the Trident initialization (of your MRE) works.

@cryptopapi997
Copy link
Contributor Author

Makes sense, thank you! I understand changing this is no simple undertaking as it would require parsing the names from Rust directly. However, I feel like if the error message specified the (incorrectly spelled) struct that caused this, it would've been a lot easier to guess what the problem is without bothering you guys. Opened a quick PR for this here: #164

@cryptopapi997
Copy link
Contributor Author

Can be closed since #164 was merged

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

3 participants