Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use compiled binary output from forcto build Rust bindings #125

Closed
digorithm opened this issue Mar 2, 2022 · 0 comments · Fixed by #150
Closed

Use compiled binary output from forcto build Rust bindings #125

digorithm opened this issue Mar 2, 2022 · 0 comments · Fixed by #150
Labels
enhancement New feature or request

Comments

@digorithm
Copy link
Member

Currently, we have a method under Contract to compile Sway code:

pub fn compile_sway_contract(
    project_path: &str,
    salt: Salt,
) -> Result<CompiledContract, Error> {
    let build_command = BuildCommand {
        debug_outfile: None,
        minify_json_abi: false,
        path: Some(project_path.into()),
        print_finalized_asm: false,
        print_intermediate_asm: false,
        binary_outfile: None,
        offline_mode: false,
        output_directory: None,
        silent_mode: true,
        print_ir: false,
        use_ir: false,
    };

    let (raw, _) =
        forc_build::build(build_command).map_err(|message| Error::CompilationError(message))?;

    Ok(CompiledContract { salt, raw })
}

Although that works fine, it adds a dependency on forc as a library. fuels-rs should be language agnostic: it should operate only on the compiled binary and the ABI, both targeting the FuelVM.

Recently, forc was updated to output the binary data to an output directory. fuels-rs can leverage that in order to remove the dependency on forc as a library. Instead of calling forc::build, take a path to the compiled binary data, the same way that it takes the path to the json ABI file.

Then, it would be on the user to use forc to generate the compiled binary and the json ABI file, then pass both to fuels-rs's deploy method and contract instantiation method (i.e. Contract::new()).

@digorithm digorithm added the enhancement New feature or request label Mar 2, 2022
@digorithm digorithm moved this to Todo in Fuel Network Mar 2, 2022
Repository owner moved this from Todo to Done in Fuel Network Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant