-
Notifications
You must be signed in to change notification settings - Fork 90
refactor: cpi context #1924
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
refactor: cpi context #1924
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,10 @@ pub mod light_system_program { | |||||||||||||
| unimplemented!("anchor wrapper not implemented") | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| pub fn re_init_cpi_context_account(ctx: Context<InitializeCpiContextAccount>) -> Result<()> { | ||||||||||||||
| unimplemented!("anchor wrapper not implemented") | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+28
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Gate unimplemented Anchor wrappers to avoid accidental on-chain panics. Since these handlers are Apply per-function gating now, and consider gating the entire +#[cfg(feature = "idl-build")]
pub fn re_init_cpi_context_account(ctx: Context<InitializeCpiContextAccount>) -> Result<()> {
unimplemented!("anchor wrapper not implemented")
}Additionally (outside this hunk), add at crate root: #[cfg(all(target_os = "solana"), not(feature = "idl-build"))]
compile_error!("Anchor wrappers must not be built for on-chain use; enable feature `idl-build` only for IDL generation.");Incorrect context type for re-init instruction. This should use the re-init accounts context, not Apply: -pub fn re_init_cpi_context_account(ctx: Context<InitializeCpiContextAccount>) -> Result<()> {
+pub fn re_init_cpi_context_account(ctx: Context<ReInitCpiContextAccount>) -> Result<()> {
unimplemented!("anchor wrapper not implemented")
}Please replace 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| pub fn invoke(ctx: Context<InvokeInstruction>, inputs: Vec<u8>) -> Result<()> { | ||||||||||||||
| unimplemented!("anchor wrapper not implemented") | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/deserialization mismatch between v1 and v2 context accounts
CpiContextAccount2 removes the context Vec, but deserialize_cpi_context_account still reads a length and iterates context items. On v2 data this will read past the struct and return corrupted data.
Parse by discriminator and handle both layouts:
Also consider returning a versioned enum if callers need to distinguish v1 vs v2.
Also applies to: 44-72, 50-53