refactor!: use context.Context in genesis api (#17885)

This commit is contained in:
Marko
2023-09-26 16:03:41 +00:00
committed by GitHub
parent 7f2fc566a5
commit 9d07b8ca8e
37 changed files with 224 additions and 104 deletions
+4 -3
View File
@@ -1,6 +1,7 @@
package module
import (
"context"
"encoding/json"
abci "github.com/cometbft/cometbft/abci/types"
@@ -82,9 +83,9 @@ func (c coreAppModuleBasicAdaptor) ValidateGenesis(cdc codec.JSONCodec, txConfig
}
// ExportGenesis implements HasGenesis
func (c coreAppModuleBasicAdaptor) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
func (c coreAppModuleBasicAdaptor) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
if module, ok := c.module.(appmodule.HasGenesis); ok {
ctx := ctx.WithGasMeter(storetypes.NewInfiniteGasMeter()) // avoid race conditions
ctx := sdk.UnwrapSDKContext(ctx).WithGasMeter(storetypes.NewInfiniteGasMeter()) // avoid race conditions
target := genesis.RawJSONTarget{}
err := module.ExportGenesis(ctx, target.Target())
if err != nil {
@@ -107,7 +108,7 @@ func (c coreAppModuleBasicAdaptor) ExportGenesis(ctx sdk.Context, cdc codec.JSON
}
// InitGenesis implements HasGenesis
func (c coreAppModuleBasicAdaptor) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.RawMessage) []abci.ValidatorUpdate {
func (c coreAppModuleBasicAdaptor) InitGenesis(ctx context.Context, cdc codec.JSONCodec, bz json.RawMessage) []abci.ValidatorUpdate {
if module, ok := c.module.(appmodule.HasGenesis); ok {
// core API genesis
source, err := genesis.SourceFromRawJSON(bz)
+4 -4
View File
@@ -184,15 +184,15 @@ func (bm BasicManager) AddQueryCommands(rootQueryCmd *cobra.Command) {
// HasGenesis is the extension interface for stateful genesis methods.
type HasGenesis interface {
HasGenesisBasics
InitGenesis(sdk.Context, codec.JSONCodec, json.RawMessage)
ExportGenesis(sdk.Context, codec.JSONCodec) json.RawMessage
InitGenesis(context.Context, codec.JSONCodec, json.RawMessage)
ExportGenesis(context.Context, codec.JSONCodec) json.RawMessage
}
// HasABCIGenesis is the extension interface for stateful genesis methods which returns validator updates.
type HasABCIGenesis interface {
HasGenesisBasics
InitGenesis(sdk.Context, codec.JSONCodec, json.RawMessage) []abci.ValidatorUpdate
ExportGenesis(sdk.Context, codec.JSONCodec) json.RawMessage
InitGenesis(context.Context, codec.JSONCodec, json.RawMessage) []abci.ValidatorUpdate
ExportGenesis(context.Context, codec.JSONCodec) json.RawMessage
}
// AppModule is the form for an application module. Most of