Skip to content

Commit

Permalink
add more prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Aug 28, 2024
1 parent 295e67b commit f4ecc01
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
17 changes: 13 additions & 4 deletions contrib/launchtools/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ type OpBridge struct {
BatchSubmissionTarget ophosttypes.BatchInfo_ChainType `json:"batch_submission_target"`

// oracle setup
EnableOracle bool `json:"enable_oracle,omitempty"`
EnableOracle *bool `json:"enable_oracle,omitempty"`
}

func (opBridge *OpBridge) Finalize(buf *bufio.Reader) error {
Expand All @@ -128,7 +128,16 @@ func (opBridge *OpBridge) Finalize(buf *bufio.Reader) error {
}

if opBridge.BatchSubmissionTarget == ophosttypes.BatchInfo_CHAIN_TYPE_UNSPECIFIED {
opBridge.BatchSubmissionTarget = ophosttypes.BatchInfo_CHAIN_TYPE_INITIA
useCelestia, err := input.GetConfirmation("Use Celestia as DA layer?", buf, os.Stderr)
if err != nil {
return err
}

if useCelestia {
opBridge.BatchSubmissionTarget = ophosttypes.BatchInfo_CHAIN_TYPE_CELESTIA
} else {
opBridge.BatchSubmissionTarget = ophosttypes.BatchInfo_CHAIN_TYPE_INITIA
}
}

if opBridge.OutputSubmissionInterval == nil {
Expand All @@ -141,13 +150,13 @@ func (opBridge *OpBridge) Finalize(buf *bufio.Reader) error {
opBridge.OutputFinalizationPeriod = &period
}

if !opBridge.EnableOracle {
if opBridge.EnableOracle == nil {
enableOracle, err := input.GetConfirmation("Enable oracle?", buf, os.Stderr)
if err != nil {
return err
}

opBridge.EnableOracle = enableOracle
opBridge.EnableOracle = &enableOracle
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion contrib/launchtools/steps/opbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func InitializeOpBridge(
*config.OpBridge.OutputSubmissionInterval,
*config.OpBridge.OutputFinalizationPeriod,
config.OpBridge.OutputSubmissionStartHeight,
config.OpBridge.EnableOracle,
*config.OpBridge.EnableOracle,
)

ctx.Logger().Info("creating op bridge...", "message", createOpBridgeMessage.String())
Expand Down
7 changes: 3 additions & 4 deletions x/ophost/types/hook/bridge_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"

"cosmossdk.io/collections"
"cosmossdk.io/core/address"
sdk "github.com/cosmos/cosmos-sdk/types"

Expand Down Expand Up @@ -70,10 +69,10 @@ func (h BridgeHook) BridgeCreated(
}

// check if the channel has a permissioned relayer
if _, err := h.IBCPermKeeper.GetPermissionedRelayers(ctx, portID, channelID); err == nil {
return channeltypes.ErrChannelExists.Wrap("cannot register permissioned relayers for the channel in use")
} else if !errors.Is(err, collections.ErrNotFound) {
if relayers, err := h.IBCPermKeeper.GetPermissionedRelayers(ctx, portID, channelID); err != nil {
return err
} else if len(relayers) > 0 {
return channeltypes.ErrChannelExists.Wrap("cannot register permissioned relayers for the channel in use")
}

// register challengers as channel relayer
Expand Down

0 comments on commit f4ecc01

Please sign in to comment.