From aadc4b6f4c8cf3bd6a4175a24761a2b1952a6dfe Mon Sep 17 00:00:00 2001 From: brentstone Date: Tue, 31 Dec 2024 18:06:54 -0800 Subject: [PATCH] add rewards query to SDK --- crates/apps_lib/src/client/rpc.rs | 4 +--- crates/sdk/src/rpc.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) 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,