Skip to content

Commit

Permalink
Merge branch 'develop' into tooling-wallet/fix-empty-infobox-on-short…
Browse files Browse the repository at this point in the history
…er-mnemonic
  • Loading branch information
evavirseda committed Jan 15, 2025
2 parents 9b7566f + 414d453 commit 5aaa36e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
15 changes: 10 additions & 5 deletions crates/iota-move/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ pub struct Build {
/// Whether we are printing in base64.
#[clap(long, global = true)]
pub dump_bytecode_as_base64: 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.,
/// the TypeScript SDK) to enable serialization/deserialization of
/// transaction arguments and events.
/// 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.
#[arg(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., the TypeScript SDK) to enable
/// serialization/deserialization of transaction arguments and events.
#[clap(long, global = true)]
pub generate_struct_layouts: bool,
/// The chain ID, if resolved. Required when the dump_bytecode_as_base64 is
Expand Down
27 changes: 15 additions & 12 deletions crates/iota/src/iota_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,18 +505,21 @@ impl IotaCommand {
} => {
match &mut cmd {
iota_move::Command::Build(build) if build.dump_bytecode_as_base64 => {
// `iota 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(iota_config_dir()?.join(IOTA_CLIENT_CONFIG));
prompt_if_no_config(&config, false, true).await?;
let context = WalletContext::new(&config, None, None)?;
let client = context.get_client().await?;
let chain_id = client.read_api().get_chain_identifier().await.ok();
build.chain_id = chain_id.clone();
if build.ignore_chain {
build.chain_id = None;
} else {
// `iota 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(iota_config_dir()?.join(IOTA_CLIENT_CONFIG));
prompt_if_no_config(&config, false, true).await?;
let context = WalletContext::new(&config, None, None)?;
let client = context.get_client().await?;
build.chain_id = client.read_api().get_chain_identifier().await.ok();
}
}
_ => (),
};
Expand Down
10 changes: 8 additions & 2 deletions crates/iota/src/keytool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,11 @@ impl KeyToolCommand {
} => match IotaKeyPair::decode(&input_string) {
Ok(ikp) => {
info!("Importing Bech32 encoded private key to keystore");
let key = Key::from(&ikp);
let mut key = Key::from(&ikp);

keystore.add_key(alias, ikp)?;
key.alias = Some(keystore.get_alias_by_address(&key.iota_address)?);

CommandOutput::Import(key)
}
Err(_) => {
Expand All @@ -617,7 +620,10 @@ impl KeyToolCommand {
};

let ikp = keystore.get_key(&iota_address)?;
let key = Key::from(ikp);
let mut key = Key::from(ikp);

key.alias = Some(keystore.get_alias_by_address(&key.iota_address)?);

CommandOutput::Import(key)
}
},
Expand Down
1 change: 1 addition & 0 deletions crates/iota/tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4383,6 +4383,7 @@ async fn test_move_new() -> Result<(), anyhow::Error> {
build_config: move_package::BuildConfig::default(),
cmd: iota_move::Command::Build(iota_move::build::Build {
chain_id: None,
ignore_chain: false,
dump_bytecode_as_base64: false,
generate_struct_layouts: false,
with_unpublished_dependencies: false,
Expand Down

0 comments on commit 5aaa36e

Please sign in to comment.