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

fix: Use gmp module account as relayer address in handler #344

Merged
merged 5 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions app/gmpmiddleware/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/ojo-network/ojo/x/gmp/types"
)

Expand All @@ -19,6 +20,8 @@ type GmpHandler struct {
gmp GmpKeeper
}

var relayer = authtypes.NewModuleAddress(types.ModuleName).String()

func NewGmpHandler(k GmpKeeper) *GmpHandler {
return &GmpHandler{
gmp: k,
Expand Down Expand Up @@ -52,8 +55,9 @@ func (h GmpHandler) HandleGeneralMessage(
if err != nil {
return err
}
ctx.Logger().Info("HandleGeneralMessage GMP Decoder", "msg", msg)
tx := &types.MsgRelayPrice{
Relayer: srcAddress,
Relayer: relayer,
DestinationChain: srcChain,
ClientContractAddress: msg.ContractAddress.Hex(),
OjoContractAddress: srcAddress,
Expand All @@ -66,7 +70,7 @@ func (h GmpHandler) HandleGeneralMessage(
if err != nil {
return err
}

ctx.Logger().Info("HandleGeneralMessage GMP Decoder", "tx", tx)
_, err = h.gmp.RelayPrice(ctx, tx)
return err
}
Expand Down Expand Up @@ -99,8 +103,9 @@ func (h GmpHandler) HandleGeneralMessageWithToken(
if err != nil {
return err
}
ctx.Logger().Info("HandleGeneralMessageWithToken GMP Decoder", "msg", msg)
tx := &types.MsgRelayPrice{
Relayer: srcAddress,
Relayer: relayer,
DestinationChain: srcChain,
ClientContractAddress: msg.ContractAddress.Hex(),
OjoContractAddress: srcAddress,
Expand All @@ -114,6 +119,7 @@ func (h GmpHandler) HandleGeneralMessageWithToken(
if err != nil {
return err
}
ctx.Logger().Info("HandleGeneralMessage GMP Decoder", "tx", tx)
_, err = h.gmp.RelayPrice(ctx, tx)
return err
}
11 changes: 11 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (app App) RegisterUpgradeHandlers() {
app.registerUpgrade0_3_0Rc3(upgradeInfo)
app.registerUpgrade0_3_0Rc4(upgradeInfo)
app.registerUpgrade0_3_0Rc5(upgradeInfo)
app.registerUpgrade0_3_0Rc6(upgradeInfo)
}

// performs upgrade from v0.1.3 to v0.1.4
Expand Down Expand Up @@ -194,6 +195,16 @@ func (app *App) registerUpgrade0_3_0Rc5(_ upgradetypes.Plan) {
)
}

func (app *App) registerUpgrade0_3_0Rc6(_ upgradetypes.Plan) {
const planName = "v0.3.0-rc6"
app.UpgradeKeeper.SetUpgradeHandler(planName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Upgrade handler execution", "name", planName)
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
},
)
}

// helper function to check if the store loader should be upgraded
func (app *App) storeUpgrade(planName string, ui upgradetypes.Plan, stores storetypes.StoreUpgrades) {
if ui.Name == planName && !app.UpgradeKeeper.IsSkipHeight(ui.Height) {
Expand Down
Loading