pub enum Rule {
Show 17 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],
pubkey_field: String,
proof_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],
pubkey_field: String,
proof_field: String,
},
Amount {
amount: u64,
operator: CompareOp,
field: String,
},
Frequency {
authority: Pubkey,
},
IsWallet {
field: String,
},
Pass,
ProgramOwnedSet {
programs: HashSet<Pubkey>,
field: String,
},
Namespace,
}
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. When the Validate
instruction is called, this rule
does not require any Payload
values, but the additional signer account must be provided
to Validate
via the additional_rule_accounts
argument so that whether it is a signer
can be retrieved from its AccountInfo
struct.
PubkeyMatch
Direct comparison between Pubkey
s. When the Validate
instruction is called, this rule
requires a PayloadType
value of PayloadType::Pubkey
. The field
value in the rule is
used to locate the Pubkey
in the payload to compare to the Pubkey
in the rule.
Fields
PubkeyListMatch
The comparing Pubkey
must be in the list of Pubkey
s. When the Validate
instruction
is called, this rule requires a PayloadType
value of PayloadType::Pubkey
. The field
value in the Rule is used to locate the Pubkey
in the payload to compare to the Pubkey
list in the rule.
Fields
PubkeyTreeMatch
The comparing Pubkey
must be a member of the Merkle tree in the rule. When the
Validate
instruction is called, this rule requires PayloadType
values of
PayloadType::Pubkey
and PayloadType::MerkleProof
. The field
values in the Rule are
used to locate them in the Payload
. The Pubkey
and the proof are used to calculate
a Merkle root which is compared against the root stored in the rule.
Fields
PDAMatch
A resulting PDA derivation of seeds must prove the account is a PDA. When the Validate
instruction is called, this rule requires PayloadType
values of PayloadType::Seeds
.
The field
values in the Rule are used to locate them in the Payload
. The seeds in the
Payload
and the program ID stored in the Rule are used to derive the PDA from the
Payload
.
Fields
ProgramOwned
The Pubkey
must be owned by a given program. When the Validate
instruction is called,
this rule requires a PayloadType
value of PayloadType::Pubkey
. The field
value in
the rule is used to locate the Pubkey
in the payload for which the owner must be the
program in the rule. Note this same Pubkey
account must also be provided to Validate
via the additional_rule_accounts
argument. This is so that the Pubkey
’s owner can be
found from its AccountInfo
struct.
Fields
ProgramOwnedList
The Pubkey
must be owned by a program in the list of Pubkey
s. When the Validate
instruction is called, this rule requires a PayloadType
value of PayloadType::Pubkey
.
The field
value in the rule is used to locate the Pubkey
in the payload for which the
owner must be a program in the list in the rule. Note this same Pubkey
account must also
be provided to Validate
via the additional_rule_accounts
argument. This is so that the
Pubkey
’s owner can be found from its AccountInfo
struct.
Fields
ProgramOwnedTree
The Pubkey
must be owned by a member of the Merkle tree in the rule. When the Validate
instruction is called, this rule requires PayloadType
values of PayloadType::Pubkey
and
PayloadType::MerkleProof
. The field
values in the Rule are used to locate them in the
Payload
. Note this same Pubkey
account must also be provided to Validate
via the
additional_rule_accounts
argument. This is so that the Pubkey
’s owner can be found
from its AccountInfo
struct. The owner and the proof are then used to calculate a Merkle
root, which is compared against the root stored in the rule.
Fields
Amount
Comparison against the amount of tokens being transferred. When the Validate
instruction is called, this rule requires a PayloadType
value of PayloadType::Amount
.
The field
value in the Rule is used to locate the numerical amount in the payload to
compare to the amount stored in the rule, using the comparison operator stored in the rule.
Fields
Frequency
Comparison based on time between operations. Currently not implemented. This rule
is planned check to ensure a certain amount of time has passed. This rule will make use
of the rule_set_state_pda
optional account passed into Validate
, and will require
the optional rule_authority
account to sign.
Fields
The authority of the frequency account.
IsWallet
The true test if a pubkey can be signed from a client and therefore is a true wallet account.
The details of this rule are as follows: a wallet is defined as being both owned by the
System Program and the address is on-curve. The field
value in the rule is used to
locate the Pubkey
in the payload that must be on-curve and for which the owner must be
the System Program. Note this same Pubkey
account must also be provided to Validate
via the additional_rule_accounts
argument. This is so that the Pubkey
’s owner can be
found from its AccountInfo
struct.
Pass
An operation that always succeeds.
ProgramOwnedSet
The Pubkey
must be owned by a program in the set of Pubkey
s. When the Validate
instruction is called, this rule requires a PayloadType
value of PayloadType::Pubkey
.
The field
value in the rule is used to locate the Pubkey
in the payload for which the
owner must be a program in the set in the rule. Note this same Pubkey
account must also
be provided to Validate
via the additional_rule_accounts
argument. This is so that the
Pubkey
’s owner can be found from its AccountInfo
struct.
Fields
Namespace
A rule that tells the operation finder to use the default namespace rule.
Implementations§
Source§impl Rule
impl Rule
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<'_>>,
) -> RuleResult
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<'_>>, ) -> RuleResult
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.
Trait Implementations§
Source§impl<'a> Assertable<'a> for Rule
impl<'a> Assertable<'a> for Rule
Source§fn validate(
&self,
accounts: &HashMap<Pubkey, &AccountInfo<'_>>,
payload: &Payload,
update_rule_state: bool,
rule_set_state_pda: &Option<&AccountInfo<'_>>,
rule_authority: &Option<&AccountInfo<'_>>,
) -> ProgramResult
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.
Source§impl<'de> Deserialize<'de> for Rule
impl<'de> Deserialize<'de> for Rule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Rule
impl StructuralPartialEq for Rule
Auto Trait Implementations§
impl Freeze for Rule
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnwindSafe for Rule
Blanket Implementations§
Source§impl<T> AbiEnumVisitor for T
impl<T> AbiEnumVisitor for T
default fn visit_for_abi( &self, _digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
Source§impl<T> AbiEnumVisitor for T
impl<T> AbiEnumVisitor for T
default fn visit_for_abi( &self, digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more