Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump up mods.irisnet.org/modules/nft to cosmos-sdk v0.50.10 #449

Closed
wants to merge 39 commits into from

Conversation

wangjiulian
Copy link
Collaborator

@wangjiulian wangjiulian commented Nov 7, 2024

#441

Summary by CodeRabbit

Release Notes

  • New Features

    • Updated to Go version 1.21 and toolchain version go1.23.1 across various modules.
    • Introduced new dependencies, enhancing functionality and security.
  • Improvements

    • Streamlined module dependency management by switching to service-based store interactions.
    • Enhanced error handling and logging mechanisms in transaction processing and state management.
  • Bug Fixes

    • Resolved issues related to transaction result processing and querying.
  • Refactor

    • Updated import paths to align with the new module structure.
    • Simplified function signatures for better readability and maintainability.

Copy link

coderabbitai bot commented Nov 7, 2024

Warning

Rate limit exceeded

@wangjiulian has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 27 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between e0472dd and 87f51ed.

Walkthrough

This pull request introduces substantial updates across multiple Go modules, primarily focusing on upgrading the Go version from 1.19 to 1.21 and adjusting various dependencies to their latest versions, including the Cosmos SDK. Key changes include the replacement of certain import paths to a new structure under cosmossdk.io, modifications in method signatures, and the removal of unused methods. Additionally, the handling of store interactions has shifted from key-based to service-based approaches, enhancing modularity and maintainability.

Changes

File Path Change Summary
e2e/go.mod Updated Go version to 1.21, added toolchain go1.23.1, upgraded multiple dependencies including cosmossdk.io/api, github.com/cosmos/cosmos-sdk, and replaced github.com/dgrijalva/jwt-go with github.com/golang-jwt/jwt/v4.
modules/mt/depinject.go Updated import path for store, modified Inputs struct to replace Key with StoreService.
modules/mt/go.mod Updated Go version to 1.21, added toolchain go1.23.1, upgraded dependencies like cosmossdk.io/core, github.com/cosmos/cosmos-sdk, and added new dependencies.
modules/mt/handler.go Changed NewHandler return type from sdk.Handler to a function type accepting sdk.Context and sdk.Msg.
modules/mt/keeper/balance.go Updated import for iterator from sdk.KVStorePrefixIterator to storetypes.KVStorePrefixIterator.
modules/mt/keeper/denom.go Updated import for iterator from sdk.KVStorePrefixIterator to storetypes.KVStorePrefixIterator.
modules/mt/keeper/grpc_query.go Changed import path for prefix package from github.com/cosmos/cosmos-sdk/store/prefix to cosmossdk.io/store/prefix.
modules/mt/keeper/keeper.go Updated imports for logging and store types to cosmossdk.io/log and cosmossdk.io/store/types.
modules/mt/keeper/mt.go Updated iterator usage from sdk.KVStorePrefixIterator to storetypes.KVStorePrefixIterator.
modules/mt/module.go Removed BeginBlock and EndBlock methods from AppModule, updated RegisterStoreDecoder method signature.
modules/mt/simulation/genesis.go Simplified RandomizedGenState function by removing simState.Cdc parameter from method calls.
modules/mt/simulation/operations.go Simplified function signatures by removing cdc parameter from WeightedOperations and simulation functions.
modules/nft/depinject.go Updated import for store and modified Inputs struct to replace Key with StoreService.
modules/nft/go.mod Updated Go version to 1.21, added toolchain go1.23.1, upgraded dependencies including cosmossdk.io/api, github.com/cosmos/cosmos-sdk, and added new dependencies.
modules/nft/keeper/denom.go Updated import path for nft package from github.com/cosmos/cosmos-sdk/x/nft to cosmossdk.io/x/nft.
modules/nft/keeper/depinject_test.go Removed imports for capabilitymodulev1 and capabilitytypes, added new imports for evidencetypes, feegrant, and upgradetypes.
modules/nft/keeper/grpc_query.go Updated import path for nft package from github.com/cosmos/cosmos-sdk/x/nft to cosmossdk.io/x/nft.
modules/nft/keeper/keeper.go Updated import paths for logging and store types to cosmossdk.io/log and cosmossdk.io/core/store.
modules/nft/keeper/nft.go Updated import path for nft package from github.com/cosmos/cosmos-sdk/x/nft to cosmossdk.io/x/nft.
modules/nft/migrations/v2/keeper.go Updated storeKey to storeService in keeper struct and its methods, changed codec type from codec.Codec to codec.BinaryCodec.
modules/nft/migrations/v2/store.go Updated store access methods to use storeService, changed iterator types, and updated codec type.
modules/nft/module.go Updated import paths for NFT package and changed RegisterStoreDecoder method signature.
modules/nft/simulation/operations.go Simplified function signatures by removing cdc parameter from WeightedOperations and simulation functions.
modules/nft/types/builder.go Updated import path for nft package from github.com/cosmos/cosmos-sdk/x/nft to cosmossdk.io/x/nft.
modules/nft/types/builder_test.go Updated import path for nft package from github.com/cosmos/cosmos-sdk/x/nft to cosmossdk.io/x/nft.
modules/nft/types/expected_keepers.go Updated context types in AccountKeeper and BankKeeper interfaces, added AddressCodec() method.
simapp/app_v2.go Removed capability module, updated InitChainer method signature, and modified NewSimApp function.
simapp/export.go Updated ExportAppStateAndValidators method signature and added error handling for various operations.
simapp/go.mod Updated Go version to 1.21, added toolchain go1.23.1, upgraded dependencies including cosmossdk.io/depinject, github.com/cometbft/cometbft, and github.com/cosmos/cosmos-sdk.
simapp/helpers/test_helpers.go Updated imports and modified GenTx function for better error handling and clarity.
simapp/network.go Changed ResponseTx struct type from abci.ResponseDeliverTx to abci.ExecTxResult.
simapp/state.go Updated zero integer representations to use sdkmath types.
simapp/test_helpers.go Updated method signatures to reflect changes in response types from abci.ResponseDeliverTx to abci.ExecTxResult.

Possibly related issues

  • irisnet/irismod#441: This PR addresses the upgrade of mods.irisnet.org/modules/nft to cosmos-sdk v0.50.10, which is part of the changes made in this PR.
  • irisnet/irismod#430: This PR also relates to the upgrade of mods.irisnet.org/modules/nft to cosmos-sdk v0.50.10, aligning with the updates in this PR.
  • irisnet/irismod#424: This issue discusses upgrading cosmos-sdk in irismod to v0.50.10, which is addressed by the changes in this PR.
  • irisnet/irismod#436: This issue pertains to upgrading mods.irisnet.org/api to cosmos-sdk v0.50.10, which is part of the broader updates in this PR.
  • irisnet/irismod#445: This issue discusses upgrading mods.irisnet.org/modules/token to cosmos-sdk v0.50.10, relevant to the changes in this PR.
  • irisnet/irismod#440: This issue relates to the upgrade of mods.irisnet.org/modules/mt to cosmos-sdk v0.50.10, consistent with this PR.
  • irisnet/irismod#442: This issue discusses upgrading mods.irisnet.org/modules/random to cosmos-sdk v0.50.10, relevant to the changes in this PR.
  • irisnet/irismod#446: This issue pertains to upgrading mods.irisnet.org/modules/service to cosmos-sdk v0.50.10, which aligns with this PR.
  • irisnet/irismod#438: This issue discusses upgrading mods.irisnet.org/modules/coinswap to cosmos-sdk v0.50.10, relevant to the changes in this PR.
  • irisnet/irismod#444: This issue discusses upgrading mods.irisnet.org/modules/record to cosmos-sdk v0.50.10, relevant to the changes in this PR.

Poem

In the meadow where bunnies hop,
Dependencies updated, we can't stop!
From old to new, we leap with glee,
Cosmos SDK, oh, how you shine for me!
With paths anew and versions bright,
Our code now dances in the moonlight! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 18

🧹 Outside diff range and nitpick comments (25)
modules/nft/keeper/migrations.go (1)

20-22: Consider adding migration tests.

Since this migration function handles critical data transformation between versions, it would be valuable to add comprehensive tests to ensure data integrity during the migration process.

Would you like me to help create a test suite for this migration function?

modules/nft/types/expected_keepers.go (1)

1-20: Consider adding migration guide

Given the significant interface changes in both AccountKeeper and BankKeeper, consider adding a migration guide to help users update their implementations.

Key points to cover:

  1. Context type changes from sdk.Context to context.Context
  2. New AddressCodec() method implementation
  3. Handling of removed BankKeeper methods
  4. Any necessary state migrations
modules/nft/keeper/keeper.go (1)

25-25: LGTM: Keeper initialization updated for store service pattern

The NewKeeper function has been properly updated to use the store service pattern. This change improves modularity by abstracting store access behind a service interface.

This architectural change to use store services provides several benefits:

  1. Better separation of concerns
  2. Easier mocking in tests
  3. More flexible store implementations
  4. Consistent with modern Cosmos SDK patterns

Also applies to: 30-32

modules/nft/depinject.go (1)

54-55: LGTM: Keeper initialization updated correctly

The change to use StoreService in the keeper initialization follows the new service-based pattern introduced in Cosmos SDK v0.50.x.

This change improves the module's architecture by:

  1. Reducing direct store key dependencies
  2. Making the store interaction more modular and testable
  3. Following the SDK's recommended service-oriented approach
simapp/network.go (1)

30-30: Consider documenting the SDK version compatibility.

This change is part of a significant upgrade to cosmos-sdk v0.50.10. Consider adding a comment or documentation note about the minimum SDK version requirement to help future maintainers.

Add a comment above the ResponseTx struct:

+// ResponseTx wraps the transaction execution result from cosmos-sdk v0.50.10+
 type ResponseTx struct {
     abci.ExecTxResult
     Height int64
 }
simapp/state.go (2)

177-179: Consider adding parameter validation.

The removal of the codec parameter is correct, but consider adding validation for the generated stake amount to ensure it's within acceptable bounds.

 appParams.GetOrGenerate(
 	StakePerAccount, &initialStake, r,
-	func(r *rand.Rand) { initialStake = sdkmath.NewInt(r.Int63n(1e12)) },
+	func(r *rand.Rand) {
+		// Ensure minimum viable stake
+		minStake := sdkmath.NewInt(1e6)
+		randomStake := sdkmath.NewInt(r.Int63n(1e12))
+		initialStake = sdkmath.MaxInt(minStake, randomStake)
+	},
 )

181-183: Consider adjusting the random range for better distribution.

While the removal of the codec parameter is correct, the current implementation uses a fixed upper bound of 300 for the random range. Consider making this configurable or relative to the total number of accounts.

 appParams.GetOrGenerate(
 	InitiallyBondedValidators, &numInitiallyBonded, r,
-	func(r *rand.Rand) { numInitiallyBonded = int64(r.Intn(300)) },
+	func(r *rand.Rand) {
+		// Use a percentage of total accounts, with a reasonable maximum
+		maxValidators := int64(300)
+		targetPercentage := 0.1 // 10% of total accounts
+		targetCount := int64(float64(numAccs) * targetPercentage)
+		numInitiallyBonded = int64(r.Int63n(sdkmath.MinInt(targetCount, maxValidators)))
+	},
 )
modules/nft/keeper/keeper_test.go (2)

Line range hint 36-96: Consider adding tests for new SDK v0.50.x features.

The test suite provides good coverage of core NFT operations. However, with the upgrade to cosmos-sdk v0.50.10, consider adding tests for:

  1. Service-based store interactions
  2. Any new NFT module features introduced in SDK v0.50.x

Line range hint 6-8: Update import paths to use cosmossdk.io.

As part of the SDK v0.50.x upgrade, the import paths should be updated from github.com/cosmos/cosmos-sdk/* to cosmossdk.io/*:

-	"github.com/cosmos/cosmos-sdk/baseapp"
-	"github.com/cosmos/cosmos-sdk/codec"
-	sdk "github.com/cosmos/cosmos-sdk/types"
+	"cosmossdk.io/baseapp"
+	"cosmossdk.io/codec"
+	sdk "cosmossdk.io/types"
modules/nft/types/builder.go (1)

Line range hint 18-32: Consider architectural improvements for better type safety and performance.

While the current implementation is functional, consider these improvements:

  1. Replace string-based metadata keys with strongly typed enums or constants to prevent typos
  2. Consider using a more structured approach for metadata handling to reduce type assertions
  3. Look into using protobuf for metadata to improve performance over JSON serialization

These changes would improve maintainability and reduce potential runtime errors.

modules/nft/simulation/operations.go (1)

Line range hint 572-573: Define constants for hardcoded denomination values

The function uses hardcoded values kitties and doggos. These should be defined as constants at the package level to improve maintainability and make the code more self-documenting.

Add these constants at the package level:

const (
    DenomKitties = "kitties"
    DenomDoggos  = "doggos"
)

Then update the usage:

-	denoms := []string{kitties, doggos}
+	denoms := []string{DenomKitties, DenomDoggos}
modules/mt/simulation/operations.go (1)

Line range hint 513-513: Consider adding range validation before uint64 conversion

The current implementation performs an unsafe conversion from int to uint64. While RandIntBetween ensures the value is within bounds, it's good practice to add explicit validation:

-amt = uint64(simtypes.RandIntBetween(r, 1, int(amt))) // unsafe conversion
+randAmt := simtypes.RandIntBetween(r, 1, int(amt))
+if randAmt < 0 {
+    return simtypes.NoOpMsg(
+        mt.ModuleName,
+        mt.EventTypeBurnMT,
+        "invalid random amount",
+    ), nil, nil
+}
+amt = uint64(randAmt)
simapp/helpers/test_helpers.go (1)

65-65: Consider passing context instead of using context.Background() directly

Using context.Background() bypasses the ability to control cancellation or timeouts within the function. It's a best practice to accept a context.Context parameter, allowing callers to provide a context that can manage deadlines and cancellation.

You can modify the GenTx function to accept a context parameter:

func GenTx(ctx context.Context, r *rand.Rand, gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) {
    // existing code
    signBytes, err := authsigning.GetSignBytesAdapter(ctx, gen.SignModeHandler(), defaultSignMode, signerData, tx.GetTx())
    // existing code
}

Then, update the calls to GenTx to pass the appropriate context.

modules/nft/migrations/v2/keeper.go (1)

62-62: Refactor repeated store opening code into a helper method

The code snippet store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) is used multiple times across different methods. Consider creating a helper method to reduce code duplication and enhance maintainability.

Apply this refactor to add a helper method:

+func (k keeper) getStore(ctx sdk.Context) sdk.KVStore {
+    return runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
+}

Then update the methods to use the helper function:

 func (k keeper) setOwner(ctx sdk.Context, classID, nftID string, owner sdk.AccAddress) {
-    store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
+    store := k.getStore(ctx)
     store.Set(ownerStoreKey(classID, nftID), owner.Bytes())
     // ...
 }

 func (k keeper) GetTotalSupply(ctx sdk.Context, classID string) uint64 {
-    store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
+    store := k.getStore(ctx)
     bz := store.Get(classTotalSupply(classID))
     return sdk.BigEndianToUint64(bz)
 }

 // Repeat similar changes for `updateTotalSupply`, `getClassStoreByOwner`, and `getNFTStore`

Also applies to: 76-76, 82-82, 88-88, 94-94

simapp/export.go (1)

81-82: Standardize error handling: inconsistent use of panic and log.Fatal

The code uses both panic(err) and log.Fatal(err) for error handling at various points. It's advisable to standardize on a single method of error handling to ensure consistent behavior.

Also applies to: 87-88, 93-94, 130-131, 174-175, 189-190, 242-243

modules/mt/go.mod (1)

Line range hint 159-164: Review replace directives and address TODO comments

The replace section contains several TODO comments indicating that these replacements are temporary:

Consider resolving these TODO items by updating dependencies or removing unnecessary replace directives. Continuing to use these replacements may hide underlying issues or prevent the project from benefiting from official updates.

Would you like assistance in evaluating these dependencies or creating issues to track their resolution?

simapp/go.mod (3)

36-38: Update DataDog dependencies to the latest versions

The github.com/DataDog/datadog-go and github.com/DataDog/zstd packages are included. Verify if these are required for the simapp module and consider updating to the latest versions if they are not already.


73-76: Confirm necessity of logging and monitoring libraries

Packages like github.com/fatih/color, github.com/felixge/httpsnoop, github.com/fsnotify/fsnotify, and github.com/getsentry/sentry-go are added indirectly. Ensure that these are essential for your application to avoid unnecessary bloat.


Line range hint 199-207: Re-evaluate replace directives for dependency management

The replace directives modify several dependencies, such as replacing github.com/99designs/keyring with github.com/cosmos/keyring and downgrading github.com/syndtr/goleveldb. Review whether these replacements are still necessary with the updated dependencies, and consider removing or updating them if possible.

simapp/app_v2.go (1)

249-252: Review error handling in RegisterStreamingServices

When RegisterStreamingServices fails, the application logs the error and exits. Consider handling the error more gracefully or confirming that exiting is the intended behavior in this scenario.

simapp/test_helpers.go (1)

Line range hint 737-758: Address commented-out code in query functions.

Several lines in QueryBalancesExec, QueryBalanceExec, and QueryAccountExec are commented out. If these functions are obsolete due to SDK changes, consider removing them to keep the codebase clean. If they need updating, it's advisable to adjust them to work with the new SDK.

Also applies to: 770-783

modules/nft/migrations/v2/store.go (4)

6-10: Update imports to align with the latest Cosmos SDK modules

The imports from github.com/cosmos/cosmos-sdk for codec and runtime might be outdated with the recent SDK updates. Consider importing cosmossdk.io/codec and cosmossdk.io/core/runtime to align with the latest module paths.

Apply this diff to update the imports:

- "github.com/cosmos/cosmos-sdk/codec"
- "github.com/cosmos/cosmos-sdk/runtime"
+ "cosmossdk.io/codec"
+ "cosmossdk.io/core/runtime"

26-28: Simplify store initialization by removing unnecessary adapter

Since storeService.OpenKVStore(ctx) returns a store.KVStore, wrapping it with runtime.KVStoreAdapter is unnecessary. You can directly use the returned KVStore.

Apply this diff to simplify the store initialization:

- store := runtime.KVStoreAdapter(storeService.OpenKVStore(ctx))
+ store := storeService.OpenKVStore(ctx)

Line range hint 42-42: Handle potential unmarshal errors instead of panicking

Using cdc.MustUnmarshal can cause the application to panic if unmarshalling fails. It is safer to use cdc.Unmarshal and handle the error to prevent unexpected crashes.

Apply this diff to handle unmarshal errors:

- cdc.MustUnmarshal(iterator.Value(), &denom)
+ if err := cdc.Unmarshal(iterator.Value(), &denom); err != nil {
+     return err
+ }

98-98: Simplify store initialization by removing unnecessary adapter

Just like in the Migrate function, you can remove runtime.KVStoreAdapter when opening the store in migrateToken.

Apply this diff to simplify the store initialization:

- store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
+ store := k.storeService.OpenKVStore(ctx)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ef0885f and e0472dd.

⛔ Files ignored due to path filters (4)
  • e2e/go.sum is excluded by !**/*.sum
  • modules/mt/go.sum is excluded by !**/*.sum
  • modules/nft/go.sum is excluded by !**/*.sum
  • simapp/go.sum is excluded by !**/*.sum
📒 Files selected for processing (35)
  • e2e/go.mod (5 hunks)
  • modules/mt/depinject.go (1 hunks)
  • modules/mt/go.mod (1 hunks)
  • modules/mt/handler.go (1 hunks)
  • modules/mt/keeper/balance.go (2 hunks)
  • modules/mt/keeper/denom.go (2 hunks)
  • modules/mt/keeper/grpc_query.go (1 hunks)
  • modules/mt/keeper/keeper.go (1 hunks)
  • modules/mt/keeper/mt.go (2 hunks)
  • modules/mt/module.go (1 hunks)
  • modules/mt/simulation/genesis.go (1 hunks)
  • modules/mt/simulation/operations.go (7 hunks)
  • modules/nft/depinject.go (3 hunks)
  • modules/nft/go.mod (2 hunks)
  • modules/nft/keeper/denom.go (1 hunks)
  • modules/nft/keeper/depinject_test.go (2 hunks)
  • modules/nft/keeper/grpc_query.go (1 hunks)
  • modules/nft/keeper/keeper.go (1 hunks)
  • modules/nft/keeper/keeper_test.go (1 hunks)
  • modules/nft/keeper/migrations.go (1 hunks)
  • modules/nft/keeper/nft.go (1 hunks)
  • modules/nft/migrations/v2/keeper.go (3 hunks)
  • modules/nft/migrations/v2/store.go (2 hunks)
  • modules/nft/module.go (2 hunks)
  • modules/nft/simulation/operations.go (7 hunks)
  • modules/nft/types/builder.go (1 hunks)
  • modules/nft/types/builder_test.go (1 hunks)
  • modules/nft/types/expected_keepers.go (1 hunks)
  • simapp/app_v2.go (5 hunks)
  • simapp/export.go (6 hunks)
  • simapp/go.mod (1 hunks)
  • simapp/helpers/test_helpers.go (3 hunks)
  • simapp/network.go (1 hunks)
  • simapp/state.go (2 hunks)
  • simapp/test_helpers.go (19 hunks)
✅ Files skipped from review due to trivial changes (4)
  • modules/mt/depinject.go
  • modules/mt/keeper/grpc_query.go
  • modules/mt/keeper/keeper.go
  • modules/nft/keeper/nft.go
🔇 Additional comments (62)
modules/nft/types/expected_keepers.go (2)

4-6: LGTM: Import changes align with Cosmos SDK v0.50.x standards

The addition of standard context package and cosmossdk.io/core/address is consistent with the SDK upgrade.


19-19: ⚠️ Potential issue

Verify BankKeeper interface reduction impact

The BankKeeper interface has been significantly simplified, retaining only SpendableCoins with updated context type. This is a breaking change that removes GetAllBalances, GetBalance, and LockedCoins methods.

Please ensure:

  1. All callers are updated to handle the removed methods
  2. The SpendableCoins method now uses context.Context
✅ Verification successful

The previous search revealed multiple usages of removed methods across modules, but we need to specifically focus on the NFT module since the change is in modules/nft/types/expected_keepers.go. Let's verify the actual usage of BankKeeper methods within the NFT module to determine the impact.


BankKeeper interface change is correctly implemented

The verification shows that:

  1. The NFT module's BankKeeper interface only declares SpendableCoins method
  2. All usages in simulation/operations.go are consistent with the interface, only using SpendableCoins
  3. The removed methods (GetAllBalances, GetBalance, LockedCoins) are not used in the NFT module

The interface reduction is safe and properly implemented within the NFT module's scope.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any existing usage of removed methods
rg "GetAllBalances|GetBalance|LockedCoins" --type go

Length of output: 12876


Script:

#!/bin/bash
# Check for BankKeeper interface definitions and usages in nft module
rg -A 5 "type BankKeeper interface" modules/nft/

# Check for SpendableCoins usage in nft module
rg "SpendableCoins" modules/nft/

Length of output: 976

modules/nft/keeper/keeper.go (1)

6-9: LGTM: Import paths updated to new SDK convention

The import paths have been correctly updated to use the new cosmossdk.io namespace, which is consistent with the SDK v0.50.10 standards.

modules/nft/depinject.go (1)

5-5: LGTM: Import path updated correctly for Cosmos SDK v0.50.10

The migration from github.com/cosmos/cosmos-sdk/store/types to cosmossdk.io/core/store aligns with the SDK upgrade objective.

modules/mt/handler.go (2)

Line range hint 3-10: LGTM: Import paths are correctly updated

The migration to cosmossdk.io/errors aligns with the Cosmos SDK v0.50.x modularization efforts.


Line range hint 16-45: LGTM: Message handling follows SDK best practices

The implementation correctly:

  • Initializes event manager for each message
  • Uses consistent service result wrapping
  • Maintains proper error handling across all message types
modules/mt/keeper/denom.go (1)

8-8: LGTM: Import path updated to new cosmos-sdk structure

The change from cosmos-sdk store types to cosmossdk.io path aligns with the SDK v0.50.x migration pattern.

modules/mt/keeper/mt.go (1)

8-8: LGTM: Import update aligns with Cosmos SDK v0.50.x standards

The migration to cosmossdk.io/store/types is consistent with the PR's objective of upgrading to cosmos-sdk v0.50.10.

modules/nft/keeper/denom.go (2)

5-5: Verify NFT package import changes across the codebase.

The import change from github.com/cosmos/cosmos-sdk/x/nft to cosmossdk.io/x/nft is part of the SDK's architectural changes in v0.50.x.

Let's verify that all NFT-related imports have been updated consistently:

✅ Verification successful

All NFT package imports have been consistently updated to use the new path

The verification shows that all NFT-related imports in the codebase have been properly updated to use the new cosmossdk.io/x/nft path. No instances of the old import path github.com/cosmos/cosmos-sdk/x/nft were found, confirming that the migration was done consistently across all files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining old NFT package imports that need updating

# Search for old import path
echo "Checking for old import paths that need updating..."
rg "github.com/cosmos/cosmos-sdk/x/nft" --type go

# Search for new import path to confirm changes
echo "Verifying new import paths..."
rg "cosmossdk.io/x/nft" --type go

Length of output: 898


Line range hint 14-156: Implementation looks good, verify integration tests.

The methods correctly use the new nft.Class type from cosmossdk.io while maintaining the same functionality. The error handling is comprehensive, and the code structure remains clean.

Let's verify the existence of integration tests for these methods:

✅ Verification successful

Based on the test output, I can now generate the final response:

NFT denomination operations are well-tested with comprehensive coverage

The codebase includes thorough test coverage for the NFT denomination operations:

  • TestTransferDenom verifies ownership transfer functionality including authorization checks
  • TestDenom and TestDenoms cover GRPC query operations
  • Integration tests in keeper_test.go verify SaveDenom operations through multiple test scenarios
  • The test suite includes proper validation of denom metadata, restrictions, and error cases
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for integration tests covering these NFT denomination operations

echo "Searching for related test files..."
fd -e go -e _test.go

echo "Checking test coverage for denomination operations..."
rg -A 5 "TestSaveDenom|TestTransferDenomOwner|TestGetDenomInfo" --type go

Length of output: 19631


Script:

#!/bin/bash
# Let's try a different approach to find the tests

# Search for test files in the nft module directory
echo "Searching for test files in the NFT module..."
fd ".*_test.go" modules/nft/

# Search for test cases related to denom operations with broader context
echo "Searching for denom-related test cases..."
rg -B 2 -A 5 "denom" modules/nft/keeper/*_test.go

# Search for specific test function patterns
echo "Searching for specific test patterns..."
rg -B 2 -A 5 "func.*Test.*Denom" modules/nft/keeper/*_test.go

Length of output: 31049

modules/nft/keeper/grpc_query.go (3)

Line range hint 15-191: LGTM! Functionality preserved after dependency update.

The gRPC query handlers maintain their original behavior while using the new NFT package. Key aspects verified:

  • Error handling remains intact
  • Response structures are unchanged
  • Keeper interactions are consistent

Line range hint 4-13: Confirmed compatibility with Cosmos SDK v0.50.10.

The implementation follows the latest SDK patterns and best practices:

  • Uses cosmossdk.io/errors for error handling
  • Follows the modular import structure
  • No deprecated methods or types detected

7-7: Verify NFT package usage after import path change.

The import path change from github.com/cosmos/cosmos-sdk/x/nft to cosmossdk.io/x/nft is aligned with Cosmos SDK v0.50.x's modularization. This is a breaking change that requires careful verification.

Let's verify that all NFT package imports are consistently updated:

✅ Verification successful

Import path migration to cosmossdk.io/x/nft is complete and consistent

The verification shows that all NFT package imports have been successfully migrated to the new path cosmossdk.io/x/nft. No instances of the old import path github.com/cosmos/cosmos-sdk/x/nft were found in the codebase, confirming a complete and consistent migration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining old NFT package imports that need updating

# Test 1: Search for old import paths
echo "Checking for old NFT package imports..."
rg "github.com/cosmos/cosmos-sdk/x/nft"

# Test 2: Verify new import paths are used consistently
echo "Verifying new NFT package imports..."
rg "cosmossdk.io/x/nft"

Length of output: 1107

modules/mt/keeper/balance.go (1)

8-8: LGTM: Import path update aligns with Cosmos SDK v0.50.x changes

The change from github.com/cosmos/cosmos-sdk/store/types to cosmossdk.io/store/types is correct and follows the SDK's modularization efforts in v0.50.x.

simapp/network.go (1)

30-30: LGTM! Verify cosmos-sdk compatibility.

The update from ResponseDeliverTx to ExecTxResult aligns with the cosmos-sdk v0.50.10 upgrade. The structure maintains compatibility while adopting the new type.

Let's verify other potential usages of ResponseDeliverTx in the codebase that might need similar updates:

✅ Verification successful

Let me check the test_helpers.go file to ensure the changes are consistent:


Based on the analysis of both files, I can now generate the final response:

The change from ResponseDeliverTx to ExecTxResult is correctly implemented and consistent

The codebase shows consistent usage of abci.ExecTxResult in both network.go and test_helpers.go. The change aligns with cosmos-sdk v0.50.10 and all related functions (QueryTx, QueryTxWithHeight) are properly updated to use the new type. No remaining instances of ResponseDeliverTx were found in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining ResponseDeliverTx usages that might need updates
rg "ResponseDeliverTx" --type go

# Search for ExecTxResult usage to ensure consistent adoption
rg "ExecTxResult" --type go

Length of output: 262


Script:

#!/bin/bash
# Check the content of test_helpers.go to verify the implementation
cat simapp/test_helpers.go

Length of output: 24508

modules/mt/module.go (2)

161-161: LGTM: Parameter type update aligns with cosmos-sdk v0.50.x

The change from sdk.StoreDecoderRegistry to simtypes.StoreDecoderRegistry is correct and consistent with cosmos-sdk v0.50.x changes.


Line range hint 1-170: Verify cosmos-sdk v0.50.10 compatibility requirements

The file might be missing some required changes for full compatibility with cosmos-sdk v0.50.10. Let's verify:

Consider the following cosmos-sdk v0.50.x compatibility checklist:

  1. Ensure all store imports use cosmossdk.io/store/types instead of github.com/cosmos/cosmos-sdk/store/types
  2. Verify that BeginBlock/EndBlock methods are removed if they don't contain any logic
  3. Check if any new required interfaces or methods need to be implemented
  4. Update any deprecated method calls or types
✅ Verification successful

Let me gather more specific information about the MT module's compatibility with cosmos-sdk v0.50.x.


Based on the verification results, I can now provide a final response:

The MT module appears to be compatible with cosmos-sdk v0.50.10

The verification shows:

  • Using correct import path cosmossdk.io/store/types instead of deprecated github.com/cosmos/cosmos-sdk/store/types
  • No BeginBlock/EndBlock methods present (correctly removed)
  • Proper implementation of AppModule interfaces
  • Using up-to-date store and keeper patterns
  • Correctly using the new BaseApp patterns in simulation code

The TODOs in go.mod are related to general cosmos-sdk issues and not specific to v0.50.x compatibility requirements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential missing changes required for cosmos-sdk v0.50.x compatibility

# Test 1: Check if BeginBlock and EndBlock methods were actually removed
echo "Checking for BeginBlock/EndBlock methods..."
rg -A 5 "func.*BeginBlock|func.*EndBlock" modules/mt/

# Test 2: Check if we're using the new cosmossdk.io import paths consistently
echo "Checking for old cosmos-sdk store import paths..."
rg "github.com/cosmos/cosmos-sdk/store"

# Test 3: Check module interface implementation
echo "Checking AppModule interface implementation..."
rg "module\.AppModule\s*=\s*AppModule{}" modules/mt/

# Test 4: Check for any TODO/FIXME comments related to SDK updates
echo "Checking for upgrade-related TODOs..."
rg -i "todo.*sdk|fixme.*sdk" modules/mt/

Length of output: 2860


Script:

#!/bin/bash
# Check MT module's imports and dependencies

# Check go.mod for cosmos-sdk version
echo "Checking cosmos-sdk version..."
cat modules/mt/go.mod | grep "cosmos-sdk"

# Check for store-related imports in MT module
echo -e "\nChecking store imports in MT module..."
rg "store|Store" modules/mt/keeper/

# Check for any deprecated types or interfaces
echo -e "\nChecking for potential deprecated types..."
rg "types\." modules/mt/module.go

# Check for BaseApp dependencies
echo -e "\nChecking BaseApp related code..."
rg "BaseApp" modules/mt/

Length of output: 7446

modules/nft/module.go (3)

Line range hint 119-127: LGTM! Service registration is properly updated.

The addition of sdknfttypes.RegisterQueryServer ensures proper integration with the new SDK's NFT module while maintaining backward compatibility through migration support.


165-167: LGTM! Verify simulation functionality.

The store decoder registration has been properly updated to use simtypes.StoreDecoderRegistry and sdknftsim.NewDecodeStore, aligning with the new SDK structure.

✅ Verification successful

Based on the search results, I can see that the simulation code is consistently using the new types and packages:

  1. The store decoder registration correctly uses simtypes.StoreDecoderRegistry and sdknftsim.NewDecodeStore
  2. All simulation operations (mint, burn, transfer etc.) use the new simtypes package for simulation-related types
  3. The genesis simulation also uses the new types consistently

Store decoder and simulation code properly updated

The store decoder registration and all simulation code has been properly updated to use the new SDK simulation types and packages. No inconsistencies found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any simulation-related changes that might need updating
# Test: Search for simulation-related code. Expect: Consistent usage of new types
rg -A 3 "simulation|simtypes|SimulationState" modules/nft/

Length of output: 23131


8-9: LGTM! Verify all NFT-related imports in the codebase.

The import path changes align with Cosmos SDK v0.50.x's modularization efforts. However, we should ensure all NFT-related imports are consistently updated.

✅ Verification successful

This script will help us:

  1. Find all Go files that might contain NFT-related code
  2. Check for any NFT-related import statements
  3. Look for NFT type usages to ensure we haven't missed any imports

This will help us:

  1. Specifically look for any remaining old-style imports
  2. Check all NFT-related import statements
  3. Verify the new import path usage

NFT imports have been successfully updated across the codebase

The verification shows that:

  1. No instances of old-style imports (github.com/cosmos/cosmos-sdk/x/nft) remain
  2. All NFT-related imports consistently use the new path cosmossdk.io/x/nft
  3. The imports are properly aliased and organized across all relevant files
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining old-style NFT imports that need updating
# Test: Search for old import paths. Expect: No matches
rg "github.com/cosmos/cosmos-sdk/x/nft"

Length of output: 39


Script:

#!/bin/bash
# Let's do a comprehensive check for NFT-related imports
# First, find all Go files
echo "=== Checking all NFT-related imports ==="
rg -l "nft" --type go

echo -e "\n=== Checking specific import patterns ==="
# Check for any NFT-related imports
rg "^import.*nft" --type go

echo -e "\n=== Checking specific NFT type usages ==="
# Look for NFT type usages to ensure we haven't missed any imports
rg "nft\." --type go

Length of output: 128439


Script:

#!/bin/bash
# Let's check for any remaining old-style imports in Go files
echo "=== Checking for old-style NFT imports ==="
rg "\"github.com/cosmos/cosmos-sdk/x/nft\"" --type go

echo -e "\n=== Checking all NFT-related imports ==="
rg "^import.*nft" --type go

echo -e "\n=== Checking specific import statements ==="
rg "cosmossdk.io/x/nft" --type go

Length of output: 1045

modules/nft/keeper/keeper_test.go (1)

77-77: Verify test coverage after context simplification.

The simplified context creation aligns with cosmos-sdk v0.50.x changes, moving away from explicit Tendermint header usage. While this change is correct, we should ensure test coverage remains comprehensive.

Let's verify if any tests depend on block header information:

✅ Verification successful

This will help us understand how the context is used in tests and if there are any dependencies on block header information.


After analyzing the test files, I can now provide a final response:

Context simplification is safe to proceed

The test suite's usage of suite.ctx is focused on basic NFT operations like saving, querying, and managing collections. None of the tests rely on block header information or time-based assertions. The context is only used for:

  • Basic CRUD operations on NFTs and collections
  • Supply calculations and balance checks
  • Owner authorization checks
  • GRPC query handling
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any block header or time-related assertions in the test files
rg -A 3 'Header|BlockTime|Time|Height' modules/nft/keeper/

Length of output: 60


Script:

#!/bin/bash
# Let's try a broader search for test assertions and time/header related usage
rg -l "suite.ctx" modules/nft/keeper/

# Then let's examine the content of these files
rg -A 5 "suite.ctx" modules/nft/keeper/

Length of output: 20510

modules/nft/keeper/depinject_test.go (2)

27-30: LGTM: Import changes align with cosmos-sdk v0.50.10 migration

The new imports from cosmossdk.io/x follow the updated import path structure in cosmos-sdk v0.50.10.


Line range hint 61-65: Verify module initialization dependencies

The module order looks correct and maintains critical dependencies. However, let's verify there are no missing module dependencies in the codebase.

✅ Verification successful

Let me analyze the output from the shell scripts. The search results show several key patterns:

  1. The BeginBlockers order across test files consistently shows:

    • upgrade module first
    • mint module early
    • distribution module after mint
  2. The EndBlockers order consistently shows:

    • crisis module first
    • gov module before staking
    • staking module last
  3. The InitGenesis order in the code under review maintains these critical dependencies:

    • auth before genutils (for params access)
    • staking before genutils (for token initialization)
    • distribution after mint
    • slashing after distribution

Based on this analysis, I can generate the final response:

Module initialization order verified

The module order in the genesis initialization sequence is correct and maintains all critical dependencies:

  • Auth and staking modules are initialized before genutils as required
  • Distribution module follows mint module for proper token handling
  • Slashing occurs after distribution to maintain fee pool invariants
  • The removal of capability module and addition of new modules (feegrant, evidence, upgrade) do not break any initialization dependencies
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any module dependencies that might require specific initialization order

# Search for InitGenesis calls to verify module dependencies
rg -A 3 "InitGenesis|BeginBlock|EndBlock" --type go

# Search for explicit module dependencies
rg -B 2 -A 2 "RequireRegistered|DependsOn|dependentModules" --type go

Length of output: 32275

modules/nft/types/builder_test.go (2)

Line range hint 15-308: LGTM! Test implementations remain robust and comprehensive.

The test cases continue to provide good coverage for NFT metadata handling, including:

  • Token building with various metadata scenarios
  • Class metadata building with different input cases
  • Proper handling of IBC assets
  • Edge cases and error conditions

The tests remain compatible with the updated NFT module import and don't require modifications.


7-7: LGTM! Import path update aligns with Cosmos SDK v0.50.10.

The change from github.com/cosmos/cosmos-sdk/x/nft to cosmossdk.io/x/nft is correct and follows Cosmos SDK's modularization efforts.

Let's verify consistent usage of the new import path across the codebase:

✅ Verification successful

Import path update is consistent across the codebase

The verification shows that:

  • No instances of the old import path github.com/cosmos/cosmos-sdk/x/nft remain in the codebase
  • The new import path cosmossdk.io/x/nft is consistently used across all relevant files in the NFT module
  • The module's dependencies are properly updated in go.mod with cosmossdk.io/x/nft v0.1.1
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining old import paths and verify consistent usage of new path

# Test 1: Check for any remaining old import paths
echo "Checking for old import paths..."
rg "github.com/cosmos/cosmos-sdk/x/nft"

# Test 2: Verify consistent usage of new import path
echo "Verifying new import path usage..."
rg "cosmossdk.io/x/nft"

Length of output: 1089

modules/nft/types/builder.go (3)

Line range hint 69-106: LGTM! ClassBuilder methods are compatible with SDK v0.50.10.

The ClassBuilder implementation correctly handles the nft types from the new package while maintaining the existing functionality:

  • Proper error handling for metadata unpacking
  • Correct usage of nft.Class type
  • Preserved metadata processing logic

Also applies to: 108-259


Line range hint 261-275: LGTM! TokenBuilder methods are compatible with SDK v0.50.10.

The TokenBuilder implementation correctly handles the nft types from the new package while maintaining the existing functionality:

  • Proper error handling for metadata unpacking
  • Correct usage of nft.NFT type
  • Preserved metadata processing logic

Also applies to: 277-386


10-10: LGTM! Import path change aligns with Cosmos SDK v0.50.x standards.

The change from github.com/cosmos/cosmos-sdk/x/nft to cosmossdk.io/x/nft is correct and follows the SDK's modularization efforts where x/ modules are being moved to cosmossdk.io domain.

Let's verify this is the standard import path in SDK v0.50.10:

✅ Verification successful

Import path change to cosmossdk.io/x/nft is correctly implemented

The verification confirms:

  • The new import path cosmossdk.io/x/nft v0.1.1 is properly declared in modules/nft/go.mod
  • No remaining references to the old import path github.com/cosmos/cosmos-sdk/x/nft were found in the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the NFT module import path in cosmos-sdk v0.50.10
# Expected: References to cosmossdk.io/x/nft in go.mod and imports

# Check go.mod for the correct dependency
rg "cosmossdk.io/x/nft" -g "go.mod"

# Check if any old import paths remain
rg "github.com/cosmos/cosmos-sdk/x/nft" -l

Length of output: 122

e2e/go.mod (2)

Line range hint 32-212: Security and performance improvements noted

The dependency updates include several security and performance improvements:

  • Updated crypto packages
  • Updated protobuf packages
  • Updated monitoring and metrics packages

These updates enhance the security and observability of the system.


3-5: Review toolchain version compatibility

The toolchain version (go1.23.1) is newer than the Go version (1.21) specified. This might lead to compatibility issues. Consider aligning the toolchain version with the Go version being used.

✅ Verification successful

This script will help us verify if there's consistency in Go versions and toolchain specifications across all modules in the repository, which is crucial for determining if the version mismatch in e2e/go.mod is a real concern.


Go version and toolchain configuration is consistent with related modules

The Go version (1.21) and toolchain (go1.23.1) in e2e/go.mod aligns with other recently updated modules in the repository:

  • simapp/go.mod
  • modules/nft/go.mod
  • modules/mt/go.mod

This appears to be part of a coordinated upgrade pattern where modules being updated to cosmos-sdk v0.50.10 are also receiving the Go 1.21 and toolchain updates. The version combination is intentional and matches across related modules.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if other modules in the repository use consistent Go and toolchain versions
fd -e mod -x grep -l "^go 1\." {} \; | while read -r file; do
    echo "=== $file ==="
    grep "^go 1\." "$file"
    grep "^toolchain" "$file" || echo "No toolchain specified"
done

Length of output: 623


Script:

#!/bin/bash
# Let's check the Go version and toolchain specifications in all go.mod files
for mod in $(fd -e mod); do
    echo "=== $mod ==="
    echo "Go version:"
    grep "^go " "$mod" || echo "No Go version specified"
    echo "Toolchain:"
    grep "^toolchain " "$mod" || echo "No toolchain specified"
    echo
done

Length of output: 3703

modules/nft/simulation/operations.go (2)

46-83: LGTM: Parameter generation changes align with Cosmos SDK v0.50.x

The removal of the cdc parameter from appParams.GetOrGenerate calls is consistent with Cosmos SDK v0.50.x changes where codec is no longer needed for basic parameter generation. The operation weights remain appropriately balanced.


195-195: LGTM: Return statement changes align with Cosmos SDK v0.50.x

The removal of the empty string parameter from simtypes.NewOperationMsg calls across all simulation functions is consistent with Cosmos SDK v0.50.x changes. This modification doesn't affect functionality as the parameter was not being utilized.

Also applies to: 266-266, 332-332, 395-395, 483-483, 560-560

modules/mt/simulation/operations.go (2)

39-39: LGTM: Consistent removal of unused codec parameter

The removal of the cdc parameter from GetOrGenerate calls is consistent with the upgrade to cosmos-sdk v0.50.10 and doesn't affect the weight generation functionality.

Also applies to: 46-46, 53-53, 60-60, 67-67, 73-73


173-173: LGTM: Simplified return statements

The return statements have been consistently simplified across all simulation functions by removing redundant nil arguments, which improves code clarity.

Also applies to: 268-268, 356-356, 461-461, 545-545, 635-635

simapp/helpers/test_helpers.go (2)

27-30: Proper error handling added for default sign mode retrieval

Including error handling when retrieving the default sign mode enhances the robustness of the GenTx function by ensuring that any potential errors are appropriately managed.


38-38: Consistent use of default sign mode in signatures

Setting SignMode to defaultSignMode ensures that all signatures use the correct signing mode derived from the configuration.

modules/nft/migrations/v2/keeper.go (3)

7-13: Update imports to align with new Cosmos SDK structure

The import paths have been updated to reflect the new module paths introduced in Cosmos SDK v0.50.10. This ensures compatibility with the latest SDK changes.


21-22: Update keeper struct to use storeService and codec.BinaryCodec

The keeper struct now utilizes store.KVStoreService instead of storetypes.StoreKey, and codec.BinaryCodec instead of codec.Codec. This aligns the keeper with the updated store management and codec interfaces in the new Cosmos SDK version.


62-62: Ensure error handling for OpenKVStore(ctx) if necessary

Verify whether k.storeService.OpenKVStore(ctx) returns an error. If it does, proper error handling should be implemented to prevent potential runtime issues.

Run the following script to check the signature of OpenKVStore:

Also applies to: 76-76, 82-82, 88-88, 94-94

simapp/export.go (2)

31-34: Good practice: Added error handling for ExportGenesisForModules

Properly handling the error returned by app.ModuleManager.ExportGenesisForModules strengthens the robustness of the application.


221-224: Ensure proper error handling when closing iterators

An error is logged when closing the iterator, and the function returns without notifying the caller. Verify that this early return does not skip necessary cleanup. Consider returning an error to inform the caller.

modules/mt/go.mod (3)

3-3: Verify compatibility with Go 1.21

Updating the Go version to 1.21 may introduce breaking changes or deprecations. Please ensure that the codebase is fully compatible with Go 1.21, and that all tests pass successfully.


5-5: Confirm the necessity of specifying toolchain go1.23.1

The toolchain directive specifies Go version 1.23.1, which is newer than the declared Go version go 1.21. Please confirm that this is intentional and verify that the project requires features from Go 1.23.1. Also, consider aligning the go and toolchain versions to avoid potential inconsistencies.


8-24: Ensure compatibility with updated dependencies

Multiple dependencies have been updated to newer versions, including:

  • cosmossdk.io/core updated to v0.11.1
  • github.com/cosmos/cosmos-sdk updated to v0.50.10
  • Other related modules updated accordingly

Upgrading to cosmos-sdk v0.50.10 is a significant change that may introduce breaking changes or require code modifications due to API changes. Please verify that the module is compatible with these updated dependencies and that any necessary code changes have been made to accommodate API updates or deprecations.

simapp/go.mod (3)

3-5: Verify Go version updates and toolchain compatibility

The Go version has been updated to 1.21, and the toolchain is set to go1.23.1. Ensure that your build environment supports these versions, and that all team members have updated their local Go installations accordingly to prevent any compatibility issues.


8-21: Dependencies aligned with cosmos-sdk v0.50.10

The core dependencies have been updated to match cosmos-sdk v0.50.10, including cosmossdk.io/depinject and github.com/cosmos/cosmos-sdk. This update is crucial for compatibility with the new SDK version.


25-194: Review indirect dependencies for necessity and security

A significant number of indirect dependencies have been added or updated. While some are required due to the upgraded cosmos-sdk, it's important to review these dependencies to ensure they are necessary and do not introduce security vulnerabilities or licensing issues.

modules/nft/go.mod (1)

3-5: Verify compatibility with Go 1.21 and toolchain go1.23.1

The go directive has been updated to version 1.21, and the toolchain directive is set to go1.23.1. Please ensure that the codebase and all dependencies are compatible with these versions, and that no breaking changes are introduced.

simapp/app_v2.go (5)

10-17: Module imports updated appropriately

The new modules (log, storetypes, evidence, feegrant, upgrade) have been imported correctly to reflect the updates in dependencies and module structure.


246-246: Updated Build method call reflects changes in logging configuration

The Build method now excludes the logger parameter, suggesting that logging is handled differently in the updated appBuilder. Ensure that logging is properly configured elsewhere to prevent loss of logging functionality.


301-301: Ensure InitChainer signature update is consistently applied

The InitChainer function signature has been changed to accept a pointer to abci.RequestInitChain and return a pointer to abci.ResponseInitChain along with an error. Verify that all overrides and calls to InitChainer in the codebase are updated accordingly, and that error handling is implemented where necessary.

Run the following script to identify any outdated InitChainer signatures:

#!/bin/bash
# Description: Search for `InitChainer` methods with the old signature.
# Expectation: No methods with the old signature should be found.

# Search for `InitChainer` method definitions with the old signature.
ast-grep --pattern 'func ($_ *$_) InitChainer(ctx $_, req abci.RequestInitChain) abci.ResponseInitChain { $$$ }'

77-77: Confirm removal of the capability module

The capability.AppModuleBasic{} has been commented out from ModuleBasics. Verify that this module is no longer required and that its removal does not affect other modules that might depend on it.

Run the following script to check for any remaining references to the capability module:

#!/bin/bash
# Description: Search for any references to the `capability` module.
# Expectation: No references to `capability` should be found.

# Search for imports or usages of the `capability` module.
rg 'capability(AppModuleBasic|keeper|types)?'

19-19: Verify the new dbm import path

The import path for dbm has been updated to "github.com/cosmos/cosmos-db". Ensure that this change is compatible with the rest of the codebase and that all references to dbm are consistent with this new import.

Run the following script to check for any outdated dbm imports:

✅ Verification successful

This script will help us:

  1. Find all dbm import statements in the codebase
  2. Check for any direct usage of either cosmos-db or tm-db packages
    This will give us a complete picture of database package usage across the codebase.

Import path for dbm is consistent across the codebase

The verification shows that all direct imports of the database package consistently use github.com/cosmos/cosmos-db. The package is properly referenced in the relevant go.mod files and there are no instances of the old tm-db package being used.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for outdated `dbm` import paths in the codebase.
# Expectation: No occurrences of the old `dbm` import path should be found.

# Search for the old `dbm` import path.
rg 'github\.com/.*\/tm-db'

Length of output: 7985


Script:

#!/bin/bash
# Let's search for all dbm imports in the codebase to verify consistency
rg '^[[:space:]]*(?:import[[:space:]]+)?(?:\([[:space:]]*\n)?[[:space:]]*dbm[[:space:]]+"[^"]+"' -A 1

# Also search for any direct usage of cosmos-db or tm-db packages
rg 'github\.com/cosmos/cosmos-db|github\.com/.*tm-db'

Length of output: 1518

simapp/test_helpers.go (6)

152-158: Confirm the updated InitChain method usage.

The InitChain function now takes a pointer to abci.RequestInitChain. Ensure that this change aligns with the updated SDK method signatures and that the initialization logic functions as expected.

Also applies to: 321-328


244-253: Consistent use of sdkmath for mathematical operations.

The use of sdkmath.LegacyOneDec() and sdkmath.ZeroInt() for initializing DelegatorShares and MinSelfDelegation is appropriate and aligns with the updated math package structure.


438-442: Added error handling for BondDenom.

Including error checks after calling app.StakingKeeper.BondDenom(ctx) enhances robustness by handling potential errors during bond denomination retrieval.

Also applies to: 474-478


799-800: Instantiation of Bech32 codec is appropriate.

Using address.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()) correctly initializes the Bech32 codec with the proper account address prefix.


Line range hint 804-814: Update QueryTx functions to match new return types.

The QueryTx and QueryTxWithHeight functions now return abci.ExecTxResult. Ensure that all usages of these functions and any dependent code are updated to handle the new return type appropriately.


Line range hint 843-849: Updated application constructor parameters.

The changes to the NewSimApp constructor include additional parameters such as pruning options, gas prices, and chain ID. This aligns with the updated SDK initialization requirements.

modules/nft/migrations/v2/store.go (3)

16-22: Update function signature to match SDK conventions

Ensure that the function signature of Migrate aligns with the conventions and requirements of the latest Cosmos SDK version.

Consider reviewing the SDK migration guides to confirm that the Migrate function's parameters and usage are up to date.


91-96: 🛠️ Refactor suggestion

Simplify iterator management by deferring close after initialization

Deferring the closure of iterator before it is initialized can be error-prone. It is better to initialize the iterator first and then immediately defer its closure to ensure it always gets closed properly.

Apply this diff to adjust the iterator management:

 var iterator storetypes.Iterator
-defer func() {
-    if iterator != nil {
-        _ = iterator.Close()
-    }
-}()
+iterator = storetypes.KVStorePrefixIterator(store, KeyNFT(denomID, ""))
+defer iterator.Close()

Likely invalid or redundant comment.


28-28: Ensure correct usage of iterator functions

Verify that storetypes.KVStorePrefixIterator is the appropriate function to use with the new store types. There might be updated iterator functions in the latest SDK that are better suited.

Run the following script to check for updated iterator functions:

✅ Verification successful

Let me search for more specific information about the store types and iterator usage.


Based on the search results, I can now provide a definitive response about the iterator usage.

storetypes.KVStorePrefixIterator is the correct iterator function to use

The code is using the appropriate iterator function from the Cosmos SDK store types. This is evidenced by:

  1. The same KVStorePrefixIterator function is consistently used across multiple modules in the codebase for similar prefix iteration purposes
  2. The import path shows it's using the latest SDK store types (cosmossdk.io/store/types)
  3. The usage pattern matches other NFT/MT module implementations in the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find iterator functions in the SDK that are compatible with the new store types

# Search for iterator functions in the storetypes package
rg 'func.*Iterator' -A 5 -t go --glob '!**/vendor/**' $(go list -f '{{.Dir}}' cosmossdk.io/store)

Length of output: 8720


Script:

#!/bin/bash
# Search for KVStorePrefixIterator usage and its imports
rg "KVStorePrefixIterator" -B 2 -A 2

# Search for store types imports
rg "storetypes" -B 2 -A 2

Length of output: 33635

@@ -18,5 +18,5 @@ func NewMigrator(k Keeper) Migrator {

// Migrate1to2 migrates from version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v2.Migrate(ctx, m.k.storeKey, m.k.cdc, m.k.Logger(ctx), m.k.SaveDenom)
return v2.Migrate(ctx, m.k.storeService, m.k.cdc, m.k.Logger(ctx), m.k.SaveDenom)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Migration tests need to be updated for store service architecture

The migration tests are currently commented out and still reference the old storeKey architecture. This poses a risk to data integrity during the upgrade process.

  • modules/nft/migrations/v2/store_test.go: Needs to be updated to use storeService instead of storeKey
    • Remove comments and update test setup to use the new store service architecture
    • Update prepareData and related test utilities to work with storeService
    • Ensure test coverage for the v1-to-v2 migration using the new store paradigm
🔗 Analysis chain

LGTM: Store service migration aligns with SDK v0.50.x architecture.

The change from storeKey to storeService follows the architectural updates in Cosmos SDK v0.50.x, which promotes a more service-oriented approach to store interactions.

Let's verify the consistency of this architectural change across the module:


The search results show that the migration to storeService is consistent across the module's core functionality. The remaining storeKey references are primarily in:

  1. Constants and type definitions (types/keys.go)
  2. Test configurations (keeper/depinject_test.go)
  3. Migration-specific key utilities (migrations/v2/keeper.go, migrations/v2/keys.go)
  4. Commented-out test code (migrations/v2/store_test.go)

Let's verify if the migration tests have been properly updated:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all store interactions have been migrated to use storeService
# and no legacy storeKey usage remains in the NFT module

# Check for any remaining storeKey references
echo "Checking for remaining storeKey references in NFT module..."
rg -i "storekey" modules/nft/

# Check for consistent storeService adoption
echo "Verifying storeService adoption..."
rg -i "storeservice" modules/nft/

Length of output: 4983


Script:

#!/bin/bash
# Check the actual migration test implementations
echo "Checking migration test implementations..."
rg -A 10 "func TestMigrate" modules/nft/migrations/v2/

Length of output: 965

Comment on lines +13 to +14
GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
AddressCodec() address.Codec
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

⚠️ Potential issue

Breaking changes in AccountKeeper interface confirmed - updates needed

The verification shows multiple modules using the AccountKeeper interface that need updates:

  • service
  • token
  • record
  • random
  • mt
  • htlc
  • nft
  • oracle
  • farm
  • coinswap

Most existing implementations use sdk.Context and don't have the AddressCodec() method, confirming the breaking changes identified in the review comment.

🔗 Analysis chain

Breaking changes in AccountKeeper interface

The changes introduce two breaking changes:

  1. Context type change from sdk.Context to context.Context
  2. Addition of new required method AddressCodec()

These changes are necessary for compatibility with Cosmos SDK v0.50.x.

Please ensure all implementations of AccountKeeper are updated to:

  1. Use context.Context in GetAccount method
  2. Implement the new AddressCodec() method
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any existing implementations that need to be updated
ast-grep --pattern 'type $_ struct {
  $$$
  accountKeeper AccountKeeper
  $$$
}'

Length of output: 12876


Script:

#!/bin/bash
# Let's search for AccountKeeper interface implementations and usages
rg -A 5 "type AccountKeeper interface" --type go

# Also search for any mock implementations
rg -A 5 "Mock.*AccountKeeper" --type go

# Search for any structs that embed or use AccountKeeper
rg "accountKeeper\s+(?:types\.)?AccountKeeper" --type go

Length of output: 6150

Comment on lines +18 to +20
storeService store.KVStoreService
cdc codec.Codec
nk nftkeeper.Keeper
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Based on the review of the test files and implementation, I can now provide the final response:

Store service migration requires additional test coverage

The migration from storeKey to storeService lacks comprehensive testing:

  • While the keeper tests exist, they rely on simapp setup without explicitly testing store service interactions
  • No dedicated test cases verify the store service functionality in isolation
  • Missing mock implementations for KVStoreService in test utilities
  • Add dedicated test cases in keeper_test.go to verify store service operations
  • Create mock implementations of KVStoreService for unit testing
  • Add test coverage for store migration scenarios
🔗 Analysis chain

Verify store service migration impact

The migration from storeKey to storeService represents a significant architectural change. While this aligns with modern SDK practices, we should ensure proper testing coverage.

Let's verify the test coverage for this change:


Let me gather more information about the test coverage.


Let me check the test setup and mock implementations to understand how the store service is being tested.


Let me check the test suite setup and the actual test implementation to understand how the store service is being used.


Let me check the test setup in simapp and the store service implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for test files that exercise the store service functionality

# Look for test files in the nft module
fd -e go test$ . | grep -i "nft"

# Check for store service usage in tests
rg -l "store.KVStoreService" $(fd -e go test$ .)

Length of output: 210


Script:

#!/bin/bash
# Check test files content for store service testing
rg -A 5 "func Test.*" modules/nft/keeper/*_test.go

# Check migration tests
rg -A 5 "func Test.*" modules/nft/migrations/v2/*_test.go

# Look for store service mocks or test setup
rg -B 5 "KVStoreService" modules/nft/keeper/*_test.go modules/nft/migrations/v2/*_test.go

Length of output: 1629


Script:

#!/bin/bash
# Check test setup in keeper tests
rg -B 10 "type KeeperSuite struct" modules/nft/keeper/keeper_test.go

# Check mock implementations and test utilities
rg -A 10 "func Setup" modules/nft/testutil/

# Look for store service initialization in tests
rg -B 5 "NewKeeper" modules/nft/keeper/*_test.go

Length of output: 776


Script:

#!/bin/bash
# Check the full keeper test suite implementation
cat modules/nft/keeper/keeper_test.go

# Check for any test utilities in the module
fd -e go . modules/nft/testing

# Look for store service mock implementations
rg -l "type.*KVStoreService" .

Length of output: 8446


Script:

#!/bin/bash
# Check simapp setup
cat simapp/app.go

# Check store service interface and implementation
rg -A 10 "type KVStoreService interface" .
rg -A 10 "func NewKeeper" modules/nft/keeper/keeper.go

Length of output: 425

Comment on lines +33 to +35
Config *modulev1.Module
Cdc codec.Codec
StoreService store.KVStoreService
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Migration to StoreService is incomplete across modules

The verification reveals that while the NFT module has been updated to use StoreService, several other modules still use the older KVStoreKey pattern in their depinject.go files:

  • modules/coinswap/depinject.go
  • modules/farm/depinject.go
  • modules/htlc/depinject.go
  • modules/mt/depinject.go
  • modules/oracle/depinject.go
  • modules/random/depinject.go
  • modules/record/depinject.go
  • modules/service/depinject.go
  • modules/token/depinject.go

These modules need to be updated to use store.KVStoreService for consistency with the architectural changes.

🔗 Analysis chain

Verify the store service migration impact

The change from KVStoreKey to KVStoreService is part of the SDK's architectural improvements. Let's verify that all dependent code has been updated to use the new store service pattern.


Let me check the content of these files to see if they actually need updates or if they're already migrated.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to KVStoreKey in the codebase
# that might need to be updated to use KVStoreService

echo "Checking for potentially missed KVStoreKey references..."
rg -l "KVStoreKey" --type go

echo "Checking for store key initialization patterns that might need updates..."
ast-grep --pattern 'NewKeeper($$$storeKey$$$)' --lang go

Length of output: 630


Script:

#!/bin/bash
# Check the actual usage context of KVStoreKey in the found files
for file in simapp/app_v2.go modules/*/depinject.go; do
    echo "=== Checking $file ==="
    rg "KVStoreKey" -C 2 "$file"
