Skip to content

Commit

Permalink
updates after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonwells committed Oct 30, 2024
1 parent d0bf4df commit 3358e70
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
26 changes: 14 additions & 12 deletions e2e/capacity/list_unclaimed_rewards.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,23 @@ describe('Capacity: list_unclaimed_rewards', function () {
assert(result.length >= 4, `Length should be >= 4 but is ${result.length}`);

// This is the era we first boosted in, shouldn't have any rewards
assert.equal(result[0].staked_amount.toHuman(), '1.0000 UNIT');
assert.equal(result[0].eligible_amount.toHuman(), '0');
assert.equal(result[0].earned_amount.toHuman(), '0');
const firstResult = result[0]
console.debug({firstResult});
assert.equal(firstResult.stakedAmount.toHuman(), '100,000,000');
assert.equal(firstResult.eligibleAmount.toHuman(), '0');
assert.equal(firstResult.earnedAmount.toHuman(), '0');

// Boosted entire eras, should have rewards
assert.equal(result[1].staked_amount.toHuman(), '1.0000 UNIT');
assert.equal(result[1].eligible_amount.toHuman(), '1.0000 UNIT');
assert.equal(result[1].earned_amount.toHuman(), '3.8000 mUNIT');
assert.equal(result[1].stakedAmount.toHuman(), '100,000,000');
assert.equal(result[1].eligibleAmount.toHuman(), '100,000,000');
assert.equal(result[1].earnedAmount.toHuman(), '380,000');

assert.equal(result[2].staked_amount.toHuman(), '1.0000 UNIT');
assert.equal(result[2].eligible_amount.toHuman(), '1.0000 UNIT');
assert.equal(result[2].earned_amount.toHuman(), '3.8000 mUNIT');
assert.equal(result[2].stakedAmount.toHuman(), '100,000,000');
assert.equal(result[2].eligibleAmount.toHuman(), '100,000,000');
assert.equal(result[2].earnedAmount.toHuman(), '380,000');

assert.equal(result[3].staked_amount.toHuman(), '1.0000 UNIT');
assert.equal(result[3].eligible_amount.toHuman(), '1.0000 UNIT');
assert.equal(result[3].earned_amount.toHuman(), '3.8000 mUNIT');
assert.equal(result[3].stakedAmount.toHuman(), '100,000,000');
assert.equal(result[3].eligibleAmount.toHuman(), '100,000,000');
assert.equal(result[3].earnedAmount.toHuman(), '380,000');
});
});
12 changes: 11 additions & 1 deletion runtime/frequency/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,14 @@ pub use pallet_time_release;
// Polkadot Imports
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};

use common_runtime::weights::rocksdb_weights::constants::RocksDbWeight;
pub use common_runtime::{
constants::MaxSchemaGrants,
weights,
weights::{block_weights::BlockExecutionWeight, extrinsic_weights::ExtrinsicBaseWeight},
};
use frame_support::traits::Contains;
use common_primitives::capacity::UnclaimedRewardInfo;
use common_runtime::weights::rocksdb_weights::constants::RocksDbWeight;

mod genesis;

Expand Down Expand Up @@ -1606,6 +1607,15 @@ sp_api::impl_runtime_apis! {
Handles::validate_handle(base_handle.to_vec())
}
}
impl pallet_capacity_runtime_api::CapacityRuntimeApi<Block, AccountId, Balance, BlockNumber> for Runtime {
fn list_unclaimed_rewards(who: AccountId) -> Vec<UnclaimedRewardInfo<Balance, BlockNumber>> {
match Capacity::list_unclaimed_rewards(&who) {
Ok(rewards) => return rewards.into_inner(),
Err(_) => return Vec::new(),
}

}
}

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
Expand Down

0 comments on commit 3358e70

Please sign in to comment.