Skip to content

Commit

Permalink
fix lint issues (#14450)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Sep 18, 2024
1 parent 328b62a commit 1a9f269
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion core/chains/evm/client/config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewClientConfigs(
chainConfig := &evmconfig.EVMConfig{
C: &toml.EVMConfig{
Chain: toml.Chain{
ChainType: chaintype.NewChainTypeConfig(chainType),
ChainType: chaintype.NewConfig(chainType),
FinalityDepth: finalityDepth,
FinalityTagEnabled: finalityTagEnabled,
NoNewHeadsThreshold: commonconfig.MustNewDuration(noNewHeadsThreshold),
Expand Down
24 changes: 12 additions & 12 deletions core/chains/evm/config/chaintype/chaintype.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (c ChainType) IsValid() bool {
return false
}

func ChainTypeFromSlug(slug string) ChainType {
func FromSlug(slug string) ChainType {
switch slug {
case "arbitrum":
return ChainArbitrum
Expand Down Expand Up @@ -79,53 +79,53 @@ func ChainTypeFromSlug(slug string) ChainType {
}
}

type ChainTypeConfig struct {
type Config struct {
value ChainType
slug string
}

func NewChainTypeConfig(slug string) *ChainTypeConfig {
return &ChainTypeConfig{
value: ChainTypeFromSlug(slug),
func NewConfig(slug string) *Config {
return &Config{
value: FromSlug(slug),
slug: slug,
}
}

func (c *ChainTypeConfig) MarshalText() ([]byte, error) {
func (c *Config) MarshalText() ([]byte, error) {
if c == nil {
return nil, nil
}
return []byte(c.slug), nil
}

func (c *ChainTypeConfig) UnmarshalText(b []byte) error {
func (c *Config) UnmarshalText(b []byte) error {
c.slug = string(b)
c.value = ChainTypeFromSlug(c.slug)
c.value = FromSlug(c.slug)
return nil
}

func (c *ChainTypeConfig) Slug() string {
func (c *Config) Slug() string {
if c == nil {
return ""
}
return c.slug
}

func (c *ChainTypeConfig) ChainType() ChainType {
func (c *Config) ChainType() ChainType {
if c == nil {
return ""
}
return c.value
}

func (c *ChainTypeConfig) String() string {
func (c *Config) String() string {
if c == nil {
return ""
}
return string(c.value)
}

var ErrInvalidChainType = fmt.Errorf("must be one of %s or omitted", strings.Join([]string{
var ErrInvalid = fmt.Errorf("must be one of %s or omitted", strings.Join([]string{
string(ChainArbitrum),
string(ChainAstar),
string(ChainCelo),
Expand Down
4 changes: 2 additions & 2 deletions core/chains/evm/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ type Chain struct {
AutoCreateKey *bool
BlockBackfillDepth *uint32
BlockBackfillSkip *bool
ChainType *chaintype.ChainTypeConfig
ChainType *chaintype.Config
FinalityDepth *uint32
FinalityTagEnabled *bool
FlagsContractAddress *types.EIP55Address
Expand Down Expand Up @@ -376,7 +376,7 @@ type Chain struct {
func (c *Chain) ValidateConfig() (err error) {
if !c.ChainType.ChainType().IsValid() {
err = multierr.Append(err, commonconfig.ErrInvalid{Name: "ChainType", Value: c.ChainType.ChainType(),
Msg: chaintype.ErrInvalidChainType.Error()})
Msg: chaintype.ErrInvalid.Error()})
}

if c.GasEstimator.BumpTxDepth != nil && *c.GasEstimator.BumpTxDepth > *c.Transactions.MaxInFlight {
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/vrfv2plus/testnet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func main() {
for i := range preSeedSlice {
ps, err := proof.BigToSeed(preSeedSlice[i])
helpers.PanicErr(err)
extraArgs, err := extraargs.ExtraArgsV1(*nativePayment)
extraArgs, err := extraargs.EncodeV1(*nativePayment)
helpers.PanicErr(err)
preSeedData := proof.PreSeedDataV2Plus{
PreSeed: ps,
Expand Down Expand Up @@ -308,7 +308,7 @@ func main() {
helpers.PanicErr(err)

parsedSubID := parseUInt256String(*subID)
extraArgs, err := extraargs.ExtraArgsV1(*nativePayment)
extraArgs, err := extraargs.EncodeV1(*nativePayment)
helpers.PanicErr(err)
preSeedData := proof.PreSeedDataV2Plus{
PreSeed: ps,
Expand Down
2 changes: 1 addition & 1 deletion core/scripts/vrfv2plus/testnet/proofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func generateProofForV2Plus(e helpers.Environment) {
if !ok {
helpers.PanicErr(fmt.Errorf("unable to parse subID: %s %w", *subId, err))
}
extraArgs, err := extraargs.ExtraArgsV1(*nativePayment)
extraArgs, err := extraargs.EncodeV1(*nativePayment)
helpers.PanicErr(err)
preSeedData := proof.PreSeedDataV2Plus{
PreSeed: preSeed,
Expand Down
2 changes: 1 addition & 1 deletion core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ func TestConfig_Marshal(t *testing.T) {
},
BlockBackfillDepth: ptr[uint32](100),
BlockBackfillSkip: ptr(true),
ChainType: chaintype.NewChainTypeConfig("Optimism"),
ChainType: chaintype.NewConfig("Optimism"),
FinalityDepth: ptr[uint32](42),
FinalityTagEnabled: ptr[bool](false),
FlagsContractAddress: mustAddress("0xae4E781a6218A8031764928E88d457937A954fC3"),
Expand Down
1 change: 1 addition & 0 deletions core/services/relay/evm/mercury/wsrpc/mocks/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mocks

import (
"context"

grpc_connectivity "google.golang.org/grpc/connectivity"

"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury/wsrpc/pb"
Expand Down
4 changes: 2 additions & 2 deletions core/services/vrf/extraargs/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const boolAbiType = `[{ "type": "bool" }]`

var extraArgsV1Tag = crypto.Keccak256([]byte("VRF ExtraArgsV1"))[:4]

func FromExtraArgsV1(extraArgs []byte) (nativePayment bool, err error) {
func DecodeV1(extraArgs []byte) (nativePayment bool, err error) {
decodedBool, err := utils.ABIDecode(boolAbiType, extraArgs[functionSignatureLength:])
if err != nil {
return false, fmt.Errorf("failed to decode 0x%x to bool", extraArgs[functionSignatureLength:])
Expand All @@ -25,7 +25,7 @@ func FromExtraArgsV1(extraArgs []byte) (nativePayment bool, err error) {
return nativePayment, nil
}

func ExtraArgsV1(nativePayment bool) ([]byte, error) {
func EncodeV1(nativePayment bool) ([]byte, error) {
encodedArgs, err := utils.ABIEncode(boolAbiType, nativePayment)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions core/services/vrf/v2/coordinator_v2x_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func (c *coordinatorV2_5) ParseRandomWordsFulfilled(log types.Log) (RandomWordsF
}

func (c *coordinatorV2_5) RequestRandomWords(opts *bind.TransactOpts, keyHash [32]byte, subID *big.Int, requestConfirmations uint16, callbackGasLimit uint32, numWords uint32, payInEth bool) (*types.Transaction, error) {
extraArgs, err := extraargs.ExtraArgsV1(payInEth)
extraArgs, err := extraargs.EncodeV1(payInEth)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -569,7 +569,7 @@ func (r *v2_5RandomWordsRequested) CallbackGasLimit() uint32 {
}

func (r *v2_5RandomWordsRequested) NativePayment() bool {
nativePayment, err := extraargs.FromExtraArgsV1(r.event.ExtraArgs)
nativePayment, err := extraargs.DecodeV1(r.event.ExtraArgs)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -1073,7 +1073,7 @@ func (r *RequestCommitment) NativePayment() bool {
if r.VRFVersion == vrfcommon.V2 {
return false
}
nativePayment, err := extraargs.FromExtraArgsV1(r.V2Plus.ExtraArgs)
nativePayment, err := extraargs.DecodeV1(r.V2Plus.ExtraArgs)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion core/services/vrf/v2/integration_v2_plus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ func requestAndEstimateFulfillmentCost(
requestLog := FindLatestRandomnessRequestedLog(t, uni.rootContract, vrfkey.PublicKey.MustHash(), nil)
s, err := proof.BigToSeed(requestLog.PreSeed())
require.NoError(t, err)
extraArgs, err := extraargs.ExtraArgsV1(nativePayment)
extraArgs, err := extraargs.EncodeV1(nativePayment)
require.NoError(t, err)
proof, rc, err := proof.GenerateProofResponseV2Plus(app.GetKeyStore().VRF(), vrfkey.ID(), proof.PreSeedDataV2Plus{
PreSeed: s,
Expand Down
10 changes: 5 additions & 5 deletions tools/txtar/visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ const (
NoRecurse RecurseOpt = false
)

type TxtarDirVisitor struct {
type DirVisitor struct {
rootDir string
cb func(path string) error
recurse RecurseOpt
}

func (d *TxtarDirVisitor) Walk() error {
func (d *DirVisitor) Walk() error {
return filepath.WalkDir(d.rootDir, func(path string, de fs.DirEntry, err error) error {
if err != nil {
return err
Expand Down Expand Up @@ -52,7 +52,7 @@ func (d *TxtarDirVisitor) Walk() error {
})
}

func (d *TxtarDirVisitor) isRootDir(de fs.DirEntry) (bool, error) {
func (d *DirVisitor) isRootDir(de fs.DirEntry) (bool, error) {
fi, err := os.Stat(d.rootDir)
if err != nil {
return false, err
Expand All @@ -65,8 +65,8 @@ func (d *TxtarDirVisitor) isRootDir(de fs.DirEntry) (bool, error) {
return os.SameFile(fi, fi2), nil
}

func NewDirVisitor(rootDir string, recurse RecurseOpt, cb func(path string) error) *TxtarDirVisitor {
return &TxtarDirVisitor{
func NewDirVisitor(rootDir string, recurse RecurseOpt, cb func(path string) error) *DirVisitor {
return &DirVisitor{
rootDir: rootDir,
cb: cb,
recurse: recurse,
Expand Down

0 comments on commit 1a9f269

Please sign in to comment.