Skip to content

Commit

Permalink
feat: make it possible to fill out the moniker and social media links…
Browse files Browse the repository at this point in the history
… for sequencer (#923)
  • Loading branch information
artemijspavlovs authored Sep 12, 2024
1 parent c5d3912 commit a8cf922
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
25 changes: 24 additions & 1 deletion cmd/rollapp/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -915,10 +915,33 @@ func populateSequencerMetadata(raCfg config.RollappConfig) error {
sm.RestApiUrls = append(sm.RestApiUrls, rest)
sm.EvmRpcs = append(sm.EvmRpcs, evmRpc)

_, _ = pterm.DefaultInteractiveConfirm.WithDefaultText(
shouldFillOptionalFields, _ := pterm.DefaultInteractiveConfirm.WithDefaultText(
"Would you also like to fill optional metadata for your sequencer?",
).Show()

if shouldFillOptionalFields {
displayName, _ := pterm.DefaultInteractiveTextInput.WithDefaultText(
"provide a display name for your sequencer",
).Show()
x, _ := pterm.DefaultInteractiveTextInput.WithDefaultText(
"provide a link to your X or as old people call it, twitter",
).Show()
website, _ := pterm.DefaultInteractiveTextInput.WithDefaultText(
"provide a link to your website",
).Show()
if !strings.HasPrefix(website, "http://") && !strings.HasPrefix(website, "https://") {
website = "https://" + website
}
telegram, _ := pterm.DefaultInteractiveTextInput.WithDefaultText(
"provide a link to your X or as old people call it, twitter",
).Show()

sm.ContactDetails.X = x
sm.ContactDetails.Website = website
sm.ContactDetails.Telegram = telegram
sm.Moniker = displayName
}

err := WriteStructToJSONFile(&sm, path)
if err != nil {
return err
Expand Down
12 changes: 10 additions & 2 deletions utils/sequencer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

cosmossdkmath "cosmossdk.io/math"
cosmossdktypes "github.com/cosmos/cosmos-sdk/types"
dymensionseqtypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types"
"github.com/gogo/protobuf/types"
)

Expand Down Expand Up @@ -59,7 +58,7 @@ type Metadata struct {
GenesisUrls []string `json:"genesis_urls"`
// contact details
// nolint:govet,staticcheck
ContactDetails *dymensionseqtypes.ContactDetails `json:"contact_details"`
ContactDetails *ContactDetails `json:"contact_details"`
// json dump the sequencer can add (limited by size)
ExtraData []byte `json:"extra_data"`
// snapshots of the sequencer
Expand All @@ -69,6 +68,15 @@ type Metadata struct {
GasPrice *cosmossdkmath.Int `json:"gas_price"`
}

type ContactDetails struct {
// website URL
Website string `json:"website"`
// telegram link
Telegram string `json:"telegram"`
// twitter link
X string `json:"x"`
}

type SnapshotInfo struct {
// the snapshot url
SnapshotUrl string `protobuf:"bytes,1,opt,name=snapshot_url,json=snapshotUrl,proto3" json:"snapshot_url,omitempty"`
Expand Down
4 changes: 1 addition & 3 deletions utils/structs/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"os"

cosmossdkmath "cosmossdk.io/math"
dymensionseqtypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types"

sequencerutils "github.com/dymensionxyz/roller/utils/sequencer"
)

Expand Down Expand Up @@ -37,7 +35,7 @@ func InitializeMetadata(m sequencerutils.Metadata) {
m.GenesisUrls = []string{}
}
if m.ContactDetails == nil {
m.ContactDetails = &dymensionseqtypes.ContactDetails{}
m.ContactDetails = &sequencerutils.ContactDetails{}
}
if m.ExtraData == nil {
m.ExtraData = []byte{}
Expand Down

0 comments on commit a8cf922

Please sign in to comment.