Documentation
¶
Index ¶
- Constants
- Variables
- func CreateTempDir(prefix string) (string, error)
- func DeletePrivateKey(environment string) error
- func EncodeExecutions(executions []erc7702delegatorV2.Execution) ([]byte, error)
- func EnsureDockerIsRunning(cCtx *cli.Context) error
- func ForceFlagWithUsage(usage string) *cli.BoolFlag
- func FormatAppDisplay(context string, appID common.Address) string
- func FormatETH(weiAmount *big.Int) string
- func GetAddressFromPrivateKey(privateKeyHex string) (string, error)
- func GetAppName(context, appID string) string
- func GetAppRegistryPath(context string) (string, error)
- func GetDefaultEnvironment() (string, error)
- func GetGlobalConfigDir() (string, error)
- func GetGlobalConfigPath() (string, error)
- func GetGlobalTelemetryPreference() (*bool, error)
- func GetLatestVersionFromS3(version string) (string, error)
- func GetLogger(verbose bool) (iface.Logger, iface.ProgressTracker)
- func GetLoggerFromCLIContext(cCtx *cli.Context) (iface.Logger, iface.ProgressTracker)
- func GetPrivateKey(environment string) (string, error)
- func IsFirstRun() (bool, error)
- func IsMainnetEnvironment(env string) bool
- func ListApps(context string) (map[string]App, error)
- func LoggerFromContext(cCtx *cli.Context) iface.Logger
- func MarkFirstRunComplete() error
- func Parallel[T1, T2 any](fn1 func() (T1, error), fn2 func() (T2, error)) (T1, T2, error)
- func PeelBoolFromFlags(args []string, longFlag, shortFlag string) bool
- func PrintUpdateNotification(info *UpdateInfo)
- func ProgressTrackerFromContext(ctx context.Context) iface.ProgressTracker
- func ResolveAppID(context, nameOrID string) (string, error)
- func SaveAppRegistry(context string, registry *AppRegistry) error
- func SaveGlobalConfig(config *GlobalConfig) error
- func SaveUserId(userUuid string) error
- func SetAppName(context, appIDOrName, newName string) error
- func SetDefaultEnvironment(environment string) error
- func SetGlobalTelemetryPreference(enabled bool) error
- func ShowTelemetryNotice(logger iface.Logger, opts TelemetryPromptOptions) bool
- func StorePrivateKey(environment, privateKey string) error
- func ValidateAppName(name string) error
- func ValidatePrivateKey(key string) error
- func WithAppEnvironment(ctx *cli.Context)
- func WithLogger(ctx context.Context, logger iface.Logger) context.Context
- func WithProgressTracker(ctx context.Context, tracker iface.ProgressTracker) context.Context
- func WithShutdown(ctx context.Context) context.Context
- type App
- type AppEnvironment
- type AppRegistry
- type AppStatus
- type ChainAddr
- type CommonAddr
- type ContractCaller
- func (cc *ContractCaller) CheckERC7702Delegation(ctx context.Context, account common.Address) (bool, error)
- func (cc *ContractCaller) DeployApp(ctx context.Context, salt [32]byte, ...) (appID common.Address, err error)
- func (cc *ContractCaller) ExecuteBatch(ctx context.Context, executions []erc7702delegatorV2.Execution, ...) error
- func (cc *ContractCaller) GetActiveAppCount(ctx context.Context, user common.Address) (uint32, error)
- func (cc *ContractCaller) GetAppsByCreator(ctx context.Context, creator common.Address, offset uint64, limit uint64) ([]common.Address, []appcontrollerV1.IAppControllerAppConfig, error)
- func (cc *ContractCaller) GetMaxActiveAppsPerUser(ctx context.Context, user common.Address) (uint32, error)
- func (cc *ContractCaller) SendAndWaitForTransaction(ctx context.Context, txDescription string, callMsg *ethereum.CallMsg, ...) error
- func (cc *ContractCaller) StartApp(ctx context.Context, appAddress common.Address) error
- func (cc *ContractCaller) StopApp(ctx context.Context, appAddress common.Address) error
- func (cc *ContractCaller) Suspend(ctx context.Context, account common.Address, apps []common.Address) error
- func (cc *ContractCaller) TerminateApp(ctx context.Context, appAddress common.Address, force bool) error
- func (cc *ContractCaller) Undelegate(ctx context.Context) error
- func (cc *ContractCaller) UpgradeApp(ctx context.Context, appAddress common.Address, ...) error
- type EnvironmentConfig
- type GlobalConfig
- type KeyringStore
- type OSKeyringStore
- type TelemetryPromptOptions
- type UpdateInfo
Constants ¶
const ( AppRegistryVersion = "1.0.0" AppRegistryFile = "apps.yaml" )
const ( // Chain IDs MainnetChainID uint64 = 1 SepoliaChainID uint64 = 11155111 // Fallback environment used if no user-defined default is found FallbackEnvironment = "sepolia" )
const ( BuildSuffix = "-dev" KeyringServiceName = "eigenx-cli-dev" Build = "dev" )
Build-specific constants for dev environment
const ( // L1 is the name of the L1 chain L1 = "l1" // ContractsDir is the subdirectory name for contract components ContractsDir = "contracts" // Makefile is the name of the makefile used for root level operations Makefile = "Makefile" // ContractsMakefile is the name of the makefile used for contract level operations ContractsMakefile = "Makefile" // GlobalConfigFile is the name of the global YAML used to store global config details (eg, user_id) GlobalConfigFile = "config.yaml" // Docker open timeout DockerOpenTimeoutSeconds = 10 // Docker open retry interval in milliseconds DockerOpenRetryIntervalMilliseconds = 500 // WatchPollIntervalSeconds is the interval between watch loop polls in seconds WatchPollIntervalSeconds = 5 // Environment variable names MnemonicEnvVar = "MNEMONIC" // Filtered out, overridden by protocol EigenMachineTypeEnvVar = "EIGEN_MACHINE_TYPE_PUBLIC" // Instance type configuration EigenXPrivateKeyEnvVar = "EIGENX_PRIVATE_KEY" // Private key for authentication )
Project structure constants
const ( AppStatusCreated = "Created" AppStatusDeploying = "Deploying" AppStatusUpgrading = "Upgrading" AppStatusResuming = "Resuming" AppStatusRunning = "Running" AppStatusStopping = "Stopping" AppStatusStopped = "Stopped" AppStatusTerminating = "Terminating" AppStatusTerminated = "Terminated" AppStatusSuspended = "Suspended" AppStatusFailed = "Failed" AppStatusExited = "Exited" )
App status strings from API
const (
KeyPrefix = "eigenx-"
)
const ( // VersionCheckInterval is how often to check for updates (24 hours) VersionCheckInterval = 24 * time.Hour )
Variables ¶
var ( // Common addresses across all chains CommonAddresses = CommonAddr{ ERC7702Delegator: common.HexToAddress("0x63c0c19a282a1b52b07dd5a65b58948a07dae32b"), } // Addresses specific to each chain ChainAddresses = map[uint64]ChainAddr{ MainnetChainID: { PermissionController: common.HexToAddress("0x25E5F8B1E7aDf44518d35D5B2271f114e081f0E5"), }, SepoliaChainID: { PermissionController: common.HexToAddress("0x44632dfBdCb6D3E21EF613B0ca8A6A0c618F5a37"), }, } // Default environment for each chain ID DefaultEnvironmentForChainID = map[uint64]string{ MainnetChainID: "mainnet-alpha", SepoliaChainID: "sepolia", } )
var ( // The permission to view app logs // bytes4(keccak256("CAN_VIEW_APP_LOGS()")) CanViewAppLogsPermission = [4]byte{0x2f, 0xd3, 0xf2, 0xfe} // The permission to view sensitive app info (including real IPs) // bytes4(keccak256("CAN_VIEW_SENSITIVE_APP_INFO()")) CanViewSensitiveAppInfoPermission = [4]byte{0x0e, 0x67, 0xb2, 0x2f} // The permission to manage billing and subscriptions // bytes4(keccak256("CAN_MANAGE_BILLING()")) CanManageBillingPermission = [4]byte{0xd6, 0xb8, 0x55, 0xa1} // The address that is used to allow auth to be bypassed for certain permissions // address(bytes20(keccak256("PermissionController:AnyoneCanCall"))) AnyoneCanCallAddress = ethcommon.HexToAddress("0x493219d9949348178af1f58740655951a8cd110c") // The address that is permissioned onchain for calls // address(bytes20(keccak256("PermissionController:ApiPermissions"))) ApiPermissionsTarget = ethcommon.HexToAddress("0x57ee1fb74c1087e26446abc4fb87fd8f07c43d8d") )
API permissions constants
var ( EnvironmentFlag = &cli.StringFlag{ Name: "environment", Aliases: []string{"env"}, Usage: "Deployment environment to use", } RpcUrlFlag = &cli.StringFlag{ Name: "rpc-url", Usage: "RPC URL to connect to blockchain", EnvVars: []string{"EIGENX_RPC_URL"}, } PrivateKeyFlag = &cli.StringFlag{ Name: "private-key", Usage: "Private key for signing transactions", EnvVars: []string{EigenXPrivateKeyEnvVar}, } ForceFlag = &cli.BoolFlag{ Name: "force", Usage: "Force operation without confirmation", } EnvFlag = &cli.StringFlag{ Name: "env-file", Usage: "Environment file to use", Value: ".env", } ImageNameFlag = &cli.StringFlag{ Name: "image-name", Usage: "Override app/image name (auto-detected from context if not provided)", } FileFlag = &cli.StringFlag{ Name: "dockerfile", Aliases: []string{"f"}, Usage: "Path to Dockerfile", } TemplateRepoFlag = &cli.StringFlag{ Name: "template-repo", Usage: "Custom template repository URL (for non-catalog templates)", } TemplateVersionFlag = &cli.StringFlag{ Name: "template-version", Usage: "Template version/tag to use", } AllFlag = &cli.BoolFlag{ Name: "all", Usage: "Show all apps including terminated ones", } AddressCountFlag = &cli.IntFlag{ Name: "address-count", Usage: "Number of addresses to fetch", Value: 1, } NameFlag = &cli.StringFlag{ Name: "name", Usage: "Friendly name for the app", } LogVisibilityFlag = &cli.StringFlag{ Name: "log-visibility", Usage: "Log visibility setting: public, private, or off", } InstanceTypeFlag = &cli.StringFlag{ Name: "instance-type", Usage: "Machine instance type to use e.g. g1-standard-4t, g1-standard-8t", } WatchFlag = &cli.BoolFlag{ Name: "watch", Aliases: []string{"w"}, Usage: "Continuously fetch and display updates", } )
Common flag definitions
var BuildDownloadURL = func(version, arch, distro string) string { ext := ".tar.gz" if strings.Contains(distro, "windows") { ext = ".zip" } return "https://s3.amazonaws.com/eigenlayer-eigenx-releases" + BuildSuffix + "/" + version + "/eigenx-cli-" + distro + "-" + arch + "-" + version + ext }
BuildDownloadURL constructs the S3 download URL for a specific version and platform
var EnvironmentConfigs = map[string]EnvironmentConfig{ "sepolia": { Name: "sepolia", AppControllerAddress: common.HexToAddress("0xa86DC1C47cb2518327fB4f9A1627F51966c83B92"), PermissionControllerAddress: ChainAddresses[SepoliaChainID].PermissionController, ERC7702DelegatorAddress: CommonAddresses.ERC7702Delegator, KMSServerURL: "http://10.128.0.57:8080", UserApiServerURL: "https://userapi-compute-sepolia-dev.eigencloud.xyz", DefaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com", }, }
EnvironmentConfigs contains all environments available in dev builds
var ErrKeyNotFound = errors.New("key not found")
var GetS3VersionURL = func() string { return "https://s3.amazonaws.com/eigenlayer-eigenx-releases" + BuildSuffix + "/VERSION" }
GetS3VersionURL returns the S3 URL for the VERSION file
var GlobalFlags = []cli.Flag{ &cli.BoolFlag{ Name: "verbose", Aliases: []string{"v"}, Usage: "Enable verbose logging", }, &cli.BoolFlag{ Name: "enable-telemetry", Usage: "Enable telemetry collection on first run without prompting", }, &cli.BoolFlag{ Name: "disable-telemetry", Usage: "Disable telemetry collection on first run without prompting", }, }
GlobalFlags defines flags that apply to the entire application (global flags).
Functions ¶
func CreateTempDir ¶ added in v0.2.12
CreateTempDir creates a temporary directory with fallback to ~/.eigenx/tmp if system temp fails
func DeletePrivateKey ¶
func EncodeExecutions ¶
func EncodeExecutions(executions []erc7702delegatorV2.Execution) ([]byte, error)
func EnsureDockerIsRunning ¶
EnsureDockerIsRunning checks if Docker is running and attempts to launch Docker Desktop if not.
func ForceFlagWithUsage ¶
func FormatAppDisplay ¶
FormatAppDisplay returns a user-friendly display string for an app Returns "name (0x123...)" if name exists, or just "0x123..." if no name
func GetAddressFromPrivateKey ¶
GetAddressFromPrivateKey validates a private key and returns the corresponding address
func GetAppName ¶
GetAppName returns the name for a given app ID, or empty string if not found
func GetAppRegistryPath ¶
GetAppRegistryPath returns the path to the app registry file for a specific context
func GetDefaultEnvironment ¶
GetDefaultEnvironment returns the user's preferred deployment environment
func GetGlobalConfigDir ¶
GetGlobalConfigDir returns the XDG-compliant directory where global eigenx config should be stored
func GetGlobalConfigPath ¶
GetGlobalConfigPath returns the full path to the global config file
func GetGlobalTelemetryPreference ¶
GetGlobalTelemetryPreference returns the global telemetry preference
func GetLatestVersionFromS3 ¶ added in v0.2.6
GetLatestVersionFromS3 fetches the latest version from the S3 bucket If version is "latest", it fetches from the VERSION file Otherwise, it returns the specified version (for explicit version upgrades)
func GetLogger ¶
func GetLogger(verbose bool) (iface.Logger, iface.ProgressTracker)
Get logger for the env we're in
func GetLoggerFromCLIContext ¶
GetLoggerFromCLIContext creates a logger based on the CLI context It checks the verbose flag and returns the appropriate logger
func GetPrivateKey ¶
func IsFirstRun ¶
IsFirstRun checks if this is the user's first time running devkit
func IsMainnetEnvironment ¶
IsMainnetEnvironment checks if the given environment is a mainnet environment
func LoggerFromContext ¶
LoggerFromContext retrieves the logger from the context If no logger is found, it returns a non-verbose logger as fallback
func MarkFirstRunComplete ¶
func MarkFirstRunComplete() error
MarkFirstRunComplete marks that the first run has been completed
func PeelBoolFromFlags ¶
PeelBoolFromFlags reports whether a boolean CLI flag is set anywhere in args, It supports these forms:
--verbose --verbose=true|false|1|0|yes|no|t|f --verbose true|false|1|0|yes|no|t|f -v -v=true|false|1|0|yes|no|t|f -v true|false|1|0|yes|no|t|f
The last occurrence wins. If a flag is present without an explicit value, it is treated as true.
func PrintUpdateNotification ¶ added in v0.2.6
func PrintUpdateNotification(info *UpdateInfo)
PrintUpdateNotification prints a user-friendly notification about an available update
func ProgressTrackerFromContext ¶
func ProgressTrackerFromContext(ctx context.Context) iface.ProgressTracker
ProgressTrackerFromContext retrieves the progress tracker from the context If no tracker is found, it returns a non-verbose tracker as fallback
func ResolveAppID ¶
ResolveAppID resolves a name or app ID to an app ID
func SaveAppRegistry ¶
func SaveAppRegistry(context string, registry *AppRegistry) error
SaveAppRegistry saves the app registry to disk
func SaveGlobalConfig ¶
func SaveGlobalConfig(config *GlobalConfig) error
SaveGlobalConfig saves the global configuration to disk
func SaveUserId ¶
SaveUserId saves user settings to the global config, but preserves existing UUID if present
func SetAppName ¶
SetAppName sets or updates a name for an app
func SetDefaultEnvironment ¶
SetDefaultEnvironment sets the user's preferred deployment environment
func SetGlobalTelemetryPreference ¶
SetGlobalTelemetryPreference sets the global telemetry preference
func ShowTelemetryNotice ¶
func ShowTelemetryNotice(logger iface.Logger, opts TelemetryPromptOptions) bool
ShowTelemetryNotice displays telemetry information notice without prompting
func StorePrivateKey ¶
func ValidateAppName ¶
ValidateAppName validates that an app name follows Docker image naming restrictions
func ValidatePrivateKey ¶
ValidatePrivateKey validates that a private key is in the correct format
func WithAppEnvironment ¶
func WithLogger ¶
WithLogger stores the logger in the context
func WithProgressTracker ¶
WithProgressTracker stores the progress tracker in the context
Types ¶
type AppEnvironment ¶
func AppEnvironmentFromContext ¶
func AppEnvironmentFromContext(ctx context.Context) (*AppEnvironment, bool)
func NewAppEnvironment ¶
func NewAppEnvironment(os, arch, userUuid string) *AppEnvironment
type AppRegistry ¶
func LoadAppRegistry ¶
func LoadAppRegistry(context string) (*AppRegistry, error)
LoadAppRegistry loads the app registry from disk
type CommonAddr ¶
type ContractCaller ¶
ContractCaller provides a high-level interface for interacting with contracts
func NewContractCaller ¶
func NewContractCaller(privateKeyHex string, chainID *big.Int, environmentConfig EnvironmentConfig, client *ethclient.Client, logger iface.Logger) (*ContractCaller, error)
func (*ContractCaller) CheckERC7702Delegation ¶
func (cc *ContractCaller) CheckERC7702Delegation(ctx context.Context, account common.Address) (bool, error)
CheckERC7702Delegation checks if the given account already delegates to the ERC-7702 delegator
func (*ContractCaller) DeployApp ¶
func (cc *ContractCaller) DeployApp(ctx context.Context, salt [32]byte, release appcontrollerV2.IAppControllerRelease, publicLogs bool, imageRef string) (appID common.Address, err error)
DeployApp creates a new app via AppController contract, accepts admin permissions, and upgrades the app
func (*ContractCaller) ExecuteBatch ¶
func (cc *ContractCaller) ExecuteBatch(ctx context.Context, executions []erc7702delegatorV2.Execution, needsConfirmation bool, confirmationPrompt string, pendingMessage string) error
ExecuteBatch executes a batch of executions. It sets the code of the EOA to the delegator contract if not already set.
func (*ContractCaller) GetActiveAppCount ¶ added in v0.2.12
func (cc *ContractCaller) GetActiveAppCount(ctx context.Context, user common.Address) (uint32, error)
GetActiveAppCount returns the number of active apps (STARTED or STOPPED) for a user
func (*ContractCaller) GetAppsByCreator ¶ added in v0.2.12
func (cc *ContractCaller) GetAppsByCreator(ctx context.Context, creator common.Address, offset uint64, limit uint64) ([]common.Address, []appcontrollerV1.IAppControllerAppConfig, error)
GetAppsByCreator retrieves a paginated list of apps created by the specified address
func (*ContractCaller) GetMaxActiveAppsPerUser ¶ added in v0.2.12
func (cc *ContractCaller) GetMaxActiveAppsPerUser(ctx context.Context, user common.Address) (uint32, error)
GetMaxActiveAppsPerUser returns the quota limit for a user
func (*ContractCaller) SendAndWaitForTransaction ¶
func (*ContractCaller) Suspend ¶ added in v0.2.12
func (cc *ContractCaller) Suspend(ctx context.Context, account common.Address, apps []common.Address) error
Suspend suspends all active apps for an account and sets their max active apps to 0
func (*ContractCaller) TerminateApp ¶
func (cc *ContractCaller) TerminateApp(ctx context.Context, appAddress common.Address, force bool) error
TerminateApp terminates an app permanently via AppController contract
func (*ContractCaller) Undelegate ¶
func (cc *ContractCaller) Undelegate(ctx context.Context) error
func (*ContractCaller) UpgradeApp ¶
func (cc *ContractCaller) UpgradeApp(ctx context.Context, appAddress common.Address, release appcontrollerV2.IAppControllerRelease, publicLogs bool, needsPermissionChange bool, imageRef string) error
UpgradeApp upgrades an app via AppController contract
type EnvironmentConfig ¶
type EnvironmentConfig struct {
Name string
AppControllerAddress common.Address
PermissionControllerAddress common.Address
ERC7702DelegatorAddress common.Address
KMSServerURL string
UserApiServerURL string
DefaultRPCURL string
}
EnvironmentConfig defines the configuration for a specific environment
type GlobalConfig ¶
type GlobalConfig struct {
// FirstRun tracks if this is the user's first time running devkit
FirstRun bool `yaml:"first_run"`
// TelemetryEnabled stores the user's global telemetry preference
TelemetryEnabled *bool `yaml:"telemetry_enabled,omitempty"`
// The users uuid to identify user across projects
UserUUID string `yaml:"user_uuid"`
// DefaultEnvironment stores the user's preferred deployment environment (sepolia, mainnet-alpha, etc.)
DefaultEnvironment string `yaml:"default_environment,omitempty"`
// LastVersionCheck stores the timestamp of the last version check
LastVersionCheck int64 `yaml:"last_version_check,omitempty"`
// LastKnownVersion stores the last known latest version from the server
LastKnownVersion string `yaml:"last_known_version,omitempty"`
}
GlobalConfig contains user-level configuration that persists across all devkit usage
func LoadGlobalConfig ¶
func LoadGlobalConfig() (*GlobalConfig, error)
LoadGlobalConfig loads the global configuration, creating defaults if needed
type KeyringStore ¶
type KeyringStore interface {
StorePrivateKey(environment, privateKey string) error
GetPrivateKey(environment string) (string, error)
DeletePrivateKey(environment string) error
}
var DefaultKeyringStore KeyringStore = &OSKeyringStore{}
type OSKeyringStore ¶
type OSKeyringStore struct{}
func (*OSKeyringStore) DeletePrivateKey ¶
func (o *OSKeyringStore) DeletePrivateKey(environment string) error
func (*OSKeyringStore) GetPrivateKey ¶
func (o *OSKeyringStore) GetPrivateKey(environment string) (string, error)
func (*OSKeyringStore) StorePrivateKey ¶
func (o *OSKeyringStore) StorePrivateKey(environment, privateKey string) error
type TelemetryPromptOptions ¶
type TelemetryPromptOptions struct {
// EnableTelemetry automatically enables telemetry without prompting (for --enable-telemetry flag)
EnableTelemetry bool
// DisableTelemetry automatically disables telemetry without prompting (for --disable-telemetry flag)
DisableTelemetry bool
// SkipPromptInCI skips the prompt in CI environments (defaults to disabled)
SkipPromptInCI bool
}
TelemetryPromptOptions controls how the telemetry prompt behaves
type UpdateInfo ¶ added in v0.2.6
UpdateInfo contains information about an available version update
func CheckForUpdate ¶ added in v0.2.6
func CheckForUpdate(logger iface.Logger) (*UpdateInfo, error)
CheckForUpdate checks if a new version is available, using cached results when possible