From 77aadfc92473d548ae64c0a73393aba798a0adfb Mon Sep 17 00:00:00 2001 From: Zaur Abdulgalimov Date: Wed, 22 Nov 2023 11:06:51 +0300 Subject: [PATCH 1/2] DAP-377; add staked value to circulatingSupply --- .../src/circulating/circulating-supply.service.ts | 8 +++++--- common/sdk/sdk.service.ts | 9 +++++++++ package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/apps/web-api/src/circulating/circulating-supply.service.ts b/apps/web-api/src/circulating/circulating-supply.service.ts index 5e7e229..25715e6 100644 --- a/apps/web-api/src/circulating/circulating-supply.service.ts +++ b/apps/web-api/src/circulating/circulating-supply.service.ts @@ -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'; @@ -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(circulatingTotal.toString()), totalSupply: Number(getAmount(count)), }; } diff --git a/common/sdk/sdk.service.ts b/common/sdk/sdk.service.ts index eaac384..85952e2 100644 --- a/common/sdk/sdk.service.ts +++ b/common/sdk/sdk.service.ts @@ -194,4 +194,13 @@ export class SdkService { method: 'totalIssuance', }); } + + @SdkCache('getTotalStaked') + async getTotalStaked(): Promise { + return await this.sdk.stateQueries.execute({ + endpoint: 'query', + module: 'appPromotion', + method: 'totalStaked', + }); + } } diff --git a/package-lock.json b/package-lock.json index 9bcc22a..e59bc63 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "polkastats-backend-uniquenetwork", - "version": "2.0.69", + "version": "2.0.70", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "polkastats-backend-uniquenetwork", - "version": "2.0.69", + "version": "2.0.70", "license": "UNLICENSED", "dependencies": { "@nestjs/apollo": "^10.1.7", diff --git a/package.json b/package.json index 28e48e7..823639b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polkastats-backend-uniquenetwork", - "version": "2.0.69", + "version": "2.0.70", "description": "", "author": "Unique Network Team", "private": true, From 340cc808720823defa819dcec221c79f60ac9d3a Mon Sep 17 00:00:00 2001 From: Zaur Abdulgalimov Date: Tue, 28 Nov 2023 13:13:59 +0300 Subject: [PATCH 2/2] DAP-377; add staked value to circulatingSupply --- apps/web-api/src/circulating/circulating-supply.service.ts | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/web-api/src/circulating/circulating-supply.service.ts b/apps/web-api/src/circulating/circulating-supply.service.ts index 25715e6..e2b4c90 100644 --- a/apps/web-api/src/circulating/circulating-supply.service.ts +++ b/apps/web-api/src/circulating/circulating-supply.service.ts @@ -25,7 +25,7 @@ export class CirculatingSupplyService { const count = BigInt(total.json).toString(); this.logger.log({ request: 'circulating supply', count, total, staked }); return { - circulatingSupply: Number(circulatingTotal.toString()), + circulatingSupply: Number(getAmount(circulatingTotal.toString())), totalSupply: Number(getAmount(count)), }; } diff --git a/package-lock.json b/package-lock.json index e59bc63..1b4f3bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "polkastats-backend-uniquenetwork", - "version": "2.0.70", + "version": "2.0.71", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "polkastats-backend-uniquenetwork", - "version": "2.0.70", + "version": "2.0.71", "license": "UNLICENSED", "dependencies": { "@nestjs/apollo": "^10.1.7", diff --git a/package.json b/package.json index 823639b..a7c1df6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polkastats-backend-uniquenetwork", - "version": "2.0.70", + "version": "2.0.71", "description": "", "author": "Unique Network Team", "private": true,