Skip to content

Commit

Permalink
fix typo and update Validate() of BridgeConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Vritra4 committed Feb 13, 2024
1 parent be17848 commit e7e014c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 0 additions & 1 deletion x/ophost/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion x/ophost/client/cli/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
16 changes: 16 additions & 0 deletions x/ophost/types/bridge_config.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
}

0 comments on commit e7e014c

Please sign in to comment.