getting query command to operate

This commit is contained in:
rigel rozanski
2017-07-18 12:08:30 +02:00
committed by Ethan Frey
parent f43fceeb4d
commit cb00c00f0d
4 changed files with 44 additions and 6 deletions
+32
View File
@@ -13,6 +13,7 @@ import (
"github.com/tendermint/basecoin/modules/auth"
"github.com/tendermint/basecoin/modules/coin"
"github.com/tendermint/basecoin/modules/nonce"
"github.com/tendermint/basecoin/stack"
)
@@ -41,6 +42,37 @@ func doAccountQuery(cmd *cobra.Command, args []string) error {
return proofcmd.OutputProof(acc, proof.BlockHeight())
}
// NonceQueryCmd - command to query an nonce account
var NonceQueryCmd = &cobra.Command{
Use: "nonce [address]",
Short: "Get details of a nonce sequence number, with proof",
RunE: lcmd.RequireInit(doNonceQuery),
}
func doNonceQuery(cmd *cobra.Command, args []string) error {
addr, err := proofcmd.ParseHexKey(args, "address")
if err != nil {
return err
}
act := []basecoin.Actor{basecoin.NewActor(
nonce.NameNonce,
addr,
)}
key := stack.PrefixedKey(nonce.NameNonce, nonce.GetSeqKey(act))
var seq uint32
proof, err := proofcmd.GetAndParseAppProof(key, &seq)
if lc.IsNoDataErr(err) {
return errors.Errorf("Sequence is empty for address %X ", addr)
} else if err != nil {
return err
}
return proofcmd.OutputProof(seq, proof.BlockHeight())
}
// BaseTxPresenter this decodes all basecoin tx
type BaseTxPresenter struct {
proofs.RawPresenter // this handles MakeKey as hex bytes
+1
View File
@@ -39,6 +39,7 @@ func main() {
proofs.TxCmd,
proofs.KeyCmd,
bcmd.AccountQueryCmd,
bcmd.NonceQueryCmd,
)
// you will always want this for the base send command