diff --git a/cmd/eibc/fulfill/feeshare/feeshare.go b/cmd/eibc/fulfill/feeshare/feeshare.go index 5235b8c8a..c576c2ca7 100644 --- a/cmd/eibc/fulfill/feeshare/feeshare.go +++ b/cmd/eibc/fulfill/feeshare/feeshare.go @@ -26,10 +26,10 @@ func Cmd() *cobra.Command { return } - if err != nil { - pterm.Error.Println("failed to expand home directory") - return - } + // if err != nil { + // pterm.Error.Println("failed to expand home directory") + // return + // } eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc) eibcConfigPath := filepath.Join(eibcHome, "config.yaml") diff --git a/cmd/eibc/init/init.go b/cmd/eibc/init/init.go index 71474cf67..bc337fa53 100644 --- a/cmd/eibc/init/init.go +++ b/cmd/eibc/init/init.go @@ -373,6 +373,8 @@ func setupEibcClient(hd consts.HubData, eibcHome string, ki *keys.KeyInfo) error rpc = strings.TrimSuffix(rpc, "/") + // Add :443 to HTTPS URLs if no port is specified + rpc = config.AddHttpsPortIfNeeded(rpc) isValid := config.IsValidURL(rpc) if !isValid { @@ -433,13 +435,13 @@ func initializeEibcForEnvironment() (consts.HubData, error) { var rollerConfig roller.RollappConfig hdid, _ := pterm.DefaultInteractiveTextInput.WithDefaultText("provide hub chain id"). Show() - hdrpc, _ := pterm.DefaultInteractiveTextInput.WithDefaultText("provide hub rpc endpoint"). + hdrpc, _ := pterm.DefaultInteractiveTextInput.WithDefaultText("provide hub rpc endpoint (example: https://hub.dym.xyz:443)"). Show() hdws, _ := pterm.DefaultInteractiveTextInput.WithDefaultText("provide hub websocket endpoint, only fill this in when RPC and WebSocket are separate (optional)"). Show() rollerConfig.HubData.ID = hdid - rollerConfig.HubData.RpcUrl = hdrpc + rollerConfig.HubData.RpcUrl = config.AddHttpsPortIfNeeded(hdrpc) if hdws == "" { rollerConfig.HubData.WsUrl = hdrpc diff --git a/cmd/rollapp/setup/setup.go b/cmd/rollapp/setup/setup.go index c6c994cd5..200fb8a87 100644 --- a/cmd/rollapp/setup/setup.go +++ b/cmd/rollapp/setup/setup.go @@ -1185,6 +1185,9 @@ func populateSequencerMetadata(raCfg roller.RollappConfig) error { rpc = "https://" + rpc } + // Add :443 to HTTPS URLs if no port is specified + rpc = config.AddHttpsPortIfNeeded(rpc) + isValid := config.IsValidURL(rpc) // Validate the URL @@ -1205,6 +1208,9 @@ func populateSequencerMetadata(raCfg roller.RollappConfig) error { rest = "https://" + rest } + // Add :443 to HTTPS URLs if no port is specified + rest = config.AddHttpsPortIfNeeded(rest) + isValid := config.IsValidURL(rest) // Validate the URL @@ -1226,6 +1232,9 @@ func populateSequencerMetadata(raCfg roller.RollappConfig) error { evmRpc = "https://" + evmRpc } + // Add :443 to HTTPS URLs if no port is specified + evmRpc = config.AddHttpsPortIfNeeded(evmRpc) + isValid := config.IsValidURL(evmRpc) // Validate the URL diff --git a/utils/config/prompts.go b/utils/config/prompts.go index 837e7e7da..ba51333b4 100644 --- a/utils/config/prompts.go +++ b/utils/config/prompts.go @@ -1,6 +1,7 @@ package config import ( + "net/url" "strings" "github.com/pterm/pterm" @@ -9,6 +10,18 @@ import ( "github.com/dymensionxyz/roller/utils/roller" ) +// AddHttpsPortIfNeeded appends :443 to HTTPS URLs that don't already have a port specified +func AddHttpsPortIfNeeded(rawurl string) string { + u, err := url.Parse(rawurl) + if err != nil || u.Scheme != "https" { + return rawurl + } + if !strings.Contains(u.Host, ":") { + u.Host = u.Host + ":443" + } + return u.String() +} + func PromptVmType() string { vmtypes := []string{"evm", "wasm"} vmtype, _ := pterm.DefaultInteractiveSelect. @@ -50,6 +63,9 @@ func PromptCustomHubEndpoint(rollerConfig roller.RollappConfig) roller.RollappCo rpcEndpoint, _ = pterm.DefaultInteractiveTextInput.WithDefaultText("We recommend using a private RPC endpoint for the hub. Please provide the hub rpc endpoint to use. You can obtain one here: https://blastapi.io/chains/dymension"). Show() + // Add :443 to HTTPS URLs if no port is specified + rpcEndpoint = AddHttpsPortIfNeeded(rpcEndpoint) + isValidUrl := IsValidURL(rpcEndpoint) if isValidUrl { break