Merge PR #2324: rename wire to codec
* rename wire to codec * fix formatting and cli * fix the docs
This commit is contained in:
parent
5bf9401e87
commit
6b55093c75
|
@ -45,6 +45,7 @@ BREAKING CHANGES
|
||||||
* [tools] Removed gocyclo [#2211](https://github.com/cosmos/cosmos-sdk/issues/2211)
|
* [tools] Removed gocyclo [#2211](https://github.com/cosmos/cosmos-sdk/issues/2211)
|
||||||
* [baseapp] Remove `SetTxDecoder` in favor of requiring the decoder be set in baseapp initialization. [#1441](https://github.com/cosmos/cosmos-sdk/issues/1441)
|
* [baseapp] Remove `SetTxDecoder` in favor of requiring the decoder be set in baseapp initialization. [#1441](https://github.com/cosmos/cosmos-sdk/issues/1441)
|
||||||
* [store] Change storeInfo within the root multistore to use tmhash instead of ripemd160 \#2308
|
* [store] Change storeInfo within the root multistore to use tmhash instead of ripemd160 \#2308
|
||||||
|
* [codec] \#2324 All referrences to wire have been renamed to codec. Additionally, wire.NewCodec is now codec.New().
|
||||||
|
|
||||||
* Tendermint
|
* Tendermint
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,10 @@ import (
|
||||||
dbm "github.com/tendermint/tendermint/libs/db"
|
dbm "github.com/tendermint/tendermint/libs/db"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/store"
|
"github.com/cosmos/cosmos-sdk/store"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/version"
|
"github.com/cosmos/cosmos-sdk/version"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Key to store the header in the DB itself.
|
// Key to store the header in the DB itself.
|
||||||
|
@ -331,7 +331,7 @@ func handleQueryApp(app *BaseApp, path []string, req abci.RequestQuery) (res abc
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode with json
|
// Encode with json
|
||||||
value := wire.Cdc.MustMarshalBinary(result)
|
value := codec.Cdc.MustMarshalBinary(result)
|
||||||
return abci.ResponseQuery{
|
return abci.ResponseQuery{
|
||||||
Code: uint32(sdk.ABCICodeOK),
|
Code: uint32(sdk.ABCICodeOK),
|
||||||
Value: value,
|
Value: value,
|
||||||
|
|
|
@ -14,8 +14,8 @@ import (
|
||||||
dbm "github.com/tendermint/tendermint/libs/db"
|
dbm "github.com/tendermint/tendermint/libs/db"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -34,14 +34,14 @@ func defaultLogger() log.Logger {
|
||||||
func newBaseApp(name string, options ...func(*BaseApp)) *BaseApp {
|
func newBaseApp(name string, options ...func(*BaseApp)) *BaseApp {
|
||||||
logger := defaultLogger()
|
logger := defaultLogger()
|
||||||
db := dbm.NewMemDB()
|
db := dbm.NewMemDB()
|
||||||
codec := wire.NewCodec()
|
codec := codec.New()
|
||||||
registerTestCodec(codec)
|
registerTestCodec(codec)
|
||||||
return NewBaseApp(name, logger, db, testTxDecoder(codec), options...)
|
return NewBaseApp(name, logger, db, testTxDecoder(codec), options...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerTestCodec(cdc *wire.Codec) {
|
func registerTestCodec(cdc *codec.Codec) {
|
||||||
// register Tx, Msg
|
// register Tx, Msg
|
||||||
sdk.RegisterWire(cdc)
|
sdk.RegisterCodec(cdc)
|
||||||
|
|
||||||
// register test types
|
// register test types
|
||||||
cdc.RegisterConcrete(&txTest{}, "cosmos-sdk/baseapp/txTest", nil)
|
cdc.RegisterConcrete(&txTest{}, "cosmos-sdk/baseapp/txTest", nil)
|
||||||
|
@ -350,7 +350,7 @@ func (msg msgCounter2) ValidateBasic() sdk.Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// amino decode
|
// amino decode
|
||||||
func testTxDecoder(cdc *wire.Codec) sdk.TxDecoder {
|
func testTxDecoder(cdc *codec.Codec) sdk.TxDecoder {
|
||||||
return func(txBytes []byte) (sdk.Tx, sdk.Error) {
|
return func(txBytes []byte) (sdk.Tx, sdk.Error) {
|
||||||
var tx txTest
|
var tx txTest
|
||||||
if len(txBytes) == 0 {
|
if len(txBytes) == 0 {
|
||||||
|
@ -448,7 +448,7 @@ func TestCheckTx(t *testing.T) {
|
||||||
app.InitChain(abci.RequestInitChain{})
|
app.InitChain(abci.RequestInitChain{})
|
||||||
|
|
||||||
// Create same codec used in txDecoder
|
// Create same codec used in txDecoder
|
||||||
codec := wire.NewCodec()
|
codec := codec.New()
|
||||||
registerTestCodec(codec)
|
registerTestCodec(codec)
|
||||||
|
|
||||||
for i := int64(0); i < nTxs; i++ {
|
for i := int64(0); i < nTxs; i++ {
|
||||||
|
@ -489,7 +489,7 @@ func TestDeliverTx(t *testing.T) {
|
||||||
app := setupBaseApp(t, anteOpt, routerOpt)
|
app := setupBaseApp(t, anteOpt, routerOpt)
|
||||||
|
|
||||||
// Create same codec used in txDecoder
|
// Create same codec used in txDecoder
|
||||||
codec := wire.NewCodec()
|
codec := codec.New()
|
||||||
registerTestCodec(codec)
|
registerTestCodec(codec)
|
||||||
|
|
||||||
nBlocks := 3
|
nBlocks := 3
|
||||||
|
@ -532,7 +532,7 @@ func TestMultiMsgDeliverTx(t *testing.T) {
|
||||||
app := setupBaseApp(t, anteOpt, routerOpt)
|
app := setupBaseApp(t, anteOpt, routerOpt)
|
||||||
|
|
||||||
// Create same codec used in txDecoder
|
// Create same codec used in txDecoder
|
||||||
codec := wire.NewCodec()
|
codec := codec.New()
|
||||||
registerTestCodec(codec)
|
registerTestCodec(codec)
|
||||||
|
|
||||||
// run a multi-msg tx
|
// run a multi-msg tx
|
||||||
|
@ -613,8 +613,8 @@ func TestSimulateTx(t *testing.T) {
|
||||||
app.InitChain(abci.RequestInitChain{})
|
app.InitChain(abci.RequestInitChain{})
|
||||||
|
|
||||||
// Create same codec used in txDecoder
|
// Create same codec used in txDecoder
|
||||||
codec := wire.NewCodec()
|
cdc := codec.New()
|
||||||
registerTestCodec(codec)
|
registerTestCodec(cdc)
|
||||||
|
|
||||||
nBlocks := 3
|
nBlocks := 3
|
||||||
for blockN := 0; blockN < nBlocks; blockN++ {
|
for blockN := 0; blockN < nBlocks; blockN++ {
|
||||||
|
@ -634,7 +634,7 @@ func TestSimulateTx(t *testing.T) {
|
||||||
require.Equal(t, gasConsumed, result.GasUsed)
|
require.Equal(t, gasConsumed, result.GasUsed)
|
||||||
|
|
||||||
// simulate by calling Query with encoded tx
|
// simulate by calling Query with encoded tx
|
||||||
txBytes, err := codec.MarshalBinary(tx)
|
txBytes, err := cdc.MarshalBinary(tx)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
query := abci.RequestQuery{
|
query := abci.RequestQuery{
|
||||||
Path: "/app/simulate",
|
Path: "/app/simulate",
|
||||||
|
@ -644,7 +644,7 @@ func TestSimulateTx(t *testing.T) {
|
||||||
require.True(t, queryResult.IsOK(), queryResult.Log)
|
require.True(t, queryResult.IsOK(), queryResult.Log)
|
||||||
|
|
||||||
var res sdk.Result
|
var res sdk.Result
|
||||||
wire.Cdc.MustUnmarshalBinary(queryResult.Value, &res)
|
codec.Cdc.MustUnmarshalBinary(queryResult.Value, &res)
|
||||||
require.Nil(t, err, "Result unmarshalling failed")
|
require.Nil(t, err, "Result unmarshalling failed")
|
||||||
require.True(t, res.IsOK(), res.Log)
|
require.True(t, res.IsOK(), res.Log)
|
||||||
require.Equal(t, gasConsumed, res.GasUsed, res.Log)
|
require.Equal(t, gasConsumed, res.GasUsed, res.Log)
|
||||||
|
@ -721,7 +721,7 @@ func TestRunInvalidTransaction(t *testing.T) {
|
||||||
tx.Msgs = append(tx.Msgs, msgNoDecode{})
|
tx.Msgs = append(tx.Msgs, msgNoDecode{})
|
||||||
|
|
||||||
// new codec so we can encode the tx, but we shouldn't be able to decode
|
// new codec so we can encode the tx, but we shouldn't be able to decode
|
||||||
newCdc := wire.NewCodec()
|
newCdc := codec.New()
|
||||||
registerTestCodec(newCdc)
|
registerTestCodec(newCdc)
|
||||||
newCdc.RegisterConcrete(&msgNoDecode{}, "cosmos-sdk/baseapp/msgNoDecode", nil)
|
newCdc.RegisterConcrete(&msgNoDecode{}, "cosmos-sdk/baseapp/msgNoDecode", nil)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
@ -22,7 +22,7 @@ const ctxAccStoreName = "acc"
|
||||||
// CLIContext implements a typical CLI context created in SDK modules for
|
// CLIContext implements a typical CLI context created in SDK modules for
|
||||||
// transaction handling and queries.
|
// transaction handling and queries.
|
||||||
type CLIContext struct {
|
type CLIContext struct {
|
||||||
Codec *wire.Codec
|
Codec *codec.Codec
|
||||||
AccDecoder auth.AccountDecoder
|
AccDecoder auth.AccountDecoder
|
||||||
Client rpcclient.Client
|
Client rpcclient.Client
|
||||||
Logger io.Writer
|
Logger io.Writer
|
||||||
|
@ -98,7 +98,7 @@ func createCertifier() tmlite.Certifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithCodec returns a copy of the context with an updated codec.
|
// WithCodec returns a copy of the context with an updated codec.
|
||||||
func (ctx CLIContext) WithCodec(cdc *wire.Codec) CLIContext {
|
func (ctx CLIContext) WithCodec(cdc *codec.Codec) CLIContext {
|
||||||
ctx.Codec = cdc
|
ctx.Codec = cdc
|
||||||
return ctx
|
return ctx
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ import (
|
||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/store"
|
"github.com/cosmos/cosmos-sdk/store"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
cmn "github.com/tendermint/tendermint/libs/common"
|
cmn "github.com/tendermint/tendermint/libs/common"
|
||||||
tmliteProxy "github.com/tendermint/tendermint/lite/proxy"
|
tmliteProxy "github.com/tendermint/tendermint/lite/proxy"
|
||||||
|
@ -343,7 +343,7 @@ func (ctx CLIContext) verifyProof(path string, resp abci.ResponseQuery) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var multiStoreProof store.MultiStoreProof
|
var multiStoreProof store.MultiStoreProof
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
err = cdc.UnmarshalBinary(resp.Proof, &multiStoreProof)
|
err = cdc.UnmarshalBinary(resp.Proof, &multiStoreProof)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to unmarshalBinary rangeProof")
|
return errors.Wrap(err, "failed to unmarshalBinary rangeProof")
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package keys
|
package keys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cdc *wire.Codec
|
var cdc *codec.Codec
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cdc = wire.NewCodec()
|
cdc = codec.New()
|
||||||
wire.RegisterCrypto(cdc)
|
codec.RegisterCrypto(cdc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// marshal keys
|
// marshal keys
|
|
@ -22,9 +22,9 @@ import (
|
||||||
client "github.com/cosmos/cosmos-sdk/client"
|
client "github.com/cosmos/cosmos-sdk/client"
|
||||||
keys "github.com/cosmos/cosmos-sdk/client/keys"
|
keys "github.com/cosmos/cosmos-sdk/client/keys"
|
||||||
rpc "github.com/cosmos/cosmos-sdk/client/rpc"
|
rpc "github.com/cosmos/cosmos-sdk/client/rpc"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
tests "github.com/cosmos/cosmos-sdk/tests"
|
tests "github.com/cosmos/cosmos-sdk/tests"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
||||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||||
|
@ -61,7 +61,7 @@ func TestKeys(t *testing.T) {
|
||||||
|
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
var resp keys.KeyOutput
|
var resp keys.KeyOutput
|
||||||
err = wire.Cdc.UnmarshalJSON([]byte(body), &resp)
|
err = codec.Cdc.UnmarshalJSON([]byte(body), &resp)
|
||||||
require.Nil(t, err, body)
|
require.Nil(t, err, body)
|
||||||
|
|
||||||
addr2Bech32 := resp.Address
|
addr2Bech32 := resp.Address
|
||||||
|
@ -181,7 +181,7 @@ func TestBlock(t *testing.T) {
|
||||||
res, body = Request(t, port, "GET", "/blocks/1", nil)
|
res, body = Request(t, port, "GET", "/blocks/1", nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
err = wire.Cdc.UnmarshalJSON([]byte(body), &resultBlock)
|
err = codec.Cdc.UnmarshalJSON([]byte(body), &resultBlock)
|
||||||
require.Nil(t, err, "Couldn't parse block")
|
require.Nil(t, err, "Couldn't parse block")
|
||||||
|
|
||||||
require.NotEqual(t, ctypes.ResultBlock{}, resultBlock)
|
require.NotEqual(t, ctypes.ResultBlock{}, resultBlock)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/client/keys"
|
"github.com/cosmos/cosmos-sdk/client/keys"
|
||||||
"github.com/cosmos/cosmos-sdk/client/rpc"
|
"github.com/cosmos/cosmos-sdk/client/rpc"
|
||||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
auth "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
auth "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/client/rest"
|
bank "github.com/cosmos/cosmos-sdk/x/bank/client/rest"
|
||||||
gov "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
|
gov "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
|
||||||
|
@ -27,7 +27,7 @@ import (
|
||||||
// ServeCommand will generate a long-running rest server
|
// ServeCommand will generate a long-running rest server
|
||||||
// (aka Light Client Daemon) that exposes functionality similar
|
// (aka Light Client Daemon) that exposes functionality similar
|
||||||
// to the cli, but over rest
|
// to the cli, but over rest
|
||||||
func ServeCommand(cdc *wire.Codec) *cobra.Command {
|
func ServeCommand(cdc *codec.Codec) *cobra.Command {
|
||||||
flagListenAddr := "laddr"
|
flagListenAddr := "laddr"
|
||||||
flagCORS := "cors"
|
flagCORS := "cors"
|
||||||
flagMaxOpenConnections := "max-open"
|
flagMaxOpenConnections := "max-open"
|
||||||
|
@ -71,7 +71,7 @@ func ServeCommand(cdc *wire.Codec) *cobra.Command {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func createHandler(cdc *wire.Codec) http.Handler {
|
func createHandler(cdc *codec.Codec) http.Handler {
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
|
|
||||||
kb, err := keys.GetKeyBase() //XXX
|
kb, err := keys.GetKeyBase() //XXX
|
||||||
|
|
|
@ -15,11 +15,11 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
keys "github.com/cosmos/cosmos-sdk/client/keys"
|
keys "github.com/cosmos/cosmos-sdk/client/keys"
|
||||||
gapp "github.com/cosmos/cosmos-sdk/cmd/gaia/app"
|
gapp "github.com/cosmos/cosmos-sdk/cmd/gaia/app"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
crkeys "github.com/cosmos/cosmos-sdk/crypto/keys"
|
crkeys "github.com/cosmos/cosmos-sdk/crypto/keys"
|
||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
"github.com/cosmos/cosmos-sdk/tests"
|
"github.com/cosmos/cosmos-sdk/tests"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
@ -176,7 +176,7 @@ func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.AccAddress
|
||||||
genesisState.StakeData.Pool.LooseTokens = genesisState.StakeData.Pool.LooseTokens.Add(sdk.NewDec(100))
|
genesisState.StakeData.Pool.LooseTokens = genesisState.StakeData.Pool.LooseTokens.Add(sdk.NewDec(100))
|
||||||
}
|
}
|
||||||
|
|
||||||
appState, err := wire.MarshalJSONIndent(cdc, genesisState)
|
appState, err := codec.MarshalJSONIndent(cdc, genesisState)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
genDoc.AppState = appState
|
genDoc.AppState = appState
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ func startTM(
|
||||||
// startLCD starts the LCD.
|
// startLCD starts the LCD.
|
||||||
//
|
//
|
||||||
// NOTE: This causes the thread to block.
|
// NOTE: This causes the thread to block.
|
||||||
func startLCD(logger log.Logger, listenAddr string, cdc *wire.Codec) (net.Listener, error) {
|
func startLCD(logger log.Logger, listenAddr string, cdc *codec.Codec) (net.Listener, error) {
|
||||||
return tmrpc.StartHTTPServer(listenAddr, createHandler(cdc), logger, tmrpc.Config{})
|
return tmrpc.StartHTTPServer(listenAddr, createHandler(cdc), logger, tmrpc.Config{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ func getBlock(cliCtx context.CLIContext, height *int64) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO move maarshalling into cmd/rest functions
|
// TODO move maarshalling into cmd/rest functions
|
||||||
// output, err := tmwire.MarshalJSON(res)
|
// output, err := tmcodec.MarshalJSON(res)
|
||||||
output, err := cdc.MarshalJSON(res)
|
output, err := cdc.MarshalJSON(res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -16,13 +16,13 @@ import (
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
)
|
)
|
||||||
|
|
||||||
// QueryTxCmd implements the default command for a tx query.
|
// QueryTxCmd implements the default command for a tx query.
|
||||||
func QueryTxCmd(cdc *wire.Codec) *cobra.Command {
|
func QueryTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "tx [hash]",
|
Use: "tx [hash]",
|
||||||
Short: "Matches this txhash over all committed blocks",
|
Short: "Matches this txhash over all committed blocks",
|
||||||
|
@ -51,7 +51,7 @@ func QueryTxCmd(cdc *wire.Codec) *cobra.Command {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func queryTx(cdc *wire.Codec, cliCtx context.CLIContext, hashHexStr string, trustNode bool) ([]byte, error) {
|
func queryTx(cdc *codec.Codec, cliCtx context.CLIContext, hashHexStr string, trustNode bool) ([]byte, error) {
|
||||||
hash, err := hex.DecodeString(hashHexStr)
|
hash, err := hex.DecodeString(hashHexStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -72,10 +72,10 @@ func queryTx(cdc *wire.Codec, cliCtx context.CLIContext, hashHexStr string, trus
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return wire.MarshalJSONIndent(cdc, info)
|
return codec.MarshalJSONIndent(cdc, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatTxResult(cdc *wire.Codec, res *ctypes.ResultTx) (Info, error) {
|
func formatTxResult(cdc *codec.Codec, res *ctypes.ResultTx) (Info, error) {
|
||||||
// TODO: verify the proof if requested
|
// TODO: verify the proof if requested
|
||||||
tx, err := parseTx(cdc, res.Tx)
|
tx, err := parseTx(cdc, res.Tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -98,7 +98,7 @@ type Info struct {
|
||||||
Result abci.ResponseDeliverTx `json:"result"`
|
Result abci.ResponseDeliverTx `json:"result"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTx(cdc *wire.Codec, txBytes []byte) (sdk.Tx, error) {
|
func parseTx(cdc *codec.Codec, txBytes []byte) (sdk.Tx, error) {
|
||||||
var tx auth.StdTx
|
var tx auth.StdTx
|
||||||
|
|
||||||
err := cdc.UnmarshalBinary(txBytes, &tx)
|
err := cdc.UnmarshalBinary(txBytes, &tx)
|
||||||
|
@ -112,7 +112,7 @@ func parseTx(cdc *wire.Codec, txBytes []byte) (sdk.Tx, error) {
|
||||||
// REST
|
// REST
|
||||||
|
|
||||||
// transaction query REST handler
|
// transaction query REST handler
|
||||||
func QueryTxRequestHandlerFn(cdc *wire.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
func QueryTxRequestHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
hashHexStr := vars["hash"]
|
hashHexStr := vars["hash"]
|
||||||
|
|
|
@ -5,11 +5,11 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddCommands adds a number of tx-query related subcommands
|
// AddCommands adds a number of tx-query related subcommands
|
||||||
func AddCommands(cmd *cobra.Command, cdc *wire.Codec) {
|
func AddCommands(cmd *cobra.Command, cdc *codec.Codec) {
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
SearchTxCmd(cdc),
|
SearchTxCmd(cdc),
|
||||||
QueryTxCmd(cdc),
|
QueryTxCmd(cdc),
|
||||||
|
@ -17,7 +17,7 @@ func AddCommands(cmd *cobra.Command, cdc *wire.Codec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// register REST routes
|
// register REST routes
|
||||||
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *wire.Codec) {
|
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec) {
|
||||||
r.HandleFunc("/txs/{hash}", QueryTxRequestHandlerFn(cdc, cliCtx)).Methods("GET")
|
r.HandleFunc("/txs/{hash}", QueryTxRequestHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||||
r.HandleFunc("/txs", SearchTxRequestHandlerFn(cliCtx, cdc)).Methods("GET")
|
r.HandleFunc("/txs", SearchTxRequestHandlerFn(cliCtx, cdc)).Methods("GET")
|
||||||
// r.HandleFunc("/txs/sign", SignTxRequstHandler).Methods("POST")
|
// r.HandleFunc("/txs/sign", SignTxRequstHandler).Methods("POST")
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
@ -24,7 +24,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// default client command to search through tagged transactions
|
// default client command to search through tagged transactions
|
||||||
func SearchTxCmd(cdc *wire.Codec) *cobra.Command {
|
func SearchTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "txs",
|
Use: "txs",
|
||||||
Short: "Search for all transactions that match the given tags.",
|
Short: "Search for all transactions that match the given tags.",
|
||||||
|
@ -70,7 +70,7 @@ $ gaiacli tendermint txs --tag test1,test2 --any
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchTxs(cliCtx context.CLIContext, cdc *wire.Codec, tags []string) ([]Info, error) {
|
func searchTxs(cliCtx context.CLIContext, cdc *codec.Codec, tags []string) ([]Info, error) {
|
||||||
if len(tags) == 0 {
|
if len(tags) == 0 {
|
||||||
return nil, errors.New("must declare at least one tag to search")
|
return nil, errors.New("must declare at least one tag to search")
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ func searchTxs(cliCtx context.CLIContext, cdc *wire.Codec, tags []string) ([]Inf
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse the indexed txs into an array of Info
|
// parse the indexed txs into an array of Info
|
||||||
func FormatTxResults(cdc *wire.Codec, res []*ctypes.ResultTx) ([]Info, error) {
|
func FormatTxResults(cdc *codec.Codec, res []*ctypes.ResultTx) ([]Info, error) {
|
||||||
var err error
|
var err error
|
||||||
out := make([]Info, len(res))
|
out := make([]Info, len(res))
|
||||||
for i := range res {
|
for i := range res {
|
||||||
|
@ -119,7 +119,7 @@ func FormatTxResults(cdc *wire.Codec, res []*ctypes.ResultTx) ([]Info, error) {
|
||||||
// REST
|
// REST
|
||||||
|
|
||||||
// Search Tx REST Handler
|
// Search Tx REST Handler
|
||||||
func SearchTxRequestHandlerFn(cliCtx context.CLIContext, cdc *wire.Codec) http.HandlerFunc {
|
func SearchTxRequestHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
tag := r.FormValue("tag")
|
tag := r.FormValue("tag")
|
||||||
if tag == "" {
|
if tag == "" {
|
||||||
|
|
|
@ -12,8 +12,8 @@ import (
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
|
|
||||||
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||||
|
@ -36,7 +36,7 @@ var (
|
||||||
// Extended ABCI application
|
// Extended ABCI application
|
||||||
type GaiaApp struct {
|
type GaiaApp struct {
|
||||||
*bam.BaseApp
|
*bam.BaseApp
|
||||||
cdc *wire.Codec
|
cdc *codec.Codec
|
||||||
|
|
||||||
// keys to access the substores
|
// keys to access the substores
|
||||||
keyMain *sdk.KVStoreKey
|
keyMain *sdk.KVStoreKey
|
||||||
|
@ -128,16 +128,16 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
|
||||||
}
|
}
|
||||||
|
|
||||||
// custom tx codec
|
// custom tx codec
|
||||||
func MakeCodec() *wire.Codec {
|
func MakeCodec() *codec.Codec {
|
||||||
var cdc = wire.NewCodec()
|
var cdc = codec.New()
|
||||||
ibc.RegisterWire(cdc)
|
ibc.RegisterCodec(cdc)
|
||||||
bank.RegisterWire(cdc)
|
bank.RegisterCodec(cdc)
|
||||||
stake.RegisterWire(cdc)
|
stake.RegisterCodec(cdc)
|
||||||
slashing.RegisterWire(cdc)
|
slashing.RegisterCodec(cdc)
|
||||||
gov.RegisterWire(cdc)
|
gov.RegisterCodec(cdc)
|
||||||
auth.RegisterWire(cdc)
|
auth.RegisterCodec(cdc)
|
||||||
sdk.RegisterWire(cdc)
|
sdk.RegisterCodec(cdc)
|
||||||
wire.RegisterCrypto(cdc)
|
codec.RegisterCrypto(cdc)
|
||||||
return cdc
|
return cdc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ func (app *GaiaApp) ExportAppStateAndValidators() (appState json.RawMessage, val
|
||||||
StakeData: stake.WriteGenesis(ctx, app.stakeKeeper),
|
StakeData: stake.WriteGenesis(ctx, app.stakeKeeper),
|
||||||
GovData: gov.WriteGenesis(ctx, app.govKeeper),
|
GovData: gov.WriteGenesis(ctx, app.govKeeper),
|
||||||
}
|
}
|
||||||
appState, err = wire.MarshalJSONIndent(app.cdc, genState)
|
appState, err = codec.MarshalJSONIndent(app.cdc, genState)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/stake"
|
"github.com/cosmos/cosmos-sdk/x/stake"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -25,7 +25,7 @@ func setGenesis(gapp *GaiaApp, accs ...*auth.BaseAccount) error {
|
||||||
StakeData: stake.DefaultGenesisState(),
|
StakeData: stake.DefaultGenesisState(),
|
||||||
}
|
}
|
||||||
|
|
||||||
stateBytes, err := wire.MarshalJSONIndent(gapp.cdc, genesisState)
|
stateBytes, err := codec.MarshalJSONIndent(gapp.cdc, genesisState)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
"github.com/cosmos/cosmos-sdk/server/config"
|
"github.com/cosmos/cosmos-sdk/server/config"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||||
"github.com/cosmos/cosmos-sdk/x/stake"
|
"github.com/cosmos/cosmos-sdk/x/stake"
|
||||||
|
@ -92,7 +92,7 @@ type GaiaGenTx struct {
|
||||||
|
|
||||||
// GaiaAppGenTx generates a Gaia genesis transaction.
|
// GaiaAppGenTx generates a Gaia genesis transaction.
|
||||||
func GaiaAppGenTx(
|
func GaiaAppGenTx(
|
||||||
cdc *wire.Codec, pk crypto.PubKey, genTxConfig config.GenTx,
|
cdc *codec.Codec, pk crypto.PubKey, genTxConfig config.GenTx,
|
||||||
) (appGenTx, cliPrint json.RawMessage, validator tmtypes.GenesisValidator, err error) {
|
) (appGenTx, cliPrint json.RawMessage, validator tmtypes.GenesisValidator, err error) {
|
||||||
if genTxConfig.Name == "" {
|
if genTxConfig.Name == "" {
|
||||||
return nil, nil, tmtypes.GenesisValidator{}, errors.New("Must specify --name (validator moniker)")
|
return nil, nil, tmtypes.GenesisValidator{}, errors.New("Must specify --name (validator moniker)")
|
||||||
|
@ -136,7 +136,7 @@ func GaiaAppGenTx(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a gaia genesis transaction without flags
|
// Generate a gaia genesis transaction without flags
|
||||||
func GaiaAppGenTxNF(cdc *wire.Codec, pk crypto.PubKey, addr sdk.AccAddress, name string) (
|
func GaiaAppGenTxNF(cdc *codec.Codec, pk crypto.PubKey, addr sdk.AccAddress, name string) (
|
||||||
appGenTx, cliPrint json.RawMessage, validator tmtypes.GenesisValidator, err error) {
|
appGenTx, cliPrint json.RawMessage, validator tmtypes.GenesisValidator, err error) {
|
||||||
|
|
||||||
var bz []byte
|
var bz []byte
|
||||||
|
@ -145,7 +145,7 @@ func GaiaAppGenTxNF(cdc *wire.Codec, pk crypto.PubKey, addr sdk.AccAddress, name
|
||||||
Address: addr,
|
Address: addr,
|
||||||
PubKey: sdk.MustBech32ifyConsPub(pk),
|
PubKey: sdk.MustBech32ifyConsPub(pk),
|
||||||
}
|
}
|
||||||
bz, err = wire.MarshalJSONIndent(cdc, gaiaGenTx)
|
bz, err = codec.MarshalJSONIndent(cdc, gaiaGenTx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ func GaiaAppGenTxNF(cdc *wire.Codec, pk crypto.PubKey, addr sdk.AccAddress, name
|
||||||
|
|
||||||
// Create the core parameters for genesis initialization for gaia
|
// Create the core parameters for genesis initialization for gaia
|
||||||
// note that the pubkey input is this machines pubkey
|
// note that the pubkey input is this machines pubkey
|
||||||
func GaiaAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (genesisState GenesisState, err error) {
|
func GaiaAppGenState(cdc *codec.Codec, appGenTxs []json.RawMessage) (genesisState GenesisState, err error) {
|
||||||
|
|
||||||
if len(appGenTxs) == 0 {
|
if len(appGenTxs) == 0 {
|
||||||
err = errors.New("must provide at least genesis transaction")
|
err = errors.New("must provide at least genesis transaction")
|
||||||
|
@ -280,13 +280,13 @@ func validateGenesisStateAccounts(accs []GenesisAccount) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GaiaAppGenState but with JSON
|
// GaiaAppGenState but with JSON
|
||||||
func GaiaAppGenStateJSON(cdc *wire.Codec, appGenTxs []json.RawMessage) (appState json.RawMessage, err error) {
|
func GaiaAppGenStateJSON(cdc *codec.Codec, appGenTxs []json.RawMessage) (appState json.RawMessage, err error) {
|
||||||
|
|
||||||
// create the final app state
|
// create the final app state
|
||||||
genesisState, err := GaiaAppGenState(cdc, appGenTxs)
|
genesisState, err := GaiaAppGenState(cdc, appGenTxs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
appState, err = wire.MarshalJSONIndent(cdc, genesisState)
|
appState, err = codec.MarshalJSONIndent(cdc, genesisState)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,10 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/keys"
|
"github.com/cosmos/cosmos-sdk/client/keys"
|
||||||
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
|
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
"github.com/cosmos/cosmos-sdk/tests"
|
"github.com/cosmos/cosmos-sdk/tests"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||||
"github.com/cosmos/cosmos-sdk/x/stake"
|
"github.com/cosmos/cosmos-sdk/x/stake"
|
||||||
|
@ -549,8 +549,8 @@ func executeGetAccount(t *testing.T, cmdStr string) auth.BaseAccount {
|
||||||
require.NoError(t, err, "out %v, err %v", out, err)
|
require.NoError(t, err, "out %v, err %v", out, err)
|
||||||
value := initRes["value"]
|
value := initRes["value"]
|
||||||
var acc auth.BaseAccount
|
var acc auth.BaseAccount
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
wire.RegisterCrypto(cdc)
|
codec.RegisterCrypto(cdc)
|
||||||
err = cdc.UnmarshalJSON(value, &acc)
|
err = cdc.UnmarshalJSON(value, &acc)
|
||||||
require.NoError(t, err, "value %v, err %v", string(value), err)
|
require.NoError(t, err, "value %v, err %v", string(value), err)
|
||||||
return acc
|
return acc
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||||
|
@ -127,7 +127,7 @@ var (
|
||||||
// Extended ABCI application
|
// Extended ABCI application
|
||||||
type GaiaApp struct {
|
type GaiaApp struct {
|
||||||
*bam.BaseApp
|
*bam.BaseApp
|
||||||
cdc *wire.Codec
|
cdc *codec.Codec
|
||||||
|
|
||||||
// keys to access the substores
|
// keys to access the substores
|
||||||
keyMain *sdk.KVStoreKey
|
keyMain *sdk.KVStoreKey
|
||||||
|
@ -204,15 +204,15 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.BaseAp
|
||||||
}
|
}
|
||||||
|
|
||||||
// custom tx codec
|
// custom tx codec
|
||||||
func MakeCodec() *wire.Codec {
|
func MakeCodec() *codec.Codec {
|
||||||
var cdc = wire.NewCodec()
|
var cdc = codec.New()
|
||||||
ibc.RegisterWire(cdc)
|
ibc.RegisterCodec(cdc)
|
||||||
bank.RegisterWire(cdc)
|
bank.RegisterCodec(cdc)
|
||||||
stake.RegisterWire(cdc)
|
stake.RegisterCodec(cdc)
|
||||||
slashing.RegisterWire(cdc)
|
slashing.RegisterCodec(cdc)
|
||||||
auth.RegisterWire(cdc)
|
auth.RegisterCodec(cdc)
|
||||||
sdk.RegisterWire(cdc)
|
sdk.RegisterCodec(cdc)
|
||||||
wire.RegisterCrypto(cdc)
|
codec.RegisterCrypto(cdc)
|
||||||
cdc.Seal()
|
cdc.Seal()
|
||||||
return cdc
|
return cdc
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package wire
|
package codec
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -11,7 +11,7 @@ import (
|
||||||
// amino codec to marshal/unmarshal
|
// amino codec to marshal/unmarshal
|
||||||
type Codec = amino.Codec
|
type Codec = amino.Codec
|
||||||
|
|
||||||
func NewCodec() *Codec {
|
func New() *Codec {
|
||||||
cdc := amino.NewCodec()
|
cdc := amino.NewCodec()
|
||||||
return cdc
|
return cdc
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ func MarshalJSONIndent(cdc *Codec, obj interface{}) ([]byte, error) {
|
||||||
var Cdc *Codec
|
var Cdc *Codec
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cdc := NewCodec()
|
cdc := New()
|
||||||
RegisterCrypto(cdc)
|
RegisterCrypto(cdc)
|
||||||
Cdc = cdc.Seal()
|
Cdc = cdc.Seal()
|
||||||
}
|
}
|
|
@ -139,8 +139,8 @@ Amino can also be used for persistent storage of interfaces.
|
||||||
To use Amino, simply create a codec, and then register types:
|
To use Amino, simply create a codec, and then register types:
|
||||||
|
|
||||||
```
|
```
|
||||||
func NewCodec() *wire.Codec {
|
func NewCodec() *codec.Codec {
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
cdc.RegisterInterface((*sdk.Msg)(nil), nil)
|
cdc.RegisterInterface((*sdk.Msg)(nil), nil)
|
||||||
cdc.RegisterConcrete(MsgSend{}, "example/MsgSend", nil)
|
cdc.RegisterConcrete(MsgSend{}, "example/MsgSend", nil)
|
||||||
cdc.RegisterConcrete(MsgIssue{}, "example/MsgIssue", nil)
|
cdc.RegisterConcrete(MsgIssue{}, "example/MsgIssue", nil)
|
||||||
|
@ -175,7 +175,7 @@ func (tx app2Tx) GetMsgs() []sdk.Msg {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Amino decode app2Tx. Capable of decoding both MsgSend and MsgIssue
|
// Amino decode app2Tx. Capable of decoding both MsgSend and MsgIssue
|
||||||
func tx2Decoder(cdc *wire.Codec) sdk.TxDecoder {
|
func tx2Decoder(cdc *codec.Codec) sdk.TxDecoder {
|
||||||
return func(txBytes []byte) (sdk.Tx, sdk.Error) {
|
return func(txBytes []byte) (sdk.Tx, sdk.Error) {
|
||||||
var tx app2Tx
|
var tx app2Tx
|
||||||
err := cdc.UnmarshalBinary(txBytes, &tx)
|
err := cdc.UnmarshalBinary(txBytes, &tx)
|
||||||
|
|
|
@ -13,8 +13,8 @@ import (
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
|
||||||
bapp "github.com/cosmos/cosmos-sdk/baseapp"
|
bapp "github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -25,8 +25,8 @@ var (
|
||||||
issuer = ed25519.GenPrivKey().PubKey().Address()
|
issuer = ed25519.GenPrivKey().PubKey().Address()
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewCodec() *wire.Codec {
|
func NewCodec() *codec.Codec {
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
cdc.RegisterInterface((*sdk.Msg)(nil), nil)
|
cdc.RegisterInterface((*sdk.Msg)(nil), nil)
|
||||||
cdc.RegisterConcrete(MsgSend{}, "example/MsgSend", nil)
|
cdc.RegisterConcrete(MsgSend{}, "example/MsgSend", nil)
|
||||||
cdc.RegisterConcrete(MsgIssue{}, "example/MsgIssue", nil)
|
cdc.RegisterConcrete(MsgIssue{}, "example/MsgIssue", nil)
|
||||||
|
@ -196,7 +196,7 @@ func (tx app2Tx) GetSignature() []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Amino decode app2Tx. Capable of decoding both MsgSend and MsgIssue
|
// Amino decode app2Tx. Capable of decoding both MsgSend and MsgIssue
|
||||||
func tx2Decoder(cdc *wire.Codec) sdk.TxDecoder {
|
func tx2Decoder(cdc *codec.Codec) sdk.TxDecoder {
|
||||||
return func(txBytes []byte) (sdk.Tx, sdk.Error) {
|
return func(txBytes []byte) (sdk.Tx, sdk.Error) {
|
||||||
var tx app2Tx
|
var tx app2Tx
|
||||||
err := cdc.UnmarshalBinary(txBytes, &tx)
|
err := cdc.UnmarshalBinary(txBytes, &tx)
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
|
||||||
bapp "github.com/cosmos/cosmos-sdk/baseapp"
|
bapp "github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
)
|
)
|
||||||
|
@ -51,12 +51,12 @@ func NewApp3(logger log.Logger, db dbm.DB) *bapp.BaseApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update codec from app2 to register imported modules
|
// Update codec from app2 to register imported modules
|
||||||
func UpdatedCodec() *wire.Codec {
|
func UpdatedCodec() *codec.Codec {
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
cdc.RegisterInterface((*sdk.Msg)(nil), nil)
|
cdc.RegisterInterface((*sdk.Msg)(nil), nil)
|
||||||
cdc.RegisterConcrete(MsgSend{}, "example/MsgSend", nil)
|
cdc.RegisterConcrete(MsgSend{}, "example/MsgSend", nil)
|
||||||
cdc.RegisterConcrete(MsgIssue{}, "example/MsgIssue", nil)
|
cdc.RegisterConcrete(MsgIssue{}, "example/MsgIssue", nil)
|
||||||
auth.RegisterWire(cdc)
|
auth.RegisterCodec(cdc)
|
||||||
cryptoAmino.RegisterAmino(cdc)
|
cryptoAmino.RegisterAmino(cdc)
|
||||||
return cdc
|
return cdc
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
|
||||||
bapp "github.com/cosmos/cosmos-sdk/baseapp"
|
bapp "github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
)
|
)
|
||||||
|
@ -76,7 +76,7 @@ func (ga *GenesisAccount) ToAccount() (acc *auth.BaseAccount, err error) {
|
||||||
|
|
||||||
// InitChainer will set initial balances for accounts as well as initial coin metadata
|
// InitChainer will set initial balances for accounts as well as initial coin metadata
|
||||||
// MsgIssue can no longer be used to create new coin
|
// MsgIssue can no longer be used to create new coin
|
||||||
func NewInitChainer(cdc *wire.Codec, accountMapper auth.AccountMapper) sdk.InitChainer {
|
func NewInitChainer(cdc *codec.Codec, accountMapper auth.AccountMapper) sdk.InitChainer {
|
||||||
return func(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
|
return func(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
|
||||||
stateJSON := req.AppStateBytes
|
stateJSON := req.AppStateBytes
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
Finally, we need to define the `MakeCodec()` function and register the concrete types and interface from the various modules.
|
Finally, we need to define the `MakeCodec()` function and register the concrete types and interface from the various modules.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func MakeCodec() *wire.Codec {
|
func MakeCodec() *codec.Codec {
|
||||||
var cdc = wire.NewCodec()
|
var cdc = codec.New()
|
||||||
wire.RegisterCrypto(cdc) // Register crypto.
|
codec.RegisterCrypto(cdc) // Register crypto.
|
||||||
sdk.RegisterWire(cdc) // Register Msgs
|
sdk.RegisterCodec(cdc) // Register Msgs
|
||||||
bank.RegisterWire(cdc)
|
bank.RegisterCodec(cdc)
|
||||||
simplestake.RegisterWire(cdc)
|
simplestake.RegisterCodec(cdc)
|
||||||
simpleGov.RegisterWire(cdc)
|
simpleGov.RegisterCodec(cdc)
|
||||||
|
|
||||||
// Register AppAccount
|
// Register AppAccount
|
||||||
cdc.RegisterInterface((*auth.Account)(nil), nil)
|
cdc.RegisterInterface((*auth.Account)(nil), nil)
|
||||||
|
|
|
@ -13,7 +13,7 @@ var SimpleGovAppInit = server.AppInit{
|
||||||
}
|
}
|
||||||
|
|
||||||
// SimpleGovAppGenState sets up the app_state and appends the simpleGov app state
|
// SimpleGovAppGenState sets up the app_state and appends the simpleGov app state
|
||||||
func SimpleGovAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (appState json.RawMessage, err error) {
|
func SimpleGovAppGenState(cdc *codec.Codec, appGenTxs []json.RawMessage) (appState json.RawMessage, err error) {
|
||||||
appState, err = server.SimpleAppGenState(cdc, appGenTxs)
|
appState, err = server.SimpleAppGenState(cdc, appGenTxs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
@ -28,7 +28,7 @@ Then, let us define the structure of our application.
|
||||||
// Extended ABCI application
|
// Extended ABCI application
|
||||||
type SimpleGovApp struct {
|
type SimpleGovApp struct {
|
||||||
*bam.BaseApp
|
*bam.BaseApp
|
||||||
cdc *wire.Codec
|
cdc *codec.Codec
|
||||||
|
|
||||||
// keys to access the substores
|
// keys to access the substores
|
||||||
capKeyMainStore *sdk.KVStoreKey
|
capKeyMainStore *sdk.KVStoreKey
|
||||||
|
|
|
@ -28,7 +28,7 @@ Before getting in the bulk of the code, we will start by some introductory conte
|
||||||
+ [Types](module-types.md)
|
+ [Types](module-types.md)
|
||||||
+ [Keeper](module-keeper.md)
|
+ [Keeper](module-keeper.md)
|
||||||
+ [Handler](module-handler.md)
|
+ [Handler](module-handler.md)
|
||||||
+ [Wire](module-wire.md)
|
+ [Wire](module-codec.md)
|
||||||
+ [Errors](module-errors.md)
|
+ [Errors](module-errors.md)
|
||||||
+ Command-Line Interface and Rest API
|
+ Command-Line Interface and Rest API
|
||||||
* [Command-Line Interface](module-cli.md)
|
* [Command-Line Interface](module-cli.md)
|
||||||
|
|
|
@ -14,7 +14,7 @@ The CLI builds on top of [Cobra](https://github.com/spf13/cobra). Here is the sc
|
||||||
)
|
)
|
||||||
|
|
||||||
// Main command function. One function for each command.
|
// Main command function. One function for each command.
|
||||||
func Command(codec *wire.Codec) *cobra.Command {
|
func Command(codec *codec.Codec) *cobra.Command {
|
||||||
// Create the command to return
|
// Create the command to return
|
||||||
command := &cobra.Command{
|
command := &cobra.Command{
|
||||||
Use: "actual command",
|
Use: "actual command",
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
## Codec
|
||||||
|
|
||||||
|
**File: [`x/simple_governance/codec.go`](https://github.com/cosmos/cosmos-sdk/blob/fedekunze/module_tutorial/examples/simpleGov/x/simple_governance/codec.go)**
|
||||||
|
|
||||||
|
The `codec.go` file allows developers to register the concrete message types of their module into the codec. In our case, we have two messages to declare:
|
||||||
|
|
||||||
|
```go
|
||||||
|
func RegisterCodec(cdc *codec.Codec) {
|
||||||
|
cdc.RegisterConcrete(SubmitProposalMsg{}, "simple_governance/SubmitProposalMsg", nil)
|
||||||
|
cdc.RegisterConcrete(VoteMsg{}, "simple_governance/VoteMsg", nil)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Don't forget to call this function in `app.go` (see [Application - Bridging it all together](app-structure.md)) for more).
|
|
@ -7,7 +7,7 @@ cd x/
|
||||||
mkdir simple_governance
|
mkdir simple_governance
|
||||||
cd simple_governance
|
cd simple_governance
|
||||||
mkdir -p client/cli client/rest
|
mkdir -p client/cli client/rest
|
||||||
touch client/cli/simple_governance.go client/rest/simple_governance.go errors.go handler.go handler_test.go keeper_keys.go keeper_test.go keeper.go test_common.go test_types.go types.go wire.go
|
touch client/cli/simple_governance.go client/rest/simple_governance.go errors.go handler.go handler_test.go keeper_keys.go keeper_test.go keeper.go test_common.go test_types.go types.go codec.go
|
||||||
```
|
```
|
||||||
|
|
||||||
Let us start by adding the files we will need. Your module's folder should look something like that:
|
Let us start by adding the files we will need. Your module's folder should look something like that:
|
||||||
|
@ -25,7 +25,7 @@ x
|
||||||
├─── keeper_keys.go
|
├─── keeper_keys.go
|
||||||
├─── keeper.go
|
├─── keeper.go
|
||||||
├─── types.go
|
├─── types.go
|
||||||
└─── wire.go
|
└─── codec.go
|
||||||
```
|
```
|
||||||
|
|
||||||
Let us go into the detail of each of these files.
|
Let us go into the detail of each of these files.
|
|
@ -47,7 +47,7 @@ With all that in mind, we can define the structure of our `Keeper`:
|
||||||
```go
|
```go
|
||||||
type Keeper struct {
|
type Keeper struct {
|
||||||
SimpleGov sdk.StoreKey // Key to our module's store
|
SimpleGov sdk.StoreKey // Key to our module's store
|
||||||
cdc *wire.Codec // Codec to encore/decode structs
|
cdc *codec.Codec // Codec to encore/decode structs
|
||||||
ck bank.Keeper // Needed to handle deposits. This module onlyl requires read/writes to Atom balance
|
ck bank.Keeper // Needed to handle deposits. This module onlyl requires read/writes to Atom balance
|
||||||
sm stake.Keeper // Needed to compute voting power. This module only needs read access to the staking store.
|
sm stake.Keeper // Needed to compute voting power. This module only needs read access to the staking store.
|
||||||
codespace sdk.CodespaceType // Reserves space for error codes
|
codespace sdk.CodespaceType // Reserves space for error codes
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
## Wire
|
|
||||||
|
|
||||||
**File: [`x/simple_governance/wire.go`](https://github.com/cosmos/cosmos-sdk/blob/fedekunze/module_tutorial/examples/simpleGov/x/simple_governance/wire.go)**
|
|
||||||
|
|
||||||
The `wire.go` file allows developers to register the concrete message types of their module into the codec. In our case, we have two messages to declare:
|
|
||||||
|
|
||||||
```go
|
|
||||||
func RegisterWire(cdc *wire.Codec) {
|
|
||||||
cdc.RegisterConcrete(SubmitProposalMsg{}, "simple_governance/SubmitProposalMsg", nil)
|
|
||||||
cdc.RegisterConcrete(VoteMsg{}, "simple_governance/VoteMsg", nil)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
Don't forget to call this function in `app.go` (see [Application - Bridging it all together](app-structure.md)) for more).
|
|
|
@ -8,7 +8,7 @@ The specification has focused on semantics and functionality of the IBC protocol
|
||||||
|
|
||||||
In defining a standard binary encoding for all the "universal" components, we wish to make use of a standardized library, with efficient serialization and support in multiple languages. We considered two main formats: Ethereum's RLP[[6](./references.md#6)] and Google's Protobuf[[7](./references.md#7)]. We decided for protobuf, as it is more widely supported, is more expressive for different data types, and supports code generation for very efficient (de)serialization codecs. It does have a learning curve and more setup to generate the code from the type specifications, but the ibc data types should not change often and this code generation setup only needs to happen once per language (and can be exposed in a common repo), so this is not a strong counter-argument. Efficiency, expressiveness, and wider support rule in its favor. It is also widely used in gRPC and in many microservice architectures.
|
In defining a standard binary encoding for all the "universal" components, we wish to make use of a standardized library, with efficient serialization and support in multiple languages. We considered two main formats: Ethereum's RLP[[6](./references.md#6)] and Google's Protobuf[[7](./references.md#7)]. We decided for protobuf, as it is more widely supported, is more expressive for different data types, and supports code generation for very efficient (de)serialization codecs. It does have a learning curve and more setup to generate the code from the type specifications, but the ibc data types should not change often and this code generation setup only needs to happen once per language (and can be exposed in a common repo), so this is not a strong counter-argument. Efficiency, expressiveness, and wider support rule in its favor. It is also widely used in gRPC and in many microservice architectures.
|
||||||
|
|
||||||
The tendermint-specific data structures are encoded with go-wire[[8](./references.md#8)], the native binary encoding used inside of tendermint. Most blockchains define their own formats, and until some universal format for headers and signatures among blockchains emerge, it seems very premature to enforce any encoding here. These are defined as arbitrary byte slices in the protocol, to be parsed in an consensus engine-dependent manner.
|
The tendermint-specific data structures are encoded with go-amino[[8](./references.md#8)], the native binary encoding used inside of tendermint. Most blockchains define their own formats, and until some universal format for headers and signatures among blockchains emerge, it seems very premature to enforce any encoding here. These are defined as arbitrary byte slices in the protocol, to be parsed in an consensus engine-dependent manner.
|
||||||
|
|
||||||
For the following appendixes, the data structure specifications will be in proto3[[9](./references.md#9)] format.
|
For the following appendixes, the data structure specifications will be in proto3[[9](./references.md#9)] format.
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ The IBC protocol does not handle these kinds of errors. They must be handled ind
|
||||||
|
|
||||||
**TODO: clean this all up**
|
**TODO: clean this all up**
|
||||||
|
|
||||||
This is a mess now, we need to figure out what formats we use, define go-wire, etc. or just point to the source???? Will do more later, need help here from the tendermint core team.
|
This is a mess now, we need to figure out what formats we use, define go-amino, etc. or just point to the source???? Will do more later, need help here from the tendermint core team.
|
||||||
|
|
||||||
In order to prove a merkle root, we must fully define the headers, signatures, and validator information returned from the Tendermint consensus engine, as well as the rules by which to verify a header. We also define here the messages used for creating and removing connections to other blockchains as well as how to handle forks.
|
In order to prove a merkle root, we must fully define the headers, signatures, and validator information returned from the Tendermint consensus engine, as well as the rules by which to verify a header. We also define here the messages used for creating and removing connections to other blockchains as well as how to handle forks.
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ Every transaction on the same chain already has a well-defined causality relatio
|
||||||
|
|
||||||
For example, an application may wish to allow a single tokenized asset to be transferred between and held on multiple blockchains while preserving fungibility and conservation of supply. The application can mint asset vouchers on chain `B` when a particular IBC packet is committed to chain `B`, and require outgoing sends of that packet on chain `A` to escrow an equal amount of the asset on chain `A` until the vouchers are later redeemed back to chain `A` with an IBC packet in the reverse direction. This ordering guarantee along with correct application logic can ensure that total supply is preserved across both chains and that any vouchers minted on chain `B` can later be redeemed back to chain `A`.
|
For example, an application may wish to allow a single tokenized asset to be transferred between and held on multiple blockchains while preserving fungibility and conservation of supply. The application can mint asset vouchers on chain `B` when a particular IBC packet is committed to chain `B`, and require outgoing sends of that packet on chain `A` to escrow an equal amount of the asset on chain `A` until the vouchers are later redeemed back to chain `A` with an IBC packet in the reverse direction. This ordering guarantee along with correct application logic can ensure that total supply is preserved across both chains and that any vouchers minted on chain `B` can later be redeemed back to chain `A`.
|
||||||
|
|
||||||
This section provides definitions for packets and channels, a high-level specification of the queue interface, and a list of the necessary proofs. To implement wire-compatible IBC, chain `A` and chain `B` must also use a common encoding format. An example binary encoding format can be found in [Appendix C](appendices.md#appendix-c-merkle-proof-formats).
|
This section provides definitions for packets and channels, a high-level specification of the queue interface, and a list of the necessary proofs. To implement amino-compatible IBC, chain `A` and chain `B` must also use a common encoding format. An example binary encoding format can be found in [Appendix C](appendices.md#appendix-c-merkle-proof-formats).
|
||||||
|
|
||||||
### 3.2 Definitions
|
### 3.2 Definitions
|
||||||
|
|
||||||
|
|
|
@ -6,4 +6,4 @@ We have demonstrated a secure, performant, and flexible protocol for cross-block
|
||||||
|
|
||||||
This document defines solely a message queue protocol - not the application-level semantics which must sit on top of it to enable asset transfer between two chains. We will shortly release a separate paper on Cosmos IBC that defines the application logic used for direct value transfer as well as routing over the Cosmos hub. That paper builds upon the IBC protocol defined here and provides a first example of how to reason about application logic and global invariants in the context of IBC.
|
This document defines solely a message queue protocol - not the application-level semantics which must sit on top of it to enable asset transfer between two chains. We will shortly release a separate paper on Cosmos IBC that defines the application logic used for direct value transfer as well as routing over the Cosmos hub. That paper builds upon the IBC protocol defined here and provides a first example of how to reason about application logic and global invariants in the context of IBC.
|
||||||
|
|
||||||
There is a reference implementation of the Cosmos IBC protocol as part of the Cosmos SDK, written in Golang and released under the Apache license. To facilitate implementations in other langauages which are wire-compatible with the Cosmos implementation, the following appendices define exact message and binary encoding formats.
|
There is a reference implementation of the Cosmos IBC protocol as part of the Cosmos SDK, written in Golang and released under the Apache license. To facilitate implementations in other langauages which are amino-compatible with the Cosmos implementation, the following appendices define exact message and binary encoding formats.
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
[https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/)
|
[https://developers.google.com/protocol-buffers/](https://developers.google.com/protocol-buffers/)
|
||||||
|
|
||||||
##### 8:
|
##### 8:
|
||||||
[https://github.com/tendermint/go-wire](https://github.com/tendermint/go-wire)
|
[https://github.com/tendermint/go-amino](https://github.com/tendermint/go-amino)
|
||||||
|
|
||||||
##### 9:
|
##### 9:
|
||||||
[https://developers.google.com/protocol-buffers/docs/proto3](https://developers.google.com/protocol-buffers/docs/proto3)
|
[https://developers.google.com/protocol-buffers/docs/proto3](https://developers.google.com/protocol-buffers/docs/proto3)
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/examples/basecoin/types"
|
"github.com/cosmos/cosmos-sdk/examples/basecoin/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||||
|
@ -27,7 +27,7 @@ const (
|
||||||
// integral app types.
|
// integral app types.
|
||||||
type BasecoinApp struct {
|
type BasecoinApp struct {
|
||||||
*bam.BaseApp
|
*bam.BaseApp
|
||||||
cdc *wire.Codec
|
cdc *codec.Codec
|
||||||
|
|
||||||
// keys to access the multistore
|
// keys to access the multistore
|
||||||
keyMain *sdk.KVStoreKey
|
keyMain *sdk.KVStoreKey
|
||||||
|
@ -93,16 +93,16 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.Ba
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeCodec creates a new wire codec and registers all the necessary types
|
// MakeCodec creates a new codec codec and registers all the necessary types
|
||||||
// with the codec.
|
// with the codec.
|
||||||
func MakeCodec() *wire.Codec {
|
func MakeCodec() *codec.Codec {
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
|
|
||||||
wire.RegisterCrypto(cdc)
|
codec.RegisterCrypto(cdc)
|
||||||
sdk.RegisterWire(cdc)
|
sdk.RegisterCodec(cdc)
|
||||||
bank.RegisterWire(cdc)
|
bank.RegisterCodec(cdc)
|
||||||
ibc.RegisterWire(cdc)
|
ibc.RegisterCodec(cdc)
|
||||||
auth.RegisterWire(cdc)
|
auth.RegisterCodec(cdc)
|
||||||
|
|
||||||
// register custom type
|
// register custom type
|
||||||
cdc.RegisterConcrete(&types.AppAccount{}, "basecoin/Account", nil)
|
cdc.RegisterConcrete(&types.AppAccount{}, "basecoin/Account", nil)
|
||||||
|
@ -173,7 +173,7 @@ func (app *BasecoinApp) ExportAppStateAndValidators() (appState json.RawMessage,
|
||||||
app.accountMapper.IterateAccounts(ctx, appendAccountsFn)
|
app.accountMapper.IterateAccounts(ctx, appendAccountsFn)
|
||||||
|
|
||||||
genState := types.GenesisState{Accounts: accounts}
|
genState := types.GenesisState{Accounts: accounts}
|
||||||
appState, err = wire.MarshalJSONIndent(app.cdc, genState)
|
appState, err = codec.MarshalJSONIndent(app.cdc, genState)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/examples/basecoin/types"
|
"github.com/cosmos/cosmos-sdk/examples/basecoin/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
@ -22,7 +22,7 @@ func setGenesis(baseApp *BasecoinApp, accounts ...*types.AppAccount) (types.Gene
|
||||||
}
|
}
|
||||||
|
|
||||||
genesisState := types.GenesisState{Accounts: genAccts}
|
genesisState := types.GenesisState{Accounts: genAccts}
|
||||||
stateBytes, err := wire.MarshalJSONIndent(baseApp.cdc, genesisState)
|
stateBytes, err := codec.MarshalJSONIndent(baseApp.cdc, genesisState)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.GenesisState{}, err
|
return types.GenesisState{}, err
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ func TestGenesis(t *testing.T) {
|
||||||
// reload app and ensure the account is still there
|
// reload app and ensure the account is still there
|
||||||
baseApp = NewBasecoinApp(logger, db)
|
baseApp = NewBasecoinApp(logger, db)
|
||||||
|
|
||||||
stateBytes, err := wire.MarshalJSONIndent(baseApp.cdc, genState)
|
stateBytes, err := codec.MarshalJSONIndent(baseApp.cdc, genState)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
// initialize the chain with the expected genesis state
|
// initialize the chain with the expected genesis state
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ func NewAppAccount(name string, baseAcct auth.BaseAccount) *AppAccount {
|
||||||
|
|
||||||
// GetAccountDecoder returns the AccountDecoder function for the custom
|
// GetAccountDecoder returns the AccountDecoder function for the custom
|
||||||
// AppAccount.
|
// AppAccount.
|
||||||
func GetAccountDecoder(cdc *wire.Codec) auth.AccountDecoder {
|
func GetAccountDecoder(cdc *codec.Codec) auth.AccountDecoder {
|
||||||
return func(accBytes []byte) (auth.Account, error) {
|
return func(accBytes []byte) (auth.Account, error) {
|
||||||
if len(accBytes) == 0 {
|
if len(accBytes) == 0 {
|
||||||
return nil, sdk.ErrTxDecode("accBytes are empty")
|
return nil, sdk.ErrTxDecode("accBytes are empty")
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
|
|
||||||
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||||
|
@ -30,7 +30,7 @@ const (
|
||||||
// Extended ABCI application
|
// Extended ABCI application
|
||||||
type DemocoinApp struct {
|
type DemocoinApp struct {
|
||||||
*bam.BaseApp
|
*bam.BaseApp
|
||||||
cdc *wire.Codec
|
cdc *codec.Codec
|
||||||
|
|
||||||
// keys to access the substores
|
// keys to access the substores
|
||||||
capKeyMainStore *sdk.KVStoreKey
|
capKeyMainStore *sdk.KVStoreKey
|
||||||
|
@ -103,15 +103,15 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
// custom tx codec
|
// custom tx codec
|
||||||
func MakeCodec() *wire.Codec {
|
func MakeCodec() *codec.Codec {
|
||||||
var cdc = wire.NewCodec()
|
var cdc = codec.New()
|
||||||
wire.RegisterCrypto(cdc) // Register crypto.
|
codec.RegisterCrypto(cdc) // Register crypto.
|
||||||
sdk.RegisterWire(cdc) // Register Msgs
|
sdk.RegisterCodec(cdc) // Register Msgs
|
||||||
cool.RegisterWire(cdc)
|
cool.RegisterCodec(cdc)
|
||||||
pow.RegisterWire(cdc)
|
pow.RegisterCodec(cdc)
|
||||||
bank.RegisterWire(cdc)
|
bank.RegisterCodec(cdc)
|
||||||
ibc.RegisterWire(cdc)
|
ibc.RegisterCodec(cdc)
|
||||||
simplestake.RegisterWire(cdc)
|
simplestake.RegisterCodec(cdc)
|
||||||
|
|
||||||
// Register AppAccount
|
// Register AppAccount
|
||||||
cdc.RegisterInterface((*auth.Account)(nil), nil)
|
cdc.RegisterInterface((*auth.Account)(nil), nil)
|
||||||
|
@ -182,7 +182,7 @@ func (app *DemocoinApp) ExportAppStateAndValidators() (appState json.RawMessage,
|
||||||
POWGenesis: pow.WriteGenesis(ctx, app.powKeeper),
|
POWGenesis: pow.WriteGenesis(ctx, app.powKeeper),
|
||||||
CoolGenesis: cool.WriteGenesis(ctx, app.coolKeeper),
|
CoolGenesis: cool.WriteGenesis(ctx, app.coolKeeper),
|
||||||
}
|
}
|
||||||
appState, err = wire.MarshalJSONIndent(app.cdc, genState)
|
appState, err = codec.MarshalJSONIndent(app.cdc, genState)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/examples/democoin/types"
|
"github.com/cosmos/cosmos-sdk/examples/democoin/types"
|
||||||
"github.com/cosmos/cosmos-sdk/examples/democoin/x/cool"
|
"github.com/cosmos/cosmos-sdk/examples/democoin/x/cool"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
@ -27,7 +27,7 @@ func setGenesis(bapp *DemocoinApp, trend string, accs ...auth.BaseAccount) error
|
||||||
CoolGenesis: cool.Genesis{trend},
|
CoolGenesis: cool.Genesis{trend},
|
||||||
}
|
}
|
||||||
|
|
||||||
stateBytes, err := wire.MarshalJSONIndent(bapp.cdc, genesisState)
|
stateBytes, err := codec.MarshalJSONIndent(bapp.cdc, genesisState)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ import (
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/examples/democoin/app"
|
"github.com/cosmos/cosmos-sdk/examples/democoin/app"
|
||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// init parameters
|
// init parameters
|
||||||
|
@ -25,7 +25,7 @@ var CoolAppInit = server.AppInit{
|
||||||
}
|
}
|
||||||
|
|
||||||
// coolGenAppParams sets up the app_state and appends the cool app state
|
// coolGenAppParams sets up the app_state and appends the cool app state
|
||||||
func CoolAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (appState json.RawMessage, err error) {
|
func CoolAppGenState(cdc *codec.Codec, appGenTxs []json.RawMessage) (appState json.RawMessage, err error) {
|
||||||
appState, err = server.SimpleAppGenState(cdc, appGenTxs)
|
appState, err = server.SimpleAppGenState(cdc, appGenTxs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/examples/democoin/x/cool"
|
"github.com/cosmos/cosmos-sdk/examples/democoin/x/cool"
|
||||||
|
@ -31,7 +31,7 @@ func (acc AppAccount) GetName() string { return acc.Name }
|
||||||
func (acc *AppAccount) SetName(name string) { acc.Name = name }
|
func (acc *AppAccount) SetName(name string) { acc.Name = name }
|
||||||
|
|
||||||
// Get the AccountDecoder function for the custom AppAccount
|
// Get the AccountDecoder function for the custom AppAccount
|
||||||
func GetAccountDecoder(cdc *wire.Codec) auth.AccountDecoder {
|
func GetAccountDecoder(cdc *codec.Codec) auth.AccountDecoder {
|
||||||
return func(accBytes []byte) (res auth.Account, err error) {
|
return func(accBytes []byte) (res auth.Account, err error) {
|
||||||
if len(accBytes) == 0 {
|
if len(accBytes) == 0 {
|
||||||
return nil, sdk.ErrTxDecode("accBytes are empty")
|
return nil, sdk.ErrTxDecode("accBytes are empty")
|
||||||
|
|
|
@ -3,8 +3,8 @@ package assoc
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ValidatorSet defines
|
// ValidatorSet defines
|
||||||
|
@ -12,7 +12,7 @@ type ValidatorSet struct {
|
||||||
sdk.ValidatorSet
|
sdk.ValidatorSet
|
||||||
|
|
||||||
store sdk.KVStore
|
store sdk.KVStore
|
||||||
cdc *wire.Codec
|
cdc *codec.Codec
|
||||||
|
|
||||||
maxAssoc int
|
maxAssoc int
|
||||||
addrLen int
|
addrLen int
|
||||||
|
@ -21,7 +21,7 @@ type ValidatorSet struct {
|
||||||
var _ sdk.ValidatorSet = ValidatorSet{}
|
var _ sdk.ValidatorSet = ValidatorSet{}
|
||||||
|
|
||||||
// NewValidatorSet returns new ValidatorSet with underlying ValidatorSet
|
// NewValidatorSet returns new ValidatorSet with underlying ValidatorSet
|
||||||
func NewValidatorSet(cdc *wire.Codec, store sdk.KVStore, valset sdk.ValidatorSet, maxAssoc int, addrLen int) ValidatorSet {
|
func NewValidatorSet(cdc *codec.Codec, store sdk.KVStore, valset sdk.ValidatorSet, maxAssoc int, addrLen int) ValidatorSet {
|
||||||
if maxAssoc < 0 || addrLen < 0 {
|
if maxAssoc < 0 || addrLen < 0 {
|
||||||
panic("Cannot use negative integer for NewValidatorSet")
|
panic("Cannot use negative integer for NewValidatorSet")
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,10 @@ import (
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
dbm "github.com/tendermint/tendermint/libs/db"
|
dbm "github.com/tendermint/tendermint/libs/db"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/examples/democoin/mock"
|
"github.com/cosmos/cosmos-sdk/examples/democoin/mock"
|
||||||
"github.com/cosmos/cosmos-sdk/store"
|
"github.com/cosmos/cosmos-sdk/store"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func defaultContext(key sdk.StoreKey) sdk.Context {
|
func defaultContext(key sdk.StoreKey) sdk.Context {
|
||||||
|
@ -36,7 +36,7 @@ func TestValidatorSet(t *testing.T) {
|
||||||
{addr2, sdk.NewDec(2)},
|
{addr2, sdk.NewDec(2)},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
valset := NewValidatorSet(wire.NewCodec(), ctx.KVStore(key).Prefix([]byte("assoc")), base, 1, 5)
|
valset := NewValidatorSet(codec.New(), ctx.KVStore(key).Prefix([]byte("assoc")), base, 1, 5)
|
||||||
|
|
||||||
require.Equal(t, base.Validator(ctx, addr1), valset.Validator(ctx, addr1))
|
require.Equal(t, base.Validator(ctx, addr1), valset.Validator(ctx, addr1))
|
||||||
require.Equal(t, base.Validator(ctx, addr2), valset.Validator(ctx, addr2))
|
require.Equal(t, base.Validator(ctx, addr2), valset.Validator(ctx, addr2))
|
||||||
|
|
|
@ -47,7 +47,7 @@ var (
|
||||||
func getMockApp(t *testing.T) *mock.App {
|
func getMockApp(t *testing.T) *mock.App {
|
||||||
mapp := mock.NewApp()
|
mapp := mock.NewApp()
|
||||||
|
|
||||||
RegisterWire(mapp.Cdc)
|
RegisterCodec(mapp.Cdc)
|
||||||
keyCool := sdk.NewKVStoreKey("cool")
|
keyCool := sdk.NewKVStoreKey("cool")
|
||||||
bankKeeper := bank.NewBaseKeeper(mapp.AccountMapper)
|
bankKeeper := bank.NewBaseKeeper(mapp.AccountMapper)
|
||||||
keeper := NewKeeper(keyCool, bankKeeper, mapp.RegisterCodespace(DefaultCodespace))
|
keeper := NewKeeper(keyCool, bankKeeper, mapp.RegisterCodespace(DefaultCodespace))
|
||||||
|
|
|
@ -7,15 +7,15 @@ import (
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
"github.com/cosmos/cosmos-sdk/client/utils"
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/examples/democoin/x/cool"
|
"github.com/cosmos/cosmos-sdk/examples/democoin/x/cool"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||||
)
|
)
|
||||||
|
|
||||||
// QuizTxCmd invokes the coolness quiz transaction.
|
// QuizTxCmd invokes the coolness quiz transaction.
|
||||||
func QuizTxCmd(cdc *wire.Codec) *cobra.Command {
|
func QuizTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "cool [answer]",
|
Use: "cool [answer]",
|
||||||
Short: "What's cooler than being cool?",
|
Short: "What's cooler than being cool?",
|
||||||
|
@ -40,7 +40,7 @@ func QuizTxCmd(cdc *wire.Codec) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTrendTxCmd sends a new cool trend transaction.
|
// SetTrendTxCmd sends a new cool trend transaction.
|
||||||
func SetTrendTxCmd(cdc *wire.Codec) *cobra.Command {
|
func SetTrendTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "setcool [answer]",
|
Use: "setcool [answer]",
|
||||||
Short: "You're so cool, tell us what is cool!",
|
Short: "You're so cool, tell us what is cool!",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package cool
|
package cool
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Register concrete types on wire codec
|
// Register concrete types on codec codec
|
||||||
func RegisterWire(cdc *wire.Codec) {
|
func RegisterCodec(cdc *codec.Codec) {
|
||||||
cdc.RegisterConcrete(MsgQuiz{}, "cool/Quiz", nil)
|
cdc.RegisterConcrete(MsgQuiz{}, "cool/Quiz", nil)
|
||||||
cdc.RegisterConcrete(MsgSetTrend{}, "cool/SetTrend", nil)
|
cdc.RegisterConcrete(MsgSetTrend{}, "cool/SetTrend", nil)
|
||||||
}
|
}
|
|
@ -8,9 +8,9 @@ import (
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
dbm "github.com/tendermint/tendermint/libs/db"
|
dbm "github.com/tendermint/tendermint/libs/db"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/store"
|
"github.com/cosmos/cosmos-sdk/store"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
auth "github.com/cosmos/cosmos-sdk/x/auth"
|
auth "github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank"
|
bank "github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
)
|
)
|
||||||
|
@ -26,7 +26,7 @@ func setupMultiStore() (sdk.MultiStore, *sdk.KVStoreKey) {
|
||||||
|
|
||||||
func TestCoolKeeper(t *testing.T) {
|
func TestCoolKeeper(t *testing.T) {
|
||||||
ms, capKey := setupMultiStore()
|
ms, capKey := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
auth.RegisterBaseAccount(cdc)
|
auth.RegisterBaseAccount(cdc)
|
||||||
|
|
||||||
am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount)
|
am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount)
|
||||||
|
|
|
@ -38,7 +38,7 @@ func NewHandler(keeper Keeper) sdk.Handler {
|
||||||
In the previous example, the keeper has an `oracle.Keeper`. `oracle.Keeper`s are generated by `NewKeeper`.
|
In the previous example, the keeper has an `oracle.Keeper`. `oracle.Keeper`s are generated by `NewKeeper`.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func NewKeeper(key sdk.StoreKey, cdc *wire.Codec, valset sdk.ValidatorSet, supermaj sdk.Dec, timeout int64) Keeper {
|
func NewKeeper(key sdk.StoreKey, cdc *codec.Codec, valset sdk.ValidatorSet, supermaj sdk.Dec, timeout int64) Keeper {
|
||||||
return Keeper {
|
return Keeper {
|
||||||
cdc: cdc,
|
cdc: cdc,
|
||||||
key: key,
|
key: key,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package oracle
|
package oracle
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
)
|
)
|
||||||
|
@ -9,7 +9,7 @@ import (
|
||||||
// Keeper of the oracle store
|
// Keeper of the oracle store
|
||||||
type Keeper struct {
|
type Keeper struct {
|
||||||
key sdk.StoreKey
|
key sdk.StoreKey
|
||||||
cdc *wire.Codec
|
cdc *codec.Codec
|
||||||
|
|
||||||
valset sdk.ValidatorSet
|
valset sdk.ValidatorSet
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ type Keeper struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewKeeper constructs a new keeper
|
// NewKeeper constructs a new keeper
|
||||||
func NewKeeper(key sdk.StoreKey, cdc *wire.Codec, valset sdk.ValidatorSet, supermaj sdk.Dec, timeout int64) Keeper {
|
func NewKeeper(key sdk.StoreKey, cdc *codec.Codec, valset sdk.ValidatorSet, supermaj sdk.Dec, timeout int64) Keeper {
|
||||||
if timeout < 0 {
|
if timeout < 0 {
|
||||||
panic("Timeout should not be negative")
|
panic("Timeout should not be negative")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
package oracle
|
package oracle
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetInfoKey returns the key for OracleInfo
|
// GetInfoKey returns the key for OracleInfo
|
||||||
func GetInfoKey(p Payload, cdc *wire.Codec) []byte {
|
func GetInfoKey(p Payload, cdc *codec.Codec) []byte {
|
||||||
bz := cdc.MustMarshalBinary(p)
|
bz := cdc.MustMarshalBinary(p)
|
||||||
return append([]byte{0x00}, bz...)
|
return append([]byte{0x00}, bz...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSignPrefix returns the prefix for signs
|
// GetSignPrefix returns the prefix for signs
|
||||||
func GetSignPrefix(p Payload, cdc *wire.Codec) []byte {
|
func GetSignPrefix(p Payload, cdc *codec.Codec) []byte {
|
||||||
bz := cdc.MustMarshalBinary(p)
|
bz := cdc.MustMarshalBinary(p)
|
||||||
return append([]byte{0x01}, bz...)
|
return append([]byte{0x01}, bz...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSignKey returns the key for sign
|
// GetSignKey returns the key for sign
|
||||||
func GetSignKey(p Payload, signer sdk.AccAddress, cdc *wire.Codec) []byte {
|
func GetSignKey(p Payload, signer sdk.AccAddress, cdc *codec.Codec) []byte {
|
||||||
return append(GetSignPrefix(p, cdc), signer...)
|
return append(GetSignPrefix(p, cdc), signer...)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,10 @@ import (
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
dbm "github.com/tendermint/tendermint/libs/db"
|
dbm "github.com/tendermint/tendermint/libs/db"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/examples/democoin/mock"
|
"github.com/cosmos/cosmos-sdk/examples/democoin/mock"
|
||||||
"github.com/cosmos/cosmos-sdk/store"
|
"github.com/cosmos/cosmos-sdk/store"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func defaultContext(keys ...sdk.StoreKey) sdk.Context {
|
func defaultContext(keys ...sdk.StoreKey) sdk.Context {
|
||||||
|
@ -39,8 +39,8 @@ func (o seqOracle) ValidateBasic() sdk.Error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeCodec() *wire.Codec {
|
func makeCodec() *codec.Codec {
|
||||||
var cdc = wire.NewCodec()
|
var cdc = codec.New()
|
||||||
|
|
||||||
cdc.RegisterInterface((*sdk.Msg)(nil), nil)
|
cdc.RegisterInterface((*sdk.Msg)(nil), nil)
|
||||||
cdc.RegisterConcrete(Msg{}, "test/Oracle", nil)
|
cdc.RegisterConcrete(Msg{}, "test/Oracle", nil)
|
||||||
|
@ -79,7 +79,7 @@ func getSequence(ctx sdk.Context, key sdk.StoreKey) int {
|
||||||
if seqbz == nil {
|
if seqbz == nil {
|
||||||
seq = 0
|
seq = 0
|
||||||
} else {
|
} else {
|
||||||
wire.NewCodec().MustUnmarshalBinary(seqbz, &seq)
|
codec.New().MustUnmarshalBinary(seqbz, &seq)
|
||||||
}
|
}
|
||||||
|
|
||||||
return seq
|
return seq
|
||||||
|
@ -93,7 +93,7 @@ func handleSeqOracle(ctx sdk.Context, key sdk.StoreKey, o seqOracle) sdk.Error {
|
||||||
return sdk.NewError(sdk.CodespaceRoot, 1, "")
|
return sdk.NewError(sdk.CodespaceRoot, 1, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
bz := wire.NewCodec().MustMarshalBinary(seq + 1)
|
bz := codec.New().MustMarshalBinary(seq + 1)
|
||||||
store.Set([]byte("seq"), bz)
|
store.Set([]byte("seq"), bz)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -23,7 +23,7 @@ var (
|
||||||
func getMockApp(t *testing.T) *mock.App {
|
func getMockApp(t *testing.T) *mock.App {
|
||||||
mapp := mock.NewApp()
|
mapp := mock.NewApp()
|
||||||
|
|
||||||
RegisterWire(mapp.Cdc)
|
RegisterCodec(mapp.Cdc)
|
||||||
keyPOW := sdk.NewKVStoreKey("pow")
|
keyPOW := sdk.NewKVStoreKey("pow")
|
||||||
bankKeeper := bank.NewBaseKeeper(mapp.AccountMapper)
|
bankKeeper := bank.NewBaseKeeper(mapp.AccountMapper)
|
||||||
config := Config{"pow", 1}
|
config := Config{"pow", 1}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
"github.com/cosmos/cosmos-sdk/client/utils"
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/examples/democoin/x/pow"
|
"github.com/cosmos/cosmos-sdk/examples/democoin/x/pow"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// command to mine some pow!
|
// command to mine some pow!
|
||||||
func MineCmd(cdc *wire.Codec) *cobra.Command {
|
func MineCmd(cdc *codec.Codec) *cobra.Command {
|
||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "mine [difficulty] [count] [nonce] [solution]",
|
Use: "mine [difficulty] [count] [nonce] [solution]",
|
||||||
Short: "Mine some coins with proof-of-work!",
|
Short: "Mine some coins with proof-of-work!",
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package pow
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Register concrete types on codec codec
|
||||||
|
func RegisterCodec(cdc *codec.Codec) {
|
||||||
|
cdc.RegisterConcrete(MsgMine{}, "pow/Mine", nil)
|
||||||
|
}
|
|
@ -8,15 +8,15 @@ import (
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
|
||||||
|
codec "github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
wire "github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
auth "github.com/cosmos/cosmos-sdk/x/auth"
|
auth "github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank"
|
bank "github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPowHandler(t *testing.T) {
|
func TestPowHandler(t *testing.T) {
|
||||||
ms, capKey := setupMultiStore()
|
ms, capKey := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
auth.RegisterBaseAccount(cdc)
|
auth.RegisterBaseAccount(cdc)
|
||||||
|
|
||||||
am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount)
|
am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount)
|
||||||
|
|
|
@ -9,9 +9,9 @@ import (
|
||||||
dbm "github.com/tendermint/tendermint/libs/db"
|
dbm "github.com/tendermint/tendermint/libs/db"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/store"
|
"github.com/cosmos/cosmos-sdk/store"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
auth "github.com/cosmos/cosmos-sdk/x/auth"
|
auth "github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank"
|
bank "github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
)
|
)
|
||||||
|
@ -29,7 +29,7 @@ func setupMultiStore() (sdk.MultiStore, *sdk.KVStoreKey) {
|
||||||
|
|
||||||
func TestPowKeeperGetSet(t *testing.T) {
|
func TestPowKeeperGetSet(t *testing.T) {
|
||||||
ms, capKey := setupMultiStore()
|
ms, capKey := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
auth.RegisterBaseAccount(cdc)
|
auth.RegisterBaseAccount(cdc)
|
||||||
|
|
||||||
am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount)
|
am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount)
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
package pow
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Register concrete types on wire codec
|
|
||||||
func RegisterWire(cdc *wire.Codec) {
|
|
||||||
cdc.RegisterConcrete(MsgMine{}, "pow/Mine", nil)
|
|
||||||
}
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
"github.com/cosmos/cosmos-sdk/client/utils"
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/examples/democoin/x/simplestake"
|
"github.com/cosmos/cosmos-sdk/examples/democoin/x/simplestake"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// simple bond tx
|
// simple bond tx
|
||||||
func BondTxCmd(cdc *wire.Codec) *cobra.Command {
|
func BondTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "bond",
|
Use: "bond",
|
||||||
Short: "Bond to a validator",
|
Short: "Bond to a validator",
|
||||||
|
@ -79,7 +79,7 @@ func BondTxCmd(cdc *wire.Codec) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
// simple unbond tx
|
// simple unbond tx
|
||||||
func UnbondTxCmd(cdc *wire.Codec) *cobra.Command {
|
func UnbondTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "unbond",
|
Use: "unbond",
|
||||||
Short: "Unbond from a validator",
|
Short: "Unbond from a validator",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package simplestake
|
package simplestake
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Register concrete types on wire codec
|
// Register concrete types on codec codec
|
||||||
func RegisterWire(cdc *wire.Codec) {
|
func RegisterCodec(cdc *codec.Codec) {
|
||||||
cdc.RegisterConcrete(MsgBond{}, "simplestake/BondMsg", nil)
|
cdc.RegisterConcrete(MsgBond{}, "simplestake/BondMsg", nil)
|
||||||
cdc.RegisterConcrete(MsgUnbond{}, "simplestake/UnbondMsg", nil)
|
cdc.RegisterConcrete(MsgUnbond{}, "simplestake/UnbondMsg", nil)
|
||||||
}
|
}
|
|
@ -3,8 +3,8 @@ package simplestake
|
||||||
import (
|
import (
|
||||||
"github.com/tendermint/tendermint/crypto"
|
"github.com/tendermint/tendermint/crypto"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,13 +17,13 @@ type Keeper struct {
|
||||||
ck bank.Keeper
|
ck bank.Keeper
|
||||||
|
|
||||||
key sdk.StoreKey
|
key sdk.StoreKey
|
||||||
cdc *wire.Codec
|
cdc *codec.Codec
|
||||||
codespace sdk.CodespaceType
|
codespace sdk.CodespaceType
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewKeeper(key sdk.StoreKey, bankKeeper bank.Keeper, codespace sdk.CodespaceType) Keeper {
|
func NewKeeper(key sdk.StoreKey, bankKeeper bank.Keeper, codespace sdk.CodespaceType) Keeper {
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
wire.RegisterCrypto(cdc)
|
codec.RegisterCrypto(cdc)
|
||||||
return Keeper{
|
return Keeper{
|
||||||
key: key,
|
key: key,
|
||||||
cdc: cdc,
|
cdc: cdc,
|
||||||
|
|
|
@ -12,9 +12,9 @@ import (
|
||||||
dbm "github.com/tendermint/tendermint/libs/db"
|
dbm "github.com/tendermint/tendermint/libs/db"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/store"
|
"github.com/cosmos/cosmos-sdk/store"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||||
)
|
)
|
||||||
|
@ -32,7 +32,7 @@ func setupMultiStore() (sdk.MultiStore, *sdk.KVStoreKey, *sdk.KVStoreKey) {
|
||||||
|
|
||||||
func TestKeeperGetSet(t *testing.T) {
|
func TestKeeperGetSet(t *testing.T) {
|
||||||
ms, authKey, capKey := setupMultiStore()
|
ms, authKey, capKey := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
auth.RegisterBaseAccount(cdc)
|
auth.RegisterBaseAccount(cdc)
|
||||||
|
|
||||||
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
|
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
|
||||||
|
@ -60,7 +60,7 @@ func TestKeeperGetSet(t *testing.T) {
|
||||||
|
|
||||||
func TestBonding(t *testing.T) {
|
func TestBonding(t *testing.T) {
|
||||||
ms, authKey, capKey := setupMultiStore()
|
ms, authKey, capKey := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
auth.RegisterBaseAccount(cdc)
|
auth.RegisterBaseAccount(cdc)
|
||||||
|
|
||||||
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||||
|
|
Binary file not shown.
|
@ -7,14 +7,14 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path"
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExportCmd dumps app state to JSON.
|
// ExportCmd dumps app state to JSON.
|
||||||
func ExportCmd(ctx *Context, cdc *wire.Codec, appExporter AppExporter) *cobra.Command {
|
func ExportCmd(ctx *Context, cdc *codec.Codec, appExporter AppExporter) *cobra.Command {
|
||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "export",
|
Use: "export",
|
||||||
Short: "Export state to JSON",
|
Short: "Export state to JSON",
|
||||||
|
@ -50,7 +50,7 @@ func ExportCmd(ctx *Context, cdc *wire.Codec, appExporter AppExporter) *cobra.Co
|
||||||
doc.AppState = appState
|
doc.AppState = appState
|
||||||
doc.Validators = validators
|
doc.Validators = validators
|
||||||
|
|
||||||
encoded, err := wire.MarshalJSONIndent(cdc, doc)
|
encoded, err := codec.MarshalJSONIndent(cdc, doc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/server/mock"
|
"github.com/cosmos/cosmos-sdk/server/mock"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
@ -18,7 +18,7 @@ func TestEmptyState(t *testing.T) {
|
||||||
cfg, err := tcmd.ParseConfig()
|
cfg, err := tcmd.ParseConfig()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
ctx := NewContext(cfg, logger)
|
ctx := NewContext(cfg, logger)
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
appInit := AppInit{
|
appInit := AppInit{
|
||||||
AppGenTx: mock.AppGenTx,
|
AppGenTx: mock.AppGenTx,
|
||||||
AppGenState: mock.AppGenStateEmpty,
|
AppGenState: mock.AppGenStateEmpty,
|
||||||
|
|
|
@ -26,9 +26,9 @@ import (
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
|
|
||||||
clkeys "github.com/cosmos/cosmos-sdk/client/keys"
|
clkeys "github.com/cosmos/cosmos-sdk/client/keys"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
|
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//Parameter names, for init gen-tx command
|
//Parameter names, for init gen-tx command
|
||||||
|
@ -63,7 +63,7 @@ type InitConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get cmd to initialize all files for tendermint and application
|
// get cmd to initialize all files for tendermint and application
|
||||||
func GenTxCmd(ctx *Context, cdc *wire.Codec, appInit AppInit) *cobra.Command {
|
func GenTxCmd(ctx *Context, cdc *codec.Codec, appInit AppInit) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "gen-tx",
|
Use: "gen-tx",
|
||||||
Short: "Create genesis transaction file (under [--home]/config/gentx/gentx-[nodeID].json)",
|
Short: "Create genesis transaction file (under [--home]/config/gentx/gentx-[nodeID].json)",
|
||||||
|
@ -99,7 +99,7 @@ func GenTxCmd(ctx *Context, cdc *wire.Codec, appInit AppInit) *cobra.Command {
|
||||||
cliPrint,
|
cliPrint,
|
||||||
genTxFile,
|
genTxFile,
|
||||||
}
|
}
|
||||||
out, err := wire.MarshalJSONIndent(cdc, toPrint)
|
out, err := codec.MarshalJSONIndent(cdc, toPrint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ func GenTxCmd(ctx *Context, cdc *wire.Codec, appInit AppInit) *cobra.Command {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func gentxWithConfig(cdc *wire.Codec, appInit AppInit, config *cfg.Config, genTxConfig serverconfig.GenTx) (
|
func gentxWithConfig(cdc *codec.Codec, appInit AppInit, config *cfg.Config, genTxConfig serverconfig.GenTx) (
|
||||||
cliPrint json.RawMessage, genTxFile json.RawMessage, err error) {
|
cliPrint json.RawMessage, genTxFile json.RawMessage, err error) {
|
||||||
nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile())
|
nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -132,7 +132,7 @@ func gentxWithConfig(cdc *wire.Codec, appInit AppInit, config *cfg.Config, genTx
|
||||||
Validator: validator,
|
Validator: validator,
|
||||||
AppGenTx: appGenTx,
|
AppGenTx: appGenTx,
|
||||||
}
|
}
|
||||||
bz, err := wire.MarshalJSONIndent(cdc, tx)
|
bz, err := codec.MarshalJSONIndent(cdc, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ func gentxWithConfig(cdc *wire.Codec, appInit AppInit, config *cfg.Config, genTx
|
||||||
}
|
}
|
||||||
|
|
||||||
// get cmd to initialize all files for tendermint and application
|
// get cmd to initialize all files for tendermint and application
|
||||||
func InitCmd(ctx *Context, cdc *wire.Codec, appInit AppInit) *cobra.Command {
|
func InitCmd(ctx *Context, cdc *codec.Codec, appInit AppInit) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "init",
|
Use: "init",
|
||||||
Short: "Initialize genesis config, priv-validator file, and p2p-node file",
|
Short: "Initialize genesis config, priv-validator file, and p2p-node file",
|
||||||
|
@ -188,7 +188,7 @@ func InitCmd(ctx *Context, cdc *wire.Codec, appInit AppInit) *cobra.Command {
|
||||||
nodeID,
|
nodeID,
|
||||||
appMessage,
|
appMessage,
|
||||||
}
|
}
|
||||||
out, err := wire.MarshalJSONIndent(cdc, toPrint)
|
out, err := codec.MarshalJSONIndent(cdc, toPrint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ func InitCmd(ctx *Context, cdc *wire.Codec, appInit AppInit) *cobra.Command {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func initWithConfig(cdc *wire.Codec, appInit AppInit, config *cfg.Config, initConfig InitConfig) (
|
func initWithConfig(cdc *codec.Codec, appInit AppInit, config *cfg.Config, initConfig InitConfig) (
|
||||||
chainID string, nodeID string, appMessage json.RawMessage, err error) {
|
chainID string, nodeID string, appMessage json.RawMessage, err error) {
|
||||||
nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile())
|
nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -273,7 +273,7 @@ func initWithConfig(cdc *wire.Codec, appInit AppInit, config *cfg.Config, initCo
|
||||||
}
|
}
|
||||||
|
|
||||||
// append a genesis-piece
|
// append a genesis-piece
|
||||||
func processGenTxs(genTxsDir string, cdc *wire.Codec) (
|
func processGenTxs(genTxsDir string, cdc *codec.Codec) (
|
||||||
validators []tmtypes.GenesisValidator, appGenTxs []json.RawMessage, persistentPeers string, err error) {
|
validators []tmtypes.GenesisValidator, appGenTxs []json.RawMessage, persistentPeers string, err error) {
|
||||||
|
|
||||||
var fos []os.FileInfo
|
var fos []os.FileInfo
|
||||||
|
@ -345,7 +345,7 @@ func readOrCreatePrivValidator(tmConfig *cfg.Config) crypto.PubKey {
|
||||||
// writeGenesisFile creates and writes the genesis configuration to disk. An
|
// writeGenesisFile creates and writes the genesis configuration to disk. An
|
||||||
// error is returned if building or writing the configuration to file fails.
|
// error is returned if building or writing the configuration to file fails.
|
||||||
// nolint: unparam
|
// nolint: unparam
|
||||||
func writeGenesisFile(cdc *wire.Codec, genesisFile, chainID string, validators []tmtypes.GenesisValidator, appState json.RawMessage) error {
|
func writeGenesisFile(cdc *codec.Codec, genesisFile, chainID string, validators []tmtypes.GenesisValidator, appState json.RawMessage) error {
|
||||||
genDoc := tmtypes.GenesisDoc{
|
genDoc := tmtypes.GenesisDoc{
|
||||||
ChainID: chainID,
|
ChainID: chainID,
|
||||||
Validators: validators,
|
Validators: validators,
|
||||||
|
@ -369,12 +369,12 @@ type AppInit struct {
|
||||||
FlagsAppGenTx *pflag.FlagSet
|
FlagsAppGenTx *pflag.FlagSet
|
||||||
|
|
||||||
// create the application genesis tx
|
// create the application genesis tx
|
||||||
AppGenTx func(cdc *wire.Codec, pk crypto.PubKey, genTxConfig serverconfig.GenTx) (
|
AppGenTx func(cdc *codec.Codec, pk crypto.PubKey, genTxConfig serverconfig.GenTx) (
|
||||||
appGenTx, cliPrint json.RawMessage, validator tmtypes.GenesisValidator, err error)
|
appGenTx, cliPrint json.RawMessage, validator tmtypes.GenesisValidator, err error)
|
||||||
|
|
||||||
// AppGenState creates the core parameters initialization. It takes in a
|
// AppGenState creates the core parameters initialization. It takes in a
|
||||||
// pubkey meant to represent the pubkey of the validator of this machine.
|
// pubkey meant to represent the pubkey of the validator of this machine.
|
||||||
AppGenState func(cdc *wire.Codec, appGenTxs []json.RawMessage) (appState json.RawMessage, err error)
|
AppGenState func(cdc *codec.Codec, appGenTxs []json.RawMessage) (appState json.RawMessage, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
//_____________________________________________________________________
|
//_____________________________________________________________________
|
||||||
|
@ -391,7 +391,7 @@ type SimpleGenTx struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a genesis transaction
|
// Generate a genesis transaction
|
||||||
func SimpleAppGenTx(cdc *wire.Codec, pk crypto.PubKey, genTxConfig serverconfig.GenTx) (
|
func SimpleAppGenTx(cdc *codec.Codec, pk crypto.PubKey, genTxConfig serverconfig.GenTx) (
|
||||||
appGenTx, cliPrint json.RawMessage, validator tmtypes.GenesisValidator, err error) {
|
appGenTx, cliPrint json.RawMessage, validator tmtypes.GenesisValidator, err error) {
|
||||||
|
|
||||||
var addr sdk.AccAddress
|
var addr sdk.AccAddress
|
||||||
|
@ -424,7 +424,7 @@ func SimpleAppGenTx(cdc *wire.Codec, pk crypto.PubKey, genTxConfig serverconfig.
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the genesis app state
|
// create the genesis app state
|
||||||
func SimpleAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (appState json.RawMessage, err error) {
|
func SimpleAppGenState(cdc *codec.Codec, appGenTxs []json.RawMessage) (appState json.RawMessage, err error) {
|
||||||
|
|
||||||
if len(appGenTxs) != 1 {
|
if len(appGenTxs) != 1 {
|
||||||
err = errors.New("must provide a single genesis transaction")
|
err = errors.New("must provide a single genesis transaction")
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/server/mock"
|
"github.com/cosmos/cosmos-sdk/server/mock"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ func TestInitCmd(t *testing.T) {
|
||||||
cfg, err := tcmd.ParseConfig()
|
cfg, err := tcmd.ParseConfig()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
ctx := NewContext(cfg, logger)
|
ctx := NewContext(cfg, logger)
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
appInit := AppInit{
|
appInit := AppInit{
|
||||||
AppGenState: mock.AppGenState,
|
AppGenState: mock.AppGenState,
|
||||||
AppGenTx: mock.AppGenTx,
|
AppGenTx: mock.AppGenTx,
|
||||||
|
|
|
@ -12,9 +12,9 @@ import (
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
|
|
||||||
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
gc "github.com/cosmos/cosmos-sdk/server/config"
|
gc "github.com/cosmos/cosmos-sdk/server/config"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewApp creates a simple mock kvstore app for testing. It should work
|
// NewApp creates a simple mock kvstore app for testing. It should work
|
||||||
|
@ -105,7 +105,7 @@ func InitChainer(key sdk.StoreKey) func(sdk.Context, abci.RequestInitChain) abci
|
||||||
|
|
||||||
// AppGenState can be passed into InitCmd, returns a static string of a few
|
// AppGenState can be passed into InitCmd, returns a static string of a few
|
||||||
// key-values that can be parsed by InitChainer
|
// key-values that can be parsed by InitChainer
|
||||||
func AppGenState(_ *wire.Codec, _ []json.RawMessage) (appState json.RawMessage, err error) {
|
func AppGenState(_ *codec.Codec, _ []json.RawMessage) (appState json.RawMessage, err error) {
|
||||||
appState = json.RawMessage(`{
|
appState = json.RawMessage(`{
|
||||||
"values": [
|
"values": [
|
||||||
{
|
{
|
||||||
|
@ -122,13 +122,13 @@ func AppGenState(_ *wire.Codec, _ []json.RawMessage) (appState json.RawMessage,
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppGenStateEmpty returns an empty transaction state for mocking.
|
// AppGenStateEmpty returns an empty transaction state for mocking.
|
||||||
func AppGenStateEmpty(_ *wire.Codec, _ []json.RawMessage) (appState json.RawMessage, err error) {
|
func AppGenStateEmpty(_ *codec.Codec, _ []json.RawMessage) (appState json.RawMessage, err error) {
|
||||||
appState = json.RawMessage(``)
|
appState = json.RawMessage(``)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a validator, not much else
|
// Return a validator, not much else
|
||||||
func AppGenTx(_ *wire.Codec, pk crypto.PubKey, genTxConfig gc.GenTx) (
|
func AppGenTx(_ *codec.Codec, pk crypto.PubKey, genTxConfig gc.GenTx) (
|
||||||
appGenTx, cliPrint json.RawMessage, validator tmtypes.GenesisValidator, err error) {
|
appGenTx, cliPrint json.RawMessage, validator tmtypes.GenesisValidator, err error) {
|
||||||
|
|
||||||
validator = tmtypes.GenesisValidator{
|
validator = tmtypes.GenesisValidator{
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/server/mock"
|
"github.com/cosmos/cosmos-sdk/server/mock"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/tendermint/tendermint/abci/server"
|
"github.com/tendermint/tendermint/abci/server"
|
||||||
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
@ -26,7 +26,7 @@ func TestStartStandAlone(t *testing.T) {
|
||||||
cfg, err := tcmd.ParseConfig()
|
cfg, err := tcmd.ParseConfig()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
ctx := NewContext(cfg, logger)
|
ctx := NewContext(cfg, logger)
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
appInit := AppInit{
|
appInit := AppInit{
|
||||||
AppGenState: mock.AppGenState,
|
AppGenState: mock.AppGenState,
|
||||||
AppGenTx: mock.AppGenTx,
|
AppGenTx: mock.AppGenTx,
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
cfg "github.com/tendermint/tendermint/config"
|
cfg "github.com/tendermint/tendermint/config"
|
||||||
cmn "github.com/tendermint/tendermint/libs/common"
|
cmn "github.com/tendermint/tendermint/libs/common"
|
||||||
|
@ -30,7 +30,7 @@ var (
|
||||||
const nodeDirPerm = 0755
|
const nodeDirPerm = 0755
|
||||||
|
|
||||||
// get cmd to initialize all files for tendermint testnet and application
|
// get cmd to initialize all files for tendermint testnet and application
|
||||||
func TestnetFilesCmd(ctx *Context, cdc *wire.Codec, appInit AppInit) *cobra.Command {
|
func TestnetFilesCmd(ctx *Context, cdc *codec.Codec, appInit AppInit) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "testnet",
|
Use: "testnet",
|
||||||
Short: "Initialize files for a Gaiad testnet",
|
Short: "Initialize files for a Gaiad testnet",
|
||||||
|
@ -65,7 +65,7 @@ Example:
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func testnetWithConfig(config *cfg.Config, cdc *wire.Codec, appInit AppInit) error {
|
func testnetWithConfig(config *cfg.Config, cdc *codec.Codec, appInit AppInit) error {
|
||||||
outDir := viper.GetString(outputDir)
|
outDir := viper.GetString(outputDir)
|
||||||
numValidators := viper.GetInt(nValidators)
|
numValidators := viper.GetInt(nValidators)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package server
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ func ShowAddressCmd(ctx *Context) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
func printlnJSON(v interface{}) error {
|
func printlnJSON(v interface{}) error {
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
wire.RegisterCrypto(cdc)
|
codec.RegisterCrypto(cdc)
|
||||||
marshalled, err := cdc.MarshalJSON(v)
|
marshalled, err := cdc.MarshalJSON(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -11,8 +11,8 @@ import (
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/version"
|
"github.com/cosmos/cosmos-sdk/version"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
||||||
cfg "github.com/tendermint/tendermint/config"
|
cfg "github.com/tendermint/tendermint/config"
|
||||||
"github.com/tendermint/tendermint/libs/cli"
|
"github.com/tendermint/tendermint/libs/cli"
|
||||||
|
@ -110,7 +110,7 @@ func validateConfig(conf *cfg.Config) error {
|
||||||
|
|
||||||
// add server commands
|
// add server commands
|
||||||
func AddCommands(
|
func AddCommands(
|
||||||
ctx *Context, cdc *wire.Codec,
|
ctx *Context, cdc *codec.Codec,
|
||||||
rootCmd *cobra.Command, appInit AppInit,
|
rootCmd *cobra.Command, appInit AppInit,
|
||||||
appCreator AppCreator, appExport AppExporter) {
|
appCreator AppCreator, appExport AppExporter) {
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ func AddCommands(
|
||||||
//
|
//
|
||||||
// NOTE: The ordering of the keys returned as the resulting JSON message is
|
// NOTE: The ordering of the keys returned as the resulting JSON message is
|
||||||
// non-deterministic, so the client should not rely on key ordering.
|
// non-deterministic, so the client should not rely on key ordering.
|
||||||
func InsertKeyJSON(cdc *wire.Codec, baseJSON []byte, key string, value json.RawMessage) ([]byte, error) {
|
func InsertKeyJSON(cdc *codec.Codec, baseJSON []byte, key string, value json.RawMessage) ([]byte, error) {
|
||||||
var jsonMap map[string]json.RawMessage
|
var jsonMap map[string]json.RawMessage
|
||||||
|
|
||||||
if err := cdc.UnmarshalJSON(baseJSON, &jsonMap); err != nil {
|
if err := cdc.UnmarshalJSON(baseJSON, &jsonMap); err != nil {
|
||||||
|
@ -155,7 +155,7 @@ func InsertKeyJSON(cdc *wire.Codec, baseJSON []byte, key string, value json.RawM
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonMap[key] = value
|
jsonMap[key] = value
|
||||||
bz, err := wire.MarshalJSONIndent(cdc, jsonMap)
|
bz, err := codec.MarshalJSONIndent(cdc, jsonMap)
|
||||||
|
|
||||||
return json.RawMessage(bz), err
|
return json.RawMessage(bz), err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInsertKeyJSON(t *testing.T) {
|
func TestInsertKeyJSON(t *testing.T) {
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
|
|
||||||
foo := map[string]string{"foo": "foofoo"}
|
foo := map[string]string{"foo": "foofoo"}
|
||||||
bar := map[string]string{"barInner": "barbar"}
|
bar := map[string]string{"barInner": "barbar"}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package store
|
package store
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cdc = wire.NewCodec()
|
var cdc = codec.New()
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import wire "github.com/cosmos/cosmos-sdk/wire"
|
import "github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
|
||||||
// Register the sdk message type
|
// Register the sdk message type
|
||||||
func RegisterWire(cdc *wire.Codec) {
|
func RegisterCodec(cdc *codec.Codec) {
|
||||||
cdc.RegisterInterface((*Msg)(nil), nil)
|
cdc.RegisterInterface((*Msg)(nil), nil)
|
||||||
cdc.RegisterInterface((*Tx)(nil), nil)
|
cdc.RegisterInterface((*Tx)(nil), nil)
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
wire "github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ func TestToLeftPadded(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var cdc = wire.NewCodec()
|
var cdc = codec.New()
|
||||||
|
|
||||||
func TestZeroDeserializationJSON(t *testing.T) {
|
func TestZeroDeserializationJSON(t *testing.T) {
|
||||||
d := Dec{new(big.Int)}
|
d := Dec{new(big.Int)}
|
||||||
|
@ -242,7 +242,7 @@ func TestSerializationText(t *testing.T) {
|
||||||
require.True(t, d.Equal(d2), "original: %v, unmarshalled: %v", d, d2)
|
require.True(t, d.Equal(d2), "original: %v, unmarshalled: %v", d, d2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSerializationGoWireJSON(t *testing.T) {
|
func TestSerializationGocodecJSON(t *testing.T) {
|
||||||
d := mustNewDecFromStr(t, "0.333")
|
d := mustNewDecFromStr(t, "0.333")
|
||||||
|
|
||||||
bz, err := cdc.MarshalJSON(d)
|
bz, err := cdc.MarshalJSON(d)
|
||||||
|
@ -254,7 +254,7 @@ func TestSerializationGoWireJSON(t *testing.T) {
|
||||||
require.True(t, d.Equal(d2), "original: %v, unmarshalled: %v", d, d2)
|
require.True(t, d.Equal(d2), "original: %v, unmarshalled: %v", d, d2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSerializationGoWireBinary(t *testing.T) {
|
func TestSerializationGocodecBinary(t *testing.T) {
|
||||||
d := mustNewDecFromStr(t, "0.333")
|
d := mustNewDecFromStr(t, "0.333")
|
||||||
|
|
||||||
bz, err := cdc.MarshalBinary(d)
|
bz, err := cdc.MarshalBinary(d)
|
||||||
|
@ -273,7 +273,7 @@ type testDEmbedStruct struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO make work for UnmarshalJSON
|
// TODO make work for UnmarshalJSON
|
||||||
func TestEmbeddedStructSerializationGoWire(t *testing.T) {
|
func TestEmbeddedStructSerializationGocodec(t *testing.T) {
|
||||||
obj := testDEmbedStruct{"foo", 10, NewDecWithPrec(1, 3)}
|
obj := testDEmbedStruct{"foo", 10, NewDecWithPrec(1, 3)}
|
||||||
bz, err := cdc.MarshalBinary(obj)
|
bz, err := cdc.MarshalBinary(obj)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
cmn "github.com/tendermint/tendermint/libs/common"
|
cmn "github.com/tendermint/tendermint/libs/common"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ func (err *sdkError) Code() CodeType {
|
||||||
|
|
||||||
// Implements ABCIError.
|
// Implements ABCIError.
|
||||||
func (err *sdkError) ABCILog() string {
|
func (err *sdkError) ABCILog() string {
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
parsedErrMsg := parseCmnError(err.cmnError.Error())
|
parsedErrMsg := parseCmnError(err.cmnError.Error())
|
||||||
jsonErr := humanReadableError{
|
jsonErr := humanReadableError{
|
||||||
Codespace: err.codespace,
|
Codespace: err.codespace,
|
||||||
|
|
|
@ -4,13 +4,13 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
wire "github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Linear defines a primitive mapper type
|
// Linear defines a primitive mapper type
|
||||||
type Linear struct {
|
type Linear struct {
|
||||||
cdc *wire.Codec
|
cdc *codec.Codec
|
||||||
store sdk.KVStore
|
store sdk.KVStore
|
||||||
keys *LinearKeys
|
keys *LinearKeys
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ func DefaultLinearKeys() *LinearKeys {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLinear constructs new Linear
|
// NewLinear constructs new Linear
|
||||||
func NewLinear(cdc *wire.Codec, store sdk.KVStore, keys *LinearKeys) Linear {
|
func NewLinear(cdc *codec.Codec, store sdk.KVStore, keys *LinearKeys) Linear {
|
||||||
if keys == nil {
|
if keys == nil {
|
||||||
keys = cachedDefaultLinearKeys
|
keys = cachedDefaultLinearKeys
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ type List interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewList constructs new List
|
// NewList constructs new List
|
||||||
func NewList(cdc *wire.Codec, store sdk.KVStore, keys *LinearKeys) List {
|
func NewList(cdc *codec.Codec, store sdk.KVStore, keys *LinearKeys) List {
|
||||||
return NewLinear(cdc, store, keys)
|
return NewLinear(cdc, store, keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ type Queue interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewQueue constructs new Queue
|
// NewQueue constructs new Queue
|
||||||
func NewQueue(cdc *wire.Codec, store sdk.KVStore, keys *LinearKeys) Queue {
|
func NewQueue(cdc *codec.Codec, store sdk.KVStore, keys *LinearKeys) Queue {
|
||||||
return NewLinear(cdc, store, keys)
|
return NewLinear(cdc, store, keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@ import (
|
||||||
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/store"
|
"github.com/cosmos/cosmos-sdk/store"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
wire "github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type S struct {
|
type S struct {
|
||||||
|
@ -21,18 +21,18 @@ type S struct {
|
||||||
B bool
|
B bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultComponents(key sdk.StoreKey) (sdk.Context, *wire.Codec) {
|
func defaultComponents(key sdk.StoreKey) (sdk.Context, *codec.Codec) {
|
||||||
db := dbm.NewMemDB()
|
db := dbm.NewMemDB()
|
||||||
cms := store.NewCommitMultiStore(db)
|
cms := store.NewCommitMultiStore(db)
|
||||||
cms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db)
|
cms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db)
|
||||||
cms.LoadLatestVersion()
|
cms.LoadLatestVersion()
|
||||||
ctx := sdk.NewContext(cms, abci.Header{}, false, log.NewNopLogger())
|
ctx := sdk.NewContext(cms, abci.Header{}, false, log.NewNopLogger())
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
return ctx, cdc
|
return ctx, cdc
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewLinear(t *testing.T) {
|
func TestNewLinear(t *testing.T) {
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
require.NotPanics(t, func() { NewLinear(cdc, nil, nil) })
|
require.NotPanics(t, func() { NewLinear(cdc, nil, nil) })
|
||||||
require.NotPanics(t, func() { NewLinear(cdc, nil, DefaultLinearKeys()) })
|
require.NotPanics(t, func() { NewLinear(cdc, nil, DefaultLinearKeys()) })
|
||||||
require.NotPanics(t, func() { NewLinear(cdc, nil, &LinearKeys{[]byte{0xAA}, []byte{0xBB}, []byte{0xCC}}) })
|
require.NotPanics(t, func() { NewLinear(cdc, nil, &LinearKeys{[]byte{0xAA}, []byte{0xBB}, []byte{0xCC}}) })
|
||||||
|
|
|
@ -3,8 +3,8 @@ package auth
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/tendermint/tendermint/crypto"
|
"github.com/tendermint/tendermint/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -119,8 +119,8 @@ func (acc *BaseAccount) SetSequence(seq int64) error {
|
||||||
// Wire
|
// Wire
|
||||||
|
|
||||||
// Most users shouldn't use this, but this comes handy for tests.
|
// Most users shouldn't use this, but this comes handy for tests.
|
||||||
func RegisterBaseAccount(cdc *wire.Codec) {
|
func RegisterBaseAccount(cdc *codec.Codec) {
|
||||||
cdc.RegisterInterface((*Account)(nil), nil)
|
cdc.RegisterInterface((*Account)(nil), nil)
|
||||||
cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount", nil)
|
cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount", nil)
|
||||||
wire.RegisterCrypto(cdc)
|
codec.RegisterCrypto(cdc)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"github.com/tendermint/tendermint/crypto"
|
"github.com/tendermint/tendermint/crypto"
|
||||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||||
|
|
||||||
|
codec "github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
wire "github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func keyPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) {
|
func keyPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) {
|
||||||
|
@ -90,20 +90,19 @@ func TestBaseAccountMarshal(t *testing.T) {
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
// need a codec for marshaling
|
// need a codec for marshaling
|
||||||
codec := wire.NewCodec()
|
cdc := codec.New()
|
||||||
wire.RegisterCrypto(codec)
|
codec.RegisterCrypto(cdc)
|
||||||
|
|
||||||
b, err := codec.MarshalBinary(acc)
|
b, err := cdc.MarshalBinary(acc)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
acc2 := BaseAccount{}
|
acc2 := BaseAccount{}
|
||||||
err = codec.UnmarshalBinary(b, &acc2)
|
err = cdc.UnmarshalBinary(b, &acc2)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Equal(t, acc, acc2)
|
require.Equal(t, acc, acc2)
|
||||||
|
|
||||||
// error on bad bytes
|
// error on bad bytes
|
||||||
acc2 = BaseAccount{}
|
acc2 = BaseAccount{}
|
||||||
err = codec.UnmarshalBinary(b[:len(b)/2], &acc2)
|
err = cdc.UnmarshalBinary(b[:len(b)/2], &acc2)
|
||||||
require.NotNil(t, err)
|
require.NotNil(t, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
codec "github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
wire "github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
"github.com/tendermint/tendermint/crypto"
|
"github.com/tendermint/tendermint/crypto"
|
||||||
|
@ -110,7 +110,7 @@ func newTestTxWithSignBytes(msgs []sdk.Msg, privs []crypto.PrivKey, accNums []in
|
||||||
func TestAnteHandlerSigErrors(t *testing.T) {
|
func TestAnteHandlerSigErrors(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
ms, capKey, capKey2 := setupMultiStore()
|
ms, capKey, capKey2 := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
RegisterBaseAccount(cdc)
|
RegisterBaseAccount(cdc)
|
||||||
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
||||||
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
||||||
|
@ -163,7 +163,7 @@ func TestAnteHandlerSigErrors(t *testing.T) {
|
||||||
func TestAnteHandlerAccountNumbers(t *testing.T) {
|
func TestAnteHandlerAccountNumbers(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
ms, capKey, capKey2 := setupMultiStore()
|
ms, capKey, capKey2 := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
RegisterBaseAccount(cdc)
|
RegisterBaseAccount(cdc)
|
||||||
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
||||||
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
||||||
|
@ -222,7 +222,7 @@ func TestAnteHandlerAccountNumbers(t *testing.T) {
|
||||||
func TestAnteHandlerSequences(t *testing.T) {
|
func TestAnteHandlerSequences(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
ms, capKey, capKey2 := setupMultiStore()
|
ms, capKey, capKey2 := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
RegisterBaseAccount(cdc)
|
RegisterBaseAccount(cdc)
|
||||||
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
||||||
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
||||||
|
@ -300,7 +300,7 @@ func TestAnteHandlerSequences(t *testing.T) {
|
||||||
func TestAnteHandlerFees(t *testing.T) {
|
func TestAnteHandlerFees(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
ms, capKey, capKey2 := setupMultiStore()
|
ms, capKey, capKey2 := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
RegisterBaseAccount(cdc)
|
RegisterBaseAccount(cdc)
|
||||||
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
||||||
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
||||||
|
@ -342,7 +342,7 @@ func TestAnteHandlerFees(t *testing.T) {
|
||||||
func TestAnteHandlerMemoGas(t *testing.T) {
|
func TestAnteHandlerMemoGas(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
ms, capKey, capKey2 := setupMultiStore()
|
ms, capKey, capKey2 := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
RegisterBaseAccount(cdc)
|
RegisterBaseAccount(cdc)
|
||||||
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
||||||
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
||||||
|
@ -385,7 +385,7 @@ func TestAnteHandlerMemoGas(t *testing.T) {
|
||||||
func TestAnteHandlerMultiSigner(t *testing.T) {
|
func TestAnteHandlerMultiSigner(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
ms, capKey, capKey2 := setupMultiStore()
|
ms, capKey, capKey2 := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
RegisterBaseAccount(cdc)
|
RegisterBaseAccount(cdc)
|
||||||
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
||||||
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
||||||
|
@ -436,7 +436,7 @@ func TestAnteHandlerMultiSigner(t *testing.T) {
|
||||||
func TestAnteHandlerBadSignBytes(t *testing.T) {
|
func TestAnteHandlerBadSignBytes(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
ms, capKey, capKey2 := setupMultiStore()
|
ms, capKey, capKey2 := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
RegisterBaseAccount(cdc)
|
RegisterBaseAccount(cdc)
|
||||||
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
||||||
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
||||||
|
@ -517,7 +517,7 @@ func TestAnteHandlerBadSignBytes(t *testing.T) {
|
||||||
func TestAnteHandlerSetPubKey(t *testing.T) {
|
func TestAnteHandlerSetPubKey(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
ms, capKey, capKey2 := setupMultiStore()
|
ms, capKey, capKey2 := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
RegisterBaseAccount(cdc)
|
RegisterBaseAccount(cdc)
|
||||||
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
||||||
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
|
||||||
|
@ -570,7 +570,7 @@ func TestAnteHandlerSetPubKey(t *testing.T) {
|
||||||
|
|
||||||
func TestProcessPubKey(t *testing.T) {
|
func TestProcessPubKey(t *testing.T) {
|
||||||
ms, capKey, _ := setupMultiStore()
|
ms, capKey, _ := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
RegisterBaseAccount(cdc)
|
RegisterBaseAccount(cdc)
|
||||||
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
mapper := NewAccountMapper(cdc, capKey, ProtoBaseAccount)
|
||||||
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, log.NewNopLogger())
|
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, log.NewNopLogger())
|
||||||
|
|
|
@ -6,18 +6,18 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetAccountCmdDefault invokes the GetAccountCmd for the auth.BaseAccount type.
|
// GetAccountCmdDefault invokes the GetAccountCmd for the auth.BaseAccount type.
|
||||||
func GetAccountCmdDefault(storeName string, cdc *wire.Codec) *cobra.Command {
|
func GetAccountCmdDefault(storeName string, cdc *codec.Codec) *cobra.Command {
|
||||||
return GetAccountCmd(storeName, cdc, GetAccountDecoder(cdc))
|
return GetAccountCmd(storeName, cdc, GetAccountDecoder(cdc))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAccountDecoder gets the account decoder for auth.DefaultAccount.
|
// GetAccountDecoder gets the account decoder for auth.DefaultAccount.
|
||||||
func GetAccountDecoder(cdc *wire.Codec) auth.AccountDecoder {
|
func GetAccountDecoder(cdc *codec.Codec) auth.AccountDecoder {
|
||||||
return func(accBytes []byte) (acct auth.Account, err error) {
|
return func(accBytes []byte) (acct auth.Account, err error) {
|
||||||
err = cdc.UnmarshalBinaryBare(accBytes, &acct)
|
err = cdc.UnmarshalBinaryBare(accBytes, &acct)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -31,7 +31,7 @@ func GetAccountDecoder(cdc *wire.Codec) auth.AccountDecoder {
|
||||||
// GetAccountCmd returns a query account that will display the state of the
|
// GetAccountCmd returns a query account that will display the state of the
|
||||||
// account at a given address.
|
// account at a given address.
|
||||||
// nolint: unparam
|
// nolint: unparam
|
||||||
func GetAccountCmd(storeName string, cdc *wire.Codec, decoder auth.AccountDecoder) *cobra.Command {
|
func GetAccountCmd(storeName string, cdc *codec.Codec, decoder auth.AccountDecoder) *cobra.Command {
|
||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "account [address]",
|
Use: "account [address]",
|
||||||
Short: "Query account balance",
|
Short: "Query account balance",
|
||||||
|
@ -58,7 +58,7 @@ func GetAccountCmd(storeName string, cdc *wire.Codec, decoder auth.AccountDecode
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
output, err := wire.MarshalJSONIndent(cdc, acc)
|
output, err := codec.MarshalJSONIndent(cdc, acc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
"github.com/cosmos/cosmos-sdk/client/utils"
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// register REST routes
|
// register REST routes
|
||||||
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *wire.Codec, storeName string) {
|
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec, storeName string) {
|
||||||
r.HandleFunc(
|
r.HandleFunc(
|
||||||
"/accounts/{address}",
|
"/accounts/{address}",
|
||||||
QueryAccountRequestHandlerFn(storeName, cdc, authcmd.GetAccountDecoder(cdc), cliCtx),
|
QueryAccountRequestHandlerFn(storeName, cdc, authcmd.GetAccountDecoder(cdc), cliCtx),
|
||||||
|
@ -28,7 +28,7 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *wire.Codec, s
|
||||||
|
|
||||||
// query accountREST Handler
|
// query accountREST Handler
|
||||||
func QueryAccountRequestHandlerFn(
|
func QueryAccountRequestHandlerFn(
|
||||||
storeName string, cdc *wire.Codec,
|
storeName string, cdc *codec.Codec,
|
||||||
decoder auth.AccountDecoder, cliCtx context.CLIContext,
|
decoder auth.AccountDecoder, cliCtx context.CLIContext,
|
||||||
) http.HandlerFunc {
|
) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
"github.com/cosmos/cosmos-sdk/client/utils"
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||||
)
|
)
|
||||||
|
@ -23,7 +23,7 @@ type SignBody struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sign tx REST handler
|
// sign tx REST handler
|
||||||
func SignTxRequestHandlerFn(cdc *wire.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
func SignTxRequestHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var m SignBody
|
var m SignBody
|
||||||
|
@ -51,7 +51,7 @@ func SignTxRequestHandlerFn(cdc *wire.Codec, cliCtx context.CLIContext) http.Han
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
output, err := wire.MarshalJSONIndent(cdc, signedTx)
|
output, err := codec.MarshalJSONIndent(cdc, signedTx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||||
return
|
return
|
||||||
|
|
|
@ -3,8 +3,8 @@ package context
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/keys"
|
"github.com/cosmos/cosmos-sdk/client/keys"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -13,7 +13,7 @@ import (
|
||||||
|
|
||||||
// TxBuilder implements a transaction context created in SDK modules.
|
// TxBuilder implements a transaction context created in SDK modules.
|
||||||
type TxBuilder struct {
|
type TxBuilder struct {
|
||||||
Codec *wire.Codec
|
Codec *codec.Codec
|
||||||
AccountNumber int64
|
AccountNumber int64
|
||||||
Sequence int64
|
Sequence int64
|
||||||
Gas int64 // TODO: should this turn into uint64? requires further discussion - see #2173
|
Gas int64 // TODO: should this turn into uint64? requires further discussion - see #2173
|
||||||
|
@ -49,7 +49,7 @@ func NewTxBuilderFromCLI() TxBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithCodec returns a copy of the context with an updated codec.
|
// WithCodec returns a copy of the context with an updated codec.
|
||||||
func (bldr TxBuilder) WithCodec(cdc *wire.Codec) TxBuilder {
|
func (bldr TxBuilder) WithCodec(cdc *codec.Codec) TxBuilder {
|
||||||
bldr.Codec = cdc
|
bldr.Codec = cdc
|
||||||
return bldr
|
return bldr
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package auth
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Register concrete types on codec codec for default AppAccount
|
||||||
|
func RegisterCodec(cdc *codec.Codec) {
|
||||||
|
cdc.RegisterInterface((*Account)(nil), nil)
|
||||||
|
cdc.RegisterConcrete(&BaseAccount{}, "auth/Account", nil)
|
||||||
|
cdc.RegisterConcrete(StdTx{}, "auth/StdTx", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
var msgCdc = codec.New()
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
RegisterCodec(msgCdc)
|
||||||
|
codec.RegisterCrypto(msgCdc)
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
codec "github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
wire "github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -16,12 +16,12 @@ type FeeCollectionKeeper struct {
|
||||||
// The (unexposed) key used to access the fee store from the Context.
|
// The (unexposed) key used to access the fee store from the Context.
|
||||||
key sdk.StoreKey
|
key sdk.StoreKey
|
||||||
|
|
||||||
// The wire codec for binary encoding/decoding of accounts.
|
// The codec codec for binary encoding/decoding of accounts.
|
||||||
cdc *wire.Codec
|
cdc *codec.Codec
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFeeKeeper returns a new FeeKeeper
|
// NewFeeKeeper returns a new FeeKeeper
|
||||||
func NewFeeCollectionKeeper(cdc *wire.Codec, key sdk.StoreKey) FeeCollectionKeeper {
|
func NewFeeCollectionKeeper(cdc *codec.Codec, key sdk.StoreKey) FeeCollectionKeeper {
|
||||||
return FeeCollectionKeeper{
|
return FeeCollectionKeeper{
|
||||||
key: key,
|
key: key,
|
||||||
cdc: cdc,
|
cdc: cdc,
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
|
||||||
|
codec "github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
wire "github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -20,7 +20,7 @@ var (
|
||||||
|
|
||||||
func TestFeeCollectionKeeperGetSet(t *testing.T) {
|
func TestFeeCollectionKeeperGetSet(t *testing.T) {
|
||||||
ms, _, capKey2 := setupMultiStore()
|
ms, _, capKey2 := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
|
|
||||||
// make context and keeper
|
// make context and keeper
|
||||||
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||||
|
@ -39,7 +39,7 @@ func TestFeeCollectionKeeperGetSet(t *testing.T) {
|
||||||
|
|
||||||
func TestFeeCollectionKeeperAdd(t *testing.T) {
|
func TestFeeCollectionKeeperAdd(t *testing.T) {
|
||||||
ms, _, capKey2 := setupMultiStore()
|
ms, _, capKey2 := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
|
|
||||||
// make context and keeper
|
// make context and keeper
|
||||||
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||||
|
@ -59,7 +59,7 @@ func TestFeeCollectionKeeperAdd(t *testing.T) {
|
||||||
|
|
||||||
func TestFeeCollectionKeeperClear(t *testing.T) {
|
func TestFeeCollectionKeeperClear(t *testing.T) {
|
||||||
ms, _, capKey2 := setupMultiStore()
|
ms, _, capKey2 := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
|
|
||||||
// make context and keeper
|
// make context and keeper
|
||||||
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
codec "github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
wire "github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/tendermint/tendermint/crypto"
|
"github.com/tendermint/tendermint/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,14 +18,14 @@ type AccountMapper struct {
|
||||||
// The prototypical Account constructor.
|
// The prototypical Account constructor.
|
||||||
proto func() Account
|
proto func() Account
|
||||||
|
|
||||||
// The wire codec for binary encoding/decoding of accounts.
|
// The codec codec for binary encoding/decoding of accounts.
|
||||||
cdc *wire.Codec
|
cdc *codec.Codec
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAccountMapper returns a new sdk.AccountMapper that
|
// NewAccountMapper returns a new sdk.AccountMapper that
|
||||||
// uses go-amino to (binary) encode and decode concrete sdk.Accounts.
|
// uses go-amino to (binary) encode and decode concrete sdk.Accounts.
|
||||||
// nolint
|
// nolint
|
||||||
func NewAccountMapper(cdc *wire.Codec, key sdk.StoreKey, proto func() Account) AccountMapper {
|
func NewAccountMapper(cdc *codec.Codec, key sdk.StoreKey, proto func() Account) AccountMapper {
|
||||||
return AccountMapper{
|
return AccountMapper{
|
||||||
key: key,
|
key: key,
|
||||||
proto: proto,
|
proto: proto,
|
||||||
|
|
|
@ -9,9 +9,9 @@ import (
|
||||||
dbm "github.com/tendermint/tendermint/libs/db"
|
dbm "github.com/tendermint/tendermint/libs/db"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
|
||||||
|
codec "github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/store"
|
"github.com/cosmos/cosmos-sdk/store"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
wire "github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupMultiStore() (sdk.MultiStore, *sdk.KVStoreKey, *sdk.KVStoreKey) {
|
func setupMultiStore() (sdk.MultiStore, *sdk.KVStoreKey, *sdk.KVStoreKey) {
|
||||||
|
@ -27,7 +27,7 @@ func setupMultiStore() (sdk.MultiStore, *sdk.KVStoreKey, *sdk.KVStoreKey) {
|
||||||
|
|
||||||
func TestAccountMapperGetSet(t *testing.T) {
|
func TestAccountMapperGetSet(t *testing.T) {
|
||||||
ms, capKey, _ := setupMultiStore()
|
ms, capKey, _ := setupMultiStore()
|
||||||
cdc := wire.NewCodec()
|
cdc := codec.New()
|
||||||
RegisterBaseAccount(cdc)
|
RegisterBaseAccount(cdc)
|
||||||
|
|
||||||
// make context and mapper
|
// make context and mapper
|
||||||
|
|
|
@ -3,8 +3,8 @@ package auth
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
"github.com/tendermint/tendermint/crypto"
|
"github.com/tendermint/tendermint/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ type StdSignature struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// logic for standard transaction decoding
|
// logic for standard transaction decoding
|
||||||
func DefaultTxDecoder(cdc *wire.Codec) sdk.TxDecoder {
|
func DefaultTxDecoder(cdc *codec.Codec) sdk.TxDecoder {
|
||||||
return func(txBytes []byte) (sdk.Tx, sdk.Error) {
|
return func(txBytes []byte) (sdk.Tx, sdk.Error) {
|
||||||
var tx = StdTx{}
|
var tx = StdTx{}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
package auth
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Register concrete types on wire codec for default AppAccount
|
|
||||||
func RegisterWire(cdc *wire.Codec) {
|
|
||||||
cdc.RegisterInterface((*Account)(nil), nil)
|
|
||||||
cdc.RegisterConcrete(&BaseAccount{}, "auth/Account", nil)
|
|
||||||
cdc.RegisterConcrete(StdTx{}, "auth/StdTx", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
var msgCdc = wire.NewCodec()
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
RegisterWire(msgCdc)
|
|
||||||
wire.RegisterCrypto(msgCdc)
|
|
||||||
}
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
func getBenchmarkMockApp() (*mock.App, error) {
|
func getBenchmarkMockApp() (*mock.App, error) {
|
||||||
mapp := mock.NewApp()
|
mapp := mock.NewApp()
|
||||||
|
|
||||||
RegisterWire(mapp.Cdc)
|
RegisterCodec(mapp.Cdc)
|
||||||
bankKeeper := NewBaseKeeper(mapp.AccountMapper)
|
bankKeeper := NewBaseKeeper(mapp.AccountMapper)
|
||||||
mapp.Router().AddRoute("bank", NewHandler(bankKeeper))
|
mapp.Router().AddRoute("bank", NewHandler(bankKeeper))
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
"github.com/cosmos/cosmos-sdk/client/utils"
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/wire"
|
|
||||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank/client"
|
"github.com/cosmos/cosmos-sdk/x/bank/client"
|
||||||
|
@ -22,7 +22,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// SendTxCmd will create a send tx and sign it with the given key.
|
// SendTxCmd will create a send tx and sign it with the given key.
|
||||||
func SendTxCmd(cdc *wire.Codec) *cobra.Command {
|
func SendTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "send",
|
Use: "send",
|
||||||
Short: "Create and sign a send tx",
|
Short: "Create and sign a send tx",
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue