new library orders

This commit is contained in:
rigel rozanski 2017-07-19 04:51:36 -04:00
parent 8617841296
commit ac1ecc10c4
30 changed files with 55 additions and 43 deletions

View File

@ -7,10 +7,12 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/basecoin/modules/coin"
eyescli "github.com/tendermint/merkleeyes/client" eyescli "github.com/tendermint/merkleeyes/client"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tmlibs/log"
"github.com/tendermint/basecoin/modules/coin"
) )
const genesisFilepath = "./testdata/genesis.json" const genesisFilepath = "./testdata/genesis.json"

View File

@ -15,19 +15,19 @@ import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/light-client/certifiers"
"github.com/tendermint/light-client/certifiers/files"
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tmlibs/cli"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
"github.com/tendermint/light-client/certifiers"
"github.com/tendermint/light-client/certifiers/files"
) )
var ( var (
dirPerm = os.FileMode(0700) dirPerm = os.FileMode(0700)
) )
//nolint
const ( const (
SeedFlag = "seed" SeedFlag = "seed"
HashFlag = "valhash" HashFlag = "valhash"

View File

@ -8,12 +8,11 @@ import (
wire "github.com/tendermint/go-wire" wire "github.com/tendermint/go-wire"
"github.com/tendermint/go-wire/data" "github.com/tendermint/go-wire/data"
lc "github.com/tendermint/light-client"
"github.com/tendermint/light-client/proofs"
"github.com/tendermint/tendermint/rpc/client" "github.com/tendermint/tendermint/rpc/client"
lc "github.com/tendermint/light-client"
"github.com/tendermint/basecoin/client/commands" "github.com/tendermint/basecoin/client/commands"
"github.com/tendermint/light-client/proofs"
) )
// GetAndParseAppProof does most of the work of the query commands, but is quite // GetAndParseAppProof does most of the work of the query commands, but is quite

View File

@ -4,24 +4,25 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/tendermint/go-wire/data" "github.com/tendermint/go-wire/data"
"github.com/tendermint/light-client/proofs"
"github.com/tendermint/basecoin/client/commands" "github.com/tendermint/basecoin/client/commands"
"github.com/tendermint/light-client/proofs"
) )
var KeyCmd = &cobra.Command{ // KeyQueryCmd - CLI command to query a state by key with proof
var KeyQueryCmd = &cobra.Command{
Use: "key [key]", Use: "key [key]",
Short: "Handle proofs for state of abci app", Short: "Handle proofs for state of abci app",
Long: `This will look up a given key in the abci app, verify the proof, Long: `This will look up a given key in the abci app, verify the proof,
and output it as hex. and output it as hex.
If you want json output, use an app-specific command that knows key and value structure.`, If you want json output, use an app-specific command that knows key and value structure.`,
RunE: commands.RequireInit(doKeyQuery), RunE: commands.RequireInit(keyQueryCmd),
} }
// Note: we cannot yse GetAndParseAppProof here, as we don't use go-wire to // Note: we cannot yse GetAndParseAppProof here, as we don't use go-wire to
// parse the object, but rather return the raw bytes // parse the object, but rather return the raw bytes
func doKeyQuery(cmd *cobra.Command, args []string) error { func keyQueryCmd(cmd *cobra.Command, args []string) error {
// parse cli // parse cli
height := GetHeight() height := GetHeight()
key, err := ParseHexKey(args, "key") key, err := ParseHexKey(args, "key")

View File

@ -3,13 +3,16 @@ package proofs
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/tendermint/basecoin/client/commands"
"github.com/tendermint/light-client/proofs" "github.com/tendermint/light-client/proofs"
"github.com/tendermint/basecoin/client/commands"
) )
//nolint TODO add description
var TxPresenters = proofs.NewPresenters() var TxPresenters = proofs.NewPresenters()
var TxCmd = &cobra.Command{ // TxQueryCmd - CLI command to query a transaction with proof
var TxQueryCmd = &cobra.Command{
Use: "tx [txhash]", Use: "tx [txhash]",
Short: "Handle proofs of commited txs", Short: "Handle proofs of commited txs",
Long: `Proofs allows you to validate abci state with merkle proofs. Long: `Proofs allows you to validate abci state with merkle proofs.
@ -18,10 +21,10 @@ These proofs tie the data to a checkpoint, which is managed by "seeds".
Here we can validate these proofs and import/export them to prove specific Here we can validate these proofs and import/export them to prove specific
data to other peers as needed. data to other peers as needed.
`, `,
RunE: commands.RequireInit(doTxQuery), RunE: commands.RequireInit(txQueryCmd),
} }
func doTxQuery(cmd *cobra.Command, args []string) error { func txQueryCmd(cmd *cobra.Command, args []string) error {
// parse cli // parse cli
height := GetHeight() height := GetHeight()
bkey, err := ParseHexKey(args, "txhash") bkey, err := ParseHexKey(args, "txhash")

View File

@ -7,14 +7,13 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
cmn "github.com/tendermint/tmlibs/common" certclient "github.com/tendermint/light-client/certifiers/client"
"github.com/tendermint/tmlibs/log"
"github.com/tendermint/tendermint/rpc/client" "github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/core" "github.com/tendermint/tendermint/rpc/core"
rpc "github.com/tendermint/tendermint/rpc/lib/server" rpc "github.com/tendermint/tendermint/rpc/lib/server"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
certclient "github.com/tendermint/light-client/certifiers/client"
"github.com/tendermint/basecoin/client/commands" "github.com/tendermint/basecoin/client/commands"
) )

