Skip to content

Separate snap_manageState into separate functions snap_getState, snap_setState, and snap_clearState #1287

@Mrtenz

Description

@Mrtenz

The snap_manageState API is a bit strange currently, because you have to specify an operation for each request. It's better if the method was separated into three separate methods:

  • snap_getState, similar to the get operation.
    await snap.request({ method: 'snap_getState', params: { key: 'foo' } });
  • snap_setState, similar to the update operation, whereparams is the new state.
    await snap.request({ method: 'snap_setState', params: { key: 'foo', value: 1 } });
  • snap_clearState, similar to the clear operation.
    await snap.request({ method: 'snap_clearState' });

snap_manageState can be deprecated, and mapped internally to one of the methods above, depending on the operation.

Right now we only have one-to-one mappings for permissions to their respective JSON-RPC methods. In order to accomplish the above, while using a single permission, we need to have a way to map one-to-many, from a single storage permission to all the methods above.

Metadata

Metadata

Assignees

Labels

area-capabilitiesRelated to the kinds of things that snaps are able to do.type-enhancementNew feature or requesttype-researchA research task.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions