Skip to content

Commit

Permalink
Fix block issuer key from bytes conversion (#2249)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
PhilippGackstatter and Thoralf-M authored May 14, 2024
1 parent a62a55d commit bdda695
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

10 changes: 10 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Security -->

## 2.0.0-beta.2 - 2024-05-14

### Changed

- Set `SyncOptions::account::basic_outputs` to true;

### Fixed

- Hash public key in `add-block-issuer-key` and `remove-block-issuer-key`;

## 2.0.0-beta.1 - 2024-05-08

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cli-wallet"
version = "2.0.0-beta.1"
version = "2.0.0-beta.2"
authors = ["IOTA Stiftung"]
edition = "2021"
homepage = "https://iota.org"
Expand Down
31 changes: 23 additions & 8 deletions cli/src/wallet_cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use colored::Colorize;
use eyre::Error;
use iota_sdk::{
client::{api::options::TransactionOptions, request_funds_from_faucet, secret::SecretManager},
crypto::signatures::ed25519::PublicKey,
types::block::{
address::{AccountAddress, Bech32Address, ToBech32Ext},
mana::ManaAllotment,
Expand All @@ -25,9 +26,9 @@ use iota_sdk::{
},
utils::ConvertTo,
wallet::{
types::OutputData, BeginStakingParams, ConsolidationParams, CreateDelegationParams, CreateNativeTokenParams,
MintNftParams, ModifyAccountBlockIssuerKey, OutputsToClaim, ReturnStrategy, SendManaParams,
SendNativeTokenParams, SendNftParams, SendParams, SyncOptions, Wallet, WalletError,
types::OutputData, AccountSyncOptions, BeginStakingParams, ConsolidationParams, CreateDelegationParams,
CreateNativeTokenParams, MintNftParams, ModifyAccountBlockIssuerKey, OutputsToClaim, ReturnStrategy,
SendManaParams, SendNativeTokenParams, SendNftParams, SendParams, SyncOptions, Wallet, WalletError,
},
U256,
};
Expand Down Expand Up @@ -751,7 +752,17 @@ pub async fn create_native_token_command(
.wait_for_transaction_acceptance(&transaction.transaction_id, None, None)
.await?;
// Sync wallet after the transaction got confirmed, so the account output is available
wallet.sync(None).await?;
wallet
.sync(Some(SyncOptions {
sync_native_token_foundries: true,
sync_implicit_accounts: true,
account: AccountSyncOptions {
basic_outputs: true,
..Default::default()
},
..Default::default()
}))
.await?;
}

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

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

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

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

let transaction = wallet.modify_account_output_block_issuer_keys(params, None).await?;
Expand Down Expand Up @@ -1199,6 +1210,10 @@ pub async fn sync_command(wallet: &Wallet) -> Result<(), Error> {
.sync(Some(SyncOptions {
sync_native_token_foundries: true,
sync_implicit_accounts: true,
account: AccountSyncOptions {
basic_outputs: true,
..Default::default()
},
..Default::default()
}))
.await?;
Expand Down

0 comments on commit bdda695

Please sign in to comment.