Skip to content

Commit

Permalink
feat: add missing pool stats status
Browse files Browse the repository at this point in the history
- add `activating` status for stake pool statistics
  • Loading branch information
Ivaylo Andonov committed May 30, 2023
1 parent 3b1230c commit c844fd0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 3 deletions.
Expand Up @@ -269,7 +269,13 @@ export const mapBlockfrostPoolMetrics = (poolMetricsModel: BlockfrostPoolMetrics
};

export const mapPoolStats = (poolStats: StakePoolStatsModel): StakePoolStats => ({
qty: { active: Number(poolStats.active), retired: Number(poolStats.retired), retiring: Number(poolStats.retiring) }
qty: {
// There is no need of resolving this for db-sync provider, will be deprecated soon with the optimized postgres one
activating: 0,
active: Number(poolStats.active),
retired: Number(poolStats.retired),
retiring: Number(poolStats.retiring)
}
});

export const mapPoolAPY = (poolAPYModel: PoolAPYModel): PoolAPY => ({
Expand Down
Expand Up @@ -283,7 +283,7 @@ describe('StakePoolBuilder', () => {
it('returns active, retired and retiring pools count', async () => {
const result = await builder.queryPoolStats();
expect(result.qty).toBeDefined();
expect(result).toMatchShapeOf({ qty: { active: 0, retired: 0, retiring: 0 } });
expect(result).toMatchShapeOf({ qty: { activating: 0, active: 0, retired: 0, retiring: 0 } });
});
});
describe('queryPoolAPY', () => {
Expand Down
Expand Up @@ -347,7 +347,7 @@ describe('mappers', () => {

it('mapPoolStats', () => {
expect(mapPoolStats({ active: '20', retired: '0', retiring: '1' })).toEqual<StakePoolStats>({
qty: { active: 20, retired: 0, retiring: 1 }
qty: { activating: 0, active: 20, retired: 0, retiring: 1 }
});
});

Expand Down
Expand Up @@ -54,6 +54,7 @@ export interface QueryStakePoolsArgs {

export interface StakePoolStats {
qty: {
activating: number;
active: number;
retired: number;
retiring: number;
Expand Down
1 change: 1 addition & 0 deletions packages/util-dev/src/createStubStakePoolProvider.ts
Expand Up @@ -56,6 +56,7 @@ export const createStubStakePoolProvider = (
if (delayMs) await delay(delayMs);
return {
qty: {
activating: 0,
active: stakePools.filter((pool) => pool.status === Cardano.StakePoolStatus.Active).length,
retired: stakePools.filter((pool) => pool.status === Cardano.StakePoolStatus.Retired).length,
retiring: stakePools.filter((pool) => pool.status === Cardano.StakePoolStatus.Retiring).length
Expand Down
1 change: 1 addition & 0 deletions packages/util-dev/src/mockProviders/mockRewardsProvider.ts
Expand Up @@ -70,6 +70,7 @@ export const stakePoolsPaginated: Paginated<Cardano.StakePool> = {

const stakePoolStatsMock = {
qty: {
activating: 0,
active: 5,
retired: 5,
retiring: 5
Expand Down

0 comments on commit c844fd0

Please sign in to comment.