fix(solana/spl_token): migrate to shared core::InstructionView, drop data clone - #381
Open
shahan-khatchadourian-anchorage wants to merge 1 commit into
Open
Conversation
Copilot started reviewing on behalf of
shahan-khatchadourian-anchorage
June 18, 2026 07:45
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the spl_token Solana preset to use the shared crate::core::InstructionView (introduced in #367) and removes the preset’s private InstructionView that cloned instruction bytes per instruction, switching all byte access to a zero-copy borrow via context.data().
Changes:
- Replaces the private
spl_token::InstructionViewwith the sharedcore::InstructionViewfor program/account display resolution. - Eliminates per-instruction heap allocation by removing
context.data().to_vec()and decoding directly fromcontext.data(). - Aligns unresolved-account fallback behavior with the canonical
core::InstructionViewplaceholder format.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…data clone Removes the private InstructionView struct (which copied context.data() into a Vec<u8> on every instruction) and switches to the shared crate::core::InstructionView introduced in #367. Instruction bytes are now accessed via context.data() directly wherever needed, eliminating the per-instruction heap allocation. Also fixes the stale None-arm fallback that rendered "unknown" instead of the canonical "unresolved(oob:N)" form. Closes #380 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
shahan-khatchadourian-anchorage
force-pushed
the
worktree-380-spl-token-migrate-instruction-view
branch
from
August 4, 2026 18:35
12a6d0f to
3d6869b
Compare
shahan-khatchadourian-anchorage
requested review from
pepe-anchor and
prasanna-anchorage
August 4, 2026 19:15
This was referenced Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
InstructionViewstruct fromspl_token/mod.rsthat clonescontext.data().to_vec()into aVec<u8>on every instruction — a per-instruction heap allocation with no architectural justification.crate::core::InstructionViewfor program ID and account resolution.context.data()directly (a zero-copy borrow), consistent with all other presets in the codebase.None => "unknown"fallback arm (now"unresolved(oob:N)"matching the canonical form incore::InstructionView).Closes #380
Test plan
cargo test -p visualsign-solana— 328 passed, 0 failed, 3 ignoredmake -C src lint— clippy clean with-D warningscargo fmt --all -- --check— clean&instruction.data->context.data()substitutions, and the rustfmt reflow those substitutions imply (the shorter argument lets 17create_text_field("Raw Data", ...)calls fit on one line)Note on formatting coverage
The rustfmt reflow above is invisible to CI.
presets/mod.rsdeclares preset modules throughinclude!(concat!(env!("OUT_DIR"), "/generated_presets_mod.rs")), so rustfmt cannot traverse intopresets/*/—cargo fmt --allformatspresets/mod.rsand nothing beneath it. The whole preset tree is therefore unformatted as far as themake generated+ clean-tree gate is concerned. Worth a follow-up issue; out of scope here.🤖 Generated with Claude Code