Skip to content

Commit f537f51

Browse files
authored
Fix get_output_mana_rewards, clippy (#2246)
1 parent de1d65d commit f537f51

File tree

24 files changed

+52
-38
lines changed

24 files changed

+52
-38
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/core/src/method/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub enum ClientMethod {
169169
/// epoch - 1 is also used as the last epoch for which rewards are fetched. Callers that do not build
170170
/// transactions with the returned values may omit this value in which case it defaults to the latest committed
171171
/// slot, which is good enough to, e.g. display estimated rewards to users.
172-
slot_index: Option<SlotIndex>,
172+
slot: Option<SlotIndex>,
173173
},
174174
/// Returns information of all registered validators and if they are active, ordered by their holding stake.
175175
#[serde(rename_all = "camelCase")]

bindings/core/src/method_handler/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ pub(crate) async fn call_client_method_internal(
189189
ClientMethod::GetAccountCongestion { account_id, work_score } => {
190190
Response::Congestion(client.get_account_congestion(&account_id, work_score).await?)
191191
}
192-
ClientMethod::GetOutputManaRewards { output_id, slot_index } => {
193-
Response::ManaRewards(client.get_output_mana_rewards(&output_id, slot_index).await?)
192+
ClientMethod::GetOutputManaRewards { output_id, slot } => {
193+
Response::ManaRewards(client.get_output_mana_rewards(&output_id, slot).await?)
194194
}
195195
ClientMethod::GetValidators { page_size, cursor } => {
196196
Response::Validators(client.get_validators(page_size, cursor).await?)

bindings/nodejs/CHANGELOG.md

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

22+
## 2.0.0-beta.1 - 2024-05-08
23+
24+
### Fixed
25+
26+
- `Client::getOutputManaRewards()` slot query parameter;
27+
2228
## 2.0.0-alpha.9 - 2024-05-02
2329

2430
### Added

bindings/nodejs/lib/client/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,13 @@ export class Client {
198198
*/
199199
async getOutputManaRewards(
200200
outputId: OutputId,
201-
slotIndex?: SlotIndex,
201+
slot?: SlotIndex,
202202
): Promise<ManaRewardsResponse> {
203203
const response = await this.methodHandler.callMethod({
204204
name: 'getOutputManaRewards',
205205
data: {
206206
outputId,
207-
slotIndex,
207+
slot,
208208
},
209209
});
210210

bindings/nodejs/lib/types/client/bridge/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export interface __GetOutputManaRewardsMethod__ {
7878
name: 'getOutputManaRewards';
7979
data: {
8080
outputId: OutputId;
81-
slotIndex?: SlotIndex;
81+
slot?: SlotIndex;
8282
};
8383
}
8484

bindings/nodejs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@iota/sdk",
3-
"version": "2.0.0-alpha.9",
3+
"version": "2.0.0-beta.1",
44
"description": "Node.js binding to the IOTA SDK library",
55
"main": "out/index.js",
66
"types": "out/index.d.ts",

bindings/python/CHANGELOG.md

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

22+
## 2.0.0-beta.1 - 2024-05-08
23+
24+
### Fixed
25+
26+
- `Client::get_output_mana_rewards()` slot query parameter;
27+
2228
## 2.0.0-alpha.1 - 2024-05-07
2329

2430
Initial alpha release of the Python 2.0 bindings.

bindings/python/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "iota-sdk-python"
3-
version = "2.0.0-alpha.1"
3+
version = "2.0.0-beta.1"
44
authors = ["IOTA Stiftung"]
55
edition = "2021"
66
description = "Python bindings for the IOTA SDK library"

bindings/python/iota_sdk/client/_node_core_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def get_account_congestion(
107107
# Rewards routes.
108108

109109
def get_output_mana_rewards(
110-
self, output_id: OutputId, slot_index: Optional[SlotIndex] = None) -> ManaRewardsResponse:
110+
self, output_id: OutputId, slot: Optional[SlotIndex] = None) -> ManaRewardsResponse:
111111
"""Returns the total available Mana rewards of an account or delegation output decayed up to `epochEnd` index
112112
provided in the response.
113113
Note that rewards for an epoch only become available at the beginning of the next epoch. If the end epoch of a
@@ -118,7 +118,7 @@ def get_output_mana_rewards(
118118
"""
119119
return ManaRewardsResponse.from_dict(self._call_method('getOutputManaRewards', {
120120
'outputId': output_id,
121-
'slotIndex': slot_index
121+
'slot': slot
122122
}))
123123

124124
# Validators routes.

bindings/python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_py_version_cfgs():
2222

2323
setup(
2424
name="iota_sdk",
25-
version="2.0.0-alpha.1",
25+
version="2.0.0-beta.1",
2626
classifiers=[
2727
"License :: SPDX-License-Identifier :: Apache-2.0",
2828
"Intended Audience :: Developers",

bindings/wasm/CHANGELOG.md

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

22+
## 2.0.0-beta.1 - 2024-05-08
23+
24+
Same changes as https://github.com/iotaledger/iota-sdk/blob/2.0/bindings/nodejs/CHANGELOG.md.
25+
2226
## 2.0.0-alpha.3 - 2024-04-19
2327

2428
Same changes as https://github.com/iotaledger/iota-sdk/blob/2.0/bindings/nodejs/CHANGELOG.md.

bindings/wasm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@iota/sdk-wasm",
3-
"version": "2.0.0-alpha.3",
3+
"version": "2.0.0-beta.1",
44
"description": "WebAssembly bindings for the IOTA SDK library",
55
"repository": {
66
"type": "git",

cli/src/cli.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -393,17 +393,13 @@ pub async fn init_command(storage_path: &Path, init_params: InitParameters) -> R
393393
}
394394

395395
let mut bip_path = init_params.bip_path;
396-
if bip_path.is_none() {
397-
if forced || enter_decision("Do you want to set the bip path of the new wallet?", "yes")? {
398-
bip_path.replace(select_or_enter_bip_path()?);
399-
}
396+
if bip_path.is_none() && forced || enter_decision("Do you want to set the bip path of the new wallet?", "yes")? {
397+
bip_path.replace(select_or_enter_bip_path()?);
400398
}
401399

402400
let mut alias = init_params.alias;
403-
if alias.is_none() {
404-
if enter_decision("Do you want to set an alias for the new wallet?", "yes")? {
405-
alias.replace(enter_alias()?);
406-
}
401+
if alias.is_none() && enter_decision("Do you want to set an alias for the new wallet?", "yes")? {
402+
alias.replace(enter_alias()?);
407403
}
408404

409405
let wallet = Wallet::builder()

cli/src/helper.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use core::str::FromStr;
55
use std::path::Path;
66

7-
use chrono::{DateTime, NaiveDateTime, Utc};
7+
use chrono::{DateTime, Utc};
88
use dialoguer::{console::Term, theme::ColorfulTheme, Input, Select};
99
use eyre::{bail, eyre, Error};
1010
use iota_sdk::{
@@ -342,10 +342,7 @@ pub fn to_utc_date_time(ts_millis: u128) -> Result<DateTime<Utc>, Error> {
342342
let secs_int = i64::try_from(secs).map_err(|e| eyre!("Failed to convert timestamp to i64: {e}"))?;
343343
let nanos = u32::try_from(millis * 1000000).map_err(|e| eyre!("Failed to convert timestamp to u32: {e}"))?;
344344

345-
let naive_time = NaiveDateTime::from_timestamp_opt(secs_int, nanos)
346-
.ok_or(eyre!("Failed to convert timestamp to NaiveDateTime"))?;
347-
348-
Ok(naive_time.and_utc())
345+
DateTime::from_timestamp(secs_int, nanos).ok_or(eyre!("Failed to convert timestamp to DateTime"))
349346
}
350347

351348
pub async fn check_file_exists(path: &Path) -> Result<(), Error> {
@@ -409,7 +406,6 @@ pub fn select_or_enter_bip_path() -> Result<Bip44, Error> {
409406
.items(&choices)
410407
.default(0)
411408
.interact_on(&Term::stderr())?
412-
.into()
413409
{
414410
0 => Bip44::new(IOTA_COIN_TYPE),
415411
1 => Bip44::new(SHIMMER_COIN_TYPE),

sdk/CHANGELOG.md

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

22+
## 2.0.0-beta.1 - 2024-05-08
23+
24+
### Fixed
25+
26+
- `Client::get_output_mana_rewards()` slot query parameter;
27+
2228
## 2.0.0-alpha.1 - 2024-04-29
2329

2430
Initial alpha release of the 2.0 SDK.

sdk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "iota-sdk"
3-
version = "2.0.0-alpha.1"
3+
version = "2.0.0-beta.1"
44
authors = ["IOTA Stiftung"]
55
edition = "2021"
66
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."

sdk/src/client/api/block_builder/transaction_builder/context_inputs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use crate::{
1111
};
1212

1313
impl TransactionBuilder {
14+
// Clippy's suggestion greatly degrades readability.
15+
#[allow(clippy::useless_let_if_seq)]
1416
pub(crate) fn fulfill_context_inputs_requirements(&mut self, input: &InputSigningData) {
1517
match &input.output {
1618
// Transitioning an issuer account requires a BlockIssuanceCreditContextInput.

sdk/src/client/node_api/core/routes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ impl Client {
146146
pub async fn get_output_mana_rewards(
147147
&self,
148148
output_id: &OutputId,
149-
slot_index: impl Into<Option<SlotIndex>> + Send,
149+
slot: impl Into<Option<SlotIndex>> + Send,
150150
) -> Result<ManaRewardsResponse, ClientError> {
151151
let path = &format!("api/core/v3/rewards/{output_id}");
152-
let query = query_tuples_to_query_string([slot_index.into().map(|i| ("slotIndex", i.to_string()))]);
152+
let query = query_tuples_to_query_string([slot.into().map(|i| ("slot", i.to_string()))]);
153153

154154
self.get_request(path, query.as_deref(), false).await
155155
}

sdk/src/wallet/core/operations/background_syncing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ where
5656
loop {
5757
log::debug!("[background_syncing]: syncing wallet");
5858

59-
if let Err(err) = wallet.sync(options.clone()).await {
59+
if let Err(err) = wallet.sync(options).await {
6060
log::debug!("[background_syncing] error: {}", err)
6161
}
6262

sdk/src/wallet/operations/syncing/addresses/output_ids/account_foundry.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright 2022 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use std::collections::HashSet;
5-
64
use crate::{
75
client::{
86
node_api::indexer::query_parameters::{AccountOutputQueryParameters, FoundryOutputQueryParameters},

sdk/src/wallet/operations/syncing/addresses/output_ids/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<S: 'static + SecretManage> Wallet<S> {
112112
tasks.push(
113113
async {
114114
let bech32_address = address.clone();
115-
let sync_options = sync_options.clone();
115+
let sync_options = *sync_options;
116116
let wallet = self.clone();
117117
tokio::spawn(async move {
118118
wallet
@@ -260,7 +260,7 @@ impl<S: 'static + SecretManage> Wallet<S> {
260260
let mut tasks = Vec::new();
261261
for address in addresses_chunk {
262262
let wallet = self.clone();
263-
let sync_options = options.clone();
263+
let sync_options = *options;
264264
tasks.push(async move {
265265
tokio::spawn(async move {
266266
let output_ids = wallet

sdk/src/wallet/operations/syncing/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<S: 'static + SecretManage> Wallet<S> {
4141

4242
// Get the default sync options we use when none are provided.
4343
pub async fn default_sync_options(&self) -> SyncOptions {
44-
self.default_sync_options.lock().await.clone()
44+
*self.default_sync_options.lock().await
4545
}
4646

4747
// First request all outputs directly related to the wallet address, then for each nft and account output we got,

sdk/src/wallet/operations/syncing/outputs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<S: 'static + SecretManage> Wallet<S> {
7171
let mut wallet_ledger = self.ledger_mut().await;
7272

7373
for output_id in output_ids {
74-
match wallet_ledger.outputs.get_mut(&output_id) {
74+
match wallet_ledger.outputs.get_mut(output_id) {
7575
// set unspent if not already
7676
Some(output_data) => {
7777
if output_data.is_spent() {

0 commit comments

Comments
 (0)