Action Schema
Actions are constructed using Action Schemas defined by the developers. To define a new action schema, you can use the ActionSchema
utility.
schemas.ts
import { ActionSchema } from "@stackr/sdk";
Using the ActionSchema
utility, a new action schema can be defined like this:
schemas.ts
export const NewSchema = new ActionSchema("<IDENTIFIER>", {
<INPUT_FIELD_NAME> : <SOLIDITY_TYPE>
});
Breaking it down we have:
<IDENTIFIER>
: A unique identifier for the action schema. This is used to identify the action schema in the MRU.<INPUT_FIELD_NAME>
: The name of the input field in the action.<SOLIDITY_TYPE>
: The solidity type of the input field in the action. This is used to validate the input field and alsoEIP-712
signing. The supported types are:uint256
address
bool
bytes32
bytes
string
The solidity types can be accessed using the SolidityType
provided with the SDK.
schemas.ts
import { ActionSchema, SolidityType } from "@stackr/sdk";
export const NewSchema = new ActionSchema("<IDENTIFIER>", {
<INPUT_FIELD_NAME> : SolidityType.ADDRESSBOOLBYTESBYTES32STRINGUINT
});
Same Schema, Multiple transitions
So, for example, if you have a schema to update the count in a counter application, you can use the same schema to increment or decrement the count. It's just the state transition function that decides how to handle the action.