Crate contract_build

Source
Expand description

§contract-build

A crate for building ink! smart contracts. Used by cargo-contract.

§Usage

use contract_build::{
    ManifestPath,
    Verbosity,
    BuildArtifacts,
    BuildMode,
    Features,
    Network,
    OptimizationPasses,
    OutputType,
    UnstableFlags,
    Target,
    ImageVariant,
};

let manifest_path = ManifestPath::new("my-contract/Cargo.toml").unwrap();

let args = contract_build::ExecuteArgs {
    manifest_path,
    verbosity: Verbosity::Default,
    build_mode: BuildMode::Release,
    features: Features::default(),
    network: Network::Online,
    build_artifact: BuildArtifacts::All,
    unstable_flags: UnstableFlags::default(),
    optimization_passes: Some(OptimizationPasses::default()),
    keep_debug_symbols: false,
    extra_lints: false,
    output_type: OutputType::Json,
    skip_wasm_validation: false,
    target: Target::Wasm,
    max_memory_pages: 16,
    image: ImageVariant::Default,
};

contract_build::execute(args);

Re-exports§

pub use self::metadata::MetadataArtifacts as MetadataResult;
pub use self::metadata::BuildInfo;
pub use self::metadata::MetadataArtifacts;
pub use self::metadata::WasmOptSettings;
pub use self::util::DEFAULT_KEY_COL_WIDTH;

Modules§

metadata
util

Macros§

name_value_println
Pretty print name value, name right aligned with colour.
verbose_eprintln
Prints to stderr if verbosity.is_verbose() is true. Like cargo, we use stderr for verbose output.

Structs§

BuildResult
Result of the build process.
CrateMetadata
Relevant metadata obtained from Cargo.toml.
ExecuteArgs
Arguments to use when executing build or check commands.
Features
Define the standard cargo features args to be passed through.
Manifest
Create, amend and save a copy of the specified Cargo.toml.
ManifestPath
Path to a Cargo.toml file
OptimizationResult
Result of the optimization process.
Profile
Subset of cargo profile settings to configure defaults for building contracts.
UnstableFlags
UnstableOptions
VerbosityFlags
Workspace
Make a copy of a contract project manifest, allow modifications to be made to it, rewrite the paths to point to the original project files, then write to a temporary directory.

Enums§

BuildArtifacts
Describes which artifacts to generate
BuildMode
The mode to build the contract in.
ImageVariant
The image to be used.
Lto
The link-time-optimization setting.
Network
Use network connection to build contracts and generate metadata or use cached dependencies only.
OptLevel
The opt-level setting
OptimizationPasses
OutputType
The type of output to display at the end of a build.
PanicStrategy
The panic setting.
Target
The list of targets that ink! supports.
Verbosity
Denotes if output should be printed to stdout.

Constants§

DEFAULT_MAX_MEMORY_PAGES
This is the default maximum number of pages available for a contract to allocate.

Functions§

assert_debug_mode_supported
Checks whether the supplied ink_version already contains the debug feature.
code_hash
Returns the blake2 hash of the code slice.
docker_build
Launches the docker container to execute verifiable build.
execute
Executes build of the smart contract which produces a Wasm binary that is ready for deploying.
load_module
Load a Wasm file from disk.
new_contract_project
Creates a new contract project from the template.
post_process_wasm
Performs required post-processing steps on the Wasm artifact.