Module mpl_token_auth_rules::state
source · Expand description
All structures and related functions representing a Rule Set on-chain.
Key types include the main RuleSetV1
type which keeps the the map of operations to Rules
,
RuleSetV2
type which keep a list of RuleV2
, as well as RuleSetHeader
and RuleSetRevisionMapV1
types used to manage data within the RuleSet
PDA.
Each time a RuleSet
is updated, a new revision is added to the PDA, and previous revisions
never deleted. The revision map is needed so that during RuleSet
validation the desired
revision can be selected by the user.
Because the RuleSet
s and the revision map are variable size, a fixed size header is stored
at the beginning of the RuleSet
PDA that allows new RuleSets
and updated revision maps
to be added to the PDA without moving the previous revision RuleSets
and without losing the
revision map’s location.
Also note there is a 1-byte version preceding each RuleSetV1
revision (for RuleSetV2
the
first byte of the serialized rule set is the version) and the revision map.
Approximate RuleSet PDA data layout
| Header | RuleSetV1 version | RuleSetV1 Revision 0 | RuleSetV1 version | RuleSetV1 Revision 1 | RuleSetV2 Revision 2 | ... | RuleSetRevisionMap version | RuleSetRevisionMap |
|---------|-------------------|----------------------|-------------------|----------------------|----------------------|-----|----------------------------|--------------------|
| 9 bytes | 1 byte | variable bytes | 1 byte | variable bytes | variable bytes | ... | 1 byte | variable bytes |
When `RuleSetV2` revisions are added, there migh be the need to add padding bytes to align the data
to 8 bytes.
Modules
- Collection of rule constraints.
Structs
- Constraint representing the requirement that An additional signer must be present.
- Constraint representing a group AND, where every rule contained must pass.
- Constraint representing a comparison against the amount of tokens being transferred.
- Constraint representing a group OR, where at least one rule contained must pass.
- Constraint representing a comparison based on time between operations.
- An account containing frequency state.
- Header for the rule.
- Constraint that represents a test on whether a pubkey can be signed from a client and therefore is a true wallet account or not.
- A constraint that tells the operation finder to use the default namespace rule.
- Constraint representing a negation, where the contained rule must fail.
- Constraint representing a test where a resulting PDA derivation of seeds must prove the account is a PDA.
- Constraint representing an operation that always succeeds.
- Constraint representing a test where a
Pubkey
must be owned by a given program. - Constraint representing a test where the
Pubkey
must be owned by a program in the list ofPubkey
s. - Constraint representing a test where the
Pubkey
must be owned by a member of the Merkle tree in the rule. - Constraint representing a test where a
Pubkey
must be in the list ofPubkey
s. - Constraint representing a direct comparison between
Pubkey
s. - Constraing representing a test where a
Pubkey
must be a member of the Merkle tree in the rule. - Header used to keep track of where RuleSets are stored in the PDA. This header is meant to be stored at the beginning of the PDA and never be versioned so that it always has the same serialized size. See top-level module for description of PDA memory layout.
- Revision map used to keep track of where individual
RuleSet
revisions are stored in the PDA. See top-level module for description of PDA memory layout. - The struct containing all Rule Set data, most importantly the map of operations to
Rules
. See top-level module for description of PDA memory layout. - The struct containing all Rule Set data, most importantly the map of operations to
Rules
. See top-level module for description of PDA memory layout. - Struct representing a ‘RuleV2’.
- Struct representing a 32 byte string.
Enums
- Operators that can be used to compare against an
Amount
rule. - The struct containing every type of Rule and its associated data.
- The key at the beginning of the serialized account that identifies the account type. NOTE: This is not used for the
RuleSet
account, which uses msgpack instead of Borsh for SerDes. - Operators that can be used to compare against an
Amount
rule. - The struct containing every type of Rule and its associated data.
- Enum representation of Rule failure conditions
Constants
- The maximum size that can be allocated at one time for a PDA.
- Size (in bytes) of the header section.
- Version of the
RuleSetRevisionMapV1
struct. - Size of
RuleSetHeader
when Borsh serialized. - Size (in bytes) of a u64 value.
Traits
- Struct representing a test performed by a rule.
- A trait implementing generic functions required by all accounts on Solana.