Merge PR #2324: rename wire to codec
* rename wire to codec * fix formatting and cli * fix the docs
This commit is contained in:
@@ -4,9 +4,9 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/examples/basecoin/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/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||
@@ -27,7 +27,7 @@ const (
|
||||
// integral app types.
|
||||
type BasecoinApp struct {
|
||||
*bam.BaseApp
|
||||
cdc *wire.Codec
|
||||
cdc *codec.Codec
|
||||
|
||||
// keys to access the multistore
|
||||
keyMain *sdk.KVStoreKey
|
||||
@@ -93,16 +93,16 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.Ba
|
||||
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.
|
||||
func MakeCodec() *wire.Codec {
|
||||
cdc := wire.NewCodec()
|
||||
func MakeCodec() *codec.Codec {
|
||||
cdc := codec.New()
|
||||
|
||||
wire.RegisterCrypto(cdc)
|
||||
sdk.RegisterWire(cdc)
|
||||
bank.RegisterWire(cdc)
|
||||
ibc.RegisterWire(cdc)
|
||||
auth.RegisterWire(cdc)
|
||||
codec.RegisterCrypto(cdc)
|
||||
sdk.RegisterCodec(cdc)
|
||||
bank.RegisterCodec(cdc)
|
||||
ibc.RegisterCodec(cdc)
|
||||
auth.RegisterCodec(cdc)
|
||||
|
||||
// register custom type
|
||||
cdc.RegisterConcrete(&types.AppAccount{}, "basecoin/Account", nil)
|
||||
@@ -173,7 +173,7 @@ func (app *BasecoinApp) ExportAppStateAndValidators() (appState json.RawMessage,
|
||||
app.accountMapper.IterateAccounts(ctx, appendAccountsFn)
|
||||
|
||||
genState := types.GenesisState{Accounts: accounts}
|
||||
appState, err = wire.MarshalJSONIndent(app.cdc, genState)
|
||||
appState, err = codec.MarshalJSONIndent(app.cdc, genState)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/examples/basecoin/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/stretchr/testify/require"
|
||||
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}
|
||||
stateBytes, err := wire.MarshalJSONIndent(baseApp.cdc, genesisState)
|
||||
stateBytes, err := codec.MarshalJSONIndent(baseApp.cdc, genesisState)
|
||||
if err != nil {
|
||||
return types.GenesisState{}, err
|
||||
}
|
||||
@@ -67,7 +67,7 @@ func TestGenesis(t *testing.T) {
|
||||
// reload app and ensure the account is still there
|
||||
baseApp = NewBasecoinApp(logger, db)
|
||||
|
||||
stateBytes, err := wire.MarshalJSONIndent(baseApp.cdc, genState)
|
||||
stateBytes, err := codec.MarshalJSONIndent(baseApp.cdc, genState)
|
||||
require.Nil(t, err)
|
||||
|
||||
// initialize the chain with the expected genesis state
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
"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
|
||||
// AppAccount.
|
||||
func GetAccountDecoder(cdc *wire.Codec) auth.AccountDecoder {
|
||||
func GetAccountDecoder(cdc *codec.Codec) auth.AccountDecoder {
|
||||
return func(accBytes []byte) (auth.Account, error) {
|
||||
if len(accBytes) == 0 {
|
||||
return nil, sdk.ErrTxDecode("accBytes are empty")
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
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/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||
@@ -30,7 +30,7 @@ const (
|
||||
// Extended ABCI application
|
||||
type DemocoinApp struct {
|
||||
*bam.BaseApp
|
||||
cdc *wire.Codec
|
||||
cdc *codec.Codec
|
||||
|
||||
// keys to access the substores
|
||||
capKeyMainStore *sdk.KVStoreKey
|
||||
@@ -103,15 +103,15 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
|
||||
}
|
||||
|
||||
// custom tx codec
|
||||
func MakeCodec() *wire.Codec {
|
||||
var cdc = wire.NewCodec()
|
||||
wire.RegisterCrypto(cdc) // Register crypto.
|
||||
sdk.RegisterWire(cdc) // Register Msgs
|
||||
cool.RegisterWire(cdc)
|
||||
pow.RegisterWire(cdc)
|
||||
bank.RegisterWire(cdc)
|
||||
ibc.RegisterWire(cdc)
|
||||
simplestake.RegisterWire(cdc)
|
||||
func MakeCodec() *codec.Codec {
|
||||
var cdc = codec.New()
|
||||
codec.RegisterCrypto(cdc) // Register crypto.
|
||||
sdk.RegisterCodec(cdc) // Register Msgs
|
||||
cool.RegisterCodec(cdc)
|
||||
pow.RegisterCodec(cdc)
|
||||
bank.RegisterCodec(cdc)
|
||||
ibc.RegisterCodec(cdc)
|
||||
simplestake.RegisterCodec(cdc)
|
||||
|
||||
// Register AppAccount
|
||||
cdc.RegisterInterface((*auth.Account)(nil), nil)
|
||||
@@ -182,7 +182,7 @@ func (app *DemocoinApp) ExportAppStateAndValidators() (appState json.RawMessage,
|
||||
POWGenesis: pow.WriteGenesis(ctx, app.powKeeper),
|
||||
CoolGenesis: cool.WriteGenesis(ctx, app.coolKeeper),
|
||||
}
|
||||
appState, err = wire.MarshalJSONIndent(app.cdc, genState)
|
||||
appState, err = codec.MarshalJSONIndent(app.cdc, genState)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/examples/democoin/types"
|
||||
"github.com/cosmos/cosmos-sdk/examples/democoin/x/cool"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/stretchr/testify/require"
|
||||
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},
|
||||
}
|
||||
|
||||
stateBytes, err := wire.MarshalJSONIndent(bapp.cdc, genesisState)
|
||||
stateBytes, err := codec.MarshalJSONIndent(bapp.cdc, genesisState)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
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/server"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
)
|
||||
|
||||
// init parameters
|
||||
@@ -25,7 +25,7 @@ var CoolAppInit = server.AppInit{
|
||||
}
|
||||
|
||||
// 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)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
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/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 }
|
||||
|
||||
// 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) {
|
||||
if len(accBytes) == 0 {
|
||||
return nil, sdk.ErrTxDecode("accBytes are empty")
|
||||
|
||||
@@ -3,8 +3,8 @@ package assoc
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
)
|
||||
|
||||
// ValidatorSet defines
|
||||
@@ -12,7 +12,7 @@ type ValidatorSet struct {
|
||||
sdk.ValidatorSet
|
||||
|
||||
store sdk.KVStore
|
||||
cdc *wire.Codec
|
||||
cdc *codec.Codec
|
||||
|
||||
maxAssoc int
|
||||
addrLen int
|
||||
@@ -21,7 +21,7 @@ type ValidatorSet struct {
|
||||
var _ sdk.ValidatorSet = 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 {
|
||||
panic("Cannot use negative integer for NewValidatorSet")
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
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/store"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
)
|
||||
|
||||
func defaultContext(key sdk.StoreKey) sdk.Context {
|
||||
@@ -36,7 +36,7 @@ func TestValidatorSet(t *testing.T) {
|
||||
{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, addr2), valset.Validator(ctx, addr2))
|
||||
|
||||
@@ -47,7 +47,7 @@ var (
|
||||
func getMockApp(t *testing.T) *mock.App {
|
||||
mapp := mock.NewApp()
|
||||
|
||||
RegisterWire(mapp.Cdc)
|
||||
RegisterCodec(mapp.Cdc)
|
||||
keyCool := sdk.NewKVStoreKey("cool")
|
||||
bankKeeper := bank.NewBaseKeeper(mapp.AccountMapper)
|
||||
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/utils"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/examples/democoin/x/cool"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
)
|
||||
|
||||
// QuizTxCmd invokes the coolness quiz transaction.
|
||||
func QuizTxCmd(cdc *wire.Codec) *cobra.Command {
|
||||
func QuizTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "cool [answer]",
|
||||
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.
|
||||
func SetTrendTxCmd(cdc *wire.Codec) *cobra.Command {
|
||||
func SetTrendTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "setcool [answer]",
|
||||
Short: "You're so cool, tell us what is cool!",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package cool
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
// Register concrete types on wire codec
|
||||
func RegisterWire(cdc *wire.Codec) {
|
||||
// Register concrete types on codec codec
|
||||
func RegisterCodec(cdc *codec.Codec) {
|
||||
cdc.RegisterConcrete(MsgQuiz{}, "cool/Quiz", nil)
|
||||
cdc.RegisterConcrete(MsgSetTrend{}, "cool/SetTrend", nil)
|
||||
}
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
dbm "github.com/tendermint/tendermint/libs/db"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
auth "github.com/cosmos/cosmos-sdk/x/auth"
|
||||
bank "github.com/cosmos/cosmos-sdk/x/bank"
|
||||
)
|
||||
@@ -26,7 +26,7 @@ func setupMultiStore() (sdk.MultiStore, *sdk.KVStoreKey) {
|
||||
|
||||
func TestCoolKeeper(t *testing.T) {
|
||||
ms, capKey := setupMultiStore()
|
||||
cdc := wire.NewCodec()
|
||||
cdc := codec.New()
|
||||
auth.RegisterBaseAccount(cdc)
|
||||
|
||||
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`.
|
||||
|
||||
```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 {
|
||||
cdc: cdc,
|
||||
key: key,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package oracle
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
// Keeper of the oracle store
|
||||
type Keeper struct {
|
||||
key sdk.StoreKey
|
||||
cdc *wire.Codec
|
||||
cdc *codec.Codec
|
||||
|
||||
valset sdk.ValidatorSet
|
||||
|
||||
@@ -18,7 +18,7 @@ type Keeper struct {
|
||||
}
|
||||
|
||||
// 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 {
|
||||
panic("Timeout should not be negative")
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
package oracle
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
)
|
||||
|
||||
// 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)
|
||||
return append([]byte{0x00}, bz...)
|
||||
}
|
||||
|
||||
// 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)
|
||||
return append([]byte{0x01}, bz...)
|
||||
}
|
||||
|
||||
// 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...)
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
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/store"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
)
|
||||
|
||||
func defaultContext(keys ...sdk.StoreKey) sdk.Context {
|
||||
@@ -39,8 +39,8 @@ func (o seqOracle) ValidateBasic() sdk.Error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func makeCodec() *wire.Codec {
|
||||
var cdc = wire.NewCodec()
|
||||
func makeCodec() *codec.Codec {
|
||||
var cdc = codec.New()
|
||||
|
||||
cdc.RegisterInterface((*sdk.Msg)(nil), nil)
|
||||
cdc.RegisterConcrete(Msg{}, "test/Oracle", nil)
|
||||
@@ -79,7 +79,7 @@ func getSequence(ctx sdk.Context, key sdk.StoreKey) int {
|
||||
if seqbz == nil {
|
||||
seq = 0
|
||||
} else {
|
||||
wire.NewCodec().MustUnmarshalBinary(seqbz, &seq)
|
||||
codec.New().MustUnmarshalBinary(seqbz, &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, "")
|
||||
}
|
||||
|
||||
bz := wire.NewCodec().MustMarshalBinary(seq + 1)
|
||||
bz := codec.New().MustMarshalBinary(seq + 1)
|
||||
store.Set([]byte("seq"), bz)
|
||||
|
||||
return nil
|
||||
|
||||
@@ -23,7 +23,7 @@ var (
|
||||
func getMockApp(t *testing.T) *mock.App {
|
||||
mapp := mock.NewApp()
|
||||
|
||||
RegisterWire(mapp.Cdc)
|
||||
RegisterCodec(mapp.Cdc)
|
||||
keyPOW := sdk.NewKVStoreKey("pow")
|
||||
bankKeeper := bank.NewBaseKeeper(mapp.AccountMapper)
|
||||
config := Config{"pow", 1}
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/examples/democoin/x/pow"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
// command to mine some pow!
|
||||
func MineCmd(cdc *wire.Codec) *cobra.Command {
|
||||
func MineCmd(cdc *codec.Codec) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "mine [difficulty] [count] [nonce] [solution]",
|
||||
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"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
codec "github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
wire "github.com/cosmos/cosmos-sdk/wire"
|
||||
auth "github.com/cosmos/cosmos-sdk/x/auth"
|
||||
bank "github.com/cosmos/cosmos-sdk/x/bank"
|
||||
)
|
||||
|
||||
func TestPowHandler(t *testing.T) {
|
||||
ms, capKey := setupMultiStore()
|
||||
cdc := wire.NewCodec()
|
||||
cdc := codec.New()
|
||||
auth.RegisterBaseAccount(cdc)
|
||||
|
||||
am := auth.NewAccountMapper(cdc, capKey, auth.ProtoBaseAccount)
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
dbm "github.com/tendermint/tendermint/libs/db"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
auth "github.com/cosmos/cosmos-sdk/x/auth"
|
||||
bank "github.com/cosmos/cosmos-sdk/x/bank"
|
||||
)
|
||||
@@ -29,7 +29,7 @@ func setupMultiStore() (sdk.MultiStore, *sdk.KVStoreKey) {
|
||||
|
||||
func TestPowKeeperGetSet(t *testing.T) {
|
||||
ms, capKey := setupMultiStore()
|
||||
cdc := wire.NewCodec()
|
||||
cdc := codec.New()
|
||||
auth.RegisterBaseAccount(cdc)
|
||||
|
||||
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/utils"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/examples/democoin/x/simplestake"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||
|
||||
@@ -25,7 +25,7 @@ const (
|
||||
)
|
||||
|
||||
// simple bond tx
|
||||
func BondTxCmd(cdc *wire.Codec) *cobra.Command {
|
||||
func BondTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "bond",
|
||||
Short: "Bond to a validator",
|
||||
@@ -79,7 +79,7 @@ func BondTxCmd(cdc *wire.Codec) *cobra.Command {
|
||||
}
|
||||
|
||||
// simple unbond tx
|
||||
func UnbondTxCmd(cdc *wire.Codec) *cobra.Command {
|
||||
func UnbondTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "unbond",
|
||||
Short: "Unbond from a validator",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package simplestake
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
// Register concrete types on wire codec
|
||||
func RegisterWire(cdc *wire.Codec) {
|
||||
// Register concrete types on codec codec
|
||||
func RegisterCodec(cdc *codec.Codec) {
|
||||
cdc.RegisterConcrete(MsgBond{}, "simplestake/BondMsg", nil)
|
||||
cdc.RegisterConcrete(MsgUnbond{}, "simplestake/UnbondMsg", nil)
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package simplestake
|
||||
import (
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/wire"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
)
|
||||
|
||||
@@ -17,13 +17,13 @@ type Keeper struct {
|
||||
ck bank.Keeper
|
||||
|
||||
key sdk.StoreKey
|
||||
cdc *wire.Codec
|
||||
cdc *codec.Codec
|
||||
codespace sdk.CodespaceType
|
||||
}
|
||||
|
||||
func NewKeeper(key sdk.StoreKey, bankKeeper bank.Keeper, codespace sdk.CodespaceType) Keeper {
|
||||
cdc := wire.NewCodec()
|
||||
wire.RegisterCrypto(cdc)
|
||||
cdc := codec.New()
|
||||
codec.RegisterCrypto(cdc)
|
||||
return Keeper{
|
||||
key: key,
|
||||
cdc: cdc,
|
||||
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
dbm "github.com/tendermint/tendermint/libs/db"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
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/bank"
|
||||
)
|
||||
@@ -32,7 +32,7 @@ func setupMultiStore() (sdk.MultiStore, *sdk.KVStoreKey, *sdk.KVStoreKey) {
|
||||
|
||||
func TestKeeperGetSet(t *testing.T) {
|
||||
ms, authKey, capKey := setupMultiStore()
|
||||
cdc := wire.NewCodec()
|
||||
cdc := codec.New()
|
||||
auth.RegisterBaseAccount(cdc)
|
||||
|
||||
accountMapper := auth.NewAccountMapper(cdc, authKey, auth.ProtoBaseAccount)
|
||||
@@ -60,7 +60,7 @@ func TestKeeperGetSet(t *testing.T) {
|
||||
|
||||
func TestBonding(t *testing.T) {
|
||||
ms, authKey, capKey := setupMultiStore()
|
||||
cdc := wire.NewCodec()
|
||||
cdc := codec.New()
|
||||
auth.RegisterBaseAccount(cdc)
|
||||
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, log.NewNopLogger())
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user