Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@metamask/manage-state-example-snap
Advanced tools
Readme
@metamask/manage-state-example-snap
This snap demonstrates how to use snap_manageState
to store, receive, and
clear internal state within a snap. This state is encrypted before being stored
on the user's disk, and is the recommended way for storing data in a snap
long-term.
Note: Using
snap_manageState
requires thesnap_manageState
permissions. Refer to the documentation for more information.
Along with other permissions, the manifest of this snap includes the
snap_manageState
permission:
{
"initialPermissions": {
"snap_manageState": {}
}
}
This permission does not require any additional configuration.
The state is stored in the snap using the following structure:
type State = {
items: string[];
};
This snap exposes an onRpcRequest
handler, which supports the following
JSON-RPC methods:
setState
- Set the state to the provided params. This assumes the new state
is an object using the above structure, but for simplicity, this is not
actually validated within the snap.getState
- Get the state from the snap. This returns the current state
if one is set, or a default state otherwise.clearState
- Reset the state to the default state.Each of the methods also takes an encrypted
parameter.
This parameter can be used to choose between using encrypted or unencrypted storage.
Encrypted storage requires MetaMask to be unlocked, unencrypted storage does not.
For more information, you can refer to the end-to-end tests.
FAQs
MetaMask example snap demonstrating the use of `snap_manageState`.
The npm package @metamask/manage-state-example-snap receives a total of 1,198 weekly downloads. As such, @metamask/manage-state-example-snap popularity was classified as popular.
We found that @metamask/manage-state-example-snap demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.