Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_output_mana_rewards, clippy #2246

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion bindings/core/src/method/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub enum ClientMethod {
/// epoch - 1 is also used as the last epoch for which rewards are fetched. Callers that do not build
/// transactions with the returned values may omit this value in which case it defaults to the latest committed
/// slot, which is good enough to, e.g. display estimated rewards to users.
slot_index: Option<SlotIndex>,
slot: Option<SlotIndex>,
},
/// Returns information of all registered validators and if they are active, ordered by their holding stake.
#[serde(rename_all = "camelCase")]
Expand Down
4 changes: 2 additions & 2 deletions bindings/core/src/method_handler/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ pub(crate) async fn call_client_method_internal(
ClientMethod::GetAccountCongestion { account_id, work_score } => {
Response::Congestion(client.get_account_congestion(&account_id, work_score).await?)
}
ClientMethod::GetOutputManaRewards { output_id, slot_index } => {
Response::ManaRewards(client.get_output_mana_rewards(&output_id, slot_index).await?)
ClientMethod::GetOutputManaRewards { output_id, slot } => {
Response::ManaRewards(client.get_output_mana_rewards(&output_id, slot).await?)
}
ClientMethod::GetValidators { page_size, cursor } => {
Response::Validators(client.get_validators(page_size, cursor).await?)
Expand Down
6 changes: 6 additions & 0 deletions bindings/nodejs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security -->

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

### Fixed

- `Client::getOutputManaRewards()` slot query parameter;

## 2.0.0-alpha.9 - 2024-05-02

### Added
Expand Down
4 changes: 2 additions & 2 deletions bindings/nodejs/lib/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ export class Client {
*/
async getOutputManaRewards(
outputId: OutputId,
slotIndex?: SlotIndex,
slot?: SlotIndex,
): Promise<ManaRewardsResponse> {
const response = await this.methodHandler.callMethod({
name: 'getOutputManaRewards',
data: {
outputId,
slotIndex,
slot,
},
});

Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/lib/types/client/bridge/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export interface __GetOutputManaRewardsMethod__ {
name: 'getOutputManaRewards';
data: {
outputId: OutputId;
slotIndex?: SlotIndex;
slot?: SlotIndex;
};
}

Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iota/sdk",
"version": "2.0.0-alpha.9",
"version": "2.0.0-beta.1",
"description": "Node.js binding to the IOTA SDK library",
"main": "out/index.js",
"types": "out/index.d.ts",
Expand Down
6 changes: 6 additions & 0 deletions bindings/python/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security -->

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

### Fixed

- `Client::get_output_mana_rewards()` slot query parameter;

## 2.0.0-alpha.1 - 2024-05-07

Initial alpha release of the Python 2.0 bindings.
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iota-sdk-python"
version = "2.0.0-alpha.1"
version = "2.0.0-beta.1"
authors = ["IOTA Stiftung"]
edition = "2021"
description = "Python bindings for the IOTA SDK library"
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/iota_sdk/client/_node_core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_account_congestion(
# Rewards routes.

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

# Validators routes.
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_py_version_cfgs():

setup(
name="iota_sdk",
version="2.0.0-alpha.1",
version="2.0.0-beta.1",
classifiers=[
"License :: SPDX-License-Identifier :: Apache-2.0",
"Intended Audience :: Developers",
Expand Down
4 changes: 4 additions & 0 deletions bindings/wasm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security -->

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

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

## 2.0.0-alpha.3 - 2024-04-19

Same changes as https://github.com/iotaledger/iota-sdk/blob/2.0/bindings/nodejs/CHANGELOG.md.
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iota/sdk-wasm",
"version": "2.0.0-alpha.3",
"version": "2.0.0-beta.1",
"description": "WebAssembly bindings for the IOTA SDK library",
"repository": {
"type": "git",
Expand Down
12 changes: 4 additions & 8 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,17 +393,13 @@ pub async fn init_command(storage_path: &Path, init_params: InitParameters) -> R
}

let mut bip_path = init_params.bip_path;
if bip_path.is_none() {
if forced || enter_decision("Do you want to set the bip path of the new wallet?", "yes")? {
bip_path.replace(select_or_enter_bip_path()?);
}
if bip_path.is_none() && forced || enter_decision("Do you want to set the bip path of the new wallet?", "yes")? {
bip_path.replace(select_or_enter_bip_path()?);
}

let mut alias = init_params.alias;
if alias.is_none() {
if enter_decision("Do you want to set an alias for the new wallet?", "yes")? {
alias.replace(enter_alias()?);
}
if alias.is_none() && enter_decision("Do you want to set an alias for the new wallet?", "yes")? {
alias.replace(enter_alias()?);
}

let wallet = Wallet::builder()
Expand Down
8 changes: 2 additions & 6 deletions cli/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use core::str::FromStr;
use std::path::Path;

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

let naive_time = NaiveDateTime::from_timestamp_opt(secs_int, nanos)
.ok_or(eyre!("Failed to convert timestamp to NaiveDateTime"))?;

Ok(naive_time.and_utc())
DateTime::from_timestamp(secs_int, nanos).ok_or(eyre!("Failed to convert timestamp to DateTime"))
}

pub async fn check_file_exists(path: &Path) -> Result<(), Error> {
Expand Down Expand Up @@ -409,7 +406,6 @@ pub fn select_or_enter_bip_path() -> Result<Bip44, Error> {
.items(&choices)
.default(0)
.interact_on(&Term::stderr())?
.into()
{
0 => Bip44::new(IOTA_COIN_TYPE),
1 => Bip44::new(SHIMMER_COIN_TYPE),
Expand Down
6 changes: 6 additions & 0 deletions sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security -->

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

### Fixed

- `Client::get_output_mana_rewards()` slot query parameter;

## 2.0.0-alpha.1 - 2024-04-29

Initial alpha release of the 2.0 SDK.
Expand Down
2 changes: 1 addition & 1 deletion sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iota-sdk"
version = "2.0.0-alpha.1"
version = "2.0.0-beta.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."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use crate::{
};

impl TransactionBuilder {
// Clippy's suggestion greatly degrades readability.
#[allow(clippy::useless_let_if_seq)]
pub(crate) fn fulfill_context_inputs_requirements(&mut self, input: &InputSigningData) {
match &input.output {
// Transitioning an issuer account requires a BlockIssuanceCreditContextInput.
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/client/node_api/core/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ impl Client {
pub async fn get_output_mana_rewards(
&self,
output_id: &OutputId,
slot_index: impl Into<Option<SlotIndex>> + Send,
slot: impl Into<Option<SlotIndex>> + Send,
) -> Result<ManaRewardsResponse, ClientError> {
let path = &format!("api/core/v3/rewards/{output_id}");
let query = query_tuples_to_query_string([slot_index.into().map(|i| ("slotIndex", i.to_string()))]);
let query = query_tuples_to_query_string([slot.into().map(|i| ("slot", i.to_string()))]);

self.get_request(path, query.as_deref(), false).await
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/wallet/core/operations/background_syncing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ where
loop {
log::debug!("[background_syncing]: syncing wallet");

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright 2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use std::collections::HashSet;

use crate::{
client::{
node_api::indexer::query_parameters::{AccountOutputQueryParameters, FoundryOutputQueryParameters},
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/wallet/operations/syncing/addresses/output_ids/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl<S: 'static + SecretManage> Wallet<S> {
tasks.push(
async {
let bech32_address = address.clone();
let sync_options = sync_options.clone();
let sync_options = *sync_options;
let wallet = self.clone();
tokio::spawn(async move {
wallet
Expand Down Expand Up @@ -260,7 +260,7 @@ impl<S: 'static + SecretManage> Wallet<S> {
let mut tasks = Vec::new();
for address in addresses_chunk {
let wallet = self.clone();
let sync_options = options.clone();
let sync_options = *options;
tasks.push(async move {
tokio::spawn(async move {
let output_ids = wallet
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/wallet/operations/syncing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<S: 'static + SecretManage> Wallet<S> {

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

// First request all outputs directly related to the wallet address, then for each nft and account output we got,
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/wallet/operations/syncing/outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<S: 'static + SecretManage> Wallet<S> {
let mut wallet_ledger = self.ledger_mut().await;

for output_id in output_ids {
match wallet_ledger.outputs.get_mut(&output_id) {
match wallet_ledger.outputs.get_mut(output_id) {
// set unspent if not already
Some(output_data) => {
if output_data.is_spent() {
Expand Down
Loading