Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix-linting' into fix-linting
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya1702 committed Sep 10, 2024
2 parents a2865ae + 6e8295c commit 4bfa2ab
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 82 deletions.
3 changes: 1 addition & 2 deletions cmd/soroban-rpc/internal/integrationtest/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import (
"runtime"
"testing"

"github.com/pkg/errors"
io_prometheus_client "github.com/prometheus/client_model/go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stellar/go/support/errors"

"github.com/stellar/soroban-rpc/cmd/soroban-rpc/internal/config"
"github.com/stellar/soroban-rpc/cmd/soroban-rpc/internal/integrationtest/infrastructure"
)
Expand Down
22 changes: 11 additions & 11 deletions cmd/soroban-rpc/internal/methods/get_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"time"

"github.com/creachadair/jrpc2"
"github.com/pkg/errors"

"github.com/stellar/go/strkey"
"github.com/stellar/go/support/collections/set"
"github.com/stellar/go/support/errors"
"github.com/stellar/go/support/log"
"github.com/stellar/go/xdr"

Expand Down Expand Up @@ -80,7 +80,7 @@ func (e eventTypeSet) matches(event xdr.ContractEvent) bool {
if len(e) == 0 {
return true
}
_, ok := e[eventTypeFromXDR[event.Type]]
_, ok := e[getEventTypeFromEventTypeXDR()[event.Type]]
return ok
}

Expand Down Expand Up @@ -119,7 +119,7 @@ func (g *GetEventsRequest) Valid(maxLimit uint) error {
// Validate the paging limit (if it exists)
if g.Pagination != nil && g.Pagination.Cursor != nil {
if g.StartLedger != 0 || g.EndLedger != 0 {
return errors.New("ledger ranges and cursor cannot both be set") //nolint:forbidigo
return errors.New("ledger ranges and cursor cannot both be set")
}
} else if g.StartLedger <= 0 {
return errors.New("startLedger must be positive")
Expand Down Expand Up @@ -160,10 +160,12 @@ const (
EventTypeDiagnostic = "diagnostic"
)

var eventTypeFromXDR = map[xdr.ContractEventType]string{
xdr.ContractEventTypeSystem: EventTypeSystem,
xdr.ContractEventTypeContract: EventTypeContract,
xdr.ContractEventTypeDiagnostic: EventTypeDiagnostic,
func getEventTypeFromEventTypeXDR() map[xdr.ContractEventType]string {
return map[xdr.ContractEventType]string{
xdr.ContractEventTypeSystem: EventTypeSystem,
xdr.ContractEventTypeContract: EventTypeContract,
xdr.ContractEventTypeDiagnostic: EventTypeDiagnostic,
}
}

func getEventTypeXDRFromEventType() map[string]xdr.ContractEventType {
Expand Down Expand Up @@ -523,7 +525,7 @@ func eventInfoForEvent(
return EventInfo{}, errors.New("unknown event version")
}

eventType, ok := eventTypeFromXDR[event.Event.Type]
eventType, ok := getEventTypeFromEventTypeXDR()[event.Event.Type]
if !ok {
return EventInfo{}, fmt.Errorf("unknown XDR ContractEventType type: %d", event.Event.Type)
}
Expand Down Expand Up @@ -600,7 +602,5 @@ func NewGetEventsHandler(
logger: logger,
ledgerReader: ledgerReader,
}
return NewHandler(func(ctx context.Context, request GetEventsRequest) (GetEventsResponse, error) {
return eventsHandler.getEvents(ctx, request)
})
return NewHandler(eventsHandler.getEvents)
}
Loading

0 comments on commit 4bfa2ab

Please sign in to comment.