diff --git a/src/command/status.ts b/src/command/status.ts index 2938ae36..67934446 100644 --- a/src/command/status.ts +++ b/src/command/status.ts @@ -12,7 +12,7 @@ export class Status extends RootCommand implements LeafCommand { public readonly description = 'Check Bee status' public async run(): Promise { - await super.init() + super.init() this.console.all(chalk.bold('Bee')) process.stdout.write(createKeyValue('API', this.beeApiUrl)) @@ -44,6 +44,15 @@ export class Status extends RootCommand implements LeafCommand { const { bzzBalance, nativeTokenBalance } = await this.bee.getWalletBalance() this.console.all(createKeyValue('xBZZ', Numbers.fromDecimals(bzzBalance, 16))) this.console.all(createKeyValue('xDAI', Numbers.fromDecimals(nativeTokenBalance, 18))) + this.console.all('') + this.console.all(chalk.bold('Chainsync')) + const { block, chainTip } = await this.bee.getChainState() + this.console.all( + createKeyValue( + 'Block', + `${block.toLocaleString()} / ${chainTip.toLocaleString()} (Δ ${(chainTip - block).toLocaleString()})`, + ), + ) } if (nodeInfo.beeMode !== BeeModes.ULTRA_LIGHT && nodeInfo.beeMode !== BeeModes.DEV) { diff --git a/test/http-mock/cheque-mock.ts b/test/http-mock/cheque-mock.ts index 2407502d..871ce67c 100644 --- a/test/http-mock/cheque-mock.ts +++ b/test/http-mock/cheque-mock.ts @@ -30,6 +30,10 @@ export function createChequeMockHttpServer(port: number): Server { response.end(JSON.stringify(balance)) } + if (request.url === '/chainstate') { + response.end(JSON.stringify(chainstate)) + } + if (request.url === '/wallet') { response.end(JSON.stringify(wallet)) } @@ -92,6 +96,13 @@ const lastCashoutCheque1 = { const balance = { totalBalance: '100026853000000000', availableBalance: '100018560000000000' } +const chainstate = { + chainTip: 37439274, + block: 37439270, + totalAmount: '153434201871', + currentPrice: '27356', +} + const wallet = { bzzBalance: '3904697022414848', nativeTokenBalance: '96106482372132023',