-
-
Notifications
You must be signed in to change notification settings - Fork 255
Constrain BaseController state to be valid JSON #366
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
Conversation
|
|
The BaseController state is now constrained to valid JSON. Anything that can't be serialized (e.g. functions) or gets mutated during serialization (e.g. `undefined` gets converted to `null`) is disallowed. This should prevent an entire class of bugs resulting from unexpected changes when serializing state as JSON. For example, we serialize state when sending it over `postMessage`, and when persisting the state.
7862dc2 to
91e9715
Compare
|
Note that I haven't added any test cases for this type, as testing that types work properly can be a bit challenging. But the comment I got this type from did include a TypeScript playground link will a comprehensive set of tests. I had intended to look into something like |
brad-decker
left a comment
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.
LGTM! Dope!
|
that type is ingenious. |
The BaseController state is now constrained to valid JSON. Anything that can't be serialized (e.g. functions) or gets mutated during serialization (e.g. `undefined` gets converted to `null`) is disallowed. This should prevent an entire class of bugs resulting from unexpected changes when serializing state as JSON. For example, we serialize state when sending it over `postMessage`, and when persisting the state.
The BaseController state is now constrained to valid JSON. Anything that can't be serialized (e.g. functions) or gets mutated during serialization (e.g. `undefined` gets converted to `null`) is disallowed. This should prevent an entire class of bugs resulting from unexpected changes when serializing state as JSON. For example, we serialize state when sending it over `postMessage`, and when persisting the state.
…ner@v1 (#366) ## Summary This pull request changes the Security Code Scanner reference from `metamask/security-code-scanner@main` to `metamask/action-security-code-scanner@v1`. This change aligns with our versioned workflow approach and MetaMask naming conventions. This is a non-breaking change that only affects the action reference name. If you have any questions, please reach out to the MetaMask Security team.
The BaseController state is now constrained to valid JSON. Anything that can't be serialized (e.g. functions) or gets mutated during
serialization (e.g.
undefinedgets converted tonull) is disallowed.This should prevent an entire class of bugs resulting from unexpected changes when serializing state as JSON. For example, we serialize state when sending it over
postMessage, and when persisting the state.