done

Length of output: 3667

@@ -10,7 +10,7 @@ import (
)

// NewHandler routes the messages to the handlers
func NewHandler(k keeper.Keeper) sdk.Handler {
func NewHandler(k keeper.Keeper) func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Breaking change detected in oracle module handler

The verification revealed that modules/oracle/handler.go still uses the old sdk.Handler return type while modules/mt/handler.go has been updated to the new signature. This inconsistency needs to be addressed for cosmos-sdk v0.50.x compatibility.

  • modules/oracle/handler.go: Update NewHandler to return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) instead of sdk.Handler
🔗 Analysis chain

Verify handler usage across dependent modules

The handler signature change from sdk.Handler to func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) is required for cosmos-sdk v0.50.x compatibility.

Let's verify the impact on dependent modules:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining old handler usage patterns
rg -l "sdk.Handler" --type go

# Search for direct NewHandler usage to verify correct implementation
rg "NewHandler\(" --type go -B 2 -A 2

Length of output: 679

Comment on lines +242 to +243
log.Fatal(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid using log.Fatal for error handling

Using log.Fatal(err) will terminate the application immediately. It is better to return the error or handle it to allow for graceful shutdown.

Comment on lines +81 to +82
panic(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid using panic for error handling

Using panic(err) can lead to abrupt termination of the application. Consider returning the error and handling it appropriately to allow for graceful recovery.

Apply this diff to adjust the error handling:

-    if err != nil {
-        panic(err)
+    if err != nil {
+        return true // stop the iteration due to error
     }

Adjust the calling code to handle the returned error:

 err := app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
     // existing code
     // ...
     return false
 })
+if err != nil {
+    // handle error appropriately
+}

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +218 to +219
// todo replace version
mods.irisnet.org/simapp => ../../simapp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Address the TODO: Replace version for 'mods.irisnet.org/simapp'

There is a TODO comment indicating that the version needs to be replaced. Currently, mods.irisnet.org/simapp is being replaced with a local path ../../simapp, which may cause issues when building or importing the module externally. Please update the replace directive with the appropriate module version.

Would you like assistance in updating the version and ensuring the module is correctly referenced?

Comment on lines +581 to +586
//app.BeginBlock(abci.RequestBeginBlock{Header: header})
app.FinalizeBlock(&abci.RequestFinalizeBlock{
Height: header.Height,
Hash: header.AppHash,
NextValidatorsHash: header.NextValidatorsHash,
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Based on the gathered evidence, I can now provide the final response:

Migration to FinalizeBlock requires attention in test files

The transition from BeginBlock to FinalizeBlock is partially complete, but there are remaining issues:

  • In simapp/test_helpers.go: The old BeginBlock and EndBlock calls are properly commented out and replaced with FinalizeBlock
  • In modules/service/keeper/keeper_test.go: There are active calls to BeginBlocker that need to be updated to use the new FinalizeBlock approach:
    • Line containing suite.app.BeginBlocker(ctx, abci.RequestBeginBlock{})
    • These calls appear to be in test setup code and need to be migrated to maintain consistency with the new block execution model
🔗 Analysis chain

Ensure correct implementation of FinalizeBlock.

The transition from BeginBlock and EndBlock to FinalizeBlock requires verifying that all block execution logic is correctly migrated.

To confirm no obsolete BeginBlock or EndBlock usages remain, you can run:

Also applies to: 597-597


Let me gather more context about these occurrences to verify if they are actual issues or just commented code.


Let me check if there are any remaining BeginBlocker/EndBlocker methods that need to be migrated.


Let me check one final thing to see if these BeginBlocker calls in the test files are actually being used or are just legacy code.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining uses of BeginBlock or EndBlock.

# Expected result: No matches found.

rg 'app\.BeginBlock|app\.EndBlock'

Length of output: 366


Script:

#!/bin/bash
# Check the context of BeginBlock/EndBlock usage in both files
echo "=== simapp/test_helpers.go ==="
rg -B 2 -A 2 'app\.BeginBlock|app\.EndBlock' simapp/test_helpers.go

echo -e "\n=== modules/service/keeper/keeper_test.go ==="
rg -B 2 -A 2 'app\.BeginBlock|app\.EndBlock' modules/service/keeper/keeper_test.go

Length of output: 935


Script:

#!/bin/bash
# Search for BeginBlocker/EndBlocker method definitions
ast-grep --pattern 'func ($app $_) BeginBlocker($ctx $_,$_ $_) $_'
echo "---"
ast-grep --pattern 'func ($app $_) EndBlocker($ctx $_,$_ $_) $_'

Length of output: 150


Script:

#!/bin/bash
# Check if the BeginBlocker calls in keeper_test.go are actually used
echo "=== Checking if test file imports BeginBlocker ==="
rg -B 3 -A 1 'import \(' modules/service/keeper/keeper_test.go

echo -e "\n=== Checking BeginBlocker interface/type ==="
rg 'type.*BeginBlocker' -A 3

Length of output: 348


total := int64(0)
iterator = sdk.KVStorePrefixIterator(store, KeyNFT(denomID, ""))
iterator = storetypes.KVStorePrefixIterator(store, KeyNFT(denomID, ""))
for ; iterator.Valid(); iterator.Next() {
var baseNFT types.BaseNFT
k.cdc.MustUnmarshal(iterator.Value(), &baseNFT)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Handle potential unmarshal errors instead of panicking

Similarly, in the migrateToken function, replace k.cdc.MustUnmarshal with k.cdc.Unmarshal to safely handle errors during unmarshalling.

Apply this diff to handle unmarshal errors:

- k.cdc.MustUnmarshal(iterator.Value(), &baseNFT)
+ if err := k.cdc.Unmarshal(iterator.Value(), &baseNFT); err != nil {
+     return 0, err
+ }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
k.cdc.MustUnmarshal(iterator.Value(), &baseNFT)
if err := k.cdc.Unmarshal(iterator.Value(), &baseNFT); err != nil {
return 0, err
}

@wangjiulian wangjiulian closed this Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant