feat(svm): add patch_idl in set_account#405
Open
aspnxdd wants to merge 33 commits intosolana-foundation:mainfrom
Open
feat(svm): add patch_idl in set_account#405aspnxdd wants to merge 33 commits intosolana-foundation:mainfrom
aspnxdd wants to merge 33 commits intosolana-foundation:mainfrom
Conversation
Co-authored-by: Micaiah Reid <micaiahreid@gmail.com>
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.
Closes #401
Overview
This PR adds support for IDL-account level patching of account data during the
setup_surfnetset_accountsetup phase. This allows precise, typed mutations to specific offsets within an account's data; useful when you need to update fields like public keys or numeric values.Example Usage
Changes
New type:
SET_ACCOUNT_PATCH_IDL(addons/svm/types/src/lib.rs)program_idl,account_name, 'field_name',field_valuefieldsExtended type:
SET_ACCOUNT_MAPpatch_idlfield accepting an array ofSET_ACCOUNT_PATCH_IDLobjectsUpdated:
SetupSurfpoolcommandpatch_idlis present, providing the required context for mutationsSurfpoolAccountUpdate::parse_value_storeso patches are applied correctlyKnown Limitation
The typing of
field_valueis currently loose: it accepts aString,Int,Bytes,Pubkey, etc., but this is not yet well-reflected in the documentation or type definitions. A follow-up issue should be opened to tighten the type signature and improve the developer experience here.How to test it:
I tested it/played around it outside of rust tests, using surfpool: Please view this branch of my surfpool fork to see how I used it. In this branch I use a Meteora DLMM account and I switch some data, then I later see it on a TS script: