Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez committed Jul 12, 2023
1 parent 38b3df4 commit 51c9a2e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ func New(
//
// example: app.HardForkManager.RegisterHandler(myHandler)
app.HardForkManager = upgrades.NewHardForkManager(app.ChainID)
app.HardForkManager.RegisterHandler(v0upgrade.NewHardForkUpgradeHandler(100_000, app.ChainID, app.WasmKeeper))
app.HardForkManager.RegisterHandler(v0upgrade.NewHardForkUpgradeHandler(100_000, upgrades.ChainIDSeiHardForkTest, app.WasmKeeper))

return app
}
Expand Down
5 changes: 5 additions & 0 deletions app/upgrades/fork_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import (
"github.com/sei-protocol/goutils"
)

// Chain-ID constants for use in hard fork handlers.
const (
ChainIDSeiHardForkTest = "sei-hard-fork-test"
)

type HardForkHandler interface {
// a unique identifying name to ensure no duplicate handlers are registered
GetName() string
Expand Down
20 changes: 19 additions & 1 deletion app/upgrades/v0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,25 @@ func (h HardForkUpgradeHandler) GetTargetHeight() int64 {

func (h HardForkUpgradeHandler) ExecuteHandler(ctx sdk.Context) error {
govKeeper := wasmkeeper.NewGovPermissionKeeper(h.WasmKeeper)
_, err := govKeeper.Migrate(ctx, nil, nil, nil, nil)
return h.migrateGringotts(ctx, govKeeper)
}

func (h HardForkUpgradeHandler) migrateGringotts(ctx sdk.Context, govKeeper *wasmkeeper.PermissionedKeeper) error {
var (
contractAddr sdk.AccAddress
newCodeID uint64
msg []byte
)

switch h.TargetChainID {
case upgrades.ChainIDSeiHardForkTest:
// TODO: ...

default:
return fmt.Errorf("unknown chain ID: %s", h.TargetChainID)
}

_, err := govKeeper.Migrate(ctx, contractAddr, sdk.AccAddress{}, newCodeID, msg)
if err != nil {
return fmt.Errorf("failed to execute wasm migration: %w", err)
}
Expand Down

0 comments on commit 51c9a2e

Please sign in to comment.