From 8a206f0aee859d69bb815cc01536af55b89bd48c Mon Sep 17 00:00:00 2001 From: Clement Sam Date: Thu, 4 May 2023 02:17:17 +0000 Subject: [PATCH] web/multinode: fix wrong undistributed payout amount Resolves https://github.com/storj/storj/issues/5849 Change-Id: I074f6ca9f9ac1e8ffa62649188a6059d9bcd4c25 --- web/multinode/src/operators/index.ts | 13 ++++++++++++- web/multinode/src/payouts/index.ts | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/web/multinode/src/operators/index.ts b/web/multinode/src/operators/index.ts index fd8d0d594..c4f873762 100644 --- a/web/multinode/src/operators/index.ts +++ b/web/multinode/src/operators/index.ts @@ -4,6 +4,11 @@ import { Operators as OperatorsClient } from '@/api/operators'; import { Cursor, Page } from '@/private/pagination'; +/** + * Divider to convert payout amounts to cents. + */ +const PRICE_DIVIDER = 10000; + /** *Operator contains contains SNO payouts contact details and amount of undistributed payouts. */ @@ -14,7 +19,9 @@ export class Operator { public wallet: string, public walletFeatures: string[] | null, public undistributed: number, - ) {} + ) { + this.undistributed = this.convertToCents(this.undistributed); + } /** * indicates if wallet features are enabled. @@ -38,6 +45,10 @@ export class Operator { // TODO: place this to config. return `https://zkscan.io/explorer/accounts/${this.wallet}`; } + + private convertToCents(value: number): number { + return value / PRICE_DIVIDER; + } } /** diff --git a/web/multinode/src/payouts/index.ts b/web/multinode/src/payouts/index.ts index 44fe538ad..38ed932c2 100644 --- a/web/multinode/src/payouts/index.ts +++ b/web/multinode/src/payouts/index.ts @@ -167,5 +167,10 @@ export class Expectation { public currentMonthEstimation: number = 0, public undistributed: number = 0, ) { + this.undistributed = this.convertToCents(this.undistributed); + } + + private convertToCents(value: number): number { + return value / PRICE_DIVIDER; } }