Skip to content

Bugfix/rewards uam support #294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/internal/command/BaseCommand.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package command

import (
"github.com/urfave/cli/v2"
)

type BaseCommand interface {
Execute(c *cli.Context) error
}
43 changes: 43 additions & 0 deletions pkg/internal/command/NewWriteableCallDataCommand.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package command

import (
"sort"

"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common/flags"
"github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry"

"github.com/urfave/cli/v2"
)

func NewWriteableCallDataCommand(
baseCmd BaseCommand,
name string,
usage string,
usageText string,
description string,
commandFlags []cli.Flag,
) *cli.Command {
withWriteFlags := append(commandFlags, flags.WriteFlags...)
allFlags := append(withWriteFlags, flags.GetSignerFlags()...)
sort.Sort(cli.FlagsByName(allFlags))

command := &cli.Command{
Name: name,
Usage: usage,
Flags: allFlags,
Action: func(cCtx *cli.Context) error {
return baseCmd.Execute(cCtx)
},
After: telemetry.AfterRunAction(),
}

if usageText != "" {
command.UsageText = usageText
}

if description != "" {
command.Description = description
}

return command
}
10 changes: 10 additions & 0 deletions pkg/internal/common/flags/write.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package flags

import "github.com/urfave/cli/v2"

var WriteFlags = []cli.Flag{
&OutputFileFlag,
&OutputTypeFlag,
&CallerAddressFlag,
&BroadcastFlag,
}
18 changes: 18 additions & 0 deletions pkg/internal/common/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,24 @@ func ValidateAndConvertSelectorString(selector string) ([4]byte, error) {
return selectorBytes, nil
}

func PopulateCallerAddress(
cliContext *cli.Context,
logger eigensdkLogger.Logger,
defaultAddress common.Address,
) common.Address {
// TODO: these are copied across both callers of this method. Will clean this up in the CLI refactor of flags.
callerAddress := cliContext.String(flags.CallerAddressFlag.Name)
if IsEmptyString(callerAddress) {
logger.Infof(
"User access management delegation using caller address not invoked. Signing with: %s",
defaultAddress,
)

return defaultAddress
}
return common.HexToAddress(callerAddress)
}

