diff --git a/.changelog/unreleased/SDK/4213-sdk-rewards-query.md b/.changelog/unreleased/SDK/4213-sdk-rewards-query.md new file mode 100644 index 0000000000..86f84732ba --- /dev/null +++ b/.changelog/unreleased/SDK/4213-sdk-rewards-query.md @@ -0,0 +1,2 @@ +- Added a fn to query PoS rewards to the SDK. + ([\#4213](https://github.com/anoma/namada/pull/4213)) \ No newline at end of file diff --git a/crates/apps_lib/src/client/rpc.rs b/crates/apps_lib/src/client/rpc.rs index 77c0e9f840..5ed707efbc 100644 --- a/crates/apps_lib/src/client/rpc.rs +++ b/crates/apps_lib/src/client/rpc.rs @@ -1482,9 +1482,7 @@ pub async fn query_rewards( source: &Option
, validator: &Address, ) -> token::Amount { - unwrap_client_response::( - RPC.vp().pos().rewards(client, validator, source).await, - ) + unwrap_sdk_result(rpc::query_rewards(client, source, validator).await) } /// Query token total supply. diff --git a/crates/sdk/src/rpc.rs b/crates/sdk/src/rpc.rs index 2e9ce1b68a..2e9792b61c 100644 --- a/crates/sdk/src/rpc.rs +++ b/crates/sdk/src/rpc.rs @@ -858,6 +858,17 @@ pub async fn get_validator_state( ) } +/// Query and return the available reward tokens corresponding to the bond +pub async fn query_rewards( + client: &C, + source: &Option
, + validator: &Address, +) -> Result { + convert_response::( + 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( client: &C,