Skip to content

Commit

Permalink
Migrate to sdk goz-phase-3
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe committed Jun 5, 2020
1 parent 015802e commit 20bd2c9
Show file tree
Hide file tree
Showing 14 changed files with 268 additions and 215 deletions.
27 changes: 11 additions & 16 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,8 @@ import (
"os"
"path/filepath"

"github.com/spf13/viper"

abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
codecstd "github.com/cosmos/cosmos-sdk/codec/std"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/std"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -42,6 +33,12 @@ import (
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
"github.com/spf13/viper"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

"github.com/cosmwasm/wasmd/x/wasm"
)
Expand Down Expand Up @@ -155,9 +152,7 @@ func NewWasmApp(
baseAppOptions ...func(*baseapp.BaseApp),
) *WasmApp {

// TODO: Remove cdc in favor of appCodec once all modules are migrated.
cdc := codecstd.MakeCodec(ModuleBasics)
appCodec := codecstd.NewAppCodec(cdc)
appCodec, cdc := MakeCodecs()

bApp := baseapp.NewBaseApp(appName, logger, db, auth.DefaultTxDecoder(cdc), baseAppOptions...)
bApp.SetCommitMultiStoreTracer(traceStore)
Expand Down Expand Up @@ -262,12 +257,12 @@ func NewWasmApp(

// Create IBC Keeper
app.ibcKeeper = ibc.NewKeeper(
app.cdc, keys[ibc.StoreKey], app.stakingKeeper, scopedIBCKeeper,
app.cdc, appCodec, keys[ibc.StoreKey], app.stakingKeeper, scopedIBCKeeper,
)

// Create Transfer Keepers
app.transferKeeper = transfer.NewKeeper(
app.cdc, keys[transfer.StoreKey],
appCodec, keys[transfer.StoreKey],
app.ibcKeeper.ChannelKeeper, &app.ibcKeeper.PortKeeper,
app.accountKeeper, app.bankKeeper,
scopedTransferKeeper,
Expand Down Expand Up @@ -295,7 +290,7 @@ func NewWasmApp(
genutil.NewAppModule(app.accountKeeper, app.stakingKeeper, app.BaseApp.DeliverTx),
auth.NewAppModule(appCodec, app.accountKeeper),
bank.NewAppModule(appCodec, app.bankKeeper, app.accountKeeper),
capability.NewAppModule(*app.capabilityKeeper),
capability.NewAppModule(appCodec, *app.capabilityKeeper),
crisis.NewAppModule(&app.crisisKeeper),
gov.NewAppModule(appCodec, app.govKeeper, app.accountKeeper, app.bankKeeper),
mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper),
Expand All @@ -304,7 +299,7 @@ func NewWasmApp(
staking.NewAppModule(appCodec, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
upgrade.NewAppModule(app.upgradeKeeper),
wasm.NewAppModule(app.wasmKeeper),
evidence.NewAppModule(appCodec, app.evidenceKeeper),
evidence.NewAppModule(app.evidenceKeeper),
ibc.NewAppModule(app.ibcKeeper),
params.NewAppModule(app.paramsKeeper),
transferModule,
Expand Down
3 changes: 1 addition & 2 deletions app/benchmarks/txsize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/tendermint/tendermint/crypto/secp256k1"

codecstd "github.com/cosmos/cosmos-sdk/codec/std"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/bank"
Expand All @@ -17,7 +16,7 @@ import (
// This is due to secp256k1 signatures not being constant size.
// nolint: vet
func ExampleTxSendSize() {
cdc := codecstd.MakeCodec(app.ModuleBasics)
_, cdc := app.MakeCodecs()

var gas uint64 = 1

Expand Down
17 changes: 17 additions & 0 deletions app/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package app

import (
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/std"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func MakeCodecs() (*std.Codec, *codec.Codec) {
cdc := std.MakeCodec(ModuleBasics)
interfaceRegistry := codectypes.NewInterfaceRegistry()
sdk.RegisterInterfaces(interfaceRegistry)
ModuleBasics.RegisterInterfaceModules(interfaceRegistry)
appCodec := std.NewAppCodec(cdc, interfaceRegistry)
return appCodec, cdc
}
4 changes: 2 additions & 2 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package app
import (
"encoding/json"

codecstd "github.com/cosmos/cosmos-sdk/codec/std"
"github.com/cosmos/cosmos-sdk/std"
)

// GenesisState defines a type alias for the Gaia genesis application state.
type GenesisState map[string]json.RawMessage

// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState() GenesisState {
cdc := codecstd.MakeCodec(ModuleBasics)
cdc := std.MakeCodec(ModuleBasics)
return ModuleBasics.DefaultGenesis(cdc)
}
Loading

0 comments on commit 20bd2c9

Please sign in to comment.