diff --git a/CHANGELOG.md b/CHANGELOG.md index 31ce75bf62f5..b1bd0c2abb55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -105,7 +105,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking Changes -* (x/auth) [#15517](https://github.com/cosmos/cosmos-sdk/pull/15517) `NewAccountKeeper` now takes a `KVStoreService` instead of a `StoreKey` and methods in the `Keeper` now take a `context.Context` instead of a `sdk.Context`. +* (x/nft) [#15588](https://github.com/cosmos/cosmos-sdk/pull/15588) `NewKeeper` now takes a `KVStoreService` instead of a `StoreKey` and methods in the `Keeper` now take a `context.Context` instead of a `sdk.Context`. +* (x/auth) [#15520](https://github.com/cosmos/cosmos-sdk/pull/15520) `NewAccountKeeper` now takes a `KVStoreService` instead of a `StoreKey` and methods in the `Keeper` now take a `context.Context` instead of a `sdk.Context`. * (x/consensus) [#15517](https://github.com/cosmos/cosmos-sdk/pull/15517) `NewKeeper` now takes a `KVStoreService` instead of a `StoreKey`. * (x/bank) [#15477](https://github.com/cosmos/cosmos-sdk/pull/15477) `banktypes.NewMsgMultiSend` and `keeper.InputOutputCoins` only accept one input. * (mempool) [#15328](https://github.com/cosmos/cosmos-sdk/pull/15328) The `PriorityNonceMempool` is now generic over type `C comparable` and takes a single `PriorityNonceMempoolConfig[C]` argument. See `DefaultPriorityNonceMempoolConfig` for how to construct the configuration and a `TxPriority` type. diff --git a/UPGRADING.md b/UPGRADING.md index c9c245d5f2eb..ac02aec886a4 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -68,6 +68,7 @@ The following modules `NewKeeper` function now take a `KVStoreService` instead o * `x/auth` * `x/consensus` +* `x/nft` When not using depinject, the `runtime.NewKVStoreService` method can be used to create a `KVStoreService` from a `StoreKey`: diff --git a/simapp/app.go b/simapp/app.go index ab37061b6067..cbbebb652e23 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -366,7 +366,7 @@ func NewSimApp( ), ) - app.NFTKeeper = nftkeeper.NewKeeper(keys[nftkeeper.StoreKey], appCodec, app.AccountKeeper, app.BankKeeper) + app.NFTKeeper = nftkeeper.NewKeeper(runtime.NewKVStoreService(keys[nftkeeper.StoreKey]), appCodec, app.AccountKeeper, app.BankKeeper) // create evidence keeper with router evidenceKeeper := evidencekeeper.NewKeeper( diff --git a/x/nft/keeper/class.go b/x/nft/keeper/class.go index 1517961df02b..1e73a27beec6 100644 --- a/x/nft/keeper/class.go +++ b/x/nft/keeper/class.go @@ -1,15 +1,17 @@ package keeper import ( + "context" + "cosmossdk.io/errors" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/nft" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/runtime" ) // SaveClass defines a method for creating a new nft class -func (k Keeper) SaveClass(ctx sdk.Context, class nft.Class) error { +func (k Keeper) SaveClass(ctx context.Context, class nft.Class) error { if k.HasClass(ctx, class.Id) { return errors.Wrap(nft.ErrClassExists, class.Id) } @@ -17,13 +19,12 @@ func (k Keeper) SaveClass(ctx sdk.Context, class nft.Class) error { if err != nil { return errors.Wrap(err, "Marshal nft.Class failed") } - store := ctx.KVStore(k.storeKey) - store.Set(classStoreKey(class.Id), bz) - return nil + store := k.storeService.OpenKVStore(ctx) + return store.Set(classStoreKey(class.Id), bz) } // UpdateClass defines a method for updating an exist nft class -func (k Keeper) UpdateClass(ctx sdk.Context, class nft.Class) error { +func (k Keeper) UpdateClass(ctx context.Context, class nft.Class) error { if !k.HasClass(ctx, class.Id) { return errors.Wrap(nft.ErrClassNotExists, class.Id) } @@ -31,17 +32,20 @@ func (k Keeper) UpdateClass(ctx sdk.Context, class nft.Class) error { if err != nil { return errors.Wrap(err, "Marshal nft.Class failed") } - store := ctx.KVStore(k.storeKey) - store.Set(classStoreKey(class.Id), bz) - return nil + store := k.storeService.OpenKVStore(ctx) + return store.Set(classStoreKey(class.Id), bz) } // GetClass defines a method for returning the class information of the specified id -func (k Keeper) GetClass(ctx sdk.Context, classID string) (nft.Class, bool) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(classStoreKey(classID)) - +func (k Keeper) GetClass(ctx context.Context, classID string) (nft.Class, bool) { + store := k.storeService.OpenKVStore(ctx) var class nft.Class + + bz, err := store.Get(classStoreKey(classID)) + if err != nil { + return class, false + } + if len(bz) == 0 { return class, false } @@ -50,9 +54,9 @@ func (k Keeper) GetClass(ctx sdk.Context, classID string) (nft.Class, bool) { } // GetClasses defines a method for returning all classes information -func (k Keeper) GetClasses(ctx sdk.Context) (classes []*nft.Class) { - store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, ClassKey) +func (k Keeper) GetClasses(ctx context.Context) (classes []*nft.Class) { + store := k.storeService.OpenKVStore(ctx) + iterator := storetypes.KVStorePrefixIterator(runtime.KVStoreAdapter(store), ClassKey) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { var class nft.Class @@ -63,7 +67,11 @@ func (k Keeper) GetClasses(ctx sdk.Context) (classes []*nft.Class) { } // HasClass determines whether the specified classID exist -func (k Keeper) HasClass(ctx sdk.Context, classID string) bool { - store := ctx.KVStore(k.storeKey) - return store.Has(classStoreKey(classID)) +func (k Keeper) HasClass(ctx context.Context, classID string) bool { + store := k.storeService.OpenKVStore(ctx) + has, err := store.Has(classStoreKey(classID)) + if err != nil { + panic(err) + } + return has } diff --git a/x/nft/keeper/grpc_query.go b/x/nft/keeper/grpc_query.go index 0280394c8951..3416f2e7ea1e 100644 --- a/x/nft/keeper/grpc_query.go +++ b/x/nft/keeper/grpc_query.go @@ -6,6 +6,7 @@ import ( "cosmossdk.io/store/prefix" "cosmossdk.io/x/nft" + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" @@ -174,8 +175,8 @@ func (k Keeper) Classes(goCtx context.Context, r *nft.QueryClassesRequest) (*nft } ctx := sdk.UnwrapSDKContext(goCtx) - store := ctx.KVStore(k.storeKey) - classStore := prefix.NewStore(store, ClassKey) + store := k.storeService.OpenKVStore(ctx) + classStore := prefix.NewStore(runtime.KVStoreAdapter(store), ClassKey) var classes []*nft.Class pageRes, err := query.Paginate(classStore, r.Pagination, func(_ []byte, value []byte) error { diff --git a/x/nft/keeper/keeper.go b/x/nft/keeper/keeper.go index 3bfa5696d2a4..b68d0004b79f 100644 --- a/x/nft/keeper/keeper.go +++ b/x/nft/keeper/keeper.go @@ -1,7 +1,7 @@ package keeper import ( - storetypes "cosmossdk.io/store/types" + store "cosmossdk.io/core/store" "cosmossdk.io/x/nft" "github.com/cosmos/cosmos-sdk/codec" @@ -9,13 +9,13 @@ import ( // Keeper of the nft store type Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - bk nft.BankKeeper + cdc codec.BinaryCodec + storeService store.KVStoreService + bk nft.BankKeeper } // NewKeeper creates a new nft Keeper instance -func NewKeeper(key storetypes.StoreKey, +func NewKeeper(storeService store.KVStoreService, cdc codec.BinaryCodec, ak nft.AccountKeeper, bk nft.BankKeeper, ) Keeper { // ensure nft module account is set @@ -24,8 +24,8 @@ func NewKeeper(key storetypes.StoreKey, } return Keeper{ - cdc: cdc, - storeKey: key, - bk: bk, + cdc: cdc, + storeService: storeService, + bk: bk, } } diff --git a/x/nft/keeper/keeper_test.go b/x/nft/keeper/keeper_test.go index 36abc07a6c09..1c926e7482d8 100644 --- a/x/nft/keeper/keeper_test.go +++ b/x/nft/keeper/keeper_test.go @@ -15,6 +15,7 @@ import ( nfttestutil "cosmossdk.io/x/nft/testutil" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" @@ -50,6 +51,7 @@ func (s *TestSuite) SetupTest() { s.encCfg = moduletestutil.MakeTestEncodingConfig(module.AppModuleBasic{}) key := storetypes.NewKVStoreKey(nft.StoreKey) + storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()}) @@ -59,7 +61,7 @@ func (s *TestSuite) SetupTest() { bankKeeper := nfttestutil.NewMockBankKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("nft").Return(s.addrs[0]).AnyTimes() - nftKeeper := keeper.NewKeeper(key, s.encCfg.Codec, accountKeeper, bankKeeper) + nftKeeper := keeper.NewKeeper(storeService, s.encCfg.Codec, accountKeeper, bankKeeper) queryHelper := baseapp.NewQueryServerTestHelper(ctx, s.encCfg.InterfaceRegistry) nft.RegisterQueryServer(queryHelper, nftKeeper) diff --git a/x/nft/keeper/nft.go b/x/nft/keeper/nft.go index 2db46f54eff0..d31a8c036f3f 100644 --- a/x/nft/keeper/nft.go +++ b/x/nft/keeper/nft.go @@ -1,15 +1,18 @@ package keeper import ( + "context" + "cosmossdk.io/errors" "cosmossdk.io/store/prefix" "cosmossdk.io/x/nft" + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" ) // Mint defines a method for minting a new nft -func (k Keeper) Mint(ctx sdk.Context, token nft.NFT, receiver sdk.AccAddress) error { +func (k Keeper) Mint(ctx context.Context, token nft.NFT, receiver sdk.AccAddress) error { if !k.HasClass(ctx, token.ClassId) { return errors.Wrap(nft.ErrClassNotExists, token.ClassId) } @@ -25,12 +28,12 @@ func (k Keeper) Mint(ctx sdk.Context, token nft.NFT, receiver sdk.AccAddress) er // mintWithNoCheck defines a method for minting a new nft // Note: this method does not check whether the class already exists in nft. // The upper-layer application needs to check it when it needs to use it. -func (k Keeper) mintWithNoCheck(ctx sdk.Context, token nft.NFT, receiver sdk.AccAddress) { +func (k Keeper) mintWithNoCheck(ctx context.Context, token nft.NFT, receiver sdk.AccAddress) { k.setNFT(ctx, token) k.setOwner(ctx, token.ClassId, token.Id, receiver) k.incrTotalSupply(ctx, token.ClassId) - ctx.EventManager().EmitTypedEvent(&nft.EventMint{ + sdk.UnwrapSDKContext(ctx).EventManager().EmitTypedEvent(&nft.EventMint{ ClassId: token.ClassId, Id: token.Id, Owner: receiver.String(), @@ -39,7 +42,7 @@ func (k Keeper) mintWithNoCheck(ctx sdk.Context, token nft.NFT, receiver sdk.Acc // Burn defines a method for burning a nft from a specific account. // Note: When the upper module uses this method, it needs to authenticate nft -func (k Keeper) Burn(ctx sdk.Context, classID string, nftID string) error { +func (k Keeper) Burn(ctx context.Context, classID string, nftID string) error { if !k.HasClass(ctx, classID) { return errors.Wrap(nft.ErrClassNotExists, classID) } @@ -55,14 +58,14 @@ func (k Keeper) Burn(ctx sdk.Context, classID string, nftID string) error { // burnWithNoCheck defines a method for burning a nft from a specific account. // Note: this method does not check whether the class already exists in nft. // The upper-layer application needs to check it when it needs to use it -func (k Keeper) burnWithNoCheck(ctx sdk.Context, classID string, nftID string) error { +func (k Keeper) burnWithNoCheck(ctx context.Context, classID string, nftID string) error { owner := k.GetOwner(ctx, classID, nftID) nftStore := k.getNFTStore(ctx, classID) nftStore.Delete([]byte(nftID)) k.deleteOwner(ctx, classID, nftID, owner) k.decrTotalSupply(ctx, classID) - ctx.EventManager().EmitTypedEvent(&nft.EventBurn{ + sdk.UnwrapSDKContext(ctx).EventManager().EmitTypedEvent(&nft.EventBurn{ ClassId: classID, Id: nftID, Owner: owner.String(), @@ -72,7 +75,7 @@ func (k Keeper) burnWithNoCheck(ctx sdk.Context, classID string, nftID string) e // Update defines a method for updating an exist nft // Note: When the upper module uses this method, it needs to authenticate nft -func (k Keeper) Update(ctx sdk.Context, token nft.NFT) error { +func (k Keeper) Update(ctx context.Context, token nft.NFT) error { if !k.HasClass(ctx, token.ClassId) { return errors.Wrap(nft.ErrClassNotExists, token.ClassId) } @@ -87,13 +90,13 @@ func (k Keeper) Update(ctx sdk.Context, token nft.NFT) error { // Update defines a method for updating an exist nft // Note: this method does not check whether the class already exists in nft. // The upper-layer application needs to check it when it needs to use it -func (k Keeper) updateWithNoCheck(ctx sdk.Context, token nft.NFT) { +func (k Keeper) updateWithNoCheck(ctx context.Context, token nft.NFT) { k.setNFT(ctx, token) } // Transfer defines a method for sending a nft from one account to another account. // Note: When the upper module uses this method, it needs to authenticate nft -func (k Keeper) Transfer(ctx sdk.Context, +func (k Keeper) Transfer(ctx context.Context, classID string, nftID string, receiver sdk.AccAddress, @@ -113,7 +116,7 @@ func (k Keeper) Transfer(ctx sdk.Context, // Transfer defines a method for sending a nft from one account to another account. // Note: this method does not check whether the class already exists in nft. // The upper-layer application needs to check it when it needs to use it -func (k Keeper) transferWithNoCheck(ctx sdk.Context, +func (k Keeper) transferWithNoCheck(ctx context.Context, classID string, nftID string, receiver sdk.AccAddress, @@ -125,7 +128,7 @@ func (k Keeper) transferWithNoCheck(ctx sdk.Context, } // GetNFT returns the nft information of the specified classID and nftID -func (k Keeper) GetNFT(ctx sdk.Context, classID, nftID string) (nft.NFT, bool) { +func (k Keeper) GetNFT(ctx context.Context, classID, nftID string) (nft.NFT, bool) { store := k.getNFTStore(ctx, classID) bz := store.Get([]byte(nftID)) if len(bz) == 0 { @@ -137,7 +140,7 @@ func (k Keeper) GetNFT(ctx sdk.Context, classID, nftID string) (nft.NFT, bool) { } // GetNFTsOfClassByOwner returns all nft information of the specified classID under the specified owner -func (k Keeper) GetNFTsOfClassByOwner(ctx sdk.Context, classID string, owner sdk.AccAddress) (nfts []nft.NFT) { +func (k Keeper) GetNFTsOfClassByOwner(ctx context.Context, classID string, owner sdk.AccAddress) (nfts []nft.NFT) { ownerStore := k.getClassStoreByOwner(ctx, owner, classID) iterator := ownerStore.Iterator(nil, nil) defer iterator.Close() @@ -151,7 +154,7 @@ func (k Keeper) GetNFTsOfClassByOwner(ctx sdk.Context, classID string, owner sdk } // GetNFTsOfClass returns all nft information under the specified classID -func (k Keeper) GetNFTsOfClass(ctx sdk.Context, classID string) (nfts []nft.NFT) { +func (k Keeper) GetNFTsOfClass(ctx context.Context, classID string) (nfts []nft.NFT) { nftStore := k.getNFTStore(ctx, classID) iterator := nftStore.Iterator(nil, nil) defer iterator.Close() @@ -164,82 +167,91 @@ func (k Keeper) GetNFTsOfClass(ctx sdk.Context, classID string) (nfts []nft.NFT) } // GetOwner returns the owner information of the specified nft -func (k Keeper) GetOwner(ctx sdk.Context, classID string, nftID string) sdk.AccAddress { - store := ctx.KVStore(k.storeKey) - bz := store.Get(ownerStoreKey(classID, nftID)) +func (k Keeper) GetOwner(ctx context.Context, classID string, nftID string) sdk.AccAddress { + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(ownerStoreKey(classID, nftID)) + if err != nil { + panic(err) + } return sdk.AccAddress(bz) } // GetBalance returns the specified account, the number of all nfts under the specified classID -func (k Keeper) GetBalance(ctx sdk.Context, classID string, owner sdk.AccAddress) uint64 { +func (k Keeper) GetBalance(ctx context.Context, classID string, owner sdk.AccAddress) uint64 { nfts := k.GetNFTsOfClassByOwner(ctx, classID, owner) return uint64(len(nfts)) } // GetTotalSupply returns the number of all nfts under the specified classID -func (k Keeper) GetTotalSupply(ctx sdk.Context, classID string) uint64 { - store := ctx.KVStore(k.storeKey) - bz := store.Get(classTotalSupply(classID)) +func (k Keeper) GetTotalSupply(ctx context.Context, classID string) uint64 { + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(classTotalSupply(classID)) + if err != nil { + panic(err) + } return sdk.BigEndianToUint64(bz) } // HasNFT determines whether the specified classID and nftID exist -func (k Keeper) HasNFT(ctx sdk.Context, classID, id string) bool { +func (k Keeper) HasNFT(ctx context.Context, classID, id string) bool { store := k.getNFTStore(ctx, classID) return store.Has([]byte(id)) } -func (k Keeper) setNFT(ctx sdk.Context, token nft.NFT) { +func (k Keeper) setNFT(ctx context.Context, token nft.NFT) { nftStore := k.getNFTStore(ctx, token.ClassId) bz := k.cdc.MustMarshal(&token) nftStore.Set([]byte(token.Id), bz) } -func (k Keeper) setOwner(ctx sdk.Context, classID, nftID string, owner sdk.AccAddress) { - store := ctx.KVStore(k.storeKey) +func (k Keeper) setOwner(ctx context.Context, classID, nftID string, owner sdk.AccAddress) { + store := k.storeService.OpenKVStore(ctx) store.Set(ownerStoreKey(classID, nftID), owner.Bytes()) ownerStore := k.getClassStoreByOwner(ctx, owner, classID) ownerStore.Set([]byte(nftID), Placeholder) } -func (k Keeper) deleteOwner(ctx sdk.Context, classID, nftID string, owner sdk.AccAddress) { - store := ctx.KVStore(k.storeKey) +func (k Keeper) deleteOwner(ctx context.Context, classID, nftID string, owner sdk.AccAddress) { + store := k.storeService.OpenKVStore(ctx) store.Delete(ownerStoreKey(classID, nftID)) ownerStore := k.getClassStoreByOwner(ctx, owner, classID) ownerStore.Delete([]byte(nftID)) } -func (k Keeper) getNFTStore(ctx sdk.Context, classID string) prefix.Store { - store := ctx.KVStore(k.storeKey) - return prefix.NewStore(store, nftStoreKey(classID)) +func (k Keeper) getNFTStore(ctx context.Context, classID string) prefix.Store { + store := k.storeService.OpenKVStore(ctx) + return prefix.NewStore(runtime.KVStoreAdapter(store), nftStoreKey(classID)) } -func (k Keeper) getClassStoreByOwner(ctx sdk.Context, owner sdk.AccAddress, classID string) prefix.Store { - store := ctx.KVStore(k.storeKey) +func (k Keeper) getClassStoreByOwner(ctx context.Context, owner sdk.AccAddress, classID string) prefix.Store { + store := k.storeService.OpenKVStore(ctx) key := nftOfClassByOwnerStoreKey(owner, classID) - return prefix.NewStore(store, key) + return prefix.NewStore(runtime.KVStoreAdapter(store), key) } -func (k Keeper) prefixStoreNftOfClassByOwner(ctx sdk.Context, owner sdk.AccAddress) prefix.Store { - store := ctx.KVStore(k.storeKey) +func (k Keeper) prefixStoreNftOfClassByOwner(ctx context.Context, owner sdk.AccAddress) prefix.Store { + store := k.storeService.OpenKVStore(ctx) key := prefixNftOfClassByOwnerStoreKey(owner) - return prefix.NewStore(store, key) + return prefix.NewStore(runtime.KVStoreAdapter(store), key) } -func (k Keeper) incrTotalSupply(ctx sdk.Context, classID string) { +func (k Keeper) incrTotalSupply(ctx context.Context, classID string) { supply := k.GetTotalSupply(ctx, classID) + 1 k.updateTotalSupply(ctx, classID, supply) } -func (k Keeper) decrTotalSupply(ctx sdk.Context, classID string) { +func (k Keeper) decrTotalSupply(ctx context.Context, classID string) { supply := k.GetTotalSupply(ctx, classID) - 1 k.updateTotalSupply(ctx, classID, supply) } -func (k Keeper) updateTotalSupply(ctx sdk.Context, classID string, supply uint64) { - store := ctx.KVStore(k.storeKey) +func (k Keeper) updateTotalSupply(ctx context.Context, classID string, supply uint64) { + store := k.storeService.OpenKVStore(ctx) supplyKey := classTotalSupply(classID) - store.Set(supplyKey, sdk.Uint64ToBigEndian(supply)) + err := store.Set(supplyKey, sdk.Uint64ToBigEndian(supply)) + if err != nil { + panic(err) + } } diff --git a/x/nft/keeper/nft_batch.go b/x/nft/keeper/nft_batch.go index 345897d6b060..474842869f66 100644 --- a/x/nft/keeper/nft_batch.go +++ b/x/nft/keeper/nft_batch.go @@ -1,6 +1,8 @@ package keeper import ( + "context" + "cosmossdk.io/errors" "cosmossdk.io/x/nft" @@ -8,7 +10,7 @@ import ( ) // BatchMint defines a method for minting a batch of nfts -func (k Keeper) BatchMint(ctx sdk.Context, +func (k Keeper) BatchMint(ctx context.Context, tokens []nft.NFT, receiver sdk.AccAddress, ) error { @@ -30,7 +32,7 @@ func (k Keeper) BatchMint(ctx sdk.Context, // BatchBurn defines a method for burning a batch of nfts from a specific classID. // Note: When the upper module uses this method, it needs to authenticate nft -func (k Keeper) BatchBurn(ctx sdk.Context, classID string, nftIDs []string) error { +func (k Keeper) BatchBurn(ctx context.Context, classID string, nftIDs []string) error { if !k.HasClass(ctx, classID) { return errors.Wrap(nft.ErrClassNotExists, classID) } @@ -47,7 +49,7 @@ func (k Keeper) BatchBurn(ctx sdk.Context, classID string, nftIDs []string) erro // BatchUpdate defines a method for updating a batch of exist nfts // Note: When the upper module uses this method, it needs to authenticate nft -func (k Keeper) BatchUpdate(ctx sdk.Context, tokens []nft.NFT) error { +func (k Keeper) BatchUpdate(ctx context.Context, tokens []nft.NFT) error { checked := make(map[string]bool, len(tokens)) for _, token := range tokens { if !checked[token.ClassId] && !k.HasClass(ctx, token.ClassId) { @@ -65,7 +67,7 @@ func (k Keeper) BatchUpdate(ctx sdk.Context, tokens []nft.NFT) error { // BatchTransfer defines a method for sending a batch of nfts from one account to another account from a specific classID. // Note: When the upper module uses this method, it needs to authenticate nft -func (k Keeper) BatchTransfer(ctx sdk.Context, +func (k Keeper) BatchTransfer(ctx context.Context, classID string, nftIDs []string, receiver sdk.AccAddress, diff --git a/x/nft/module/module.go b/x/nft/module/module.go index 5ff580568504..4404f87d26ae 100644 --- a/x/nft/module/module.go +++ b/x/nft/module/module.go @@ -10,9 +10,9 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/errors" - store "cosmossdk.io/store/types" sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -186,9 +186,9 @@ func init() { type NftInputs struct { depinject.In - Key *store.KVStoreKey - Cdc codec.Codec - Registry cdctypes.InterfaceRegistry + StoreService store.KVStoreService + Cdc codec.Codec + Registry cdctypes.InterfaceRegistry AccountKeeper nft.AccountKeeper BankKeeper nft.BankKeeper @@ -202,7 +202,7 @@ type NftOutputs struct { } func ProvideModule(in NftInputs) NftOutputs { - k := keeper.NewKeeper(in.Key, in.Cdc, in.AccountKeeper, in.BankKeeper) + k := keeper.NewKeeper(in.StoreService, in.Cdc, in.AccountKeeper, in.BankKeeper) m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry) return NftOutputs{NFTKeeper: k, Module: m}