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

Fields

§rules: Vec<Rule>

The vector of Rules contained under All.

Group AND, where every rule contained must pass.

§

Any

Fields

§rules: Vec<Rule>

The vector of Rules contained under Any.

Group OR, where at least one rule contained must pass.

§

Not

Fields

§rule: Box<Rule>

The Rule contained under Not.

Negation, where the contained rule must fail.

§

AdditionalSigner

Fields

§account: Pubkey

The public key that must have also signed the transaction.

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

Fields

§pubkey: Pubkey

The public key to be compared against.

§field: String

The field in the Payload to be compared.

Direct comparison between Pubkeys. 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.

§

PubkeyListMatch

Fields

§pubkeys: Vec<Pubkey>

The list of public keys to be compared against.

§field: String

The field in the Payload to be compared.

The comparing Pubkey must be in the list of Pubkeys. 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.

§

PubkeyTreeMatch

Fields

§root: [u8; 32]

The root of the Merkle tree.

§pubkey_field: String

The field in the Payload to be compared when looking for the Pubkey.

§proof_field: String

The field in the Payload to be compared when looking for the Merkle proof.

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.

§

PDAMatch

Fields

§program: Option<Pubkey>

The program used for the PDA derivation. If None then the account owner is used.

§pda_field: String

The field in the Payload to be compared when looking for the PDA.

§seeds_field: String

The field in the Payload to be compared when looking for the seeds.

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.

§

ProgramOwned

Fields

§program: Pubkey

The program that must own the Pubkey.

§field: String

The field in the Payload to be compared.

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.

§

ProgramOwnedList

Fields

§programs: Vec<Pubkey>

The program that must own the Pubkey.

§field: String

The field in the Payload to be compared.

The Pubkey must be owned by a program in the list of Pubkeys. 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.

§

ProgramOwnedTree

Fields

§root: [u8; 32]

The root of the Merkle tree.

§pubkey_field: String

The field in the Payload to be compared when looking for the Pubkey.

§proof_field: String

The field in the Payload to be compared when looking for the Merkle proof.

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.

§

Amount

Fields

§amount: u64

The amount to be compared against.

§operator: CompareOp

The operator to be used in the comparison.

§field: String

The field the amount is stored in.

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.

§

Frequency

Fields

§authority: Pubkey

The authority of the frequency account.

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.

§

IsWallet

Fields

§field: String

The field in the Payload to be checked.

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

Fields

§programs: HashSet<Pubkey>

The program that must own the Pubkey.

§field: String

The field in the Payload to be compared.

The Pubkey must be owned by a program in the set of Pubkeys. 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.

§

Namespace

A rule that tells the operation finder to use the default namespace rule.

Implementations§

source§

impl Rule

source

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.

source

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.

source

pub fn to_error(&self) -> ProgramError

Convert the rule to a corresponding error resulting from the rule failure.

Trait Implementations§

source§

impl Clone for Rule

source§

fn clone(&self) -> Rule

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Rule

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Rule

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq<Rule> for Rule

source§

fn eq(&self, other: &Rule) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Rule

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Rule

source§

impl StructuralEq for Rule

source§

impl StructuralPartialEq for Rule

Auto Trait Implementations§

§

impl RefUnwindSafe for Rule

§

impl Send for Rule

§

impl Sync for Rule

§

impl Unpin for Rule

§

impl UnwindSafe for Rule

Blanket Implementations§

§

impl<T> AbiEnumVisitor for Twhere T: Serialize + ?Sized,

§

default fn visit_for_abi( &self, _digester: &mut AbiDigester ) -> Result<AbiDigester, DigestError>

§

impl<T> AbiEnumVisitor for Twhere T: Serialize + AbiExample + ?Sized,

§

default fn visit_for_abi( &self, digester: &mut AbiDigester ) -> Result<AbiDigester, DigestError>

§

impl<T> AbiExample for T

§

default fn example() -> T

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,