diff --git a/pkg/internal/common/constants.go b/pkg/internal/common/constants.go index 7bcb6ec..9b65c23 100644 --- a/pkg/internal/common/constants.go +++ b/pkg/internal/common/constants.go @@ -10,4 +10,13 @@ const ( OutputType_Calldata OutputType = "calldata" OutputType_Pretty OutputType = "pretty" OutputType_Json OutputType = "json" + + MainnetChainId = 1 + HoleskyChainId = 17000 + AnvilChainId = 31337 + + MainnetNetworkName = "mainnet" + HoleskyNetworkName = "holesky" + AnvilNetworkName = "anvil" + UnknownNetworkName = "unknown" ) diff --git a/pkg/internal/common/eth.go b/pkg/internal/common/eth.go index 8467573..59123db 100644 --- a/pkg/internal/common/eth.go +++ b/pkg/internal/common/eth.go @@ -32,6 +32,7 @@ func (t *TxFeeDetails) Print() { fmt.Printf("Approximate Max Cost of transaction: %0.12f ETH\n", t.CostInEth) fmt.Println(strings.Repeat("-", len(message))) } + func GetTxFeeDetails(tx *types.Transaction) *TxFeeDetails { gasTipCapGwei := float64(tx.GasTipCap().Uint64()) / GweiToWei gasFeeCapGwei := float64(tx.GasFeeCap().Uint64()) / GweiToWei diff --git a/pkg/internal/common/helper.go b/pkg/internal/common/helper.go index 374c29b..a4506d3 100644 --- a/pkg/internal/common/helper.go +++ b/pkg/internal/common/helper.go @@ -35,6 +35,33 @@ import ( "github.com/fatih/color" ) +var ChainMetadataMap = map[int64]types.ChainMetadata{ + MainnetChainId: { + BlockExplorerUrl: "https://etherscan.io/tx", + ELDelegationManagerAddress: "0x39053D51B77DC0d36036Fc1fCc8Cb819df8Ef37A", + ELAVSDirectoryAddress: "0x135dda560e946695d6f155dacafc6f1f25c1f5af", + ELRewardsCoordinatorAddress: "0x7750d328b314EfFa365A0402CcfD489B80B0adda", + WebAppUrl: "https://app.eigenlayer.xyz/operator", + ProofStoreBaseURL: "https://eigenlabs-rewards-mainnet-ethereum.s3.amazonaws.com", + }, + HoleskyChainId: { + BlockExplorerUrl: "https://holesky.etherscan.io/tx", + ELDelegationManagerAddress: "0xA44151489861Fe9e3055d95adC98FbD462B948e7", + ELAVSDirectoryAddress: "0x055733000064333CaDDbC92763c58BF0192fFeBf", + ELRewardsCoordinatorAddress: "0xAcc1fb458a1317E886dB376Fc8141540537E68fE", + WebAppUrl: "https://holesky.eigenlayer.xyz/operator", + ProofStoreBaseURL: "https://eigenlabs-rewards-testnet-holesky.s3.amazonaws.com", + }, + AnvilChainId: { + BlockExplorerUrl: "", + ELDelegationManagerAddress: "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", + ELAVSDirectoryAddress: "0x0165878A594ca255338adfa4d48449f69242Eb8F", + ELRewardsCoordinatorAddress: "0x610178dA211FEF7D417bC0e6FeD39F05609AD788", + WebAppUrl: "", + ProofStoreBaseURL: "", + }, +} + func PrintRegistrationInfo(txHash string, operatorAddress common.Address, chainId *big.Int) { fmt.Println() fmt.Println(strings.Repeat("-", 100)) @@ -255,13 +282,13 @@ func ReadConfigFile(path string) (*types.OperatorConfig, error) { return nil, err } - elAVSDirectoryAddress, err := getAVSDirectoryAddress(operatorCfg.ChainId) + elAVSDirectoryAddress, err := GetAVSDirectoryAddress(&operatorCfg.ChainId) if err != nil { return nil, err } operatorCfg.ELAVSDirectoryAddress = elAVSDirectoryAddress - elRewardsCoordinatorAddress, err := getRewardCoordinatorAddress(operatorCfg.ChainId) + elRewardsCoordinatorAddress, err := GetRewardCoordinatorAddress(&operatorCfg.ChainId) if err != nil { return nil, err } @@ -270,30 +297,29 @@ func ReadConfigFile(path string) (*types.OperatorConfig, error) { return &operatorCfg, nil } -func getAVSDirectoryAddress(chainID big.Int) (string, error) { +func GetRewardCoordinatorAddress(chainID *big.Int) (string, error) { chainIDInt := chainID.Int64() - chainMetadata, ok := utils.ChainMetadataMap[chainIDInt] + chainMetadata, ok := ChainMetadataMap[chainIDInt] if !ok { return "", fmt.Errorf("chain ID %d not supported", chainIDInt) } else { - return chainMetadata.ELAVSDirectoryAddress, nil + return chainMetadata.ELRewardsCoordinatorAddress, nil } } -// TODO(shrimalmadhur): remove this and use the utils one in a separate PR -func getRewardCoordinatorAddress(chainID big.Int) (string, error) { +func GetAVSDirectoryAddress(chainID *big.Int) (string, error) { chainIDInt := chainID.Int64() - chainMetadata, ok := utils.ChainMetadataMap[chainIDInt] + chainMetadata, ok := ChainMetadataMap[chainIDInt] if !ok { return "", fmt.Errorf("chain ID %d not supported", chainIDInt) } else { - return chainMetadata.ELRewardsCoordinatorAddress, nil + return chainMetadata.ELAVSDirectoryAddress, nil } } func GetTransactionLink(txHash string, chainId *big.Int) string { chainIDInt := chainId.Int64() - chainMetadata, ok := utils.ChainMetadataMap[chainIDInt] + chainMetadata, ok := ChainMetadataMap[chainIDInt] if !ok { return txHash } else { @@ -303,7 +329,7 @@ func GetTransactionLink(txHash string, chainId *big.Int) string { func getWebAppLink(operatorAddress common.Address, chainId *big.Int) string { chainIDInt := chainId.Int64() - chainMetadata, ok := utils.ChainMetadataMap[chainIDInt] + chainMetadata, ok := ChainMetadataMap[chainIDInt] if !ok { return "" } else { diff --git a/pkg/operator/config/create.go b/pkg/operator/config/create.go index 2940ddc..f07e308 100644 --- a/pkg/operator/config/create.go +++ b/pkg/operator/config/create.go @@ -7,6 +7,7 @@ import ( "math/big" "os" + "github.com/Layr-Labs/eigenlayer-cli/pkg/internal/common" "github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry" "github.com/Layr-Labs/eigenlayer-cli/pkg/types" "github.com/Layr-Labs/eigenlayer-cli/pkg/utils" @@ -166,13 +167,13 @@ func promptOperatorInfo(config *types.OperatorConfig, p utils.Prompter) (types.O switch chainId { case utils.MainnetNetworkName: config.ChainId = *big.NewInt(utils.MainnetChainId) - config.ELDelegationManagerAddress = utils.ChainMetadataMap[utils.MainnetChainId].ELDelegationManagerAddress + config.ELDelegationManagerAddress = common.ChainMetadataMap[utils.MainnetChainId].ELDelegationManagerAddress case utils.HoleskyNetworkName: config.ChainId = *big.NewInt(utils.HoleskyChainId) - config.ELDelegationManagerAddress = utils.ChainMetadataMap[utils.HoleskyChainId].ELDelegationManagerAddress + config.ELDelegationManagerAddress = common.ChainMetadataMap[utils.HoleskyChainId].ELDelegationManagerAddress case utils.AnvilNetworkName: config.ChainId = *big.NewInt(utils.AnvilChainId) - config.ELDelegationManagerAddress = utils.ChainMetadataMap[utils.AnvilChainId].ELDelegationManagerAddress + config.ELDelegationManagerAddress = common.ChainMetadataMap[utils.AnvilChainId].ELDelegationManagerAddress } // Prompt for signer type diff --git a/pkg/rewards/claim.go b/pkg/rewards/claim.go index 4c3e541..8721960 100644 --- a/pkg/rewards/claim.go +++ b/pkg/rewards/claim.go @@ -314,7 +314,7 @@ func readAndValidateClaimConfig(cCtx *cli.Context, logger logging.Logger) (*Clai var err error if common.IsEmptyString(rewardsCoordinatorAddress) { - rewardsCoordinatorAddress, err = utils.GetRewardCoordinatorAddress(utils.NetworkNameToChainId(network)) + rewardsCoordinatorAddress, err = common.GetRewardCoordinatorAddress(utils.NetworkNameToChainId(network)) if err != nil { return nil, err } @@ -351,7 +351,7 @@ func readAndValidateClaimConfig(cCtx *cli.Context, logger logging.Logger) (*Clai // If empty get from utils if common.IsEmptyString(proofStoreBaseURL) { - proofStoreBaseURL = utils.GetProofStoreBaseURL(network) + proofStoreBaseURL = getProofStoreBaseURL(network) // If still empty return error if common.IsEmptyString(proofStoreBaseURL) { @@ -397,6 +397,16 @@ func readAndValidateClaimConfig(cCtx *cli.Context, logger logging.Logger) (*Clai }, nil } +func getProofStoreBaseURL(network string) string { + chainId := utils.NetworkNameToChainId(network) + chainMetadata, ok := common.ChainMetadataMap[chainId.Int64()] + if !ok { + return "" + } else { + return chainMetadata.ProofStoreBaseURL + } +} + func getEnvFromNetwork(network string) string { switch network { case utils.HoleskyNetworkName: diff --git a/pkg/rewards/setclaimer.go b/pkg/rewards/setclaimer.go index a935b32..3a11aee 100644 --- a/pkg/rewards/setclaimer.go +++ b/pkg/rewards/setclaimer.go @@ -167,7 +167,7 @@ func readAndValidateSetClaimerConfig(cCtx *cli.Context, logger logging.Logger) ( rewardsCoordinatorAddress := cCtx.String(RewardsCoordinatorAddressFlag.Name) var err error if common.IsEmptyString(rewardsCoordinatorAddress) { - rewardsCoordinatorAddress, err = utils.GetRewardCoordinatorAddress(utils.NetworkNameToChainId(network)) + rewardsCoordinatorAddress, err = common.GetRewardCoordinatorAddress(utils.NetworkNameToChainId(network)) if err != nil { return nil, err } diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 3bccafb..3ff6b5d 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -3,54 +3,14 @@ package utils import ( "bufio" "errors" - "fmt" "log" "math/big" "os" "path/filepath" - "github.com/Layr-Labs/eigenlayer-cli/pkg/types" - "gopkg.in/yaml.v2" ) -var ChainMetadataMap = map[int64]types.ChainMetadata{ - MainnetChainId: { - BlockExplorerUrl: "https://etherscan.io/tx", - ELDelegationManagerAddress: "0x39053D51B77DC0d36036Fc1fCc8Cb819df8Ef37A", - ELAVSDirectoryAddress: "0x135dda560e946695d6f155dacafc6f1f25c1f5af", - ELRewardsCoordinatorAddress: "0x7750d328b314EfFa365A0402CcfD489B80B0adda", - WebAppUrl: "https://app.eigenlayer.xyz/operator", - ProofStoreBaseURL: "https://eigenlabs-rewards-mainnet-ethereum.s3.amazonaws.com", - }, - HoleskyChainId: { - BlockExplorerUrl: "https://holesky.etherscan.io/tx", - ELDelegationManagerAddress: "0xA44151489861Fe9e3055d95adC98FbD462B948e7", - ELAVSDirectoryAddress: "0x055733000064333CaDDbC92763c58BF0192fFeBf", - ELRewardsCoordinatorAddress: "0xAcc1fb458a1317E886dB376Fc8141540537E68fE", - WebAppUrl: "https://holesky.eigenlayer.xyz/operator", - ProofStoreBaseURL: "https://eigenlabs-rewards-testnet-holesky.s3.amazonaws.com", - }, - AnvilChainId: { - BlockExplorerUrl: "", - ELDelegationManagerAddress: "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", - ELAVSDirectoryAddress: "0x0165878A594ca255338adfa4d48449f69242Eb8F", - ELRewardsCoordinatorAddress: "0x610178dA211FEF7D417bC0e6FeD39F05609AD788", - WebAppUrl: "", - ProofStoreBaseURL: "", - }, -} - -func GetRewardCoordinatorAddress(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.ELRewardsCoordinatorAddress, nil - } -} - func ChainIdToNetworkName(chainId int64) string { switch chainId { case MainnetChainId: @@ -77,16 +37,6 @@ func NetworkNameToChainId(networkName string) *big.Int { } } -func GetProofStoreBaseURL(network string) string { - chainId := NetworkNameToChainId(network) - chainMetadata, ok := ChainMetadataMap[chainId.Int64()] - if !ok { - return "" - } else { - return chainMetadata.ProofStoreBaseURL - } -} - func ReadYamlConfig(path string, o interface{}) error { if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) { log.Fatal("Path ", path, " does not exist")