diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 66c225c..d6189a0 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -60,6 +60,11 @@ jobs: run: | cd eigenlayer-cli echo "" | ./bin/eigenlayer operator update tests/keystore/operator-ci.yaml + + - name: Update operator metadata uri + run: | + cd eigenlayer-cli + echo "" | ./bin/eigenlayer operator update-metadata-uri tests/keystore/operator-ci.yaml Web3Signer: name: Integration Test - Web3 Signer runs-on: ubuntu-latest @@ -118,4 +123,9 @@ jobs: - name: Update operator details run: | cd eigenlayer-cli - echo "HhzcmbpkHCQpvBlXrvLB" | ./bin/eigenlayer operator update tests/web3signer/operator-ci.yaml \ No newline at end of file + echo "HhzcmbpkHCQpvBlXrvLB" | ./bin/eigenlayer operator update tests/web3signer/operator-ci.yaml + + - name: Update operator metadata uri + run: | + cd eigenlayer-cli + echo "HhzcmbpkHCQpvBlXrvLB" | ./bin/eigenlayer operator update-metadata-uri tests/web3signer/operator-ci.yaml \ No newline at end of file diff --git a/pkg/operator.go b/pkg/operator.go index 4418695..c08f872 100644 --- a/pkg/operator.go +++ b/pkg/operator.go @@ -16,6 +16,7 @@ func OperatorCmd(p utils.Prompter) *cli.Command { operator.RegisterCmd(p), operator.StatusCmd(p), operator.UpdateCmd(p), + operator.UpdateMetadataURICmd(p), operator.SetClaimerCmd(p), }, } diff --git a/pkg/operator/update.go b/pkg/operator/update.go index af3c8c2..7cc9449 100644 --- a/pkg/operator/update.go +++ b/pkg/operator/update.go @@ -23,16 +23,16 @@ import ( func UpdateCmd(p utils.Prompter) *cli.Command { updateCmd := &cli.Command{ Name: "update", - Usage: "Update the operator metadata onchain", + Usage: "Update the operator details onchain", UsageText: "update ", Description: ` - Updates the operator metadata onchain which includes - - metadata url - - delegation approver address - - earnings receiver address - - staker opt out window blocks +Updates the operator metadata onchain which includes + - delegation approver address + - earnings receiver address + - staker opt out window blocks - Requires the same file used for registration as argument +Requires the same file used for registration as argument +This command only updates above details. To update metadata URI, use eigenlayer operator update-metadata-uri command `, After: telemetry.AfterRunAction(), Action: func(cCtx *cli.Context) error { @@ -106,7 +106,7 @@ func UpdateCmd(p utils.Prompter) *cli.Command { ) fmt.Printf( - "%s Operator updated successfully. There is a 30 minute delay between update and operator details being shown in our webapp.\n", + "%s Operator details updated successfully. There is a 30 minute delay between update and operator details being shown in our webapp.\n", utils.EmojiCheckMark, ) return nil diff --git a/pkg/operator/update_metadata_uri.go b/pkg/operator/update_metadata_uri.go new file mode 100644 index 0000000..d7875fc --- /dev/null +++ b/pkg/operator/update_metadata_uri.go @@ -0,0 +1,114 @@ +package operator + +import ( + "context" + "fmt" + "os" + + "github.com/Layr-Labs/eigenlayer-cli/pkg/common" + "github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry" + "github.com/Layr-Labs/eigenlayer-cli/pkg/utils" + + elContracts "github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts" + "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" + "github.com/Layr-Labs/eigensdk-go/chainio/txmgr" + eigensdkLogger "github.com/Layr-Labs/eigensdk-go/logging" + eigenMetrics "github.com/Layr-Labs/eigensdk-go/metrics" + + gethcommon "github.com/ethereum/go-ethereum/common" + + "github.com/urfave/cli/v2" +) + +func UpdateMetadataURICmd(p utils.Prompter) *cli.Command { + updateMetadataURICmd := &cli.Command{ + Name: "update-metadata-uri", + Usage: "Update the operator metadata uri onchain", + UsageText: "update-metadata-uri ", + Description: ` +Updates the operator metadata uri onchain + +Requires the same file used for registration as argument + `, + After: telemetry.AfterRunAction(), + Action: func(cCtx *cli.Context) error { + args := cCtx.Args() + if args.Len() != 1 { + return fmt.Errorf("%w: accepts 1 arg, received %d", ErrInvalidNumberOfArgs, args.Len()) + } + + configurationFilePath := args.Get(0) + operatorCfg, err := common.ValidateAndReturnConfig(configurationFilePath) + if err != nil { + return err + } + cCtx.App.Metadata["network"] = operatorCfg.ChainId.String() + + fmt.Printf( + "\r%s Operator configuration file validated successfully %s\n", + utils.EmojiCheckMark, + operatorCfg.Operator.Address, + ) + + logger := eigensdkLogger.NewTextSLogger(os.Stdout, &eigensdkLogger.SLoggerOptions{}) + + ethClient, err := eth.NewClient(operatorCfg.EthRPCUrl) + if err != nil { + return err + } + + keyWallet, sender, err := common.GetWallet( + operatorCfg.SignerConfig, + operatorCfg.Operator.Address, + ethClient, + p, + operatorCfg.ChainId, + logger, + ) + if err != nil { + return err + } + + txMgr := txmgr.NewSimpleTxManager(keyWallet, ethClient, logger, sender) + noopMetrics := eigenMetrics.NewNoopMetrics() + elWriter, err := elContracts.NewWriterFromConfig( + elContracts.Config{ + DelegationManagerAddress: gethcommon.HexToAddress(operatorCfg.ELDelegationManagerAddress), + AvsDirectoryAddress: gethcommon.HexToAddress(operatorCfg.ELAVSDirectoryAddress), + }, + ethClient, + logger, + noopMetrics, + txMgr, + ) + + if err != nil { + return err + } + + receipt, err := elWriter.UpdateMetadataURI(context.Background(), operatorCfg.Operator.MetadataUrl) + if err != nil { + fmt.Printf("%s Error while updating operator metadata uri\n", utils.EmojiCrossMark) + return err + } + fmt.Printf( + "%s Operator metadata uri updated at: %s\n", + utils.EmojiCheckMark, + common.GetTransactionLink(receipt.TxHash.String(), &operatorCfg.ChainId), + ) + common.PrintRegistrationInfo( + "", + gethcommon.HexToAddress(operatorCfg.Operator.Address), + &operatorCfg.ChainId, + ) + + fmt.Printf( + "%s Operator metadata uri successfully. There is a 30 minute delay between update and operator metadata being shown in our webapp.\n", + utils.EmojiCheckMark, + ) + return nil + }, + } + + return updateMetadataURICmd +}