Skip to content

Commit

Permalink
better display messages after operator registration (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed May 22, 2024
1 parent ef1f5cb commit dde52bb
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 5 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/Layr-Labs/eigensdk-go v0.1.7-0.20240506234104-06805a99d717
github.com/ethereum/go-ethereum v1.14.0
github.com/fatih/color v1.13.0
github.com/stretchr/testify v1.9.0
github.com/urfave/cli/v2 v2.27.2
github.com/wagslane/go-password-validator v0.3.0
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHE
github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/ethereum/go-ethereum v1.14.0 h1:xRWC5NlB6g1x7vNy4HDBLuqVNbtLrc7v8S6+Uxim1LU=
github.com/ethereum/go-ethereum v1.14.0/go.mod h1:1STrq471D0BQbCX9He0hUj4bHxX2k6mt5nOQJhDNOJ8=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
Expand Down Expand Up @@ -184,9 +186,12 @@ github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
Expand Down Expand Up @@ -309,8 +314,11 @@ golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
32 changes: 27 additions & 5 deletions pkg/operator/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strings"
"time"

"github.com/fatih/color"

"github.com/Layr-Labs/eigensdk-go/aws/secretmanager"

"github.com/Layr-Labs/eigenlayer-cli/pkg/types"
Expand Down Expand Up @@ -113,12 +115,11 @@ func RegisterCmd(p utils.Prompter) *cli.Command {
fmt.Printf("%s Error while registering operator\n", utils.EmojiCrossMark)
return err
}
fmt.Printf(
"%s Operator registration transaction at: %s\n",
utils.EmojiCheckMark,
getTransactionLink(receipt.TxHash.String(), &operatorCfg.ChainId),
printRegistrationInfo(
receipt.TxHash.String(),
common.HexToAddress(operatorCfg.Operator.Address),
&operatorCfg.ChainId,
)

} else {
fmt.Printf("%s Operator is already registered on EigenLayer\n", utils.EmojiCheckMark)
return nil
Expand All @@ -132,6 +133,17 @@ func RegisterCmd(p utils.Prompter) *cli.Command {
return registerCmd
}

func printRegistrationInfo(txHash string, operatorAddress common.Address, chainId *big.Int) {
fmt.Println(strings.Repeat("-", 100))
fmt.Printf("%s Chain ID: %s\n", utils.EmojiLink, chainId.String())
if len(txHash) > 0 {
fmt.Printf("%s Transaction Link: %s\n", utils.EmojiLink, getTransactionLink(txHash, chainId))
}

color.Blue("%s Operator Web App Link: %s\n", utils.EmojiInternet, getWebAppLink(operatorAddress, chainId))
fmt.Println(strings.Repeat("-", 100))
}

func getWallet(
cfg *types.OperatorConfigNew,
ethClient eth.Client,
Expand Down Expand Up @@ -343,6 +355,16 @@ func getTransactionLink(txHash string, chainId *big.Int) string {
}
}

func getWebAppLink(operatorAddress common.Address, chainId *big.Int) string {
chainIDInt := chainId.Int64()
chainMetadata, ok := utils.ChainMetadataMap[chainIDInt]
if !ok {
return ""
} else {
return fmt.Sprintf("%s/%s", chainMetadata.WebAppUrl, operatorAddress.Hex())
}
}

func validateMetadata(operatorCfg *types.OperatorConfigNew) error {
// Raw GitHub URL validation is only for mainnet
if operatorCfg.ChainId.Cmp(big.NewInt(utils.MainnetChainId)) == 0 {
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func StatusCmd(p utils.Prompter) *cli.Command {
return err
}
printOperatorDetails(operatorDetails)
printRegistrationInfo("", common.HexToAddress(operatorCfg.Operator.Address), &operatorCfg.ChainId)
} else {
fmt.Printf("%s Operator is not registered to EigenLayer\n", utils.EmojiCrossMark)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func UpdateCmd(p utils.Prompter) *cli.Command {
utils.EmojiCheckMark,
getTransactionLink(receipt.TxHash.String(), &operatorCfg.ChainId),
)
printRegistrationInfo("", common.HexToAddress(operatorCfg.Operator.Address), &operatorCfg.ChainId)

fmt.Printf("%s Operator updated successfully\n", utils.EmojiCheckMark)
return nil
Expand Down
1 change: 1 addition & 0 deletions pkg/types/chain_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ type ChainMetadata struct {
BlockExplorerUrl string
ELDelegationManagerAddress string
ELAVSDirectoryAddress string
WebAppUrl string
}
2 changes: 2 additions & 0 deletions pkg/utils/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const (
EmojiWarning = "⚠️"
EmojiInfo = "ℹ️"
EmojiWait = "⏳"
EmojiLink = "🔗"
EmojiInternet = "🌐"

MainnetChainId = 1
HoleskyChainId = 17000
Expand Down
3 changes: 3 additions & 0 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ var ChainMetadataMap = map[int64]types.ChainMetadata{
BlockExplorerUrl: "https://etherscan.io/tx",
ELDelegationManagerAddress: "0x39053D51B77DC0d36036Fc1fCc8Cb819df8Ef37A",
ELAVSDirectoryAddress: "0x135dda560e946695d6f155dacafc6f1f25c1f5af",
WebAppUrl: "https://app.eigenlayer.xyz/operator",
},
HoleskyChainId: {
BlockExplorerUrl: "https://holesky.etherscan.io/tx",
ELDelegationManagerAddress: "0xA44151489861Fe9e3055d95adC98FbD462B948e7",
ELAVSDirectoryAddress: "0x055733000064333CaDDbC92763c58BF0192fFeBf",
WebAppUrl: "https://holesky.eigenlayer.xyz/operator",
},
LocalChainId: {
BlockExplorerUrl: "",
ELDelegationManagerAddress: "",
ELAVSDirectoryAddress: "",
WebAppUrl: "",
},
}

Expand Down

0 comments on commit dde52bb

Please sign in to comment.