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

Add rewards to mana balance #1951

Merged
merged 7 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
10 changes: 10 additions & 0 deletions sdk/src/wallet/operations/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ where
output_id.transaction_id().slot_index(),
slot_index,
)?;
if let Ok(response) = self.client().get_output_mana_rewards(output_id, slot_index).await {
balance.mana.rewards += response.rewards;
}

// Add storage deposit
balance.required_storage_deposit.account += storage_cost;
Expand Down Expand Up @@ -129,6 +132,9 @@ where
output_id.transaction_id().slot_index(),
slot_index,
)?;
if let Ok(response) = self.client().get_output_mana_rewards(output_id, slot_index).await {
balance.mana.rewards += response.rewards;
}
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved

// Add storage deposit
if output.is_basic() {
Expand Down Expand Up @@ -204,6 +210,10 @@ where
output_id.transaction_id().slot_index(),
slot_index,
)?;
if let Ok(response) = self.client().get_output_mana_rewards(output_id, slot_index).await
{
balance.mana.rewards += response.rewards;
}
Thoralf-M marked this conversation as resolved.
Show resolved Hide resolved

// Add storage deposit
if output.is_basic() {
Expand Down
2 changes: 2 additions & 0 deletions sdk/src/wallet/types/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ pub struct ManaBalance {
pub(crate) total: DecayedMana,
/// Available mana.
pub(crate) available: DecayedMana,
/// Mana rewards.
pub(crate) rewards: u64,
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
}

#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, CopyGetters, derive_more::AddAssign)]
Expand Down
Loading