Skip to content

Scaffold a singleton type #1154

@lumtis

Description

@lumtis

Scaffold a singleton type with the command starport type fields... --singleton or starport type fields... --unique where the type has only one instance in the store

This is used for global customizable variable for the app like the params.

I got the idea of it because it would be used with spn: the testnet monitoring module must store a structure named "Consensus State" of spn. This is a single instance of structure that must be stored in the store

This type would have the --no-message flag as well. To keep consistent with the CRUD format we would have

  • create: create the type and fails if it already exists
  • read: query the type, takes no param
  • update: update by providing a new value, fails if it doesn't exists
  • delete: delete the type, fails if it doesn't exist

Internally, the keeper would simply expose the methods SetFoo, GetFoo and RemoveFoo

We would then have a nice representation of the set of features from the type command:
starport type --singleton generates a variable
starport type generates an array
starport type --indexed generates a map

Metadata

Metadata

Assignees

Labels

component:spnRelated to or beneficial for SPN development

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions