Skip to content
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

CLI method signatures defining the interface for interacting with UAM contracts #243

Closed
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
1 change: 1 addition & 0 deletions cmd/eigenlayer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func main() {
app.Commands = append(app.Commands, pkg.RewardsCmd(prompter))
app.Commands = append(app.Commands, pkg.KeysCmd(prompter))
app.Commands = append(app.Commands, pkg.EigenPodCmd(prompter))
app.Commands = append(app.Commands, pkg.UsersCmd())

if err := app.Run(os.Args); err != nil {
_, err := fmt.Fprintln(os.Stderr, err)
Expand Down
23 changes: 23 additions & 0 deletions pkg/internal/common/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"os/user"
"strings"
"time"
"unicode/utf8"

"github.com/urfave/cli/v2"

Expand All @@ -20,11 +21,11 @@
"github.com/Layr-Labs/eigenlayer-cli/pkg/types"
"github.com/Layr-Labs/eigenlayer-cli/pkg/utils"

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

Check failure on line 24 in pkg/internal/common/helper.go

View workflow job for this annotation

GitHub Actions / Unit Test

github.com/Layr-Labs/[email protected]: replacement directory ../eigensdk-go does not exist

Check failure on line 24 in pkg/internal/common/helper.go

View workflow job for this annotation

GitHub Actions / Build

github.com/Layr-Labs/[email protected]: replacement directory ../eigensdk-go does not exist
"github.com/Layr-Labs/eigensdk-go/chainio/clients/fireblocks"

Check failure on line 25 in pkg/internal/common/helper.go

View workflow job for this annotation

GitHub Actions / Unit Test

github.com/Layr-Labs/[email protected]: replacement directory ../eigensdk-go does not exist

Check failure on line 25 in pkg/internal/common/helper.go

View workflow job for this annotation

GitHub Actions / Build

github.com/Layr-Labs/[email protected]: replacement directory ../eigensdk-go does not exist
"github.com/Layr-Labs/eigensdk-go/chainio/clients/wallet"

Check failure on line 26 in pkg/internal/common/helper.go

View workflow job for this annotation

GitHub Actions / Unit Test

github.com/Layr-Labs/[email protected]: replacement directory ../eigensdk-go does not exist

Check failure on line 26 in pkg/internal/common/helper.go

View workflow job for this annotation

GitHub Actions / Build

github.com/Layr-Labs/[email protected]: replacement directory ../eigensdk-go does not exist
eigensdkLogger "github.com/Layr-Labs/eigensdk-go/logging"
"github.com/Layr-Labs/eigensdk-go/signerv2"

Check failure on line 28 in pkg/internal/common/helper.go

View workflow job for this annotation

GitHub Actions / Unit Test

github.com/Layr-Labs/[email protected]: replacement directory ../eigensdk-go does not exist

Check failure on line 28 in pkg/internal/common/helper.go

View workflow job for this annotation

GitHub Actions / Build

github.com/Layr-Labs/[email protected]: replacement directory ../eigensdk-go does not exist
eigensdkTypes "github.com/Layr-Labs/eigensdk-go/types"
eigenSdkUtils "github.com/Layr-Labs/eigensdk-go/utils"

Expand All @@ -44,6 +45,7 @@
ELDelegationManagerAddress: "0x39053D51B77DC0d36036Fc1fCc8Cb819df8Ef37A",
ELAVSDirectoryAddress: "0x135dda560e946695d6f155dacafc6f1f25c1f5af",
ELRewardsCoordinatorAddress: "0x7750d328b314EfFa365A0402CcfD489B80B0adda",
ELPermissionManagerAddress: "",
WebAppUrl: "https://app.eigenlayer.xyz/operator",
ProofStoreBaseURL: "https://eigenlabs-rewards-mainnet-ethereum.s3.amazonaws.com",
},
Expand All @@ -52,6 +54,7 @@
ELDelegationManagerAddress: "0xA44151489861Fe9e3055d95adC98FbD462B948e7",
ELAVSDirectoryAddress: "0x055733000064333CaDDbC92763c58BF0192fFeBf",
ELRewardsCoordinatorAddress: "0xAcc1fb458a1317E886dB376Fc8141540537E68fE",
ELPermissionManagerAddress: "",
WebAppUrl: "https://holesky.eigenlayer.xyz/operator",
ProofStoreBaseURL: "https://eigenlabs-rewards-testnet-holesky.s3.amazonaws.com",
},
Expand All @@ -60,6 +63,7 @@
ELDelegationManagerAddress: "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
ELAVSDirectoryAddress: "0x0165878A594ca255338adfa4d48449f69242Eb8F",
ELRewardsCoordinatorAddress: "0x610178dA211FEF7D417bC0e6FeD39F05609AD788",
ELPermissionManagerAddress: "",
WebAppUrl: "",
ProofStoreBaseURL: "",
},
Expand Down Expand Up @@ -331,6 +335,16 @@
}
}

func GetPermissionManagerAddress(chainID *big.Int) (string, error) {
chainIDInt := chainID.Int64()
chainMetadata, ok := ChainMetadataMap[chainIDInt]
if !ok {
return "", fmt.Errorf("chain ID %d not supported", chainIDInt)
} else {
return chainMetadata.ELDelegationManagerAddress, nil
}
}