View File

@ -2,6 +2,7 @@ package rpc
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/tendermint/basecoin/client/commands" "github.com/tendermint/basecoin/client/commands"
) )

View File

@ -6,9 +6,9 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/tendermint/go-wire/data" "github.com/tendermint/go-wire/data"
certclient "github.com/tendermint/light-client/certifiers/client"
"github.com/tendermint/tendermint/rpc/client" "github.com/tendermint/tendermint/rpc/client"
certclient "github.com/tendermint/light-client/certifiers/client"
"github.com/tendermint/basecoin/client/commands" "github.com/tendermint/basecoin/client/commands"
) )

View File

@ -3,6 +3,7 @@ package rpc
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/basecoin/client/commands" "github.com/tendermint/basecoin/client/commands"
) )

View File

@ -4,6 +4,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/basecoin/client/commands" "github.com/tendermint/basecoin/client/commands"
) )

View File

@ -6,7 +6,9 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/light-client/certifiers" "github.com/tendermint/light-client/certifiers"
"github.com/tendermint/basecoin/client/commands" "github.com/tendermint/basecoin/client/commands"
) )

View File

@ -7,7 +7,9 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/light-client/certifiers" "github.com/tendermint/light-client/certifiers"
"github.com/tendermint/basecoin/client/commands" "github.com/tendermint/basecoin/client/commands"
) )

View File

@ -4,7 +4,9 @@ import (
"fmt" "fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/tendermint/light-client/certifiers" "github.com/tendermint/light-client/certifiers"
"github.com/tendermint/basecoin/client/commands" "github.com/tendermint/basecoin/client/commands"
) )

View File

@ -2,6 +2,7 @@ package txs
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"
wire "github.com/tendermint/go-wire" wire "github.com/tendermint/go-wire"
"github.com/tendermint/light-client/proofs" "github.com/tendermint/light-client/proofs"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"

View File

@ -9,6 +9,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/basecoin" "github.com/tendermint/basecoin"
) )

View File

