pub struct Contract {
pub name: String,
pub inheritance: Vec<String>,
pub state_variables: Vec<StateVariable>,
pub functions: Vec<FunctionDef>,
pub modifiers_defs: Vec<ModifierDef>,
pub events: Vec<EventDef>,
pub kind: ContractKind,
pub line: usize,
pub structs: Vec<StructDef>,
pub errors: Vec<ErrorDef>,
pub using_for: Vec<UsingForDef>,
}Expand description
A contract, interface, or library definition.
Fields§
§name: String§inheritance: Vec<String>§state_variables: Vec<StateVariable>§functions: Vec<FunctionDef>§modifiers_defs: Vec<ModifierDef>§events: Vec<EventDef>§kind: ContractKind§line: usize§structs: Vec<StructDef>§errors: Vec<ErrorDef>§using_for: Vec<UsingForDef>Implementations§
Source§impl Contract
impl Contract
Sourcepub fn inherits_access_control(&self) -> bool
pub fn inherits_access_control(&self) -> bool
Check if contract (or its inheritance chain) likely has a specific capability.
Sourcepub fn has_modifier_named(&self, name: &str) -> bool
pub fn has_modifier_named(&self, name: &str) -> bool
Check if a modifier with the given name exists in this contract.
Sourcepub fn get_modifier(&self, name: &str) -> Option<&ModifierDef>
pub fn get_modifier(&self, name: &str) -> Option<&ModifierDef>
Get a modifier by name.
Sourcepub fn has_reentrancy_guard_modifier(&self) -> bool
pub fn has_reentrancy_guard_modifier(&self) -> bool
Check if the contract has OpenZeppelin-style ReentrancyGuard.
Sourcepub fn has_supports_interface(&self) -> bool
pub fn has_supports_interface(&self) -> bool
Check if this contract defines ERC-165 supportsInterface.
Sourcepub fn is_erc721(&self) -> bool
pub fn is_erc721(&self) -> bool
Check if this contract likely implements ERC-721 (has balanceOf, ownerOf).
Sourcepub fn is_erc1155(&self) -> bool
pub fn is_erc1155(&self) -> bool
Check if this contract likely implements ERC-1155 (has balanceOfBatch).
Sourcepub fn get_function(&self, name: &str) -> Option<&FunctionDef>
pub fn get_function(&self, name: &str) -> Option<&FunctionDef>
Find a function by name.
Sourcepub fn state_variable_by_name(&self, name: &str) -> Option<&StateVariable>
pub fn state_variable_by_name(&self, name: &str) -> Option<&StateVariable>
Find all state variables initialized to a specific value pattern.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Contract
impl RefUnwindSafe for Contract
impl Send for Contract
impl Sync for Contract
impl Unpin for Contract
impl UnsafeUnpin for Contract
impl UnwindSafe for Contract
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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