Update to use new helper methods, less code dups

This commit is contained in:
Ethan Frey 2017-06-15 15:59:45 +02:00
parent 8f67b6be84
commit 282a157997
4 changed files with 6 additions and 27 deletions

View File

@ -53,7 +53,7 @@ func doSendTx(cmd *cobra.Command, args []string) error {
} }
send := &SendTx{ send := &SendTx{
chainID: viper.GetString(commands.ChainFlag), chainID: commands.GetChainID(),
Tx: tx, Tx: tx,
} }
send.AddSigner(txcmd.GetSigner()) send.AddSigner(txcmd.GetSigner())
@ -138,7 +138,7 @@ func ReadAppTxFlags(tx *btypes.AppTx) error {
func WrapAppTx(tx *btypes.AppTx) *AppTx { func WrapAppTx(tx *btypes.AppTx) *AppTx {
return &AppTx{ return &AppTx{
chainID: viper.GetString(commands.ChainFlag), chainID: commands.GetChainID(),
Tx: tx, Tx: tx,
} }
} }

View File

@ -4,7 +4,6 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
wire "github.com/tendermint/go-wire" wire "github.com/tendermint/go-wire"
"github.com/tendermint/light-client/commands"
proofcmd "github.com/tendermint/light-client/commands/proofs" proofcmd "github.com/tendermint/light-client/commands/proofs"
"github.com/tendermint/light-client/proofs" "github.com/tendermint/light-client/proofs"
@ -18,23 +17,14 @@ var AccountQueryCmd = &cobra.Command{
} }
func doAccountQuery(cmd *cobra.Command, args []string) error { func doAccountQuery(cmd *cobra.Command, args []string) error {
height := proofcmd.GetHeight()
addr, err := proofcmd.ParseHexKey(args, "address") addr, err := proofcmd.ParseHexKey(args, "address")
if err != nil { if err != nil {
return err return err
} }
key := btypes.AccountKey(addr) key := btypes.AccountKey(addr)
// get the proof -> this will be used by all prover commands
node := commands.GetNode()
prover := proofs.NewAppProver(node)
proof, err := proofcmd.GetProof(node, prover, key, height)
if err != nil {
return err
}
acc := new(btypes.Account) acc := new(btypes.Account)
err = wire.ReadBinaryBytes(proof.Data(), &acc) proof, err := proofcmd.GetAndParseAppProof(key, &acc)
if err != nil { if err != nil {
return err return err
} }
@ -42,7 +32,7 @@ func doAccountQuery(cmd *cobra.Command, args []string) error {
return proofcmd.OutputProof(acc, proof.BlockHeight()) return proofcmd.OutputProof(acc, proof.BlockHeight())
} }
/*** this decodes the basecoin tx ***/ /*** this decodes all basecoin tx ***/
type BaseTxPresenter struct { type BaseTxPresenter struct {
proofs.RawPresenter // this handles MakeKey as hex bytes proofs.RawPresenter // this handles MakeKey as hex bytes

View File

@ -3,10 +3,7 @@ package counter
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
wire "github.com/tendermint/go-wire"
"github.com/tendermint/light-client/commands"
proofcmd "github.com/tendermint/light-client/commands/proofs" proofcmd "github.com/tendermint/light-client/commands/proofs"
"github.com/tendermint/light-client/proofs"
"github.com/tendermint/basecoin/plugins/counter" "github.com/tendermint/basecoin/plugins/counter"
) )
@ -18,18 +15,10 @@ var CounterQueryCmd = &cobra.Command{
} }
func doCounterQuery(cmd *cobra.Command, args []string) error { func doCounterQuery(cmd *cobra.Command, args []string) error {
height := proofcmd.GetHeight()
key := counter.New().StateKey() key := counter.New().StateKey()
node := commands.GetNode()
prover := proofs.NewAppProver(node)
proof, err := proofcmd.GetProof(node, prover, key, height)
if err != nil {
return err
}
var cp counter.CounterPluginState var cp counter.CounterPluginState
err = wire.ReadBinaryBytes(proof.Data(), &cp) proof, err := proofcmd.GetAndParseAppProof(key, &cp)
if err != nil { if err != nil {
return err return err
} }

2
glide.lock generated
View File

@ -127,7 +127,7 @@ imports:
- data - data
- data/base58 - data/base58
- name: github.com/tendermint/light-client - name: github.com/tendermint/light-client
version: c90f1a90b28977431c6291a0162228e9e4250401 version: 88fb726e779d97acac5f0bd387892bfc541f3701
subpackages: subpackages:
- certifiers - certifiers
- certifiers/client - certifiers/client