Skip to content

Commit

Permalink
Update version
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-ogrady committed Oct 23, 2020
1 parent 0361e09 commit f0b3834
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,6 @@ var versionCmd = &cobra.Command{
Use: "version",
Short: "Print rosetta-cli version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("v0.5.16")
fmt.Println("v0.5.17")
},
}
44 changes: 39 additions & 5 deletions cmd/view_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package cmd

import (
"fmt"
"log"
"strconv"
"time"

Expand Down Expand Up @@ -95,7 +94,7 @@ func runViewBlockCmd(cmd *cobra.Command, args []string) error {
}

if !OnlyChanges {
log.Printf("Current Block: %s\n", types.PrettyPrintStruct(block))
fmt.Println("Current Block:", types.PrettyPrintStruct(block))
}

// Print out all balance changes in a given block. This does NOT exempt
Expand All @@ -106,23 +105,58 @@ func runViewBlockCmd(cmd *cobra.Command, args []string) error {
return fmt.Errorf("%w: unable to calculate balance changes", err)
}

fmt.Printf("All Block Balance Changes (Hash: %s)\n", block.BlockIdentifier.Hash)

for _, balanceChange := range balanceChanges {
parsedDiff, err := types.BigInt(balanceChange.Difference)
if err != nil {
return fmt.Errorf("%w: unable to parse Difference", err)
}

log.Printf(
"%s -> %s\n",
fmt.Println(
types.PrintStruct(balanceChange.Account),
"->",
utils.PrettyAmount(parsedDiff, balanceChange.Currency),
)
}

// Print out balance changes by transaction hash
//
// TODO: modify parser to allow for calculating balance
// changes for a single transaction.
for _, tx := range block.Transactions {
fmt.Printf("\n")
balanceChanges, err := p.BalanceChanges(Context, &types.Block{
Transactions: []*types.Transaction{
tx,
},
}, false)
if err != nil {
return fmt.Errorf("%w: unable to calculate balance changes", err)
}

fmt.Println("Transaction Hash:", tx.TransactionIdentifier.Hash)

for _, balanceChange := range balanceChanges {
parsedDiff, err := types.BigInt(balanceChange.Difference)
if err != nil {
return fmt.Errorf("%w: unable to parse Difference", err)
}

fmt.Println(
types.PrintStruct(balanceChange.Account),
"->",
utils.PrettyAmount(parsedDiff, balanceChange.Currency),
)
}

}
fmt.Printf("\n")

if !OnlyChanges {
// Print out all OperationGroups for each transaction in a block.
for _, tx := range block.Transactions {
log.Printf(
fmt.Printf(
"Transaction %s Operation Groups: %s\n",
tx.TransactionIdentifier.Hash,
types.PrettyPrintStruct(parser.GroupOperations(tx)),
Expand Down

0 comments on commit f0b3834

Please sign in to comment.