Skip to content

Commit 951814d

Browse files
authored
feat: add chainsync info to status command (#549)
* feat: add chainsync info to status command * test: add chainstate response to mock server
1 parent a0bbf58 commit 951814d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/command/status.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class Status extends RootCommand implements LeafCommand {
1212
public readonly description = 'Check Bee status'
1313

1414
public async run(): Promise<void> {
15-
await super.init()
15+
super.init()
1616

1717
this.console.all(chalk.bold('Bee'))
1818
process.stdout.write(createKeyValue('API', this.beeApiUrl))
@@ -44,6 +44,15 @@ export class Status extends RootCommand implements LeafCommand {
4444
const { bzzBalance, nativeTokenBalance } = await this.bee.getWalletBalance()
4545
this.console.all(createKeyValue('xBZZ', Numbers.fromDecimals(bzzBalance, 16)))
4646
this.console.all(createKeyValue('xDAI', Numbers.fromDecimals(nativeTokenBalance, 18)))
47+
this.console.all('')
48+
this.console.all(chalk.bold('Chainsync'))
49+
const { block, chainTip } = await this.bee.getChainState()
50+
this.console.all(
51+
createKeyValue(
52+
'Block',
53+
`${block.toLocaleString()} / ${chainTip.toLocaleString()}${(chainTip - block).toLocaleString()})`,
54+
),
55+
)
4756
}
4857

4958
if (nodeInfo.beeMode !== BeeModes.ULTRA_LIGHT && nodeInfo.beeMode !== BeeModes.DEV) {

test/http-mock/cheque-mock.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ export function createChequeMockHttpServer(port: number): Server {
3030
response.end(JSON.stringify(balance))
3131
}
3232

33+
if (request.url === '/chainstate') {
34+
response.end(JSON.stringify(chainstate))
35+
}
36+
3337
if (request.url === '/wallet') {
3438
response.end(JSON.stringify(wallet))
3539
}
@@ -92,6 +96,13 @@ const lastCashoutCheque1 = {
9296

9397
const balance = { totalBalance: '100026853000000000', availableBalance: '100018560000000000' }
9498

99+
const chainstate = {
100+
chainTip: 37439274,
101+
block: 37439270,
102+
totalAmount: '153434201871',
103+
currentPrice: '27356',
104+
}
105+
95106
const wallet = {
96107
bzzBalance: '3904697022414848',
97108
nativeTokenBalance: '96106482372132023',

0 commit comments

Comments
 (0)