diff --git a/Makefile b/Makefile index ee767dc6c7dd..6e01b4119be7 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ GOTOOLS = github.com/mitchellh/gox \ github.com/rigelrozanski/shelldown/cmd/shelldown TUTORIALS=$(shell find docs/guide -name "*md" -type f) -LINKER_FLAGS:="-X github.com/tendermint/basecoin/client/commands.CommitHash=`git rev-parse --short HEAD`" +LINKER_FLAGS:="-X github.com/cosmos/cosmos-sdk/client/commands.CommitHash=`git rev-parse --short HEAD`" all: get_vendor_deps install test diff --git a/app/app.go b/app/app.go index f31425f36689..17fa1cfdd570 100644 --- a/app/app.go +++ b/app/app.go @@ -9,11 +9,11 @@ import ( cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/stack" - sm "github.com/tendermint/basecoin/state" - "github.com/tendermint/basecoin/version" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/stack" + sm "github.com/cosmos/cosmos-sdk/state" + "github.com/cosmos/cosmos-sdk/version" ) //nolint @@ -27,7 +27,7 @@ type Basecoin struct { info *sm.ChainState state *Store - handler basecoin.Handler + handler sdk.Handler pending []*abci.Validator height uint64 @@ -37,7 +37,7 @@ type Basecoin struct { var _ abci.Application = &Basecoin{} // NewBasecoin - create a new instance of the basecoin application -func NewBasecoin(handler basecoin.Handler, store *Store, logger log.Logger) *Basecoin { +func NewBasecoin(handler sdk.Handler, store *Store, logger log.Logger) *Basecoin { return &Basecoin{ handler: handler, info: sm.NewChainState(), @@ -96,7 +96,7 @@ func (app *Basecoin) SetOption(key string, value string) string { // DeliverTx - ABCI func (app *Basecoin) DeliverTx(txBytes []byte) abci.Result { - tx, err := basecoin.LoadTx(txBytes) + tx, err := sdk.LoadTx(txBytes) if err != nil { return errors.Result(err) } @@ -112,12 +112,12 @@ func (app *Basecoin) DeliverTx(txBytes []byte) abci.Result { return errors.Result(err) } app.addValChange(res.Diff) - return basecoin.ToABCI(res) + return sdk.ToABCI(res) } // CheckTx - ABCI func (app *Basecoin) CheckTx(txBytes []byte) abci.Result { - tx, err := basecoin.LoadTx(txBytes) + tx, err := sdk.LoadTx(txBytes) if err != nil { return errors.Result(err) } @@ -132,7 +132,7 @@ func (app *Basecoin) CheckTx(txBytes []byte) abci.Result { if err != nil { return errors.Result(err) } - return basecoin.ToABCI(res) + return sdk.ToABCI(res) } // Query - ABCI diff --git a/app/app_test.go b/app/app_test.go index 0da5b31c1a2a..fca03e15ecc4 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -8,22 +8,22 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/abci/types" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/modules/auth" - "github.com/tendermint/basecoin/modules/base" - "github.com/tendermint/basecoin/modules/coin" - "github.com/tendermint/basecoin/modules/fee" - "github.com/tendermint/basecoin/modules/ibc" - "github.com/tendermint/basecoin/modules/nonce" - "github.com/tendermint/basecoin/modules/roles" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/modules/auth" + "github.com/cosmos/cosmos-sdk/modules/base" + "github.com/cosmos/cosmos-sdk/modules/coin" + "github.com/cosmos/cosmos-sdk/modules/fee" + "github.com/cosmos/cosmos-sdk/modules/ibc" + "github.com/cosmos/cosmos-sdk/modules/nonce" + "github.com/cosmos/cosmos-sdk/modules/roles" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" wire "github.com/tendermint/go-wire" "github.com/tendermint/tmlibs/log" ) // DefaultHandler for the tests (coin, roles, ibc) -func DefaultHandler(feeDenom string) basecoin.Handler { +func DefaultHandler(feeDenom string) sdk.Handler { // use the default stack r := roles.NewHandler() i := ibc.NewHandler() @@ -70,30 +70,30 @@ func newAppTest(t *testing.T) *appTest { } // baseTx is the -func (at *appTest) baseTx(coins coin.Coins) basecoin.Tx { +func (at *appTest) baseTx(coins coin.Coins) sdk.Tx { in := []coin.TxInput{{Address: at.acctIn.Actor(), Coins: coins}} out := []coin.TxOutput{{Address: at.acctOut.Actor(), Coins: coins}} tx := coin.NewSendTx(in, out) return tx } -func (at *appTest) signTx(tx basecoin.Tx) basecoin.Tx { +func (at *appTest) signTx(tx sdk.Tx) sdk.Tx { stx := auth.NewMulti(tx) auth.Sign(stx, at.acctIn.Key) return stx.Wrap() } -func (at *appTest) getTx(coins coin.Coins, sequence uint32) basecoin.Tx { +func (at *appTest) getTx(coins coin.Coins, sequence uint32) sdk.Tx { tx := at.baseTx(coins) - tx = nonce.NewTx(sequence, []basecoin.Actor{at.acctIn.Actor()}, tx) + tx = nonce.NewTx(sequence, []sdk.Actor{at.acctIn.Actor()}, tx) tx = base.NewChainTx(at.chainID, 0, tx) return at.signTx(tx) } -func (at *appTest) feeTx(coins coin.Coins, toll coin.Coin, sequence uint32) basecoin.Tx { +func (at *appTest) feeTx(coins coin.Coins, toll coin.Coin, sequence uint32) sdk.Tx { tx := at.baseTx(coins) tx = fee.NewFee(tx, toll, at.acctIn.Actor()) - tx = nonce.NewTx(sequence, []basecoin.Actor{at.acctIn.Actor()}, tx) + tx = nonce.NewTx(sequence, []sdk.Actor{at.acctIn.Actor()}, tx) tx = base.NewChainTx(at.chainID, 0, tx) return at.signTx(tx) } @@ -131,7 +131,7 @@ func (at *appTest) reset() { require.True(at.t, resabci.IsOK(), resabci) } -func getBalance(key basecoin.Actor, store state.SimpleDB) (coin.Coins, error) { +func getBalance(key sdk.Actor, store state.SimpleDB) (coin.Coins, error) { cspace := stack.PrefixedStore(coin.NameCoin, store) acct, err := coin.GetAccount(cspace, key) return acct.Coins, err @@ -143,7 +143,7 @@ func getAddr(addr []byte, state state.SimpleDB) (coin.Coins, error) { } // returns the final balance and expected balance for input and output accounts -func (at *appTest) exec(t *testing.T, tx basecoin.Tx, checkTx bool) (res abci.Result, diffIn, diffOut coin.Coins) { +func (at *appTest) exec(t *testing.T, tx sdk.Tx, checkTx bool) (res abci.Result, diffIn, diffOut coin.Coins) { require := require.New(t) initBalIn, err := getBalance(at.acctIn.Actor(), at.app.GetState()) diff --git a/app/app_val_test.go b/app/app_val_test.go index aabb83443418..ea0be27d0bb3 100644 --- a/app/app_val_test.go +++ b/app/app_val_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" abci "github.com/tendermint/abci/types" - "github.com/tendermint/basecoin/modules/base" + "github.com/cosmos/cosmos-sdk/modules/base" wire "github.com/tendermint/go-wire" cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/log" diff --git a/app/genesis_test.go b/app/genesis_test.go index 83e8ba741776..2b76cd7f9514 100644 --- a/app/genesis_test.go +++ b/app/genesis_test.go @@ -11,7 +11,7 @@ import ( cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin/modules/coin" + "github.com/cosmos/cosmos-sdk/modules/coin" ) const genesisFilepath = "./testdata/genesis.json" diff --git a/app/store.go b/app/store.go index efb5471ca12a..8a9be0875ece 100644 --- a/app/store.go +++ b/app/store.go @@ -15,7 +15,7 @@ import ( dbm "github.com/tendermint/tmlibs/db" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin/state" + "github.com/cosmos/cosmos-sdk/state" ) // Store contains the merkle tree, and all info to handle abci requests diff --git a/benchmarks/app_test.go b/benchmarks/app_test.go index b25ffce0ccba..acbf182f789a 100644 --- a/benchmarks/app_test.go +++ b/benchmarks/app_test.go @@ -9,15 +9,15 @@ import ( cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/app" - "github.com/tendermint/basecoin/modules/auth" - "github.com/tendermint/basecoin/modules/base" - "github.com/tendermint/basecoin/modules/coin" - "github.com/tendermint/basecoin/modules/fee" - "github.com/tendermint/basecoin/modules/nonce" - "github.com/tendermint/basecoin/modules/roles" - "github.com/tendermint/basecoin/stack" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/app" + "github.com/cosmos/cosmos-sdk/modules/auth" + "github.com/cosmos/cosmos-sdk/modules/base" + "github.com/cosmos/cosmos-sdk/modules/coin" + "github.com/cosmos/cosmos-sdk/modules/fee" + "github.com/cosmos/cosmos-sdk/modules/nonce" + "github.com/cosmos/cosmos-sdk/modules/roles" + "github.com/cosmos/cosmos-sdk/stack" ) type BenchApp struct { @@ -27,7 +27,7 @@ type BenchApp struct { } // DefaultHandler - placeholder to just handle sendtx -func DefaultHandler(feeDenom string) basecoin.Handler { +func DefaultHandler(feeDenom string) sdk.Handler { // use the default stack c := coin.NewHandler() r := roles.NewHandler() @@ -46,7 +46,7 @@ func DefaultHandler(feeDenom string) basecoin.Handler { ).Use(d) } -func NewBenchApp(h basecoin.Handler, chainID string, n int, +func NewBenchApp(h sdk.Handler, chainID string, n int, persist bool) BenchApp { logger := log.NewNopLogger() @@ -107,7 +107,7 @@ func (b BenchApp) makeTx(useFee bool) []byte { tx = fee.NewFee(tx, toll, sender.Actor()) } sequence := sender.NextSequence() - tx = nonce.NewTx(sequence, []basecoin.Actor{sender.Actor()}, tx) + tx = nonce.NewTx(sequence, []sdk.Actor{sender.Actor()}, tx) tx = base.NewChainTx(b.ChainID, 0, tx) stx := auth.NewMulti(tx) auth.Sign(stx, sender.Key) diff --git a/client/commands/common.go b/client/commands/common.go index 15be46b244a2..3b75a211ba18 100644 --- a/client/commands/common.go +++ b/client/commands/common.go @@ -20,8 +20,8 @@ import ( rpcclient "github.com/tendermint/tendermint/rpc/client" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/modules/auth" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/modules/auth" ) var ( @@ -86,9 +86,9 @@ func GetCertifier() (*certifiers.InquiringCertifier, error) { // ParseActor parses an address of form: // [:][:] -// into a basecoin.Actor. +// into a sdk.Actor. // If app is not specified or "", then assume auth.NameSigs -func ParseActor(input string) (res basecoin.Actor, err error) { +func ParseActor(input string) (res sdk.Actor, err error) { chain, app := "", auth.NameSigs input = strings.TrimSpace(input) spl := strings.SplitN(input, ":", 3) @@ -108,7 +108,7 @@ func ParseActor(input string) (res basecoin.Actor, err error) { if err != nil { return res, errors.Errorf("Address is invalid hex: %v\n", err) } - res = basecoin.Actor{ + res = sdk.Actor{ ChainID: chain, App: app, Address: addr, @@ -118,8 +118,8 @@ func ParseActor(input string) (res basecoin.Actor, err error) { // ParseActors takes a comma-separated list of actors and parses them into // a slice -func ParseActors(key string) (signers []basecoin.Actor, err error) { - var act basecoin.Actor +func ParseActors(key string) (signers []sdk.Actor, err error) { + var act sdk.Actor for _, k := range strings.Split(key, ",") { act, err = ParseActor(k) if err != nil { diff --git a/client/commands/proxy/root.go b/client/commands/proxy/root.go index 4845773dad04..cc47107ed2b6 100644 --- a/client/commands/proxy/root.go +++ b/client/commands/proxy/root.go @@ -14,7 +14,7 @@ import ( cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands" ) // RootCmd represents the base command when called without any subcommands diff --git a/client/commands/query/get.go b/client/commands/query/get.go index 574d679bad67..7798473a98ee 100644 --- a/client/commands/query/get.go +++ b/client/commands/query/get.go @@ -16,7 +16,7 @@ import ( "github.com/tendermint/merkleeyes/iavl" "github.com/tendermint/tendermint/rpc/client" - "github.com/tendermint/basecoin/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands" ) // GetParsed does most of the work of the query commands, but is quite diff --git a/client/commands/query/query_test.go b/client/commands/query/query_test.go index 47579c4648d0..0786851c2b5b 100644 --- a/client/commands/query/query_test.go +++ b/client/commands/query/query_test.go @@ -17,8 +17,8 @@ import ( "github.com/tendermint/tendermint/types" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin/app" - "github.com/tendermint/basecoin/modules/eyes" + "github.com/cosmos/cosmos-sdk/app" + "github.com/cosmos/cosmos-sdk/modules/eyes" ) var node *nm.Node diff --git a/client/commands/query/root.go b/client/commands/query/root.go index 24b25ff21de2..ec583dd79f8e 100644 --- a/client/commands/query/root.go +++ b/client/commands/query/root.go @@ -2,7 +2,7 @@ package query import ( "github.com/spf13/cobra" - "github.com/tendermint/basecoin/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands" ) // nolint diff --git a/client/commands/query/state.go b/client/commands/query/state.go index 513440b20bb8..13dae0ea856e 100644 --- a/client/commands/query/state.go +++ b/client/commands/query/state.go @@ -4,7 +4,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands" ) // KeyQueryCmd - CLI command to query a state by key with proof diff --git a/client/commands/query/tx.go b/client/commands/query/tx.go index 7b108b950a0e..6d41d3a53f39 100644 --- a/client/commands/query/tx.go +++ b/client/commands/query/tx.go @@ -4,11 +4,11 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin" + sdk "github.com/cosmos/cosmos-sdk" wire "github.com/tendermint/go-wire" "github.com/tendermint/tendermint/types" - "github.com/tendermint/basecoin/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands" ) // TxQueryCmd - CLI command to query a transaction with proof @@ -65,9 +65,9 @@ func txQueryCmd(cmd *cobra.Command, args []string) error { return showTx(res.Height, res.Proof.Data) } -// showTx parses anything that was previously registered as basecoin.Tx +// showTx parses anything that was previously registered as sdk.Tx func showTx(h int, tx types.Tx) error { - var info basecoin.Tx + var info sdk.Tx err := wire.ReadBinaryBytes(tx, &info) if err != nil { return err diff --git a/client/commands/rpc/helpers.go b/client/commands/rpc/helpers.go index 5ef0f4f3ef1f..7bcd074a0fa8 100644 --- a/client/commands/rpc/helpers.go +++ b/client/commands/rpc/helpers.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands" "github.com/tendermint/tendermint/rpc/client" ) diff --git a/client/commands/rpc/insecure.go b/client/commands/rpc/insecure.go index 5587a5914068..143bff163003 100644 --- a/client/commands/rpc/insecure.go +++ b/client/commands/rpc/insecure.go @@ -3,7 +3,7 @@ package rpc import ( "github.com/spf13/cobra" - "github.com/tendermint/basecoin/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands" ) var statusCmd = &cobra.Command{ diff --git a/client/commands/rpc/root.go b/client/commands/rpc/root.go index 2a1d0e532bfe..af9327470f37 100644 --- a/client/commands/rpc/root.go +++ b/client/commands/rpc/root.go @@ -9,7 +9,7 @@ import ( certclient "github.com/tendermint/light-client/certifiers/client" "github.com/tendermint/tendermint/rpc/client" - "github.com/tendermint/basecoin/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands" ) const ( diff --git a/client/commands/rpc/secure.go b/client/commands/rpc/secure.go index 717c20c98146..fb310294b46d 100644 --- a/client/commands/rpc/secure.go +++ b/client/commands/rpc/secure.go @@ -4,7 +4,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands" ) func init() { diff --git a/client/commands/seeds/export.go b/client/commands/seeds/export.go index b37c11bfb0d0..febdc7daea6e 100644 --- a/client/commands/seeds/export.go +++ b/client/commands/seeds/export.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands" "github.com/tendermint/light-client/certifiers" ) diff --git a/client/commands/seeds/import.go b/client/commands/seeds/import.go index 4a63ef7d78af..311439150663 100644 --- a/client/commands/seeds/import.go +++ b/client/commands/seeds/import.go @@ -9,7 +9,7 @@ import ( "github.com/tendermint/light-client/certifiers" - "github.com/tendermint/basecoin/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands" ) const ( diff --git a/client/commands/seeds/show.go b/client/commands/seeds/show.go index 100201b63706..d0ba0b7b84ca 100644 --- a/client/commands/seeds/show.go +++ b/client/commands/seeds/show.go @@ -10,7 +10,7 @@ import ( "github.com/tendermint/light-client/certifiers" - "github.com/tendermint/basecoin/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands" ) const ( diff --git a/client/commands/seeds/update.go b/client/commands/seeds/update.go index a3be67aced89..df2a9621087c 100644 --- a/client/commands/seeds/update.go +++ b/client/commands/seeds/update.go @@ -8,7 +8,7 @@ import ( "github.com/tendermint/light-client/certifiers" - "github.com/tendermint/basecoin/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands" ) var updateCmd = &cobra.Command{ diff --git a/client/commands/txs/helpers.go b/client/commands/txs/helpers.go index 45c811ecf6c3..f7600368c204 100644 --- a/client/commands/txs/helpers.go +++ b/client/commands/txs/helpers.go @@ -22,9 +22,9 @@ import ( ctypes "github.com/tendermint/tendermint/rpc/core/types" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/modules/auth" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/modules/auth" ) // Validatable represents anything that can be Validated @@ -43,7 +43,7 @@ func GetSigner() crypto.PubKey { // GetSignerAct returns the address of the signer of the tx // (as we still only support single sig) -func GetSignerAct() (res basecoin.Actor) { +func GetSignerAct() (res sdk.Actor) { // this could be much cooler with multisig... signer := GetSigner() if !signer.Empty() { @@ -61,7 +61,7 @@ func GetSignerAct() (res basecoin.Actor) { // If you want a non-standard flow, just call the various functions directly. // eg. if you already set the middleware layers in your code, or want to // output in another format. -func DoTx(tx basecoin.Tx) (err error) { +func DoTx(tx sdk.Tx) (err error) { tx, err = Middleware.Wrap(tx) if err != nil { return err @@ -85,7 +85,7 @@ func DoTx(tx basecoin.Tx) (err error) { // SignTx will validate the tx, and signs it if it is wrapping a Signable. // Modifies tx in place, and returns an error if it should sign but couldn't -func SignTx(tx basecoin.Tx) error { +func SignTx(tx sdk.Tx) error { // validate tx client-side err := tx.ValidateBasic() if err != nil { @@ -114,7 +114,7 @@ func SignTx(tx basecoin.Tx) error { // multisig, or to post it to the node. Returns error on any failure. // If no error and the result is nil, it means it already wrote to file, // no post, no need to do more. -func PrepareOrPostTx(tx basecoin.Tx) (*ctypes.ResultBroadcastTxCommit, error) { +func PrepareOrPostTx(tx sdk.Tx) (*ctypes.ResultBroadcastTxCommit, error) { wrote, err := PrepareTx(tx) // error in prep if err != nil { @@ -132,7 +132,7 @@ func PrepareOrPostTx(tx basecoin.Tx) (*ctypes.ResultBroadcastTxCommit, error) { // to the specified location for later multi-sig. Returns true if it // handled the tx (no futher work required), false if it did nothing // (and we should post the tx) -func PrepareTx(tx basecoin.Tx) (bool, error) { +func PrepareTx(tx sdk.Tx) (bool, error) { prep := viper.GetString(FlagPrepare) if prep == "" { return false, nil @@ -152,7 +152,7 @@ func PrepareTx(tx basecoin.Tx) (bool, error) { // PostTx does all work once we construct a proper struct // it validates the data, signs if needed, transforms to bytes, // and posts to the node. -func PostTx(tx basecoin.Tx) (*ctypes.ResultBroadcastTxCommit, error) { +func PostTx(tx sdk.Tx) (*ctypes.ResultBroadcastTxCommit, error) { packet := wire.BinaryBytes(tx) // post the bytes node := commands.GetNode() diff --git a/client/commands/txs/root.go b/client/commands/txs/root.go index d5a31a940ca0..0a6317027bd2 100644 --- a/client/commands/txs/root.go +++ b/client/commands/txs/root.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin" + sdk "github.com/cosmos/cosmos-sdk" ) // nolint @@ -39,7 +39,7 @@ func doRawTx(cmd *cobra.Command, args []string) error { } // parse the input - var tx basecoin.Tx + var tx sdk.Tx err = json.Unmarshal(raw, &tx) if err != nil { return errors.WithStack(err) diff --git a/client/commands/txs/wrapper.go b/client/commands/txs/wrapper.go index 3d711f948b65..4265eff8d727 100644 --- a/client/commands/txs/wrapper.go +++ b/client/commands/txs/wrapper.go @@ -3,7 +3,7 @@ package txs import ( "github.com/spf13/pflag" - "github.com/tendermint/basecoin" + sdk "github.com/cosmos/cosmos-sdk" ) var ( @@ -14,7 +14,7 @@ var ( // Wrapper defines the information needed for each middleware package that // wraps the data. They should read all configuration out of bounds via viper. type Wrapper interface { - Wrap(basecoin.Tx) (basecoin.Tx, error) + Wrap(sdk.Tx) (sdk.Tx, error) Register(*pflag.FlagSet) } @@ -26,7 +26,7 @@ var _ Wrapper = Wrappers{} // Wrap applies the wrappers to the passed in tx in order, // aborting on the first error -func (ws Wrappers) Wrap(tx basecoin.Tx) (basecoin.Tx, error) { +func (ws Wrappers) Wrap(tx sdk.Tx) (sdk.Tx, error) { var err error for _, w := range ws { tx, err = w.Wrap(tx) diff --git a/client/commands/version.go b/client/commands/version.go index 34a2af2ff195..551b2506f363 100644 --- a/client/commands/version.go +++ b/client/commands/version.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/tendermint/basecoin/version" + "github.com/cosmos/cosmos-sdk/version" ) // CommitHash should be filled by linker flags diff --git a/client/rest/handlers.go b/client/rest/handlers.go index 695bd6a0f9b1..ee2bfb89fb29 100644 --- a/client/rest/handlers.go +++ b/client/rest/handlers.go @@ -6,7 +6,7 @@ import ( "github.com/gorilla/mux" "github.com/pkg/errors" - "github.com/tendermint/basecoin" + sdk "github.com/cosmos/cosmos-sdk" keysutils "github.com/tendermint/go-crypto/cmd" keys "github.com/tendermint/go-crypto/keys" "github.com/tendermint/tmlibs/common" @@ -126,7 +126,7 @@ func (k *Keys) DeleteKey(w http.ResponseWriter, r *http.Request) { } func doPostTx(w http.ResponseWriter, r *http.Request) { - tx := new(basecoin.Tx) + tx := new(sdk.Tx) if err := common.ParseRequestAndValidateJSON(r, tx); err != nil { common.WriteError(w, err) return diff --git a/client/rest/helpers.go b/client/rest/helpers.go index e780fdd95bef..be9118ef8752 100644 --- a/client/rest/helpers.go +++ b/client/rest/helpers.go @@ -7,12 +7,12 @@ import ( ctypes "github.com/tendermint/tendermint/rpc/core/types" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/client/commands" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/client/commands" ) // PostTx is same as a tx -func PostTx(tx basecoin.Tx) (*ctypes.ResultBroadcastTxCommit, error) { +func PostTx(tx sdk.Tx) (*ctypes.ResultBroadcastTxCommit, error) { packet := wire.BinaryBytes(tx) // post the bytes node := commands.GetNode() @@ -20,7 +20,7 @@ func PostTx(tx basecoin.Tx) (*ctypes.ResultBroadcastTxCommit, error) { } // SignTx will modify the tx in-place, adding a signature if possible -func SignTx(name, pass string, tx basecoin.Tx) error { +func SignTx(name, pass string, tx sdk.Tx) error { if sign, ok := tx.Unwrap().(keys.Signable); ok { manager := keycmd.GetKeyManager() return manager.Sign(name, pass, sign) diff --git a/client/rest/types.go b/client/rest/types.go index a04141ae90a5..3ae0252ca6d5 100644 --- a/client/rest/types.go +++ b/client/rest/types.go @@ -1,8 +1,8 @@ package rest import ( - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/modules/coin" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/modules/coin" "github.com/tendermint/go-crypto/keys" ) @@ -29,7 +29,7 @@ type SignRequest struct { Name string `json:"name,omitempty" validate:"required,min=3,printascii"` Password string `json:"password,omitempty" validate:"required,min=10"` - Tx basecoin.Tx `json:"tx" validate:"required"` + Tx sdk.Tx `json:"tx" validate:"required"` } type CreateKeyResponse struct { @@ -46,7 +46,7 @@ type SendInput struct { Multi bool `json:"multi,omitempty"` Sequence uint32 `json:"sequence"` - To *basecoin.Actor `json:"to"` - From *basecoin.Actor `json:"from"` + To *sdk.Actor `json:"to"` + From *sdk.Actor `json:"from"` Amount coin.Coins `json:"amount"` } diff --git a/cmd/basecli/main.go b/cmd/basecli/main.go index 54df8eac5455..d69e795b7cf0 100644 --- a/cmd/basecli/main.go +++ b/cmd/basecli/main.go @@ -8,20 +8,20 @@ import ( keycmd "github.com/tendermint/go-crypto/cmd" "github.com/tendermint/tmlibs/cli" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/client/commands/auto" - "github.com/tendermint/basecoin/client/commands/proxy" - "github.com/tendermint/basecoin/client/commands/query" - rpccmd "github.com/tendermint/basecoin/client/commands/rpc" - "github.com/tendermint/basecoin/client/commands/seeds" - txcmd "github.com/tendermint/basecoin/client/commands/txs" - authcmd "github.com/tendermint/basecoin/modules/auth/commands" - basecmd "github.com/tendermint/basecoin/modules/base/commands" - coincmd "github.com/tendermint/basecoin/modules/coin/commands" - feecmd "github.com/tendermint/basecoin/modules/fee/commands" - ibccmd "github.com/tendermint/basecoin/modules/ibc/commands" - noncecmd "github.com/tendermint/basecoin/modules/nonce/commands" - rolecmd "github.com/tendermint/basecoin/modules/roles/commands" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands/auto" + "github.com/cosmos/cosmos-sdk/client/commands/proxy" + "github.com/cosmos/cosmos-sdk/client/commands/query" + rpccmd "github.com/cosmos/cosmos-sdk/client/commands/rpc" + "github.com/cosmos/cosmos-sdk/client/commands/seeds" + txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs" + authcmd "github.com/cosmos/cosmos-sdk/modules/auth/commands" + basecmd "github.com/cosmos/cosmos-sdk/modules/base/commands" + coincmd "github.com/cosmos/cosmos-sdk/modules/coin/commands" + feecmd "github.com/cosmos/cosmos-sdk/modules/fee/commands" + ibccmd "github.com/cosmos/cosmos-sdk/modules/ibc/commands" + noncecmd "github.com/cosmos/cosmos-sdk/modules/nonce/commands" + rolecmd "github.com/cosmos/cosmos-sdk/modules/roles/commands" ) // BaseCli - main basecoin client command diff --git a/cmd/basecoin/commands/ibc.go b/cmd/basecoin/commands/ibc.go index 3cb98a9fb9e0..e551bbfd2c54 100644 --- a/cmd/basecoin/commands/ibc.go +++ b/cmd/basecoin/commands/ibc.go @@ -1,6 +1,6 @@ package commands -// import "github.com/tendermint/basecoin/plugins/ibc" +// import "github.com/cosmos/cosmos-sdk/plugins/ibc" // // returns a new IBC plugin to be registered with Basecoin // func NewIBCPlugin() *ibc.IBCPlugin { diff --git a/cmd/basecoin/commands/relay.go b/cmd/basecoin/commands/relay.go index a177acec8121..4a8be9fbd569 100644 --- a/cmd/basecoin/commands/relay.go +++ b/cmd/basecoin/commands/relay.go @@ -17,8 +17,8 @@ package commands // "github.com/tendermint/merkleeyes/iavl" // cmn "github.com/tendermint/tmlibs/common" -// "github.com/tendermint/basecoin/plugins/ibc" -// "github.com/tendermint/basecoin/types" +// "github.com/cosmos/cosmos-sdk/plugins/ibc" +// "github.com/cosmos/cosmos-sdk/types" // "github.com/tendermint/tendermint/rpc/client" // tmtypes "github.com/tendermint/tendermint/types" // ) diff --git a/cmd/basecoin/commands/start.go b/cmd/basecoin/commands/start.go index aac85a96bf04..5a94a60c70bf 100644 --- a/cmd/basecoin/commands/start.go +++ b/cmd/basecoin/commands/start.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/viper" "github.com/tendermint/abci/server" - "github.com/tendermint/basecoin" + sdk "github.com/cosmos/cosmos-sdk" "github.com/tendermint/tmlibs/cli" cmn "github.com/tendermint/tmlibs/common" @@ -19,7 +19,7 @@ import ( "github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/types" - "github.com/tendermint/basecoin/app" + "github.com/cosmos/cosmos-sdk/app" ) // StartCmd - command to start running the basecoin node! @@ -41,7 +41,7 @@ const ( var ( // Handler - use a global to store the handler, so we can set it in main. // TODO: figure out a cleaner way to register plugins - Handler basecoin.Handler + Handler sdk.Handler ) func init() { diff --git a/cmd/basecoin/main.go b/cmd/basecoin/main.go index fc4fa691ac0b..c14eacca69e6 100644 --- a/cmd/basecoin/main.go +++ b/cmd/basecoin/main.go @@ -5,21 +5,21 @@ import ( "github.com/tendermint/tmlibs/cli" - "github.com/tendermint/basecoin" - client "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/cmd/basecoin/commands" - "github.com/tendermint/basecoin/modules/auth" - "github.com/tendermint/basecoin/modules/base" - "github.com/tendermint/basecoin/modules/coin" - "github.com/tendermint/basecoin/modules/fee" - "github.com/tendermint/basecoin/modules/ibc" - "github.com/tendermint/basecoin/modules/nonce" - "github.com/tendermint/basecoin/modules/roles" - "github.com/tendermint/basecoin/stack" + sdk "github.com/cosmos/cosmos-sdk" + client "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/cmd/basecoin/commands" + "github.com/cosmos/cosmos-sdk/modules/auth" + "github.com/cosmos/cosmos-sdk/modules/base" + "github.com/cosmos/cosmos-sdk/modules/coin" + "github.com/cosmos/cosmos-sdk/modules/fee" + "github.com/cosmos/cosmos-sdk/modules/ibc" + "github.com/cosmos/cosmos-sdk/modules/nonce" + "github.com/cosmos/cosmos-sdk/modules/roles" + "github.com/cosmos/cosmos-sdk/stack" ) // BuildApp constructs the stack we want to use for this app -func BuildApp(feeDenom string) basecoin.Handler { +func BuildApp(feeDenom string) sdk.Handler { return stack.New( base.Logger{}, stack.Recovery{}, diff --git a/cmd/baseserver/main.go b/cmd/baseserver/main.go index 422b445dec13..a92e8edd0190 100644 --- a/cmd/baseserver/main.go +++ b/cmd/baseserver/main.go @@ -10,11 +10,11 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin/client/commands" - rest "github.com/tendermint/basecoin/client/rest" - coinrest "github.com/tendermint/basecoin/modules/coin/rest" - noncerest "github.com/tendermint/basecoin/modules/nonce/rest" - rolerest "github.com/tendermint/basecoin/modules/roles/rest" + "github.com/cosmos/cosmos-sdk/client/commands" + rest "github.com/cosmos/cosmos-sdk/client/rest" + coinrest "github.com/cosmos/cosmos-sdk/modules/coin/rest" + noncerest "github.com/cosmos/cosmos-sdk/modules/nonce/rest" + rolerest "github.com/cosmos/cosmos-sdk/modules/roles/rest" "github.com/tendermint/tmlibs/cli" ) diff --git a/cmd/eyes/init.go b/cmd/eyes/init.go index 54f424293850..87f05daf801f 100644 --- a/cmd/eyes/init.go +++ b/cmd/eyes/init.go @@ -8,7 +8,7 @@ import ( tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" - "github.com/tendermint/basecoin/cmd/basecoin/commands" + "github.com/cosmos/cosmos-sdk/cmd/basecoin/commands" ) // InitCmd - node initialization command diff --git a/cmd/eyes/main.go b/cmd/eyes/main.go index c82cd7d196b3..8216eb658dea 100644 --- a/cmd/eyes/main.go +++ b/cmd/eyes/main.go @@ -5,16 +5,16 @@ import ( "github.com/tendermint/tmlibs/cli" - "github.com/tendermint/basecoin" - client "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/cmd/basecoin/commands" - "github.com/tendermint/basecoin/modules/base" - "github.com/tendermint/basecoin/modules/eyes" - "github.com/tendermint/basecoin/stack" + sdk "github.com/cosmos/cosmos-sdk" + client "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/cmd/basecoin/commands" + "github.com/cosmos/cosmos-sdk/modules/base" + "github.com/cosmos/cosmos-sdk/modules/eyes" + "github.com/cosmos/cosmos-sdk/stack" ) // BuildApp constructs the stack we want to use for this app -func BuildApp() basecoin.Handler { +func BuildApp() sdk.Handler { return stack.New( base.Logger{}, stack.Recovery{}, diff --git a/cmd/eyescli/main.go b/cmd/eyescli/main.go index 7b89a5d91d84..2ba4a5355e12 100644 --- a/cmd/eyescli/main.go +++ b/cmd/eyescli/main.go @@ -8,14 +8,14 @@ import ( keycmd "github.com/tendermint/go-crypto/cmd" "github.com/tendermint/tmlibs/cli" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/client/commands/auto" - "github.com/tendermint/basecoin/client/commands/proxy" - "github.com/tendermint/basecoin/client/commands/query" - rpccmd "github.com/tendermint/basecoin/client/commands/rpc" - "github.com/tendermint/basecoin/client/commands/seeds" - txcmd "github.com/tendermint/basecoin/client/commands/txs" - eyescmd "github.com/tendermint/basecoin/modules/eyes/commands" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands/auto" + "github.com/cosmos/cosmos-sdk/client/commands/proxy" + "github.com/cosmos/cosmos-sdk/client/commands/query" + rpccmd "github.com/cosmos/cosmos-sdk/client/commands/rpc" + "github.com/cosmos/cosmos-sdk/client/commands/seeds" + txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs" + eyescmd "github.com/cosmos/cosmos-sdk/modules/eyes/commands" ) // EyesCli - main basecoin client command diff --git a/context.go b/context.go index d22102e94107..75677f0857e8 100644 --- a/context.go +++ b/context.go @@ -1,4 +1,4 @@ -package basecoin +package sdk import ( "bytes" diff --git a/docs/guide/counter/cmd/counter/main.go b/docs/guide/counter/cmd/counter/main.go index 705136964c7e..02a2d045d107 100644 --- a/docs/guide/counter/cmd/counter/main.go +++ b/docs/guide/counter/cmd/counter/main.go @@ -7,9 +7,9 @@ import ( "github.com/tendermint/tmlibs/cli" - client "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/cmd/basecoin/commands" - "github.com/tendermint/basecoin/docs/guide/counter/plugins/counter" + client "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/cmd/basecoin/commands" + "github.com/cosmos/cosmos-sdk/docs/guide/counter/plugins/counter" ) func main() { diff --git a/docs/guide/counter/cmd/countercli/commands/counter.go b/docs/guide/counter/cmd/countercli/commands/counter.go index cf4dbfe28dfe..01a2dafff622 100644 --- a/docs/guide/counter/cmd/countercli/commands/counter.go +++ b/docs/guide/counter/cmd/countercli/commands/counter.go @@ -4,10 +4,10 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin" - txcmd "github.com/tendermint/basecoin/client/commands/txs" - "github.com/tendermint/basecoin/docs/guide/counter/plugins/counter" - "github.com/tendermint/basecoin/modules/coin" + sdk "github.com/cosmos/cosmos-sdk" + txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs" + "github.com/cosmos/cosmos-sdk/docs/guide/counter/plugins/counter" + "github.com/cosmos/cosmos-sdk/modules/coin" ) //CounterTxCmd is the CLI command to execute the counter @@ -41,7 +41,7 @@ func counterTx(cmd *cobra.Command, args []string) error { return txcmd.DoTx(tx) } -func readCounterTxFlags() (tx basecoin.Tx, err error) { +func readCounterTxFlags() (tx sdk.Tx, err error) { feeCoins, err := coin.ParseCoins(viper.GetString(FlagCountFee)) if err != nil { return tx, err diff --git a/docs/guide/counter/cmd/countercli/commands/query.go b/docs/guide/counter/cmd/countercli/commands/query.go index f497fec92ec5..6dcbe14b71bb 100644 --- a/docs/guide/counter/cmd/countercli/commands/query.go +++ b/docs/guide/counter/cmd/countercli/commands/query.go @@ -4,11 +4,11 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/client/commands/query" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands/query" - "github.com/tendermint/basecoin/docs/guide/counter/plugins/counter" - "github.com/tendermint/basecoin/stack" + "github.com/cosmos/cosmos-sdk/docs/guide/counter/plugins/counter" + "github.com/cosmos/cosmos-sdk/stack" ) //CounterQueryCmd - CLI command to query the counter state diff --git a/docs/guide/counter/cmd/countercli/main.go b/docs/guide/counter/cmd/countercli/main.go index 975fb5655395..184b222aa64a 100644 --- a/docs/guide/counter/cmd/countercli/main.go +++ b/docs/guide/counter/cmd/countercli/main.go @@ -8,17 +8,17 @@ import ( keycmd "github.com/tendermint/go-crypto/cmd" "github.com/tendermint/tmlibs/cli" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/client/commands/proxy" - "github.com/tendermint/basecoin/client/commands/query" - "github.com/tendermint/basecoin/client/commands/seeds" - txcmd "github.com/tendermint/basecoin/client/commands/txs" - bcount "github.com/tendermint/basecoin/docs/guide/counter/cmd/countercli/commands" - authcmd "github.com/tendermint/basecoin/modules/auth/commands" - basecmd "github.com/tendermint/basecoin/modules/base/commands" - coincmd "github.com/tendermint/basecoin/modules/coin/commands" - feecmd "github.com/tendermint/basecoin/modules/fee/commands" - noncecmd "github.com/tendermint/basecoin/modules/nonce/commands" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands/proxy" + "github.com/cosmos/cosmos-sdk/client/commands/query" + "github.com/cosmos/cosmos-sdk/client/commands/seeds" + txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs" + bcount "github.com/cosmos/cosmos-sdk/docs/guide/counter/cmd/countercli/commands" + authcmd "github.com/cosmos/cosmos-sdk/modules/auth/commands" + basecmd "github.com/cosmos/cosmos-sdk/modules/base/commands" + coincmd "github.com/cosmos/cosmos-sdk/modules/coin/commands" + feecmd "github.com/cosmos/cosmos-sdk/modules/fee/commands" + noncecmd "github.com/cosmos/cosmos-sdk/modules/nonce/commands" ) // BaseCli represents the base command when called without any subcommands diff --git a/docs/guide/counter/plugins/counter/counter.go b/docs/guide/counter/plugins/counter/counter.go index 53ae4f9f5e2c..7ce08761db46 100644 --- a/docs/guide/counter/plugins/counter/counter.go +++ b/docs/guide/counter/plugins/counter/counter.go @@ -6,17 +6,17 @@ import ( abci "github.com/tendermint/abci/types" "github.com/tendermint/go-wire" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/modules/auth" - "github.com/tendermint/basecoin/modules/base" - "github.com/tendermint/basecoin/modules/coin" - "github.com/tendermint/basecoin/modules/fee" - "github.com/tendermint/basecoin/modules/ibc" - "github.com/tendermint/basecoin/modules/nonce" - "github.com/tendermint/basecoin/modules/roles" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/modules/auth" + "github.com/cosmos/cosmos-sdk/modules/base" + "github.com/cosmos/cosmos-sdk/modules/coin" + "github.com/cosmos/cosmos-sdk/modules/fee" + "github.com/cosmos/cosmos-sdk/modules/ibc" + "github.com/cosmos/cosmos-sdk/modules/nonce" + "github.com/cosmos/cosmos-sdk/modules/roles" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) // Tx @@ -32,7 +32,7 @@ const ( ) func init() { - basecoin.TxMapper.RegisterImplementation(Tx{}, TypeTx, ByteTx) + sdk.TxMapper.RegisterImplementation(Tx{}, TypeTx, ByteTx) } // Tx - struct for all counter transactions @@ -42,7 +42,7 @@ type Tx struct { } // NewTx - return a new counter transaction struct wrapped as a basecoin transaction -func NewTx(valid bool, fee coin.Coins) basecoin.Tx { +func NewTx(valid bool, fee coin.Coins) sdk.Tx { return Tx{ Valid: valid, Fee: fee, @@ -50,8 +50,8 @@ func NewTx(valid bool, fee coin.Coins) basecoin.Tx { } // Wrap - Wrap a Tx as a Basecoin Tx, used to satisfy the XXX interface -func (c Tx) Wrap() basecoin.Tx { - return basecoin.Tx{TxInner: c} +func (c Tx) Wrap() sdk.Tx { + return sdk.Tx{TxInner: c} } // ValidateBasic just makes sure the Fee is a valid, non-negative value @@ -91,7 +91,7 @@ func ErrDecoding() error { //-------------------------------------------------------------------------------- // NewHandler returns a new counter transaction processing handler -func NewHandler(feeDenom string) basecoin.Handler { +func NewHandler(feeDenom string) sdk.Handler { return stack.New( base.Logger{}, stack.Recovery{}, @@ -129,13 +129,13 @@ func (Handler) Name() string { func (Handler) AssertDispatcher() {} // CheckTx checks if the tx is properly structured -func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, _ basecoin.Checker) (res basecoin.CheckResult, err error) { +func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, _ sdk.Checker) (res sdk.CheckResult, err error) { _, err = checkTx(ctx, tx) return } // DeliverTx executes the tx if valid -func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, dispatch basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, dispatch sdk.Deliver) (res sdk.DeliverResult, err error) { ctr, err := checkTx(ctx, tx) if err != nil { return res, err @@ -175,7 +175,7 @@ func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx baseco return res, err } -func checkTx(ctx basecoin.Context, tx basecoin.Tx) (ctr Tx, err error) { +func checkTx(ctx sdk.Context, tx sdk.Tx) (ctr Tx, err error) { ctr, ok := tx.Unwrap().(Tx) if !ok { return ctr, errors.ErrInvalidFormat(TypeTx, tx) @@ -191,8 +191,8 @@ func checkTx(ctx basecoin.Context, tx basecoin.Tx) (ctr Tx, err error) { //-------------------------------------------------------------------------------- // StoreActor - return the basecoin actor for the account -func StoreActor() basecoin.Actor { - return basecoin.Actor{App: NameCounter, Address: []byte{0x04, 0x20}} //XXX what do these bytes represent? - should use typebyte variables +func StoreActor() sdk.Actor { + return sdk.Actor{App: NameCounter, Address: []byte{0x04, 0x20}} //XXX what do these bytes represent? - should use typebyte variables } // State - state of the counter applicaton diff --git a/docs/guide/counter/plugins/counter/counter_test.go b/docs/guide/counter/plugins/counter/counter_test.go index 968760492d14..50af3b3d9b9f 100644 --- a/docs/guide/counter/plugins/counter/counter_test.go +++ b/docs/guide/counter/plugins/counter/counter_test.go @@ -10,12 +10,12 @@ import ( "github.com/tendermint/go-wire" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/app" - "github.com/tendermint/basecoin/modules/auth" - "github.com/tendermint/basecoin/modules/base" - "github.com/tendermint/basecoin/modules/coin" - "github.com/tendermint/basecoin/modules/nonce" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/app" + "github.com/cosmos/cosmos-sdk/modules/auth" + "github.com/cosmos/cosmos-sdk/modules/base" + "github.com/cosmos/cosmos-sdk/modules/coin" + "github.com/cosmos/cosmos-sdk/modules/nonce" ) func TestCounterPlugin(t *testing.T) { @@ -47,7 +47,7 @@ func TestCounterPlugin(t *testing.T) { // Deliver a CounterTx DeliverCounterTx := func(valid bool, counterFee coin.Coins, sequence uint32) abci.Result { tx := NewTx(valid, counterFee) - tx = nonce.NewTx(sequence, []basecoin.Actor{acct.Actor()}, tx) + tx = nonce.NewTx(sequence, []sdk.Actor{acct.Actor()}, tx) tx = base.NewChainTx(chainID, 0, tx) stx := auth.NewSig(tx) auth.Sign(stx, acct.Key) diff --git a/handler.go b/handler.go index 82c636ddd926..8047fc40af09 100644 --- a/handler.go +++ b/handler.go @@ -1,11 +1,11 @@ -package basecoin +package sdk import ( abci "github.com/tendermint/abci/types" "github.com/tendermint/go-wire/data" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin/state" + "github.com/cosmos/cosmos-sdk/state" ) // Handler is anything that processes a transaction diff --git a/modules/auth/bench_test.go b/modules/auth/bench_test.go index f2434f1eeec7..739c553278c2 100644 --- a/modules/auth/bench_test.go +++ b/modules/auth/bench_test.go @@ -8,12 +8,12 @@ import ( cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) -func makeSignTx() basecoin.Tx { +func makeSignTx() sdk.Tx { key := crypto.GenPrivKeyEd25519().Wrap() payload := cmn.RandBytes(32) tx := NewSig(stack.NewRawTx(payload)) @@ -21,7 +21,7 @@ func makeSignTx() basecoin.Tx { return tx.Wrap() } -func makeMultiSignTx(cnt int) basecoin.Tx { +func makeMultiSignTx(cnt int) sdk.Tx { payload := cmn.RandBytes(32) tx := NewMulti(stack.NewRawTx(payload)) for i := 0; i < cnt; i++ { @@ -31,7 +31,7 @@ func makeMultiSignTx(cnt int) basecoin.Tx { return tx.Wrap() } -func makeHandler() basecoin.Handler { +func makeHandler() sdk.Handler { return stack.New(Signatures{}).Use(stack.OKHandler{}) } diff --git a/modules/auth/commands/wrap.go b/modules/auth/commands/wrap.go index c93eecb70239..a731b7f3d000 100644 --- a/modules/auth/commands/wrap.go +++ b/modules/auth/commands/wrap.go @@ -4,9 +4,9 @@ import ( "github.com/spf13/pflag" "github.com/spf13/viper" - "github.com/tendermint/basecoin" - txcmd "github.com/tendermint/basecoin/client/commands/txs" - "github.com/tendermint/basecoin/modules/auth" + sdk "github.com/cosmos/cosmos-sdk" + txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs" + "github.com/cosmos/cosmos-sdk/modules/auth" ) //nolint @@ -20,7 +20,7 @@ type SigWrapper struct{} var _ txcmd.Wrapper = SigWrapper{} // Wrap will wrap the tx with OneSig or MultiSig depending on flags -func (SigWrapper) Wrap(tx basecoin.Tx) (res basecoin.Tx, err error) { +func (SigWrapper) Wrap(tx sdk.Tx) (res sdk.Tx, err error) { if !viper.GetBool(FlagMulti) { res = auth.NewSig(tx).Wrap() } else { diff --git a/modules/auth/errors.go b/modules/auth/errors.go index 28352ce2d8c1..46b562cf4e49 100644 --- a/modules/auth/errors.go +++ b/modules/auth/errors.go @@ -6,7 +6,7 @@ import ( abci "github.com/tendermint/abci/types" - "github.com/tendermint/basecoin/errors" + "github.com/cosmos/cosmos-sdk/errors" ) var ( diff --git a/modules/auth/errors_test.go b/modules/auth/errors_test.go index 887eae1e5c70..d23d3b14db98 100644 --- a/modules/auth/errors_test.go +++ b/modules/auth/errors_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/tendermint/basecoin/errors" + "github.com/cosmos/cosmos-sdk/errors" ) func TestChecks(t *testing.T) { diff --git a/modules/auth/signature.go b/modules/auth/signature.go index 01ee72bd4c55..99de6f7b9d11 100644 --- a/modules/auth/signature.go +++ b/modules/auth/signature.go @@ -3,10 +3,10 @@ package auth import ( crypto "github.com/tendermint/go-crypto" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) //nolint @@ -29,18 +29,18 @@ func (Signatures) Name() string { var _ stack.Middleware = Signatures{} // SigPerm takes the binary address from PubKey.Address and makes it an Actor -func SigPerm(addr []byte) basecoin.Actor { - return basecoin.NewActor(NameSigs, addr) +func SigPerm(addr []byte) sdk.Actor { + return sdk.NewActor(NameSigs, addr) } // Signable allows us to use txs.OneSig and txs.MultiSig (and others??) type Signable interface { - basecoin.TxLayer + sdk.TxLayer Signers() ([]crypto.PubKey, error) } // CheckTx verifies the signatures are correct - fulfills Middlware interface -func (Signatures) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) { +func (Signatures) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) { sigs, tnext, err := getSigners(tx) if err != nil { return res, err @@ -50,7 +50,7 @@ func (Signatures) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoi } // DeliverTx verifies the signatures are correct - fulfills Middlware interface -func (Signatures) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (Signatures) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) { sigs, tnext, err := getSigners(tx) if err != nil { return res, err @@ -59,8 +59,8 @@ func (Signatures) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basec return next.DeliverTx(ctx2, store, tnext) } -func addSigners(ctx basecoin.Context, sigs []crypto.PubKey) basecoin.Context { - perms := make([]basecoin.Actor, len(sigs)) +func addSigners(ctx sdk.Context, sigs []crypto.PubKey) sdk.Context { + perms := make([]sdk.Actor, len(sigs)) for i, s := range sigs { perms[i] = SigPerm(s.Address()) } @@ -68,10 +68,10 @@ func addSigners(ctx basecoin.Context, sigs []crypto.PubKey) basecoin.Context { return ctx.WithPermissions(perms...) } -func getSigners(tx basecoin.Tx) ([]crypto.PubKey, basecoin.Tx, error) { +func getSigners(tx sdk.Tx) ([]crypto.PubKey, sdk.Tx, error) { stx, ok := tx.Unwrap().(Signable) if !ok { - return nil, basecoin.Tx{}, errors.ErrUnauthorized() + return nil, sdk.Tx{}, errors.ErrUnauthorized() } sig, err := stx.Signers() return sig, stx.Next(), err diff --git a/modules/auth/signature_test.go b/modules/auth/signature_test.go index 5afbee1a60b5..79706f953d8d 100644 --- a/modules/auth/signature_test.go +++ b/modules/auth/signature_test.go @@ -9,9 +9,9 @@ import ( crypto "github.com/tendermint/go-crypto" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) func TestSignatureChecks(t *testing.T) { @@ -32,7 +32,7 @@ func TestSignatureChecks(t *testing.T) { cases := []struct { useMultiSig bool keys []crypto.PrivKey - check basecoin.Actor + check sdk.Actor valid bool }{ // test with single sigs @@ -61,7 +61,7 @@ func TestSignatureChecks(t *testing.T) { stack.CheckMiddleware{Required: tc.check}, ).Use(stack.OKHandler{}) - var tx basecoin.Tx + var tx sdk.Tx // this does the signing as needed if tc.useMultiSig { mtx := NewMulti(raw) diff --git a/modules/auth/tx.go b/modules/auth/tx.go index 970f321dc55c..9139e5818712 100644 --- a/modules/auth/tx.go +++ b/modules/auth/tx.go @@ -9,7 +9,7 @@ complex algorithms (although it would be great to add them). You can create them with NewSig() and NewMultiSig(), and they fulfill the keys.Signable interface. You can then .Wrap() them to create -a basecoin.Tx. +a sdk.Tx. */ package auth @@ -18,8 +18,8 @@ import ( "github.com/tendermint/go-crypto/keys" "github.com/tendermint/go-wire/data" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" ) // nolint @@ -50,7 +50,7 @@ func (s Signed) Empty() bool { /**** Registration ****/ func init() { - basecoin.TxMapper. + sdk.TxMapper. RegisterImplementation(&OneSig{}, TypeSingleTx, ByteSingleTx). RegisterImplementation(&MultiSig{}, TypeMultiSig, ByteMultiSig) } @@ -59,23 +59,23 @@ func init() { // OneSig lets us wrap arbitrary data with a go-crypto signature type OneSig struct { - Tx basecoin.Tx `json:"tx"` + Tx sdk.Tx `json:"tx"` Signed `json:"signature"` } var _ keys.Signable = &OneSig{} -var _ basecoin.TxLayer = &OneSig{} +var _ sdk.TxLayer = &OneSig{} // NewSig wraps the tx with a Signable that accepts exactly one signature -func NewSig(tx basecoin.Tx) *OneSig { +func NewSig(tx sdk.Tx) *OneSig { return &OneSig{Tx: tx} } //nolint -func (s *OneSig) Wrap() basecoin.Tx { - return basecoin.Tx{s} +func (s *OneSig) Wrap() sdk.Tx { + return sdk.Tx{s} } -func (s *OneSig) Next() basecoin.Tx { +func (s *OneSig) Next() sdk.Tx { return s.Tx } func (s *OneSig) ValidateBasic() error { @@ -130,23 +130,23 @@ func (s *OneSig) Signers() ([]crypto.PubKey, error) { // MultiSig lets us wrap arbitrary data with a go-crypto signature type MultiSig struct { - Tx basecoin.Tx `json:"tx"` + Tx sdk.Tx `json:"tx"` Sigs []Signed `json:"signatures"` } var _ keys.Signable = &MultiSig{} -var _ basecoin.TxLayer = &MultiSig{} +var _ sdk.TxLayer = &MultiSig{} // NewMulti wraps the tx with a Signable that accepts arbitrary numbers of signatures -func NewMulti(tx basecoin.Tx) *MultiSig { +func NewMulti(tx sdk.Tx) *MultiSig { return &MultiSig{Tx: tx} } // nolint -func (s *MultiSig) Wrap() basecoin.Tx { - return basecoin.Tx{s} +func (s *MultiSig) Wrap() sdk.Tx { + return sdk.Tx{s} } -func (s *MultiSig) Next() basecoin.Tx { +func (s *MultiSig) Next() sdk.Tx { return s.Tx } func (s *MultiSig) ValidateBasic() error { diff --git a/modules/auth/tx_test.go b/modules/auth/tx_test.go index 03ef42c12447..4ec555d85397 100644 --- a/modules/auth/tx_test.go +++ b/modules/auth/tx_test.go @@ -12,13 +12,13 @@ import ( "github.com/tendermint/go-crypto/keys/storage/memstorage" wire "github.com/tendermint/go-wire" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" ) func checkSignBytes(t *testing.T, bytes []byte, expected string) { // load it back... unwrap the tx - var preTx basecoin.Tx + var preTx sdk.Tx err := wire.ReadBinaryBytes(bytes, &preTx) require.Nil(t, err) diff --git a/modules/base/chain.go b/modules/base/chain.go index b2fa845c4891..61f919c0efe0 100644 --- a/modules/base/chain.go +++ b/modules/base/chain.go @@ -1,9 +1,9 @@ package base import ( - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) //nolint @@ -25,7 +25,7 @@ func (Chain) Name() string { var _ stack.Middleware = Chain{} // CheckTx makes sure we are on the proper chain - fulfills Middlware interface -func (c Chain) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) { +func (c Chain) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) { stx, err := c.checkChainTx(ctx.ChainID(), ctx.BlockHeight(), tx) if err != nil { return res, err @@ -34,7 +34,7 @@ func (c Chain) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.T } // DeliverTx makes sure we are on the proper chain - fulfills Middlware interface -func (c Chain) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (c Chain) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) { stx, err := c.checkChainTx(ctx.ChainID(), ctx.BlockHeight(), tx) if err != nil { return res, err @@ -44,7 +44,7 @@ func (c Chain) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin // checkChainTx makes sure the tx is a Chain Tx, it is on the proper chain, // and it has not expired. -func (c Chain) checkChainTx(chainID string, height uint64, tx basecoin.Tx) (basecoin.Tx, error) { +func (c Chain) checkChainTx(chainID string, height uint64, tx sdk.Tx) (sdk.Tx, error) { // make sure it is a chaintx ctx, ok := tx.Unwrap().(ChainTx) if !ok { diff --git a/modules/base/chain_test.go b/modules/base/chain_test.go index 4f039892cc10..4ce1a53a72a2 100644 --- a/modules/base/chain_test.go +++ b/modules/base/chain_test.go @@ -8,9 +8,9 @@ import ( "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) func TestChainValidate(t *testing.T) { @@ -39,7 +39,7 @@ func TestChainValidate(t *testing.T) { } } - empty := NewChainTx("okay", 0, basecoin.Tx{}) + empty := NewChainTx("okay", 0, sdk.Tx{}) err := empty.ValidateBasic() assert.NotNil(err) } @@ -52,7 +52,7 @@ func TestChain(t *testing.T) { raw := stack.NewRawTx([]byte{1, 2, 3, 4}) cases := []struct { - tx basecoin.Tx + tx sdk.Tx valid bool errorMsg string }{ diff --git a/modules/base/commands/wrap.go b/modules/base/commands/wrap.go index 92e994fd068b..b9be03779f94 100644 --- a/modules/base/commands/wrap.go +++ b/modules/base/commands/wrap.go @@ -6,10 +6,10 @@ import ( "github.com/spf13/pflag" "github.com/spf13/viper" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/client/commands" - txcmd "github.com/tendermint/basecoin/client/commands/txs" - "github.com/tendermint/basecoin/modules/base" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/client/commands" + txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs" + "github.com/cosmos/cosmos-sdk/modules/base" ) //nolint @@ -23,7 +23,7 @@ type ChainWrapper struct{} var _ txcmd.Wrapper = ChainWrapper{} // Wrap will wrap the tx with a ChainTx from the standard flags -func (ChainWrapper) Wrap(tx basecoin.Tx) (res basecoin.Tx, err error) { +func (ChainWrapper) Wrap(tx sdk.Tx) (res sdk.Tx, err error) { expires := viper.GetInt64(FlagExpires) chain := commands.GetChainID() if chain == "" { diff --git a/modules/base/errors.go b/modules/base/errors.go index 8279bc434135..4ebf626b8f9c 100644 --- a/modules/base/errors.go +++ b/modules/base/errors.go @@ -6,7 +6,7 @@ import ( abci "github.com/tendermint/abci/types" - "github.com/tendermint/basecoin/errors" + "github.com/cosmos/cosmos-sdk/errors" ) var ( diff --git a/modules/base/errors_test.go b/modules/base/errors_test.go index 64fda60f8470..0354cd8c8ac5 100644 --- a/modules/base/errors_test.go +++ b/modules/base/errors_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/tendermint/basecoin/errors" + "github.com/cosmos/cosmos-sdk/errors" ) func TestErrorMatches(t *testing.T) { diff --git a/modules/base/helpers.go b/modules/base/helpers.go index e99d5af7e520..4958a8bfbbe4 100644 --- a/modules/base/helpers.go +++ b/modules/base/helpers.go @@ -3,9 +3,9 @@ package base import ( abci "github.com/tendermint/abci/types" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/state" ) //nolint @@ -21,7 +21,7 @@ const ( ) func init() { - basecoin.TxMapper. + sdk.TxMapper. RegisterImplementation(ValChangeTx{}, TypeValChange, ByteValChange). RegisterImplementation(PriceShowTx{}, TypePriceShow, BytePriceShow) } @@ -30,19 +30,19 @@ func init() { // Setup tx and handler for validation test cases type ValSetHandler struct { - basecoin.NopCheck - basecoin.NopInitState - basecoin.NopInitValidate + sdk.NopCheck + sdk.NopInitState + sdk.NopInitValidate } -var _ basecoin.Handler = ValSetHandler{} +var _ sdk.Handler = ValSetHandler{} func (ValSetHandler) Name() string { return NameVal } -func (ValSetHandler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx) (res basecoin.DeliverResult, err error) { +func (ValSetHandler) DeliverTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx) (res sdk.DeliverResult, err error) { change, ok := tx.Unwrap().(ValChangeTx) if !ok { return res, errors.ErrUnknownTxType(tx) @@ -55,8 +55,8 @@ type ValChangeTx struct { Diff []*abci.Validator } -func (v ValChangeTx) Wrap() basecoin.Tx { - return basecoin.Tx{v} +func (v ValChangeTx) Wrap() sdk.Tx { + return sdk.Tx{v} } func (v ValChangeTx) ValidateBasic() error { return nil } @@ -69,18 +69,18 @@ var PriceData = []byte{0xCA, 0xFE} // PriceHandler returns checktx results based on the input type PriceHandler struct { - basecoin.NopInitState - basecoin.NopInitValidate + sdk.NopInitState + sdk.NopInitValidate } -var _ basecoin.Handler = PriceHandler{} +var _ sdk.Handler = PriceHandler{} func (PriceHandler) Name() string { return NamePrice } -func (PriceHandler) CheckTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx) (res basecoin.CheckResult, err error) { +func (PriceHandler) CheckTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx) (res sdk.CheckResult, err error) { price, ok := tx.Unwrap().(PriceShowTx) if !ok { return res, errors.ErrUnknownTxType(tx) @@ -91,8 +91,8 @@ func (PriceHandler) CheckTx(ctx basecoin.Context, store state.SimpleDB, return } -func (PriceHandler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx) (res basecoin.DeliverResult, err error) { +func (PriceHandler) DeliverTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx) (res sdk.DeliverResult, err error) { _, ok := tx.Unwrap().(PriceShowTx) if !ok { return res, errors.ErrUnknownTxType(tx) @@ -107,12 +107,12 @@ type PriceShowTx struct { GasPayment uint64 } -func NewPriceShowTx(gasAllocated, gasPayment uint64) basecoin.Tx { +func NewPriceShowTx(gasAllocated, gasPayment uint64) sdk.Tx { return PriceShowTx{GasAllocated: gasAllocated, GasPayment: gasPayment}.Wrap() } -func (p PriceShowTx) Wrap() basecoin.Tx { - return basecoin.Tx{p} +func (p PriceShowTx) Wrap() sdk.Tx { + return sdk.Tx{p} } func (v PriceShowTx) ValidateBasic() error { return nil } diff --git a/modules/base/logger.go b/modules/base/logger.go index 4d8d29135206..ab15c01f61c9 100644 --- a/modules/base/logger.go +++ b/modules/base/logger.go @@ -6,9 +6,9 @@ import ( abci "github.com/tendermint/abci/types" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) // nolint @@ -27,7 +27,7 @@ func (Logger) Name() string { var _ stack.Middleware = Logger{} // CheckTx logs time and result - fulfills Middlware interface -func (Logger) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) { +func (Logger) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) { start := time.Now() res, err = next.CheckTx(ctx, store, tx) delta := time.Now().Sub(start) @@ -42,7 +42,7 @@ func (Logger) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx } // DeliverTx logs time and result - fulfills Middlware interface -func (Logger) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (Logger) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) { start := time.Now() res, err = next.DeliverTx(ctx, store, tx) delta := time.Now().Sub(start) @@ -57,7 +57,7 @@ func (Logger) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin. } // InitState logs time and result - fulfills Middlware interface -func (Logger) InitState(l log.Logger, store state.SimpleDB, module, key, value string, next basecoin.InitStater) (string, error) { +func (Logger) InitState(l log.Logger, store state.SimpleDB, module, key, value string, next sdk.InitStater) (string, error) { start := time.Now() res, err := next.InitState(l, store, module, key, value) delta := time.Now().Sub(start) @@ -72,7 +72,7 @@ func (Logger) InitState(l log.Logger, store state.SimpleDB, module, key, value s } // InitValidate logs time and result - fulfills Middlware interface -func (Logger) InitValidate(l log.Logger, store state.SimpleDB, vals []*abci.Validator, next basecoin.InitValidater) { +func (Logger) InitValidate(l log.Logger, store state.SimpleDB, vals []*abci.Validator, next sdk.InitValidater) { start := time.Now() next.InitValidate(l, store, vals) delta := time.Now().Sub(start) diff --git a/modules/base/multiplexer.go b/modules/base/multiplexer.go index 38008376cf9d..d899a76ebe06 100644 --- a/modules/base/multiplexer.go +++ b/modules/base/multiplexer.go @@ -7,9 +7,9 @@ import ( wire "github.com/tendermint/go-wire" "github.com/tendermint/go-wire/data" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) //nolint @@ -31,7 +31,7 @@ func (Multiplexer) Name() string { var _ stack.Middleware = Multiplexer{} // CheckTx splits the input tx and checks them all - fulfills Middlware interface -func (Multiplexer) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) { +func (Multiplexer) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) { if mtx, ok := tx.Unwrap().(MultiTx); ok { return runAllChecks(ctx, store, mtx.Txs, next) } @@ -39,16 +39,16 @@ func (Multiplexer) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx baseco } // DeliverTx splits the input tx and checks them all - fulfills Middlware interface -func (Multiplexer) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (Multiplexer) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) { if mtx, ok := tx.Unwrap().(MultiTx); ok { return runAllDelivers(ctx, store, mtx.Txs, next) } return next.DeliverTx(ctx, store, tx) } -func runAllChecks(ctx basecoin.Context, store state.SimpleDB, txs []basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) { +func runAllChecks(ctx sdk.Context, store state.SimpleDB, txs []sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) { // store all results, unless anything errors - rs := make([]basecoin.CheckResult, len(txs)) + rs := make([]sdk.CheckResult, len(txs)) for i, stx := range txs { rs[i], err = next.CheckTx(ctx, store, stx) if err != nil { @@ -59,9 +59,9 @@ func runAllChecks(ctx basecoin.Context, store state.SimpleDB, txs []basecoin.Tx, return combineChecks(rs), nil } -func runAllDelivers(ctx basecoin.Context, store state.SimpleDB, txs []basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func runAllDelivers(ctx sdk.Context, store state.SimpleDB, txs []sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) { // store all results, unless anything errors - rs := make([]basecoin.DeliverResult, len(txs)) + rs := make([]sdk.DeliverResult, len(txs)) for i, stx := range txs { rs[i], err = next.DeliverTx(ctx, store, stx) if err != nil { @@ -74,7 +74,7 @@ func runAllDelivers(ctx basecoin.Context, store state.SimpleDB, txs []basecoin.T // combines all data bytes as a go-wire array. // joins all log messages with \n -func combineChecks(all []basecoin.CheckResult) basecoin.CheckResult { +func combineChecks(all []sdk.CheckResult) sdk.CheckResult { datas := make([]data.Bytes, len(all)) logs := make([]string, len(all)) var allocated, payments uint64 @@ -84,7 +84,7 @@ func combineChecks(all []basecoin.CheckResult) basecoin.CheckResult { allocated += r.GasAllocated payments += r.GasPayment } - return basecoin.CheckResult{ + return sdk.CheckResult{ Data: wire.BinaryBytes(datas), Log: strings.Join(logs, "\n"), GasAllocated: allocated, @@ -94,7 +94,7 @@ func combineChecks(all []basecoin.CheckResult) basecoin.CheckResult { // combines all data bytes as a go-wire array. // joins all log messages with \n -func combineDelivers(all []basecoin.DeliverResult) basecoin.DeliverResult { +func combineDelivers(all []sdk.DeliverResult) sdk.DeliverResult { datas := make([]data.Bytes, len(all)) logs := make([]string, len(all)) var used uint64 @@ -107,7 +107,7 @@ func combineDelivers(all []basecoin.DeliverResult) basecoin.DeliverResult { diffs = append(diffs, r.Diff...) } } - return basecoin.DeliverResult{ + return sdk.DeliverResult{ Data: wire.BinaryBytes(datas), Log: strings.Join(logs, "\n"), GasUsed: used, diff --git a/modules/base/multiplexer_test.go b/modules/base/multiplexer_test.go index 1378d8dbd62c..97d5324ee64d 100644 --- a/modules/base/multiplexer_test.go +++ b/modules/base/multiplexer_test.go @@ -4,9 +4,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" wire "github.com/tendermint/go-wire" "github.com/tendermint/go-wire/data" "github.com/tendermint/tmlibs/log" @@ -41,7 +41,7 @@ func TestMultiplexer(t *testing.T) { } cases := [...]struct { - tx basecoin.Tx + tx sdk.Tx valid bool gasAllocated uint64 gasPayment uint64 diff --git a/modules/base/tx.go b/modules/base/tx.go index d365c1b7b8a5..edd57b672147 100644 --- a/modules/base/tx.go +++ b/modules/base/tx.go @@ -3,8 +3,8 @@ package base import ( "regexp" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" ) // nolint @@ -21,7 +21,7 @@ const ( ) func init() { - basecoin.TxMapper. + sdk.TxMapper. RegisterImplementation(MultiTx{}, TypeMultiTx, ByteMultiTx). RegisterImplementation(ChainTx{}, TypeChainTx, ByteChainTx) } @@ -30,17 +30,17 @@ func init() { // MultiTx - a transaction containing multiple transactions type MultiTx struct { - Txs []basecoin.Tx `json:"txs"` + Txs []sdk.Tx `json:"txs"` } -var _ basecoin.TxInner = &MultiTx{} +var _ sdk.TxInner = &MultiTx{} //nolint - TxInner Functions -func NewMultiTx(txs ...basecoin.Tx) basecoin.Tx { +func NewMultiTx(txs ...sdk.Tx) sdk.Tx { return (MultiTx{Txs: txs}).Wrap() } -func (mt MultiTx) Wrap() basecoin.Tx { - return basecoin.Tx{mt} +func (mt MultiTx) Wrap() sdk.Tx { + return sdk.Tx{mt} } func (mt MultiTx) ValidateBasic() error { for _, t := range mt.Txs { @@ -60,10 +60,10 @@ type ChainTx struct { ChainID string `json:"chain_id"` // block height at which it is no longer valid, 0 means no expiration ExpiresAt uint64 `json:"expires_at"` - Tx basecoin.Tx `json:"tx"` + Tx sdk.Tx `json:"tx"` } -var _ basecoin.TxInner = &ChainTx{} +var _ sdk.TxInner = &ChainTx{} var ( chainPattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") @@ -71,7 +71,7 @@ var ( // NewChainTx wraps a particular tx with the ChainTx wrapper, // to enforce chain and height -func NewChainTx(chainID string, expires uint64, tx basecoin.Tx) basecoin.Tx { +func NewChainTx(chainID string, expires uint64, tx sdk.Tx) sdk.Tx { c := ChainTx{ ChainID: chainID, ExpiresAt: expires, @@ -81,8 +81,8 @@ func NewChainTx(chainID string, expires uint64, tx basecoin.Tx) basecoin.Tx { } //nolint - TxInner Functions -func (c ChainTx) Wrap() basecoin.Tx { - return basecoin.Tx{c} +func (c ChainTx) Wrap() sdk.Tx { + return sdk.Tx{c} } func (c ChainTx) ValidateBasic() error { if c.ChainID == "" { diff --git a/modules/base/tx_test.go b/modules/base/tx_test.go index e2ad3e2190a1..82f0ffad7fe8 100644 --- a/modules/base/tx_test.go +++ b/modules/base/tx_test.go @@ -9,8 +9,8 @@ import ( "github.com/tendermint/go-wire/data" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" ) func TestEncoding(t *testing.T) { @@ -21,7 +21,7 @@ func TestEncoding(t *testing.T) { // raw2 := stack.NewRawTx([]byte{0x73, 0x86, 0x22}) cases := []struct { - Tx basecoin.Tx + Tx sdk.Tx }{ {raw}, // {NewMultiTx(raw, raw2)}, @@ -35,7 +35,7 @@ func TestEncoding(t *testing.T) { // test json in and out js, err := data.ToJSON(tx) require.Nil(err, i) - var jtx basecoin.Tx + var jtx sdk.Tx err = data.FromJSON(js, &jtx) require.Nil(err, i) assert.Equal(tx, jtx, i) @@ -43,7 +43,7 @@ func TestEncoding(t *testing.T) { // test wire in and out bin, err := data.ToWire(tx) require.Nil(err, i) - var wtx basecoin.Tx + var wtx sdk.Tx err = data.FromWire(bin, &wtx) require.Nil(err, i) assert.Equal(tx, wtx, i) diff --git a/modules/coin/bench_test.go b/modules/coin/bench_test.go index cfa7b708b8e7..4fc5b8e8fd61 100644 --- a/modules/coin/bench_test.go +++ b/modules/coin/bench_test.go @@ -6,16 +6,16 @@ import ( cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) func makeHandler() stack.Dispatchable { return NewHandler() } -func makeSimpleTx(from, to basecoin.Actor, amount Coins) basecoin.Tx { +func makeSimpleTx(from, to sdk.Actor, amount Coins) sdk.Tx { in := []TxInput{{Address: from, Coins: amount}} out := []TxOutput{{Address: to, Coins: amount}} return NewSendTx(in, out) @@ -30,7 +30,7 @@ func BenchmarkSimpleTransfer(b *testing.B) { acct := NewAccountWithKey(Coins{{"mycoin", 1234567890}}) h.InitState(logger, store, NameCoin, "account", acct.MakeOption(), nil) sender := acct.Actor() - receiver := basecoin.Actor{App: "foo", Address: cmn.RandBytes(20)} + receiver := sdk.Actor{App: "foo", Address: cmn.RandBytes(20)} // now, loop... for i := 1; i <= b.N; i++ { diff --git a/modules/coin/commands/query.go b/modules/coin/commands/query.go index dea196529470..ca0cced01352 100644 --- a/modules/coin/commands/query.go +++ b/modules/coin/commands/query.go @@ -7,10 +7,10 @@ import ( lc "github.com/tendermint/light-client" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/client/commands/query" - "github.com/tendermint/basecoin/modules/coin" - "github.com/tendermint/basecoin/stack" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands/query" + "github.com/cosmos/cosmos-sdk/modules/coin" + "github.com/cosmos/cosmos-sdk/stack" ) // AccountQueryCmd - command to query an account diff --git a/modules/coin/commands/tx.go b/modules/coin/commands/tx.go index aa23fab82b1c..6459f602e41a 100644 --- a/modules/coin/commands/tx.go +++ b/modules/coin/commands/tx.go @@ -4,10 +4,10 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/client/commands" - txcmd "github.com/tendermint/basecoin/client/commands/txs" - "github.com/tendermint/basecoin/modules/coin" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/client/commands" + txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs" + "github.com/cosmos/cosmos-sdk/modules/coin" ) // SendTxCmd is CLI command to send tokens between basecoin accounts @@ -50,7 +50,7 @@ func sendTxCmd(cmd *cobra.Command, args []string) error { return txcmd.DoTx(tx) } -func readSendTxFlags() (tx basecoin.Tx, err error) { +func readSendTxFlags() (tx sdk.Tx, err error) { // parse to address toAddr, err := commands.ParseActor(viper.GetString(FlagTo)) if err != nil { @@ -80,7 +80,7 @@ func creditTxCmd(cmd *cobra.Command, args []string) error { return txcmd.DoTx(tx) } -func readCreditTxFlags() (tx basecoin.Tx, err error) { +func readCreditTxFlags() (tx sdk.Tx, err error) { // parse to address toAddr, err := commands.ParseActor(viper.GetString(FlagTo)) if err != nil { @@ -96,7 +96,7 @@ func readCreditTxFlags() (tx basecoin.Tx, err error) { return } -func readFromAddr() (basecoin.Actor, error) { +func readFromAddr() (sdk.Actor, error) { from := viper.GetString(FlagFrom) if from == "" { return txcmd.GetSignerAct(), nil diff --git a/modules/coin/errors.go b/modules/coin/errors.go index 39c334e8b212..caf7d4c9b975 100644 --- a/modules/coin/errors.go +++ b/modules/coin/errors.go @@ -6,7 +6,7 @@ import ( abci "github.com/tendermint/abci/types" - "github.com/tendermint/basecoin/errors" + "github.com/cosmos/cosmos-sdk/errors" ) var ( diff --git a/modules/coin/handler.go b/modules/coin/handler.go index c083ab7a38de..da98d97dc141 100644 --- a/modules/coin/handler.go +++ b/modules/coin/handler.go @@ -4,12 +4,12 @@ import ( "github.com/tendermint/go-wire/data" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/modules/auth" - "github.com/tendermint/basecoin/modules/ibc" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/modules/auth" + "github.com/cosmos/cosmos-sdk/modules/ibc" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) const ( @@ -42,8 +42,8 @@ func (Handler) Name() string { func (Handler) AssertDispatcher() {} // CheckTx checks if there is enough money in the account -func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx, _ basecoin.Checker) (res basecoin.CheckResult, err error) { +func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx, _ sdk.Checker) (res sdk.CheckResult, err error) { err = tx.ValidateBasic() if err != nil { @@ -54,17 +54,17 @@ func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, case SendTx: // price based on inputs and outputs used := uint64(len(t.Inputs) + len(t.Outputs)) - return basecoin.NewCheck(used*CostSend, ""), h.checkSendTx(ctx, store, t) + return sdk.NewCheck(used*CostSend, ""), h.checkSendTx(ctx, store, t) case CreditTx: // default price of 20, constant work - return basecoin.NewCheck(CostCredit, ""), h.creditTx(ctx, store, t) + return sdk.NewCheck(CostCredit, ""), h.creditTx(ctx, store, t) } return res, errors.ErrUnknownTxType(tx.Unwrap()) } // DeliverTx moves the money -func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx, cb basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx, cb sdk.Deliver) (res sdk.DeliverResult, err error) { err = tx.ValidateBasic() if err != nil { @@ -82,7 +82,7 @@ func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, // InitState - sets the genesis account balance func (h Handler) InitState(l log.Logger, store state.SimpleDB, - module, key, value string, cb basecoin.InitStater) (log string, err error) { + module, key, value string, cb sdk.InitStater) (log string, err error) { if module != NameCoin { return "", errors.ErrUnknownModule(module) } @@ -95,8 +95,8 @@ func (h Handler) InitState(l log.Logger, store state.SimpleDB, return "", errors.ErrUnknownKey(key) } -func (h Handler) sendTx(ctx basecoin.Context, store state.SimpleDB, - send SendTx, cb basecoin.Deliver) error { +func (h Handler) sendTx(ctx sdk.Context, store state.SimpleDB, + send SendTx, cb sdk.Deliver) error { err := checkTx(ctx, send) if err != nil { @@ -104,7 +104,7 @@ func (h Handler) sendTx(ctx basecoin.Context, store state.SimpleDB, } // deduct from all input accounts - senders := basecoin.Actors{} + senders := sdk.Actors{} for _, in := range send.Inputs { _, err = ChangeCoins(store, in.Address, in.Coins.Negative()) if err != nil { @@ -153,7 +153,7 @@ func (h Handler) sendTx(ctx basecoin.Context, store state.SimpleDB, return nil } -func (h Handler) creditTx(ctx basecoin.Context, store state.SimpleDB, +func (h Handler) creditTx(ctx sdk.Context, store state.SimpleDB, credit CreditTx) error { // first check permissions!! @@ -186,7 +186,7 @@ func (h Handler) creditTx(ctx basecoin.Context, store state.SimpleDB, return err } -func checkTx(ctx basecoin.Context, send SendTx) error { +func checkTx(ctx sdk.Context, send SendTx) error { // check if all inputs have permission for _, in := range send.Inputs { if !ctx.HasPermission(in.Address) { @@ -196,7 +196,7 @@ func checkTx(ctx basecoin.Context, send SendTx) error { return nil } -func (Handler) checkSendTx(ctx basecoin.Context, store state.SimpleDB, send SendTx) error { +func (Handler) checkSendTx(ctx sdk.Context, store state.SimpleDB, send SendTx) error { err := checkTx(ctx, send) if err != nil { return err @@ -234,7 +234,7 @@ func setAccount(store state.SimpleDB, value string) (log string, err error) { // setIssuer sets a permission for some super-powerful account to // mint money func setIssuer(store state.SimpleDB, value string) (log string, err error) { - var issuer basecoin.Actor + var issuer sdk.Actor err = data.FromJSON([]byte(value), &issuer) if err != nil { return "", err diff --git a/modules/coin/handler_test.go b/modules/coin/handler_test.go index 4c6a4b784452..3df51d8e56b0 100644 --- a/modules/coin/handler_test.go +++ b/modules/coin/handler_test.go @@ -10,11 +10,11 @@ import ( crypto "github.com/tendermint/go-crypto" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/modules/auth" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/modules/auth" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) // this makes sure that txs are rejected with invalid data or permissions @@ -22,56 +22,56 @@ func TestHandlerValidation(t *testing.T) { assert := assert.New(t) // these are all valid, except for minusCoins - addr1 := basecoin.Actor{App: "coin", Address: []byte{1, 2}} - addr2 := basecoin.Actor{App: "role", Address: []byte{7, 8}} + addr1 := sdk.Actor{App: "coin", Address: []byte{1, 2}} + addr2 := sdk.Actor{App: "role", Address: []byte{7, 8}} someCoins := Coins{{"atom", 123}} doubleCoins := Coins{{"atom", 246}} minusCoins := Coins{{"eth", -34}} cases := []struct { valid bool - tx basecoin.Tx - perms []basecoin.Actor + tx sdk.Tx + perms []sdk.Actor }{ // auth works with different apps {true, NewSendTx( []TxInput{NewTxInput(addr1, someCoins)}, []TxOutput{NewTxOutput(addr2, someCoins)}), - []basecoin.Actor{addr1}}, + []sdk.Actor{addr1}}, {true, NewSendTx( []TxInput{NewTxInput(addr2, someCoins)}, []TxOutput{NewTxOutput(addr1, someCoins)}), - []basecoin.Actor{addr1, addr2}}, + []sdk.Actor{addr1, addr2}}, // check multi-input with both sigs {true, NewSendTx( []TxInput{NewTxInput(addr1, someCoins), NewTxInput(addr2, someCoins)}, []TxOutput{NewTxOutput(addr1, doubleCoins)}), - []basecoin.Actor{addr1, addr2}}, + []sdk.Actor{addr1, addr2}}, // wrong permissions fail {false, NewSendTx( []TxInput{NewTxInput(addr1, someCoins)}, []TxOutput{NewTxOutput(addr2, someCoins)}), - []basecoin.Actor{}}, + []sdk.Actor{}}, {false, NewSendTx( []TxInput{NewTxInput(addr1, someCoins)}, []TxOutput{NewTxOutput(addr2, someCoins)}), - []basecoin.Actor{addr2}}, + []sdk.Actor{addr2}}, {false, NewSendTx( []TxInput{NewTxInput(addr1, someCoins), NewTxInput(addr2, someCoins)}, []TxOutput{NewTxOutput(addr1, doubleCoins)}), - []basecoin.Actor{addr1}}, + []sdk.Actor{addr1}}, // invalid input fails {false, NewSendTx( []TxInput{NewTxInput(addr1, minusCoins)}, []TxOutput{NewTxOutput(addr2, minusCoins)}), - []basecoin.Actor{addr2}}, + []sdk.Actor{addr2}}, } for i, tc := range cases { @@ -90,9 +90,9 @@ func TestCheckDeliverSendTx(t *testing.T) { require := require.New(t) // some sample settings - addr1 := basecoin.Actor{App: "coin", Address: []byte{1, 2}} - addr2 := basecoin.Actor{App: "role", Address: []byte{7, 8}} - addr3 := basecoin.Actor{App: "coin", Address: []byte{6, 5, 4, 3}} + addr1 := sdk.Actor{App: "coin", Address: []byte{1, 2}} + addr2 := sdk.Actor{App: "role", Address: []byte{7, 8}} + addr3 := sdk.Actor{App: "coin", Address: []byte{6, 5, 4, 3}} someCoins := Coins{{"atom", 123}} moreCoins := Coins{{"atom", 6487}} @@ -101,14 +101,14 @@ func TestCheckDeliverSendTx(t *testing.T) { mixedCoins := someCoins.Plus(otherCoins) type money struct { - addr basecoin.Actor + addr sdk.Actor coins Coins } cases := []struct { init []money - tx basecoin.Tx - perms []basecoin.Actor + tx sdk.Tx + perms []sdk.Actor final []money // nil for error cost uint64 // gas allocated (if not error) }{ @@ -117,7 +117,7 @@ func TestCheckDeliverSendTx(t *testing.T) { NewSendTx( []TxInput{NewTxInput(addr1, someCoins)}, []TxOutput{NewTxOutput(addr2, someCoins)}), - []basecoin.Actor{addr1}, + []sdk.Actor{addr1}, []money{{addr1, diffCoins}, {addr2, someCoins}}, 20, }, @@ -127,7 +127,7 @@ func TestCheckDeliverSendTx(t *testing.T) { NewSendTx( []TxInput{NewTxInput(addr1, otherCoins), NewTxInput(addr2, someCoins)}, []TxOutput{NewTxOutput(addr3, mixedCoins)}), - []basecoin.Actor{addr1, addr2}, + []sdk.Actor{addr1, addr2}, []money{{addr1, someCoins}, {addr2, diffCoins}, {addr3, mixedCoins}}, 30, }, @@ -137,7 +137,7 @@ func TestCheckDeliverSendTx(t *testing.T) { NewSendTx( []TxInput{NewTxInput(addr1, otherCoins), NewTxInput(addr1, someCoins)}, []TxOutput{NewTxOutput(addr2, mixedCoins)}), - []basecoin.Actor{addr1}, + []sdk.Actor{addr1}, []money{{addr1, diffCoins}, {addr2, mixedCoins}}, 30, }, @@ -147,7 +147,7 @@ func TestCheckDeliverSendTx(t *testing.T) { NewSendTx( []TxInput{NewTxInput(addr2, moreCoins)}, []TxOutput{NewTxOutput(addr1, moreCoins)}), - []basecoin.Actor{addr1, addr2}, + []sdk.Actor{addr1, addr2}, nil, 0, }, @@ -206,7 +206,7 @@ func TestInitState(t *testing.T) { mixedCoins := someCoins.Plus(otherCoins) type money struct { - addr basecoin.Actor + addr sdk.Actor coins Coins } @@ -248,12 +248,12 @@ func TestSetIssuer(t *testing.T) { require := require.New(t) cases := []struct { - issuer basecoin.Actor + issuer sdk.Actor }{ - {basecoin.Actor{App: "sig", Address: []byte("gwkfgk")}}, + {sdk.Actor{App: "sig", Address: []byte("gwkfgk")}}, // and set back to empty (nil is valid, but assert.Equals doesn't match) - {basecoin.Actor{Address: []byte{}}}, - {basecoin.Actor{ChainID: "other", App: "role", Address: []byte("vote")}}, + {sdk.Actor{Address: []byte{}}}, + {sdk.Actor{ChainID: "other", App: "role", Address: []byte("vote")}}, } h := NewHandler() @@ -286,11 +286,11 @@ func TestDeliverCreditTx(t *testing.T) { mixedCoins := someCoins.Plus(otherCoins) // some sample addresses - owner := basecoin.Actor{App: "foo", Address: []byte("rocks")} - addr1 := basecoin.Actor{App: "coin", Address: []byte{1, 2}} + owner := sdk.Actor{App: "foo", Address: []byte("rocks")} + addr1 := sdk.Actor{App: "coin", Address: []byte{1, 2}} key := NewAccountWithKey(someCoins) addr2 := key.Actor() - addr3 := basecoin.Actor{ChainID: "other", App: "sigs", Address: []byte{3, 9}} + addr3 := sdk.Actor{ChainID: "other", App: "sigs", Address: []byte{3, 9}} h := NewHandler() store := state.NewMemKVStore() @@ -307,10 +307,10 @@ func TestDeliverCreditTx(t *testing.T) { require.Nil(err, "%+v", err) cases := []struct { - tx basecoin.Tx - perm basecoin.Actor + tx sdk.Tx + perm sdk.Actor check errors.CheckErr - addr basecoin.Actor + addr sdk.Actor expected Account }{ // require permission diff --git a/modules/coin/helper.go b/modules/coin/helper.go index c4af2f080ea7..a885c78b05c7 100644 --- a/modules/coin/helper.go +++ b/modules/coin/helper.go @@ -4,8 +4,8 @@ import ( crypto "github.com/tendermint/go-crypto" "github.com/tendermint/go-wire/data" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/modules/auth" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/modules/auth" ) // AccountWithKey is a helper for tests, that includes and account @@ -31,7 +31,7 @@ func (a *AccountWithKey) Address() []byte { } // Actor returns the basecoin actor associated with this account -func (a *AccountWithKey) Actor() basecoin.Actor { +func (a *AccountWithKey) Actor() sdk.Actor { return auth.SigPerm(a.Key.PubKey().Address()) } diff --git a/modules/coin/ibc_test.go b/modules/coin/ibc_test.go index 81aeb83655c3..a51b5359d893 100644 --- a/modules/coin/ibc_test.go +++ b/modules/coin/ibc_test.go @@ -5,12 +5,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/modules/auth" - "github.com/tendermint/basecoin/modules/ibc" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/modules/auth" + "github.com/cosmos/cosmos-sdk/modules/ibc" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" wire "github.com/tendermint/go-wire" ) @@ -48,7 +48,7 @@ func TestIBCPostPacket(t *testing.T) { require.Nil(err, "%+v", err) // sends money to another guy on a different chain, now other chain has credit - buddy := basecoin.Actor{ChainID: otherID, App: auth.NameSigs, Address: []byte("dude")} + buddy := sdk.Actor{ChainID: otherID, App: auth.NameSigs, Address: []byte("dude")} outTx := NewSendOneTx(rich.Actor(), buddy, wealth) _, err = ourChain.DeliverTx(outTx, rich.Actor()) require.Nil(err, "%+v", err) @@ -64,8 +64,8 @@ func TestIBCPostPacket(t *testing.T) { assertPacket(t, istore, otherID, wealth) // these are the people for testing incoming ibc from the other chain - recipient := basecoin.Actor{ChainID: ourID, App: auth.NameSigs, Address: []byte("bar")} - sender := basecoin.Actor{ChainID: otherID, App: auth.NameSigs, Address: []byte("foo")} + recipient := sdk.Actor{ChainID: ourID, App: auth.NameSigs, Address: []byte("bar")} + sender := sdk.Actor{ChainID: otherID, App: auth.NameSigs, Address: []byte("foo")} payment := Coins{{"eth", 100}, {"ltc", 300}} coinTx := NewSendOneTx(sender, recipient, payment) wrongCoin := NewSendOneTx(sender, recipient, Coins{{"missing", 20}}) @@ -82,10 +82,10 @@ func TestIBCPostPacket(t *testing.T) { packet2, update2 := otherChain.MakePostPacket(p2, start+50) require.Nil(ourChain.Update(update2)) - ibcPerm := basecoin.Actors{ibc.AllowIBC(NameCoin)} + ibcPerm := sdk.Actors{ibc.AllowIBC(NameCoin)} cases := []struct { packet ibc.PostPacketTx - permissions basecoin.Actors + permissions sdk.Actors checker errors.CheckErr }{ // out of order -> error diff --git a/modules/coin/rest/handlers.go b/modules/coin/rest/handlers.go index 0b1c3d4de747..49250d5e2efd 100644 --- a/modules/coin/rest/handlers.go +++ b/modules/coin/rest/handlers.go @@ -8,15 +8,15 @@ import ( "github.com/gorilla/mux" "github.com/spf13/viper" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/client/commands/query" - "github.com/tendermint/basecoin/modules/auth" - "github.com/tendermint/basecoin/modules/base" - "github.com/tendermint/basecoin/modules/coin" - "github.com/tendermint/basecoin/modules/fee" - "github.com/tendermint/basecoin/modules/nonce" - "github.com/tendermint/basecoin/stack" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands/query" + "github.com/cosmos/cosmos-sdk/modules/auth" + "github.com/cosmos/cosmos-sdk/modules/base" + "github.com/cosmos/cosmos-sdk/modules/coin" + "github.com/cosmos/cosmos-sdk/modules/fee" + "github.com/cosmos/cosmos-sdk/modules/nonce" + "github.com/cosmos/cosmos-sdk/stack" lightclient "github.com/tendermint/light-client" "github.com/tendermint/tmlibs/common" ) @@ -30,8 +30,8 @@ type SendInput struct { Multi bool `json:"multi,omitempty"` Sequence uint32 `json:"sequence"` - To *basecoin.Actor `json:"to"` - From *basecoin.Actor `json:"from"` + To *sdk.Actor `json:"to"` + From *sdk.Actor `json:"from"` Amount coin.Coins `json:"amount"` } @@ -64,14 +64,14 @@ func doQueryAccount(w http.ResponseWriter, r *http.Request) { } } -func PrepareSendTx(si *SendInput) basecoin.Tx { +func PrepareSendTx(si *SendInput) sdk.Tx { tx := coin.NewSendOneTx(*si.From, *si.To, si.Amount) // fees are optional if si.Fees != nil && !si.Fees.IsZero() { tx = fee.NewFee(tx, *si.Fees, *si.From) } // only add the actual signer to the nonce - signers := []basecoin.Actor{*si.From} + signers := []sdk.Actor{*si.From} tx = nonce.NewTx(si.Sequence, signers, tx) tx = base.NewChainTx(commands.GetChainID(), 0, tx) diff --git a/modules/coin/store.go b/modules/coin/store.go index 58e0319610ac..7b0edbaad2fa 100644 --- a/modules/coin/store.go +++ b/modules/coin/store.go @@ -5,13 +5,13 @@ import ( wire "github.com/tendermint/go-wire" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/state" ) // GetAccount - Get account from store and address -func GetAccount(store state.SimpleDB, addr basecoin.Actor) (Account, error) { +func GetAccount(store state.SimpleDB, addr sdk.Actor) (Account, error) { // if the actor is another chain, we use one address for the chain.... addr = ChainAddr(addr) acct, err := loadAccount(store, addr.Bytes()) @@ -24,7 +24,7 @@ func GetAccount(store state.SimpleDB, addr basecoin.Actor) (Account, error) { } // CheckCoins makes sure there are funds, but doesn't change anything -func CheckCoins(store state.SimpleDB, addr basecoin.Actor, coins Coins) (Coins, error) { +func CheckCoins(store state.SimpleDB, addr sdk.Actor, coins Coins) (Coins, error) { // if the actor is another chain, we use one address for the chain.... addr = ChainAddr(addr) @@ -33,7 +33,7 @@ func CheckCoins(store state.SimpleDB, addr basecoin.Actor, coins Coins) (Coins, } // ChangeCoins changes the money, returns error if it would be negative -func ChangeCoins(store state.SimpleDB, addr basecoin.Actor, coins Coins) (Coins, error) { +func ChangeCoins(store state.SimpleDB, addr sdk.Actor, coins Coins) (Coins, error) { // if the actor is another chain, we use one address for the chain.... addr = ChainAddr(addr) @@ -50,7 +50,7 @@ func ChangeCoins(store state.SimpleDB, addr basecoin.Actor, coins Coins) (Coins, // keep an over-all balance // // TODO: is there a better way to do this? -func ChainAddr(addr basecoin.Actor) basecoin.Actor { +func ChainAddr(addr sdk.Actor) sdk.Actor { if addr.ChainID == "" { return addr } @@ -62,7 +62,7 @@ func ChainAddr(addr basecoin.Actor) basecoin.Actor { // updateCoins will load the account, make all checks, and return the updated account. // // it doesn't save anything, that is up to you to decide (Check/Change Coins) -func updateCoins(store state.SimpleDB, addr basecoin.Actor, coins Coins) (acct Account, err error) { +func updateCoins(store state.SimpleDB, addr sdk.Actor, coins Coins) (acct Account, err error) { acct, err = loadAccount(store, addr.Bytes()) // we can increase an empty account... if IsNoAccountErr(err) && coins.IsPositive() { @@ -114,7 +114,7 @@ func storeAccount(store state.SimpleDB, key []byte, acct Account) error { // HandlerInfo - this is global info on the coin handler type HandlerInfo struct { - Issuer basecoin.Actor `json:"issuer"` + Issuer sdk.Actor `json:"issuer"` } // TODO: where to store these special pieces?? @@ -133,7 +133,7 @@ func loadHandlerInfo(store state.KVStore) (info HandlerInfo, err error) { return info, nil } -func storeIssuer(store state.KVStore, issuer basecoin.Actor) error { +func storeIssuer(store state.KVStore, issuer sdk.Actor) error { info, err := loadHandlerInfo(store) if err != nil { return err diff --git a/modules/coin/tx.go b/modules/coin/tx.go index bc5f77e44d28..09a25abeefe8 100644 --- a/modules/coin/tx.go +++ b/modules/coin/tx.go @@ -3,11 +3,11 @@ package coin import ( "fmt" - "github.com/tendermint/basecoin" + sdk "github.com/cosmos/cosmos-sdk" ) func init() { - basecoin.TxMapper. + sdk.TxMapper. RegisterImplementation(SendTx{}, TypeSend, ByteSend). RegisterImplementation(CreditTx{}, TypeCredit, ByteCredit) } @@ -24,7 +24,7 @@ const ( // TxInput - expected coin movement outputs, used with SendTx type TxInput struct { - Address basecoin.Actor `json:"address"` + Address sdk.Actor `json:"address"` Coins Coins `json:"coins"` } @@ -51,7 +51,7 @@ func (txIn TxInput) String() string { } // NewTxInput - create a transaction input, used with SendTx -func NewTxInput(addr basecoin.Actor, coins Coins) TxInput { +func NewTxInput(addr sdk.Actor, coins Coins) TxInput { input := TxInput{ Address: addr, Coins: coins, @@ -63,7 +63,7 @@ func NewTxInput(addr basecoin.Actor, coins Coins) TxInput { // TxOutput - expected coin movement output, used with SendTx type TxOutput struct { - Address basecoin.Actor `json:"address"` + Address sdk.Actor `json:"address"` Coins Coins `json:"coins"` } @@ -90,7 +90,7 @@ func (txOut TxOutput) String() string { } // NewTxOutput - create a transaction output, used with SendTx -func NewTxOutput(addr basecoin.Actor, coins Coins) TxOutput { +func NewTxOutput(addr sdk.Actor, coins Coins) TxOutput { output := TxOutput{ Address: addr, Coins: coins, @@ -107,16 +107,16 @@ type SendTx struct { Outputs []TxOutput `json:"outputs"` } -var _ basecoin.Tx = NewSendTx(nil, nil) +var _ sdk.Tx = NewSendTx(nil, nil) // NewSendTx - construct arbitrary multi-in, multi-out sendtx -func NewSendTx(in []TxInput, out []TxOutput) basecoin.Tx { +func NewSendTx(in []TxInput, out []TxOutput) sdk.Tx { return SendTx{Inputs: in, Outputs: out}.Wrap() } // NewSendOneTx is a helper for the standard (?) case where there is exactly // one sender and one recipient -func NewSendOneTx(sender, recipient basecoin.Actor, amount Coins) basecoin.Tx { +func NewSendOneTx(sender, recipient sdk.Actor, amount Coins) sdk.Tx { in := []TxInput{{Address: sender, Coins: amount}} out := []TxOutput{{Address: recipient, Coins: amount}} return SendTx{Inputs: in, Outputs: out}.Wrap() @@ -158,8 +158,8 @@ func (tx SendTx) String() string { } // Wrap - used to satisfy TxInner -func (tx SendTx) Wrap() basecoin.Tx { - return basecoin.Tx{tx} +func (tx SendTx) Wrap() sdk.Tx { + return sdk.Tx{tx} } //----------------------------------------------------------------------------- @@ -167,7 +167,7 @@ func (tx SendTx) Wrap() basecoin.Tx { // CreditTx - this allows a special issuer to give an account credit // Satisfies: TxInner type CreditTx struct { - Debitor basecoin.Actor `json:"debitor"` + Debitor sdk.Actor `json:"debitor"` // Credit is the amount to change the credit... // This may be negative to remove some over-issued credit, // but can never bring the credit or the balance to negative @@ -175,13 +175,13 @@ type CreditTx struct { } // NewCreditTx - modify the credit granted to a given account -func NewCreditTx(debitor basecoin.Actor, credit Coins) basecoin.Tx { +func NewCreditTx(debitor sdk.Actor, credit Coins) sdk.Tx { return CreditTx{Debitor: debitor, Credit: credit}.Wrap() } // Wrap - used to satisfy TxInner -func (tx CreditTx) Wrap() basecoin.Tx { - return basecoin.Tx{tx} +func (tx CreditTx) Wrap() sdk.Tx { + return sdk.Tx{tx} } // ValidateBasic - used to satisfy TxInner diff --git a/modules/coin/tx_test.go b/modules/coin/tx_test.go index 1b292ae2891e..bff2f98da614 100644 --- a/modules/coin/tx_test.go +++ b/modules/coin/tx_test.go @@ -8,20 +8,20 @@ import ( "github.com/tendermint/go-wire/data" - "github.com/tendermint/basecoin" + sdk "github.com/cosmos/cosmos-sdk" ) // these are some constructs for the test cases var actors = []struct { - actor basecoin.Actor + actor sdk.Actor valid bool }{ - {basecoin.Actor{}, false}, - {basecoin.Actor{App: "fooz"}, false}, - {basecoin.Actor{Address: []byte{1, 2, 3, 4}}, false}, - {basecoin.Actor{App: "fooz", Address: []byte{1, 2, 3, 4}}, true}, - {basecoin.Actor{ChainID: "dings", App: "fooz", Address: []byte{1, 2, 3, 4}}, true}, - {basecoin.Actor{ChainID: "dat", App: "fooz"}, false}, + {sdk.Actor{}, false}, + {sdk.Actor{App: "fooz"}, false}, + {sdk.Actor{Address: []byte{1, 2, 3, 4}}, false}, + {sdk.Actor{App: "fooz", Address: []byte{1, 2, 3, 4}}, true}, + {sdk.Actor{ChainID: "dings", App: "fooz", Address: []byte{1, 2, 3, 4}}, true}, + {sdk.Actor{ChainID: "dat", App: "fooz"}, false}, } var ( @@ -78,10 +78,10 @@ func TestTxValidateOutput(t *testing.T) { func TestTxValidateTx(t *testing.T) { assert := assert.New(t) - addr1 := basecoin.Actor{App: "coin", Address: []byte{1, 2}} - addr2 := basecoin.Actor{App: "coin", Address: []byte{3, 4}, ChainID: "over-there"} - addr3 := basecoin.Actor{App: "role", Address: []byte{7, 8}} - noAddr := basecoin.Actor{} + addr1 := sdk.Actor{App: "coin", Address: []byte{1, 2}} + addr2 := sdk.Actor{App: "coin", Address: []byte{3, 4}, ChainID: "over-there"} + addr3 := sdk.Actor{App: "role", Address: []byte{7, 8}} + noAddr := sdk.Actor{} noCoins := Coins{} someCoins := Coins{{"atom", 123}} @@ -95,7 +95,7 @@ func TestTxValidateTx(t *testing.T) { // totals don't match cases := []struct { valid bool - tx basecoin.Tx + tx sdk.Tx }{ // 0-2. valid cases {true, NewSendTx( @@ -164,8 +164,8 @@ func TestTxSerializeTx(t *testing.T) { assert := assert.New(t) require := require.New(t) - addr1 := basecoin.Actor{App: "coin", Address: []byte{1, 2}} - addr2 := basecoin.Actor{App: "coin", Address: []byte{3, 4}} + addr1 := sdk.Actor{App: "coin", Address: []byte{1, 2}} + addr2 := sdk.Actor{App: "coin", Address: []byte{3, 4}} someCoins := Coins{{"atom", 123}} send := NewSendTx( @@ -175,14 +175,14 @@ func TestTxSerializeTx(t *testing.T) { js, err := data.ToJSON(send) require.Nil(err) - var tx basecoin.Tx + var tx sdk.Tx err = data.FromJSON(js, &tx) require.Nil(err) assert.Equal(send, tx) bin, err := data.ToWire(send) require.Nil(err) - var tx2 basecoin.Tx + var tx2 sdk.Tx err = data.FromWire(bin, &tx2) require.Nil(err) assert.Equal(send, tx2) diff --git a/modules/eyes/commands/query.go b/modules/eyes/commands/query.go index c6a45101a155..6e71e88c6bdc 100644 --- a/modules/eyes/commands/query.go +++ b/modules/eyes/commands/query.go @@ -8,10 +8,10 @@ import ( cmn "github.com/tendermint/tmlibs/common" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/client/commands/query" - "github.com/tendermint/basecoin/modules/eyes" - "github.com/tendermint/basecoin/stack" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands/query" + "github.com/cosmos/cosmos-sdk/modules/eyes" + "github.com/cosmos/cosmos-sdk/stack" ) // EyesQueryCmd - command to query raw data diff --git a/modules/eyes/commands/tx.go b/modules/eyes/commands/tx.go index 6c7c0368c73b..7db82f3fd1f4 100644 --- a/modules/eyes/commands/tx.go +++ b/modules/eyes/commands/tx.go @@ -3,9 +3,9 @@ package commands import ( "github.com/spf13/cobra" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/client/commands/txs" - "github.com/tendermint/basecoin/modules/eyes" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands/txs" + "github.com/cosmos/cosmos-sdk/modules/eyes" ) // SetTxCmd is CLI command to set data diff --git a/modules/eyes/errors.go b/modules/eyes/errors.go index 8b6c1a71f50e..ae7babc6ca07 100644 --- a/modules/eyes/errors.go +++ b/modules/eyes/errors.go @@ -5,7 +5,7 @@ import ( abci "github.com/tendermint/abci/types" - "github.com/tendermint/basecoin/errors" + "github.com/cosmos/cosmos-sdk/errors" ) var ( diff --git a/modules/eyes/handler.go b/modules/eyes/handler.go index eb759056a7da..478019b33dc6 100644 --- a/modules/eyes/handler.go +++ b/modules/eyes/handler.go @@ -1,9 +1,9 @@ package eyes import ( - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/state" wire "github.com/tendermint/go-wire" ) @@ -19,11 +19,11 @@ const ( // Handler allows us to set and remove data type Handler struct { - basecoin.NopInitState - basecoin.NopInitValidate + sdk.NopInitState + sdk.NopInitValidate } -var _ basecoin.Handler = Handler{} +var _ sdk.Handler = Handler{} // NewHandler makes a role handler to modify data func NewHandler() Handler { @@ -36,7 +36,7 @@ func (Handler) Name() string { } // CheckTx verifies if the transaction is properly formated -func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.CheckResult, err error) { +func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) { err = tx.ValidateBasic() if err != nil { return @@ -44,9 +44,9 @@ func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin switch tx.Unwrap().(type) { case SetTx: - res = basecoin.NewCheck(CostSet, "") + res = sdk.NewCheck(CostSet, "") case RemoveTx: - res = basecoin.NewCheck(CostRemove, "") + res = sdk.NewCheck(CostRemove, "") default: err = errors.ErrUnknownTxType(tx) } @@ -56,7 +56,7 @@ func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin // DeliverTx tries to create a new role. // // Returns an error if the role already exists -func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.DeliverResult, err error) { +func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error) { err = tx.ValidateBasic() if err != nil { return @@ -75,7 +75,7 @@ func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx baseco // doSetTx writes to the store, overwriting any previous value // note that an empty response in DeliverTx is OK with no log or data returned -func (h Handler) doSetTx(ctx basecoin.Context, store state.SimpleDB, tx SetTx) (res basecoin.DeliverResult, err error) { +func (h Handler) doSetTx(ctx sdk.Context, store state.SimpleDB, tx SetTx) (res sdk.DeliverResult, err error) { data := NewData(tx.Value, ctx.BlockHeight()) store.Set(tx.Key, wire.BinaryBytes(data)) return @@ -83,7 +83,7 @@ func (h Handler) doSetTx(ctx basecoin.Context, store state.SimpleDB, tx SetTx) ( // doRemoveTx deletes the value from the store and returns the last value // here we let res.Data to return the value over abci -func (h Handler) doRemoveTx(ctx basecoin.Context, store state.SimpleDB, tx RemoveTx) (res basecoin.DeliverResult, err error) { +func (h Handler) doRemoveTx(ctx sdk.Context, store state.SimpleDB, tx RemoveTx) (res sdk.DeliverResult, err error) { // we set res.Data so it gets returned to the client over the abci interface res.Data = store.Get(tx.Key) if len(res.Data) != 0 { diff --git a/modules/eyes/handler_test.go b/modules/eyes/handler_test.go index 0bf510fb699d..1e44ae438114 100644 --- a/modules/eyes/handler_test.go +++ b/modules/eyes/handler_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" wire "github.com/tendermint/go-wire" ) diff --git a/modules/eyes/tx.go b/modules/eyes/tx.go index 943742b28747..8fe25c2eabb7 100644 --- a/modules/eyes/tx.go +++ b/modules/eyes/tx.go @@ -1,7 +1,7 @@ package eyes import ( - "github.com/tendermint/basecoin" + sdk "github.com/cosmos/cosmos-sdk" "github.com/tendermint/go-wire/data" ) @@ -15,7 +15,7 @@ const ( ) func init() { - basecoin.TxMapper. + sdk.TxMapper. RegisterImplementation(SetTx{}, TypeSet, ByteSet). RegisterImplementation(RemoveTx{}, TypeRemove, ByteRemove) } @@ -26,13 +26,13 @@ type SetTx struct { Value data.Bytes `json:"value"` } -func NewSetTx(key, value []byte) basecoin.Tx { +func NewSetTx(key, value []byte) sdk.Tx { return SetTx{Key: key, Value: value}.Wrap() } // Wrap - fulfills TxInner interface -func (t SetTx) Wrap() basecoin.Tx { - return basecoin.Tx{t} +func (t SetTx) Wrap() sdk.Tx { + return sdk.Tx{t} } // ValidateBasic makes sure it is valid @@ -48,13 +48,13 @@ type RemoveTx struct { Key data.Bytes `json:"key"` } -func NewRemoveTx(key []byte) basecoin.Tx { +func NewRemoveTx(key []byte) sdk.Tx { return RemoveTx{Key: key}.Wrap() } // Wrap - fulfills TxInner interface -func (t RemoveTx) Wrap() basecoin.Tx { - return basecoin.Tx{t} +func (t RemoveTx) Wrap() sdk.Tx { + return sdk.Tx{t} } // ValidateBasic makes sure it is valid diff --git a/modules/fee/commands/wrap.go b/modules/fee/commands/wrap.go index 32fb98483043..50ac91eb2a07 100644 --- a/modules/fee/commands/wrap.go +++ b/modules/fee/commands/wrap.go @@ -4,11 +4,11 @@ import ( "github.com/spf13/pflag" "github.com/spf13/viper" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/client/commands" - txcmd "github.com/tendermint/basecoin/client/commands/txs" - "github.com/tendermint/basecoin/modules/coin" - "github.com/tendermint/basecoin/modules/fee" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/client/commands" + txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs" + "github.com/cosmos/cosmos-sdk/modules/coin" + "github.com/cosmos/cosmos-sdk/modules/fee" ) //nolint @@ -24,7 +24,7 @@ var _ txcmd.Wrapper = FeeWrapper{} // Wrap checks for FlagFee and if present wraps the tx with a // FeeTx of the given amount, paid by the signer -func (FeeWrapper) Wrap(tx basecoin.Tx) (res basecoin.Tx, err error) { +func (FeeWrapper) Wrap(tx sdk.Tx) (res sdk.Tx, err error) { //parse the fee and amounts into coin types toll, err := coin.ParseCoin(viper.GetString(FlagFee)) if err != nil { @@ -50,7 +50,7 @@ func (FeeWrapper) Register(fs *pflag.FlagSet) { fs.String(FlagPayer, "", "Account to pay fee if not current signer (for multisig)") } -func readPayer() (basecoin.Actor, error) { +func readPayer() (sdk.Actor, error) { payer := viper.GetString(FlagPayer) if payer == "" { return txcmd.GetSignerAct(), nil diff --git a/modules/fee/errors.go b/modules/fee/errors.go index 5d06fce410da..80cc9818aa30 100644 --- a/modules/fee/errors.go +++ b/modules/fee/errors.go @@ -6,7 +6,7 @@ import ( abci "github.com/tendermint/abci/types" - "github.com/tendermint/basecoin/errors" + "github.com/cosmos/cosmos-sdk/errors" ) var ( diff --git a/modules/fee/handler.go b/modules/fee/handler.go index 564eab1ce84a..0a1df3f49d91 100644 --- a/modules/fee/handler.go +++ b/modules/fee/handler.go @@ -1,11 +1,11 @@ package fee import ( - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/modules/coin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/modules/coin" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) // NameFee - namespace for the fee module @@ -13,7 +13,7 @@ const NameFee = "fee" // Bank is a default location for the fees, but pass anything into // the middleware constructor -var Bank = basecoin.Actor{App: NameFee, Address: []byte("bank")} +var Bank = sdk.Actor{App: NameFee, Address: []byte("bank")} // SimpleFeeMiddleware - middleware for fee checking, constant amount // It used modules.coin to move the money @@ -23,7 +23,7 @@ type SimpleFeeMiddleware struct { MinFee coin.Coin // all fees go here, which could be a dump (Bank) or something reachable // by other app logic - Collector basecoin.Actor + Collector sdk.Actor stack.PassInitState stack.PassInitValidate } @@ -33,7 +33,7 @@ var _ stack.Middleware = SimpleFeeMiddleware{} // NewSimpleFeeMiddleware returns a fee handler with a fixed minimum fee. // // If minFee is 0, then the FeeTx is optional -func NewSimpleFeeMiddleware(minFee coin.Coin, collector basecoin.Actor) SimpleFeeMiddleware { +func NewSimpleFeeMiddleware(minFee coin.Coin, collector sdk.Actor) SimpleFeeMiddleware { return SimpleFeeMiddleware{ MinFee: minFee, Collector: collector, @@ -46,7 +46,7 @@ func (SimpleFeeMiddleware) Name() string { } // CheckTx - check the transaction -func (h SimpleFeeMiddleware) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) { +func (h SimpleFeeMiddleware) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) { fee, err := h.verifyFee(ctx, tx) if err != nil { if IsSkipFeesErr(err) { @@ -76,7 +76,7 @@ func (h SimpleFeeMiddleware) CheckTx(ctx basecoin.Context, store state.SimpleDB, } // DeliverTx - send the fee handler transaction -func (h SimpleFeeMiddleware) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (h SimpleFeeMiddleware) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) { fee, err := h.verifyFee(ctx, tx) if IsSkipFeesErr(err) { return next.DeliverTx(ctx, store, tx) @@ -95,7 +95,7 @@ func (h SimpleFeeMiddleware) DeliverTx(ctx basecoin.Context, store state.SimpleD return next.DeliverTx(ctx, store, fee.Tx) } -func (h SimpleFeeMiddleware) verifyFee(ctx basecoin.Context, tx basecoin.Tx) (Fee, error) { +func (h SimpleFeeMiddleware) verifyFee(ctx sdk.Context, tx sdk.Tx) (Fee, error) { feeTx, ok := tx.Unwrap().(Fee) if !ok { // the fee wrapper is not required if there is no minimum diff --git a/modules/fee/handler_test.go b/modules/fee/handler_test.go index dcaff0b09b4e..a4fc0cc9baf6 100644 --- a/modules/fee/handler_test.go +++ b/modules/fee/handler_test.go @@ -8,11 +8,11 @@ import ( "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/modules/coin" - "github.com/tendermint/basecoin/modules/fee" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/modules/coin" + "github.com/cosmos/cosmos-sdk/modules/fee" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) func TestFeeChecks(t *testing.T) { @@ -30,7 +30,7 @@ func TestFeeChecks(t *testing.T) { pure := atoms(46657) // these are some accounts - collector := basecoin.Actor{App: fee.NameFee, Address: []byte("mine")} + collector := sdk.Actor{App: fee.NameFee, Address: []byte("mine")} key1 := coin.NewAccountWithKey(mixed) key2 := coin.NewAccountWithKey(pure) act1, act2 := key1.Actor(), key2.Actor() @@ -60,12 +60,12 @@ func TestFeeChecks(t *testing.T) { cases := []struct { valid bool // this is the middleware stack to test - app basecoin.Handler + app sdk.Handler // they sign the tx - signer basecoin.Actor + signer sdk.Actor // wrap with the given fee if hasFee is true hasFee bool - payer basecoin.Actor + payer sdk.Actor fee coin.Coin // expected balance after the tx left coin.Coins diff --git a/modules/fee/tx.go b/modules/fee/tx.go index 20ce861fd2b1..43250a7c84d6 100644 --- a/modules/fee/tx.go +++ b/modules/fee/tx.go @@ -1,8 +1,8 @@ package fee import ( - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/modules/coin" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/modules/coin" ) // nolint @@ -12,7 +12,7 @@ const ( ) func init() { - basecoin.TxMapper. + sdk.TxMapper. RegisterImplementation(Fee{}, TypeFees, ByteFees) } @@ -22,12 +22,12 @@ func init() { type Fee struct { // Gas coin.Coin `json:"gas"` // ????? Fee coin.Coin `json:"fee"` - Payer basecoin.Actor `json:"payer"` // the address who pays the fee - Tx basecoin.Tx `json:"tx"` + Payer sdk.Actor `json:"payer"` // the address who pays the fee + Tx sdk.Tx `json:"tx"` } // NewFee wraps a tx with a promised fee from this actor -func NewFee(tx basecoin.Tx, fee coin.Coin, payer basecoin.Actor) basecoin.Tx { +func NewFee(tx sdk.Tx, fee coin.Coin, payer sdk.Actor) sdk.Tx { return Fee{Tx: tx, Fee: fee, Payer: payer}.Wrap() } @@ -36,9 +36,9 @@ func (f Fee) ValidateBasic() error { // TODO: more checks return f.Tx.ValidateBasic() } -func (f Fee) Wrap() basecoin.Tx { - return basecoin.Tx{f} +func (f Fee) Wrap() sdk.Tx { + return sdk.Tx{f} } -func (f Fee) Next() basecoin.Tx { +func (f Fee) Next() sdk.Tx { return f.Tx } diff --git a/modules/ibc/commands/query.go b/modules/ibc/commands/query.go index e0e3c564c70e..46227e1def16 100644 --- a/modules/ibc/commands/query.go +++ b/modules/ibc/commands/query.go @@ -7,10 +7,10 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/client/commands/query" - "github.com/tendermint/basecoin/modules/ibc" - "github.com/tendermint/basecoin/stack" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands/query" + "github.com/cosmos/cosmos-sdk/modules/ibc" + "github.com/cosmos/cosmos-sdk/stack" wire "github.com/tendermint/go-wire" "github.com/tendermint/go-wire/data" ) diff --git a/modules/ibc/commands/tx.go b/modules/ibc/commands/tx.go index 475d35809bcb..487803ca58cb 100644 --- a/modules/ibc/commands/tx.go +++ b/modules/ibc/commands/tx.go @@ -8,9 +8,9 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin/client/commands" - txcmd "github.com/tendermint/basecoin/client/commands/txs" - "github.com/tendermint/basecoin/modules/ibc" + "github.com/cosmos/cosmos-sdk/client/commands" + txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs" + "github.com/cosmos/cosmos-sdk/modules/ibc" "github.com/tendermint/light-client/certifiers" ) diff --git a/modules/ibc/errors.go b/modules/ibc/errors.go index 228c85e889ef..8c3c99a611bb 100644 --- a/modules/ibc/errors.go +++ b/modules/ibc/errors.go @@ -4,7 +4,7 @@ import ( "fmt" abci "github.com/tendermint/abci/types" - "github.com/tendermint/basecoin/errors" + "github.com/cosmos/cosmos-sdk/errors" ) // nolint diff --git a/modules/ibc/handler.go b/modules/ibc/handler.go index b4df69c224fa..63bebc3ed177 100644 --- a/modules/ibc/handler.go +++ b/modules/ibc/handler.go @@ -6,10 +6,10 @@ import ( "github.com/tendermint/go-wire/data" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) const ( @@ -29,16 +29,16 @@ var ( // AllowIBC returns a specially crafted Actor that // enables sending IBC packets for this app type -func AllowIBC(app string) basecoin.Actor { - return basecoin.Actor{App: app, Address: allowIBC} +func AllowIBC(app string) sdk.Actor { + return sdk.Actor{App: app, Address: allowIBC} } // Handler updates the chain state or creates an ibc packet type Handler struct { - basecoin.NopInitValidate + sdk.NopInitValidate } -var _ basecoin.Handler = Handler{} +var _ sdk.Handler = Handler{} // NewHandler returns a Handler that allows all chains to connect via IBC. // Set a Registrar via InitState to restrict it. @@ -57,7 +57,7 @@ func (h Handler) InitState(l log.Logger, store state.SimpleDB, module, key, valu return "", errors.ErrUnknownModule(module) } if key == OptionRegistrar { - var act basecoin.Actor + var act sdk.Actor err = data.FromJSON([]byte(value), &act) if err != nil { return "", err @@ -72,7 +72,7 @@ func (h Handler) InitState(l log.Logger, store state.SimpleDB, module, key, valu // CheckTx verifies the packet is formated correctly, and has the proper sequence // for a registered chain -func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.CheckResult, err error) { +func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) { err = tx.ValidateBasic() if err != nil { return res, err @@ -92,7 +92,7 @@ func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin // DeliverTx verifies all signatures on the tx and updates the chain state // apropriately -func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.DeliverResult, err error) { +func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error) { err = tx.ValidateBasic() if err != nil { return res, err @@ -113,8 +113,8 @@ func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx baseco // accepts it as the root of trust. // // only the registrar, if set, is allowed to do this -func (h Handler) initSeed(ctx basecoin.Context, store state.SimpleDB, - t RegisterChainTx) (res basecoin.DeliverResult, err error) { +func (h Handler) initSeed(ctx sdk.Context, store state.SimpleDB, + t RegisterChainTx) (res sdk.DeliverResult, err error) { info := LoadInfo(store) if !info.Registrar.Empty() && !ctx.HasPermission(info.Registrar) { @@ -137,8 +137,8 @@ func (h Handler) initSeed(ctx basecoin.Context, store state.SimpleDB, // updateSeed checks the seed against the existing chain data and rejects it if it // doesn't fit (or no chain data) -func (h Handler) updateSeed(ctx basecoin.Context, store state.SimpleDB, - t UpdateChainTx) (res basecoin.DeliverResult, err error) { +func (h Handler) updateSeed(ctx sdk.Context, store state.SimpleDB, + t UpdateChainTx) (res sdk.DeliverResult, err error) { chainID := t.ChainID() s := NewChainSet(store) @@ -167,8 +167,8 @@ func (h Handler) updateSeed(ctx basecoin.Context, store state.SimpleDB, // createPacket makes sure all permissions are good and the destination // chain is registed. If so, it appends it to the outgoing queue -func (h Handler) createPacket(ctx basecoin.Context, store state.SimpleDB, - t CreatePacketTx) (res basecoin.DeliverResult, err error) { +func (h Handler) createPacket(ctx sdk.Context, store state.SimpleDB, + t CreatePacketTx) (res sdk.DeliverResult, err error) { // make sure the chain is registed dest := t.DestChain @@ -189,7 +189,7 @@ func (h Handler) createPacket(ctx basecoin.Context, store state.SimpleDB, packet := Packet{ DestChain: dest, Tx: t.Tx, - Permissions: make([]basecoin.Actor, len(t.Permissions)), + Permissions: make([]sdk.Actor, len(t.Permissions)), } // make sure we have all the permissions we want to send @@ -206,6 +206,6 @@ func (h Handler) createPacket(ctx basecoin.Context, store state.SimpleDB, packet.Sequence = q.Tail() q.Push(packet.Bytes()) - res = basecoin.DeliverResult{Log: fmt.Sprintf("Packet %s %d", dest, packet.Sequence)} + res = sdk.DeliverResult{Log: fmt.Sprintf("Packet %s %d", dest, packet.Sequence)} return } diff --git a/modules/ibc/ibc_test.go b/modules/ibc/ibc_test.go index 1fb0394194d3..7300746ca257 100644 --- a/modules/ibc/ibc_test.go +++ b/modules/ibc/ibc_test.go @@ -11,10 +11,10 @@ import ( "github.com/tendermint/light-client/certifiers" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) // this tests registration without registrar permissions @@ -73,14 +73,14 @@ func TestIBCRegisterPermissions(t *testing.T) { keys := certifiers.GenValKeys(4) appHash := []byte{0x17, 0x21, 0x5, 0x1e} - foobar := basecoin.Actor{App: "foo", Address: []byte("bar")} - baz := basecoin.Actor{App: "baz", Address: []byte("bar")} - foobaz := basecoin.Actor{App: "foo", Address: []byte("baz")} + foobar := sdk.Actor{App: "foo", Address: []byte("bar")} + baz := sdk.Actor{App: "baz", Address: []byte("bar")} + foobaz := sdk.Actor{App: "foo", Address: []byte("baz")} cases := []struct { seed certifiers.Seed - registrar basecoin.Actor - signer basecoin.Actor + registrar sdk.Actor + signer sdk.Actor checker errors.CheckErr }{ // no sig, no registrar @@ -240,18 +240,18 @@ func TestIBCCreatePacket(t *testing.T) { // this is the tx we send, and the needed permission to send it raw := stack.NewRawTx([]byte{0xbe, 0xef}) ibcPerm := AllowIBC(stack.NameOK) - somePerm := basecoin.Actor{App: "some", Address: []byte("perm")} + somePerm := sdk.Actor{App: "some", Address: []byte("perm")} cases := []struct { dest string - ibcPerms basecoin.Actors - ctxPerms basecoin.Actors + ibcPerms sdk.Actors + ctxPerms sdk.Actors checker errors.CheckErr }{ // wrong chain -> error { dest: "some-other-chain", - ctxPerms: basecoin.Actors{ibcPerm}, + ctxPerms: sdk.Actors{ibcPerm}, checker: IsNotRegisteredErr, }, @@ -264,23 +264,23 @@ func TestIBCCreatePacket(t *testing.T) { // correct -> nice sequence { dest: chainID, - ctxPerms: basecoin.Actors{ibcPerm}, + ctxPerms: sdk.Actors{ibcPerm}, checker: errors.NoErr, }, // requesting invalid permissions -> error { dest: chainID, - ibcPerms: basecoin.Actors{somePerm}, - ctxPerms: basecoin.Actors{ibcPerm}, + ibcPerms: sdk.Actors{somePerm}, + ctxPerms: sdk.Actors{ibcPerm}, checker: IsCannotSetPermissionErr, }, // requesting extra permissions when present { dest: chainID, - ibcPerms: basecoin.Actors{somePerm}, - ctxPerms: basecoin.Actors{ibcPerm, somePerm}, + ibcPerms: sdk.Actors{somePerm}, + ctxPerms: sdk.Actors{ibcPerm, somePerm}, checker: errors.NoErr, }, } @@ -303,10 +303,10 @@ func TestIBCCreatePacket(t *testing.T) { if assert.Equal(2, q.Size()) { expected := []struct { seq uint64 - perm basecoin.Actors + perm sdk.Actors }{ {0, nil}, - {1, basecoin.Actors{somePerm}}, + {1, sdk.Actors{somePerm}}, } for _, tc := range expected { @@ -359,7 +359,7 @@ func TestIBCPostPacket(t *testing.T) { packet0badHeight := packet0 packet0badHeight.FromChainHeight -= 2 - theirActor := basecoin.Actor{ChainID: otherID, App: "foo", Address: []byte{1}} + theirActor := sdk.Actor{ChainID: otherID, App: "foo", Address: []byte{1}} p1 := NewPacket(rawTx, ourID, 1, theirActor) packet1, update1 := otherChain.MakePostPacket(p1, start+25) require.Nil(ourChain.Update(update1)) @@ -367,15 +367,15 @@ func TestIBCPostPacket(t *testing.T) { packet1badProof := packet1 packet1badProof.Key = []byte("random-data") - ourActor := basecoin.Actor{ChainID: ourID, App: "bar", Address: []byte{2}} + ourActor := sdk.Actor{ChainID: ourID, App: "bar", Address: []byte{2}} p2 := NewPacket(rawTx, ourID, 2, ourActor) packet2, update2 := otherChain.MakePostPacket(p2, start+50) require.Nil(ourChain.Update(update2)) - ibcPerm := basecoin.Actors{AllowIBC(stack.NameOK)} + ibcPerm := sdk.Actors{AllowIBC(stack.NameOK)} cases := []struct { packet PostPacketTx - permissions basecoin.Actors + permissions sdk.Actors checker errors.CheckErr }{ // bad chain -> error diff --git a/modules/ibc/keys.go b/modules/ibc/keys.go index e520d1888b33..4b5a53f980f0 100644 --- a/modules/ibc/keys.go +++ b/modules/ibc/keys.go @@ -1,8 +1,8 @@ package ibc import ( - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) const ( diff --git a/modules/ibc/middleware.go b/modules/ibc/middleware.go index eafff78ac124..fcf169aebc69 100644 --- a/modules/ibc/middleware.go +++ b/modules/ibc/middleware.go @@ -1,9 +1,9 @@ package ibc import ( - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) // Middleware allows us to verify the IBC proof on a packet and @@ -27,7 +27,7 @@ func (Middleware) Name() string { // CheckTx verifies the named chain and height is present, and verifies // the merkle proof in the packet -func (m Middleware) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) { +func (m Middleware) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) { // if it is not a PostPacket, just let it go through post, ok := tx.Unwrap().(PostPacketTx) if !ok { @@ -44,7 +44,7 @@ func (m Middleware) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basec // DeliverTx verifies the named chain and height is present, and verifies // the merkle proof in the packet -func (m Middleware) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (m Middleware) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) { // if it is not a PostPacket, just let it go through post, ok := tx.Unwrap().(PostPacketTx) if !ok { @@ -61,8 +61,8 @@ func (m Middleware) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx bas // verifyPost accepts a message bound for this chain... // TODO: think about relay -func (m Middleware) verifyPost(ctx basecoin.Context, store state.SimpleDB, - tx PostPacketTx) (ictx basecoin.Context, itx basecoin.Tx, err error) { +func (m Middleware) verifyPost(ctx sdk.Context, store state.SimpleDB, + tx PostPacketTx) (ictx sdk.Context, itx sdk.Tx, err error) { // make sure the chain is registered from := tx.FromChainID diff --git a/modules/ibc/provider.go b/modules/ibc/provider.go index d5fb877da0be..e308eb79d47f 100644 --- a/modules/ibc/provider.go +++ b/modules/ibc/provider.go @@ -4,8 +4,8 @@ import ( wire "github.com/tendermint/go-wire" "github.com/tendermint/light-client/certifiers" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) const ( diff --git a/modules/ibc/provider_test.go b/modules/ibc/provider_test.go index 6028570ea24d..96d0ad0ae198 100644 --- a/modules/ibc/provider_test.go +++ b/modules/ibc/provider_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tendermint/basecoin/state" + "github.com/cosmos/cosmos-sdk/state" "github.com/tendermint/light-client/certifiers" ) diff --git a/modules/ibc/store.go b/modules/ibc/store.go index e675455d7ab3..6da04f004b9f 100644 --- a/modules/ibc/store.go +++ b/modules/ibc/store.go @@ -1,15 +1,15 @@ package ibc import ( - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" wire "github.com/tendermint/go-wire" ) // HandlerInfo is the global state of the ibc.Handler type HandlerInfo struct { - Registrar basecoin.Actor `json:"registrar"` + Registrar sdk.Actor `json:"registrar"` } // Save the HandlerInfo to the store @@ -88,12 +88,12 @@ func (c ChainSet) Update(chainID string, theirHeight int) error { type Packet struct { DestChain string `json:"dest_chain"` Sequence uint64 `json:"sequence"` - Permissions basecoin.Actors `json:"permissions"` - Tx basecoin.Tx `json:"tx"` + Permissions sdk.Actors `json:"permissions"` + Tx sdk.Tx `json:"tx"` } // NewPacket creates a new outgoing packet -func NewPacket(tx basecoin.Tx, dest string, seq uint64, perm ...basecoin.Actor) Packet { +func NewPacket(tx sdk.Tx, dest string, seq uint64, perm ...sdk.Actor) Packet { return Packet{ DestChain: dest, Sequence: seq, diff --git a/modules/ibc/test_helpers.go b/modules/ibc/test_helpers.go index 5eba0f00a3db..59f531f09494 100644 --- a/modules/ibc/test_helpers.go +++ b/modules/ibc/test_helpers.go @@ -7,9 +7,9 @@ import ( "github.com/tendermint/merkleeyes/iavl" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) // MockChain is used to simulate a chain for ibc tests. @@ -79,13 +79,13 @@ func makePostPacket(tree *iavl.IAVLTree, packet Packet, fromID string, fromHeigh // AppChain is ready to handle tx type AppChain struct { chainID string - app basecoin.Handler + app sdk.Handler store state.SimpleDB height int } // NewAppChain returns a chain that is ready to respond to tx -func NewAppChain(app basecoin.Handler, chainID string) *AppChain { +func NewAppChain(app sdk.Handler, chainID string) *AppChain { return &AppChain{ chainID: chainID, app: app, @@ -103,7 +103,7 @@ func (a *AppChain) IncrementHeight(delta int) int { // DeliverTx runs the tx and commits the new tree, incrementing height // by one. -func (a *AppChain) DeliverTx(tx basecoin.Tx, perms ...basecoin.Actor) (basecoin.DeliverResult, error) { +func (a *AppChain) DeliverTx(tx sdk.Tx, perms ...sdk.Actor) (sdk.DeliverResult, error) { ctx := stack.MockContext(a.chainID, uint64(a.height)).WithPermissions(perms...) store := a.store.Checkpoint() res, err := a.app.DeliverTx(ctx, store, tx) diff --git a/modules/ibc/tx.go b/modules/ibc/tx.go index a7decdc24edd..7d474eba6fe5 100644 --- a/modules/ibc/tx.go +++ b/modules/ibc/tx.go @@ -5,7 +5,7 @@ import ( "github.com/tendermint/light-client/certifiers" "github.com/tendermint/merkleeyes/iavl" - "github.com/tendermint/basecoin" + sdk "github.com/cosmos/cosmos-sdk" ) // nolint @@ -23,7 +23,7 @@ const ( ) func init() { - basecoin.TxMapper. + sdk.TxMapper. RegisterImplementation(RegisterChainTx{}, TypeRegisterChain, ByteRegisterChain). RegisterImplementation(UpdateChainTx{}, TypeUpdateChain, ByteUpdateChain). RegisterImplementation(CreatePacketTx{}, TypeCreatePacket, ByteCreatePacket). @@ -50,8 +50,8 @@ func (r RegisterChainTx) ValidateBasic() error { } // Wrap - used to satisfy TxInner -func (r RegisterChainTx) Wrap() basecoin.Tx { - return basecoin.Tx{r} +func (r RegisterChainTx) Wrap() sdk.Tx { + return sdk.Tx{r} } // UpdateChainTx updates the state of this chain @@ -74,8 +74,8 @@ func (u UpdateChainTx) ValidateBasic() error { } // Wrap - used to satisfy TxInner -func (u UpdateChainTx) Wrap() basecoin.Tx { - return basecoin.Tx{u} +func (u UpdateChainTx) Wrap() sdk.Tx { + return sdk.Tx{u} } // CreatePacketTx is meant to be called by IPC, another module... @@ -87,8 +87,8 @@ func (u UpdateChainTx) Wrap() basecoin.Tx { // that can send this packet (so only coins can request SendTx packet) type CreatePacketTx struct { DestChain string `json:"dest_chain"` - Permissions basecoin.Actors `json:"permissions"` - Tx basecoin.Tx `json:"tx"` + Permissions sdk.Actors `json:"permissions"` + Tx sdk.Tx `json:"tx"` } // ValidateBasic makes sure this is consistent - used to satisfy TxInner @@ -100,8 +100,8 @@ func (p CreatePacketTx) ValidateBasic() error { } // Wrap - used to satisfy TxInner -func (p CreatePacketTx) Wrap() basecoin.Tx { - return basecoin.Tx{p} +func (p CreatePacketTx) Wrap() sdk.Tx { + return sdk.Tx{p} } // PostPacketTx takes a wrapped packet from another chain and @@ -127,6 +127,6 @@ func (p PostPacketTx) ValidateBasic() error { } // Wrap - used to satisfy TxInner -func (p PostPacketTx) Wrap() basecoin.Tx { - return basecoin.Tx{p} +func (p PostPacketTx) Wrap() sdk.Tx { + return sdk.Tx{p} } diff --git a/modules/nonce/commands/query.go b/modules/nonce/commands/query.go index a369e9667356..e4652638eab9 100644 --- a/modules/nonce/commands/query.go +++ b/modules/nonce/commands/query.go @@ -9,11 +9,11 @@ import ( lc "github.com/tendermint/light-client" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/client/commands/query" - "github.com/tendermint/basecoin/modules/nonce" - "github.com/tendermint/basecoin/stack" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands/query" + "github.com/cosmos/cosmos-sdk/modules/nonce" + "github.com/cosmos/cosmos-sdk/stack" ) // NonceQueryCmd - command to query an nonce account @@ -42,7 +42,7 @@ func nonceQueryCmd(cmd *cobra.Command, args []string) error { return query.OutputProof(seq, height) } -func doNonceQuery(signers []basecoin.Actor) (sequence uint32, height uint64, err error) { +func doNonceQuery(signers []sdk.Actor) (sequence uint32, height uint64, err error) { key := stack.PrefixedKey(nonce.NameNonce, nonce.GetSeqKey(signers)) prove := !viper.GetBool(commands.FlagTrustNode) height, err = query.GetParsed(key, &sequence, prove) diff --git a/modules/nonce/commands/wrap.go b/modules/nonce/commands/wrap.go index 508294665480..c7e5be7045a2 100644 --- a/modules/nonce/commands/wrap.go +++ b/modules/nonce/commands/wrap.go @@ -6,10 +6,10 @@ import ( "github.com/spf13/pflag" "github.com/spf13/viper" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/client/commands" - txcmd "github.com/tendermint/basecoin/client/commands/txs" - "github.com/tendermint/basecoin/modules/nonce" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/client/commands" + txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs" + "github.com/cosmos/cosmos-sdk/modules/nonce" ) // nolint @@ -26,7 +26,7 @@ var _ txcmd.Wrapper = NonceWrapper{} // Wrap grabs the sequence number from the flag and wraps // the tx with this nonce. Grabs the permission from the signer, // as we still only support single sig on the cli -func (NonceWrapper) Wrap(tx basecoin.Tx) (res basecoin.Tx, err error) { +func (NonceWrapper) Wrap(tx sdk.Tx) (res sdk.Tx, err error) { signers, err := readNonceKey() if err != nil { @@ -48,16 +48,16 @@ func (NonceWrapper) Register(fs *pflag.FlagSet) { fs.String(FlagNonceKey, "", "Set of comma-separated addresses for the nonce (for multisig)") } -func readNonceKey() ([]basecoin.Actor, error) { +func readNonceKey() ([]sdk.Actor, error) { nonce := viper.GetString(FlagNonceKey) if nonce == "" { - return []basecoin.Actor{txcmd.GetSignerAct()}, nil + return []sdk.Actor{txcmd.GetSignerAct()}, nil } return commands.ParseActors(nonce) } // read the sequence from the flag or query for it if flag is -1 -func readSequence(signers []basecoin.Actor) (seq uint32, err error) { +func readSequence(signers []sdk.Actor) (seq uint32, err error) { //add the nonce tx layer to the tx seqFlag := viper.GetInt(FlagSequence) diff --git a/modules/nonce/errors.go b/modules/nonce/errors.go index 832ea8ce2ee7..0d77b798427c 100644 --- a/modules/nonce/errors.go +++ b/modules/nonce/errors.go @@ -6,7 +6,7 @@ import ( abci "github.com/tendermint/abci/types" - "github.com/tendermint/basecoin/errors" + "github.com/cosmos/cosmos-sdk/errors" ) var ( diff --git a/modules/nonce/replaycheck.go b/modules/nonce/replaycheck.go index 2d532a1c2c45..521e5ec58853 100644 --- a/modules/nonce/replaycheck.go +++ b/modules/nonce/replaycheck.go @@ -1,9 +1,9 @@ package nonce import ( - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) //nolint @@ -26,8 +26,8 @@ func (ReplayCheck) Name() string { var _ stack.Middleware = ReplayCheck{} // CheckTx verifies tx is not being replayed - fulfills Middlware interface -func (r ReplayCheck) CheckTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) { +func (r ReplayCheck) CheckTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) { stx, err := r.checkIncrementNonceTx(ctx, store, tx) if err != nil { @@ -42,8 +42,8 @@ func (r ReplayCheck) CheckTx(ctx basecoin.Context, store state.SimpleDB, // DeliverTx verifies tx is not being replayed - fulfills Middlware interface // NOTE It is okay to modify the sequence before running the wrapped TX because if the // wrapped Tx fails, the state changes are not applied -func (r ReplayCheck) DeliverTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (r ReplayCheck) DeliverTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) { stx, err := r.checkIncrementNonceTx(ctx, store, tx) if err != nil { @@ -54,8 +54,8 @@ func (r ReplayCheck) DeliverTx(ctx basecoin.Context, store state.SimpleDB, } // checkNonceTx varifies the nonce sequence, an increment sequence number -func (r ReplayCheck) checkIncrementNonceTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx) (basecoin.Tx, error) { +func (r ReplayCheck) checkIncrementNonceTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx) (sdk.Tx, error) { // make sure it is a the nonce Tx (Tx from this package) nonceTx, ok := tx.Unwrap().(Tx) diff --git a/modules/nonce/rest/handlers.go b/modules/nonce/rest/handlers.go index 630d055f80e6..b27e7512fd83 100644 --- a/modules/nonce/rest/handlers.go +++ b/modules/nonce/rest/handlers.go @@ -7,13 +7,13 @@ import ( "github.com/gorilla/mux" "github.com/spf13/viper" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/client/commands/query" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/modules/coin" - "github.com/tendermint/basecoin/modules/nonce" - "github.com/tendermint/basecoin/stack" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands/query" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/modules/coin" + "github.com/cosmos/cosmos-sdk/modules/nonce" + "github.com/cosmos/cosmos-sdk/stack" wire "github.com/tendermint/go-wire" lightclient "github.com/tendermint/light-client" "github.com/tendermint/tmlibs/common" @@ -29,7 +29,7 @@ func doQueryNonce(w http.ResponseWriter, r *http.Request) { return } actor = coin.ChainAddr(actor) - key := nonce.GetSeqKey([]basecoin.Actor{actor}) + key := nonce.GetSeqKey([]sdk.Actor{actor}) key = stack.PrefixedKey(nonce.NameNonce, key) prove := !viper.GetBool(commands.FlagTrustNode) diff --git a/modules/nonce/store.go b/modules/nonce/store.go index bb5fca27d922..3ce2977d656a 100644 --- a/modules/nonce/store.go +++ b/modules/nonce/store.go @@ -5,8 +5,8 @@ import ( wire "github.com/tendermint/go-wire" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/state" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/state" ) func getSeq(store state.SimpleDB, key []byte) (seq uint32, err error) { diff --git a/modules/nonce/tx.go b/modules/nonce/tx.go index c0ff41da0e7e..ba5b21c31ffd 100644 --- a/modules/nonce/tx.go +++ b/modules/nonce/tx.go @@ -10,8 +10,8 @@ package nonce import ( "sort" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/state" ) // nolint @@ -21,20 +21,20 @@ const ( ) func init() { - basecoin.TxMapper.RegisterImplementation(Tx{}, TypeNonce, ByteNonce) + sdk.TxMapper.RegisterImplementation(Tx{}, TypeNonce, ByteNonce) } // Tx - Nonce transaction structure, contains list of signers and current sequence number type Tx struct { Sequence uint32 `json:"sequence"` - Signers []basecoin.Actor `json:"signers"` - Tx basecoin.Tx `json:"tx"` + Signers []sdk.Actor `json:"signers"` + Tx sdk.Tx `json:"tx"` } -var _ basecoin.TxInner = &Tx{} +var _ sdk.TxInner = &Tx{} // NewTx wraps the tx with a signable nonce -func NewTx(sequence uint32, signers []basecoin.Actor, tx basecoin.Tx) basecoin.Tx { +func NewTx(sequence uint32, signers []sdk.Actor, tx sdk.Tx) sdk.Tx { return (Tx{ Sequence: sequence, Signers: signers, @@ -43,8 +43,8 @@ func NewTx(sequence uint32, signers []basecoin.Actor, tx basecoin.Tx) basecoin.T } //nolint -func (n Tx) Wrap() basecoin.Tx { - return basecoin.Tx{n} +func (n Tx) Wrap() sdk.Tx { + return sdk.Tx{n} } func (n Tx) ValidateBasic() error { switch { @@ -62,7 +62,7 @@ func (n Tx) ValidateBasic() error { // and further increment the sequence number // NOTE It is okay to modify the sequence before running the wrapped TX because if the // wrapped Tx fails, the state changes are not applied -func (n Tx) CheckIncrementSeq(ctx basecoin.Context, store state.SimpleDB) error { +func (n Tx) CheckIncrementSeq(ctx sdk.Context, store state.SimpleDB) error { seqKey := n.getSeqKey() @@ -96,12 +96,12 @@ func (n Tx) getSeqKey() (seqKey []byte) { } // GetSeqKey - Generate the sequence key as the concatenated list of signers, sorted by address. -func GetSeqKey(signers []basecoin.Actor) (seqKey []byte) { +func GetSeqKey(signers []sdk.Actor) (seqKey []byte) { // First copy the list of signers to sort as sort is done in place - signers2sort := make([]basecoin.Actor, len(signers)) + signers2sort := make([]sdk.Actor, len(signers)) copy(signers2sort, signers) - sort.Sort(basecoin.ByAll(signers)) + sort.Sort(sdk.ByAll(signers)) for _, signer := range signers { seqKey = append(seqKey, signer.Bytes()...) diff --git a/modules/nonce/tx_test.go b/modules/nonce/tx_test.go index 218686deec71..e47a7711645c 100644 --- a/modules/nonce/tx_test.go +++ b/modules/nonce/tx_test.go @@ -6,9 +6,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) func TestNonce(t *testing.T) { @@ -27,36 +27,36 @@ func TestNonce(t *testing.T) { appName2 := "foot" //root actors for the tests - act1 := basecoin.Actor{ChainID: chainID, App: appName1, Address: []byte{1, 2, 3, 4}} - act2 := basecoin.Actor{ChainID: chainID, App: appName1, Address: []byte{1, 1, 1, 1}} - act3 := basecoin.Actor{ChainID: chainID, App: appName1, Address: []byte{3, 3, 3, 3}} - act1DiffChain := basecoin.Actor{ChainID: chain2ID, App: appName1, Address: []byte{1, 2, 3, 4}} - act2DiffChain := basecoin.Actor{ChainID: chain2ID, App: appName1, Address: []byte{1, 1, 1, 1}} - act3DiffChain := basecoin.Actor{ChainID: chain2ID, App: appName1, Address: []byte{3, 3, 3, 3}} - act1DiffApp := basecoin.Actor{ChainID: chainID, App: appName2, Address: []byte{1, 2, 3, 4}} - act2DiffApp := basecoin.Actor{ChainID: chainID, App: appName2, Address: []byte{1, 1, 1, 1}} - act3DiffApp := basecoin.Actor{ChainID: chainID, App: appName2, Address: []byte{3, 3, 3, 3}} + act1 := sdk.Actor{ChainID: chainID, App: appName1, Address: []byte{1, 2, 3, 4}} + act2 := sdk.Actor{ChainID: chainID, App: appName1, Address: []byte{1, 1, 1, 1}} + act3 := sdk.Actor{ChainID: chainID, App: appName1, Address: []byte{3, 3, 3, 3}} + act1DiffChain := sdk.Actor{ChainID: chain2ID, App: appName1, Address: []byte{1, 2, 3, 4}} + act2DiffChain := sdk.Actor{ChainID: chain2ID, App: appName1, Address: []byte{1, 1, 1, 1}} + act3DiffChain := sdk.Actor{ChainID: chain2ID, App: appName1, Address: []byte{3, 3, 3, 3}} + act1DiffApp := sdk.Actor{ChainID: chainID, App: appName2, Address: []byte{1, 2, 3, 4}} + act2DiffApp := sdk.Actor{ChainID: chainID, App: appName2, Address: []byte{1, 1, 1, 1}} + act3DiffApp := sdk.Actor{ChainID: chainID, App: appName2, Address: []byte{3, 3, 3, 3}} // let's construct some tests to make the table a bit less verbose - set0 := []basecoin.Actor{} - set1 := []basecoin.Actor{act1} - set2 := []basecoin.Actor{act2} - set12 := []basecoin.Actor{act1, act2} - set21 := []basecoin.Actor{act2, act1} - set123 := []basecoin.Actor{act1, act2, act3} - set321 := []basecoin.Actor{act3, act2, act1} + set0 := []sdk.Actor{} + set1 := []sdk.Actor{act1} + set2 := []sdk.Actor{act2} + set12 := []sdk.Actor{act1, act2} + set21 := []sdk.Actor{act2, act1} + set123 := []sdk.Actor{act1, act2, act3} + set321 := []sdk.Actor{act3, act2, act1} //some more test cases for different chains and apps for each actor - set123Chain2 := []basecoin.Actor{act1DiffChain, act2DiffChain, act3DiffChain} - set123App2 := []basecoin.Actor{act1DiffApp, act2DiffApp, act3DiffApp} - set123MixedChains := []basecoin.Actor{act1, act2DiffChain, act3} - set123MixedApps := []basecoin.Actor{act1, act2DiffApp, act3} + set123Chain2 := []sdk.Actor{act1DiffChain, act2DiffChain, act3DiffChain} + set123App2 := []sdk.Actor{act1DiffApp, act2DiffApp, act3DiffApp} + set123MixedChains := []sdk.Actor{act1, act2DiffChain, act3} + set123MixedApps := []sdk.Actor{act1, act2DiffApp, act3} testList := []struct { valid bool seq uint32 - actors []basecoin.Actor - signers []basecoin.Actor + actors []sdk.Actor + signers []sdk.Actor }{ // one signer {false, 0, set1, set1}, // seq 0 is no good diff --git a/modules/roles/commands/query.go b/modules/roles/commands/query.go index fccd54938a0b..fb2b077cf86e 100644 --- a/modules/roles/commands/query.go +++ b/modules/roles/commands/query.go @@ -4,10 +4,10 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/client/commands/query" - "github.com/tendermint/basecoin/modules/roles" - "github.com/tendermint/basecoin/stack" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/client/commands/query" + "github.com/cosmos/cosmos-sdk/modules/roles" + "github.com/cosmos/cosmos-sdk/stack" ) // RoleQueryCmd - command to query a role diff --git a/modules/roles/commands/tx.go b/modules/roles/commands/tx.go index d0492445c099..2b018f1a8c6d 100644 --- a/modules/roles/commands/tx.go +++ b/modules/roles/commands/tx.go @@ -5,10 +5,10 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/client/commands" - txcmd "github.com/tendermint/basecoin/client/commands/txs" - "github.com/tendermint/basecoin/modules/roles" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/client/commands" + txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs" + "github.com/cosmos/cosmos-sdk/modules/roles" ) // CreateRoleTxCmd is CLI command to create a new role @@ -41,7 +41,7 @@ func createRoleTxCmd(cmd *cobra.Command, args []string) error { return txcmd.DoTx(tx) } -func readCreateRoleTxFlags() (tx basecoin.Tx, err error) { +func readCreateRoleTxFlags() (tx sdk.Tx, err error) { role, err := parseRole(viper.GetString(FlagRole)) if err != nil { return tx, err diff --git a/modules/roles/commands/wrap.go b/modules/roles/commands/wrap.go index ba3ee51aae1e..9ea855e9e4c8 100644 --- a/modules/roles/commands/wrap.go +++ b/modules/roles/commands/wrap.go @@ -9,10 +9,10 @@ import ( abci "github.com/tendermint/abci/types" cmn "github.com/tendermint/tmlibs/common" - "github.com/tendermint/basecoin" - txcmd "github.com/tendermint/basecoin/client/commands/txs" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/modules/roles" + sdk "github.com/cosmos/cosmos-sdk" + txcmd "github.com/cosmos/cosmos-sdk/client/commands/txs" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/modules/roles" ) // nolint @@ -28,7 +28,7 @@ var _ txcmd.Wrapper = RoleWrapper{} // Wrap grabs the sequence number from the flag and wraps // the tx with this nonce. Grabs the permission from the signer, // as we still only support single sig on the cli -func (RoleWrapper) Wrap(tx basecoin.Tx) (basecoin.Tx, error) { +func (RoleWrapper) Wrap(tx sdk.Tx) (sdk.Tx, error) { assume := viper.GetStringSlice(FlagAssumeRole) // we wrap from inside-out, so we must wrap them in the reverse order, diff --git a/modules/roles/error.go b/modules/roles/error.go index 62ff77226c2e..4abdbf895671 100644 --- a/modules/roles/error.go +++ b/modules/roles/error.go @@ -6,7 +6,7 @@ import ( abci "github.com/tendermint/abci/types" - "github.com/tendermint/basecoin/errors" + "github.com/cosmos/cosmos-sdk/errors" ) var ( diff --git a/modules/roles/handler.go b/modules/roles/handler.go index d12ba0764d48..f70091e89cdf 100644 --- a/modules/roles/handler.go +++ b/modules/roles/handler.go @@ -1,9 +1,9 @@ package roles import ( - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/state" ) const ( @@ -17,11 +17,11 @@ const ( // Handler allows us to create new roles type Handler struct { - basecoin.NopInitState - basecoin.NopInitValidate + sdk.NopInitState + sdk.NopInitValidate } -var _ basecoin.Handler = Handler{} +var _ sdk.Handler = Handler{} // NewHandler makes a role handler to create roles func NewHandler() Handler { @@ -34,13 +34,13 @@ func (Handler) Name() string { } // CheckTx verifies if the transaction is properly formated -func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.CheckResult, err error) { +func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) { var cr CreateRoleTx cr, err = checkTx(ctx, tx) if err != nil { return } - res = basecoin.NewCheck(CostCreate, "") + res = sdk.NewCheck(CostCreate, "") err = checkNoRole(store, cr.Role) return } @@ -48,7 +48,7 @@ func (h Handler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin // DeliverTx tries to create a new role. // // Returns an error if the role already exists -func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.DeliverResult, err error) { +func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error) { create, err := checkTx(ctx, tx) if err != nil { return res, err @@ -60,7 +60,7 @@ func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx baseco return res, err } -func checkTx(ctx basecoin.Context, tx basecoin.Tx) (create CreateRoleTx, err error) { +func checkTx(ctx sdk.Context, tx sdk.Tx) (create CreateRoleTx, err error) { // check if the tx is proper type and valid create, ok := tx.Unwrap().(CreateRoleTx) if !ok { diff --git a/modules/roles/handler_test.go b/modules/roles/handler_test.go index ca177bf22643..f654f5acee05 100644 --- a/modules/roles/handler_test.go +++ b/modules/roles/handler_test.go @@ -5,32 +5,32 @@ import ( "github.com/stretchr/testify/assert" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/modules/roles" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/modules/roles" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) func TestCreateRole(t *testing.T) { assert := assert.New(t) - a := basecoin.Actor{App: "foo", Address: []byte("bar")} - b := basecoin.Actor{ChainID: "eth", App: "foo", Address: []byte("bar")} - c := basecoin.Actor{App: "foo", Address: []byte("baz")} - d := basecoin.Actor{App: "si-ly", Address: []byte("bar")} + a := sdk.Actor{App: "foo", Address: []byte("bar")} + b := sdk.Actor{ChainID: "eth", App: "foo", Address: []byte("bar")} + c := sdk.Actor{App: "foo", Address: []byte("baz")} + d := sdk.Actor{App: "si-ly", Address: []byte("bar")} cases := []struct { valid bool role string min uint32 - sigs []basecoin.Actor + sigs []sdk.Actor }{ - {true, "awesome", 1, []basecoin.Actor{a}}, - {true, "cool", 2, []basecoin.Actor{b, c, d}}, - {false, "oops", 3, []basecoin.Actor{a, d}}, // too many - {false, "ugh", 0, []basecoin.Actor{a, d}}, // too few - {false, "phew", 1, []basecoin.Actor{}}, // none - {false, "cool", 1, []basecoin.Actor{c, d}}, // duplicate of existing one + {true, "awesome", 1, []sdk.Actor{a}}, + {true, "cool", 2, []sdk.Actor{b, c, d}}, + {false, "oops", 3, []sdk.Actor{a, d}}, // too many + {false, "ugh", 0, []sdk.Actor{a, d}}, // too few + {false, "phew", 1, []sdk.Actor{}}, // none + {false, "cool", 1, []sdk.Actor{c, d}}, // duplicate of existing one } h := roles.NewHandler() diff --git a/modules/roles/middleware.go b/modules/roles/middleware.go index 6266db8e4284..73d9255c8b87 100644 --- a/modules/roles/middleware.go +++ b/modules/roles/middleware.go @@ -1,9 +1,9 @@ package roles import ( - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) // Middleware allows us to add a requested role as a permission @@ -28,7 +28,7 @@ func (Middleware) Name() string { // CheckTx tries to assume the named role if requested. // If no role is requested, do nothing. // If insufficient authority to assume the role, return error. -func (m Middleware) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) { +func (m Middleware) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) { // if this is not an AssumeRoleTx, then continue assume, ok := tx.Unwrap().(AssumeRoleTx) if !ok { // this also breaks the recursion below @@ -50,7 +50,7 @@ func (m Middleware) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basec // DeliverTx tries to assume the named role if requested. // If no role is requested, do nothing. // If insufficient authority to assume the role, return error. -func (m Middleware) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (m Middleware) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) { // if this is not an AssumeRoleTx, then continue assume, ok := tx.Unwrap().(AssumeRoleTx) if !ok { // this also breaks the recursion below @@ -66,7 +66,7 @@ func (m Middleware) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx bas return m.DeliverTx(ctx, store, assume.Tx, next) } -func assumeRole(ctx basecoin.Context, store state.SimpleDB, assume AssumeRoleTx) (basecoin.Context, error) { +func assumeRole(ctx sdk.Context, store state.SimpleDB, assume AssumeRoleTx) (sdk.Context, error) { err := assume.ValidateBasic() if err != nil { return nil, err diff --git a/modules/roles/middleware_test.go b/modules/roles/middleware_test.go index 032a9106ef46..459405cf9c66 100644 --- a/modules/roles/middleware_test.go +++ b/modules/roles/middleware_test.go @@ -8,17 +8,17 @@ import ( "github.com/tendermint/go-wire/data" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/modules/roles" - "github.com/tendermint/basecoin/stack" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/modules/roles" + "github.com/cosmos/cosmos-sdk/stack" + "github.com/cosmos/cosmos-sdk/state" ) // shortcut for the lazy -type ba []basecoin.Actor +type ba []sdk.Actor -func createRole(app basecoin.Handler, store state.SimpleDB, - name []byte, min uint32, sigs ...basecoin.Actor) (basecoin.Actor, error) { +func createRole(app sdk.Handler, store state.SimpleDB, + name []byte, min uint32, sigs ...sdk.Actor) (sdk.Actor, error) { tx := roles.NewCreateRoleTx(name, min, sigs) ctx := stack.MockContext("foo", 1) _, err := app.DeliverTx(ctx, store, tx) @@ -42,10 +42,10 @@ func TestAssumeRole(t *testing.T) { store := state.NewMemKVStore() // potential actors - a := basecoin.Actor{App: "sig", Address: []byte("jae")} - b := basecoin.Actor{App: "sig", Address: []byte("bucky")} - c := basecoin.Actor{App: "sig", Address: []byte("ethan")} - d := basecoin.Actor{App: "tracko", Address: []byte("rigel")} + a := sdk.Actor{App: "sig", Address: []byte("jae")} + b := sdk.Actor{App: "sig", Address: []byte("bucky")} + c := sdk.Actor{App: "sig", Address: []byte("ethan")} + d := sdk.Actor{App: "tracko", Address: []byte("rigel")} // devs is a 2-of-3 multisig devs := data.Bytes{0, 1, 0, 1} @@ -64,8 +64,8 @@ func TestAssumeRole(t *testing.T) { // which roles we try to assume (can be multiple!) // note: that wrapping is FILO, so tries to assume last role first roles []data.Bytes - signers []basecoin.Actor // which people sign the tx - required []basecoin.Actor // which permission we require to succeed + signers []sdk.Actor // which people sign the tx + required []sdk.Actor // which permission we require to succeed }{ // basic checks to see logic works {true, nil, nil, nil}, diff --git a/modules/roles/rest/handlers.go b/modules/roles/rest/handlers.go index 37aef256ff4e..1943634a34e4 100644 --- a/modules/roles/rest/handlers.go +++ b/modules/roles/rest/handlers.go @@ -7,12 +7,12 @@ import ( "github.com/gorilla/mux" abci "github.com/tendermint/abci/types" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/client/commands" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/modules/base" - "github.com/tendermint/basecoin/modules/nonce" - "github.com/tendermint/basecoin/modules/roles" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/client/commands" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/modules/base" + "github.com/cosmos/cosmos-sdk/modules/nonce" + "github.com/cosmos/cosmos-sdk/modules/roles" "github.com/tendermint/tmlibs/common" ) @@ -25,7 +25,7 @@ type RoleInput struct { MinimumSigners uint32 `json:"min_sigs" validate:"required,min=1"` - Signers []basecoin.Actor `json:"signers" validate:"required,min=1"` + Signers []sdk.Actor `json:"signers" validate:"required,min=1"` // Sequence is the user defined field whose purpose is to // prevent replay attacks when creating a role, since it diff --git a/modules/roles/store.go b/modules/roles/store.go index e9ef0c96737e..6268d40971c0 100644 --- a/modules/roles/store.go +++ b/modules/roles/store.go @@ -5,14 +5,14 @@ import ( wire "github.com/tendermint/go-wire" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/state" ) // NewPerm creates a role permission with the given label -func NewPerm(role []byte) basecoin.Actor { - return basecoin.Actor{ +func NewPerm(role []byte) sdk.Actor { + return sdk.Actor{ App: NameRole, Address: role, } @@ -21,11 +21,11 @@ func NewPerm(role []byte) basecoin.Actor { // Role - structure to hold permissioning type Role struct { MinSigs uint32 `json:"min_sigs"` - Signers []basecoin.Actor `json:"signers"` + Signers []sdk.Actor `json:"signers"` } // NewRole creates a Role structure to store the permissioning -func NewRole(min uint32, signers []basecoin.Actor) Role { +func NewRole(min uint32, signers []sdk.Actor) Role { return Role{ MinSigs: min, Signers: signers, @@ -33,7 +33,7 @@ func NewRole(min uint32, signers []basecoin.Actor) Role { } // IsSigner checks if the given Actor is allowed to sign this role -func (r Role) IsSigner(a basecoin.Actor) bool { +func (r Role) IsSigner(a sdk.Actor) bool { for _, s := range r.Signers { if a.Equals(s) { return true @@ -43,7 +43,7 @@ func (r Role) IsSigner(a basecoin.Actor) bool { } // IsAuthorized checks if the context has permission to assume the role -func (r Role) IsAuthorized(ctx basecoin.Context) bool { +func (r Role) IsAuthorized(ctx sdk.Context) bool { needed := r.MinSigs for _, s := range r.Signers { if ctx.HasPermission(s) { diff --git a/modules/roles/store_test.go b/modules/roles/store_test.go index fb69abb8d6a9..445a93c72623 100644 --- a/modules/roles/store_test.go +++ b/modules/roles/store_test.go @@ -6,42 +6,42 @@ import ( "github.com/stretchr/testify/assert" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/modules/roles" - "github.com/tendermint/basecoin/stack" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/modules/roles" + "github.com/cosmos/cosmos-sdk/stack" ) func TestRole(t *testing.T) { assert := assert.New(t) // prepare some actors... - a := basecoin.Actor{App: "foo", Address: []byte("bar")} - b := basecoin.Actor{ChainID: "eth", App: "foo", Address: []byte("bar")} - c := basecoin.Actor{App: "foo", Address: []byte("baz")} - d := basecoin.Actor{App: "si-ly", Address: []byte("bar")} - e := basecoin.Actor{App: "si-ly", Address: []byte("big")} - f := basecoin.Actor{App: "sig", Address: []byte{1}} - g := basecoin.Actor{App: "sig", Address: []byte{2, 3, 4}} + a := sdk.Actor{App: "foo", Address: []byte("bar")} + b := sdk.Actor{ChainID: "eth", App: "foo", Address: []byte("bar")} + c := sdk.Actor{App: "foo", Address: []byte("baz")} + d := sdk.Actor{App: "si-ly", Address: []byte("bar")} + e := sdk.Actor{App: "si-ly", Address: []byte("big")} + f := sdk.Actor{App: "sig", Address: []byte{1}} + g := sdk.Actor{App: "sig", Address: []byte{2, 3, 4}} cases := []struct { sigs uint32 - allowed []basecoin.Actor - signers []basecoin.Actor + allowed []sdk.Actor + signers []sdk.Actor valid bool }{ // make sure simple compare is correct - {1, []basecoin.Actor{a}, []basecoin.Actor{a}, true}, - {1, []basecoin.Actor{a}, []basecoin.Actor{b}, false}, - {1, []basecoin.Actor{a}, []basecoin.Actor{c}, false}, - {1, []basecoin.Actor{a}, []basecoin.Actor{d}, false}, + {1, []sdk.Actor{a}, []sdk.Actor{a}, true}, + {1, []sdk.Actor{a}, []sdk.Actor{b}, false}, + {1, []sdk.Actor{a}, []sdk.Actor{c}, false}, + {1, []sdk.Actor{a}, []sdk.Actor{d}, false}, // make sure multi-sig counts to 1 - {1, []basecoin.Actor{a, b, c}, []basecoin.Actor{d, e, a, f}, true}, - {1, []basecoin.Actor{a, b, c}, []basecoin.Actor{a, b, c, d}, true}, - {1, []basecoin.Actor{a, b, c}, []basecoin.Actor{d, e, f}, false}, + {1, []sdk.Actor{a, b, c}, []sdk.Actor{d, e, a, f}, true}, + {1, []sdk.Actor{a, b, c}, []sdk.Actor{a, b, c, d}, true}, + {1, []sdk.Actor{a, b, c}, []sdk.Actor{d, e, f}, false}, // make sure multi-sig counts higher - {2, []basecoin.Actor{b, e, g}, []basecoin.Actor{g, c, a, d, b}, true}, - {2, []basecoin.Actor{b, e, g}, []basecoin.Actor{c, a, d, b}, false}, - {3, []basecoin.Actor{a, b, c}, []basecoin.Actor{g}, false}, + {2, []sdk.Actor{b, e, g}, []sdk.Actor{g, c, a, d, b}, true}, + {2, []sdk.Actor{b, e, g}, []sdk.Actor{c, a, d, b}, false}, + {3, []sdk.Actor{a, b, c}, []sdk.Actor{g}, false}, } for idx, tc := range cases { diff --git a/modules/roles/tx.go b/modules/roles/tx.go index 48f5d5392ab6..c059478834ad 100644 --- a/modules/roles/tx.go +++ b/modules/roles/tx.go @@ -3,8 +3,8 @@ package roles import ( "github.com/tendermint/go-wire/data" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" ) var ( @@ -24,7 +24,7 @@ const ( ) func init() { - basecoin.TxMapper. + sdk.TxMapper. RegisterImplementation(AssumeRoleTx{}, TypeAssumeRoleTx, ByteAssumeRoleTx). RegisterImplementation(CreateRoleTx{}, TypeCreateRoleTx, ByteCreateRoleTx) } @@ -33,11 +33,11 @@ func init() { // the authority to use a given role. type AssumeRoleTx struct { Role data.Bytes `json:"role"` - Tx basecoin.Tx `json:"tx"` + Tx sdk.Tx `json:"tx"` } // NewAssumeRoleTx creates a new wrapper to add a role to a tx execution -func NewAssumeRoleTx(role []byte, tx basecoin.Tx) basecoin.Tx { +func NewAssumeRoleTx(role []byte, tx sdk.Tx) sdk.Tx { return AssumeRoleTx{Role: role, Tx: tx}.Wrap() } @@ -53,8 +53,8 @@ func (tx AssumeRoleTx) ValidateBasic() error { } // Wrap - used to satisfy TxInner -func (tx AssumeRoleTx) Wrap() basecoin.Tx { - return basecoin.Tx{tx} +func (tx AssumeRoleTx) Wrap() sdk.Tx { + return sdk.Tx{tx} } // CreateRoleTx is used to construct a new role @@ -64,11 +64,11 @@ func (tx AssumeRoleTx) Wrap() basecoin.Tx { type CreateRoleTx struct { Role data.Bytes `json:"role"` MinSigs uint32 `json:"min_sigs"` - Signers []basecoin.Actor `json:"signers"` + Signers []sdk.Actor `json:"signers"` } // NewCreateRoleTx creates a new role, which we can later use -func NewCreateRoleTx(role []byte, minSigs uint32, signers []basecoin.Actor) basecoin.Tx { +func NewCreateRoleTx(role []byte, minSigs uint32, signers []sdk.Actor) sdk.Tx { return CreateRoleTx{Role: role, MinSigs: minSigs, Signers: signers}.Wrap() } @@ -93,6 +93,6 @@ func (tx CreateRoleTx) ValidateBasic() error { } // Wrap - used to satisfy TxInner -func (tx CreateRoleTx) Wrap() basecoin.Tx { - return basecoin.Tx{tx} +func (tx CreateRoleTx) Wrap() sdk.Tx { + return sdk.Tx{tx} } diff --git a/publish/print_test_account.go b/publish/print_test_account.go index d96d151a4998..f8e3fe66abf5 100644 --- a/publish/print_test_account.go +++ b/publish/print_test_account.go @@ -5,7 +5,7 @@ package main import ( "fmt" - "github.com/tendermint/basecoin/tests" + "github.com/cosmos/cosmos-sdk/tests" "github.com/tendermint/go-wire" ) diff --git a/stack/checkpoint.go b/stack/checkpoint.go index e5426be8a976..53c32b88bbe1 100644 --- a/stack/checkpoint.go +++ b/stack/checkpoint.go @@ -1,8 +1,8 @@ package stack import ( - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/state" ) //nolint @@ -26,7 +26,7 @@ func (Checkpoint) Name() string { var _ Middleware = Checkpoint{} // CheckTx reverts all data changes if there was an error -func (c Checkpoint) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) { +func (c Checkpoint) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) { if !c.OnCheck { return next.CheckTx(ctx, store, tx) } @@ -39,7 +39,7 @@ func (c Checkpoint) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basec } // DeliverTx reverts all data changes if there was an error -func (c Checkpoint) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (c Checkpoint) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) { if !c.OnDeliver { return next.DeliverTx(ctx, store, tx) } diff --git a/stack/checkpoint_test.go b/stack/checkpoint_test.go index 013990649cf4..50d6132cd643 100644 --- a/stack/checkpoint_test.go +++ b/stack/checkpoint_test.go @@ -10,8 +10,8 @@ import ( "github.com/tendermint/merkleeyes/iavl" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/state" ) func makeState() state.SimpleDB { @@ -45,7 +45,7 @@ func TestCheckpointer(t *testing.T) { WrapHandler(bad), )) - basecoin.TxMapper.RegisterImplementation(RawTx{}, good.Name(), byte(80)) + sdk.TxMapper.RegisterImplementation(RawTx{}, good.Name(), byte(80)) mid := state.Model{ Key: []byte{'b', 'i', 'n', 'g', 0, 1, 2}, @@ -58,7 +58,7 @@ func TestCheckpointer(t *testing.T) { cases := []struct { // tx to send down the line - tx basecoin.Tx + tx sdk.Tx // expect no error? valid bool // models to check afterwards diff --git a/stack/context.go b/stack/context.go index 6fe31f244acd..18e76680f167 100644 --- a/stack/context.go +++ b/stack/context.go @@ -5,8 +5,8 @@ import ( "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/state" ) // store nonce as it's own type so no one can even try to fake it @@ -20,7 +20,7 @@ type secureContext struct { } // NewContext - create a new secureContext -func NewContext(chain string, height uint64, logger log.Logger) basecoin.Context { +func NewContext(chain string, height uint64, logger log.Logger) sdk.Context { mock := MockContext(chain, height).(naiveContext) mock.Logger = logger return secureContext{ @@ -28,10 +28,10 @@ func NewContext(chain string, height uint64, logger log.Logger) basecoin.Context } } -var _ basecoin.Context = secureContext{} +var _ sdk.Context = secureContext{} // WithPermissions will panic if they try to set permission without the proper app -func (c secureContext) WithPermissions(perms ...basecoin.Actor) basecoin.Context { +func (c secureContext) WithPermissions(perms ...sdk.Actor) sdk.Context { // the guard makes sure you only set permissions for the app you are inside for _, p := range perms { if !c.validPermisison(p) { @@ -48,7 +48,7 @@ func (c secureContext) WithPermissions(perms ...basecoin.Actor) basecoin.Context } } -func (c secureContext) validPermisison(p basecoin.Actor) bool { +func (c secureContext) validPermisison(p sdk.Actor) bool { // if app is set, then it must match if c.app != "" && c.app != p.App { return false @@ -59,7 +59,7 @@ func (c secureContext) validPermisison(p basecoin.Actor) bool { // Reset should clear out all permissions, // but carry on knowledge that this is a child -func (c secureContext) Reset() basecoin.Context { +func (c secureContext) Reset() sdk.Context { return secureContext{ app: c.app, ibc: c.ibc, @@ -68,7 +68,7 @@ func (c secureContext) Reset() basecoin.Context { } // IsParent ensures that this is derived from the given secureClient -func (c secureContext) IsParent(other basecoin.Context) bool { +func (c secureContext) IsParent(other sdk.Context) bool { so, ok := other.(secureContext) if !ok { return false @@ -78,7 +78,7 @@ func (c secureContext) IsParent(other basecoin.Context) bool { // withApp is a private method that we can use to properly set the // app controls in the middleware -func withApp(ctx basecoin.Context, app string) basecoin.Context { +func withApp(ctx sdk.Context, app string) sdk.Context { sc, ok := ctx.(secureContext) if !ok { return ctx @@ -91,7 +91,7 @@ func withApp(ctx basecoin.Context, app string) basecoin.Context { } // withIBC is a private method so we can securely allow IBC permissioning -func withIBC(ctx basecoin.Context) basecoin.Context { +func withIBC(ctx sdk.Context) sdk.Context { sc, ok := ctx.(secureContext) if !ok { return ctx @@ -103,22 +103,22 @@ func withIBC(ctx basecoin.Context) basecoin.Context { } } -func secureCheck(h basecoin.Checker, parent basecoin.Context) basecoin.Checker { - next := func(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.CheckResult, err error) { +func secureCheck(h sdk.Checker, parent sdk.Context) sdk.Checker { + next := func(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) { if !parent.IsParent(ctx) { return res, errors.New("Passing in non-child Context") } return h.CheckTx(ctx, store, tx) } - return basecoin.CheckerFunc(next) + return sdk.CheckerFunc(next) } -func secureDeliver(h basecoin.Deliver, parent basecoin.Context) basecoin.Deliver { - next := func(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.DeliverResult, err error) { +func secureDeliver(h sdk.Deliver, parent sdk.Context) sdk.Deliver { + next := func(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error) { if !parent.IsParent(ctx) { return res, errors.New("Passing in non-child Context") } return h.DeliverTx(ctx, store, tx) } - return basecoin.DeliverFunc(next) + return sdk.DeliverFunc(next) } diff --git a/stack/dispatcher.go b/stack/dispatcher.go index 54d67f11c974..89c489696de9 100644 --- a/stack/dispatcher.go +++ b/stack/dispatcher.go @@ -8,9 +8,9 @@ import ( abci "github.com/tendermint/abci/types" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/state" ) // nolint @@ -40,7 +40,7 @@ func NewDispatcher(routes ...Dispatchable) *Dispatcher { return d } -var _ basecoin.Handler = new(Dispatcher) +var _ sdk.Handler = new(Dispatcher) // AddRoutes registers all these dispatchable choices under their subdomains // @@ -66,7 +66,7 @@ func (d *Dispatcher) Name() string { // Tries to find a registered module (Dispatchable) based on the name of the tx. // The tx name (as registered with go-data) should be in the form `/XXXX`, // where `module name` must match the name of a dispatchable and XXX can be any string. -func (d *Dispatcher) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.CheckResult, err error) { +func (d *Dispatcher) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) { r, err := d.lookupTx(tx) if err != nil { return res, err @@ -87,7 +87,7 @@ func (d *Dispatcher) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx base // Tries to find a registered module (Dispatchable) based on the name of the tx. // The tx name (as registered with go-data) should be in the form `/XXXX`, // where `module name` must match the name of a dispatchable and XXX can be any string. -func (d *Dispatcher) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.DeliverResult, err error) { +func (d *Dispatcher) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error) { r, err := d.lookupTx(tx) if err != nil { return res, err @@ -131,7 +131,7 @@ func (d *Dispatcher) InitValidate(log log.Logger, store state.SimpleDB, vals []* } } -func (d *Dispatcher) lookupTx(tx basecoin.Tx) (Dispatchable, error) { +func (d *Dispatcher) lookupTx(tx sdk.Tx) (Dispatchable, error) { kind, err := tx.GetKind() if err != nil { return nil, err diff --git a/stack/helpers.go b/stack/helpers.go index ca3c7f586abc..000b82fcfc51 100644 --- a/stack/helpers.go +++ b/stack/helpers.go @@ -3,9 +3,9 @@ package stack import ( "github.com/tendermint/go-wire/data" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/state" ) //nolint @@ -30,7 +30,7 @@ const ( ) func init() { - basecoin.TxMapper. + sdk.TxMapper. RegisterImplementation(RawTx{}, TypeRawTx, ByteRawTx). RegisterImplementation(CheckTx{}, TypeCheckTx, ByteCheckTx). RegisterImplementation(FailTx{}, TypeFailTx, ByteFailTx) @@ -41,14 +41,14 @@ type RawTx struct { data.Bytes } -var _ basecoin.TxInner = RawTx{} +var _ sdk.TxInner = RawTx{} // nolint -func NewRawTx(d []byte) basecoin.Tx { +func NewRawTx(d []byte) sdk.Tx { return RawTx{data.Bytes(d)}.Wrap() } -func (r RawTx) Wrap() basecoin.Tx { - return basecoin.Tx{r} +func (r RawTx) Wrap() sdk.Tx { + return sdk.Tx{r} } func (r RawTx) ValidateBasic() error { if len(r.Bytes) > rawMaxSize { @@ -59,17 +59,17 @@ func (r RawTx) ValidateBasic() error { // CheckTx contains a list of permissions to be tested type CheckTx struct { - Required []basecoin.Actor + Required []sdk.Actor } -var _ basecoin.TxInner = CheckTx{} +var _ sdk.TxInner = CheckTx{} // nolint -func NewCheckTx(req []basecoin.Actor) basecoin.Tx { +func NewCheckTx(req []sdk.Actor) sdk.Tx { return CheckTx{req}.Wrap() } -func (c CheckTx) Wrap() basecoin.Tx { - return basecoin.Tx{c} +func (c CheckTx) Wrap() sdk.Tx { + return sdk.Tx{c} } func (CheckTx) ValidateBasic() error { return nil @@ -78,14 +78,14 @@ func (CheckTx) ValidateBasic() error { // FailTx just gets routed to filaure type FailTx struct{} -var _ basecoin.TxInner = FailTx{} +var _ sdk.TxInner = FailTx{} -func NewFailTx() basecoin.Tx { +func NewFailTx() sdk.Tx { return FailTx{}.Wrap() } -func (f FailTx) Wrap() basecoin.Tx { - return basecoin.Tx{f} +func (f FailTx) Wrap() sdk.Tx { + return sdk.Tx{f} } func (r FailTx) ValidateBasic() error { return nil @@ -94,11 +94,11 @@ func (r FailTx) ValidateBasic() error { // OKHandler just used to return okay to everything type OKHandler struct { Log string - basecoin.NopInitState - basecoin.NopInitValidate + sdk.NopInitState + sdk.NopInitValidate } -var _ basecoin.Handler = OKHandler{} +var _ sdk.Handler = OKHandler{} // Name - return handler's name func (OKHandler) Name() string { @@ -106,22 +106,22 @@ func (OKHandler) Name() string { } // CheckTx always returns an empty success tx -func (ok OKHandler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.CheckResult, err error) { - return basecoin.CheckResult{Log: ok.Log}, nil +func (ok OKHandler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) { + return sdk.CheckResult{Log: ok.Log}, nil } // DeliverTx always returns an empty success tx -func (ok OKHandler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.DeliverResult, err error) { - return basecoin.DeliverResult{Log: ok.Log}, nil +func (ok OKHandler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error) { + return sdk.DeliverResult{Log: ok.Log}, nil } // EchoHandler returns success, echoing res.Data = tx bytes type EchoHandler struct { - basecoin.NopInitState - basecoin.NopInitValidate + sdk.NopInitState + sdk.NopInitValidate } -var _ basecoin.Handler = EchoHandler{} +var _ sdk.Handler = EchoHandler{} // Name - return handler's name func (EchoHandler) Name() string { @@ -129,25 +129,25 @@ func (EchoHandler) Name() string { } // CheckTx always returns an empty success tx -func (EchoHandler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.CheckResult, err error) { +func (EchoHandler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) { data, err := data.ToWire(tx) - return basecoin.CheckResult{Data: data}, err + return sdk.CheckResult{Data: data}, err } // DeliverTx always returns an empty success tx -func (EchoHandler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.DeliverResult, err error) { +func (EchoHandler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error) { data, err := data.ToWire(tx) - return basecoin.DeliverResult{Data: data}, err + return sdk.DeliverResult{Data: data}, err } // FailHandler always returns an error type FailHandler struct { Err error - basecoin.NopInitState - basecoin.NopInitValidate + sdk.NopInitState + sdk.NopInitValidate } -var _ basecoin.Handler = FailHandler{} +var _ sdk.Handler = FailHandler{} // Name - return handler's name func (FailHandler) Name() string { @@ -155,12 +155,12 @@ func (FailHandler) Name() string { } // CheckTx always returns the given error -func (f FailHandler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.CheckResult, err error) { +func (f FailHandler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) { return res, errors.Wrap(f.Err) } // DeliverTx always returns the given error -func (f FailHandler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.DeliverResult, err error) { +func (f FailHandler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error) { return res, errors.Wrap(f.Err) } @@ -168,11 +168,11 @@ func (f FailHandler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx ba type PanicHandler struct { Msg string Err error - basecoin.NopInitState - basecoin.NopInitValidate + sdk.NopInitState + sdk.NopInitValidate } -var _ basecoin.Handler = PanicHandler{} +var _ sdk.Handler = PanicHandler{} // Name - return handler's name func (PanicHandler) Name() string { @@ -180,7 +180,7 @@ func (PanicHandler) Name() string { } // CheckTx always panics -func (p PanicHandler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.CheckResult, err error) { +func (p PanicHandler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) { if p.Err != nil { panic(p.Err) } @@ -188,7 +188,7 @@ func (p PanicHandler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx bas } // DeliverTx always panics -func (p PanicHandler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.DeliverResult, err error) { +func (p PanicHandler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error) { if p.Err != nil { panic(p.Err) } @@ -197,11 +197,11 @@ func (p PanicHandler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx b // CheckHandler accepts CheckTx and verifies the permissions type CheckHandler struct { - basecoin.NopInitState - basecoin.NopInitValidate + sdk.NopInitState + sdk.NopInitValidate } -var _ basecoin.Handler = CheckHandler{} +var _ sdk.Handler = CheckHandler{} // Name - return handler's name func (CheckHandler) Name() string { @@ -209,7 +209,7 @@ func (CheckHandler) Name() string { } // CheckTx verifies the permissions -func (c CheckHandler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.CheckResult, err error) { +func (c CheckHandler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) { check, ok := tx.Unwrap().(CheckTx) if !ok { return res, errors.ErrUnknownTxType(tx) @@ -224,7 +224,7 @@ func (c CheckHandler) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx bas } // DeliverTx verifies the permissions -func (c CheckHandler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.DeliverResult, err error) { +func (c CheckHandler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error) { check, ok := tx.Unwrap().(CheckTx) if !ok { return res, errors.ErrUnknownTxType(tx) diff --git a/stack/helpers_test.go b/stack/helpers_test.go index fb07c35c7bea..d28c0ce21d37 100644 --- a/stack/helpers_test.go +++ b/stack/helpers_test.go @@ -8,8 +8,8 @@ import ( "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/state" ) func TestOK(t *testing.T) { @@ -18,7 +18,7 @@ func TestOK(t *testing.T) { ctx := NewContext("test-chain", 20, log.NewNopLogger()) store := state.NewMemKVStore() data := "this looks okay" - tx := basecoin.Tx{} + tx := sdk.Tx{} ok := OKHandler{Log: data} res, err := ok.CheckTx(ctx, store, tx) @@ -36,7 +36,7 @@ func TestFail(t *testing.T) { ctx := NewContext("test-chain", 20, log.NewNopLogger()) store := state.NewMemKVStore() msg := "big problem" - tx := basecoin.Tx{} + tx := sdk.Tx{} fail := FailHandler{Err: errors.New(msg)} _, err := fail.CheckTx(ctx, store, tx) @@ -56,7 +56,7 @@ func TestPanic(t *testing.T) { ctx := NewContext("test-chain", 20, log.NewNopLogger()) store := state.NewMemKVStore() msg := "system crash!" - tx := basecoin.Tx{} + tx := sdk.Tx{} fail := PanicHandler{Msg: msg} assert.Panics(func() { fail.CheckTx(ctx, store, tx) }) @@ -70,18 +70,18 @@ func TestCheck(t *testing.T) { store := state.NewMemKVStore() h := CheckHandler{} - a := basecoin.Actor{App: "foo", Address: []byte("baz")} - b := basecoin.Actor{App: "si-ly", Address: []byte("bar")} + a := sdk.Actor{App: "foo", Address: []byte("baz")} + b := sdk.Actor{App: "si-ly", Address: []byte("bar")} cases := []struct { valid bool - signers, required []basecoin.Actor + signers, required []sdk.Actor }{ {true, nil, nil}, - {true, []basecoin.Actor{a}, []basecoin.Actor{a}}, - {true, []basecoin.Actor{a, b}, []basecoin.Actor{a}}, - {false, []basecoin.Actor{a}, []basecoin.Actor{a, b}}, - {false, []basecoin.Actor{a}, []basecoin.Actor{b}}, + {true, []sdk.Actor{a}, []sdk.Actor{a}}, + {true, []sdk.Actor{a, b}, []sdk.Actor{a}}, + {false, []sdk.Actor{a}, []sdk.Actor{a, b}}, + {false, []sdk.Actor{a}, []sdk.Actor{b}}, } for i, tc := range cases { diff --git a/stack/helperware.go b/stack/helperware.go index 003b1156b79b..65e40842cc73 100644 --- a/stack/helperware.go +++ b/stack/helperware.go @@ -2,9 +2,9 @@ package stack import ( - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/state" ) const ( @@ -15,7 +15,7 @@ const ( // CheckMiddleware returns an error if the tx doesn't have auth of this // Required Actor, otherwise passes along the call untouched type CheckMiddleware struct { - Required basecoin.Actor + Required sdk.Actor PassInitState PassInitValidate } @@ -26,14 +26,14 @@ func (_ CheckMiddleware) Name() string { return NameCheck } -func (p CheckMiddleware) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) { +func (p CheckMiddleware) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) { if !ctx.HasPermission(p.Required) { return res, errors.ErrUnauthorized() } return next.CheckTx(ctx, store, tx) } -func (p CheckMiddleware) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (p CheckMiddleware) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) { if !ctx.HasPermission(p.Required) { return res, errors.ErrUnauthorized() } @@ -42,7 +42,7 @@ func (p CheckMiddleware) DeliverTx(ctx basecoin.Context, store state.SimpleDB, t // GrantMiddleware tries to set the permission to this Actor, which may be prohibited type GrantMiddleware struct { - Auth basecoin.Actor + Auth sdk.Actor PassInitState PassInitValidate } @@ -53,12 +53,12 @@ func (_ GrantMiddleware) Name() string { return NameGrant } -func (g GrantMiddleware) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) { +func (g GrantMiddleware) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) { ctx = ctx.WithPermissions(g.Auth) return next.CheckTx(ctx, store, tx) } -func (g GrantMiddleware) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (g GrantMiddleware) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) { ctx = ctx.WithPermissions(g.Auth) return next.DeliverTx(ctx, store, tx) } diff --git a/stack/interface.go b/stack/interface.go index 35fe35e8dfc0..db2542797f4a 100644 --- a/stack/interface.go +++ b/stack/interface.go @@ -5,8 +5,8 @@ import ( abci "github.com/tendermint/abci/types" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/state" ) // Middleware is anything that wraps another handler to enhance functionality. @@ -18,86 +18,86 @@ type Middleware interface { DeliverMiddle InitStaterMiddle InitValidaterMiddle - basecoin.Named + sdk.Named } type CheckerMiddle interface { - CheckTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx, next basecoin.Checker) (basecoin.CheckResult, error) + CheckTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx, next sdk.Checker) (sdk.CheckResult, error) } -type CheckerMiddleFunc func(basecoin.Context, state.SimpleDB, - basecoin.Tx, basecoin.Checker) (basecoin.CheckResult, error) +type CheckerMiddleFunc func(sdk.Context, state.SimpleDB, + sdk.Tx, sdk.Checker) (sdk.CheckResult, error) -func (c CheckerMiddleFunc) CheckTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx, next basecoin.Checker) (basecoin.CheckResult, error) { +func (c CheckerMiddleFunc) CheckTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx, next sdk.Checker) (sdk.CheckResult, error) { return c(ctx, store, tx, next) } type DeliverMiddle interface { - DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, - next basecoin.Deliver) (basecoin.DeliverResult, error) + DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, + next sdk.Deliver) (sdk.DeliverResult, error) } -type DeliverMiddleFunc func(basecoin.Context, state.SimpleDB, - basecoin.Tx, basecoin.Deliver) (basecoin.DeliverResult, error) +type DeliverMiddleFunc func(sdk.Context, state.SimpleDB, + sdk.Tx, sdk.Deliver) (sdk.DeliverResult, error) -func (d DeliverMiddleFunc) DeliverTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx, next basecoin.Deliver) (basecoin.DeliverResult, error) { +func (d DeliverMiddleFunc) DeliverTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx, next sdk.Deliver) (sdk.DeliverResult, error) { return d(ctx, store, tx, next) } type InitStaterMiddle interface { InitState(l log.Logger, store state.SimpleDB, module, - key, value string, next basecoin.InitStater) (string, error) + key, value string, next sdk.InitStater) (string, error) } type InitStaterMiddleFunc func(log.Logger, state.SimpleDB, - string, string, string, basecoin.InitStater) (string, error) + string, string, string, sdk.InitStater) (string, error) func (c InitStaterMiddleFunc) InitState(l log.Logger, store state.SimpleDB, - module, key, value string, next basecoin.InitStater) (string, error) { + module, key, value string, next sdk.InitStater) (string, error) { return c(l, store, module, key, value, next) } type InitValidaterMiddle interface { - InitValidate(l log.Logger, store state.SimpleDB, vals []*abci.Validator, next basecoin.InitValidater) + InitValidate(l log.Logger, store state.SimpleDB, vals []*abci.Validator, next sdk.InitValidater) } type InitValidaterMiddleFunc func(log.Logger, state.SimpleDB, - []*abci.Validator, basecoin.InitValidater) + []*abci.Validator, sdk.InitValidater) func (c InitValidaterMiddleFunc) InitValidate(l log.Logger, store state.SimpleDB, - vals []*abci.Validator, next basecoin.InitValidater) { + vals []*abci.Validator, next sdk.InitValidater) { c(l, store, vals, next) } // holders type PassCheck struct{} -func (_ PassCheck) CheckTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx, next basecoin.Checker) (basecoin.CheckResult, error) { +func (_ PassCheck) CheckTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx, next sdk.Checker) (sdk.CheckResult, error) { return next.CheckTx(ctx, store, tx) } type PassDeliver struct{} -func (_ PassDeliver) DeliverTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx, next basecoin.Deliver) (basecoin.DeliverResult, error) { +func (_ PassDeliver) DeliverTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx, next sdk.Deliver) (sdk.DeliverResult, error) { return next.DeliverTx(ctx, store, tx) } type PassInitState struct{} func (_ PassInitState) InitState(l log.Logger, store state.SimpleDB, module, - key, value string, next basecoin.InitStater) (string, error) { + key, value string, next sdk.InitStater) (string, error) { return next.InitState(l, store, module, key, value) } type PassInitValidate struct{} func (_ PassInitValidate) InitValidate(l log.Logger, store state.SimpleDB, - vals []*abci.Validator, next basecoin.InitValidater) { + vals []*abci.Validator, next sdk.InitValidater) { next.InitValidate(l, store, vals) } @@ -109,13 +109,13 @@ type Dispatchable interface { AssertDispatcher() } -// WrapHandler turns a basecoin.Handler into a Dispatchable interface -func WrapHandler(h basecoin.Handler) Dispatchable { +// WrapHandler turns a sdk.Handler into a Dispatchable interface +func WrapHandler(h sdk.Handler) Dispatchable { return wrapped{h} } type wrapped struct { - h basecoin.Handler + h sdk.Handler } var _ Dispatchable = wrapped{} @@ -126,22 +126,22 @@ func (w wrapped) Name() string { return w.h.Name() } -func (w wrapped) CheckTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx, _ basecoin.Checker) (basecoin.CheckResult, error) { +func (w wrapped) CheckTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx, _ sdk.Checker) (sdk.CheckResult, error) { return w.h.CheckTx(ctx, store, tx) } -func (w wrapped) DeliverTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx, _ basecoin.Deliver) (basecoin.DeliverResult, error) { +func (w wrapped) DeliverTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx, _ sdk.Deliver) (sdk.DeliverResult, error) { return w.h.DeliverTx(ctx, store, tx) } func (w wrapped) InitState(l log.Logger, store state.SimpleDB, - module, key, value string, _ basecoin.InitStater) (string, error) { + module, key, value string, _ sdk.InitStater) (string, error) { return w.h.InitState(l, store, module, key, value) } func (w wrapped) InitValidate(l log.Logger, store state.SimpleDB, - vals []*abci.Validator, next basecoin.InitValidater) { + vals []*abci.Validator, next sdk.InitValidater) { w.h.InitValidate(l, store, vals) } diff --git a/stack/middleware.go b/stack/middleware.go index ebd2a4bba4ef..4c55f7f0af82 100644 --- a/stack/middleware.go +++ b/stack/middleware.go @@ -4,8 +4,8 @@ import ( abci "github.com/tendermint/abci/types" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/state" ) // middleware lets us wrap a whole stack up into one Handler @@ -15,16 +15,16 @@ type middleware struct { middleware Middleware space string allowIBC bool - next basecoin.Handler + next sdk.Handler } -var _ basecoin.Handler = &middleware{} +var _ sdk.Handler = &middleware{} func (m *middleware) Name() string { return m.middleware.Name() } -func (m *middleware) wrapCtx(ctx basecoin.Context) basecoin.Context { +func (m *middleware) wrapCtx(ctx sdk.Context) sdk.Context { if m.allowIBC { return withIBC(ctx) } @@ -32,7 +32,7 @@ func (m *middleware) wrapCtx(ctx basecoin.Context) basecoin.Context { } // CheckTx always returns an empty success tx -func (m *middleware) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (basecoin.CheckResult, error) { +func (m *middleware) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (sdk.CheckResult, error) { // make sure we pass in proper context to child next := secureCheck(m.next, ctx) // set the permissions for this app @@ -43,7 +43,7 @@ func (m *middleware) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx base } // DeliverTx always returns an empty success tx -func (m *middleware) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx) (res basecoin.DeliverResult, err error) { +func (m *middleware) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error) { // make sure we pass in proper context to child next := secureDeliver(m.next, ctx) // set the permissions for this app @@ -83,7 +83,7 @@ func prep(m Middleware, ibc bool) builder { } // wrap sets up the middleware with the proper options -func (b builder) wrap(next basecoin.Handler) basecoin.Handler { +func (b builder) wrap(next sdk.Handler) sdk.Handler { return &middleware{ middleware: b.middleware, space: b.stateSpace, @@ -95,11 +95,11 @@ func (b builder) wrap(next basecoin.Handler) basecoin.Handler { // Stack is the entire application stack type Stack struct { middles []builder - handler basecoin.Handler - basecoin.Handler // the compiled version, which we expose + handler sdk.Handler + sdk.Handler // the compiled version, which we expose } -var _ basecoin.Handler = &Stack{} +var _ sdk.Handler = &Stack{} // New prepares a middleware stack, you must `.Use()` a Handler // before you can execute it. @@ -127,7 +127,7 @@ func (s *Stack) IBC(m Middleware) *Stack { } // Use sets the final handler for the stack and prepares it for use -func (s *Stack) Use(handler basecoin.Handler) *Stack { +func (s *Stack) Use(handler sdk.Handler) *Stack { if handler == nil { panic("Cannot have a Stack without an end handler") } @@ -143,7 +143,7 @@ func (s *Stack) Dispatch(routes ...Dispatchable) *Stack { return s.Use(d) } -func build(mid []builder, end basecoin.Handler) basecoin.Handler { +func build(mid []builder, end sdk.Handler) sdk.Handler { if len(mid) == 0 { return end } diff --git a/stack/middleware_test.go b/stack/middleware_test.go index b7fa9231a4f1..c09c28f5241c 100644 --- a/stack/middleware_test.go +++ b/stack/middleware_test.go @@ -9,9 +9,9 @@ import ( "github.com/tendermint/go-wire/data" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/state" ) const ( @@ -29,16 +29,16 @@ func TestPermissionSandbox(t *testing.T) { require.Nil(err) // test cases to make sure permissioning is solid - grantee := basecoin.Actor{App: NameGrant, Address: []byte{1}} - grantee2 := basecoin.Actor{App: NameGrant, Address: []byte{2}} + grantee := sdk.Actor{App: NameGrant, Address: []byte{1}} + grantee2 := sdk.Actor{App: NameGrant, Address: []byte{2}} // ibc and grantee are the same, just different chains - ibc := basecoin.Actor{ChainID: "other", App: NameGrant, Address: []byte{1}} - ibc2 := basecoin.Actor{ChainID: "other", App: nameSigner, Address: []byte{21}} - signer := basecoin.Actor{App: nameSigner, Address: []byte{21}} + ibc := sdk.Actor{ChainID: "other", App: NameGrant, Address: []byte{1}} + ibc2 := sdk.Actor{ChainID: "other", App: nameSigner, Address: []byte{21}} + signer := sdk.Actor{App: nameSigner, Address: []byte{21}} cases := []struct { asIBC bool - grant basecoin.Actor - require basecoin.Actor + grant sdk.Actor + require sdk.Actor expectedRes data.Bytes expected func(error) bool }{ @@ -80,7 +80,7 @@ func TestPermissionSandbox(t *testing.T) { } } -func checkPerm(t *testing.T, idx int, data []byte, check func(error) bool, res basecoin.Result, err error) { +func checkPerm(t *testing.T, idx int, data []byte, check func(error) bool, res sdk.Result, err error) { assert := assert.New(t) if len(data) > 0 { diff --git a/stack/mock.go b/stack/mock.go index b64f4e12f155..7327875f6a3e 100644 --- a/stack/mock.go +++ b/stack/mock.go @@ -5,21 +5,21 @@ import ( "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" + sdk "github.com/cosmos/cosmos-sdk" ) type naiveContext struct { id nonce chain string height uint64 - perms []basecoin.Actor + perms []sdk.Actor log.Logger } // MockContext returns a simple, non-checking context for test cases. // // Always use NewContext() for production code to sandbox malicious code better -func MockContext(chain string, height uint64) basecoin.Context { +func MockContext(chain string, height uint64) sdk.Context { return naiveContext{ id: nonce(rand.Int63()), chain: chain, @@ -28,7 +28,7 @@ func MockContext(chain string, height uint64) basecoin.Context { } } -var _ basecoin.Context = naiveContext{} +var _ sdk.Context = naiveContext{} func (c naiveContext) ChainID() string { return c.chain @@ -39,7 +39,7 @@ func (c naiveContext) BlockHeight() uint64 { } // WithPermissions will panic if they try to set permission without the proper app -func (c naiveContext) WithPermissions(perms ...basecoin.Actor) basecoin.Context { +func (c naiveContext) WithPermissions(perms ...sdk.Actor) sdk.Context { return naiveContext{ id: c.id, chain: c.chain, @@ -49,7 +49,7 @@ func (c naiveContext) WithPermissions(perms ...basecoin.Actor) basecoin.Context } } -func (c naiveContext) HasPermission(perm basecoin.Actor) bool { +func (c naiveContext) HasPermission(perm sdk.Actor) bool { for _, p := range c.perms { if p.Equals(perm) { return true @@ -58,7 +58,7 @@ func (c naiveContext) HasPermission(perm basecoin.Actor) bool { return false } -func (c naiveContext) GetPermissions(chain, app string) (res []basecoin.Actor) { +func (c naiveContext) GetPermissions(chain, app string) (res []sdk.Actor) { for _, p := range c.perms { if chain == p.ChainID { if app == "" || app == p.App { @@ -70,7 +70,7 @@ func (c naiveContext) GetPermissions(chain, app string) (res []basecoin.Actor) { } // IsParent ensures that this is derived from the given secureClient -func (c naiveContext) IsParent(other basecoin.Context) bool { +func (c naiveContext) IsParent(other sdk.Context) bool { nc, ok := other.(naiveContext) if !ok { return false @@ -80,7 +80,7 @@ func (c naiveContext) IsParent(other basecoin.Context) bool { // Reset should clear out all permissions, // but carry on knowledge that this is a child -func (c naiveContext) Reset() basecoin.Context { +func (c naiveContext) Reset() sdk.Context { return naiveContext{ id: c.id, chain: c.chain, diff --git a/stack/prefixstore.go b/stack/prefixstore.go index 5c6a4e7a08ca..86b58ad33638 100644 --- a/stack/prefixstore.go +++ b/stack/prefixstore.go @@ -4,7 +4,7 @@ import ( "bytes" "errors" - "github.com/tendermint/basecoin/state" + "github.com/cosmos/cosmos-sdk/state" ) type prefixStore struct { diff --git a/stack/recovery.go b/stack/recovery.go index cbf9d2d49f33..bfa04b189892 100644 --- a/stack/recovery.go +++ b/stack/recovery.go @@ -6,9 +6,9 @@ import ( abci "github.com/tendermint/abci/types" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/state" ) // nolint @@ -27,7 +27,7 @@ func (Recovery) Name() string { var _ Middleware = Recovery{} // CheckTx catches any panic and converts to error - fulfills Middlware interface -func (Recovery) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Checker) (res basecoin.CheckResult, err error) { +func (Recovery) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error) { defer func() { if r := recover(); r != nil { err = normalizePanic(r) @@ -37,7 +37,7 @@ func (Recovery) CheckTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin. } // DeliverTx catches any panic and converts to error - fulfills Middlware interface -func (Recovery) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.DeliverResult, err error) { +func (Recovery) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error) { defer func() { if r := recover(); r != nil { err = normalizePanic(r) @@ -47,7 +47,7 @@ func (Recovery) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoi } // InitState catches any panic and converts to error - fulfills Middlware interface -func (Recovery) InitState(l log.Logger, store state.SimpleDB, module, key, value string, next basecoin.InitStater) (log string, err error) { +func (Recovery) InitState(l log.Logger, store state.SimpleDB, module, key, value string, next sdk.InitStater) (log string, err error) { defer func() { if r := recover(); r != nil { err = normalizePanic(r) @@ -59,7 +59,7 @@ func (Recovery) InitState(l log.Logger, store state.SimpleDB, module, key, value // InitValidate catches any panic and logs it // TODO: return an error??? func (Recovery) InitValidate(l log.Logger, store state.SimpleDB, - vals []*abci.Validator, next basecoin.InitValidater) { + vals []*abci.Validator, next sdk.InitValidater) { defer func() { if r := recover(); r != nil { diff --git a/stack/recovery_test.go b/stack/recovery_test.go index 944d0db315ef..292410ba46df 100644 --- a/stack/recovery_test.go +++ b/stack/recovery_test.go @@ -9,8 +9,8 @@ import ( "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/state" ) func TestRecovery(t *testing.T) { @@ -19,7 +19,7 @@ func TestRecovery(t *testing.T) { // generic args here... ctx := NewContext("test-chain", 20, log.NewNopLogger()) store := state.NewMemKVStore() - tx := basecoin.Tx{} + tx := sdk.Tx{} cases := []struct { msg string // what to send to panic diff --git a/stack/state_space_test.go b/stack/state_space_test.go index 8f9d302e3762..9b471484c925 100644 --- a/stack/state_space_test.go +++ b/stack/state_space_test.go @@ -9,8 +9,8 @@ import ( "github.com/tendermint/go-wire/data" "github.com/tendermint/tmlibs/log" - "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/state" + sdk "github.com/cosmos/cosmos-sdk" + "github.com/cosmos/cosmos-sdk/state" ) // writerMid is a middleware that writes the given bytes on CheckTx and DeliverTx @@ -24,20 +24,20 @@ var _ Middleware = writerMid{} func (w writerMid) Name() string { return w.name } -func (w writerMid) CheckTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx, next basecoin.Checker) (basecoin.CheckResult, error) { +func (w writerMid) CheckTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx, next sdk.Checker) (sdk.CheckResult, error) { store.Set(w.key, w.value) return next.CheckTx(ctx, store, tx) } -func (w writerMid) DeliverTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx, next basecoin.Deliver) (basecoin.DeliverResult, error) { +func (w writerMid) DeliverTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx, next sdk.Deliver) (sdk.DeliverResult, error) { store.Set(w.key, w.value) return next.DeliverTx(ctx, store, tx) } func (w writerMid) InitState(l log.Logger, store state.SimpleDB, module, - key, value string, next basecoin.InitStater) (string, error) { + key, value string, next sdk.InitStater) (string, error) { store.Set([]byte(key), []byte(value)) return next.InitState(l, store, module, key, value) } @@ -46,23 +46,23 @@ func (w writerMid) InitState(l log.Logger, store state.SimpleDB, module, type writerHand struct { name string key, value []byte - basecoin.NopInitValidate + sdk.NopInitValidate } -var _ basecoin.Handler = writerHand{} +var _ sdk.Handler = writerHand{} func (w writerHand) Name() string { return w.name } -func (w writerHand) CheckTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx) (basecoin.CheckResult, error) { +func (w writerHand) CheckTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx) (sdk.CheckResult, error) { store.Set(w.key, w.value) - return basecoin.CheckResult{}, nil + return sdk.CheckResult{}, nil } -func (w writerHand) DeliverTx(ctx basecoin.Context, store state.SimpleDB, - tx basecoin.Tx) (basecoin.DeliverResult, error) { +func (w writerHand) DeliverTx(ctx sdk.Context, store state.SimpleDB, + tx sdk.Tx) (sdk.DeliverResult, error) { store.Set(w.key, w.value) - return basecoin.DeliverResult{}, nil + return sdk.DeliverResult{}, nil } func (w writerHand) InitState(l log.Logger, store state.SimpleDB, module, @@ -73,7 +73,7 @@ func (w writerHand) InitState(l log.Logger, store state.SimpleDB, module, func TestStateSpace(t *testing.T) { cases := []struct { - h basecoin.Handler + h sdk.Handler m []Middleware expected []data.Bytes }{ @@ -95,7 +95,7 @@ func TestStateSpace(t *testing.T) { app := New(tc.m...).Use(d) // register so RawTx is routed to this handler - basecoin.TxMapper.RegisterImplementation(RawTx{}, tc.h.Name(), byte(50+i)) + sdk.TxMapper.RegisterImplementation(RawTx{}, tc.h.Name(), byte(50+i)) // run various tests on this setup spaceCheck(t, i, app, tc.expected) @@ -104,7 +104,7 @@ func TestStateSpace(t *testing.T) { } } -func spaceCheck(t *testing.T, i int, app basecoin.Handler, keys []data.Bytes) { +func spaceCheck(t *testing.T, i int, app sdk.Handler, keys []data.Bytes) { assert := assert.New(t) require := require.New(t) @@ -122,7 +122,7 @@ func spaceCheck(t *testing.T, i int, app basecoin.Handler, keys []data.Bytes) { } } -func spaceDeliver(t *testing.T, i int, app basecoin.Handler, keys []data.Bytes) { +func spaceDeliver(t *testing.T, i int, app sdk.Handler, keys []data.Bytes) { assert := assert.New(t) require := require.New(t) diff --git a/state/errors.go b/state/errors.go index cc314ddb0c8a..54b5badd3d5d 100644 --- a/state/errors.go +++ b/state/errors.go @@ -5,7 +5,7 @@ import ( "fmt" abci "github.com/tendermint/abci/types" - "github.com/tendermint/basecoin/errors" + "github.com/cosmos/cosmos-sdk/errors" ) var ( diff --git a/tests/tendermint/main.go b/tests/tendermint/main.go index 32ca659e58a5..0f27a2cd1c3e 100644 --- a/tests/tendermint/main.go +++ b/tests/tendermint/main.go @@ -7,7 +7,7 @@ func main() {} // "time" // "github.com/gorilla/websocket" -// "github.com/tendermint/basecoin/types" +// "github.com/cosmos/cosmos-sdk/types" // wire "github.com/tendermint/go-wire" // _ "github.com/tendermint/tendermint/rpc/core/types" // Register RPCResponse > Result types // "github.com/tendermint/tendermint/rpc/lib/client" diff --git a/tx.go b/tx.go index 3a5626a7f62b..81dd1dc0b074 100644 --- a/tx.go +++ b/tx.go @@ -1,11 +1,11 @@ -package basecoin +package sdk import ( "strings" "github.com/tendermint/go-wire/data" - "github.com/tendermint/basecoin/errors" + "github.com/cosmos/cosmos-sdk/errors" ) const maxTxSize = 10240 diff --git a/tx_test.go b/tx_test.go index c54a26dba6dc..c3ddfc819a4b 100644 --- a/tx_test.go +++ b/tx_test.go @@ -1,4 +1,4 @@ -package basecoin +package sdk import ( "testing" diff --git a/txinner_wrapper.go b/txinner_wrapper.go index cfc91b5b2003..c3cf36ebe0db 100644 --- a/txinner_wrapper.go +++ b/txinner_wrapper.go @@ -2,7 +2,7 @@ // TypeWriter: wrapper // Directive: +gen on TxInner -package basecoin +package sdk import ( "github.com/tendermint/go-wire/data"