Lint imports

This commit is contained in:
Kirill Fedoseev 2022-05-22 15:29:01 +04:00
parent 9270c9911c
commit b3cc0be853
36 changed files with 124 additions and 91 deletions

View File

@ -4,14 +4,15 @@ import (
"context" "context"
"fmt" "fmt"
"time" "time"
"tokenbridge-monitor/config"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
"tokenbridge-monitor/ethclient"
"tokenbridge-monitor/logging"
"tokenbridge-monitor/repository"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/poanetwork/tokenbridge-monitor/config"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
"github.com/poanetwork/tokenbridge-monitor/ethclient"
"github.com/poanetwork/tokenbridge-monitor/logging"
"github.com/poanetwork/tokenbridge-monitor/repository"
) )
func main() { func main() {

View File

@ -5,15 +5,16 @@ import (
"net/http" "net/http"
"os" "os"
"os/signal" "os/signal"
"tokenbridge-monitor/config"
"tokenbridge-monitor/db"
"tokenbridge-monitor/ethclient"
"tokenbridge-monitor/logging"
"tokenbridge-monitor/monitor"
"tokenbridge-monitor/presenter"
"tokenbridge-monitor/repository"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/poanetwork/tokenbridge-monitor/config"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/ethclient"
"github.com/poanetwork/tokenbridge-monitor/logging"
"github.com/poanetwork/tokenbridge-monitor/monitor"
"github.com/poanetwork/tokenbridge-monitor/presenter"
"github.com/poanetwork/tokenbridge-monitor/repository"
) )
func main() { func main() {

View File

@ -3,11 +3,12 @@ package contract
import ( import (
"context" "context"
"fmt" "fmt"
"tokenbridge-monitor/config"
"tokenbridge-monitor/contract/abi"
"tokenbridge-monitor/ethclient"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/config"
"github.com/poanetwork/tokenbridge-monitor/contract/abi"
"github.com/poanetwork/tokenbridge-monitor/ethclient"
) )
type BridgeContract struct { type BridgeContract struct {

View File

@ -3,12 +3,13 @@ package contract
import ( import (
"context" "context"
"fmt" "fmt"
"tokenbridge-monitor/entity"
"tokenbridge-monitor/ethclient"
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/entity"
"github.com/poanetwork/tokenbridge-monitor/ethclient"
) )
type Contract struct { type Contract struct {

View File

@ -2,10 +2,11 @@ package contract
import ( import (
"fmt" "fmt"
"tokenbridge-monitor/entity"
"github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
func Indexed(args abi.Arguments) abi.Arguments { func Indexed(args abi.Arguments) abi.Arguments {

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"runtime" "runtime"
"strings" "strings"
"tokenbridge-monitor/config"
"github.com/golang-migrate/migrate/v4" "github.com/golang-migrate/migrate/v4"
_ "github.com/golang-migrate/migrate/v4/database/pgx" _ "github.com/golang-migrate/migrate/v4/database/pgx"
@ -14,6 +13,8 @@ import (
_ "github.com/jackc/pgx/v4/stdlib" _ "github.com/jackc/pgx/v4/stdlib"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
_ "github.com/lib/pq" _ "github.com/lib/pq"
"github.com/poanetwork/tokenbridge-monitor/config"
) )
type DB struct { type DB struct {

2
go.mod
View File

@ -1,4 +1,4 @@
module tokenbridge-monitor module github.com/poanetwork/tokenbridge-monitor
go 1.17 go 1.17

View File

@ -4,9 +4,10 @@ import (
"context" "context"
"fmt" "fmt"
"time" "time"
"tokenbridge-monitor/config"
"tokenbridge-monitor/db" "github.com/poanetwork/tokenbridge-monitor/config"
"tokenbridge-monitor/logging" "github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/logging"
) )
type AlertManager struct { type AlertManager struct {

View File

@ -4,11 +4,12 @@ import (
"context" "context"
"fmt" "fmt"
"time" "time"
"tokenbridge-monitor/db"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/lib/pq" "github.com/lib/pq"
"github.com/poanetwork/tokenbridge-monitor/db"
) )
type DBAlertsProvider struct { type DBAlertsProvider struct {

View File

@ -6,11 +6,12 @@ import (
"fmt" "fmt"
"strconv" "strconv"
"time" "time"
"tokenbridge-monitor/logging"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/poanetwork/tokenbridge-monitor/logging"
) )
type AlertJobParams struct { type AlertJobParams struct {

View File

@ -8,14 +8,6 @@ import (
"sort" "sort"
"sync" "sync"
"time" "time"
"tokenbridge-monitor/config"
"tokenbridge-monitor/contract"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
"tokenbridge-monitor/ethclient"
"tokenbridge-monitor/logging"
"tokenbridge-monitor/repository"
"tokenbridge-monitor/utils"
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -23,6 +15,15 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/poanetwork/tokenbridge-monitor/config"
"github.com/poanetwork/tokenbridge-monitor/contract"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
"github.com/poanetwork/tokenbridge-monitor/ethclient"
"github.com/poanetwork/tokenbridge-monitor/logging"
"github.com/poanetwork/tokenbridge-monitor/repository"
"github.com/poanetwork/tokenbridge-monitor/utils"
) )
const defaultSyncedThreshold = 10 const defaultSyncedThreshold = 10

View File

@ -3,10 +3,11 @@ package monitor
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"tokenbridge-monitor/entity"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
func unmarshalMessage(bridgeID string, direction entity.Direction, encodedData []byte) *entity.Message { func unmarshalMessage(bridgeID string, direction entity.Direction, encodedData []byte) *entity.Message {

View File

@ -5,15 +5,16 @@ import (
"errors" "errors"
"fmt" "fmt"
"math/big" "math/big"
"tokenbridge-monitor/config"
"tokenbridge-monitor/contract/abi"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
"tokenbridge-monitor/ethclient"
"tokenbridge-monitor/repository"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/poanetwork/tokenbridge-monitor/config"
"github.com/poanetwork/tokenbridge-monitor/contract/abi"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
"github.com/poanetwork/tokenbridge-monitor/ethclient"
"github.com/poanetwork/tokenbridge-monitor/repository"
) )
type EventHandler func(ctx context.Context, log *entity.Log, data map[string]interface{}) error type EventHandler func(ctx context.Context, log *entity.Log, data map[string]interface{}) error

View File

@ -3,13 +3,14 @@ package monitor
import ( import (
"context" "context"
"fmt" "fmt"
"tokenbridge-monitor/config"
"tokenbridge-monitor/contract/abi" "github.com/poanetwork/tokenbridge-monitor/config"
"tokenbridge-monitor/db" "github.com/poanetwork/tokenbridge-monitor/contract/abi"
"tokenbridge-monitor/ethclient" "github.com/poanetwork/tokenbridge-monitor/db"
"tokenbridge-monitor/logging" "github.com/poanetwork/tokenbridge-monitor/ethclient"
"tokenbridge-monitor/monitor/alerts" "github.com/poanetwork/tokenbridge-monitor/logging"
"tokenbridge-monitor/repository" "github.com/poanetwork/tokenbridge-monitor/monitor/alerts"
"github.com/poanetwork/tokenbridge-monitor/repository"
) )
type Monitor struct { type Monitor struct {

View File

@ -2,9 +2,10 @@ package monitor
import ( import (
"math" "math"
"tokenbridge-monitor/entity"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type BlocksRange struct { type BlocksRange struct {

View File

@ -2,10 +2,11 @@ package monitor_test
import ( import (
"testing" "testing"
"tokenbridge-monitor/entity"
"tokenbridge-monitor/monitor"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/poanetwork/tokenbridge-monitor/entity"
"github.com/poanetwork/tokenbridge-monitor/monitor"
) )
func TestSplitBlockRange(t *testing.T) { func TestSplitBlockRange(t *testing.T) {

View File

@ -4,10 +4,11 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"time" "time"
"tokenbridge-monitor/logging"
"github.com/go-chi/chi/v5/middleware" "github.com/go-chi/chi/v5/middleware"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/poanetwork/tokenbridge-monitor/logging"
) )
func NewRequestLogger(logger logging.Logger) func(next http.Handler) http.Handler { func NewRequestLogger(logger logging.Logger) func(next http.Handler) http.Handler {

View File

@ -8,15 +8,16 @@ import (
"net/http" "net/http"
"regexp" "regexp"
"strconv" "strconv"
"tokenbridge-monitor/config"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
"tokenbridge-monitor/logging"
"tokenbridge-monitor/repository"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware" "github.com/go-chi/chi/v5/middleware"
"github.com/poanetwork/tokenbridge-monitor/config"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
"github.com/poanetwork/tokenbridge-monitor/logging"
"github.com/poanetwork/tokenbridge-monitor/repository"
) )
type Presenter struct { type Presenter struct {

View File

@ -2,10 +2,11 @@ package presenter
import ( import (
"time" "time"
"tokenbridge-monitor/entity"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type MessageInfo struct { type MessageInfo struct {

View File

@ -2,7 +2,8 @@ package presenter
import ( import (
"fmt" "fmt"
"tokenbridge-monitor/entity"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
var formats = map[string]string{ var formats = map[string]string{

View File

@ -1,7 +1,7 @@
package postgres package postgres
import ( import (
"tokenbridge-monitor/db" "github.com/poanetwork/tokenbridge-monitor/db"
) )
type basePostgresRepo struct { type basePostgresRepo struct {

View File

@ -5,10 +5,11 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type blockTimestampsRepo basePostgresRepo type blockTimestampsRepo basePostgresRepo

View File

@ -5,11 +5,12 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type bridgeValidatorsRepo basePostgresRepo type bridgeValidatorsRepo basePostgresRepo

View File

@ -5,11 +5,12 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type collectedMessagesRepo basePostgresRepo type collectedMessagesRepo basePostgresRepo

View File

@ -5,11 +5,12 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type ercToNativeMessagesRepo basePostgresRepo type ercToNativeMessagesRepo basePostgresRepo

View File

@ -5,11 +5,12 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type executedInformationRequestsRepo basePostgresRepo type executedInformationRequestsRepo basePostgresRepo

View File

@ -5,11 +5,12 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type executedMessagesRepo basePostgresRepo type executedMessagesRepo basePostgresRepo

View File

@ -5,11 +5,12 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type informationRequestsRepo basePostgresRepo type informationRequestsRepo basePostgresRepo

View File

@ -3,11 +3,12 @@ package postgres
import ( import (
"context" "context"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type logsRepo basePostgresRepo type logsRepo basePostgresRepo

View File

@ -5,11 +5,12 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type logsCursorsRepo basePostgresRepo type logsCursorsRepo basePostgresRepo

View File

@ -5,11 +5,12 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type messagesRepo basePostgresRepo type messagesRepo basePostgresRepo

View File

@ -5,11 +5,12 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type sentInformationRequestsRepo basePostgresRepo type sentInformationRequestsRepo basePostgresRepo

View File

@ -5,11 +5,12 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type sentMessagesRepo basePostgresRepo type sentMessagesRepo basePostgresRepo

View File

@ -5,11 +5,12 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type signedInformationRequestsRepo basePostgresRepo type signedInformationRequestsRepo basePostgresRepo

View File

@ -5,11 +5,12 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
"tokenbridge-monitor/db"
"tokenbridge-monitor/entity"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/poanetwork/tokenbridge-monitor/db"
"github.com/poanetwork/tokenbridge-monitor/entity"
) )
type signedMessagesRepo basePostgresRepo type signedMessagesRepo basePostgresRepo

View File

@ -1,9 +1,9 @@
package repository package repository
import ( import (
"tokenbridge-monitor/db" "github.com/poanetwork/tokenbridge-monitor/db"
"tokenbridge-monitor/entity" "github.com/poanetwork/tokenbridge-monitor/entity"
"tokenbridge-monitor/repository/postgres" "github.com/poanetwork/tokenbridge-monitor/repository/postgres"
) )
type Repo struct { type Repo struct {