refactor!: use context.Context in genesis api (#17885)
This commit is contained in:
parent
7f2fc566a5
commit
9d07b8ca8e
@ -148,6 +148,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* (client) [#17746](https://github.com/cosmos/cosmos-sdk/pull/17746) `txEncodeAmino` & `txDecodeAmino` txs via grpc and rest were removed
|
||||
* `RegisterLegacyAmino` was removed from `AppModuleBasic`
|
||||
* (x/staking) [#17655](https://github.com/cosmos/cosmos-sdk/pull/17655) `QueryHistoricalInfo` was adjusted to return `HistoricalRecord` and marked `Hist` as deprecated.
|
||||
* (types) [#17885](https://github.com/cosmos/cosmos-sdk/pull/17885) `InitGenesis` & `ExportGenesis` now take `context.Context` instead of `sdk.Context`
|
||||
|
||||
### CLI Breaking Changes
|
||||
|
||||
|
||||
16
UPGRADING.md
16
UPGRADING.md
@ -36,6 +36,22 @@ Refer to SimApp `root_v2.go` and `root.go` for an example with an app v2 and a l
|
||||
|
||||
#### `**all**`
|
||||
|
||||
##### Genesis Interface
|
||||
|
||||
All genesis interfaces have been migrated to take context.Context instead of sdk.Context.
|
||||
|
||||
```golang
|
||||
// InitGenesis performs genesis initialization for the authz module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
}
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the authz
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
}
|
||||
```
|
||||
|
||||
##### Migration to Collections
|
||||
|
||||
Most of Cosmos SDK modules have migrated to [collections](https://docs.cosmos.network/main/packages/collections).
|
||||
|
||||
@ -140,3 +140,96 @@ func (mr *MockProposalTxVerifierMockRecorder) ProcessProposalVerifyTx(txBz inter
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProcessProposalVerifyTx", reflect.TypeOf((*MockProposalTxVerifier)(nil).ProcessProposalVerifyTx), txBz)
|
||||
}
|
||||
|
||||
// TxDecode mocks base method.
|
||||
func (m *MockProposalTxVerifier) TxDecode(txBz []byte) (types.Tx, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TxDecode", txBz)
|
||||
ret0, _ := ret[0].(types.Tx)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// TxDecode indicates an expected call of TxDecode.
|
||||
func (mr *MockProposalTxVerifierMockRecorder) TxDecode(txBz interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TxDecode", reflect.TypeOf((*MockProposalTxVerifier)(nil).TxDecode), txBz)
|
||||
}
|
||||
|
||||
// TxEncode mocks base method.
|
||||
func (m *MockProposalTxVerifier) TxEncode(tx types.Tx) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TxEncode", tx)
|
||||
ret0, _ := ret[0].([]byte)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// TxEncode indicates an expected call of TxEncode.
|
||||
func (mr *MockProposalTxVerifierMockRecorder) TxEncode(tx interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TxEncode", reflect.TypeOf((*MockProposalTxVerifier)(nil).TxEncode), tx)
|
||||
}
|
||||
|
||||
// MockTxSelector is a mock of TxSelector interface.
|
||||
type MockTxSelector struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockTxSelectorMockRecorder
|
||||
}
|
||||
|
||||
// MockTxSelectorMockRecorder is the mock recorder for MockTxSelector.
|
||||
type MockTxSelectorMockRecorder struct {
|
||||
mock *MockTxSelector
|
||||
}
|
||||
|
||||
// NewMockTxSelector creates a new mock instance.
|
||||
func NewMockTxSelector(ctrl *gomock.Controller) *MockTxSelector {
|
||||
mock := &MockTxSelector{ctrl: ctrl}
|
||||
mock.recorder = &MockTxSelectorMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockTxSelector) EXPECT() *MockTxSelectorMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Clear mocks base method.
|
||||
func (m *MockTxSelector) Clear() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Clear")
|
||||
}
|
||||
|
||||
// Clear indicates an expected call of Clear.
|
||||
func (mr *MockTxSelectorMockRecorder) Clear() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Clear", reflect.TypeOf((*MockTxSelector)(nil).Clear))
|
||||
}
|
||||
|
||||
// SelectTxForProposal mocks base method.
|
||||
func (m *MockTxSelector) SelectTxForProposal(maxTxBytes, maxBlockGas uint64, memTx types.Tx, txBz []byte) bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SelectTxForProposal", maxTxBytes, maxBlockGas, memTx, txBz)
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SelectTxForProposal indicates an expected call of SelectTxForProposal.
|
||||
func (mr *MockTxSelectorMockRecorder) SelectTxForProposal(maxTxBytes, maxBlockGas, memTx, txBz interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SelectTxForProposal", reflect.TypeOf((*MockTxSelector)(nil).SelectTxForProposal), maxTxBytes, maxBlockGas, memTx, txBz)
|
||||
}
|
||||
|
||||
// SelectedTxs mocks base method.
|
||||
func (m *MockTxSelector) SelectedTxs() [][]byte {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SelectedTxs")
|
||||
ret0, _ := ret[0].([][]byte)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SelectedTxs indicates an expected call of SelectedTxs.
|
||||
func (mr *MockTxSelectorMockRecorder) SelectedTxs() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SelectedTxs", reflect.TypeOf((*MockTxSelector)(nil).SelectedTxs))
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ func (mr *MockAppModuleWithAllExtensionsMockRecorder) EndBlock(arg0 interface{})
|
||||
}
|
||||
|
||||
// ExportGenesis mocks base method.
|
||||
func (m *MockAppModuleWithAllExtensions) ExportGenesis(arg0 types1.Context, arg1 codec.JSONCodec) json.RawMessage {
|
||||
func (m *MockAppModuleWithAllExtensions) ExportGenesis(arg0 context.Context, arg1 codec.JSONCodec) json.RawMessage {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ExportGenesis", arg0, arg1)
|
||||
ret0, _ := ret[0].(json.RawMessage)
|
||||
@ -101,7 +101,7 @@ func (mr *MockAppModuleWithAllExtensionsMockRecorder) ExportGenesis(arg0, arg1 i
|
||||
}
|
||||
|
||||
// InitGenesis mocks base method.
|
||||
func (m *MockAppModuleWithAllExtensions) InitGenesis(arg0 types1.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) {
|
||||
func (m *MockAppModuleWithAllExtensions) InitGenesis(arg0 context.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "InitGenesis", arg0, arg1, arg2)
|
||||
}
|
||||
@ -267,7 +267,7 @@ func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) EndBlock(arg0 interfac
|
||||
}
|
||||
|
||||
// ExportGenesis mocks base method.
|
||||
func (m *MockAppModuleWithAllExtensionsABCI) ExportGenesis(arg0 types1.Context, arg1 codec.JSONCodec) json.RawMessage {
|
||||
func (m *MockAppModuleWithAllExtensionsABCI) ExportGenesis(arg0 context.Context, arg1 codec.JSONCodec) json.RawMessage {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ExportGenesis", arg0, arg1)
|
||||
ret0, _ := ret[0].(json.RawMessage)
|
||||
@ -281,7 +281,7 @@ func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) ExportGenesis(arg0, ar
|
||||
}
|
||||
|
||||
// InitGenesis mocks base method.
|
||||
func (m *MockAppModuleWithAllExtensionsABCI) InitGenesis(arg0 types1.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) []types.ValidatorUpdate {
|
||||
func (m *MockAppModuleWithAllExtensionsABCI) InitGenesis(arg0 context.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) []types.ValidatorUpdate {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].([]types.ValidatorUpdate)
|
||||
|
||||
@ -218,7 +218,7 @@ func (mr *MockHasGenesisMockRecorder) DefaultGenesis(arg0 interface{}) *gomock.C
|
||||
}
|
||||
|
||||
// ExportGenesis mocks base method.
|
||||
func (m *MockHasGenesis) ExportGenesis(arg0 types1.Context, arg1 codec.JSONCodec) json.RawMessage {
|
||||
func (m *MockHasGenesis) ExportGenesis(arg0 context.Context, arg1 codec.JSONCodec) json.RawMessage {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ExportGenesis", arg0, arg1)
|
||||
ret0, _ := ret[0].(json.RawMessage)
|
||||
@ -232,7 +232,7 @@ func (mr *MockHasGenesisMockRecorder) ExportGenesis(arg0, arg1 interface{}) *gom
|
||||
}
|
||||
|
||||
// InitGenesis mocks base method.
|
||||
func (m *MockHasGenesis) InitGenesis(arg0 types1.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) {
|
||||
func (m *MockHasGenesis) InitGenesis(arg0 context.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "InitGenesis", arg0, arg1, arg2)
|
||||
}
|
||||
@ -295,7 +295,7 @@ func (mr *MockHasABCIGenesisMockRecorder) DefaultGenesis(arg0 interface{}) *gomo
|
||||
}
|
||||
|
||||
// ExportGenesis mocks base method.
|
||||
func (m *MockHasABCIGenesis) ExportGenesis(arg0 types1.Context, arg1 codec.JSONCodec) json.RawMessage {
|
||||
func (m *MockHasABCIGenesis) ExportGenesis(arg0 context.Context, arg1 codec.JSONCodec) json.RawMessage {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ExportGenesis", arg0, arg1)
|
||||
ret0, _ := ret[0].(json.RawMessage)
|
||||
@ -309,7 +309,7 @@ func (mr *MockHasABCIGenesisMockRecorder) ExportGenesis(arg0, arg1 interface{})
|
||||
}
|
||||
|
||||
// InitGenesis mocks base method.
|
||||
func (m *MockHasABCIGenesis) InitGenesis(arg0 types1.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) []types.ValidatorUpdate {
|
||||
func (m *MockHasABCIGenesis) InitGenesis(arg0 context.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) []types.ValidatorUpdate {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].([]types.ValidatorUpdate)
|
||||
@ -642,7 +642,7 @@ func (mr *MockgenesisOnlyModuleMockRecorder) DefaultGenesis(arg0 interface{}) *g
|
||||
}
|
||||
|
||||
// ExportGenesis mocks base method.
|
||||
func (m *MockgenesisOnlyModule) ExportGenesis(arg0 types1.Context, arg1 codec.JSONCodec) json.RawMessage {
|
||||
func (m *MockgenesisOnlyModule) ExportGenesis(arg0 context.Context, arg1 codec.JSONCodec) json.RawMessage {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ExportGenesis", arg0, arg1)
|
||||
ret0, _ := ret[0].(json.RawMessage)
|
||||
@ -656,7 +656,7 @@ func (mr *MockgenesisOnlyModuleMockRecorder) ExportGenesis(arg0, arg1 interface{
|
||||
}
|
||||
|
||||
// InitGenesis mocks base method.
|
||||
func (m *MockgenesisOnlyModule) InitGenesis(arg0 types1.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) []types.ValidatorUpdate {
|
||||
func (m *MockgenesisOnlyModule) InitGenesis(arg0 context.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) []types.ValidatorUpdate {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].([]types.ValidatorUpdate)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
)
|
||||
@ -9,7 +11,7 @@ import (
|
||||
//
|
||||
// CONTRACT: old coins from the FeeCollectionKeeper need to be transferred through
|
||||
// a genesis port script to the new fee collector account
|
||||
func (ak AccountKeeper) InitGenesis(ctx sdk.Context, data types.GenesisState) {
|
||||
func (ak AccountKeeper) InitGenesis(ctx context.Context, data types.GenesisState) {
|
||||
if err := ak.Params.Set(ctx, data.Params); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -35,7 +37,7 @@ func (ak AccountKeeper) InitGenesis(ctx sdk.Context, data types.GenesisState) {
|
||||
}
|
||||
|
||||
// ExportGenesis returns a GenesisState for a given context and keeper
|
||||
func (ak AccountKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
func (ak AccountKeeper) ExportGenesis(ctx context.Context) *types.GenesisState {
|
||||
params := ak.GetParams(ctx)
|
||||
|
||||
var genAccounts types.GenesisAccounts
|
||||
|
||||
@ -130,7 +130,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
|
||||
// InitGenesis performs genesis initialization for the auth module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
var genesisState types.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
am.accountKeeper.InitGenesis(ctx, genesisState)
|
||||
@ -138,7 +138,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the auth
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs := am.accountKeeper.ExportGenesis(ctx)
|
||||
return cdc.MustMarshalJSON(gs)
|
||||
}
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz"
|
||||
)
|
||||
|
||||
// InitGenesis initializes new authz genesis
|
||||
func (k Keeper) InitGenesis(ctx sdk.Context, data *authz.GenesisState) {
|
||||
now := ctx.HeaderInfo().Time
|
||||
func (k Keeper) InitGenesis(ctx context.Context, data *authz.GenesisState) {
|
||||
now := sdk.UnwrapSDKContext(ctx).HeaderInfo().Time
|
||||
for _, entry := range data.Authorization {
|
||||
// ignore expired authorizations
|
||||
if entry.Expiration != nil && entry.Expiration.Before(now) {
|
||||
@ -36,7 +38,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *authz.GenesisState) {
|
||||
}
|
||||
|
||||
// ExportGenesis returns a GenesisState for a given context.
|
||||
func (k Keeper) ExportGenesis(ctx sdk.Context) *authz.GenesisState {
|
||||
func (k Keeper) ExportGenesis(ctx context.Context) *authz.GenesisState {
|
||||
var entries []authz.GrantAuthorization
|
||||
k.IterateGrants(ctx, func(granter, grantee sdk.AccAddress, grant authz.Grant) bool {
|
||||
entries = append(entries, authz.GrantAuthorization{
|
||||
|
||||
@ -19,7 +19,6 @@ import (
|
||||
sdkclient "github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz"
|
||||
@ -128,7 +127,7 @@ func (am AppModule) IsAppModule() {}
|
||||
|
||||
// InitGenesis performs genesis initialization for the authz module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
var genesisState authz.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
am.keeper.InitGenesis(ctx, &genesisState)
|
||||
@ -136,7 +135,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the authz
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs := am.keeper.ExportGenesis(ctx)
|
||||
return cdc.MustMarshalJSON(gs)
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ func (AppModule) QuerierRoute() string { return types.RouterKey }
|
||||
|
||||
// InitGenesis performs genesis initialization for the bank module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
start := time.Now()
|
||||
var genesisState types.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
@ -154,7 +154,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the bank
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs := am.keeper.ExportGenesis(ctx)
|
||||
return cdc.MustMarshalJSON(gs)
|
||||
}
|
||||
|
||||
@ -24,7 +24,6 @@ import (
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
"github.com/cosmos/cosmos-sdk/telemetry"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
)
|
||||
@ -117,7 +116,7 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|
||||
|
||||
// InitGenesis performs genesis initialization for the circuit module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
start := time.Now()
|
||||
var genesisState types.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
@ -128,7 +127,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the circuit
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs := am.keeper.ExportGenesis(ctx)
|
||||
return cdc.MustMarshalJSON(gs)
|
||||
}
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"context"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/crisis/types"
|
||||
)
|
||||
|
||||
// new crisis genesis
|
||||
func (k *Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) {
|
||||
func (k *Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) {
|
||||
if err := k.ConstantFee.Set(ctx, data.ConstantFee); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// ExportGenesis returns a GenesisState for a given context and keeper.
|
||||
func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
func (k *Keeper) ExportGenesis(ctx context.Context) *types.GenesisState {
|
||||
constantFee, err := k.ConstantFee.Get(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@ -95,16 +95,17 @@ func (k *Keeper) Invariants() []sdk.Invariant {
|
||||
|
||||
// AssertInvariants asserts all registered invariants. If any invariant fails,
|
||||
// the method panics.
|
||||
func (k *Keeper) AssertInvariants(ctx sdk.Context) {
|
||||
func (k *Keeper) AssertInvariants(ctx context.Context) {
|
||||
logger := k.Logger(ctx)
|
||||
|
||||
start := time.Now()
|
||||
invarRoutes := k.Routes()
|
||||
n := len(invarRoutes)
|
||||
sdkCtx := sdk.UnwrapSDKContext(ctx)
|
||||
for i, ir := range invarRoutes {
|
||||
logger.Info("asserting crisis invariants", "inv", fmt.Sprint(i+1, "/", n), "name", ir.FullRoute())
|
||||
|
||||
invCtx, _ := ctx.CacheContext()
|
||||
invCtx, _ := sdkCtx.CacheContext()
|
||||
if res, stop := ir.Invar(invCtx); stop {
|
||||
// TODO: Include app name as part of context to allow for this to be
|
||||
// variable.
|
||||
@ -115,7 +116,7 @@ func (k *Keeper) AssertInvariants(ctx sdk.Context) {
|
||||
}
|
||||
|
||||
diff := time.Since(start)
|
||||
logger.Info("asserted all invariants", "duration", diff, "height", ctx.BlockHeight())
|
||||
logger.Info("asserted all invariants", "duration", diff, "height", sdkCtx.BlockHeight())
|
||||
}
|
||||
|
||||
// InvCheckPeriod returns the invariant checks period.
|
||||
|
||||
@ -22,7 +22,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
"github.com/cosmos/cosmos-sdk/telemetry"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/crisis/client/cli"
|
||||
@ -139,7 +138,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
|
||||
// InitGenesis performs genesis initialization for the crisis module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
start := time.Now()
|
||||
var genesisState types.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
@ -153,7 +152,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the crisis
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs := am.keeper.ExportGenesis(ctx)
|
||||
return cdc.MustMarshalJSON(gs)
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
@ -10,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// InitGenesis sets distribution information for genesis
|
||||
func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) {
|
||||
func (k Keeper) InitGenesis(ctx context.Context, data types.GenesisState) {
|
||||
var moduleHoldings sdk.DecCoins
|
||||
|
||||
err := k.FeePool.Set(ctx, data.FeePool)
|
||||
@ -146,7 +147,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) {
|
||||
}
|
||||
|
||||
// ExportGenesis returns a GenesisState for a given context and keeper.
|
||||
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
func (k Keeper) ExportGenesis(ctx context.Context) *types.GenesisState {
|
||||
feePool, err := k.FeePool.Get(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@ -147,7 +147,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
|
||||
// InitGenesis performs genesis initialization for the distribution module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
var genesisState types.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
am.keeper.InitGenesis(ctx, genesisState)
|
||||
@ -155,7 +155,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the distribution
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs := am.keeper.ExportGenesis(ctx)
|
||||
return cdc.MustMarshalJSON(gs)
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package evidence
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/x/evidence/exported"
|
||||
@ -8,12 +9,11 @@ import (
|
||||
"cosmossdk.io/x/evidence/types"
|
||||
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// InitGenesis initializes the evidence module's state from a provided genesis
|
||||
// state.
|
||||
func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs *types.GenesisState) {
|
||||
func InitGenesis(ctx context.Context, k keeper.Keeper, gs *types.GenesisState) {
|
||||
if err := gs.Validate(); err != nil {
|
||||
panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err))
|
||||
}
|
||||
@ -34,7 +34,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs *types.GenesisState) {
|
||||
}
|
||||
|
||||
// ExportGenesis returns the evidence module's exported genesis.
|
||||
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
|
||||
func ExportGenesis(ctx context.Context, k keeper.Keeper) *types.GenesisState {
|
||||
gs := new(types.GenesisState)
|
||||
err := k.Evidences.Walk(ctx, nil, func(_ []byte, value exported.Evidence) (stop bool, err error) {
|
||||
anyEvi, err := codectypes.NewAnyWithValue(value)
|
||||
|
||||
@ -23,7 +23,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
)
|
||||
@ -136,7 +135,7 @@ func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error {
|
||||
|
||||
// InitGenesis performs the evidence module's genesis initialization It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, bz json.RawMessage) {
|
||||
var gs types.GenesisState
|
||||
err := cdc.UnmarshalJSON(bz, &gs)
|
||||
if err != nil {
|
||||
@ -147,7 +146,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.Ra
|
||||
}
|
||||
|
||||
// ExportGenesis returns the evidence module's exported genesis state as raw JSON bytes.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
return cdc.MustMarshalJSON(ExportGenesis(ctx, am.keeper))
|
||||
}
|
||||
|
||||
|
||||
@ -135,7 +135,7 @@ func (am AppModule) IsAppModule() {}
|
||||
|
||||
// InitGenesis performs genesis initialization for the feegrant module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, bz json.RawMessage) {
|
||||
var gs feegrant.GenesisState
|
||||
cdc.MustUnmarshalJSON(bz, &gs)
|
||||
|
||||
@ -147,7 +147,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.Ra
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the feegrant
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs, err := am.keeper.ExportGenesis(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@ -1,18 +1,19 @@
|
||||
package genutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
|
||||
"cosmossdk.io/core/genesis"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
// InitGenesis - initialize accounts and deliver genesis transactions
|
||||
func InitGenesis(
|
||||
ctx sdk.Context, stakingKeeper types.StakingKeeper,
|
||||
ctx context.Context, stakingKeeper types.StakingKeeper,
|
||||
deliverTx genesis.TxHandler, genesisState types.GenesisState,
|
||||
txEncodingConfig client.TxEncodingConfig,
|
||||
) (validators []abci.ValidatorUpdate, err error) {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package genutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
@ -90,7 +91,7 @@ func ValidateAccountInGenesis(
|
||||
// invokes the provided deliverTxfn with the decoded Tx. It returns the result
|
||||
// of the staking module's ApplyAndReturnValidatorSetUpdates.
|
||||
func DeliverGenTxs(
|
||||
ctx sdk.Context, genTxs []json.RawMessage,
|
||||
ctx context.Context, genTxs []json.RawMessage,
|
||||
stakingKeeper types.StakingKeeper, deliverTx genesis.TxHandler,
|
||||
txEncodingConfig client.TxEncodingConfig,
|
||||
) ([]abci.ValidatorUpdate, error) {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package genutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
@ -15,7 +16,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
@ -100,7 +100,7 @@ func (AppModule) IsOnePerModuleType() {}
|
||||
func (AppModule) IsAppModule() {}
|
||||
|
||||
// InitGenesis performs genesis initialization for the genutil module.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
|
||||
var genesisState types.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
validators, err := InitGenesis(ctx, am.stakingKeeper, am.deliverTx, genesisState, am.txEncodingConfig)
|
||||
@ -112,7 +112,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the genutil
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(_ context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
return am.DefaultGenesis(cdc)
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package gov
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
@ -12,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// InitGenesis - store genesis parameters
|
||||
func InitGenesis(ctx sdk.Context, ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, data *v1.GenesisState) {
|
||||
func InitGenesis(ctx context.Context, ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, data *v1.GenesisState) {
|
||||
err := k.ProposalID.Set(ctx, data.StartingProposalId)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -86,7 +87,7 @@ func InitGenesis(ctx sdk.Context, ak types.AccountKeeper, bk types.BankKeeper, k
|
||||
}
|
||||
|
||||
// ExportGenesis - output genesis parameters
|
||||
func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) (*v1.GenesisState, error) {
|
||||
func ExportGenesis(ctx context.Context, k *keeper.Keeper) (*v1.GenesisState, error) {
|
||||
startingProposalID, err := k.ProposalID.Peek(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -290,7 +290,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
|
||||
// InitGenesis performs genesis initialization for the gov module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
var genesisState v1.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
InitGenesis(ctx, am.accountKeeper, am.bankKeeper, am.keeper, &genesisState)
|
||||
@ -298,7 +298,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the gov
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs, err := ExportGenesis(ctx, am.keeper)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
@ -8,36 +9,38 @@ import (
|
||||
"cosmossdk.io/errors"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/group"
|
||||
)
|
||||
|
||||
// InitGenesis initializes the group module's genesis state.
|
||||
func (k Keeper) InitGenesis(ctx types.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
|
||||
func (k Keeper) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
|
||||
var genesisState group.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
|
||||
if err := k.groupTable.Import(ctx.KVStore(k.key), genesisState.Groups, genesisState.GroupSeq); err != nil {
|
||||
sdkCtx := sdk.UnwrapSDKContext(ctx)
|
||||
|
||||
if err := k.groupTable.Import(sdkCtx.KVStore(k.key), genesisState.Groups, genesisState.GroupSeq); err != nil {
|
||||
panic(errors.Wrap(err, "groups"))
|
||||
}
|
||||
|
||||
if err := k.groupMemberTable.Import(ctx.KVStore(k.key), genesisState.GroupMembers, 0); err != nil {
|
||||
if err := k.groupMemberTable.Import(sdkCtx.KVStore(k.key), genesisState.GroupMembers, 0); err != nil {
|
||||
panic(errors.Wrap(err, "group members"))
|
||||
}
|
||||
|
||||
if err := k.groupPolicyTable.Import(ctx.KVStore(k.key), genesisState.GroupPolicies, 0); err != nil {
|
||||
if err := k.groupPolicyTable.Import(sdkCtx.KVStore(k.key), genesisState.GroupPolicies, 0); err != nil {
|
||||
panic(errors.Wrap(err, "group policies"))
|
||||
}
|
||||
|
||||
if err := k.groupPolicySeq.InitVal(ctx.KVStore(k.key), genesisState.GroupPolicySeq); err != nil {
|
||||
if err := k.groupPolicySeq.InitVal(sdkCtx.KVStore(k.key), genesisState.GroupPolicySeq); err != nil {
|
||||
panic(errors.Wrap(err, "group policy account seq"))
|
||||
}
|
||||
|
||||
if err := k.proposalTable.Import(ctx.KVStore(k.key), genesisState.Proposals, genesisState.ProposalSeq); err != nil {
|
||||
if err := k.proposalTable.Import(sdkCtx.KVStore(k.key), genesisState.Proposals, genesisState.ProposalSeq); err != nil {
|
||||
panic(errors.Wrap(err, "proposals"))
|
||||
}
|
||||
|
||||
if err := k.voteTable.Import(ctx.KVStore(k.key), genesisState.Votes, 0); err != nil {
|
||||
if err := k.voteTable.Import(sdkCtx.KVStore(k.key), genesisState.Votes, 0); err != nil {
|
||||
panic(errors.Wrap(err, "votes"))
|
||||
}
|
||||
|
||||
@ -45,12 +48,14 @@ func (k Keeper) InitGenesis(ctx types.Context, cdc codec.JSONCodec, data json.Ra
|
||||
}
|
||||
|
||||
// ExportGenesis returns the group module's exported genesis.
|
||||
func (k Keeper) ExportGenesis(ctx types.Context, _ codec.JSONCodec) *group.GenesisState {
|
||||
func (k Keeper) ExportGenesis(ctx context.Context, _ codec.JSONCodec) *group.GenesisState {
|
||||
genesisState := group.NewGenesisState()
|
||||
|
||||
var groups []*group.GroupInfo
|
||||
|
||||
groupSeq, err := k.groupTable.Export(ctx.KVStore(k.key), &groups)
|
||||
sdkCtx := sdk.UnwrapSDKContext(ctx)
|
||||
|
||||
groupSeq, err := k.groupTable.Export(sdkCtx.KVStore(k.key), &groups)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "groups"))
|
||||
}
|
||||
@ -58,22 +63,22 @@ func (k Keeper) ExportGenesis(ctx types.Context, _ codec.JSONCodec) *group.Genes
|
||||
genesisState.GroupSeq = groupSeq
|
||||
|
||||
var groupMembers []*group.GroupMember
|
||||
_, err = k.groupMemberTable.Export(ctx.KVStore(k.key), &groupMembers)
|
||||
_, err = k.groupMemberTable.Export(sdkCtx.KVStore(k.key), &groupMembers)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "group members"))
|
||||
}
|
||||
genesisState.GroupMembers = groupMembers
|
||||
|
||||
var groupPolicies []*group.GroupPolicyInfo
|
||||
_, err = k.groupPolicyTable.Export(ctx.KVStore(k.key), &groupPolicies)
|
||||
_, err = k.groupPolicyTable.Export(sdkCtx.KVStore(k.key), &groupPolicies)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "group policies"))
|
||||
}
|
||||
genesisState.GroupPolicies = groupPolicies
|
||||
genesisState.GroupPolicySeq = k.groupPolicySeq.CurVal(ctx.KVStore(k.key))
|
||||
genesisState.GroupPolicySeq = k.groupPolicySeq.CurVal(sdkCtx.KVStore(k.key))
|
||||
|
||||
var proposals []*group.Proposal
|
||||
proposalSeq, err := k.proposalTable.Export(ctx.KVStore(k.key), &proposals)
|
||||
proposalSeq, err := k.proposalTable.Export(sdkCtx.KVStore(k.key), &proposals)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "proposals"))
|
||||
}
|
||||
@ -81,7 +86,7 @@ func (k Keeper) ExportGenesis(ctx types.Context, _ codec.JSONCodec) *group.Genes
|
||||
genesisState.ProposalSeq = proposalSeq
|
||||
|
||||
var votes []*group.Vote
|
||||
_, err = k.voteTable.Export(ctx.KVStore(k.key), &votes)
|
||||
_, err = k.voteTable.Export(sdkCtx.KVStore(k.key), &votes)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "votes"))
|
||||
}
|
||||
|
||||
@ -120,13 +120,13 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
|
||||
|
||||
// InitGenesis performs genesis initialization for the group module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
am.keeper.InitGenesis(ctx, cdc, data)
|
||||
}
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the group
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs := am.keeper.ExportGenesis(ctx, cdc)
|
||||
return cdc.MustMarshalJSON(gs)
|
||||
}
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"context"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
// InitGenesis new mint genesis
|
||||
func (keeper Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) {
|
||||
func (keeper Keeper) InitGenesis(ctx context.Context, ak types.AccountKeeper, data *types.GenesisState) {
|
||||
if err := keeper.Minter.Set(ctx, data.Minter); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -19,7 +20,7 @@ func (keeper Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *
|
||||
}
|
||||
|
||||
// ExportGenesis returns a GenesisState for a given context and keeper.
|
||||
func (keeper Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
func (keeper Keeper) ExportGenesis(ctx context.Context) *types.GenesisState {
|
||||
minter, err := keeper.Minter.Get(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@ -15,7 +15,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
@ -133,7 +132,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
|
||||
// InitGenesis performs genesis initialization for the mint module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
var genesisState types.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
|
||||
@ -142,7 +141,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the mint
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs := am.keeper.ExportGenesis(ctx)
|
||||
return cdc.MustMarshalJSON(gs)
|
||||
}
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sort"
|
||||
|
||||
"cosmossdk.io/x/nft"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// InitGenesis initializes the nft module's genesis state from a given
|
||||
// genesis state.
|
||||
func (k Keeper) InitGenesis(ctx sdk.Context, data *nft.GenesisState) {
|
||||
func (k Keeper) InitGenesis(ctx context.Context, data *nft.GenesisState) {
|
||||
for _, class := range data.Classes {
|
||||
if err := k.SaveClass(ctx, *class); err != nil {
|
||||
panic(err)
|
||||
@ -31,7 +30,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *nft.GenesisState) {
|
||||
}
|
||||
|
||||
// ExportGenesis returns a GenesisState for a given context.
|
||||
func (k Keeper) ExportGenesis(ctx sdk.Context) *nft.GenesisState {
|
||||
func (k Keeper) ExportGenesis(ctx context.Context) *nft.GenesisState {
|
||||
classes := k.GetClasses(ctx)
|
||||
nftMap := make(map[string][]*nft.NFT)
|
||||
for _, class := range classes {
|
||||
|
||||
@ -22,7 +22,6 @@ import (
|
||||
sdkclient "github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
)
|
||||
@ -120,7 +119,7 @@ func (am AppModule) IsAppModule() {}
|
||||
|
||||
// InitGenesis performs genesis initialization for the nft module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
var genesisState nft.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
am.keeper.InitGenesis(ctx, &genesisState)
|
||||
@ -128,7 +127,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the nft
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs := am.keeper.ExportGenesis(ctx)
|
||||
return cdc.MustMarshalJSON(gs)
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
@ -8,7 +10,7 @@ import (
|
||||
|
||||
// InitGenesis initializes default parameters and the keeper's address to
|
||||
// pubkey map.
|
||||
func (keeper Keeper) InitGenesis(ctx sdk.Context, stakingKeeper types.StakingKeeper, data *types.GenesisState) {
|
||||
func (keeper Keeper) InitGenesis(ctx context.Context, stakingKeeper types.StakingKeeper, data *types.GenesisState) {
|
||||
err := stakingKeeper.IterateValidators(ctx,
|
||||
func(index int64, validator stakingtypes.ValidatorI) bool {
|
||||
consPk, err := validator.ConsPubKey()
|
||||
@ -59,7 +61,7 @@ func (keeper Keeper) InitGenesis(ctx sdk.Context, stakingKeeper types.StakingKee
|
||||
// ExportGenesis writes the current store values
|
||||
// to a genesis file, which can be imported again
|
||||
// with InitGenesis
|
||||
func (keeper Keeper) ExportGenesis(ctx sdk.Context) (data *types.GenesisState) {
|
||||
func (keeper Keeper) ExportGenesis(ctx context.Context) (data *types.GenesisState) {
|
||||
params, err := keeper.Params.Get(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@ -16,7 +16,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
@ -145,7 +144,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
|
||||
// InitGenesis performs genesis initialization for the slashing module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) {
|
||||
var genesisState types.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
am.keeper.InitGenesis(ctx, am.stakingKeeper, &genesisState)
|
||||
@ -153,7 +152,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the slashing
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
gs := am.keeper.ExportGenesis(ctx)
|
||||
return cdc.MustMarshalJSON(gs)
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ func (k Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) (res
|
||||
// ExportGenesis returns a GenesisState for a given context and keeper. The
|
||||
// GenesisState will contain the pool, params, validators, and bonds found in
|
||||
// the keeper.
|
||||
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
func (k Keeper) ExportGenesis(ctx context.Context) *types.GenesisState {
|
||||
var unbondingDelegations []types.UnbondingDelegation
|
||||
|
||||
err := k.UnbondingDelegations.Walk(
|
||||
|
||||
@ -152,7 +152,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
}
|
||||
|
||||
// InitGenesis performs genesis initialization for the staking module.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
|
||||
var genesisState types.GenesisState
|
||||
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
@ -162,7 +162,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the staking
|
||||
// module.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
return cdc.MustMarshalJSON(am.keeper.ExportGenesis(ctx))
|
||||
}
|
||||
|
||||
|
||||
@ -25,7 +25,6 @@ import (
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
@ -116,7 +115,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
}
|
||||
|
||||
// InitGenesis is ignored, no sense in serializing future upgrades
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, _ codec.JSONCodec, _ json.RawMessage) {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, _ codec.JSONCodec, _ json.RawMessage) {
|
||||
// set version map automatically if available
|
||||
if versionMap := am.keeper.GetInitVersionMap(); versionMap != nil {
|
||||
// chains can still use a custom init chainer for setting the version map
|
||||
@ -150,7 +149,7 @@ func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, _ client.TxEncodingConf
|
||||
}
|
||||
|
||||
// ExportGenesis is always empty, as InitGenesis does nothing either
|
||||
func (am AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
func (am AppModule) ExportGenesis(_ context.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
return am.DefaultGenesis(cdc)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user