Skip to content

interface: Add cross-program invocation helpers#389

Draft
febo wants to merge 5 commits into
mainfrom
febo/interface-refactor
Draft

interface: Add cross-program invocation helpers#389
febo wants to merge 5 commits into
mainfrom
febo/interface-refactor

Conversation

@febo

@febo febo commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Problem

Currently the interface crate does not offer a CPI helper.

Solution

Add CPI helpers following the pattern used in pinocchio. This includes a refactor of the interface to minimize dependencies. The crate now contains 2 features:

  • "cpi": intended for on-chain program and enables CPI helpers
  • "instruction": intended for off-chain clients and enables instruction helpers

@febo febo force-pushed the febo/interface-refactor branch from 11ef181 to 66c9688 Compare June 8, 2026 12:14
@febo

febo commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

@joncinque @grod220 This is one alternative to refactor interface crates + add helpers. It is probably not the best example since it does not contain "state" types, but it could give an idea.

@joncinque joncinque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this up!

Comment thread interface/Cargo.toml

[features]
cpi = ["dep:solana-account-view", "dep:solana-instruction-view", "dep:solana-program-error"]
instruction = ["dep:solana-instruction"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instruction as a feature might encourage the wrong behavior, since the cpi helpers also create instructions (in a way).

I can get behind instruction if it's preferred by others, but we could go with alloc to be technically correct, since that's what solana-instruction requires, or we can go with offchain to make it clearer where it should be used.

Of the options, I think I prefer alloc the most.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the name is definitely not ideal, but I found it tricky to come up with a feature name for this. Maybe alloc would be best, although it does not directly reflect what is being enabled; offchain is tricky since anyone still using AccountInfo will need to use this feature to get an instruction for CPI.

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

Successfully merging this pull request may close these issues.

2 participants