func GetEnvFromNetwork(network string) string {
switch network {
case utils.HoleskyNetworkName:
Expand Down
6 changes: 3 additions & 3 deletions pkg/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ func OperatorCmd(p utils.Prompter) *cli.Command {
operator.UpdateCmd(p),
operator.UpdateMetadataURICmd(p),
operator.GetApprovalCmd(p),
operator.SetOperatorSplitCmd(p),
operator.NewSetOperatorSplitCmd(p, false, false),
operator.GetOperatorSplitCmd(p),
operator.GetOperatorPISplitCmd(p),
operator.SetOperatorPISplitCmd(p),
operator.SetOperatorSetSplitCmd(p),
operator.GetOperatorSetSplitCmd(p),
operator.AllocationsCmd(p),
operator.DeregisterCommand(p),
operator.RegisterOperatorSetsCommand(p),
operator.NewDeregisterOperatorSetsCmd(p),
operator.NewRegisterOperatorSetsCmd(p),
},
}

Expand Down
69 changes: 28 additions & 41 deletions pkg/operator/deregister_operator_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import (
"math"
"strings"

"sort"

"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/command"
"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common"
"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common/flags"
"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"
Expand All @@ -23,28 +21,29 @@ import (
"github.com/urfave/cli/v2"
)

func DeregisterCommand(p utils.Prompter) *cli.Command {
getDeregisterCmd := &cli.Command{
Name: "deregister-operator-sets",
Usage: "Deregister operator from specified operator sets",
UsageText: "deregister-operator-sets [flags]",
Description: `
Deregister operator from operator sets.
This command doesn't automatically deallocate your slashable stake from that operator set so you will have to use the 'operator allocations update' command to deallocate your stake from the operator set.

To find what operator set you are part of, use the 'eigenlayer operator allocations show' command.

`,
Flags: getDeregistrationFlags(),
After: telemetry.AfterRunAction(),
Action: func(context *cli.Context) error {
return deregisterAction(context, p)
},
}
return getDeregisterCmd
type DeregisterOperatorSetsCmd struct {
prompter utils.Prompter
}

func NewDeregisterOperatorSetsCmd(p utils.Prompter) *cli.Command {
delegateCommand := &DeregisterOperatorSetsCmd{prompter: p}
deregisterCmd := command.NewWriteableCallDataCommand(
delegateCommand,
"deregister-operator-sets",
"Deregister operator from specified operator sets",
"deregister-operator-sets [flags]",
`
Deregister operator from operator sets.
This command doesn't automatically deallocate your slashable stake from that operator set so you will have to use the 'operator allocations update' command to deallocate your stake from the operator set.

To find what operator set you are part of, use the 'eigenlayer operator allocations show' command.
`,
getDeregistrationFlags(),
)
return deregisterCmd
}

func deregisterAction(cCtx *cli.Context, p utils.Prompter) error {
func (d DeregisterOperatorSetsCmd) Execute(cCtx *cli.Context) error {
ctx := cCtx.Context
logger := common.GetLogger(cCtx)

Expand Down Expand Up @@ -72,7 +71,7 @@ func deregisterAction(cCtx *cli.Context, p utils.Prompter) error {
elcontracts.Config{
DelegationManagerAddress: config.delegationManagerAddress,
},
p,
d.prompter,
config.chainID,
logger,
)
Expand Down Expand Up @@ -169,12 +168,8 @@ func readAndValidateDeregisterConfig(cCtx *cli.Context, logger logging.Logger) (
broadcast := cCtx.Bool(flags.BroadcastFlag.Name)
isSilent := cCtx.Bool(flags.SilentFlag.Name)

operatorAddress := cCtx.String(flags.OperatorAddressFlag.Name)
callerAddress := cCtx.String(flags.CallerAddressFlag.Name)
if common.IsEmptyString(callerAddress) {
logger.Infof("Caller address not provided. Using operator address (%s) as caller address", operatorAddress)
callerAddress = operatorAddress
}
operatorAddress := gethcommon.HexToAddress(cCtx.String(flags.OperatorAddressFlag.Name))
callerAddress := common.PopulateCallerAddress(cCtx, logger, operatorAddress)
avsAddress := gethcommon.HexToAddress(cCtx.String(flags.AVSAddressFlag.Name))

// Get signerConfig
Expand Down Expand Up @@ -204,8 +199,8 @@ func readAndValidateDeregisterConfig(cCtx *cli.Context, logger logging.Logger) (
config := &DeregisterConfig{
avsAddress: avsAddress,
operatorSetIds: operatorSetIds,
operatorAddress: gethcommon.HexToAddress(operatorAddress),
callerAddress: gethcommon.HexToAddress(callerAddress),
operatorAddress: operatorAddress,
callerAddress: callerAddress,
network: network,
environment: environment,
broadcast: broadcast,
Expand All @@ -222,23 +217,15 @@ func readAndValidateDeregisterConfig(cCtx *cli.Context, logger logging.Logger) (
}

func getDeregistrationFlags() []cli.Flag {
baseFlags := []cli.Flag{
return []cli.Flag{
&flags.NetworkFlag,
&flags.EnvironmentFlag,
&flags.ETHRpcUrlFlag,
&flags.OutputFileFlag,
&flags.OutputTypeFlag,
&flags.BroadcastFlag,
&flags.VerboseFlag,
&flags.AVSAddressFlag,
&flags.OperatorAddressFlag,
&flags.OperatorSetIdsFlag,
&flags.DelegationManagerAddressFlag,
&flags.SilentFlag,
&flags.CallerAddressFlag,
}

allFlags := append(baseFlags, flags.GetSignerFlags()...)
sort.Sort(cli.FlagsByName(allFlags))
return allFlags
}
66 changes: 25 additions & 41 deletions pkg/operator/register_operator_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package operator

import (
"fmt"
"sort"

"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/command"
"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common"
"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common/flags"
"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"
Expand All @@ -20,27 +18,25 @@ import (
"github.com/urfave/cli/v2"
)

func RegisterOperatorSetsCommand(p utils.Prompter) *cli.Command {
registerOperatorSetsCmd := &cli.Command{
Name: "register-operator-sets",
Usage: "register operator from specified operator sets",
UsageText: "register-operator-sets [flags]",
Description: `
register operator sets for operator.

To find what operator set you are registered for, use the 'eigenlayer operator allocations show' command.

`,
Flags: getRegistrationFlags(),
After: telemetry.AfterRunAction(),
Action: func(context *cli.Context) error {
return registerOperatorSetsAction(context, p)
},
}
return registerOperatorSetsCmd
type RegisterOperatorSetCmd struct {
prompter utils.Prompter
}

func NewRegisterOperatorSetsCmd(p utils.Prompter) *cli.Command {
delegateCommand := &RegisterOperatorSetCmd{p}
registerOperatorSetCmd := command.NewWriteableCallDataCommand(
delegateCommand,
"register-operator-sets",
"register operator from specified operator sets",
"register-operator-sets [flags]",
"",
getRegistrationFlags(),
)

return registerOperatorSetCmd
}

func registerOperatorSetsAction(cCtx *cli.Context, p utils.Prompter) error {
func (r RegisterOperatorSetCmd) Execute(cCtx *cli.Context) error {
ctx := cCtx.Context
logger := common.GetLogger(cCtx)

Expand Down Expand Up @@ -68,7 +64,7 @@ func registerOperatorSetsAction(cCtx *cli.Context, p utils.Prompter) error {
elcontracts.Config{
DelegationManagerAddress: config.delegationManagerAddress,
},
p,
r.prompter,
config.chainID,
logger,
)
Expand Down Expand Up @@ -96,7 +92,7 @@ func registerOperatorSetsAction(cCtx *cli.Context, p utils.Prompter) error {
if err != nil {
return err
}
// If operator is a smart contract, we can't estimate gas using geth
// If caller is a smart contract, we can't estimate gas using geth
// since balance of contract can be 0, as it can be called by an EOA
// to claim. So we hardcode the gas limit to 150_000 so that we can
// create unsigned tx without gas limit estimation from contract bindings
Expand Down Expand Up @@ -157,12 +153,8 @@ func readAndValidateRegisterOperatorSetsConfig(cCtx *cli.Context, logger logging
broadcast := cCtx.Bool(flags.BroadcastFlag.Name)
isSilent := cCtx.Bool(flags.SilentFlag.Name)

operatorAddress := cCtx.String(flags.OperatorAddressFlag.Name)
callerAddress := cCtx.String(flags.CallerAddressFlag.Name)
if common.IsEmptyString(callerAddress) {
logger.Infof("Caller address not provided. Using operator address (%s) as caller address", operatorAddress)
callerAddress = operatorAddress
}
operatorAddress := gethcommon.HexToAddress(cCtx.String(flags.OperatorAddressFlag.Name))
callerAddress := common.PopulateCallerAddress(cCtx, logger, operatorAddress)
avsAddress := gethcommon.HexToAddress(cCtx.String(flags.AVSAddressFlag.Name))

// Get signerConfig
Expand Down Expand Up @@ -192,8 +184,8 @@ func readAndValidateRegisterOperatorSetsConfig(cCtx *cli.Context, logger logging
config := &RegisterConfig{
avsAddress: avsAddress,
operatorSetIds: operatorSetIds,
operatorAddress: gethcommon.HexToAddress(operatorAddress),
callerAddress: gethcommon.HexToAddress(callerAddress),
operatorAddress: operatorAddress,
callerAddress: callerAddress,
network: network,
environment: environment,
broadcast: broadcast,
Expand All @@ -210,23 +202,15 @@ func readAndValidateRegisterOperatorSetsConfig(cCtx *cli.Context, logger logging
}

func getRegistrationFlags() []cli.Flag {
baseFlags := []cli.Flag{
return []cli.Flag{
&flags.NetworkFlag,
&flags.EnvironmentFlag,
&flags.ETHRpcUrlFlag,
&flags.OutputFileFlag,
&flags.OutputTypeFlag,
&flags.BroadcastFlag,
&flags.VerboseFlag,
&flags.AVSAddressFlag,
&flags.OperatorAddressFlag,
&flags.OperatorSetIdsFlag,
&flags.DelegationManagerAddressFlag,
&flags.SilentFlag,
&flags.CallerAddressFlag,
}

allFlags := append(baseFlags, flags.GetSignerFlags()...)
sort.Sort(cli.FlagsByName(allFlags))
return allFlags
}
Loading
Loading