From 1a231ee0ce9e859ddbb5911bc8b65da217c9bc17 Mon Sep 17 00:00:00 2001 From: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:57:33 +0200 Subject: [PATCH 1/4] Fix staking amount (#2238) Co-authored-by: Thibault Martinez --- .../api/block_builder/transaction_builder/transition.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sdk/src/client/api/block_builder/transaction_builder/transition.rs b/sdk/src/client/api/block_builder/transaction_builder/transition.rs index 8889001432..f7cb4eef02 100644 --- a/sdk/src/client/api/block_builder/transaction_builder/transition.rs +++ b/sdk/src/client/api/block_builder/transaction_builder/transition.rs @@ -69,6 +69,8 @@ impl TransactionBuilder { .cloned() .collect::>(); + let mut new_amount = None; + if let Some(change) = self.transitions.as_ref().and_then(|t| t.accounts.get(&account_id)) { match change { AccountChange::BeginStaking { @@ -83,6 +85,7 @@ impl TransactionBuilder { self.protocol_parameters .past_bounded_slot(self.latest_slot_commitment_id), ); + new_amount = Some(*staked_amount); features.push( StakingFeature::new( *staked_amount, @@ -101,6 +104,7 @@ impl TransactionBuilder { .protocol_parameters .future_bounded_epoch(self.latest_slot_commitment_id); let staking_feature = feature.as_staking(); + new_amount = Some(staking_feature.staked_amount()); // Just extend the end epoch if it's still possible if future_bounded_epoch <= staking_feature.end_epoch() { *feature = StakingFeature::new( @@ -162,11 +166,14 @@ impl TransactionBuilder { } let mut builder = AccountOutputBuilder::from(input) - .with_minimum_amount(self.protocol_parameters.storage_score_parameters()) .with_mana(0) .with_account_id(account_id) .with_foundry_counter(u32::max(highest_foundry_serial_number, input.foundry_counter())) .with_features(features); + match new_amount { + Some(amount) => builder = builder.with_amount(amount), + None => builder = builder.with_minimum_amount(self.protocol_parameters.storage_score_parameters()), + } // Block issuers cannot move their mana elsewhere. if input.is_block_issuer() { From 02849504d0cf359b624f140cd2dd91cb933be821 Mon Sep 17 00:00:00 2001 From: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> Date: Mon, 29 Apr 2024 19:42:42 +0200 Subject: [PATCH 2/4] Don't set with_minimum_amount for accounts when they have a staking feature (#2240) --- .../api/block_builder/transaction_builder/transition.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdk/src/client/api/block_builder/transaction_builder/transition.rs b/sdk/src/client/api/block_builder/transaction_builder/transition.rs index f7cb4eef02..7cbcdcd690 100644 --- a/sdk/src/client/api/block_builder/transaction_builder/transition.rs +++ b/sdk/src/client/api/block_builder/transaction_builder/transition.rs @@ -172,7 +172,11 @@ impl TransactionBuilder { .with_features(features); match new_amount { Some(amount) => builder = builder.with_amount(amount), - None => builder = builder.with_minimum_amount(self.protocol_parameters.storage_score_parameters()), + None => { + if input.features().staking().is_none() { + builder = builder.with_minimum_amount(self.protocol_parameters.storage_score_parameters()); + } + } } // Block issuers cannot move their mana elsewhere. From 19294a7255db8e4599719cb0b5d2d6bbd65fd092 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 29 Apr 2024 21:19:58 +0200 Subject: [PATCH 3/4] Prepare 2.0.0-alpha.1 release (#2239) --- Cargo.lock | 2 +- sdk/CHANGELOG.md | 4 ++++ sdk/Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dfd996edcd..b4bbf70210 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1652,7 +1652,7 @@ dependencies = [ [[package]] name = "iota-sdk" -version = "1.1.4" +version = "2.0.0-alpha.1" dependencies = [ "anymap", "async-trait", diff --git a/sdk/CHANGELOG.md b/sdk/CHANGELOG.md index b1f25d5d1b..036004e0d2 100644 --- a/sdk/CHANGELOG.md +++ b/sdk/CHANGELOG.md @@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security --> +## 2.0.0-alpha.1 - 2024-04-29 + +Initial alpha release of the 2.0 SDK. + ## 1.1.5 - 2024-MM-DD ### Added diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index b5a18abcb5..948418440f 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iota-sdk" -version = "1.1.4" +version = "2.0.0-alpha.1" authors = ["IOTA Stiftung"] edition = "2021" description = "The IOTA SDK provides developers with a seamless experience to develop on IOTA by providing account abstractions and clients to interact with node APIs." From 3e44c807dd8d28f2a7221e58c58946383676f187 Mon Sep 17 00:00:00 2001 From: /alex/ Date: Tue, 30 Apr 2024 16:29:43 +0200 Subject: [PATCH 4/4] Clean up wallet syncing code (#2108) * const fn * sync options * move instead of clone * combinators * rm unnecessary cloning 1 * rm unnecessary cloning 2 * slices; impl Into