1.1.0 • Published 2 years ago

@lab11/anchorgen v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

ANCHORGEN

Publish Status npm version Known Vulnerabilities Code Style: Google

This is a work-in-progress. Use at your own risk.

Reverse engineers an Anchor program's interface from its IDL.

This could be useful when invoking CPIs on a closed-source Anchor program.

Try it

anchor init jupiter

anchor idl fetch --provider.cluster mainnet JUP2jxvXaqu7NQY1GmNF4m1vodw12LVXYxbFL2uJvfo | \
npx @lab11/anchorgen JUP2jxvXaqu7NQY1GmNF4m1vodw12LVXYxbFL2uJvfo > jupiter/programs/jupiter/src/lib.rs

anchor build

Now you can use reference it in your program's Cargo.toml as a depedency:

[dependencies]
jupiter = { path = "../../../jupiter/programs/jupiter", features = ["cpi", "no-entrypoint"] }

See npx @lab11/anchorgen --help for more info.

Features

Tested with Anchor 0.24.x.

  • Instrcutions
  • Accounts
  • Accounts: Nested
  • Types: Primitives
  • Types: Struct
  • Types: Enum
  • Types: Option & COption
  • Types: Vector & Array
  • Errors
  • Constants
  • State
  • Events
  • Metadata
  • Docs (waiting for https://github.com/project-serum/anchor/pull/1561 to make it to a canonical release)

Contributing

Pull requests and GitHub Issues are welcome.