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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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 forc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ forc-tracing = { version = "0.56.0", path = "../forc-tracing" }
forc-util = { version = "0.56.0", 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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// flag to display contract-id in bech32 format
// Flag to display contract-id in bech32 format

#[clap(long)]
pub bech32: bool,
}

pub(crate) fn exec(cmd: Command) -> ForcResult<()> {
Expand Down
11 changes: 10 additions & 1 deletion forc/src/ops/forc_contract_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use forc_tracing::println_green;
use pkg::manifest::build_profile::ExperimentalFlags;
use sway_core::{fuel_prelude::fuel_tx, BuildTarget};
use tracing::info;
use fuels_core::types::bech32::Bech32ContractId;

pub fn contract_id(command: ContractIdCommand) -> Result<()> {
let build_options = build_opts_from_cmd(&command);
Expand Down Expand Up @@ -40,7 +41,15 @@ pub fn contract_id(command: ContractIdCommand) -> Result<()> {
let contract_id =
pkg::contract_id(built_contract.bytecode.bytes.clone(), 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