mirror of
https://github.com/wealdtech/ethdo.git
synced 2026-01-09 14:07:56 -05:00
Linting.
This commit is contained in:
@@ -142,7 +142,6 @@ linters:
|
|||||||
- gocognit
|
- gocognit
|
||||||
- goconst
|
- goconst
|
||||||
- goerr113
|
- goerr113
|
||||||
- gofumpt
|
|
||||||
- goheader
|
- goheader
|
||||||
- golint
|
- golint
|
||||||
- gomnd
|
- gomnd
|
||||||
|
|||||||
@@ -29,9 +29,11 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var jsonOutput bool
|
var (
|
||||||
var sszOutput bool
|
jsonOutput bool
|
||||||
var results *dataOut
|
sszOutput bool
|
||||||
|
results *dataOut
|
||||||
|
)
|
||||||
|
|
||||||
func process(ctx context.Context, data *dataIn) (*dataOut, error) {
|
func process(ctx context.Context, data *dataIn) (*dataOut, error) {
|
||||||
if data == nil {
|
if data == nil {
|
||||||
|
|||||||
@@ -29,12 +29,14 @@ import (
|
|||||||
string2eth "github.com/wealdtech/go-string2eth"
|
string2eth "github.com/wealdtech/go-string2eth"
|
||||||
)
|
)
|
||||||
|
|
||||||
var depositVerifyData string
|
var (
|
||||||
var depositVerifyWithdrawalPubKey string
|
depositVerifyData string
|
||||||
var depositVerifyWithdrawalAddress string
|
depositVerifyWithdrawalPubKey string
|
||||||
var depositVerifyValidatorPubKey string
|
depositVerifyWithdrawalAddress string
|
||||||
var depositVerifyDepositAmount string
|
depositVerifyValidatorPubKey string
|
||||||
var depositVerifyForkVersion string
|
depositVerifyDepositAmount string
|
||||||
|
depositVerifyForkVersion string
|
||||||
|
)
|
||||||
|
|
||||||
var depositVerifyCmd = &cobra.Command{
|
var depositVerifyCmd = &cobra.Command{
|
||||||
Use: "verify",
|
Use: "verify",
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ func (c *command) activeValidators(ctx context.Context) (map[phase0.ValidatorInd
|
|||||||
|
|
||||||
return activeValidators, nil
|
return activeValidators, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *command) processAttesterDuties(ctx context.Context) error {
|
func (c *command) processAttesterDuties(ctx context.Context) error {
|
||||||
activeValidators, err := c.activeValidators(ctx)
|
activeValidators, err := c.activeValidators(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
10
cmd/root.go
10
cmd/root.go
@@ -33,10 +33,12 @@ import (
|
|||||||
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
|
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cfgFile string
|
var (
|
||||||
var quiet bool
|
cfgFile string
|
||||||
var verbose bool
|
quiet bool
|
||||||
var debug bool
|
verbose bool
|
||||||
|
debug bool
|
||||||
|
)
|
||||||
|
|
||||||
// RootCmd represents the base command when called without any subcommands.
|
// RootCmd represents the base command when called without any subcommands.
|
||||||
var RootCmd = &cobra.Command{
|
var RootCmd = &cobra.Command{
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ func init() {
|
|||||||
RootCmd.AddCommand(signatureCmd)
|
RootCmd.AddCommand(signatureCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
var dataFlag *pflag.Flag
|
var (
|
||||||
var domainFlag *pflag.Flag
|
dataFlag *pflag.Flag
|
||||||
|
domainFlag *pflag.Flag
|
||||||
|
)
|
||||||
|
|
||||||
func signatureFlags(cmd *cobra.Command) {
|
func signatureFlags(cmd *cobra.Command) {
|
||||||
if dataFlag == nil {
|
if dataFlag == nil {
|
||||||
|
|||||||
@@ -27,8 +27,10 @@ import (
|
|||||||
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
|
e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var signatureVerifySignature string
|
var (
|
||||||
var signatureVerifySigner string
|
signatureVerifySignature string
|
||||||
|
signatureVerifySigner string
|
||||||
|
)
|
||||||
|
|
||||||
// signatureVerifyCmd represents the signature verify command.
|
// signatureVerifyCmd represents the signature verify command.
|
||||||
var signatureVerifyCmd = &cobra.Command{
|
var signatureVerifyCmd = &cobra.Command{
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ func (c *command) writeChainInfoToFile(_ context.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := os.WriteFile(offlinePreparationFilename, data, 0600); err != nil {
|
if err := os.WriteFile(offlinePreparationFilename, data, 0o600); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func (c *command) output(_ context.Context) (string, error) {
|
|||||||
if c.json {
|
if c.json {
|
||||||
return string(data), nil
|
return string(data), nil
|
||||||
}
|
}
|
||||||
if err := os.WriteFile(changeOperationsFilename, data, 0600); err != nil {
|
if err := os.WriteFile(changeOperationsFilename, data, 0o600); err != nil {
|
||||||
return "", errors.Wrap(err, fmt.Sprintf("failed to write %s", changeOperationsFilename))
|
return "", errors.Wrap(err, fmt.Sprintf("failed to write %s", changeOperationsFilename))
|
||||||
}
|
}
|
||||||
return "", nil
|
return "", nil
|
||||||
|
|||||||
@@ -47,8 +47,10 @@ var minTimeout = 2 * time.Minute
|
|||||||
// validatorPath is the regular expression that matches a validator path.
|
// validatorPath is the regular expression that matches a validator path.
|
||||||
var validatorPath = regexp.MustCompile("^m/12381/3600/[0-9]+/0/0$")
|
var validatorPath = regexp.MustCompile("^m/12381/3600/[0-9]+/0/0$")
|
||||||
|
|
||||||
var offlinePreparationFilename = "offline-preparation.json"
|
var (
|
||||||
var changeOperationsFilename = "change-operations.json"
|
offlinePreparationFilename = "offline-preparation.json"
|
||||||
|
changeOperationsFilename = "change-operations.json"
|
||||||
|
)
|
||||||
|
|
||||||
func (c *command) process(ctx context.Context) error {
|
func (c *command) process(ctx context.Context) error {
|
||||||
if err := c.setup(ctx); err != nil {
|
if err := c.setup(ctx); err != nil {
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ func (c *command) writeChainInfoToFile(_ context.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := os.WriteFile(offlinePreparationFilename, data, 0600); err != nil {
|
if err := os.WriteFile(offlinePreparationFilename, data, 0o600); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func (c *command) output(_ context.Context) (string, error) {
|
|||||||
if c.json {
|
if c.json {
|
||||||
return string(data), nil
|
return string(data), nil
|
||||||
}
|
}
|
||||||
if err := os.WriteFile(exitOperationFilename, data, 0600); err != nil {
|
if err := os.WriteFile(exitOperationFilename, data, 0o600); err != nil {
|
||||||
return "", errors.Wrap(err, fmt.Sprintf("failed to write %s", exitOperationFilename))
|
return "", errors.Wrap(err, fmt.Sprintf("failed to write %s", exitOperationFilename))
|
||||||
}
|
}
|
||||||
return "", nil
|
return "", nil
|
||||||
|
|||||||
@@ -46,8 +46,10 @@ var minTimeout = 2 * time.Minute
|
|||||||
// validatorPath is the regular expression that matches a validator path.
|
// validatorPath is the regular expression that matches a validator path.
|
||||||
var validatorPath = regexp.MustCompile("^m/12381/3600/[0-9]+/0/0$")
|
var validatorPath = regexp.MustCompile("^m/12381/3600/[0-9]+/0/0$")
|
||||||
|
|
||||||
var offlinePreparationFilename = "offline-preparation.json"
|
var (
|
||||||
var exitOperationFilename = "exit-operation.json"
|
offlinePreparationFilename = "offline-preparation.json"
|
||||||
|
exitOperationFilename = "exit-operation.json"
|
||||||
|
)
|
||||||
|
|
||||||
func (c *command) process(ctx context.Context) error {
|
func (c *command) process(ctx context.Context) error {
|
||||||
if err := c.setup(ctx); err != nil {
|
if err := c.setup(ctx); err != nil {
|
||||||
|
|||||||
@@ -40,9 +40,11 @@ func (c *command) process(ctx context.Context) error {
|
|||||||
return c.calculateYield(ctx)
|
return c.calculateYield(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
var weiPerGwei = decimal.New(1e9, 0)
|
var (
|
||||||
var one = decimal.New(1, 0)
|
weiPerGwei = decimal.New(1e9, 0)
|
||||||
var epochsPerYear = decimal.New(225*365, 0)
|
one = decimal.New(1, 0)
|
||||||
|
epochsPerYear = decimal.New(225*365, 0)
|
||||||
|
)
|
||||||
|
|
||||||
// calculateYield calculates yield from the number of active validators.
|
// calculateYield calculates yield from the number of active validators.
|
||||||
func (c *command) calculateYield(ctx context.Context) error {
|
func (c *command) calculateYield(ctx context.Context) error {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func process(ctx context.Context, data *dataIn) (*dataOut, error) {
|
|||||||
return nil, errors.Wrap(err, "failed to marshal shamir export")
|
return nil, errors.Wrap(err, "failed to marshal shamir export")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(data.file, sharedFile, 0600); err != nil {
|
if err := os.WriteFile(data.file, sharedFile, 0o600); err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to write export file")
|
return nil, errors.Wrap(err, "failed to write export file")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func TestInput(t *testing.T) {
|
|||||||
dir, err := os.MkdirTemp("", "")
|
dir, err := os.MkdirTemp("", "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
datFile := filepath.Join(dir, "backup.dat")
|
datFile := filepath.Join(dir, "backup.dat")
|
||||||
require.NoError(t, os.WriteFile(datFile, []byte("dummy"), 0600))
|
require.NoError(t, os.WriteFile(datFile, []byte("dummy"), 0o600))
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
|
|
||||||
store := scratch.New()
|
store := scratch.New()
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ func TestProcess(t *testing.T) {
|
|||||||
dir, err := os.MkdirTemp("", "")
|
dir, err := os.MkdirTemp("", "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
datFile := filepath.Join(dir, "backup.dat")
|
datFile := filepath.Join(dir, "backup.dat")
|
||||||
require.NoError(t, os.WriteFile(datFile, export, 0600))
|
require.NoError(t, os.WriteFile(datFile, export, 0o600))
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ var Log zerolog.Logger
|
|||||||
func InitLogging() error {
|
func InitLogging() error {
|
||||||
// Change the output file.
|
// Change the output file.
|
||||||
if viper.GetString("log-file") != "" {
|
if viper.GetString("log-file") != "" {
|
||||||
f, err := os.OpenFile(viper.GetString("log-file"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
|
f, err := os.OpenFile(viper.GetString("log-file"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to open log file")
|
return errors.Wrap(err, "failed to open log file")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestUnmarshal(t *testing.T) {
|
func TestUnmarshal(t *testing.T) {
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
in []byte
|
in []byte
|
||||||
|
|||||||
Reference in New Issue
Block a user