@ -8,8 +8,6 @@ import (
"path" "path"
"strings" "strings"
//"github.com/pkg/errors"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/go-crypto" "github.com/tendermint/go-crypto"

View File

@ -3,9 +3,10 @@ package main
import ( import (
"os" "os"
"github.com/tendermint/tmlibs/cli"
"github.com/tendermint/basecoin/app" "github.com/tendermint/basecoin/app"
"github.com/tendermint/basecoin/cmd/basecoin/commands" "github.com/tendermint/basecoin/cmd/basecoin/commands"
"github.com/tendermint/tmlibs/cli"
) )
func main() { func main() {

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
abci "github.com/tendermint/abci/types" abci "github.com/tendermint/abci/types"
"github.com/tendermint/basecoin/errors" "github.com/tendermint/basecoin/errors"
) )

View File

@ -6,7 +6,6 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/basecoin/stack"
crypto "github.com/tendermint/go-crypto" crypto "github.com/tendermint/go-crypto"
keys "github.com/tendermint/go-crypto/keys" keys "github.com/tendermint/go-crypto/keys"
"github.com/tendermint/go-crypto/keys/cryptostore" "github.com/tendermint/go-crypto/keys/cryptostore"
@ -14,6 +13,7 @@ import (
wire "github.com/tendermint/go-wire" wire "github.com/tendermint/go-wire"
"github.com/tendermint/basecoin" "github.com/tendermint/basecoin"
"github.com/tendermint/basecoin/stack"
) )
func checkSignBytes(t *testing.T, bytes []byte, expected string) { func checkSignBytes(t *testing.T, bytes []byte, expected string) {

View File

@ -6,9 +6,8 @@ import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/tendermint/basecoin/client/commands"
"github.com/tendermint/basecoin" "github.com/tendermint/basecoin"
"github.com/tendermint/basecoin/client/commands"
txcmd "github.com/tendermint/basecoin/client/commands/txs" txcmd "github.com/tendermint/basecoin/client/commands/txs"
"github.com/tendermint/basecoin/modules/base" "github.com/tendermint/basecoin/modules/base"
) )

View File

@ -4,9 +4,8 @@ package base
import ( import (
"fmt" "fmt"
pkgerrors "github.com/pkg/errors"
abci "github.com/tendermint/abci/types" abci "github.com/tendermint/abci/types"
"github.com/tendermint/basecoin/errors" "github.com/tendermint/basecoin/errors"
) )
@ -25,13 +24,11 @@ func IsNoChainErr(err error) bool {
return errors.IsSameError(errNoChain, err) return errors.IsSameError(errNoChain, err)
} }
func ErrWrongChain(chain string) errors.TMError { func ErrWrongChain(chain string) errors.TMError {
msg := pkgerrors.Wrap(errWrongChain, chain) return errors.WithMessage(chain, errWrongChain, unauthorized)
return errors.WithCode(msg, unauthorized)
} }
func IsWrongChainErr(err error) bool { func IsWrongChainErr(err error) bool {
return errors.IsSameError(errWrongChain, err) return errors.IsSameError(errWrongChain, err)
} }
func ErrExpired() errors.TMError { func ErrExpired() errors.TMError {
return errors.WithCode(errExpired, unauthorized) return errors.WithCode(errExpired, unauthorized)
} }

View File

