Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed lint errors #1270

Merged
merged 6 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/wardend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ on:
- "cmd/wardend/**"
- "warden/**"
- "precompiles/**"
- "prophet/**"
tags:
- "wardend/v*"
pull_request:
paths:
- "cmd/wardend/**"
- "warden/**"
- "precompiles/**"
- "prophet/**"

env:
modules: "./warden/... ./cmd/wardend/... ./cmd/faucet/..."
modules: "./warden/... ./cmd/wardend/... ./cmd/faucet/... ./prophet/... ./precompiles/..."

jobs:
lint:
Expand Down
6 changes: 3 additions & 3 deletions cmd/shield_repl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ func main() {
exp, err := shield.Parse(line)

if err != nil {
io.WriteString(os.Stderr, err.Error())
io.WriteString(os.Stderr, err.Error()) //nolint:all
continue
}

evaluated := shield.Eval(exp, env)
if evaluated != nil {
io.WriteString(os.Stdout, evaluated.Inspect())
io.WriteString(os.Stdout, "\n")
io.WriteString(os.Stdout, evaluated.Inspect()) //nolint:all
io.WriteString(os.Stdout, "\n") //nolint:all
}
}
}
5 changes: 4 additions & 1 deletion precompiles/async/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ func (p *Precompile) GetCreateFutureEvent(ctx sdk.Context, writerAddress *ethcmn
}

topics[1], err = evmoscmn.MakeTopic(typedEvent.GetId())
topics[2], err = evmoscmn.MakeTopic(creatorAddress)
if err != nil {
return nil, err
}

topics[2], err = evmoscmn.MakeTopic(creatorAddress)
if err != nil {
return nil, err
}
Expand Down
13 changes: 10 additions & 3 deletions precompiles/common/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ import (
// Takes sdk.Event as proto msg, passes it to fillEvent.
// fillEvent should create typed event for caller.
func ParseSdkEvent(sdkEvent sdk.Event, fillEvent func(proto.Message)) error {
return ParseSdkEventSafe(sdkEvent, func(msg proto.Message) error {
fillEvent(msg)
return nil
})
}

// Takes sdk.Event as proto msg, passes it to fillEvent.
// fillEvent should create typed event for caller.
func ParseSdkEventSafe(sdkEvent sdk.Event, fillEvent func(proto.Message) error) error {
events := sdk.EmptyEvents().AppendEvent(sdkEvent).ToABCIEvents()
event := events[0]

Expand All @@ -16,7 +25,5 @@ func ParseSdkEvent(sdkEvent sdk.Event, fillEvent func(proto.Message)) error {
return err
}

fillEvent(msg)

return nil
return fillEvent(msg)
}
4 changes: 2 additions & 2 deletions precompiles/warden/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ func (p Precompile) GetUpdateKeychainEvent(ctx sdk.Context, _ *common.Address, e
// use Marshal/Unmarshal here cause big.Word=uint inside big.Int is not correctly merged in cosmos.gogoproto
var err error
var marshaled []byte
if err := precommon.ParseSdkEvent(eventUpdateKeychain, func(m proto.Message) {
if err := precommon.ParseSdkEventSafe(eventUpdateKeychain, func(m proto.Message) error {
marshaled, err = proto.Marshal(m)
typedEvent.Unmarshal(marshaled)
return typedEvent.Unmarshal(marshaled)
}); err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion prophet/handlers/echo/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (s Handler) Execute(ctx context.Context, input []byte) ([]byte, error) {
}

func (s Handler) Verify(ctx context.Context, input []byte, output []byte) error {
if bytes.Compare(input, output) != 0 {
if !bytes.Equal(input, output) {
return fmt.Errorf("input and output do not match")
}
return nil
Expand Down
5 changes: 1 addition & 4 deletions prophet/handlers/pricepred/pricepred.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ func (s PricePredictorSolidity) Execute(ctx context.Context, input []byte) ([]by

var backtestingRes *BacktestingResponse
if len(inputData.Metrics) > 0 {
res, err := s.c.Backtesting(ctx, BacktestingRequest{
SolverInput: req.SolverInput,
FalsePositiveRate: req.FalsePositiveRate,
})
res, err := s.c.Backtesting(ctx, BacktestingRequest(req))
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/exec/warden_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (w *WardenNode) GRPCClient(t *testing.T) *GRPCClient {
grpc.WithTransportCredentials(insecurecreds.NewCredentials()),
}

grpcConn, err := grpc.Dial(w.grpcAddr(), opts...)
grpcConn, err := grpc.NewClient(w.grpcAddr(), opts...)
require.NoError(t, err)

return &GRPCClient{
Expand Down
8 changes: 6 additions & 2 deletions tests/framework/files/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ func CloneDir(dest, src string, templateData any) error {

for _, entry := range entries {
if entry.IsDir() {
CloneDir(dest+"/"+entry.Name(), src+"/"+entry.Name(), templateData)
if err := CloneDir(dest+"/"+entry.Name(), src+"/"+entry.Name(), templateData); err != nil {
return err
}
} else {
if strings.HasSuffix(entry.Name(), ".tmpl") {
// render template
Expand All @@ -35,7 +37,9 @@ func CloneDir(dest, src string, templateData any) error {
return err
}

t.Execute(out, templateData)
if err := t.Execute(out, templateData); err != nil {
return err
}
} else {
// copy file
out, err := os.Create(dest + "/" + entry.Name())
Expand Down
Loading