Skip to content

feat(svm): add patch_idl in set_account#405

Open
aspnxdd wants to merge 33 commits intosolana-foundation:mainfrom
aspnxdd:feat/add-mutation-with-idl
Open

feat(svm): add patch_idl in set_account#405
aspnxdd wants to merge 33 commits intosolana-foundation:mainfrom
aspnxdd:feat/add-mutation-with-idl

Conversation

@aspnxdd
Copy link
Copy Markdown
Contributor

@aspnxdd aspnxdd commented Mar 30, 2026

Closes #401

Note: This is one of two PRs that together address #401. Splitting into separate branches makes each change easier to review in isolation.

Overview

This PR adds support for IDL-account level patching of account data during the setup_surfnet set_account setup 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

action "setup_surfnet" "svm::setup_surfnet" {
  set_account {
    public_key = "3BznENHP5KkRikLZqCLGLTaVGcDBsWDTLjSCbHZD2qTA"
    patch_idl {
        program_idl = "./idl.json"
        account_name = "PositionV2"
        field_name = "lb_pair"
        field_value = "GdkseahYCNJF5gSpb4Pzsmsj6GQL3Zi8AGTEkniSzGAQ"
      }
      patch_idl{
        program_idl = "./idl.json"
        account_name = "PositionV2"
        field_name = "lower_bin_id"
        field_value = -3333
      }
  }
}

Changes

New type: SET_ACCOUNT_PATCH_IDL (addons/svm/types/src/lib.rs)

  • Defines a patch descriptor with program_idl, account_name, 'field_name', field_value fields

Extended type: SET_ACCOUNT_MAP

  • Added an optional patch_idl field accepting an array of SET_ACCOUNT_PATCH_IDL objects
  • Multiple patches can be applied to a single account in one update

Updated: SetupSurfpool command

  • Pre-fetches existing account data when patch_idl is present, providing the required context for mutations
  • Passes fetched data to SurfpoolAccountUpdate::parse_value_store so patches are applied correctly

Known Limitation

The typing of field_value is currently loose: it accepts a String, 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:

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.

SVM: Feature - On-the-Fly Account Mutation

1 participant