@zenchain-protocol/zazen
v0.0.5
Published
Zenchain snap for securely storing validator cloud access keys within Metamask.
Downloads
7,590
Readme
@zenchain-protocol/zazen
This Metamask snap, Zazen, is intended to store validator cloud access keys in an encrypted, secure manner within Metamask. In the future, it may be used to store other types of data. This snap was forked from the MetaMask manage-state example snap at version 2.2.2.
Snap manifest
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.
Snap usage
The state is stored in the snap using the following structure:
type State = {
staking: {
nodeCloudAccessKeys: {
onFinality: {
accessKey: string;
secretKey: string;
workspaceId: string;
};
};
};
};
This snap exposes an onRpcRequest
handler, which supports the following JSON-RPC methods:
setState
- Set the state to the provided parameters. This assumes the new state is an object using the above structure. The state is always stored encrypted.getState
- Get the state from the snap. This returns the current state if one is set, or a default state otherwise. The state from the encrypted store is always retrieved.clearState
- Reset the state to the default state. The state from the encrypted store is always cleared.
Encrypted storage requires MetaMask to be unlocked.
For more information, you can refer to the end-to-end tests.
Running the Snap Locally
Prerequisites
Make sure you have nvm
(Node Version Manager) installed. If not, you can install it by following the instructions here.
Without Docker
Install the correct Node.js version:
nvm install nvm use
This will use the Node.js version specified in the
.nvmrc
file.Install the dependencies:
yarn install
Build the project:
yarn build
Start the Snap:
yarn start
Run tests:
yarn test
With Docker
You can also build and run this snap locally using Docker.
Build the Docker image
Navigate to the directory containing the
Dockerfile
and run:docker build -t zazen-snap .
Run the Docker container
docker run -d -p 8014:8014 zazen-snap
This command will run the container and map port 8081
of the container to port 8081
of your host machine, allowing you to access the snap locally for testing.