-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support set claimer * add new commit * disable it for mainnet * correct tabs
- Loading branch information
1 parent
f57d0da
commit 6c239d2
Showing
9 changed files
with
196 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package operator | ||
|
||
import "github.com/urfave/cli/v2" | ||
|
||
var ( | ||
ConfigurationFilePathFlag = cli.StringFlag{ | ||
Name: "configuration-file", | ||
Aliases: []string{"c"}, | ||
Usage: "Path to the configuration file", | ||
Required: true, | ||
EnvVars: []string{"NODE_OPERATOR_CONFIG_FILE"}, | ||
} | ||
|
||
ClaimerAddressFlag = cli.StringFlag{ | ||
Name: "claimer-address", | ||
Aliases: []string{"a"}, | ||
Usage: "Address of the claimer", | ||
Required: true, | ||
EnvVars: []string{"NODE_OPERATOR_CLAIMER_ADDRESS"}, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package operator | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry" | ||
"github.com/Layr-Labs/eigenlayer-cli/pkg/utils" | ||
|
||
"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" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
|
||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func SetClaimerCmd(p utils.Prompter) *cli.Command { | ||
setClaimerCmd := &cli.Command{ | ||
Name: "set-claimer", | ||
Usage: "Set the claimer address for the operator", | ||
UsageText: "set-claimer", | ||
Description: ` | ||
Set the rewards claimer address for the operator. | ||
`, | ||
After: telemetry.AfterRunAction(), | ||
Flags: []cli.Flag{ | ||
&ConfigurationFilePathFlag, | ||
&ClaimerAddressFlag, | ||
}, | ||
Action: func(cCtx *cli.Context) error { | ||
configurationFilePath := cCtx.String(ConfigurationFilePathFlag.Name) | ||
claimerAddress := cCtx.String(ClaimerAddressFlag.Name) | ||
|
||
operatorCfg, err := validateAndReturnConfig(configurationFilePath) | ||
if err != nil { | ||
return err | ||
} | ||
cCtx.App.Metadata["network"] = operatorCfg.ChainId.String() | ||
if operatorCfg.ChainId.Int64() == utils.MainnetChainId { | ||
return fmt.Errorf("set claimer currently unsupported on mainnet") | ||
} | ||
|
||
logger, err := eigensdkLogger.NewZapLogger(eigensdkLogger.Development) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
ethClient, err := eth.NewClient(operatorCfg.EthRPCUrl) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
keyWallet, sender, err := getWallet(operatorCfg, ethClient, p, logger) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
txMgr := txmgr.NewSimpleTxManager(keyWallet, ethClient, logger, sender) | ||
|
||
noopMetrics := eigenMetrics.NewNoopMetrics() | ||
|
||
contractCfg := elcontracts.Config{ | ||
DelegationManagerAddress: common.HexToAddress(operatorCfg.ELDelegationManagerAddress), | ||
AvsDirectoryAddress: common.HexToAddress(operatorCfg.ELAVSDirectoryAddress), | ||
RewardsCoordinatorAddress: common.HexToAddress(operatorCfg.ELRewardsCoordinatorAddress), | ||
} | ||
fmt.Println(operatorCfg) | ||
|
||
elWriter, err := elcontracts.NewWriterFromConfig(contractCfg, ethClient, logger, noopMetrics, txMgr) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
receipt, err := elWriter.SetClaimerFor(context.Background(), common.HexToAddress(claimerAddress)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Printf( | ||
"%s Claimer address %s set successfully for operator %s\n", | ||
utils.EmojiCheckMark, | ||
claimerAddress, | ||
operatorCfg.Operator.Address, | ||
) | ||
|
||
printRegistrationInfo( | ||
receipt.TxHash.String(), | ||
common.HexToAddress(operatorCfg.Operator.Address), | ||
&operatorCfg.ChainId, | ||
) | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
return setClaimerCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package types | ||
|
||
type ChainMetadata struct { | ||
BlockExplorerUrl string | ||
ELDelegationManagerAddress string | ||
ELAVSDirectoryAddress string | ||
WebAppUrl string | ||
BlockExplorerUrl string | ||
ELDelegationManagerAddress string | ||
ELAVSDirectoryAddress string | ||
ELRewardsCoordinatorAddress string | ||
WebAppUrl string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.