Skip to content

Commit

Permalink
add rewards query to SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Jan 1, 2025
1 parent b579d49 commit aadc4b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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 aadc4b6

Please sign in to comment.