Skip to content

Commit

Permalink
move set claimer to rewards (#157)
Browse files Browse the repository at this point in the history
* move set claimer to rewards
  • Loading branch information
shrimalmadhur authored Jul 9, 2024
1 parent e5abcca commit 6ca74e4
Show file tree
Hide file tree
Showing 9 changed files with 268 additions and 147 deletions.
14 changes: 10 additions & 4 deletions pkg/common/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ import (

func PrintRegistrationInfo(txHash string, operatorAddress common.Address, chainId *big.Int) {
fmt.Println(strings.Repeat("-", 100))
PrintTransactionInfo(txHash, chainId)

color.Blue("%s Operator Web App Link: %s\n", utils.EmojiInternet, getWebAppLink(operatorAddress, chainId))
fmt.Println(strings.Repeat("-", 100))
}

func PrintTransactionInfo(txHash string, chainId *big.Int) {
fmt.Printf("%s Chain ID: %s\n", utils.EmojiLink, chainId.String())
if len(txHash) > 0 {
fmt.Printf("%s Transaction Link: %s\n", utils.EmojiLink, GetTransactionLink(txHash, chainId))
}

color.Blue("%s Operator Web App Link: %s\n", utils.EmojiInternet, getWebAppLink(operatorAddress, chainId))
fmt.Println(strings.Repeat("-", 100))
}

func GetWallet(
Expand Down Expand Up @@ -322,10 +326,11 @@ func validateMetadata(operatorCfg *types.OperatorConfig) error {
return nil
}

func GetSignerConfig(cCtx *cli.Context) (*types.SignerConfig, error) {
func GetSignerConfig(cCtx *cli.Context, logger eigensdkLogger.Logger) (*types.SignerConfig, error) {
ecdsaPrivateKeyString := cCtx.String(flags.EcdsaPrivateKeyFlag.Name)
pathToKeyStore := cCtx.String(flags.PathToKeyStoreFlag.Name)
if len(ecdsaPrivateKeyString) != 0 {
logger.Debug("Using private key signer")
pk, err := crypto.HexToECDSA(ecdsaPrivateKeyString)
if err != nil {
return nil, err
Expand All @@ -337,6 +342,7 @@ func GetSignerConfig(cCtx *cli.Context) (*types.SignerConfig, error) {
}

if len(pathToKeyStore) != 0 {
logger.Debug("Using local keystore signer")
return &types.SignerConfig{
SignerType: types.LocalKeystoreSigner,
PrivateKeyStorePath: pathToKeyStore,
Expand Down
1 change: 0 additions & 1 deletion pkg/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func OperatorCmd(p utils.Prompter) *cli.Command {
operator.StatusCmd(p),
operator.UpdateCmd(p),
operator.UpdateMetadataURICmd(p),
operator.SetClaimerCmd(p),
},
}

Expand Down
21 changes: 0 additions & 21 deletions pkg/operator/flags.go

This file was deleted.

106 changes: 0 additions & 106 deletions pkg/operator/setclaimer.go

This file was deleted.

1 change: 1 addition & 0 deletions pkg/rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func RewardsCmd(p utils.Prompter) *cli.Command {
Usage: "Execute onchain operations for the rewards",
Subcommands: []*cli.Command{
rewards.ClaimCmd(p),
rewards.SetClaimerCmd(p),
},
}

Expand Down
60 changes: 51 additions & 9 deletions pkg/rewards/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Rewards

### Command
### Claim Command
```bash
eigenlayer rewards claim --help
NAME:
Expand All @@ -26,8 +26,19 @@ OPTIONS:
--help, -h show help
```

### Example
### Preprod
#### Example
##### Testnet
```bash
eigenlayer rewards claim \
--network holesky \
--eth-rpc-url https://rpc.ankr.com/eth_holesky/<> \
--earner-address 0x111116fe4f8c2f83e3eb2318f090557b7cd0bf76 \
--recipient-address 0x2222AAC0C980Cc029624b7ff55B88Bc6F63C538f \
--path-to-key-store /path/to/key/store \
--token-addresses 0xdeeeeE2b48C121e6728ed95c860e296177849932 --broadcast
```

##### Preprod
```bash
eigenlayer rewards claim \
--network holesky \
Expand All @@ -41,13 +52,44 @@ eigenlayer rewards claim \
--broadcast
```

### Testnet
### Set Claimer Command
```bash
eigenlayer rewards claim \
eigenlayer rewards set-claimer --help
NAME:
eigenlayer rewards set-claimer - Set the claimer address for the earner

USAGE:
set-claimer

DESCRIPTION:

Set the rewards claimer address for the earner.


OPTIONS:
--verbose, -v Enable verbose logging (default: false) [$VERBOSE]
--network value, -n value Network to use. Currently supports 'holesky' and 'mainnet' (default: "holesky") [$NETWORK]
--eth-rpc-url value, -r value URL of the Ethereum RPC [$ETH_RPC_URL]
--earner-address value, --ea value Address of the earner (this is your staker/operator address) [$EARNER_ADDRESS]
--output-file value, -o value Output file to write the data [$OUTPUT_FILE]
--path-to-key-store value, -k value Path to the key store [$PATH_TO_KEY_STORE]
--ecdsa-private-key value, -e value ECDSA private key hex to send transaction [$ECDSA_PRIVATE_KEY]
--broadcast, -b Use this flag to broadcast the transaction (default: false) [$BROADCAST]
--rewards-coordinator-address value, --rc value Specify the address of the rewards coordinator. If not provided, the address will be used based on provided network [$REWARDS_COORDINATOR_ADDRESS]
--claimer-address value, -a value Address of the claimer [$NODE_OPERATOR_CLAIMER_ADDRESS]
--help, -h
```

#### Example
##### Preprod
```bash
eigenlayer rewards set-claimer \
--network holesky \
--eth-rpc-url https://rpc.ankr.com/eth_holesky/<> \
--earner-address 0x111116fe4f8c2f83e3eb2318f090557b7cd0bf76 \
--recipient-address 0x2222AAC0C980Cc029624b7ff55B88Bc6F63C538f \
--earner-address 0x2222AAC0C980Cc029624b7ff55B88Bc6F63C538f \
--claimer-address 0x2222AAC0C980Cc029624b7ff55B88Bc6F63C538f \
--path-to-key-store /path/to/key/store \
--token-addresses 0xdeeeeE2b48C121e6728ed95c860e296177849932 --broadcast
```
--rewards-coordinator-address 0xb22Ef643e1E067c994019A4C19e403253C05c2B0
--broadcast
```
For testnet, remove the `--rewards-coordinator-address` flag and binary will automatically use the testnet rewards coordinator address.
13 changes: 7 additions & 6 deletions pkg/rewards/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type ClaimConfig struct {
ChainID *big.Int
ProofStoreBaseURL string
Environment string
SignerConfig types.SignerConfig
SignerConfig *types.SignerConfig
}

func ClaimCmd(p utils.Prompter) *cli.Command {
Expand Down Expand Up @@ -94,6 +94,7 @@ func Claim(cCtx *cli.Context, p utils.Prompter) error {
if err != nil {
return eigenSdkUtils.WrapError("failed to read and validate claim config", err)
}
cCtx.App.Metadata["network"] = config.ChainID.String()

ethClient, err := eth.NewClient(config.RPCUrl)
if err != nil {
Expand Down Expand Up @@ -150,7 +151,7 @@ func Claim(cCtx *cli.Context, p utils.Prompter) error {
if config.Broadcast {
logger.Info("Broadcasting claim...")
keyWallet, sender, err := common.GetWallet(
config.SignerConfig,
*config.SignerConfig,
config.EarnerAddress.String(),
ethClient,
p,
Expand Down Expand Up @@ -193,8 +194,8 @@ func Claim(cCtx *cli.Context, p utils.Prompter) error {
return eigenSdkUtils.WrapError("failed to process claim", err)
}

txLink := common.GetTransactionLink(receipt.TxHash.String(), config.ChainID)
logger.Infof("Claim transaction submitted successfully: %s", txLink)
logger.Infof("Claim transaction submitted successfully")
common.PrintTransactionInfo(receipt.TxHash.String(), config.ChainID)
} else {
solidityClaim := claimgen.FormatProofForSolidity(accounts.Root(), claim)
fmt.Println("------- Claim generated -------")
Expand Down Expand Up @@ -275,7 +276,7 @@ func readAndValidateClaimConfig(cCtx *cli.Context, logger logging.Logger) (*Clai
logger.Debugf("Using network %s and environment: %s", network, environment)

// Get SignerConfig
signerConfig, err := common.GetSignerConfig(cCtx)
signerConfig, err := common.GetSignerConfig(cCtx, logger)
if err != nil {
return nil, err
}
Expand All @@ -292,7 +293,7 @@ func readAndValidateClaimConfig(cCtx *cli.Context, logger logging.Logger) (*Clai
ProofStoreBaseURL: proofStoreBaseURL,
Environment: environment,
RecipientAddress: recipientAddress,
SignerConfig: *signerConfig,
SignerConfig: signerConfig,
}, nil
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/rewards/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@ var (
Usage: "Environment to use. Currently supports 'preprod' ,`testnet' and 'prod'. If not provided, it will be inferred based on network",
EnvVars: []string{"ENVIRONMENT"},
}

ClaimerAddressFlag = cli.StringFlag{
Name: "claimer-address",
Aliases: []string{"a"},
Usage: "Address of the claimer",
Required: true,
EnvVars: []string{"NODE_OPERATOR_CLAIMER_ADDRESS"},
}
)
Loading

0 comments on commit 6ca74e4

Please sign in to comment.