Skip to content

Commit

Permalink
refactor: remove deprecated imports + consistent imports + linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Unique-Divine committed May 20, 2024
1 parent 5b090a1 commit 7dbc830
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
5 changes: 2 additions & 3 deletions collections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ import (
"cosmossdk.io/log"
"cosmossdk.io/store"
"cosmossdk.io/store/metrics"
"cosmossdk.io/store/types"
storetypes "cosmossdk.io/store/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func deps() (types.StoreKey, sdk.Context, codec.BinaryCodec) {
func deps() (storetypes.StoreKey, sdk.Context, codec.BinaryCodec) {
sk := storetypes.NewKVStoreKey("mock")
db := dbm.NewMemDB()
ms := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())
ms.MountStoreWithDB(sk, types.StoreTypeIAVL, db)
ms.MountStoreWithDB(sk, storetypes.StoreTypeIAVL, db)
if err := ms.LoadLatestVersion(); err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/1.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package examples

import (
storagetypes "cosmossdk.io/store/types"
storetypes "cosmossdk.io/store/types"
"github.com/NibiruChain/collections"
"github.com/cosmos/cosmos-sdk/codec"
crypto "github.com/cosmos/cosmos-sdk/crypto/types"
Expand All @@ -15,7 +15,7 @@ type AccountKeeper struct {
Params collections.Item[types.Params]
}

func NewAccountKeeper(sk storagetypes.StoreKey, cdc codec.BinaryCodec) *AccountKeeper {
func NewAccountKeeper(sk storetypes.StoreKey, cdc codec.BinaryCodec) *AccountKeeper {
return &AccountKeeper{
AccountNumber: collections.NewSequence(sk, 0), // namespace is unique across the module's collections types
Accounts: collections.NewMap(sk, 1, collections.AccAddressKeyEncoder, collections.ProtoValueEncoder[types.BaseAccount](cdc)), // we pass it the AccAddress key encoder and the base account value encoder.
Expand Down
4 changes: 2 additions & 2 deletions examples/3.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package examples

import (
storagetypes "cosmossdk.io/store/types"
storetypes "cosmossdk.io/store/types"
"github.com/NibiruChain/collections"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -27,7 +27,7 @@ type StakingKeeper2 struct {
Validators collections.IndexedMap[sdk.ValAddress, types.Validator, ValidatorIndexes]
}

func NewStakingKeeper2(sk storagetypes.StoreKey, cdc codec.BinaryCodec) *StakingKeeper2 {
func NewStakingKeeper2(sk storetypes.StoreKey, cdc codec.BinaryCodec) *StakingKeeper2 {
return &StakingKeeper2{
Validators: collections.NewIndexedMap(
sk, 0,
Expand Down
4 changes: 2 additions & 2 deletions indexed_map.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package collections

import (
"cosmossdk.io/store/types"
storetypes "cosmossdk.io/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand Down Expand Up @@ -31,7 +31,7 @@ type Indexer[PK any, V any] interface {

// NewIndexedMap instantiates a new IndexedMap instance.
func NewIndexedMap[PK any, V any, I IndexersProvider[PK, V]](
storeKey types.StoreKey, namespace Namespace,
storeKey storetypes.StoreKey, namespace Namespace,
primaryKeyEncoder KeyEncoder[PK],
valueEncoder ValueEncoder[V],
indexers I,
Expand Down
4 changes: 2 additions & 2 deletions indexers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package collections

import (
"cosmossdk.io/store/types"
storetypes "cosmossdk.io/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand Down Expand Up @@ -40,7 +40,7 @@ func (i IndexerIterator[IK, PK]) Close() { (KeySetIterator[Pair[IK, PK]])(i
// namespace is the unique storage namespace for the index.
// getIndexingKeyFunc is a function which given the object returns the key we use to index the object.
func NewMultiIndex[IK, PK any, V any](
sk types.StoreKey, namespace Namespace,
sk storetypes.StoreKey, namespace Namespace,
indexKeyEncoder KeyEncoder[IK], primaryKeyEncoder KeyEncoder[PK],
getIndexingKeyFunc func(v V) IK,
) MultiIndex[IK, PK, V] {
Expand Down
6 changes: 3 additions & 3 deletions item.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package collections

import (
"cosmossdk.io/store/types"
storetypes "cosmossdk.io/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// itemKey is a constant byte key which maps an Item object.
const itemKey uint64 = 0

// NewItem instantiates a new Item instance.
func NewItem[V any](sk types.StoreKey, namespace Namespace, valueEncoder ValueEncoder[V]) Item[V] {
func NewItem[V any](sk storetypes.StoreKey, namespace Namespace, valueEncoder ValueEncoder[V]) Item[V] {
return (Item[V])(NewMap[uint64, V](sk, namespace, uint64Key{}, valueEncoder))
}

Expand All @@ -35,7 +35,7 @@ func (i Item[V]) Set(ctx sdk.Context, v V) { (Map[uint64, V])(i).Insert(ctx, ite

// NewItem instantiates a new Item instance.
func NewItemTransient[V any](
sk types.StoreKey, namespace Namespace, valueEncoder ValueEncoder[V],
sk storetypes.StoreKey, namespace Namespace, valueEncoder ValueEncoder[V],
) ItemTransient[V] {
return (ItemTransient[V])(NewMapTransient[uint64, V](sk, namespace, uint64Key{}, valueEncoder))
}
Expand Down
4 changes: 2 additions & 2 deletions keyset.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"fmt"

"cosmossdk.io/store/types"
storetypes "cosmossdk.io/store/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand All @@ -18,7 +18,7 @@ type KeySet[K any] Map[K, setObject]
type KeySetIterator[K any] Iterator[K, setObject]

// NewKeySet instantiates a new KeySet.
func NewKeySet[K any](sk types.StoreKey, namespace Namespace, keyEncoder KeyEncoder[K]) KeySet[K] {
func NewKeySet[K any](sk storetypes.StoreKey, namespace Namespace, keyEncoder KeyEncoder[K]) KeySet[K] {
return (KeySet[K])(NewMap[K, setObject](sk, namespace, keyEncoder, setObject{}))
}

Expand Down
8 changes: 4 additions & 4 deletions map.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"cosmossdk.io/store"
"cosmossdk.io/store/types"
storetypes "cosmossdk.io/store/types"

"cosmossdk.io/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -18,7 +18,7 @@ type Map[K, V any] struct {
vc ValueEncoder[V]

prefix []byte
sk types.StoreKey
sk storetypes.StoreKey

typeName string
}
Expand All @@ -27,7 +27,7 @@ type Map[K, V any] struct {
// encoder, and value encoder. It initializes a namespace-specific prefix and
// type name for value type V.
func NewMap[K, V any](
sk types.StoreKey, namespace Namespace, kc KeyEncoder[K], vc ValueEncoder[V],
sk storetypes.StoreKey, namespace Namespace, kc KeyEncoder[K], vc ValueEncoder[V],
) Map[K, V] {
return Map[K, V]{
kc: kc,
Expand Down Expand Up @@ -112,7 +112,7 @@ func (m MapTransient[K, V]) GetStore(ctx sdk.Context) store.KVStore {
}

func NewMapTransient[K, V any](
sk types.StoreKey, namespace Namespace, kc KeyEncoder[K], vc ValueEncoder[V],
sk storetypes.StoreKey, namespace Namespace, kc KeyEncoder[K], vc ValueEncoder[V],
) MapTransient[K, V] {
return MapTransient[K, V]{
Map: Map[K, V]{
Expand Down
4 changes: 2 additions & 2 deletions sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package collections
import (
"strconv"

"cosmossdk.io/store/types"
storetypes "cosmossdk.io/store/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand All @@ -18,7 +18,7 @@ type Sequence struct {
}

// NewSequence instantiates a new sequence object.
func NewSequence(sk types.StoreKey, namespace Namespace) Sequence {
func NewSequence(sk storetypes.StoreKey, namespace Namespace) Sequence {
return Sequence{
sequence: NewItem[uint64](sk, namespace, uint64Value{}),
}
Expand Down
5 changes: 3 additions & 2 deletions value_encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
cosmosproto "github.com/cosmos/gogoproto/proto"
"github.com/gogo/protobuf/proto"
)

Expand All @@ -22,7 +23,7 @@ var (
// the protobuf object bytes representation into the concrete object.
func ProtoValueEncoder[V any, PV interface {
*V
codec.ProtoMarshaler
cosmosproto.Message
}](cdc codec.BinaryCodec) ValueEncoder[V] {
return protoValueEncoder[V, PV]{
cdc: cdc,
Expand All @@ -31,7 +32,7 @@ func ProtoValueEncoder[V any, PV interface {

type protoValueEncoder[V any, PV interface {
*V
codec.ProtoMarshaler
cosmosproto.Message
}] struct {
cdc codec.BinaryCodec
}
Expand Down

0 comments on commit 7dbc830

Please sign in to comment.