add color for token amount
This commit is contained in:
parent
c3d94f8aa9
commit
3224c84fb1
@ -218,11 +218,11 @@ func infoCmdAct(cctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
spendable = big.Add(spendable, availBalance)
|
spendable = big.Add(spendable, availBalance)
|
||||||
|
|
||||||
fmt.Printf("Miner Balance: %s\n", color.YellowString("%s", types.FIL(mact.Balance).Short()))
|
colorTokenAmount("Miner Balance: %s\n", mact.Balance)
|
||||||
fmt.Printf(" PreCommit: %s\n", types.FIL(lockedFunds.PreCommitDeposits).Short())
|
colorTokenAmount(" PreCommit: %s\n", lockedFunds.PreCommitDeposits)
|
||||||
fmt.Printf(" Pledge: %s\n", types.FIL(lockedFunds.InitialPledgeRequirement).Short())
|
colorTokenAmount(" Pledge: %s\n", lockedFunds.InitialPledgeRequirement)
|
||||||
fmt.Printf(" Vesting: %s\n", types.FIL(lockedFunds.VestingFunds).Short())
|
colorTokenAmount(" Vesting: %s\n", lockedFunds.VestingFunds)
|
||||||
color.Green(" Available: %s", types.FIL(availBalance).Short())
|
colorTokenAmount(" Available: %s\n", availBalance)
|
||||||
|
|
||||||
mb, err := api.StateMarketBalance(ctx, maddr, types.EmptyTSK)
|
mb, err := api.StateMarketBalance(ctx, maddr, types.EmptyTSK)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -230,16 +230,16 @@ func infoCmdAct(cctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
spendable = big.Add(spendable, big.Sub(mb.Escrow, mb.Locked))
|
spendable = big.Add(spendable, big.Sub(mb.Escrow, mb.Locked))
|
||||||
|
|
||||||
fmt.Printf("Market Balance: %s\n", types.FIL(mb.Escrow).Short())
|
colorTokenAmount("Market Balance: %s\n", mb.Escrow)
|
||||||
fmt.Printf(" Locked: %s\n", types.FIL(mb.Locked).Short())
|
colorTokenAmount(" Locked: %s\n", mb.Locked)
|
||||||
color.Green(" Available: %s\n", types.FIL(big.Sub(mb.Escrow, mb.Locked)).Short())
|
colorTokenAmount(" Available: %s\n", big.Sub(mb.Escrow, mb.Locked))
|
||||||
|
|
||||||
wb, err := api.WalletBalance(ctx, mi.Worker)
|
wb, err := api.WalletBalance(ctx, mi.Worker)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("getting worker balance: %w", err)
|
return xerrors.Errorf("getting worker balance: %w", err)
|
||||||
}
|
}
|
||||||
spendable = big.Add(spendable, wb)
|
spendable = big.Add(spendable, wb)
|
||||||
color.Cyan("Worker Balance: %s", types.FIL(wb).Short())
|
colorTokenAmount("Worker Balance: %s\n", wb)
|
||||||
if len(mi.ControlAddresses) > 0 {
|
if len(mi.ControlAddresses) > 0 {
|
||||||
cbsum := big.Zero()
|
cbsum := big.Zero()
|
||||||
for _, ca := range mi.ControlAddresses {
|
for _, ca := range mi.ControlAddresses {
|
||||||
@ -251,9 +251,9 @@ func infoCmdAct(cctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
spendable = big.Add(spendable, cbsum)
|
spendable = big.Add(spendable, cbsum)
|
||||||
|
|
||||||
fmt.Printf(" Control: %s\n", types.FIL(cbsum).Short())
|
colorTokenAmount(" Control: %s\n", cbsum)
|
||||||
}
|
}
|
||||||
fmt.Printf("Total Spendable: %s\n", color.YellowString(types.FIL(spendable).Short()))
|
colorTokenAmount("Total Spendable: %s\n", spendable)
|
||||||
|
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
@ -355,3 +355,13 @@ func sectorsInfo(ctx context.Context, napi api.StorageMiner) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func colorTokenAmount(format string, amount abi.TokenAmount) {
|
||||||
|
if amount.GreaterThan(big.Zero()) {
|
||||||
|
fmt.Printf(format, color.GreenString("%s", types.FIL(amount).Short()))
|
||||||
|
} else if amount.Equals(big.Zero()) {
|
||||||
|
fmt.Printf(format, color.YellowString("%s", types.FIL(amount).Short()))
|
||||||
|
} else {
|
||||||
|
fmt.Printf(format, color.RedString("%s", types.FIL(amount).Short()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user