func GetTransactionLink(txHash string, chainId *big.Int) string {
chainIDInt := chainId.Int64()
chainMetadata, ok := ChainMetadataMap[chainIDInt]
Expand Down Expand Up @@ -544,6 +558,15 @@
return signed, nil
}

func ValidateAndConvertSelectorString(selector string) ([4]byte, error) {
if utf8.RuneCountInString(selector) != 4 {
return [4]byte{}, fmt.Errorf("selector must be 4 characters long")
}
var selectorBytes [4]byte
copy(selectorBytes[:], selector)
return selectorBytes, nil
}

func GetEnvFromNetwork(network string) string {
switch network {
case utils.HoleskyNetworkName:
Expand Down
4 changes: 2 additions & 2 deletions pkg/operator/allocations/set_allocation_delay.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func setDelayAction(cCtx *cli.Context, p utils.Prompter) error {
return eigenSdkUtils.WrapError("failed to get EL writer", err)
}

receipt, err := eLWriter.SetAllocationDelay(ctx, config.allocationDelay, true)
receipt, err := eLWriter.SetAllocationDelay(ctx, config.operatorAddress, config.allocationDelay, true)
if err != nil {
return err
}
Expand All @@ -99,7 +99,7 @@ func setDelayAction(cCtx *cli.Context, p utils.Prompter) error {
noSendTxOpts.GasLimit = 150_000
}

unsignedTx, err := contractBindings.AllocationManager.SetAllocationDelay0(noSendTxOpts, config.allocationDelay)
unsignedTx, err := contractBindings.AllocationManager.SetAllocationDelay(noSendTxOpts, config.operatorAddress, config.allocationDelay)
if err != nil {
return eigenSdkUtils.WrapError("failed to create unsigned tx", err)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/operator/allocations/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func updateAllocations(cCtx *cli.Context, p utils.Prompter) error {

receipt, err := eLWriter.ModifyAllocations(
ctx,
config.operatorAddress,
allocationsToUpdate.Allocations,
true,
)
Expand All @@ -136,6 +137,7 @@ func updateAllocations(cCtx *cli.Context, p utils.Prompter) error {

unsignedTx, err := contractBindings.AllocationManager.ModifyAllocations(
noSendTxOpts,
config.operatorAddress,
allocationsToUpdate.Allocations,
)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/operator/register_operator_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func registerOperatorSetsAction(cCtx *cli.Context, p utils.Prompter) error {
}
receipt, err := eLWriter.RegisterForOperatorSets(
ctx,
config.operatorAddress,
elcontracts.RegistrationRequest{
AVSAddress: config.avsAddress,
OperatorSetIds: config.operatorSetIds,
Expand Down Expand Up @@ -104,6 +105,7 @@ func registerOperatorSetsAction(cCtx *cli.Context, p utils.Prompter) error {
}
unsignedTx, err := contractBindings.AllocationManager.RegisterForOperatorSets(
noSendTxOpts,
config.operatorAddress,
allocationmanager.IAllocationManagerTypesRegisterParams{
Avs: config.avsAddress,
OperatorSetIds: config.operatorSetIds,
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/update_metadata_uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Requires the same file used for registration as argument
return eigenSdkUtils.WrapError("failed to get EL writer", err)
}

receipt, err := elWriter.UpdateMetadataURI(context.Background(), operatorCfg.Operator.MetadataUrl, true)
receipt, err := elWriter.UpdateMetadataURI(context.Background(), operatorCfg.Operator.MetadataUrl, operatorCfg.Operator.Address, true)
if err != nil {
fmt.Printf("%s Error while updating operator metadata uri\n", utils.EmojiCrossMark)
return err
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 @@ -5,6 +5,7 @@ type ChainMetadata struct {
ELDelegationManagerAddress string
ELAVSDirectoryAddress string
ELRewardsCoordinatorAddress string
ELPermissionManagerAddress string
WebAppUrl string
ProofStoreBaseURL string
}
25 changes: 25 additions & 0 deletions pkg/user/admin/accept.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package admin

import (
"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common/flags"
"github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry"
"github.com/urfave/cli/v2"
)

func AcceptCmd() *cli.Command {
acceptCmd := &cli.Command{
Name: "accept-admin",
Usage: "user admin accept-admin <AccountAddress>",
UsageText: "Accepts a user to become admin who is currently pending admin acceptance.",
Description: `
Accepts a user to become admin who is currently pending admin acceptance.
`,
After: telemetry.AfterRunAction(),
Flags: []cli.Flag{
&flags.VerboseFlag,
&AccountAddressFlag,
},
}

return acceptCmd
}
26 changes: 26 additions & 0 deletions pkg/user/admin/add_pending.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package admin

import (
"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common/flags"
"github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry"
"github.com/urfave/cli/v2"
)

func AddPendingCmd() *cli.Command {
addPendingCmd := &cli.Command{
Name: "add-pending-admin",
Usage: "user admin add-pending-admin <AccountAddress> <AdminAddress>",
UsageText: "Add an admin to be pending until accepted.",
Description: `
Add an admin to be pending until accepted.
`,
After: telemetry.AfterRunAction(),
Flags: []cli.Flag{
&flags.VerboseFlag,
&AccountAddressFlag,
&AdminAddressFlag,
},
}

return addPendingCmd
}
34 changes: 34 additions & 0 deletions pkg/user/admin/admin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package admin

import (
"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common/flags"
"github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry"
"github.com/urfave/cli/v2"
)

func AdminCmd() *cli.Command {
adminCmd := &cli.Command{
Name: "admin",
Usage: "user admin <command>",
UsageText: "Manage admin users.",
Description: `
Manage admin users.
`,
After: telemetry.AfterRunAction(),
Flags: []cli.Flag{
&flags.VerboseFlag,
},
Subcommands: []*cli.Command{
AcceptCmd(),
AddPendingCmd(),
IsAdminCmd(),
IsPendingCmd(),
ListCmd(),
ListPendingCmd(),
RemoveCmd(),
RemovePendingCmd(),
},
}

return adminCmd
}
48 changes: 48 additions & 0 deletions pkg/user/admin/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package admin

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

var (
AccountAddressFlag = cli.StringFlag{
Name: "account-address",
Aliases: []string{"aa"},
Usage: "user admin ... --account-address \"0x...\"",
EnvVars: []string{"ACCOUNT_ADDRESS"},
}
)

var (
AdminAddressFlag = cli.StringFlag{
Name: "admin-address",
Aliases: []string{"aa"},
Usage: "user admin ... --admin-address \"0x...\"",
EnvVars: []string{"ADMIN_ADDRESS"},
}
)

var (
CallerAddressFlag = cli.StringFlag{
Name: "caller-address",
Aliases: []string{"ca"},
Usage: "user admin ... --caller-address \"0x...\"",
EnvVars: []string{"CALLER_ADDRESS"},
}
)

var (
PendingAdminAddressFlag = cli.StringFlag{
Name: "pending-admin-address",
Aliases: []string{"paa"},
Usage: "user admin ... --pending-admin-address \"0x...\"",
EnvVars: []string{"PENDING_ADMIN_ADDRESS"},
}
)

var (
PermissionManagerAddressFlag = cli.StringFlag{
Name: "permission-manager-address",
Aliases: []string{"pma"},
Usage: "user admin ... --permission-manager-address \"0x...\"",
EnvVars: []string{"PERMISSION_MANAGER_ADDRESS"},
}
)
26 changes: 26 additions & 0 deletions pkg/user/admin/is_admin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package admin

import (
"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common/flags"
"github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry"
"github.com/urfave/cli/v2"
)

func IsAdminCmd() *cli.Command {
isAdmin := &cli.Command{
Name: "is-admin",
Usage: "user admin is-admin <AccountAddress> <CallerAddress>",
UsageText: "Checks if a user is an admin.",
Description: `
Checks if a user is an admin.
`,
After: telemetry.AfterRunAction(),
Flags: []cli.Flag{
&flags.VerboseFlag,
&AccountAddressFlag,
&CallerAddressFlag,
},
}

return isAdmin
}
26 changes: 26 additions & 0 deletions pkg/user/admin/is_pending.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package admin

import (
"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common/flags"
"github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry"
"github.com/urfave/cli/v2"
)

func IsPendingCmd() *cli.Command {
isPendingCmd := &cli.Command{
Name: "is-pending-admin",
Usage: "user admin is-pending-admin <AccountAddress> <PendingAdminAddress>",
UsageText: "Checks if a user is pending acceptance to admin.",
Description: `
Checks if a user is pending acceptance to admin.
`,
After: telemetry.AfterRunAction(),
Flags: []cli.Flag{
&flags.VerboseFlag,
&AccountAddressFlag,
&PendingAdminAddressFlag,
},
}

return isPendingCmd
}
25 changes: 25 additions & 0 deletions pkg/user/admin/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package admin

import (
"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common/flags"
"github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry"
"github.com/urfave/cli/v2"
)

func ListCmd() *cli.Command {
listCmd := &cli.Command{
Name: "list-admins",
Usage: "user admin list-admins <AccountAddress>",
UsageText: "List all users who are admins.",
Description: `
List all users who are admins.
`,
After: telemetry.AfterRunAction(),
Flags: []cli.Flag{
&flags.VerboseFlag,
&AccountAddressFlag,
},
}

return listCmd
}
25 changes: 25 additions & 0 deletions pkg/user/admin/list_pending.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package admin

import (
"github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common/flags"
"github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry"
"github.com/urfave/cli/v2"
)

func ListPendingCmd() *cli.Command {
listPendingCmd := &cli.Command{
Name: "list-pending-admins",
Usage: "user admin list-pending-admins <AccountAddress>",
UsageText: "List all users who are pending admin acceptance.",
Description: `
List all users who are pending admin acceptance.
`,
After: telemetry.AfterRunAction(),
Flags: []cli.Flag{
&flags.VerboseFlag,
&AccountAddressFlag,
},
}

return listPendingCmd
}
Loading
Loading