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

feat: fetch ra rpc from chain when not provided #1141

Merged
merged 1 commit into from
Nov 28, 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
19 changes: 18 additions & 1 deletion cmd/eibc/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/dymensionxyz/roller/utils/keys"
"github.com/dymensionxyz/roller/utils/rollapp"
"github.com/dymensionxyz/roller/utils/roller"
sequencerutils "github.com/dymensionxyz/roller/utils/sequencer"
"github.com/dymensionxyz/roller/utils/templates"
"github.com/dymensionxyz/roller/utils/tx"
)
Expand Down Expand Up @@ -359,12 +360,28 @@ func Cmd() *cobra.Command {
for {
// Prompt the user for the RPC URL
rpc, _ = pterm.DefaultInteractiveTextInput.WithDefaultText(
"dymint rpc endpoint that you trust (example: rpc.rollapp.dym.xyz)",
"dymint rpc endpoint that you trust, leave empty to fetch from chain (example: rpc.rollapp.dym.xyz)",
).Show()
if !strings.HasPrefix(rpc, "http://") && !strings.HasPrefix(rpc, "https://") {
rpc = "https://" + rpc
}

if strings.TrimSpace(rpc) == "" {
rpc, err = sequencerutils.GetRpcEndpointFromChain(raID, hd)
if err != nil {
pterm.Error.Println("failed to retrieve rollapp rpc endpoint: ", err)
rpc, _ = pterm.DefaultInteractiveTextInput.WithDefaultText(
"can't fetch rpc endpoint from chain, provide manually (example: rpc.rollapp.dym.xyz)",
).Show()
if !strings.HasPrefix(rpc, "http://") &&
!strings.HasPrefix(rpc, "https://") {
rpc = "https://" + rpc
}
}
}

rpc = strings.TrimSuffix(rpc, "/")

isValid := config.IsValidURL(rpc)

if !isValid {
Expand Down
1 change: 1 addition & 0 deletions cmd/relayer/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ func getPreRunInfo(home string) (*consts.RollappData, *consts.HubData, string, e
pterm.Error.Println("failed to retrieve rollapp rpc endpoint: ", err)
return nil, nil, "", err
}
raRpc = strings.TrimSuffix(raRpc, "/")

raData := consts.RollappData{
ID: raID,
Expand Down
Loading