@ -7,10 +7,10 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/basecoin/stack"
"github.com/tendermint/go-wire/data" "github.com/tendermint/go-wire/data"
"github.com/tendermint/basecoin" "github.com/tendermint/basecoin"
"github.com/tendermint/basecoin/stack"
) )
func TestEncoding(t *testing.T) { func TestEncoding(t *testing.T) {

View File

@ -4,10 +4,10 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
lcmd "github.com/tendermint/basecoin/client/commands"
proofcmd "github.com/tendermint/basecoin/client/commands/proofs"
lc "github.com/tendermint/light-client" lc "github.com/tendermint/light-client"
lcmd "github.com/tendermint/basecoin/client/commands"
proofcmd "github.com/tendermint/basecoin/client/commands/proofs"
"github.com/tendermint/basecoin/modules/auth" "github.com/tendermint/basecoin/modules/auth"
"github.com/tendermint/basecoin/modules/coin" "github.com/tendermint/basecoin/modules/coin"
"github.com/tendermint/basecoin/stack" "github.com/tendermint/basecoin/stack"

View File

@ -4,9 +4,8 @@ package coin
import ( import (
"fmt" "fmt"
pkgerrors "github.com/pkg/errors"
abci "github.com/tendermint/abci/types" abci "github.com/tendermint/abci/types"
"github.com/tendermint/basecoin/errors" "github.com/tendermint/basecoin/errors"
) )
@ -83,8 +82,7 @@ func IsNoOutputsErr(err error) bool {
} }
func ErrUnknownKey(mod string) errors.TMError { func ErrUnknownKey(mod string) errors.TMError {
w := pkgerrors.Wrap(errUnknownKey, mod) return errors.WithMessage(mod, errUnknownKey, unknownRequest)
return errors.WithCode(w, unknownRequest)
} }
func IsUnknownKeyErr(err error) bool { func IsUnknownKeyErr(err error) bool {
return errors.IsSameError(errUnknownKey, err) return errors.IsSameError(errUnknownKey, err)

View File

@ -1,11 +1,11 @@
package coin package coin
import ( import (
"github.com/tendermint/basecoin/modules/auth"
crypto "github.com/tendermint/go-crypto" crypto "github.com/tendermint/go-crypto"
"github.com/tendermint/go-wire/data" "github.com/tendermint/go-wire/data"
"github.com/tendermint/basecoin" "github.com/tendermint/basecoin"
"github.com/tendermint/basecoin/modules/auth"
) )
// AccountWithKey is a helper for tests, that includes and account // AccountWithKey is a helper for tests, that includes and account

View File

@ -6,11 +6,11 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
lc "github.com/tendermint/light-client"
"github.com/tendermint/basecoin" "github.com/tendermint/basecoin"
lcmd "github.com/tendermint/basecoin/client/commands" lcmd "github.com/tendermint/basecoin/client/commands"
proofcmd "github.com/tendermint/basecoin/client/commands/proofs" proofcmd "github.com/tendermint/basecoin/client/commands/proofs"
lc "github.com/tendermint/light-client"
"github.com/tendermint/basecoin/modules/nonce" "github.com/tendermint/basecoin/modules/nonce"
"github.com/tendermint/basecoin/stack" "github.com/tendermint/basecoin/stack"
) )

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
abci "github.com/tendermint/abci/types" abci "github.com/tendermint/abci/types"
"github.com/tendermint/basecoin/errors" "github.com/tendermint/basecoin/errors"
) )

View File

@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/tendermint/basecoin" "github.com/tendermint/basecoin"
"github.com/tendermint/basecoin/modules/roles" "github.com/tendermint/basecoin/modules/roles"
"github.com/tendermint/basecoin/stack" "github.com/tendermint/basecoin/stack"

View File

@ -3,10 +3,11 @@ package roles
import ( import (
"fmt" "fmt"
wire "github.com/tendermint/go-wire"
"github.com/tendermint/basecoin" "github.com/tendermint/basecoin"
"github.com/tendermint/basecoin/errors" "github.com/tendermint/basecoin/errors"
"github.com/tendermint/basecoin/state" "github.com/tendermint/basecoin/state"
wire "github.com/tendermint/go-wire"
) )
// NewPerm creates a role permission with the given label // NewPerm creates a role permission with the given label

View File

@ -6,11 +6,11 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/go-wire/data"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tmlibs/log"
"github.com/tendermint/basecoin" "github.com/tendermint/basecoin"
"github.com/tendermint/basecoin/state" "github.com/tendermint/basecoin/state"
"github.com/tendermint/go-wire/data"
) )
// writerMid is a middleware that writes the given bytes on CheckTx and DeliverTx // writerMid is a middleware that writes the given bytes on CheckTx and DeliverTx