Skip to content

Commit

Permalink
validate disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mvid committed Jul 7, 2023
1 parent cae2365 commit 0a5659c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions x/axelarcork/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ var _ types.MsgServer = Keeper{}
// ScheduleCork implements types.MsgServer
func (k Keeper) ScheduleCork(c context.Context, msg *types.MsgScheduleAxelarCorkRequest) (*types.MsgScheduleAxelarCorkResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
if !k.GetParamSet(ctx).Enabled {
return nil, types.ErrDisabled
}

config, err := k.GetChainConfigurationByNameAndID(ctx, msg.ChainName, msg.ChainId)
if err != nil {
Expand Down Expand Up @@ -61,6 +64,10 @@ func (k Keeper) RelayCork(c context.Context, msg *types.MsgRelayAxelarCorkReques
ctx := sdk.UnwrapSDKContext(c)
params := k.GetParamSet(ctx)

if !params.Enabled {
return nil, types.ErrDisabled
}

config, err := k.GetChainConfigurationByNameAndID(ctx, msg.ChainName, msg.ChainId)
if err != nil {
return nil, err
Expand Down Expand Up @@ -118,6 +125,10 @@ func (k Keeper) BumpCorkGas(c context.Context, msg *types.MsgBumpAxelarCorkGasRe
ctx := sdk.UnwrapSDKContext(c)
params := k.GetParamSet(ctx)

if !params.Enabled {
return nil, types.ErrDisabled
}

transferMsg := transfertypes.NewMsgTransfer(
params.IbcPort,
params.IbcChannel,
Expand Down
4 changes: 4 additions & 0 deletions x/axelarcork/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func (k Keeper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capability,
}

func (k Keeper) ValidateAxelarCorkPacket(ctx sdk.Context, packet ibcexported.PacketI) error {
if !k.GetParamSet(ctx).Enabled {
return nil
}

// check if this is a call to axelar, exit early if this isn't axelar
channelID := packet.GetDestChannel()
if channelID != k.GetParamSet(ctx).IbcChannel {
Expand Down
1 change: 1 addition & 0 deletions x/axelarcork/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ var (
ErrSchedulingInThePast = sdkerrors.Register(ModuleName, 5, "cork is trying to be scheduled for a block that has already passed")
ErrInvalidJSON = sdkerrors.Register(ModuleName, 6, "invalid json")
ErrValuelessSend = sdkerrors.Register(ModuleName, 7, "transferring an empty token amount")
ErrDisabled = sdkerrors.Register(ModuleName, 8, "axelar disabled")
)

0 comments on commit 0a5659c

Please sign in to comment.