Expression

Enum Expression 

Source
pub enum Expression {
Show 33 variants Literal(Literal), Var(String), StateAccess(String), MappingAccess { mapping_name: String, keys: Vec<Expression>, account_name: String, }, MsgSender, MsgValue, BlockTimestamp, ClockSlot, ClockEpoch, ClockUnixTimestamp, RentMinimumBalance { data_len: Box<Expression>, }, RentIsExempt { lamports: Box<Expression>, data_len: Box<Expression>, }, Binary { op: BinaryOp, left: Box<Expression>, right: Box<Expression>, }, Unary { op: UnaryOp, expr: Box<Expression>, }, Call { func: String, args: Vec<Expression>, }, MethodCall { receiver: Box<Expression>, method: String, args: Vec<Expression>, }, InterfaceCast { interface_name: String, program_id: Box<Expression>, }, CpiCall { program: Box<Expression>, interface_name: String, method: String, args: Vec<Expression>, }, TokenTransfer { from: Box<Expression>, to: Box<Expression>, authority: Box<Expression>, amount: Box<Expression>, }, TokenMint { mint: Box<Expression>, to: Box<Expression>, authority: Box<Expression>, amount: Box<Expression>, }, TokenBurn { from: Box<Expression>, mint: Box<Expression>, authority: Box<Expression>, amount: Box<Expression>, }, SolTransfer { to: Box<Expression>, amount: Box<Expression>, }, GetATA { owner: Box<Expression>, mint: Box<Expression>, }, Index { expr: Box<Expression>, index: Box<Expression>, }, Field { expr: Box<Expression>, field: String, }, Ternary { condition: Box<Expression>, then_expr: Box<Expression>, else_expr: Box<Expression>, }, Assert { condition: Box<Expression>, message: Option<String>, }, AssertEq { left: Box<Expression>, right: Box<Expression>, message: Option<String>, }, AssertNe { left: Box<Expression>, right: Box<Expression>, message: Option<String>, }, AssertGt { left: Box<Expression>, right: Box<Expression>, message: Option<String>, }, AssertGe { left: Box<Expression>, right: Box<Expression>, message: Option<String>, }, AssertLt { left: Box<Expression>, right: Box<Expression>, message: Option<String>, }, AssertLe { left: Box<Expression>, right: Box<Expression>, message: Option<String>, },
}
Expand description

Expressions in IR

Variants§

§

Literal(Literal)

§

Var(String)

§

StateAccess(String)

§

MappingAccess

Mapping access: mapping_name[key1][key2]...ctx.accounts.{account_name}.value

Fields

§mapping_name: String
§keys: Vec<Expression>

All keys in order (outer to inner)

§account_name: String

Generated account name for this access point

§

MsgSender

§

MsgValue

§

BlockTimestamp

§

ClockSlot

§

ClockEpoch

§

ClockUnixTimestamp

§

RentMinimumBalance

Fields

§data_len: Box<Expression>
§

RentIsExempt

Fields

§lamports: Box<Expression>
§data_len: Box<Expression>
§

Binary

Fields

§

Unary

Fields

§

Call

Fields

§func: String
§

MethodCall

Fields

§receiver: Box<Expression>
§method: String
§

InterfaceCast

Interface cast for CPI: IERC20(programId) -> allows calling methods on external programs

Fields

§interface_name: String

The interface name (e.g., “IERC20”)

§program_id: Box<Expression>

The program ID to call

§

CpiCall

Cross-Program Invocation call

Fields

§program: Box<Expression>

The program to call (expression evaluating to program ID)

§interface_name: String

Interface/program name for generating the right instruction

§method: String

Method name to call

§args: Vec<Expression>

Arguments to the CPI call

§

TokenTransfer

SPL Token transfer CPI

Fields

§from: Box<Expression>

from account

§to: Box<Expression>

to account

§authority: Box<Expression>

authority

§amount: Box<Expression>

amount

§

TokenMint

SPL Token mint CPI

Fields

§mint: Box<Expression>

mint account

§to: Box<Expression>

to account

§authority: Box<Expression>

authority

§amount: Box<Expression>

amount

§

TokenBurn

SPL Token burn CPI

Fields

§from: Box<Expression>

from account

§mint: Box<Expression>

mint account

§authority: Box<Expression>

authority

§amount: Box<Expression>

amount

§

SolTransfer

Direct SOL transfer via system_program::transfer

Fields

§to: Box<Expression>

to account (Pubkey)

§amount: Box<Expression>

amount in lamports

§

GetATA

Get Associated Token Address

Fields

§owner: Box<Expression>

owner/wallet address

§mint: Box<Expression>

token mint address

§

Index

Fields

§

Field

Fields

§field: String
§

Ternary

Fields

§condition: Box<Expression>
§then_expr: Box<Expression>
§else_expr: Box<Expression>
§

Assert

Assert expression: assert(condition, “message”)

Fields

§condition: Box<Expression>
§message: Option<String>
§

AssertEq

Assert equality: assertEq(left, right, “message”)

Fields

§message: Option<String>
§

AssertNe

Assert not equal: assertNe(left, right, “message”)

Fields

§message: Option<String>
§

AssertGt

Assert greater than: assertGt(left, right, “message”)

Fields

§message: Option<String>
§

AssertGe

Assert greater or equal: assertGe(left, right, “message”)

Fields

§message: Option<String>
§

AssertLt

Assert less than: assertLt(left, right, “message”)

Fields

§message: Option<String>
§

AssertLe

Assert less or equal: assertLe(left, right, “message”)

Fields

§message: Option<String>

Trait Implementations§

Source§

impl Clone for Expression

Source§

fn clone(&self) -> Expression

Returns a duplicate 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 Expression

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.