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

Fix lint error in /methods and remove usage of internal error package #285

Merged
merged 9 commits into from
Sep 9, 2024
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
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
Loading