Struct cubist_sdk::Contract
source · pub struct Contract<M: Middleware = HttpStack> {
pub is_shim: bool,
pub project: Arc<TargetProject<M>>,
pub meta: ContractInfo,
pub shims: HashMap<Target, Arc<Contract<M>>>,
pub deps: Vec<Arc<Contract<M>>>,
/* private fields */
}
Expand description
Re-export some very commonly used types. Deployable contract.
Fields§
§is_shim: bool
Whether this is a shim.
project: Arc<TargetProject<M>>
Project for the target chain (where this contract is deployed)
meta: ContractInfo
Contract metadata
shims: HashMap<Target, Arc<Contract<M>>>
Generated shims interfaces of this contract (one per other chain).
Deploying a contract implies deploying all of its shims. Bridging is done only between the contracts within the same deployment cluster.
If this contract is a shim itself, this map is empty.
deps: Vec<Arc<Contract<M>>>
Shims of other contracts (on this target) that this contract is allowed to call.
Implementations§
source§impl<M: Middleware> Contract<M>
impl<M: Middleware> Contract<M>
sourcepub fn shim(project: Arc<TargetProject<M>>, meta: ContractInfo) -> Self
pub fn shim(project: Arc<TargetProject<M>>, meta: ContractInfo) -> Self
Create new shim contract for a given chain project.
Arguments
project
-TargetProject
corresponding to the chain where this shim is to be deployed.meta
- contract metadata (name, abi, bytecode, etc.)
sourcepub fn new(
project: Arc<TargetProject<M>>,
shims: HashMap<Target, Arc<Contract<M>>>,
deps: Vec<Arc<Contract<M>>>,
meta: ContractInfo
) -> Self
pub fn new(
project: Arc<TargetProject<M>>,
shims: HashMap<Target, Arc<Contract<M>>>,
deps: Vec<Arc<Contract<M>>>,
meta: ContractInfo
) -> Self
Create new (non-shim) contract for a given chain project.
Arguments
project
-TargetProject
corresponding to the chain for which this contract is defined.shims
- shims (interfaces) of this contract auto-generated for other chains.deps
- shims (interfaces) of other contract (on this target) that this contract is allowed to call.meta
- contract metadata (name, abi, bytecode, etc.)
sourcepub async fn when_bridged(&self, delays: &Vec<Duration>) -> bool
pub async fn when_bridged(&self, delays: &Vec<Duration>) -> bool
sourcepub fn full_name(&self) -> String
pub fn full_name(&self) -> String
Full contract name in the format of {file_name}:{contract_name}
sourcepub fn full_name_with_target(&self) -> String
pub fn full_name_with_target(&self) -> String
Full contract name + the target chain.
sourcepub fn name_with_target_and_address(&self) -> String
pub fn name_with_target_and_address(&self) -> String
Contract name + deployed address + the target chain.
sourcepub fn address_and_target(&self) -> String
pub fn address_and_target(&self) -> String
Contract address @ target chain.
sourcepub fn address(&self) -> Option<Address>
pub fn address(&self) -> Option<Address>
Address if the contract has been deployed (or loaded from disk), None
otherwise.
sourcepub fn is_deployed(&self) -> bool
pub fn is_deployed(&self) -> bool
Whether this contract is deployed.
sourcepub fn try_address_on(&self, target: Target) -> Option<Address>
pub fn try_address_on(&self, target: Target) -> Option<Address>
Try to find deployed address of this contract or one of its shims corresponding to the given chain target.
sourcepub fn address_on(&self, target: Target) -> Address
pub fn address_on(&self, target: Target) -> Address
Same as Self::try_address_on
except that it panics instead
of returning None
.
Panics
If this contract has not been deployed on target target
.
sourcepub async fn deploy<T>(&self, args: T) -> Result<(Address, Arc<M>)>where
T: Tokenize,
pub async fn deploy<T>(&self, args: T) -> Result<(Address, Arc<M>)>where
T: Tokenize,
First deploy all generated shims to their chains; then deploy this contract to its target chain.
May be called multiple times; once deployed, subsequent calls become no-op.
sourcepub async fn deploy_shims(&self) -> Result<()>
pub async fn deploy_shims(&self) -> Result<()>
Deploy only this contract’s shims. May be called multiple times; once deployed, subsequent calls become no-op (this is true because deploy_self has this property).
sourcepub async fn at(&self, addr: Address) -> Result<()>
pub async fn at(&self, addr: Address) -> Result<()>
Set address of this contract. Returns an error if address is already set and is different from addr
.
sourcepub async fn deployed(&self) -> Result<Address>
pub async fn deployed(&self) -> Result<Address>
Initialize this contract from its deployment receipt. No-op if the contract is already deployed/initialized. Otherwise, succeeds only if there is exactly one corresponding deployment receipt found. The return value is the contract address.
sourcepub async fn call<TArgs, TRet>(&self, name: &str, args: TArgs) -> Result<TRet>where
TArgs: Tokenize,
TRet: Detokenize,
pub async fn call<TArgs, TRet>(&self, name: &str, args: TArgs) -> Result<TRet>where
TArgs: Tokenize,
TRet: Detokenize,
Call a method on this contract.
Auto Trait Implementations§
impl<M = TransformerMiddleware<Provider<Provider>, LegacyTransformer>> !RefUnwindSafe for Contract<M>
impl<M> Send for Contract<M>
impl<M> Sync for Contract<M>
impl<M> Unpin for Contract<M>
impl<M = TransformerMiddleware<Provider<Provider>, LegacyTransformer>> !UnwindSafe for Contract<M>
Blanket Implementations§
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> 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>
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
§fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
§fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
§fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
§fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
§fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
§fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
§fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
§fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
§fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
§fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
§fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
§fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
§fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
§fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
§fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
§fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
§fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
§fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
§fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more