Skip to content

Commit

Permalink
add update metadata uri command (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur authored Jul 6, 2024
1 parent 88433c3 commit 3074226
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 9 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -118,4 +123,9 @@ jobs:
- name: Update operator details
run: |
cd eigenlayer-cli
echo "HhzcmbpkHCQpvBlXrvLB" | ./bin/eigenlayer operator update tests/web3signer/operator-ci.yaml
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
1 change: 1 addition & 0 deletions pkg/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/operator/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <configuration-file>",
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 {
Expand Down Expand Up @@ -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
Expand Down
114 changes: 114 additions & 0 deletions pkg/operator/update_metadata_uri.go
Original file line number Diff line number Diff line change
@@ -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 <configuration-file>",
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
}

0 comments on commit 3074226

Please sign in to comment.