Skip to content

Commit

Permalink
refactor: sdk upgrade refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: Deepanshu Tripathi <[email protected]>
  • Loading branch information
deepanshutr committed Jun 20, 2024
1 parent d44333e commit b349ab7
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions helpers/base/auxiliary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package base

import (
context2 "context"
sdkTypes "github.com/cosmos/cosmos-sdk/types"
storeTypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
Expand Down Expand Up @@ -49,7 +49,7 @@ func (dummyMapper dummyMapper) IteratePaginated(_ context2.Context, _ helpers.Ke
func (dummyMapper dummyMapper) StoreDecoder(_ kv.Pair, _ kv.Pair) string {
return ""
}
func (dummyMapper dummyMapper) Initialize(_ *sdkTypes.KVStoreKey) helpers.Mapper {
func (dummyMapper dummyMapper) Initialize(_ *storeTypes.KVStoreKey) helpers.Mapper {
return nil
}
func (dummyMapper dummyMapper) Get(_ string) (interface{}, error) {
Expand Down
10 changes: 5 additions & 5 deletions helpers/base/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package base
import (
"context"
"github.com/AssetMantle/modules/helpers"
"github.com/cosmos/cosmos-sdk/store/types"
storeTypes "github.com/cosmos/cosmos-sdk/store/types"
sdkTypes "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/stretchr/testify/assert"
Expand All @@ -33,15 +33,15 @@ func (mr MockRecord) ReadFromIterator(sdkTypes.Iterator) helpers.Record {
return nil
}

func (mr MockRecord) Read(types.KVStore) helpers.Record {
func (mr MockRecord) Read(storeTypes.KVStore) helpers.Record {
return nil
}

func (mr MockRecord) Write(types.KVStore) helpers.Record {
func (mr MockRecord) Write(storeTypes.KVStore) helpers.Record {
return nil
}

func (mr MockRecord) Delete(types.KVStore) {
func (mr MockRecord) Delete(storeTypes.KVStore) {
}

type MockMapper struct {
Expand All @@ -55,7 +55,7 @@ func (mm MockMapper) StoreDecoder(_ kv.Pair, _ kv.Pair) string {
return ""
}

func (mm MockMapper) Initialize(_ *sdkTypes.KVStoreKey) helpers.Mapper {
func (mm MockMapper) Initialize(_ *storeTypes.KVStoreKey) helpers.Mapper {
return nil
}

Expand Down
11 changes: 6 additions & 5 deletions helpers/base/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ import (
"bytes"
"context"
"fmt"
sdkTypes "github.com/cosmos/cosmos-sdk/types"

prefixStore "github.com/cosmos/cosmos-sdk/store/prefix"
sdkTypes "github.com/cosmos/cosmos-sdk/types"
storeTypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/types/kv"

"github.com/AssetMantle/modules/helpers"
)

type mapper struct {
kvStoreKey *sdkTypes.KVStoreKey
kvStoreKey *storeTypes.KVStoreKey
recordPrototype func() helpers.Record
}

Expand All @@ -25,7 +26,7 @@ var _ helpers.Mapper = (*mapper)(nil)
func (mapper mapper) NewCollection(context context.Context) helpers.Collection {
return collection{}.Initialize(context, mapper)
}
func (mapper mapper) GetKVStoreKey() *sdkTypes.KVStoreKey {
func (mapper mapper) GetKVStoreKey() *storeTypes.KVStoreKey {
return mapper.kvStoreKey
}
func (mapper mapper) Upsert(context context.Context, record helpers.Record) {
Expand All @@ -46,7 +47,7 @@ func (mapper mapper) FetchAll(context context.Context) []helpers.Record {
return records
}
func (mapper mapper) Iterate(context context.Context, key helpers.Key, accumulator func(helpers.Record) bool) {
kvStorePrefixIterator := prefixStore.NewStore(sdkTypes.UnwrapSDKContext(context).KVStore(mapper.kvStoreKey), key.GenerateStorePrefixBytes()).Iterator(key.GenerateStoreKeyBytes(), nil)
kvStorePrefixIterator := sdkTypes.KVStorePrefixIterator(prefixStore.NewStore(sdkTypes.UnwrapSDKContext(context).KVStore(mapper.kvStoreKey), key.GenerateStorePrefixBytes()), key.GenerateStoreKeyBytes())

for ; kvStorePrefixIterator.Valid(); kvStorePrefixIterator.Next() {
if accumulator(mapper.recordPrototype().ReadFromIterator(kvStorePrefixIterator)) {
Expand Down Expand Up @@ -82,7 +83,7 @@ func (mapper mapper) StoreDecoder(kvA kv.Pair, kvB kv.Pair) string {

panic(fmt.Errorf("invalid key prefix %X", kvA.Key[:1]))
}
func (mapper mapper) Initialize(kvStoreKey *sdkTypes.KVStoreKey) helpers.Mapper {
func (mapper mapper) Initialize(kvStoreKey *storeTypes.KVStoreKey) helpers.Mapper {
mapper.kvStoreKey = kvStoreKey
return mapper
}
Expand Down
4 changes: 2 additions & 2 deletions helpers/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package helpers
import (
"context"

sdkTypes "github.com/cosmos/cosmos-sdk/types"
storeTypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/types/kv"
)

Expand All @@ -22,5 +22,5 @@ type Mapper interface {
IteratePaginated(context.Context, Key, int32, func(Record) bool)

StoreDecoder(kv.Pair, kv.Pair) string
Initialize(*sdkTypes.KVStoreKey) Mapper
Initialize(*storeTypes.KVStoreKey) Mapper
}
2 changes: 1 addition & 1 deletion helpers/simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ type Simulator interface {
RandomizedGenesisState(*module.SimulationState)
WeightedOperations(module.SimulationState, Module) simulation.WeightedOperations
WeightedProposalContentList(module.SimulationState) []simulationTypes.WeightedProposalContent
ParamChangeList(*rand.Rand) []simulationTypes.ParamChange
ParamChangeList(*rand.Rand) []simulationTypes.LegacyParamChange
}
2 changes: 1 addition & 1 deletion utilities/cuckoo/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"testing"
"time"

"github.com/cometbft/cometbft/crypto"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto"
)

var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
Expand Down
3 changes: 1 addition & 2 deletions utilities/rest/id_getters/docs/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
package docs

import (
"github.com/cosmos/cosmos-sdk/types/rest"

"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/utilities/rest"
)

type request struct {
Expand Down
2 changes: 1 addition & 1 deletion utilities/rest/queuing/kafka_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"fmt"
"net/http"

dbm "github.com/cometbft/cometbft-db"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/gorilla/mux"
dbm "github.com/tendermint/tm-db"
)

// setTicketIDtoDB : initiates TicketID in Database
Expand Down
5 changes: 3 additions & 2 deletions utilities/rest/queuing/kafka_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
package queuing

import (
"github.com/AssetMantle/modules/utilities/rest"
"github.com/Shopify/sarama"
"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest"
dbm "github.com/tendermint/tm-db"

dbm "github.com/cometbft/cometbft-db"
)

// TicketID : is a type that implements string
Expand Down
2 changes: 1 addition & 1 deletion utilities/rest/queuing/sign_and_broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func signAndBroadcastMultiple(kafkaMsgList []kafkaMsg, context client.Context) (
return nil, err
}

keyBase, err := keyring.New(sdkTypes.KeyringServiceName(), viper.GetString(flags.FlagKeyringBackend), viper.GetString(flags.FlagHome), strings.NewReader(keys.DefaultKeyPass))
keyBase, err := keyring.New(sdkTypes.KeyringServiceName(), viper.GetString(flags.FlagKeyringBackend), viper.GetString(flags.FlagHome), strings.NewReader(keys.DefaultKeyPass), context.Codec)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit b349ab7

Please sign in to comment.