Skip to content

Commit

Permalink
revert InitGenesis
Browse files Browse the repository at this point in the history
  • Loading branch information
anhductn2001 committed Nov 4, 2024
1 parent b57f058 commit d218993
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 2 additions & 3 deletions x/delayedack/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import (
// InitGenesis initializes the module's state from a provided genesis state.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) {
k.SetParams(ctx, genState.Params)
// Validate all other genesis fields are empty
if len(genState.RollappPackets) != 0 {
panic("Only params can be initialized at genesis")
for _, packet := range genState.RollappPackets {
k.SetRollappPacket(ctx, packet)
}
}

Expand Down
5 changes: 4 additions & 1 deletion x/delayedack/types/genesis.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package types

import commontypes "github.com/dymensionxyz/dymension/v3/x/common/types"

// DefaultIndex is the default global index
const DefaultIndex uint64 = 1

// DefaultGenesis returns the default genesis state
func DefaultGenesis() *GenesisState {
return &GenesisState{
Params: DefaultParams(),
Params: DefaultParams(),
RollappPackets: []commontypes.RollappPacket{},
}
}

Expand Down
11 changes: 8 additions & 3 deletions x/eibc/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ import (
// InitGenesis initializes the module's state from a provided genesis state.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) {
k.SetParams(ctx, genState.Params)
// Validate all other genesis fields are empty
if len(genState.DemandOrders) != 0 {
panic("Only params can be initialized at genesis")
// Add the demand orders
for _, demandOrder := range genState.DemandOrders {
// Create a copy of demandOrder to avoid reusing the same memory address
demandOrderCopy := demandOrder
err := k.SetDemandOrder(ctx, &demandOrderCopy)
if err != nil {
panic(err)
}
}
}

Expand Down

0 comments on commit d218993

Please sign in to comment.