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: boolInitially, 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: StringThe 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: StringThe 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: StringThe 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: ContractVariantSettingsCollection of flags, specified in the multicontract config.
abi: ContractAbiFiltered and processed ABI of the output contract.
Implementations§
Source§impl ContractVariant
impl ContractVariant
Sourcepub fn default_from_abi(original_abi: &ContractAbi) -> Self
pub fn default_from_abi(original_abi: &ContractAbi) -> Self
Constructor that is called when no contract variants are configured.
This single resulting variant takes all its data from the original ABI, and uses defaults for everything else.
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) -> PathBuf
pub fn cargo_toml_path(&self) -> PathBuf
pub fn some_other_test_path(&self) -> PathBuf
pub fn wasm_crate_name_snake_case(&self) -> String
pub fn resolve_wasm_target_dir( &self, explicit_target_dir: &Option<String>, ) -> PathBuf
Sourcepub fn wasm_compilation_output_path(
&self,
explicit_target_dir: &Option<String>,
) -> PathBuf
pub fn wasm_compilation_output_path( &self, explicit_target_dir: &Option<String>, ) -> PathBuf
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: &Path, ) -> Result<(), ExecuteCommandError>
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.