Skip to content

Commit

Permalink
Merge pull request #25 from initia-labs/chore-fix
Browse files Browse the repository at this point in the history
fix typo and update Validate() of BridgeConfig
  • Loading branch information
beer-1 authored Feb 26, 2024
2 parents d7ae15f + e7e014c commit 77c1e0b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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 77c1e0b

Please sign in to comment.