Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit bdda695

Browse files
Fix block issuer key from bytes conversion (#2249)
* Fix block issuer key from bytes conversion * Sync basic_outputs of account outputs by default, changelog, bump cli version --------- Co-authored-by: Thoralf Müller <thoralf.mue@gmail.com>
1 parent a62a55d commit bdda695

4 files changed

Lines changed: 35 additions & 10 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
2020
### Security -->
2121

22+
## 2.0.0-beta.2 - 2024-05-14
23+
24+
### Changed
25+
26+
- Set `SyncOptions::account::basic_outputs` to true;
27+
28+
### Fixed
29+
30+
- Hash public key in `add-block-issuer-key` and `remove-block-issuer-key`;
31+
2232
## 2.0.0-beta.1 - 2024-05-08
2333

2434
### Fixed

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cli-wallet"
3-
version = "2.0.0-beta.1"
3+
version = "2.0.0-beta.2"
44
authors = ["IOTA Stiftung"]
55
edition = "2021"
66
homepage = "https://iota.org"

cli/src/wallet_cli/mod.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use colored::Colorize;
1010
use eyre::Error;
1111
use iota_sdk::{
1212
client::{api::options::TransactionOptions, request_funds_from_faucet, secret::SecretManager},
13+
crypto::signatures::ed25519::PublicKey,
1314
types::block::{
1415
address::{AccountAddress, Bech32Address, ToBech32Ext},
1516
mana::ManaAllotment,
@@ -25,9 +26,9 @@ use iota_sdk::{
2526
},
2627
utils::ConvertTo,
2728
wallet::{
28-
types::OutputData, BeginStakingParams, ConsolidationParams, CreateDelegationParams, CreateNativeTokenParams,
29-
MintNftParams, ModifyAccountBlockIssuerKey, OutputsToClaim, ReturnStrategy, SendManaParams,
30-
SendNativeTokenParams, SendNftParams, SendParams, SyncOptions, Wallet, WalletError,
29+
types::OutputData, AccountSyncOptions, BeginStakingParams, ConsolidationParams, CreateDelegationParams,
30+
CreateNativeTokenParams, MintNftParams, ModifyAccountBlockIssuerKey, OutputsToClaim, ReturnStrategy,
31+
SendManaParams, SendNativeTokenParams, SendNftParams, SendParams, SyncOptions, Wallet, WalletError,
3132
},
3233
U256,
3334
};
@@ -751,7 +752,17 @@ pub async fn create_native_token_command(
751752
.wait_for_transaction_acceptance(&transaction.transaction_id, None, None)
752753
.await?;
753754
// Sync wallet after the transaction got confirmed, so the account output is available
754-
wallet.sync(None).await?;
755+
wallet
756+
.sync(Some(SyncOptions {
757+
sync_native_token_foundries: true,
758+
sync_implicit_accounts: true,
759+
account: AccountSyncOptions {
760+
basic_outputs: true,
761+
..Default::default()
762+
},
763+
..Default::default()
764+
}))
765+
.await?;
755766
}
756767

757768
let params = CreateNativeTokenParams {
@@ -942,10 +953,10 @@ pub async fn implicit_accounts_command(wallet: &Wallet) -> Result<(), Error> {
942953

943954
// `add-block-issuer-key` command
944955
pub async fn add_block_issuer_key(wallet: &Wallet, account_id: AccountId, issuer_key: &str) -> Result<(), Error> {
945-
let issuer_key: [u8; Ed25519PublicKeyHashBlockIssuerKey::LENGTH] = prefix_hex::decode(issuer_key)?;
956+
let public_key = PublicKey::try_from_bytes(prefix_hex::decode(issuer_key)?)?;
946957
let params = ModifyAccountBlockIssuerKey {
947958
account_id,
948-
keys_to_add: vec![Ed25519PublicKeyHashBlockIssuerKey::new(issuer_key).into()],
959+
keys_to_add: vec![Ed25519PublicKeyHashBlockIssuerKey::from_public_key(public_key).into()],
949960
keys_to_remove: vec![],
950961
};
951962

@@ -962,11 +973,11 @@ pub async fn add_block_issuer_key(wallet: &Wallet, account_id: AccountId, issuer
962973

963974
// `remove-block-issuer-key` command
964975
pub async fn remove_block_issuer_key(wallet: &Wallet, account_id: AccountId, issuer_key: &str) -> Result<(), Error> {
965-
let issuer_key: [u8; Ed25519PublicKeyHashBlockIssuerKey::LENGTH] = prefix_hex::decode(issuer_key)?;
976+
let public_key = PublicKey::try_from_bytes(prefix_hex::decode(issuer_key)?)?;
966977
let params = ModifyAccountBlockIssuerKey {
967978
account_id,
968979
keys_to_add: vec![],
969-
keys_to_remove: vec![Ed25519PublicKeyHashBlockIssuerKey::new(issuer_key).into()],
980+
keys_to_remove: vec![Ed25519PublicKeyHashBlockIssuerKey::from_public_key(public_key).into()],
970981
};
971982

972983
let transaction = wallet.modify_account_output_block_issuer_keys(params, None).await?;
@@ -1199,6 +1210,10 @@ pub async fn sync_command(wallet: &Wallet) -> Result<(), Error> {
11991210
.sync(Some(SyncOptions {
12001211
sync_native_token_foundries: true,
12011212
sync_implicit_accounts: true,
1213+
account: AccountSyncOptions {
1214+
basic_outputs: true,
1215+
..Default::default()
1216+
},
12021217
..Default::default()
12031218
}))
12041219
.await?;

0 commit comments

Comments
 (0)