Skip to content

Commit

Permalink
fix: remove duplicated code now that its not a separate command
Browse files Browse the repository at this point in the history
  • Loading branch information
gpabst committed Nov 15, 2024
1 parent 44936d0 commit 6ea4abb
Showing 1 changed file with 5 additions and 33 deletions.
38 changes: 5 additions & 33 deletions pkg/rewards/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,38 +85,10 @@ func getClaimFlags() []cli.Flag {
return allFlags
}

func BatchClaim(cCtx *cli.Context, p utils.Prompter) error {
func BatchClaim(cCtx *cli.Context, ethClient *ethclient.Client, elReader *elcontracts.ChainReader, df *httpProofDataFetcher.HttpProofDataFetcher, config *ClaimConfig, p utils.Prompter) error {
ctx := cCtx.Context
logger := common.GetLogger(cCtx)

config, err := readAndValidateClaimConfig(cCtx, logger)
if err != nil {
return eigenSdkUtils.WrapError("failed to read and validate claim config", err)
}
cCtx.App.Metadata["network"] = config.ChainID.String()

ethClient, err := ethclient.Dial(config.RPCUrl)
if err != nil {
return eigenSdkUtils.WrapError("failed to create new eth client", err)
}

elReader, err := elcontracts.NewReaderFromConfig(
elcontracts.Config{
RewardsCoordinatorAddress: config.RewardsCoordinatorAddress,
},
ethClient, logger,
)
if err != nil {
return eigenSdkUtils.WrapError("failed to create new reader from config", err)
}

df := httpProofDataFetcher.NewHttpProofDataFetcher(
config.ProofStoreBaseURL,
config.Environment,
config.Network,
http.DefaultClient,
)

yamlFile, err := os.ReadFile(config.BatchClaimFile)
if err != nil {
return eigenSdkUtils.WrapError("failed to read YAML config file", err)
Expand Down Expand Up @@ -256,10 +228,6 @@ func Claim(cCtx *cli.Context, p utils.Prompter) error {
return eigenSdkUtils.WrapError("failed to read and validate claim config", err)
}

if config.BatchClaimFile != "" {
return BatchClaim(cCtx, p)
}

cCtx.App.Metadata["network"] = config.ChainID.String()

ethClient, err := ethclient.Dial(config.RPCUrl)
Expand All @@ -284,6 +252,10 @@ func Claim(cCtx *cli.Context, p utils.Prompter) error {
http.DefaultClient,
)

if config.BatchClaimFile != "" {
return BatchClaim(cCtx, ethClient, elReader, df, config, p)
}

elClaim, claim, accounts, err := claimHelper(config.ClaimTimestamp, ctx, elReader, logger, config.EarnerAddress, df, config.TokenAddresses)

if err != nil {
Expand Down

0 comments on commit 6ea4abb

Please sign in to comment.