Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions apps/web-api/src/circulating/circulating-supply.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forwardRef, Inject, Injectable, Logger } from '@nestjs/common';
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Total } from '@entities/Total';
Expand All @@ -19,11 +19,13 @@ export class CirculatingSupplyService {
const circulating = await this.repo.findOne({
where: { name: 'circulating_supply' },
});
const staked = await this.sdkService.getTotalStaked();
const circulatingTotal = BigInt(circulating.count) + BigInt(staked.json);
const total = await this.sdkService.getTotalSupply();
const count = BigInt(total.json).toString();
this.logger.log({ request: 'circulating supply', count, total });
this.logger.log({ request: 'circulating supply', count, total, staked });
return {
circulatingSupply: Number(circulating.count),
circulatingSupply: Number(getAmount(circulatingTotal.toString())),
totalSupply: Number(getAmount(count)),
};
}
Expand Down
9 changes: 9 additions & 0 deletions common/sdk/sdk.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,13 @@ export class SdkService {
method: 'totalIssuance',
});
}

@SdkCache('getTotalStaked')
async getTotalStaked(): Promise<ITotalIssuance> {
return await this.sdk.stateQueries.execute({
endpoint: 'query',
module: 'appPromotion',
method: 'totalStaked',
});
}
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polkastats-backend-uniquenetwork",
"version": "2.0.69",
"version": "2.0.71",
"description": "",
"author": "Unique Network Team",
"private": true,
Expand Down