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:
Ivan Verchenko
2021-10-04 16:36:38 +00:00
committed by GitHub
parent b601f521cb
commit d07e41683a
41 changed files with 193 additions and 189 deletions
+6 -6
View File
@@ -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
+8 -34
View File
@@ -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)
}
+2 -1
View File
@@ -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"
+3 -3
View File
@@ -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")))
}