Enum mpl_token_auth_rules::state::Rule
source · pub enum Rule {
Show 14 variants
All {
rules: Vec<Rule>,
},
Any {
rules: Vec<Rule>,
},
Not {
rule: Box<Rule>,
},
AdditionalSigner {
account: Pubkey,
},
PubkeyMatch {
pubkey: Pubkey,
field: String,
},
PubkeyListMatch {
pubkeys: Vec<Pubkey>,
field: String,
},
PubkeyTreeMatch {
root: [u8; 32],
field: String,
},
PDAMatch {
program: Option<Pubkey>,
pda_field: String,
seeds_field: String,
},
ProgramOwned {
program: Pubkey,
field: String,
},
ProgramOwnedList {
programs: Vec<Pubkey>,
field: String,
},
ProgramOwnedTree {
_root: [u8; 32],
_program_field: String,
_merkle_proof_field: String,
},
Amount {
amount: u64,
operator: CompareOp,
field: String,
},
Frequency {
authority: Pubkey,
},
Pass,
}
Expand description
The struct containing every type of Rule and its associated data.
Variants§
All
Group AND, where every rule contained must pass.
Any
Group OR, where at least one rule contained must pass.
Not
Negation, where the contained rule must fail.
AdditionalSigner
An additional signer must be present.
PubkeyMatch
Fields
Direct comparison between Pubkeys.
PubkeyListMatch
Fields
The comparing Pubkey
must be in the list of Pubkey
s.
PubkeyTreeMatch
Fields
The pubkey must be a member of the Merkle tree.
PDAMatch
Fields
A resulting PDA derivation of seeds must prove the account is a PDA.
ProgramOwned
Fields
The Pubkey
must be owned by a given program.
ProgramOwnedList
Fields
The Pubkey
must be owned by a program in the list
of Pubkey
s.
ProgramOwnedTree
Fields
The Pubkey
must be owned a member of the Merkle tree.
Amount
Fields
Comparison against the amount of tokens being transferred.
Frequency
Fields
The authority of the frequency account.
Comparison based on time between operations.
Pass
An operation that always succeeds.
Implementations§
source§impl Rule
impl Rule
sourcepub fn validate(
&self,
accounts: &HashMap<Pubkey, &AccountInfo<'_>>,
payload: &Payload,
update_rule_state: bool,
rule_set_state_pda: &Option<&AccountInfo<'_>>,
rule_authority: &Option<&AccountInfo<'_>>
) -> ProgramResult
pub fn validate(
&self,
accounts: &HashMap<Pubkey, &AccountInfo<'_>>,
payload: &Payload,
update_rule_state: bool,
rule_set_state_pda: &Option<&AccountInfo<'_>>,
rule_authority: &Option<&AccountInfo<'_>>
) -> ProgramResult
The top level validation function which parses an entire rule tree.
sourcepub fn low_level_validate(
&self,
accounts: &HashMap<Pubkey, &AccountInfo<'_>>,
payload: &Payload,
_update_rule_state: bool,
_rule_set_state_pda: &Option<&AccountInfo<'_>>,
rule_authority: &Option<&AccountInfo<'_>>
) -> (bool, ProgramError)
pub fn low_level_validate(
&self,
accounts: &HashMap<Pubkey, &AccountInfo<'_>>,
payload: &Payload,
_update_rule_state: bool,
_rule_set_state_pda: &Option<&AccountInfo<'_>>,
rule_authority: &Option<&AccountInfo<'_>>
) -> (bool, ProgramError)
Lower level validation function which iterates through a rule tree and applies boolean logic to rule results.
sourcepub fn to_error(&self) -> ProgramError
pub fn to_error(&self) -> ProgramError
Convert the rule to a corresponding error resulting from the rule failure.