Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4125 +/- ##
=======================================
Coverage 98.59% 98.59%
=======================================
Files 429 429
Lines 12495 12498 +3
Branches 1976 1977 +1
=======================================
+ Hits 12320 12323 +3
Misses 175 175 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
hmalik88
marked this pull request as ready for review
September 17, 2026 16:58
|
|
||
| const GetStateParametersStruct = object({ | ||
| key: optional(StateKeyStruct), | ||
| key: optional(union([StateKeyStruct, StateKeysStruct])), |
Member
There was a problem hiding this comment.
Can we use a selective union so we get better error messaging? We can branch on isArray()
| } | ||
|
|
||
| if (Array.isArray(key)) { | ||
| return Object.fromEntries(key.map((k) => [k, get(value, k)])); |
Member
There was a problem hiding this comment.
I can't remember why we chose to use a classic loop below, this will likely be slower. Can you @Mrtenz
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.
Description
Updates
snap_getStateto accept an array of keys in thekeyparameter, allowing a Snap to fetch multiple state values in a single call.Before
After
Behavior
keyis astring[], the result is aRecord<string, Json>mapping each key to its resolved value. Keys not found in state map tonull.Note
Medium Risk
Changes permitted state-read RPC and validation for encrypted Snap storage, but behavior is additive and reuses existing single-key lookup and security checks.
Overview
Extends
snap_getStatesoparams.keycan be astring[], not just a single path. With an array, the RPC returns aRecord<string, Json>keyed by each requested path; paths that are missing resolve tonull. Single-key and whole-state behavior is unchanged.Implementation updates
get()ingetState.tsto map over array keys (including empty array →{}), addsStateKeysStructvalidation, and keeps existing dot-path and forbidden-segment rules per element.GetStateParamsin the SDK is updated accordingly.Example Snap, RPC tests, manage-state integration tests, and the test-snaps GetState UI (comma-separated keys) exercise the new behavior; changelogs note the addition.
Reviewed by Cursor Bugbot for commit 7ab29d5. Bugbot is set up for automated code reviews on this repo. Configure here.