refactor: Remove store type aliases (#10295)
<!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Closes: #9362 <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [X] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [X] added `!` to the type prefix if API or client breaking change - [X] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [X] provided a link to the relevant issue or specification - [X] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [X] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [X] added a changelog entry to `CHANGELOG.md` - [X] included comments for [documenting Go code](https://blog.golang.org/godoc) - [X] updated the relevant documentation or specification - [X] reviewed "Files changed" and left comments if necessary - [X] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
This commit is contained in:
parent
b601f521cb
commit
d07e41683a
@ -50,6 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### API Breaking Changes
|
||||
|
||||
* [\#10295](https://github.com/cosmos/cosmos-sdk/pull/10295) Remove store type aliases from /types
|
||||
* [\#9695](https://github.com/cosmos/cosmos-sdk/pull/9695) Migrate keys from `Info` -> `Record`
|
||||
* Add new `codec.Codec` argument in:
|
||||
* `keyring.NewInMemory`
|
||||
|
||||
@ -15,6 +15,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/snapshots"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
"github.com/cosmos/cosmos-sdk/store/rootmulti"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx"
|
||||
)
|
||||
@ -185,20 +186,20 @@ func (app *BaseApp) Trace() bool {
|
||||
|
||||
// MountStores mounts all IAVL or DB stores to the provided keys in the BaseApp
|
||||
// multistore.
|
||||
func (app *BaseApp) MountStores(keys ...sdk.StoreKey) {
|
||||
func (app *BaseApp) MountStores(keys ...storetypes.StoreKey) {
|
||||
for _, key := range keys {
|
||||
switch key.(type) {
|
||||
case *sdk.KVStoreKey:
|
||||
case *storetypes.KVStoreKey:
|
||||
if !app.fauxMerkleMode {
|
||||
app.MountStore(key, sdk.StoreTypeIAVL)
|
||||
app.MountStore(key, storetypes.StoreTypeIAVL)
|
||||
} else {
|
||||
// StoreTypeDB doesn't do anything upon commit, and it doesn't
|
||||
// retain history, but it's useful for faster simulation.
|
||||
app.MountStore(key, sdk.StoreTypeDB)
|
||||
app.MountStore(key, storetypes.StoreTypeDB)
|
||||
}
|
||||
|
||||
case *sdk.TransientStoreKey:
|
||||
app.MountStore(key, sdk.StoreTypeTransient)
|
||||
case *storetypes.TransientStoreKey:
|
||||
app.MountStore(key, storetypes.StoreTypeTransient)
|
||||
|
||||
default:
|
||||
panic("Unrecognized store key type " + reflect.TypeOf(key).Name())
|
||||
@ -208,37 +209,37 @@ func (app *BaseApp) MountStores(keys ...sdk.StoreKey) {
|
||||
|
||||
// MountKVStores mounts all IAVL or DB stores to the provided keys in the
|
||||
// BaseApp multistore.
|
||||
func (app *BaseApp) MountKVStores(keys map[string]*sdk.KVStoreKey) {
|
||||
func (app *BaseApp) MountKVStores(keys map[string]*storetypes.KVStoreKey) {
|
||||
for _, key := range keys {
|
||||
if !app.fauxMerkleMode {
|
||||
app.MountStore(key, sdk.StoreTypeIAVL)
|
||||
app.MountStore(key, storetypes.StoreTypeIAVL)
|
||||
} else {
|
||||
// StoreTypeDB doesn't do anything upon commit, and it doesn't
|
||||
// retain history, but it's useful for faster simulation.
|
||||
app.MountStore(key, sdk.StoreTypeDB)
|
||||
app.MountStore(key, storetypes.StoreTypeDB)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MountTransientStores mounts all transient stores to the provided keys in
|
||||
// the BaseApp multistore.
|
||||
func (app *BaseApp) MountTransientStores(keys map[string]*sdk.TransientStoreKey) {
|
||||
func (app *BaseApp) MountTransientStores(keys map[string]*storetypes.TransientStoreKey) {
|
||||
for _, key := range keys {
|
||||
app.MountStore(key, sdk.StoreTypeTransient)
|
||||
app.MountStore(key, storetypes.StoreTypeTransient)
|
||||
}
|
||||
}
|
||||
|
||||
// MountMemoryStores mounts all in-memory KVStores with the BaseApp's internal
|
||||
// commit multi-store.
|
||||
func (app *BaseApp) MountMemoryStores(keys map[string]*sdk.MemoryStoreKey) {
|
||||
func (app *BaseApp) MountMemoryStores(keys map[string]*storetypes.MemoryStoreKey) {
|
||||
for _, memKey := range keys {
|
||||
app.MountStore(memKey, sdk.StoreTypeMemory)
|
||||
app.MountStore(memKey, storetypes.StoreTypeMemory)
|
||||
}
|
||||
}
|
||||
|
||||
// MountStore mounts a store to the provided key in the BaseApp multistore,
|
||||
// using the default DB.
|
||||
func (app *BaseApp) MountStore(key sdk.StoreKey, typ sdk.StoreType) {
|
||||
func (app *BaseApp) MountStore(key storetypes.StoreKey, typ storetypes.StoreType) {
|
||||
app.cms.MountStoreWithDB(key, typ, nil)
|
||||
}
|
||||
|
||||
@ -270,7 +271,7 @@ func (app *BaseApp) LoadVersion(version int64) error {
|
||||
}
|
||||
|
||||
// LastCommitID returns the last CommitID of the multistore.
|
||||
func (app *BaseApp) LastCommitID() sdk.CommitID {
|
||||
func (app *BaseApp) LastCommitID() storetypes.CommitID {
|
||||
return app.cms.LastCommitID()
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/snapshots"
|
||||
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
|
||||
"github.com/cosmos/cosmos-sdk/store/rootmulti"
|
||||
store "github.com/cosmos/cosmos-sdk/store/types"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
@ -234,7 +234,7 @@ func TestMountStores(t *testing.T) {
|
||||
// Test that LoadLatestVersion actually does.
|
||||
func TestLoadVersion(t *testing.T) {
|
||||
logger := defaultLogger()
|
||||
pruningOpt := baseapp.SetPruning(store.PruneNothing)
|
||||
pruningOpt := baseapp.SetPruning(storetypes.PruneNothing)
|
||||
db := dbm.NewMemDB()
|
||||
name := t.Name()
|
||||
app := baseapp.NewBaseApp(name, logger, db, nil, pruningOpt)
|
||||
@ -243,7 +243,7 @@ func TestLoadVersion(t *testing.T) {
|
||||
err := app.LoadLatestVersion() // needed to make stores non-nil
|
||||
require.Nil(t, err)
|
||||
|
||||
emptyCommitID := sdk.CommitID{}
|
||||
emptyCommitID := storetypes.CommitID{}
|
||||
|
||||
// fresh store has zero/empty last commit
|
||||
lastHeight := app.LastBlockHeight()
|
||||
@ -255,13 +255,13 @@ func TestLoadVersion(t *testing.T) {
|
||||
header := tmproto.Header{Height: 1}
|
||||
app.BeginBlock(abci.RequestBeginBlock{Header: header})
|
||||
res := app.Commit()
|
||||
commitID1 := sdk.CommitID{Version: 1, Hash: res.Data}
|
||||
commitID1 := storetypes.CommitID{Version: 1, Hash: res.Data}
|
||||
|
||||
// execute a block, collect commit ID
|
||||
header = tmproto.Header{Height: 2}
|
||||
app.BeginBlock(abci.RequestBeginBlock{Header: header})
|
||||
res = app.Commit()
|
||||
commitID2 := sdk.CommitID{Version: 2, Hash: res.Data}
|
||||
commitID2 := storetypes.CommitID{Version: 2, Hash: res.Data}
|
||||
|
||||
// reload with LoadLatestVersion
|
||||
app = baseapp.NewBaseApp(name, logger, db, nil, pruningOpt)
|
||||
@ -287,15 +287,15 @@ func useDefaultLoader(app *baseapp.BaseApp) {
|
||||
|
||||
func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) {
|
||||
rs := rootmulti.NewStore(db)
|
||||
rs.SetPruning(store.PruneNothing)
|
||||
rs.SetPruning(storetypes.PruneNothing)
|
||||
key := sdk.NewKVStoreKey(storeKey)
|
||||
rs.MountStoreWithDB(key, store.StoreTypeIAVL, nil)
|
||||
rs.MountStoreWithDB(key, storetypes.StoreTypeIAVL, nil)
|
||||
err := rs.LoadLatestVersion()
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, int64(0), rs.LastCommitID().Version)
|
||||
|
||||
// write some data in substore
|
||||
kv, _ := rs.GetStore(key).(store.KVStore)
|
||||
kv, _ := rs.GetStore(key).(storetypes.KVStore)
|
||||
require.NotNil(t, kv)
|
||||
kv.Set(k, v)
|
||||
commitID := rs.Commit()
|
||||
@ -304,15 +304,15 @@ func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) {
|
||||
|
||||
func checkStore(t *testing.T, db dbm.DB, ver int64, storeKey string, k, v []byte) {
|
||||
rs := rootmulti.NewStore(db)
|
||||
rs.SetPruning(store.PruneDefault)
|
||||
rs.SetPruning(storetypes.PruneDefault)
|
||||
key := sdk.NewKVStoreKey(storeKey)
|
||||
rs.MountStoreWithDB(key, store.StoreTypeIAVL, nil)
|
||||
rs.MountStoreWithDB(key, storetypes.StoreTypeIAVL, nil)
|
||||
err := rs.LoadLatestVersion()
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, ver, rs.LastCommitID().Version)
|
||||
|
||||
// query data in substore
|
||||
kv, _ := rs.GetStore(key).(store.KVStore)
|
||||
kv, _ := rs.GetStore(key).(storetypes.KVStore)
|
||||
require.NotNil(t, kv)
|
||||
require.Equal(t, v, kv.Get(k))
|
||||
}
|
||||
@ -347,7 +347,7 @@ func TestSetLoader(t *testing.T) {
|
||||
initStore(t, db, tc.origStoreKey, k, v)
|
||||
|
||||
// load the app with the existing db
|
||||
opts := []func(*baseapp.BaseApp){baseapp.SetPruning(store.PruneNothing)}
|
||||
opts := []func(*baseapp.BaseApp){baseapp.SetPruning(storetypes.PruneNothing)}
|
||||
if tc.setLoader != nil {
|
||||
opts = append(opts, tc.setLoader)
|
||||
}
|
||||
@ -370,7 +370,7 @@ func TestSetLoader(t *testing.T) {
|
||||
|
||||
func TestVersionSetterGetter(t *testing.T) {
|
||||
logger := defaultLogger()
|
||||
pruningOpt := baseapp.SetPruning(store.PruneDefault)
|
||||
pruningOpt := baseapp.SetPruning(storetypes.PruneDefault)
|
||||
db := dbm.NewMemDB()
|
||||
name := t.Name()
|
||||
app := baseapp.NewBaseApp(name, logger, db, nil, pruningOpt)
|
||||
@ -390,7 +390,7 @@ func TestVersionSetterGetter(t *testing.T) {
|
||||
|
||||
func TestLoadVersionInvalid(t *testing.T) {
|
||||
logger := log.NewNopLogger()
|
||||
pruningOpt := baseapp.SetPruning(store.PruneNothing)
|
||||
pruningOpt := baseapp.SetPruning(storetypes.PruneNothing)
|
||||
db := dbm.NewMemDB()
|
||||
name := t.Name()
|
||||
app := baseapp.NewBaseApp(name, logger, db, nil, pruningOpt)
|
||||
@ -405,7 +405,7 @@ func TestLoadVersionInvalid(t *testing.T) {
|
||||
header := tmproto.Header{Height: 1}
|
||||
app.BeginBlock(abci.RequestBeginBlock{Header: header})
|
||||
res := app.Commit()
|
||||
commitID1 := sdk.CommitID{Version: 1, Hash: res.Data}
|
||||
commitID1 := storetypes.CommitID{Version: 1, Hash: res.Data}
|
||||
|
||||
// create a new app with the stores mounted under the same cap key
|
||||
app = baseapp.NewBaseApp(name, logger, db, nil, pruningOpt)
|
||||
@ -422,7 +422,7 @@ func TestLoadVersionInvalid(t *testing.T) {
|
||||
|
||||
func TestLoadVersionPruning(t *testing.T) {
|
||||
logger := log.NewNopLogger()
|
||||
pruningOptions := store.PruningOptions{
|
||||
pruningOptions := storetypes.PruningOptions{
|
||||
KeepRecent: 2,
|
||||
KeepEvery: 3,
|
||||
Interval: 1,
|
||||
@ -439,7 +439,7 @@ func TestLoadVersionPruning(t *testing.T) {
|
||||
err := app.LoadLatestVersion() // needed to make stores non-nil
|
||||
require.Nil(t, err)
|
||||
|
||||
emptyCommitID := sdk.CommitID{}
|
||||
emptyCommitID := storetypes.CommitID{}
|
||||
|
||||
// fresh store has zero/empty last commit
|
||||
lastHeight := app.LastBlockHeight()
|
||||
@ -447,14 +447,14 @@ func TestLoadVersionPruning(t *testing.T) {
|
||||
require.Equal(t, int64(0), lastHeight)
|
||||
require.Equal(t, emptyCommitID, lastID)
|
||||
|
||||
var lastCommitID sdk.CommitID
|
||||
var lastCommitID storetypes.CommitID
|
||||
|
||||
// Commit seven blocks, of which 7 (latest) is kept in addition to 6, 5
|
||||
// (keep recent) and 3 (keep every).
|
||||
for i := int64(1); i <= 7; i++ {
|
||||
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: i}})
|
||||
res := app.Commit()
|
||||
lastCommitID = sdk.CommitID{Version: i, Hash: res.Data}
|
||||
lastCommitID = storetypes.CommitID{Version: i, Hash: res.Data}
|
||||
}
|
||||
|
||||
for _, v := range []int64{1, 2, 4} {
|
||||
@ -476,7 +476,7 @@ func TestLoadVersionPruning(t *testing.T) {
|
||||
testLoadVersionHelper(t, app, int64(7), lastCommitID)
|
||||
}
|
||||
|
||||
func testLoadVersionHelper(t *testing.T, app *baseapp.BaseApp, expectedHeight int64, expectedID sdk.CommitID) {
|
||||
func testLoadVersionHelper(t *testing.T, app *baseapp.BaseApp, expectedHeight int64, expectedID storetypes.CommitID) {
|
||||
lastHeight := app.LastBlockHeight()
|
||||
lastID := app.LastCommitID()
|
||||
require.Equal(t, expectedHeight, lastHeight)
|
||||
@ -845,7 +845,7 @@ func testTxDecoder(cdc *codec.LegacyAmino) sdk.TxDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
func customHandlerTxTest(t *testing.T, capKey sdk.StoreKey, storeKey []byte) handlerFun {
|
||||
func customHandlerTxTest(t *testing.T, capKey storetypes.StoreKey, storeKey []byte) handlerFun {
|
||||
return func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) {
|
||||
store := ctx.KVStore(capKey)
|
||||
txTest := tx.(txTest)
|
||||
@ -876,7 +876,7 @@ func counterEvent(evType string, msgCount int64) sdk.Events {
|
||||
}
|
||||
}
|
||||
|
||||
func handlerMsgCounter(t *testing.T, capKey sdk.StoreKey, deliverKey []byte) sdk.Handler {
|
||||
func handlerMsgCounter(t *testing.T, capKey storetypes.StoreKey, deliverKey []byte) sdk.Handler {
|
||||
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
||||
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
||||
store := ctx.KVStore(capKey)
|
||||
|
||||
@ -6,14 +6,14 @@ import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/tendermint/tendermint/types"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
|
||||
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/middleware"
|
||||
@ -72,7 +72,7 @@ func NewApp(rootDir string, logger log.Logger) (abci.Application, error) {
|
||||
|
||||
// KVStoreHandler is a simple handler that takes kvstoreTx and writes
|
||||
// them to the db
|
||||
func KVStoreHandler(storeKey sdk.StoreKey) sdk.Handler {
|
||||
func KVStoreHandler(storeKey storetypes.StoreKey) sdk.Handler {
|
||||
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
||||
dTx, ok := msg.(kvstoreTx)
|
||||
if !ok {
|
||||
@ -105,7 +105,7 @@ type GenesisJSON struct {
|
||||
|
||||
// InitChainer returns a function that can initialize the chain
|
||||
// with key/value pairs
|
||||
func InitChainer(key sdk.StoreKey) func(sdk.Context, abci.RequestInitChain) abci.ResponseInitChain {
|
||||
func InitChainer(key storetypes.StoreKey) func(sdk.Context, abci.RequestInitChain) abci.ResponseInitChain {
|
||||
return func(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
|
||||
stateJSON := req.AppStateBytes
|
||||
|
||||
|
||||
@ -5,14 +5,14 @@ import (
|
||||
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
store "github.com/cosmos/cosmos-sdk/store/types"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
var _ sdk.MultiStore = multiStore{}
|
||||
|
||||
type multiStore struct {
|
||||
kv map[sdk.StoreKey]kvStore
|
||||
kv map[storetypes.StoreKey]kvStore
|
||||
}
|
||||
|
||||
func (ms multiStore) CacheMultiStore() sdk.CacheMultiStore {
|
||||
@ -23,15 +23,15 @@ func (ms multiStore) CacheMultiStoreWithVersion(_ int64) (sdk.CacheMultiStore, e
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms multiStore) CacheWrap() sdk.CacheWrap {
|
||||
func (ms multiStore) CacheWrap() storetypes.CacheWrap {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms multiStore) CacheWrapWithTrace(_ io.Writer, _ sdk.TraceContext) sdk.CacheWrap {
|
||||
func (ms multiStore) CacheWrapWithTrace(_ io.Writer, _ sdk.TraceContext) storetypes.CacheWrap {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms multiStore) CacheWrapWithListeners(_ store.StoreKey, _ []store.WriteListener) store.CacheWrap {
|
||||
func (ms multiStore) CacheWrapWithListeners(_ storetypes.StoreKey, _ []storetypes.WriteListener) storetypes.CacheWrap {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
@ -47,19 +47,19 @@ func (ms multiStore) SetTracer(w io.Writer) sdk.MultiStore {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms multiStore) AddListeners(key store.StoreKey, listeners []store.WriteListener) {
|
||||
func (ms multiStore) AddListeners(key storetypes.StoreKey, listeners []storetypes.WriteListener) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms multiStore) ListeningEnabled(key store.StoreKey) bool {
|
||||
func (ms multiStore) ListeningEnabled(key storetypes.StoreKey) bool {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms multiStore) Commit() sdk.CommitID {
|
||||
func (ms multiStore) Commit() storetypes.CommitID {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms multiStore) LastCommitID() sdk.CommitID {
|
||||
func (ms multiStore) LastCommitID() storetypes.CommitID {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
@ -71,15 +71,15 @@ func (ms multiStore) GetPruning() sdk.PruningOptions {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms multiStore) GetCommitKVStore(key sdk.StoreKey) sdk.CommitKVStore {
|
||||
func (ms multiStore) GetCommitKVStore(key storetypes.StoreKey) storetypes.CommitKVStore {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms multiStore) GetCommitStore(key sdk.StoreKey) sdk.CommitStore {
|
||||
func (ms multiStore) GetCommitStore(key storetypes.StoreKey) storetypes.CommitStore {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms multiStore) MountStoreWithDB(key sdk.StoreKey, typ sdk.StoreType, db dbm.DB) {
|
||||
func (ms multiStore) MountStoreWithDB(key storetypes.StoreKey, typ storetypes.StoreType, db dbm.DB) {
|
||||
ms.kv[key] = kvStore{store: make(map[string][]byte)}
|
||||
}
|
||||
|
||||
@ -87,11 +87,11 @@ func (ms multiStore) LoadLatestVersion() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ms multiStore) LoadLatestVersionAndUpgrade(upgrades *store.StoreUpgrades) error {
|
||||
func (ms multiStore) LoadLatestVersionAndUpgrade(upgrades *storetypes.StoreUpgrades) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ms multiStore) LoadVersionAndUpgrade(ver int64, upgrades *store.StoreUpgrades) error {
|
||||
func (ms multiStore) LoadVersionAndUpgrade(ver int64, upgrades *storetypes.StoreUpgrades) error {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
@ -99,15 +99,15 @@ func (ms multiStore) LoadVersion(ver int64) error {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms multiStore) GetKVStore(key sdk.StoreKey) sdk.KVStore {
|
||||
func (ms multiStore) GetKVStore(key storetypes.StoreKey) sdk.KVStore {
|
||||
return ms.kv[key]
|
||||
}
|
||||
|
||||
func (ms multiStore) GetStore(key sdk.StoreKey) sdk.Store {
|
||||
func (ms multiStore) GetStore(key storetypes.StoreKey) sdk.Store {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms multiStore) GetStoreType() sdk.StoreType {
|
||||
func (ms multiStore) GetStoreType() storetypes.StoreType {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
@ -135,19 +135,19 @@ type kvStore struct {
|
||||
store map[string][]byte
|
||||
}
|
||||
|
||||
func (kv kvStore) CacheWrap() sdk.CacheWrap {
|
||||
func (kv kvStore) CacheWrap() storetypes.CacheWrap {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (kv kvStore) CacheWrapWithTrace(w io.Writer, tc sdk.TraceContext) sdk.CacheWrap {
|
||||
func (kv kvStore) CacheWrapWithTrace(w io.Writer, tc sdk.TraceContext) storetypes.CacheWrap {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (kv kvStore) CacheWrapWithListeners(_ store.StoreKey, _ []store.WriteListener) store.CacheWrap {
|
||||
func (kv kvStore) CacheWrapWithListeners(_ storetypes.StoreKey, _ []storetypes.WriteListener) storetypes.CacheWrap {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (kv kvStore) GetStoreType() sdk.StoreType {
|
||||
func (kv kvStore) GetStoreType() storetypes.StoreType {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ func (kv kvStore) Has(key []byte) bool {
|
||||
}
|
||||
|
||||
func (kv kvStore) Set(key, value []byte) {
|
||||
store.AssertValidKey(key)
|
||||
storetypes.AssertValidKey(key)
|
||||
kv.store[string(key)] = value
|
||||
}
|
||||
|
||||
@ -198,5 +198,5 @@ func (kv kvStore) ReverseSubspaceIterator(prefix []byte) sdk.Iterator {
|
||||
}
|
||||
|
||||
func NewCommitMultiStore() sdk.CommitMultiStore {
|
||||
return multiStore{kv: make(map[sdk.StoreKey]kvStore)}
|
||||
return multiStore{kv: make(map[storetypes.StoreKey]kvStore)}
|
||||
}
|
||||
|
||||
@ -4,9 +4,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@ -15,7 +15,7 @@ func TestStore(t *testing.T) {
|
||||
cms := NewCommitMultiStore()
|
||||
|
||||
key := sdk.NewKVStoreKey("test")
|
||||
cms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db)
|
||||
cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
|
||||
err := cms.LoadLatestVersion()
|
||||
require.Nil(t, err)
|
||||
|
||||
|
||||
@ -42,6 +42,7 @@ import (
|
||||
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
|
||||
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
|
||||
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
authmiddleware "github.com/cosmos/cosmos-sdk/x/auth/middleware"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz"
|
||||
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
|
||||
@ -147,9 +148,9 @@ type SimApp struct {
|
||||
invCheckPeriod uint
|
||||
|
||||
// keys to access the substores
|
||||
keys map[string]*sdk.KVStoreKey
|
||||
tkeys map[string]*sdk.TransientStoreKey
|
||||
memKeys map[string]*sdk.MemoryStoreKey
|
||||
keys map[string]*storetypes.KVStoreKey
|
||||
tkeys map[string]*storetypes.TransientStoreKey
|
||||
memKeys map[string]*storetypes.MemoryStoreKey
|
||||
|
||||
// keepers
|
||||
AccountKeeper authkeeper.AccountKeeper
|
||||
@ -484,21 +485,21 @@ func (app *SimApp) InterfaceRegistry() types.InterfaceRegistry {
|
||||
// GetKey returns the KVStoreKey for the provided store key.
|
||||
//
|
||||
// NOTE: This is solely to be used for testing purposes.
|
||||
func (app *SimApp) GetKey(storeKey string) *sdk.KVStoreKey {
|
||||
func (app *SimApp) GetKey(storeKey string) *storetypes.KVStoreKey {
|
||||
return app.keys[storeKey]
|
||||
}
|
||||
|
||||
// GetTKey returns the TransientStoreKey for the provided store key.
|
||||
//
|
||||
// NOTE: This is solely to be used for testing purposes.
|
||||
func (app *SimApp) GetTKey(storeKey string) *sdk.TransientStoreKey {
|
||||
func (app *SimApp) GetTKey(storeKey string) *storetypes.TransientStoreKey {
|
||||
return app.tkeys[storeKey]
|
||||
}
|
||||
|
||||
// GetMemKey returns the MemStoreKey for the provided mem key.
|
||||
//
|
||||
// NOTE: This is solely used for testing purposes.
|
||||
func (app *SimApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey {
|
||||
func (app *SimApp) GetMemKey(storeKey string) *storetypes.MemoryStoreKey {
|
||||
return app.memKeys[storeKey]
|
||||
}
|
||||
|
||||
@ -565,7 +566,7 @@ func GetMaccPerms() map[string][]string {
|
||||
}
|
||||
|
||||
// initParamsKeeper init params keeper and its subspaces
|
||||
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper {
|
||||
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper {
|
||||
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)
|
||||
|
||||
paramsKeeper.Subspace(authtypes.ModuleName)
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
@ -38,8 +39,8 @@ func init() {
|
||||
}
|
||||
|
||||
type StoreKeysPrefixes struct {
|
||||
A sdk.StoreKey
|
||||
B sdk.StoreKey
|
||||
A storetypes.StoreKey
|
||||
B storetypes.StoreKey
|
||||
Prefixes [][]byte
|
||||
}
|
||||
|
||||
|
||||
@ -6,15 +6,16 @@ import (
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// DefaultContext creates a sdk.Context with a fresh MemDB that can be used in tests.
|
||||
func DefaultContext(key sdk.StoreKey, tkey sdk.StoreKey) sdk.Context {
|
||||
func DefaultContext(key storetypes.StoreKey, tkey storetypes.StoreKey) sdk.Context {
|
||||
db := dbm.NewMemDB()
|
||||
cms := store.NewCommitMultiStore(db)
|
||||
cms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db)
|
||||
cms.MountStoreWithDB(tkey, sdk.StoreTypeTransient, db)
|
||||
cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
|
||||
cms.MountStoreWithDB(tkey, storetypes.StoreTypeTransient, db)
|
||||
err := cms.LoadLatestVersion()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@ -11,7 +11,7 @@ import (
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/store/gaskv"
|
||||
stypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -87,7 +87,7 @@ func NewContext(ms MultiStore, header tmproto.Header, isCheckTx bool, logger log
|
||||
chainID: header.ChainID,
|
||||
checkTx: isCheckTx,
|
||||
logger: logger,
|
||||
gasMeter: stypes.NewInfiniteGasMeter(),
|
||||
gasMeter: storetypes.NewInfiniteGasMeter(),
|
||||
minGasPrice: DecCoins{},
|
||||
eventManager: NewEventManager(),
|
||||
}
|
||||
@ -243,13 +243,13 @@ func (c Context) Value(key interface{}) interface{} {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// KVStore fetches a KVStore from the MultiStore.
|
||||
func (c Context) KVStore(key StoreKey) KVStore {
|
||||
return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), stypes.KVGasConfig())
|
||||
func (c Context) KVStore(key storetypes.StoreKey) KVStore {
|
||||
return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), storetypes.KVGasConfig())
|
||||
}
|
||||
|
||||
// TransientStore fetches a TransientStore from the MultiStore.
|
||||
func (c Context) TransientStore(key StoreKey) KVStore {
|
||||
return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), stypes.TransientGasConfig())
|
||||
func (c Context) TransientStore(key storetypes.StoreKey) KVStore {
|
||||
return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), storetypes.TransientGasConfig())
|
||||
}
|
||||
|
||||
// CacheContext returns a new Context with the multi-store cached and a new
|
||||
|
||||
@ -58,32 +58,6 @@ func DiffKVStores(a KVStore, b KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []k
|
||||
return types.DiffKVStores(a, b, prefixesToSkip)
|
||||
}
|
||||
|
||||
type (
|
||||
CacheKVStore = types.CacheKVStore
|
||||
CommitKVStore = types.CommitKVStore
|
||||
CacheWrap = types.CacheWrap
|
||||
CacheWrapper = types.CacheWrapper
|
||||
CommitID = types.CommitID
|
||||
)
|
||||
|
||||
type StoreType = types.StoreType
|
||||
|
||||
const (
|
||||
StoreTypeMulti = types.StoreTypeMulti
|
||||
StoreTypeDB = types.StoreTypeDB
|
||||
StoreTypeIAVL = types.StoreTypeIAVL
|
||||
StoreTypeTransient = types.StoreTypeTransient
|
||||
StoreTypeMemory = types.StoreTypeMemory
|
||||
)
|
||||
|
||||
type (
|
||||
StoreKey = types.StoreKey
|
||||
CapabilityKey = types.CapabilityKey
|
||||
KVStoreKey = types.KVStoreKey
|
||||
TransientStoreKey = types.TransientStoreKey
|
||||
MemoryStoreKey = types.MemoryStoreKey
|
||||
)
|
||||
|
||||
// assertNoCommonPrefix will panic if there are two keys: k1 and k2 in keys, such that
|
||||
// k1 is a prefix of k2
|
||||
func assertNoPrefix(keys []string) {
|
||||
@ -98,16 +72,16 @@ func assertNoPrefix(keys []string) {
|
||||
}
|
||||
|
||||
// NewKVStoreKey returns a new pointer to a KVStoreKey.
|
||||
func NewKVStoreKey(name string) *KVStoreKey {
|
||||
func NewKVStoreKey(name string) *types.KVStoreKey {
|
||||
return types.NewKVStoreKey(name)
|
||||
}
|
||||
|
||||
// NewKVStoreKeys returns a map of new pointers to KVStoreKey's.
|
||||
// The function will panic if there is a potential conflict in names (see `assertNoPrefix`
|
||||
// function for more details).
|
||||
func NewKVStoreKeys(names ...string) map[string]*KVStoreKey {
|
||||
func NewKVStoreKeys(names ...string) map[string]*types.KVStoreKey {
|
||||
assertNoPrefix(names)
|
||||
keys := make(map[string]*KVStoreKey, len(names))
|
||||
keys := make(map[string]*types.KVStoreKey, len(names))
|
||||
for _, n := range names {
|
||||
keys[n] = NewKVStoreKey(n)
|
||||
}
|
||||
@ -117,7 +91,7 @@ func NewKVStoreKeys(names ...string) map[string]*KVStoreKey {
|
||||
|
||||
// Constructs new TransientStoreKey
|
||||
// Must return a pointer according to the ocap principle
|
||||
func NewTransientStoreKey(name string) *TransientStoreKey {
|
||||
func NewTransientStoreKey(name string) *types.TransientStoreKey {
|
||||
return types.NewTransientStoreKey(name)
|
||||
}
|
||||
|
||||
@ -125,9 +99,9 @@ func NewTransientStoreKey(name string) *TransientStoreKey {
|
||||
// Must return pointers according to the ocap principle
|
||||
// The function will panic if there is a potential conflict in names (see `assertNoPrefix`
|
||||
// function for more details).
|
||||
func NewTransientStoreKeys(names ...string) map[string]*TransientStoreKey {
|
||||
func NewTransientStoreKeys(names ...string) map[string]*types.TransientStoreKey {
|
||||
assertNoPrefix(names)
|
||||
keys := make(map[string]*TransientStoreKey)
|
||||
keys := make(map[string]*types.TransientStoreKey)
|
||||
for _, n := range names {
|
||||
keys[n] = NewTransientStoreKey(n)
|
||||
}
|
||||
@ -139,9 +113,9 @@ func NewTransientStoreKeys(names ...string) map[string]*TransientStoreKey {
|
||||
// respective MemoryStoreKey references.
|
||||
// The function will panic if there is a potential conflict in names (see `assertNoPrefix`
|
||||
// function for more details).
|
||||
func NewMemoryStoreKeys(names ...string) map[string]*MemoryStoreKey {
|
||||
func NewMemoryStoreKeys(names ...string) map[string]*types.MemoryStoreKey {
|
||||
assertNoPrefix(names)
|
||||
keys := make(map[string]*MemoryStoreKey)
|
||||
keys := make(map[string]*types.MemoryStoreKey)
|
||||
for _, n := range names {
|
||||
keys[n] = types.NewMemoryStoreKey(n)
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package types
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
@ -47,7 +48,7 @@ func (s *storeIntSuite) TestNewKVStoreKeys() {
|
||||
require := s.Require()
|
||||
require.Panics(func() { NewKVStoreKeys("a1", "a") }, "should fail one key is a prefix of another one")
|
||||
|
||||
require.Equal(map[string]*KVStoreKey{}, NewKVStoreKeys())
|
||||
require.Equal(map[string]*types.KVStoreKey{}, NewKVStoreKeys())
|
||||
require.Equal(1, len(NewKVStoreKeys("one")))
|
||||
|
||||
key := "baca"
|
||||
|
||||
@ -44,10 +44,10 @@ func (s *storeTestSuite) TestPrefixEndBytes() {
|
||||
}
|
||||
|
||||
func (s *storeTestSuite) TestCommitID() {
|
||||
var empty sdk.CommitID
|
||||
var empty types.CommitID
|
||||
s.Require().True(empty.IsZero())
|
||||
|
||||
var nonempty = sdk.CommitID{
|
||||
var nonempty = types.CommitID{
|
||||
Version: 1,
|
||||
Hash: []byte("testhash"),
|
||||
}
|
||||
@ -55,7 +55,7 @@ func (s *storeTestSuite) TestCommitID() {
|
||||
}
|
||||
|
||||
func (s *storeTestSuite) TestNewTransientStoreKeys() {
|
||||
s.Require().Equal(map[string]*sdk.TransientStoreKey{}, sdk.NewTransientStoreKeys())
|
||||
s.Require().Equal(map[string]*types.TransientStoreKey{}, sdk.NewTransientStoreKeys())
|
||||
s.Require().Equal(1, len(sdk.NewTransientStoreKeys("one")))
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
@ -53,7 +54,7 @@ type AccountKeeperI interface {
|
||||
// AccountKeeper encodes/decodes accounts using the go-amino (binary)
|
||||
// encoding/decoding library.
|
||||
type AccountKeeper struct {
|
||||
key sdk.StoreKey
|
||||
key storetypes.StoreKey
|
||||
cdc codec.BinaryCodec
|
||||
paramSubspace paramtypes.Subspace
|
||||
permAddrs map[string]types.PermissionsForAddress
|
||||
@ -72,7 +73,7 @@ var _ AccountKeeperI = &AccountKeeper{}
|
||||
// and don't have to fit into any predefined structure. This auth module does not use account permissions internally, though other modules
|
||||
// may use auth.Keeper to access the accounts permissions map.
|
||||
func NewAccountKeeper(
|
||||
cdc codec.BinaryCodec, key sdk.StoreKey, paramstore paramtypes.Subspace, proto func() types.AccountI,
|
||||
cdc codec.BinaryCodec, key storetypes.StoreKey, paramstore paramtypes.Subspace, proto func() types.AccountI,
|
||||
maccPerms map[string][]string, bech32Prefix string,
|
||||
) AccountKeeper {
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/middleware"
|
||||
@ -17,13 +18,13 @@ import (
|
||||
)
|
||||
|
||||
type Keeper struct {
|
||||
storeKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
cdc codec.BinaryCodec
|
||||
router *middleware.MsgServiceRouter
|
||||
}
|
||||
|
||||
// NewKeeper constructs a message authorization Keeper
|
||||
func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, router *middleware.MsgServiceRouter) Keeper {
|
||||
func NewKeeper(storeKey storetypes.StoreKey, cdc codec.BinaryCodec, router *middleware.MsgServiceRouter) Keeper {
|
||||
return Keeper{
|
||||
storeKey: storeKey,
|
||||
cdc: cdc,
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
@ -52,7 +53,7 @@ type BaseKeeper struct {
|
||||
|
||||
ak types.AccountKeeper
|
||||
cdc codec.BinaryCodec
|
||||
storeKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
paramSpace paramtypes.Subspace
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ func (k BaseKeeper) GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.P
|
||||
// by using a SendCoinsFromModuleToAccount execution.
|
||||
func NewBaseKeeper(
|
||||
cdc codec.BinaryCodec,
|
||||
storeKey sdk.StoreKey,
|
||||
storeKey storetypes.StoreKey,
|
||||
ak types.AccountKeeper,
|
||||
paramSpace paramtypes.Subspace,
|
||||
blockedAddrs map[string]bool,
|
||||
|
||||
@ -3,6 +3,7 @@ package keeper
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/cosmos/cosmos-sdk/telemetry"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
@ -37,7 +38,7 @@ type BaseSendKeeper struct {
|
||||
|
||||
cdc codec.BinaryCodec
|
||||
ak types.AccountKeeper
|
||||
storeKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
paramSpace paramtypes.Subspace
|
||||
|
||||
// list of addresses that are restricted from receiving transactions
|
||||
@ -45,7 +46,7 @@ type BaseSendKeeper struct {
|
||||
}
|
||||
|
||||
func NewBaseSendKeeper(
|
||||
cdc codec.BinaryCodec, storeKey sdk.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blockedAddrs map[string]bool,
|
||||
cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blockedAddrs map[string]bool,
|
||||
) BaseSendKeeper {
|
||||
|
||||
return BaseSendKeeper{
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
|
||||
@ -34,12 +35,12 @@ type ViewKeeper interface {
|
||||
// BaseViewKeeper implements a read only keeper implementation of ViewKeeper.
|
||||
type BaseViewKeeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
storeKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
ak types.AccountKeeper
|
||||
}
|
||||
|
||||
// NewBaseViewKeeper returns a new BaseViewKeeper.
|
||||
func NewBaseViewKeeper(cdc codec.BinaryCodec, storeKey sdk.StoreKey, ak types.AccountKeeper) BaseViewKeeper {
|
||||
func NewBaseViewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak types.AccountKeeper) BaseViewKeeper {
|
||||
return BaseViewKeeper{
|
||||
cdc: cdc,
|
||||
storeKey: storeKey,
|
||||
|
||||
@ -3,6 +3,7 @@ package v043
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040"
|
||||
v040bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v040"
|
||||
@ -76,7 +77,7 @@ func migrateBalanceKeys(store sdk.KVStore) {
|
||||
// - Change balances prefix to 1 byte
|
||||
// - Change supply to be indexed by denom
|
||||
// - Prune balances & supply with zero coins (ref: https://github.com/cosmos/cosmos-sdk/pull/9229)
|
||||
func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) error {
|
||||
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error {
|
||||
store := ctx.KVStore(storeKey)
|
||||
migrateBalanceKeys(store)
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package v045
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
v043 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043"
|
||||
@ -15,7 +16,7 @@ import (
|
||||
// - Migrate coin storage to save only amount.
|
||||
// - Add an additional reverse index from denomination to address.
|
||||
// - Remove duplicate denom from denom metadata store key.
|
||||
func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) error {
|
||||
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error {
|
||||
store := ctx.KVStore(storeKey)
|
||||
err := addDenomReverseIndex(store, cdc)
|
||||
if err != nil {
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/capability/types"
|
||||
@ -28,8 +29,8 @@ type (
|
||||
// a single specific module.
|
||||
Keeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
storeKey sdk.StoreKey
|
||||
memKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
memKey storetypes.StoreKey
|
||||
capMap map[uint64]*types.Capability
|
||||
scopedModules map[string]struct{}
|
||||
sealed bool
|
||||
@ -43,8 +44,8 @@ type (
|
||||
// passed by other modules.
|
||||
ScopedKeeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
storeKey sdk.StoreKey
|
||||
memKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
memKey storetypes.StoreKey
|
||||
capMap map[uint64]*types.Capability
|
||||
module string
|
||||
}
|
||||
@ -52,7 +53,7 @@ type (
|
||||
|
||||
// NewKeeper constructs a new CapabilityKeeper instance and initializes maps
|
||||
// for capability map and scopedModules map.
|
||||
func NewKeeper(cdc codec.BinaryCodec, storeKey, memKey sdk.StoreKey) *Keeper {
|
||||
func NewKeeper(cdc codec.BinaryCodec, storeKey, memKey storetypes.StoreKey) *Keeper {
|
||||
return &Keeper{
|
||||
cdc: cdc,
|
||||
storeKey: storeKey,
|
||||
@ -108,8 +109,8 @@ func (k *Keeper) InitMemStore(ctx sdk.Context) {
|
||||
memStore := ctx.KVStore(k.memKey)
|
||||
memStoreType := memStore.GetStoreType()
|
||||
|
||||
if memStoreType != sdk.StoreTypeMemory {
|
||||
panic(fmt.Sprintf("invalid memory store type; got %s, expected: %s", memStoreType, sdk.StoreTypeMemory))
|
||||
if memStoreType != storetypes.StoreTypeMemory {
|
||||
panic(fmt.Sprintf("invalid memory store type; got %s, expected: %s", memStoreType, storetypes.StoreTypeMemory))
|
||||
}
|
||||
|
||||
// create context with no block gas meter to ensure we do not consume gas during local initialization logic.
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
@ -14,7 +15,7 @@ import (
|
||||
|
||||
// Keeper of the distribution store
|
||||
type Keeper struct {
|
||||
storeKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
cdc codec.BinaryCodec
|
||||
paramSpace paramtypes.Subspace
|
||||
authKeeper types.AccountKeeper
|
||||
@ -28,7 +29,7 @@ type Keeper struct {
|
||||
|
||||
// NewKeeper creates a new distribution Keeper instance
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace,
|
||||
cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace,
|
||||
ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper,
|
||||
feeCollectorName string, blockedAddrs map[string]bool,
|
||||
) Keeper {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package v043
|
||||
|
||||
import (
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
v040distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v040"
|
||||
)
|
||||
@ -9,7 +10,7 @@ import (
|
||||
// migration includes:
|
||||
//
|
||||
// - Change addresses to be length-prefixed.
|
||||
func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey) error {
|
||||
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey) error {
|
||||
store := ctx.KVStore(storeKey)
|
||||
MigratePrefixAddress(store, v040distribution.ValidatorOutstandingRewardsPrefix)
|
||||
MigratePrefixAddress(store, v040distribution.DelegatorWithdrawAddrPrefix)
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
db "github.com/tendermint/tm-db"
|
||||
)
|
||||
@ -22,7 +23,7 @@ var (
|
||||
|
||||
// Keeper of the store
|
||||
type Keeper struct {
|
||||
storeKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
cdc codec.BinaryCodec
|
||||
// Used to calculate the estimated next epoch time.
|
||||
// This is local to every node
|
||||
@ -31,7 +32,7 @@ type Keeper struct {
|
||||
}
|
||||
|
||||
// NewKeeper creates a epoch queue manager
|
||||
func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, commitTimeout time.Duration) Keeper {
|
||||
func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, commitTimeout time.Duration) Keeper {
|
||||
return Keeper{
|
||||
storeKey: key,
|
||||
cdc: cdc,
|
||||
|
||||
@ -3,6 +3,7 @@ package keeper
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
tmbytes "github.com/tendermint/tendermint/libs/bytes"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
@ -19,14 +20,14 @@ import (
|
||||
// module.
|
||||
type Keeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
storeKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
router types.Router
|
||||
stakingKeeper types.StakingKeeper
|
||||
slashingKeeper types.SlashingKeeper
|
||||
}
|
||||
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec, storeKey sdk.StoreKey, stakingKeeper types.StakingKeeper,
|
||||
cdc codec.BinaryCodec, storeKey storetypes.StoreKey, stakingKeeper types.StakingKeeper,
|
||||
slashingKeeper types.SlashingKeeper,
|
||||
) *Keeper {
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package keeper
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
@ -16,14 +17,14 @@ import (
|
||||
// It must have a codec with all available allowances registered.
|
||||
type Keeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
storeKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
authKeeper feegrant.AccountKeeper
|
||||
}
|
||||
|
||||
var _ middleware.FeegrantKeeper = &Keeper{}
|
||||
|
||||
// NewKeeper creates a fee grant Keeper
|
||||
func NewKeeper(cdc codec.BinaryCodec, storeKey sdk.StoreKey, ak feegrant.AccountKeeper) Keeper {
|
||||
func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak feegrant.AccountKeeper) Keeper {
|
||||
return Keeper{
|
||||
cdc: cdc,
|
||||
storeKey: storeKey,
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
@ -27,7 +28,7 @@ type Keeper struct {
|
||||
hooks types.GovHooks
|
||||
|
||||
// The (unexposed) keys used to access the stores from the Context.
|
||||
storeKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
|
||||
// The codec codec for binary encoding/decoding.
|
||||
cdc codec.BinaryCodec
|
||||
@ -44,7 +45,7 @@ type Keeper struct {
|
||||
//
|
||||
// CONTRACT: the parameter Subspace must have the param key table already initialized
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace types.ParamSubspace,
|
||||
cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace types.ParamSubspace,
|
||||
authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper, rtr types.Router,
|
||||
) Keeper {
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
|
||||
store "github.com/cosmos/cosmos-sdk/store/types"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/cosmos/cosmos-sdk/telemetry"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
@ -39,7 +39,7 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *types.MsgSubmitPro
|
||||
|
||||
// ref: https://github.com/cosmos/cosmos-sdk/issues/9683
|
||||
ctx.GasMeter().ConsumeGas(
|
||||
3*store.KVGasConfig().WriteCostPerByte*uint64(len(bytes)),
|
||||
3*storetypes.KVGasConfig().WriteCostPerByte*uint64(len(bytes)),
|
||||
"submit proposal",
|
||||
)
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
@ -73,7 +74,7 @@ func migrateStoreWeightedVotes(store sdk.KVStore, cdc codec.BinaryCodec) error {
|
||||
// migration includes:
|
||||
//
|
||||
// - Change addresses to be length-prefixed.
|
||||
func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) error {
|
||||
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error {
|
||||
store := ctx.KVStore(storeKey)
|
||||
migratePrefixProposalAddress(store, types.DepositsKeyPrefix)
|
||||
migratePrefixProposalAddress(store, types.VotesKeyPrefix)
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
@ -12,7 +13,7 @@ import (
|
||||
// Keeper of the mint store
|
||||
type Keeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
storeKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
paramSpace paramtypes.Subspace
|
||||
stakingKeeper types.StakingKeeper
|
||||
bankKeeper types.BankKeeper
|
||||
@ -21,7 +22,7 @@ type Keeper struct {
|
||||
|
||||
// NewKeeper creates a new mint Keeper instance
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace,
|
||||
cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace,
|
||||
sk types.StakingKeeper, ak types.AccountKeeper, bk types.BankKeeper,
|
||||
feeCollectorName string,
|
||||
) Keeper {
|
||||
|
||||
@ -3,12 +3,13 @@ package keeper_test
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
|
||||
)
|
||||
|
||||
func testComponents() (*codec.LegacyAmino, sdk.Context, sdk.StoreKey, sdk.StoreKey, paramskeeper.Keeper) {
|
||||
func testComponents() (*codec.LegacyAmino, sdk.Context, storetypes.StoreKey, storetypes.StoreKey, paramskeeper.Keeper) {
|
||||
marshaler := simapp.MakeTestEncodingConfig().Codec
|
||||
legacyAmino := createTestCodec()
|
||||
mkey := sdk.NewKVStoreKey("test")
|
||||
|
||||
@ -1,25 +1,25 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
)
|
||||
|
||||
// Keeper of the global paramstore
|
||||
type Keeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
legacyAmino *codec.LegacyAmino
|
||||
key sdk.StoreKey
|
||||
tkey sdk.StoreKey
|
||||
key storetypes.StoreKey
|
||||
tkey storetypes.StoreKey
|
||||
spaces map[string]*types.Subspace
|
||||
}
|
||||
|
||||
// NewKeeper constructs a params keeper
|
||||
func NewKeeper(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) Keeper {
|
||||
func NewKeeper(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) Keeper {
|
||||
return Keeper{
|
||||
cdc: cdc,
|
||||
legacyAmino: legacyAmino,
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@ -23,14 +24,14 @@ const (
|
||||
type Subspace struct {
|
||||
cdc codec.BinaryCodec
|
||||
legacyAmino *codec.LegacyAmino
|
||||
key sdk.StoreKey // []byte -> []byte, stores parameter
|
||||
tkey sdk.StoreKey // []byte -> bool, stores parameter change
|
||||
key storetypes.StoreKey // []byte -> []byte, stores parameter
|
||||
tkey storetypes.StoreKey // []byte -> bool, stores parameter change
|
||||
name []byte
|
||||
table KeyTable
|
||||
}
|
||||
|
||||
// NewSubspace constructs a store with namestore
|
||||
func NewSubspace(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key sdk.StoreKey, tkey sdk.StoreKey, name string) Subspace {
|
||||
func NewSubspace(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key storetypes.StoreKey, tkey storetypes.StoreKey, name string) Subspace {
|
||||
return Subspace{
|
||||
cdc: cdc,
|
||||
legacyAmino: legacyAmino,
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
@ -31,8 +32,8 @@ func (suite *SubspaceTestSuite) SetupTest() {
|
||||
db := dbm.NewMemDB()
|
||||
|
||||
ms := store.NewCommitMultiStore(db)
|
||||
ms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db)
|
||||
ms.MountStoreWithDB(tkey, sdk.StoreTypeTransient, db)
|
||||
ms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
|
||||
ms.MountStoreWithDB(tkey, storetypes.StoreTypeTransient, db)
|
||||
suite.NoError(ms.LoadLatestVersion())
|
||||
|
||||
encCfg := simapp.MakeTestEncodingConfig()
|
||||
|
||||
@ -3,6 +3,7 @@ package keeper
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
@ -13,14 +14,14 @@ import (
|
||||
|
||||
// Keeper of the slashing store
|
||||
type Keeper struct {
|
||||
storeKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
cdc codec.BinaryCodec
|
||||
sk types.StakingKeeper
|
||||
paramspace types.ParamSubspace
|
||||
}
|
||||
|
||||
// NewKeeper creates a slashing keeper
|
||||
func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, sk types.StakingKeeper, paramspace types.ParamSubspace) Keeper {
|
||||
func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, sk types.StakingKeeper, paramspace types.ParamSubspace) Keeper {
|
||||
// set KeyTable if it has not already been set
|
||||
if !paramspace.HasKeyTable() {
|
||||
paramspace = paramspace.WithKeyTable(types.ParamKeyTable())
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package v043
|
||||
|
||||
import (
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
v043distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v043"
|
||||
v040slashing "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v040"
|
||||
@ -10,7 +11,7 @@ import (
|
||||
// migration includes:
|
||||
//
|
||||
// - Change addresses to be length-prefixed.
|
||||
func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey) error {
|
||||
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey) error {
|
||||
store := ctx.KVStore(storeKey)
|
||||
v043distribution.MigratePrefixAddress(store, v040slashing.ValidatorSigningInfoKeyPrefix)
|
||||
v043distribution.MigratePrefixAddressBytes(store, v040slashing.ValidatorMissedBlockBitArrayKeyPrefix)
|
||||
|
||||
@ -3,6 +3,7 @@ package keeper
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
@ -19,7 +20,7 @@ var _ types.DelegationSet = Keeper{}
|
||||
|
||||
// keeper of the staking store
|
||||
type Keeper struct {
|
||||
storeKey sdk.StoreKey
|
||||
storeKey storetypes.StoreKey
|
||||
cdc codec.BinaryCodec
|
||||
authKeeper types.AccountKeeper
|
||||
bankKeeper types.BankKeeper
|
||||
@ -29,7 +30,7 @@ type Keeper struct {
|
||||
|
||||
// NewKeeper creates a new staking Keeper instance
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec, key sdk.StoreKey, ak types.AccountKeeper, bk types.BankKeeper,
|
||||
cdc codec.BinaryCodec, key storetypes.StoreKey, ak types.AccountKeeper, bk types.BankKeeper,
|
||||
ps paramtypes.Subspace,
|
||||
) Keeper {
|
||||
// set KeyTable if it has not already been set
|
||||
|
||||
@ -2,6 +2,7 @@ package v043
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040"
|
||||
@ -58,7 +59,7 @@ func migrateValidatorsByPowerIndexKey(store sdk.KVStore) {
|
||||
// migration includes:
|
||||
//
|
||||
// - Setting the Power Reduction param in the paramstore
|
||||
func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey) error {
|
||||
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey) error {
|
||||
store := ctx.KVStore(storeKey)
|
||||
|
||||
v043distribution.MigratePrefixAddress(store, v040staking.LastValidatorPowerKey)
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmos "github.com/tendermint/tendermint/libs/os"
|
||||
|
||||
@ -28,7 +29,7 @@ const UpgradeInfoFileName string = "upgrade-info.json"
|
||||
type Keeper struct {
|
||||
homePath string // root directory of app config
|
||||
skipUpgradeHeights map[int64]bool // map of heights to skip for an upgrade
|
||||
storeKey sdk.StoreKey // key to access x/upgrade store
|
||||
storeKey storetypes.StoreKey // key to access x/upgrade store
|
||||
cdc codec.BinaryCodec // App-wide binary codec
|
||||
upgradeHandlers map[string]types.UpgradeHandler // map of plan name to upgrade handler
|
||||
versionSetter xp.ProtocolVersionSetter // implements setting the protocol version field on BaseApp
|
||||
@ -40,7 +41,7 @@ type Keeper struct {
|
||||
// cdc - the app-wide binary codec
|
||||
// homePath - root directory of the application's config
|
||||
// vs - the interface implemented by baseapp which allows setting baseapp's protocol version field
|
||||
func NewKeeper(skipUpgradeHeights map[int64]bool, storeKey sdk.StoreKey, cdc codec.BinaryCodec, homePath string, vs xp.ProtocolVersionSetter) Keeper {
|
||||
func NewKeeper(skipUpgradeHeights map[int64]bool, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, homePath string, vs xp.ProtocolVersionSetter) Keeper {
|
||||
return Keeper{
|
||||
homePath: homePath,
|
||||
skipUpgradeHeights: skipUpgradeHeights,
|
||||
|
||||
@ -2,13 +2,13 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
store "github.com/cosmos/cosmos-sdk/store/types"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// UpgradeStoreLoader is used to prepare baseapp with a fixed StoreLoader
|
||||
// pattern. This is useful for custom upgrade loading logic.
|
||||
func UpgradeStoreLoader(upgradeHeight int64, storeUpgrades *store.StoreUpgrades) baseapp.StoreLoader {
|
||||
func UpgradeStoreLoader(upgradeHeight int64, storeUpgrades *storetypes.StoreUpgrades) baseapp.StoreLoader {
|
||||
return func(ms sdk.CommitMultiStore) error {
|
||||
if upgradeHeight == ms.LastCommitID().Version+1 {
|
||||
// Check if the current commit version and upgrade height matches
|
||||
|
||||
@ -15,11 +15,11 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/store/rootmulti"
|
||||
store "github.com/cosmos/cosmos-sdk/store/types"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
func useUpgradeLoader(height int64, upgrades *store.StoreUpgrades) func(*baseapp.BaseApp) {
|
||||
func useUpgradeLoader(height int64, upgrades *storetypes.StoreUpgrades) func(*baseapp.BaseApp) {
|
||||
return func(app *baseapp.BaseApp) {
|
||||
app.SetStoreLoader(UpgradeStoreLoader(height, upgrades))
|
||||
}
|
||||
@ -31,15 +31,15 @@ func defaultLogger() log.Logger {
|
||||
|
||||
func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) {
|
||||
rs := rootmulti.NewStore(db)
|
||||
rs.SetPruning(store.PruneNothing)
|
||||
rs.SetPruning(storetypes.PruneNothing)
|
||||
key := sdk.NewKVStoreKey(storeKey)
|
||||
rs.MountStoreWithDB(key, store.StoreTypeIAVL, nil)
|
||||
rs.MountStoreWithDB(key, storetypes.StoreTypeIAVL, nil)
|
||||
err := rs.LoadLatestVersion()
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, int64(0), rs.LastCommitID().Version)
|
||||
|
||||
// write some data in substore
|
||||
kv, _ := rs.GetStore(key).(store.KVStore)
|
||||
kv, _ := rs.GetStore(key).(storetypes.KVStore)
|
||||
require.NotNil(t, kv)
|
||||
kv.Set(k, v)
|
||||
commitID := rs.Commit()
|
||||
@ -48,15 +48,15 @@ func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) {
|
||||
|
||||
func checkStore(t *testing.T, db dbm.DB, ver int64, storeKey string, k, v []byte) {
|
||||
rs := rootmulti.NewStore(db)
|
||||
rs.SetPruning(store.PruneNothing)
|
||||
rs.SetPruning(storetypes.PruneNothing)
|
||||
key := sdk.NewKVStoreKey(storeKey)
|
||||
rs.MountStoreWithDB(key, store.StoreTypeIAVL, nil)
|
||||
rs.MountStoreWithDB(key, storetypes.StoreTypeIAVL, nil)
|
||||
err := rs.LoadLatestVersion()
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, ver, rs.LastCommitID().Version)
|
||||
|
||||
// query data in substore
|
||||
kv, _ := rs.GetStore(key).(store.KVStore)
|
||||
kv, _ := rs.GetStore(key).(storetypes.KVStore)
|
||||
|
||||
require.NotNil(t, kv)
|
||||
require.Equal(t, v, kv.Get(k))
|
||||
@ -95,8 +95,8 @@ func TestSetLoader(t *testing.T) {
|
||||
loadStoreKey: "foo",
|
||||
},
|
||||
"rename with inline opts": {
|
||||
setLoader: useUpgradeLoader(upgradeHeight, &store.StoreUpgrades{
|
||||
Renamed: []store.StoreRename{{
|
||||
setLoader: useUpgradeLoader(upgradeHeight, &storetypes.StoreUpgrades{
|
||||
Renamed: []storetypes.StoreRename{{
|
||||
OldKey: "foo",
|
||||
NewKey: "bar",
|
||||
}},
|
||||
@ -118,7 +118,7 @@ func TestSetLoader(t *testing.T) {
|
||||
initStore(t, db, tc.origStoreKey, k, v)
|
||||
|
||||
// load the app with the existing db
|
||||
opts := []func(*baseapp.BaseApp){baseapp.SetPruning(store.PruneNothing)}
|
||||
opts := []func(*baseapp.BaseApp){baseapp.SetPruning(storetypes.PruneNothing)}
|
||||
|
||||
origapp := baseapp.NewBaseApp(t.Name(), defaultLogger(), db, nil, opts...)
|
||||
origapp.MountStores(sdk.NewKVStoreKey(tc.origStoreKey))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user