diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..8a4d370 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,58 @@ +run: + go: "1.22.2" + tests: true + timeout: 5m + concurrency: 4 + +linters: + enable: + - dogsled + - dupl + - errcheck + - goconst + - gocritic + - gofumpt + - revive + - gosec + - gosimple + - govet + - ineffassign + - misspell + - nakedret + - prealloc + - exportloopref + - staticcheck + - stylecheck + - typecheck + - unconvert + - unparam + - unused + - nolintlint + - asciicheck + - exportloopref + - gofumpt + - gomodguard + +linters-settings: + dogsled: + max-blank-identifiers: 3 + golint: + min-confidence: 0 + maligned: + suggest-new: true + misspell: + locale: US + nolintlint: + allow-unused: false + allow-leading-space: true + require-explanation: false + require-specific: false + gomodguard: + blocked: + versions: # List of blocked module version constraints + - https://github.com/etcd-io/etcd: # Blocked module with version constraint + version: ">= 3.4.10 || ~3.3.23" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons + reason: "CVE-2020-15114; CVE-2020-15136; CVE-2020-15115" # Reason why the version constraint exists. (Optional) + - https://github.com/dgrijalva/jwt-go: # Blocked module with version constraint + version: ">= 4.0.0-preview1" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons + reason: "CVE-2020-26160" # Reason why the version constraint exists. (Optional) diff --git a/Makefile b/Makefile index d0c432e..dc6aac4 100644 --- a/Makefile +++ b/Makefile @@ -3,3 +3,6 @@ dev-docs: @source /opt/homebrew/opt/nvm/nvm.sh && nvm use && npm run docs:dev +lint: + golangci-lint run --fix --out-format=line-number --issues-exit-code=0 --config .golangci.yml --color always ./... + diff --git a/go.mod b/go.mod index f8824c3..61b2c0f 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( github.com/mailru/easyjson v0.7.7 github.com/miguelmota/go-ethereum-hdwallet v0.1.1 github.com/valyala/fasthttp v1.55.0 - ) require ( @@ -47,7 +46,7 @@ require ( github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect - github.com/cosmos/gogoproto v1.4.10 // indirect + github.com/cosmos/gogoproto v1.4.12 // indirect github.com/cosmos/iavl v0.21.0-alpha.1.0.20230904092046-df3db2d96583 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect @@ -144,7 +143,7 @@ require ( go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.9.0 // indirect golang.org/x/crypto v0.24.0 // indirect - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/net v0.26.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.21.0 // indirect @@ -164,7 +163,6 @@ require ( ) replace ( - // the go-ethereum-hdwallet uses an old version of the btcutil lib, should replace in the future github.com/btcsuite/btcutil => github.com/btcsuite/btcd/btcutil v1.1.5 github.com/cosmos/cosmos-sdk => github.com/evmos/cosmos-sdk v0.47.8-evmos diff --git a/go.sum b/go.sum index b819f04..8ed4a35 100644 --- a/go.sum +++ b/go.sum @@ -194,8 +194,8 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI= -github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoKuI= -github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek= +github.com/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8JpFE= +github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY= github.com/cosmos/iavl v0.21.0-alpha.1.0.20230904092046-df3db2d96583 h1:3Matt7/LjZiZkIBPalYazOZcw2B05Ch14dU5TJyqJEc= github.com/cosmos/iavl v0.21.0-alpha.1.0.20230904092046-df3db2d96583/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= github.com/cosmos/ibc-go/v7 v7.6.0 h1:S1G5hcIVe9go+jQV6F9+I9yy+hylbJeLiVHUmktQNrM= @@ -893,8 +893,8 @@ golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= diff --git a/lib/converter/hash.go b/lib/converter/hash.go index 2c964da..c71c6cd 100644 --- a/lib/converter/hash.go +++ b/lib/converter/hash.go @@ -16,5 +16,5 @@ func GenerateCosmosTxHashWithBase64(txInBase64 string) (string, error) { if err != nil { return "", err } - return GenerateCosmosTxHash([]byte(txBytes)), nil + return GenerateCosmosTxHash(txBytes), nil } diff --git a/lib/protoencoder/codec/codec.go b/lib/protoencoder/codec/codec.go index 23df117..ccdc3e8 100644 --- a/lib/protoencoder/codec/codec.go +++ b/lib/protoencoder/codec/codec.go @@ -34,7 +34,6 @@ import ( revenue "github.com/evmos/evmos/v18/x/revenue/v1/types" vesting "github.com/evmos/evmos/v18/x/vesting/types" - "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" authTx "github.com/cosmos/cosmos-sdk/x/auth/tx" ) diff --git a/lib/protoencoder/codec/hash.go b/lib/protoencoder/codec/hash.go deleted file mode 100644 index e69de29..0000000 diff --git a/lib/smartcontract/erc20/get.go b/lib/smartcontract/erc20/get.go index 578984a..87f1711 100644 --- a/lib/smartcontract/erc20/get.go +++ b/lib/smartcontract/erc20/get.go @@ -1,9 +1,8 @@ package erc20 import ( - "fmt" - "encoding/hex" + "fmt" "math" "math/big" diff --git a/lib/txbuilder/contract.go b/lib/txbuilder/contract.go index eef0adf..20c5001 100644 --- a/lib/txbuilder/contract.go +++ b/lib/txbuilder/contract.go @@ -1,8 +1,6 @@ package txbuilder import ( - "math/big" - "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" ) diff --git a/lib/types/cosmos/cosmos_block.go b/lib/types/cosmos/cosmos_block.go index 53b06f0..ca805ee 100644 --- a/lib/types/cosmos/cosmos_block.go +++ b/lib/types/cosmos/cosmos_block.go @@ -2,7 +2,7 @@ package cosmos import "time" -type CosmosBlockResult struct { +type CosmosBlockResult struct { //nolint: revive // Is the field "Txs" used? // Txs []any `json:"txs"` BlockID struct {