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

Added --bech32 flag to forc contract-id command #5943

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions forc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ forc-tracing = { version = "0.63.3", path = "../forc-tracing" }
forc-util = { version = "0.63.3", path = "../forc-util" }
fs_extra = "1.2"
fuel-asm = { workspace = true }
fuels-core = { workspace = true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency here will likely create an issue for us. Due to our internal procedures we require forc not to depend on sdk. We should be able to move around this somehow. I will think about a different way of doing this but first I wanted to make sure this is not allowed by our CI.

hex = "0.4.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.73"
Expand Down
3 changes: 3 additions & 0 deletions forc/src/cli/commands/contract_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ pub struct Command {
/// Disable the "new encoding" feature
#[clap(long)]
pub no_encoding_v1: bool,
// Flag to display contract-id in bech32 format
#[clap(long)]
pub bech32: bool,
}

pub(crate) fn exec(cmd: Command) -> ForcResult<()> {
Expand Down
9 changes: 8 additions & 1 deletion forc/src/ops/forc_contract_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::cli::ContractIdCommand;
use anyhow::{bail, Result};
use forc_pkg::{self as pkg, build_with_options};
use forc_tracing::println_green;
use fuels_core::types::bech32::Bech32ContractId;
use pkg::manifest::build_profile::ExperimentalFlags;
use sway_core::{fuel_prelude::fuel_tx, BuildTarget};
use tracing::info;
Expand Down Expand Up @@ -39,7 +40,13 @@ pub fn contract_id(command: ContractIdCommand) -> Result<()> {
let storage_slots = built_contract.storage_slots.clone();
let contract_id = pkg::contract_id(&built_contract.bytecode.bytes, storage_slots, &salt);
println_green(&format!(" {name}"));
info!(" Contract id: 0x{contract_id}");
//check if --bech32 flag is present in command
if command.bech32 {
let contract_id_bech32 = Bech32ContractId::from(contract_id);
info!(" Contract id: {contract_id_bech32}");
} else {
info!(" Contract id: 0x{contract_id}");
}
}
Ok(())
}
Expand Down
Loading