Skip to content

Commit

Permalink
feat: fetch ra rpc from chain when not provided (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs authored Nov 28, 2024
1 parent d1f175d commit 61e6815
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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

0 comments on commit 61e6815

Please sign in to comment.