Skip to content

Commit

Permalink
fix: Use gmp module account as relayer address in handler (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari authored Dec 27, 2023
1 parent 5cc3e92 commit 96c089c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
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

0 comments on commit 96c089c

Please sign in to comment.