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

Ignore chain id when using --dump-bytecode-as-base64 in sui move build #20475

Merged
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
5 changes: 5 additions & 0 deletions crates/sui-move/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ pub struct Build {
/// Whether we are printing in base64.
#[clap(long, global = true)]
pub dump_bytecode_as_base64: bool,
/// Don't specialize the package to the active chain when dumping bytecode as Base64. This
/// allows building to proceed without a network connection or active environment, but it
/// will not be able to automatically determine the addresses of its dependencies.
#[clap(long, global = true, requires = "dump_bytecode_as_base64")]
pub ignore_chain: bool,
/// If true, generate struct layout schemas for
/// all struct types passed into `entry` functions declared by modules in this package
/// These layout schemas can be consumed by clients (e.g.,
Expand Down
30 changes: 17 additions & 13 deletions crates/sui/src/sui_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,20 +477,24 @@ impl SuiCommand {
} => {
match &mut cmd {
sui_move::Command::Build(build) if build.dump_bytecode_as_base64 => {
// `sui move build` does not ordinarily require a network connection.
// The exception is when --dump-bytecode-as-base64 is specified: In this
// case, we should resolve the correct addresses for the respective chain
// (e.g., testnet, mainnet) from the Move.lock under automated address management.
let config =
client_config.unwrap_or(sui_config_dir()?.join(SUI_CLIENT_CONFIG));
prompt_if_no_config(&config, false).await?;
let context = WalletContext::new(&config, None, None)?;
if let Err(e) = context.get_client().await?.check_api_version() {
eprintln!("{}", format!("[warning] {e}").yellow().bold());
if build.ignore_chain {
build.chain_id = None;
} else {
// `sui move build` does not ordinarily require a network connection.
// The exception is when --dump-bytecode-as-base64 is specified: In this
// case, we should resolve the correct addresses for the respective chain
// (e.g., testnet, mainnet) from the Move.lock under automated address management.
let config =
client_config.unwrap_or(sui_config_dir()?.join(SUI_CLIENT_CONFIG));
prompt_if_no_config(&config, false).await?;
let context = WalletContext::new(&config, None, None)?;
if let Err(e) = context.get_client().await?.check_api_version() {
eprintln!("{}", format!("[warning] {e}").yellow().bold());
}
let client = context.get_client().await?;
let chain_id = client.read_api().get_chain_identifier().await.ok();
build.chain_id = chain_id.clone();
}
let client = context.get_client().await?;
let chain_id = client.read_api().get_chain_identifier().await.ok();
build.chain_id = chain_id.clone();
}
_ => (),
};
Expand Down
Loading