Skip to content

Commit f922177

Browse files
authored
add command available-balance (#1)
1 parent 55bb1f0 commit f922177

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Commands:
4242
meridian set-next-round-length <blocks> Set the next round length
4343
meridian set-round-reward <reward> Set the round reward
4444
meridian tick Trigger a tick
45+
meridian available-balance Get the balance available
4546

4647
Options:
4748
-a, --address Contract address (or $MERIDIAN_ADDRESS) [string] [required]

bin/meridian.js

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
import { setNextRoundLength } from '../commands/set-next-round-length.js'
2222
import { setRoundReward } from '../commands/set-round-reward.js'
2323
import { tick } from '../commands/tick.js'
24+
import { availableBalance } from '../commands/available-balance.js'
2425

2526
const pkg = JSON.parse(
2627
await fs.readFile(
@@ -119,6 +120,12 @@ yargs(hideBin(process.argv))
119120
yargs => yargs,
120121
tick
121122
)
123+
.command(
124+
'available-balance',
125+
'Get the balance available',
126+
yargs => yargs,
127+
availableBalance
128+
)
122129
.demandCommand()
123130
.version(`${pkg.name}: ${pkg.version}`)
124131
.alias('v', 'version')

commands/available-balance.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createContract } from '../index.js'
2+
import { formatEther } from 'ethers'
3+
4+
export const availableBalance = async opts => {
5+
const { contract } = createContract(opts)
6+
console.log(formatEther(await contract.availableBalance()), 'FIL')
7+
process.exit(0)
8+
}

0 commit comments

Comments
 (0)