Skip to content

Commit

Permalink
add command available-balance (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber authored May 10, 2024
1 parent 55bb1f0 commit f922177
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Commands:
meridian set-next-round-length <blocks> Set the next round length
meridian set-round-reward <reward> Set the round reward
meridian tick Trigger a tick
meridian available-balance Get the balance available

Options:
-a, --address Contract address (or $MERIDIAN_ADDRESS) [string] [required]
Expand Down
7 changes: 7 additions & 0 deletions bin/meridian.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import { setNextRoundLength } from '../commands/set-next-round-length.js'
import { setRoundReward } from '../commands/set-round-reward.js'
import { tick } from '../commands/tick.js'
import { availableBalance } from '../commands/available-balance.js'

const pkg = JSON.parse(
await fs.readFile(
Expand Down Expand Up @@ -119,6 +120,12 @@ yargs(hideBin(process.argv))
yargs => yargs,
tick
)
.command(
'available-balance',
'Get the balance available',
yargs => yargs,
availableBalance
)
.demandCommand()
.version(`${pkg.name}: ${pkg.version}`)
.alias('v', 'version')
Expand Down
8 changes: 8 additions & 0 deletions commands/available-balance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createContract } from '../index.js'
import { formatEther } from 'ethers'

export const availableBalance = async opts => {
const { contract } = createContract(opts)
console.log(formatEther(await contract.availableBalance()), 'FIL')
process.exit(0)
}

0 comments on commit f922177

Please sign in to comment.