[cli] Add transaction history command (#100)

* Returns transaction history for an account
* Take account address & max transactions to show as params
pull/102/head
janet-harmony 5 years ago committed by GitHub
parent 18e27b2df7
commit ac8abb5dd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      README.md
  2. 30
      cmd/subcommands/blockchain.go
  3. 1
      cmd/subcommands/request.go

@ -88,6 +88,10 @@ hmy --node="https://api.s1.p.hmny.io" staking collect-rewards \
16. Check active validators
hmy --node="https://api.s1.p.hmny.io" blockchain validator all-active
17. Check in-memory record of failed staking transactions
hmy failures staking
```
# Debugging

@ -8,6 +8,11 @@ import (
"github.com/spf13/cobra"
)
var (
addr oneAddress
size int64
)
func init() {
cmdValidator := &cobra.Command{
Use: "validator",
@ -45,6 +50,30 @@ Query Harmony's blockchain for completed transaction, historic records
},
}
accountHistorySubCmd := &cobra.Command {
Use: "account-history",
Short: "Get history of all transactions for given account",
Long: `
High level information about each transaction for given account
`,
RunE: func(cmd *cobra.Command, args []string) error {
type historyParams struct {
Address string `json:"address"`
PageIndex int64 `json:"pageIndex"`
PageSize int64 `json:"pageSize"`
FullTx bool `json:"fullTx"`
TxType string `json:"txType"`
Order string `json:"order"`
}
noLatest = true
params := historyParams{addr.String(), 0, size, true, "", ""}
return request(rpc.Method.GetTransactionsHistory, []interface{}{params})
},
}
accountHistorySubCmd.Flags().Var(&addr, "address", "address to list transactions for")
accountHistorySubCmd.Flags().Int64Var(&size, "max-tx", 1000, "max number of transactions to list")
subCommands := []*cobra.Command{{
Use: "block-by-number",
Short: "Get a harmony blockchain block by block number",
@ -118,6 +147,7 @@ High level information about transaction, like blockNumber, blockHash
return request(rpc.Method.GetLatestBlockHeader, []interface{}{})
},
},
accountHistorySubCmd,
}
cmdBlockchain.AddCommand(cmdValidator)

Loading…
Cancel
Save