Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typo and update Validate() of BridgeConfig #25

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading