From e7e014cc38f4506226cafa9b80e9b6e67f2294df Mon Sep 17 00:00:00 2001 From: Vritra4 Date: Tue, 13 Feb 2024 12:27:24 +0900 Subject: [PATCH] fix typo and update Validate() of BridgeConfig --- x/ophost/client/cli/tx.go | 1 - x/ophost/client/cli/types.go | 2 +- x/ophost/types/bridge_config.go | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/x/ophost/client/cli/tx.go b/x/ophost/client/cli/tx.go index 5c0b132a..ea7fa007 100644 --- a/x/ophost/client/cli/tx.go +++ b/x/ophost/client/cli/tx.go @@ -139,7 +139,6 @@ func NewCreateBridge(ac address.Codec) *cobra.Command { return err } - fmt.Println("SIBONG", origConfig) config := types.BridgeConfig{ Challenger: origConfig.Challenger, Proposer: origConfig.Proposer, diff --git a/x/ophost/client/cli/types.go b/x/ophost/client/cli/types.go index 226a2523..d94ae14e 100644 --- a/x/ophost/client/cli/types.go +++ b/x/ophost/client/cli/types.go @@ -22,7 +22,7 @@ type BridgeConfig struct { // MsgFinalizeTokenWithdrawal is a message to remove a validator from designated list // -// NOTE: it is a modified MsgFinalizeTokenWithdrawal from x/ophost/types/txpb.go to make unmarshal easier +// NOTE: it is a modified MsgFinalizeTokenWithdrawal from x/ophost/types/tx.pb.go to make unmarshal easier type MsgFinalizeTokenWithdrawal struct { BridgeId uint64 `protobuf:"varint,2,opt,name=bridge_id,json=bridgeId,proto3" json:"bridge_id,omitempty" yaml:"bridge_id"` OutputIndex uint64 `protobuf:"varint,3,opt,name=output_index,json=outputIndex,proto3" json:"output_index,omitempty" yaml:"output_index"` diff --git a/x/ophost/types/bridge_config.go b/x/ophost/types/bridge_config.go index ae389936..42a55160 100644 --- a/x/ophost/types/bridge_config.go +++ b/x/ophost/types/bridge_config.go @@ -1,7 +1,11 @@ package types import ( + time "time" + "cosmossdk.io/core/address" + "cosmossdk.io/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) func (config BridgeConfig) Validate(ac address.Codec) error { @@ -13,5 +17,17 @@ func (config BridgeConfig) Validate(ac address.Codec) error { return err } + if config.FinalizationPeriod == time.Duration(0) { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "finalization period must be greater than 0") + } + + if config.SubmissionInterval == time.Duration(0) { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "submission interval must be greater than 0") + } + + if config.SubmissionStartTime.IsZero() { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "submission start time must be set") + } + return nil }