Skip to content

Commit

Permalink
Merge of #4213
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jan 7, 2025
2 parents f0d9ff0 + a5a83f9 commit 4f7e19a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/SDK/4213-sdk-rewards-query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added a fn to query PoS rewards to the SDK.
([\#4213](https://github.com/anoma/namada/pull/4213))
4 changes: 1 addition & 3 deletions crates/apps_lib/src/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1482,9 +1482,7 @@ pub async fn query_rewards<C: Client + Sync>(
source: &Option<Address>,
validator: &Address,
) -> token::Amount {
unwrap_client_response::<C, token::Amount>(
RPC.vp().pos().rewards(client, validator, source).await,
)
unwrap_sdk_result(rpc::query_rewards(client, source, validator).await)
}

/// Query token total supply.
Expand Down
11 changes: 11 additions & 0 deletions crates/sdk/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,17 @@ pub async fn get_validator_state<C: namada_io::Client + Sync>(
)
}

/// Query and return the available reward tokens corresponding to the bond
pub async fn query_rewards<C: namada_io::Client + Sync>(
client: &C,
source: &Option<Address>,
validator: &Address,
) -> Result<token::Amount, error::Error> {
convert_response::<C, token::Amount>(
RPC.vp().pos().rewards(client, validator, source).await,
)
}

/// Get the validators to which a delegator is bonded at a certain epoch
pub async fn get_delegation_validators<C: namada_io::Client + Sync>(
client: &C,
Expand Down

0 comments on commit 4f7e19a

Please sign in to comment.