pub struct ContractVariant {
pub main: 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§
§main: bool
If it is the main contract, then the wasm crate is called just wasm
,
and the wasm Cargo.toml
is provided by the dev.
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
impl ContractVariant
pub fn default_from_abi(abi: &ContractAbi) -> Self
pub fn public_name_snake_case(&self) -> String
Sourcepub fn wasm_crate_dir_name(&self) -> String
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.
pub fn wasm_crate_path(&self) -> String
pub fn cargo_toml_path(&self) -> String
pub fn some_other_test_path(&self) -> String
pub fn wasm_crate_name_snake_case(&self) -> String
pub fn resolve_wasm_target_dir( &self, explicit_target_dir: &Option<String>, ) -> String
Sourcepub fn wasm_compilation_output_path(
&self,
explicit_target_dir: &Option<String>,
) -> String
pub fn wasm_compilation_output_path( &self, explicit_target_dir: &Option<String>, ) -> String
This is where Rust will initially compile the WASM binary.
pub fn abi_output_name(&self) -> String
pub fn wasm_output_name(&self, build_args: &BuildArgs) -> String
pub fn wat_output_name(&self, build_args: &BuildArgs) -> String
pub fn mxsc_file_output_name(&self, build_args: &BuildArgs) -> String
pub fn imports_json_output_name(&self, build_args: &BuildArgs) -> String
pub fn twiggy_top_name(&self, build_args: &BuildArgs) -> String
pub fn twiggy_paths_name(&self, build_args: &BuildArgs) -> String
pub fn twiggy_monos_name(&self, build_args: &BuildArgs) -> String
pub fn twiggy_dominators_name(&self, build_args: &BuildArgs) -> String
pub fn endpoint_names(&self) -> Vec<String>
Sourcepub fn all_exported_function_names(&self) -> Vec<String>
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
impl ContractVariant
pub fn build_contract(&self, build_args: &BuildArgs, output_path: &str)
Source§impl ContractVariant
impl ContractVariant
Sourcepub fn cargo_clean(&self)
pub fn cargo_clean(&self)
Runs cargo clean
in the corresponding wasm crate.
Source§impl ContractVariant
impl ContractVariant
Sourcepub fn create_wasm_crate_dir(&self)
pub fn create_wasm_crate_dir(&self)
Makes sure that all the necessary wasm crate directories exist.
Sourcepub fn generate_wasm_src_lib_file(&self)
pub fn generate_wasm_src_lib_file(&self)
Generates the wasm crate lib.rs source, st the given path.
Source§impl ContractVariant
impl ContractVariant
Sourcepub fn cargo_update(&self)
pub fn cargo_update(&self)
Runs cargo update
in the corresponding wasm crate.