Skip to content

Commit

Permalink
fix: reverse from_index for get_rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
irfianto committed Apr 29, 2021
1 parent 2233d36 commit 9ce3f2e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion paras-claim-rewards-contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ impl Contract{

pub fn get_rewards(&self, from_index: u64, limit: u64, account_id: ValidAccountId) -> Vec<WrappedReward> {
let user_rewards = self.records.get(account_id.as_ref()).unwrap();
(from_index..std::cmp::min(from_index + limit, user_rewards.get_rewards_len())).rev()
let end_index = user_rewards.get_rewards_len().saturating_sub(from_index);
(end_index.saturating_sub(limit)..end_index).rev()
.map(|index| user_rewards.get_reward(index).to_wreward())
.collect()
}
Expand Down
Binary file modified res/paras_claim_rewards_contract.wasm
Binary file not shown.

0 comments on commit 9ce3f2e

Please sign in to comment.