ContractVariant

Struct ContractVariant 

Source
pub struct ContractVariant {
    pub wasm_dir_short_name: bool,
    pub contract_id: String,
    pub contract_name: String,
    pub wasm_crate_name: String,
    pub settings: ContractVariantSettings,
    pub abi: ContractAbi,
}
Expand description

Represents a contract created by the framework when building.

It might have only some of the endpoints written by the developer and maybe some other function.

Fields§

§wasm_dir_short_name: bool

Initially, there was only 1 wasm crate, called wasm.

Then, we got multi-contracts, but the wasm crate became the “main” one.

Then we removed that mechanism completely, and it remained purely cosmetic, being named just wasm, instead of wasm-{contract-name}.

We are still keeping this around for contracts with only one output contract, for the cosmetic bit.

§contract_id: String

The contract id is defined in multicontract.toml. It has no effect on the produced assets.

It can be the same as the contract name, but it is not necessary.

§contract_name: String

The name, as seen in the generated contract names.

It is either defined in the multicontract.toml, or is inferred from the main crate name.

§wasm_crate_name: String

The name of the wasm crate, as it appear in Cargo.toml. It is normally the contract_name field, followed by the -wasm suffix.

However, the main contract Cargo.toml is given explicitly, so this name might differ.

§settings: ContractVariantSettings

Collection of flags, specified in the multicontract config.

§abi: ContractAbi

Filtered and processed ABI of the output contract.

Implementations§

Source§

impl ContractVariant

Source

pub fn default_from_abi(abi: &ContractAbi) -> Self

Source

pub fn public_name_snake_case(&self) -> String

Source

pub fn wasm_crate_dir_name(&self) -> String

The name of the directory of the wasm crate.

Note this does not necessarily have to match the wasm crate name defined in Cargo.toml.

Source

pub fn wasm_crate_path(&self) -> PathBuf

Source

pub fn cargo_toml_path(&self) -> PathBuf

Source

pub fn some_other_test_path(&self) -> PathBuf

Source

pub fn wasm_crate_name_snake_case(&self) -> String

Source

pub fn resolve_wasm_target_dir( &self, explicit_target_dir: &Option<String>, ) -> PathBuf

Source

pub fn wasm_compilation_output_path( &self, explicit_target_dir: &Option<String>, ) -> PathBuf

This is where Rust will initially compile the WASM binary.

Source

pub fn abi_output_name(&self) -> String

Source

pub fn wasm_output_name(&self, build_args: &BuildArgs) -> String

Source

pub fn wat_output_name(&self, build_args: &BuildArgs) -> String

Source

pub fn mxsc_file_output_name(&self, build_args: &BuildArgs) -> String

Source

pub fn imports_json_output_name(&self, build_args: &BuildArgs) -> String

Source

pub fn twiggy_top_name(&self, build_args: &BuildArgs) -> String

Source

pub fn twiggy_paths_name(&self, build_args: &BuildArgs) -> String

Source

pub fn twiggy_monos_name(&self, build_args: &BuildArgs) -> String

Source

pub fn twiggy_dominators_name(&self, build_args: &BuildArgs) -> String

Source

pub fn endpoint_names(&self) -> Vec<String>

Source

pub fn all_exported_function_names(&self) -> Vec<String>

Yields “init” + all endpoint names + “callBack” (if it exists).

Should correspond to all wasm exported functions.

Source§

impl ContractVariant

Source

pub fn build_contract( &self, build_args: &BuildArgs, output_path: &Path, ) -> Result<(), ExecuteCommandError>

Source§

impl ContractVariant

Source

pub fn cargo_clean(&self)

Runs cargo clean in the corresponding wasm crate.

Source§

impl ContractVariant

Source

pub fn create_wasm_crate_dir(&self)

Makes sure that all the necessary wasm crate directories exist.

Source

pub fn generate_wasm_src_lib_file(&self)

Generates the wasm crate lib.rs source, st the given path.

Source§

impl ContractVariant

Source

pub fn cargo_update(&self)

Runs cargo update in the corresponding wasm crate.

Trait Implementations§

Source§

impl Debug for ContractVariant

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.