From 6b75d9df3acab6bd9c808b12513348d36d10a649 Mon Sep 17 00:00:00 2001 From: Ajaz Ahmed Ansari Date: Wed, 1 Mar 2023 19:13:46 +0530 Subject: [PATCH] fix: ci (#329) * fix/ci * revert upgradehandler chnages * fix --- .github/CODEOWNERS | 4 ++++ .github/workflows/buildtest.yaml | 7 ++++-- .github/workflows/docker.yaml | 24 +++++++++++++++----- .github/workflows/golangci.yml | 1 - Dockerfile | 19 +++------------- Makefile | 16 +++++++++---- app/ante.go | 7 +++--- server/config/config.go | 7 +++--- wasmbinding/message_plugin.go | 30 ++++++++++++------------- wasmbinding/query_plugin.go | 11 +++++---- x/airdrop/handler.go | 3 ++- x/airdrop/types/errors.go | 2 +- x/claimsmanager/handler.go | 3 ++- x/claimsmanager/types/errors.go | 10 ++++----- x/epochs/handler.go | 3 ++- x/interchainquery/handler.go | 4 ++-- x/interchainstaking/handler.go | 5 +++-- x/interchainstaking/keeper/callbacks.go | 18 +++++++-------- x/interchainstaking/keeper/receipt.go | 6 ++--- x/participationrewards/handler.go | 5 +++-- x/participationrewards/types/errors.go | 22 +++++++++--------- x/tokenfactory/types/denoms.go | 2 +- x/tokenfactory/types/errors.go | 2 +- x/tokenfactory/types/genesis.go | 6 ++--- x/tokenfactory/types/msgs.go | 27 +++++++++++----------- 25 files changed, 132 insertions(+), 112 deletions(-) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..890cbd85b --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,4 @@ +# CODEOWNERS: https://help.github.com/articles/about-codeowners/ + +# Primary repo maintainers +* @joe-bowman @ajansari95 @aljo242 \ No newline at end of file diff --git a/.github/workflows/buildtest.yaml b/.github/workflows/buildtest.yaml index 5caff3fce..7fec7b5c6 100644 --- a/.github/workflows/buildtest.yaml +++ b/.github/workflows/buildtest.yaml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: '^1.19.4' + go-version: '1.19.6' env: GOOS: ${{ matrix.targetos }} GOARCH: ${{ matrix.arch }} @@ -54,7 +54,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: '^1.19.4' + go-version: '1.19.6' env: GOOS: ${{ matrix.targetos }} GOARCH: ${{ matrix.arch }} @@ -75,11 +75,14 @@ jobs: cat coverage.txt | grep .pb.go -v | grep .pb.gw.go -v | grep osmosis-types -v > coverage_nogen.txt - name: "Go vulnerability checks" + continue-on-error: true #temp-till we upgrade to v1.20 run: make vulncheck + - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v3 with: + token: ${{ secrets.CODECOV_TOKEN }} # needed for private repo files: ./coverage_nogen.txt flags: unittests fail_ci_if_error: true diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 9aa5cfb31..f9352f83f 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -9,6 +9,7 @@ jobs: docker: runs-on: ubuntu-latest steps: + - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -21,9 +22,22 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push evinced - uses: docker/build-push-action@v3 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: '1.19.6' + + - name: Setup Golang caches + uses: actions/cache@v3 with: - push: true - tags: quicksilverzone/quicksilver:latest - file: Dockerfile + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-golang- + + - name: build and push container + run: | + DOCKER_BUILDKIT=1 /usr/bin/docker build . -f Dockerfile -t quicksilverzone/quicksilver:latest + /usr/bin/docker push quicksilverzone/quicksilver:latest diff --git a/.github/workflows/golangci.yml b/.github/workflows/golangci.yml index 6b1a3af54..19b9a59e3 100644 --- a/.github/workflows/golangci.yml +++ b/.github/workflows/golangci.yml @@ -4,7 +4,6 @@ on: tags: - v* branches: - - master - main pull_request: permissions: diff --git a/Dockerfile b/Dockerfile index d2fb2fcf0..dff7d643b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,27 +12,14 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ # Cosmwasm - download correct libwasmvm version RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \ wget https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.$(uname -m).a \ - -O /lib/libwasmvm_muslc.a && \ - wget https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/checksums.txt -O /tmp/checksums.txt && \ + -O /lib/libwasmvm_muslc.a && \ + wget https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/checksums.txt -O /tmp/checksums.txt && \ sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep $(uname -m) | cut -d ' ' -f 1) COPY . . RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/go/pkg/mod \ - VERSION=$(echo $(git describe --tags) | sed 's/^v//') && \ - COMMIT=$(git log -1 --format='%H') && \ - go build \ - -mod=readonly \ - -tags "netgo,ledger,muslc" \ - -ldflags "-X github.com/cosmos/cosmos-sdk/version.Name="quicksilver" \ - -X github.com/cosmos/cosmos-sdk/version.AppName="quicksilverd" \ - -X github.com/cosmos/cosmos-sdk/version.Version=$VERSION \ - -X github.com/cosmos/cosmos-sdk/version.Commit=$COMMIT \ - -X github.com/cosmos/cosmos-sdk/version.BuildTags='netgo,ledger,muslc' \ - -w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \ - -trimpath \ - -o /src/app/build/ \ - ./... + LINK_STATICALLY=true make build # Add to a distroless container FROM alpine:3.17 diff --git a/Makefile b/Makefile index 384ef0b21..9310be8f5 100755 --- a/Makefile +++ b/Makefile @@ -94,6 +94,7 @@ endif ifeq ($(LINK_STATICALLY),true) ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static" + build_tags += muslc endif build_tags += $(BUILD_TAGS) @@ -144,7 +145,7 @@ $(BUILDDIR)/: mkdir -p $(BUILDDIR)/ build-docker: - DOCKER_BUILDKIT=1 $(DOCKER) build . -f Dockerfile -t quicksilverzone/quicksilver:$(DOCKER_VERSION) + DOCKER_BUILDKIT=1 $(DOCKER) build . -f Dockerfile -t quicksilverzone/quicksilver:$(DOCKER_VERSION) -t quicksilverzone/quicksilver:latest build-docker-local: build DOCKER_BUILDKIT=1 $(DOCKER) build -f Dockerfile.local . -t quicksilverzone/quicksilver:$(DOCKER_VERSION) @@ -316,13 +317,13 @@ test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT) run-tests: ifneq (,$(shell which tparse 2>/dev/null)) - go test -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse + go test -short -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse else - go test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) + go test -short -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) endif test-import: - @go test ./tests/importer -v --vet=off --run=TestImportBlocks --datadir tmp \ + @go test -short ./tests/importer -v --vet=off --run=TestImportBlocks --datadir tmp \ --blockchain blockchain rm -rf tests/importer/tmp @@ -404,6 +405,13 @@ format: find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs goimports -w -local github.com/ingenuity-build/quicksilver .PHONY: format +mdlint: + @echo "--> Running markdown linter" + @docker run -v $(PWD):/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.md" + +mdlint-fix: + @docker run -v $(PWD):/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.md" --fix + ############################################################################### ### Protobuf ### ############################################################################### diff --git a/app/ante.go b/app/ante.go index 086fdf79d..29cb55b9a 100644 --- a/app/ante.go +++ b/app/ante.go @@ -1,6 +1,7 @@ package app import ( + sdkioerrors "cosmossdk.io/errors" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -24,13 +25,13 @@ type HandlerOptions struct { func NewAnteHandler(options HandlerOptions) sdk.AnteHandler { if options.AccountKeeper == nil { - panic(sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")) + panic(sdkioerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")) } if options.BankKeeper == nil { - panic(sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")) + panic(sdkioerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")) } if options.SignModeHandler == nil { - panic(sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")) + panic(sdkioerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")) } sigGasConsumer := options.SigGasConsumer diff --git a/server/config/config.go b/server/config/config.go index 85c32fe0d..6ded4e77f 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -4,11 +4,10 @@ import ( "fmt" "path" - "github.com/spf13/viper" - + sdkioerrors "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/server/config" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/spf13/viper" ) const ( @@ -122,7 +121,7 @@ func ParseConfig(v *viper.Viper) (*Config, error) { // ValidateBasic returns an error any of the application configuration fields are invalid func (c Config) ValidateBasic() error { if err := c.TLS.Validate(); err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrAppConfig, "invalid tls config value: %s", err.Error()) + return sdkioerrors.Wrapf(sdkerrors.ErrAppConfig, "invalid tls config value: %s", err.Error()) } return c.Config.ValidateBasic() diff --git a/wasmbinding/message_plugin.go b/wasmbinding/message_plugin.go index a9e637477..a95441f5b 100644 --- a/wasmbinding/message_plugin.go +++ b/wasmbinding/message_plugin.go @@ -3,10 +3,10 @@ package wasmbinding import ( "encoding/json" + sdkioerrors "cosmossdk.io/errors" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmvmtypes "github.com/CosmWasm/wasmvm/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/ingenuity-build/quicksilver/wasmbinding/bindings" @@ -41,7 +41,7 @@ func (m *CustomMessenger) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddre // leave everything else for the wrapped version var contractMsg bindings.TokenFactoryMsg if err := json.Unmarshal(msg.Custom, &contractMsg); err != nil { - return nil, nil, sdkerrors.Wrap(err, "TokenFactoryMsg msg") + return nil, nil, sdkioerrors.Wrap(err, "TokenFactoryMsg msg") } if contractMsg.CreateDenom != nil { return m.createDenom(ctx, contractAddr, contractMsg.CreateDenom) @@ -63,7 +63,7 @@ func (m *CustomMessenger) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddre func (m *CustomMessenger) createDenom(ctx sdk.Context, contractAddr sdk.AccAddress, createDenom *bindings.CreateDenom) ([]sdk.Event, [][]byte, error) { err := PerformCreateDenom(m.tokenFactory, m.bank, ctx, contractAddr, createDenom) if err != nil { - return nil, nil, sdkerrors.Wrap(err, "perform create denom") + return nil, nil, sdkioerrors.Wrap(err, "perform create denom") } return nil, nil, nil } @@ -79,7 +79,7 @@ func PerformCreateDenom(f *tokenfactorykeeper.Keeper, b *bankkeeper.BaseKeeper, msgCreateDenom := tokenfactorytypes.NewMsgCreateDenom(contractAddr.String(), createDenom.Subdenom) if err := msgCreateDenom.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "failed validating MsgCreateDenom") + return sdkioerrors.Wrap(err, "failed validating MsgCreateDenom") } // Create denom @@ -88,7 +88,7 @@ func PerformCreateDenom(f *tokenfactorykeeper.Keeper, b *bankkeeper.BaseKeeper, msgCreateDenom, ) if err != nil { - return sdkerrors.Wrap(err, "creating denom") + return sdkioerrors.Wrap(err, "creating denom") } return nil } @@ -97,7 +97,7 @@ func PerformCreateDenom(f *tokenfactorykeeper.Keeper, b *bankkeeper.BaseKeeper, func (m *CustomMessenger) mintTokens(ctx sdk.Context, contractAddr sdk.AccAddress, mint *bindings.MintTokens) ([]sdk.Event, [][]byte, error) { err := PerformMint(m.tokenFactory, m.bank, ctx, contractAddr, mint) if err != nil { - return nil, nil, sdkerrors.Wrap(err, "perform mint") + return nil, nil, sdkioerrors.Wrap(err, "perform mint") } return nil, nil, nil } @@ -122,11 +122,11 @@ func PerformMint(f *tokenfactorykeeper.Keeper, b *bankkeeper.BaseKeeper, ctx sdk msgServer := tokenfactorykeeper.NewMsgServerImpl(*f) _, err = msgServer.Mint(sdk.WrapSDKContext(ctx), sdkMsg) if err != nil { - return sdkerrors.Wrap(err, "minting coins from message") + return sdkioerrors.Wrap(err, "minting coins from message") } err = b.SendCoins(ctx, contractAddr, rcpt, sdk.NewCoins(coin)) if err != nil { - return sdkerrors.Wrap(err, "sending newly minted coins from message") + return sdkioerrors.Wrap(err, "sending newly minted coins from message") } return nil } @@ -135,7 +135,7 @@ func PerformMint(f *tokenfactorykeeper.Keeper, b *bankkeeper.BaseKeeper, ctx sdk func (m *CustomMessenger) changeAdmin(ctx sdk.Context, contractAddr sdk.AccAddress, changeAdmin *bindings.ChangeAdmin) ([]sdk.Event, [][]byte, error) { err := ChangeAdmin(m.tokenFactory, ctx, contractAddr, changeAdmin) if err != nil { - return nil, nil, sdkerrors.Wrap(err, "failed to change admin") + return nil, nil, sdkioerrors.Wrap(err, "failed to change admin") } return nil, nil, nil } @@ -158,7 +158,7 @@ func ChangeAdmin(f *tokenfactorykeeper.Keeper, ctx sdk.Context, contractAddr sdk msgServer := tokenfactorykeeper.NewMsgServerImpl(*f) _, err = msgServer.ChangeAdmin(sdk.WrapSDKContext(ctx), changeAdminMsg) if err != nil { - return sdkerrors.Wrap(err, "failed changing admin from message") + return sdkioerrors.Wrap(err, "failed changing admin from message") } return nil } @@ -167,7 +167,7 @@ func ChangeAdmin(f *tokenfactorykeeper.Keeper, ctx sdk.Context, contractAddr sdk func (m *CustomMessenger) burnTokens(ctx sdk.Context, contractAddr sdk.AccAddress, burn *bindings.BurnTokens) ([]sdk.Event, [][]byte, error) { err := PerformBurn(m.tokenFactory, ctx, contractAddr, burn) if err != nil { - return nil, nil, sdkerrors.Wrap(err, "perform burn") + return nil, nil, sdkioerrors.Wrap(err, "perform burn") } return nil, nil, nil } @@ -191,7 +191,7 @@ func PerformBurn(f *tokenfactorykeeper.Keeper, ctx sdk.Context, contractAddr sdk msgServer := tokenfactorykeeper.NewMsgServerImpl(*f) _, err := msgServer.Burn(sdk.WrapSDKContext(ctx), sdkMsg) if err != nil { - return sdkerrors.Wrap(err, "burning coins from message") + return sdkioerrors.Wrap(err, "burning coins from message") } return nil } @@ -204,7 +204,7 @@ func GetFullDenom(contract string, subDenom string) (string, error) { } fullDenom, err := tokenfactorytypes.GetTokenDenom(contract, subDenom) if err != nil { - return "", sdkerrors.Wrap(err, "validate sub-denom") + return "", sdkioerrors.Wrap(err, "validate sub-denom") } return fullDenom, nil @@ -214,11 +214,11 @@ func GetFullDenom(contract string, subDenom string) (string, error) { func parseAddress(addr string) (sdk.AccAddress, error) { parsed, err := sdk.AccAddressFromBech32(addr) if err != nil { - return nil, sdkerrors.Wrap(err, "address from bech32") + return nil, sdkioerrors.Wrap(err, "address from bech32") } err = sdk.VerifyAddressFormat(parsed) if err != nil { - return nil, sdkerrors.Wrap(err, "verify address format") + return nil, sdkioerrors.Wrap(err, "verify address format") } return parsed, nil } diff --git a/wasmbinding/query_plugin.go b/wasmbinding/query_plugin.go index f9fe394b9..8cbf02c15 100644 --- a/wasmbinding/query_plugin.go +++ b/wasmbinding/query_plugin.go @@ -4,14 +4,13 @@ import ( "encoding/json" "fmt" + sdkioerrors "cosmossdk.io/errors" wasmvmtypes "github.com/CosmWasm/wasmvm/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/ingenuity-build/quicksilver/wasmbinding/bindings" + abci "github.com/tendermint/tendermint/abci/types" ) // StargateQuerier dispatches whitelisted stargate queries @@ -49,7 +48,7 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag return func(ctx sdk.Context, request json.RawMessage) ([]byte, error) { var contractQuery bindings.QuickSilverQuery if err := json.Unmarshal(request, &contractQuery); err != nil { - return nil, sdkerrors.Wrap(err, "quicksilver query") + return nil, sdkioerrors.Wrap(err, "quicksilver query") } switch { @@ -59,7 +58,7 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag fullDenom, err := GetFullDenom(creator, subdenom) if err != nil { - return nil, sdkerrors.Wrap(err, "osmo full denom query") + return nil, sdkioerrors.Wrap(err, "osmo full denom query") } res := bindings.FullDenomResponse{ @@ -68,7 +67,7 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag bz, err := json.Marshal(res) if err != nil { - return nil, sdkerrors.Wrap(err, "osmo full denom query response") + return nil, sdkioerrors.Wrap(err, "osmo full denom query response") } return bz, nil diff --git a/x/airdrop/handler.go b/x/airdrop/handler.go index 7d0238807..987b0edca 100644 --- a/x/airdrop/handler.go +++ b/x/airdrop/handler.go @@ -1,6 +1,7 @@ package airdrop import ( + sdkioerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -21,7 +22,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler { return sdk.WrapServiceResult(ctx, res, err) default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized airdrop message type: %T", msg) + return nil, sdkioerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized airdrop message type: %T", msg) } } } diff --git a/x/airdrop/types/errors.go b/x/airdrop/types/errors.go index f4da0af04..4c1e50150 100644 --- a/x/airdrop/types/errors.go +++ b/x/airdrop/types/errors.go @@ -3,7 +3,7 @@ package types import ( "fmt" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + sdkerrors "cosmossdk.io/errors" ) // x/airdrop module sentinel errors diff --git a/x/claimsmanager/handler.go b/x/claimsmanager/handler.go index dd15317f4..19984564a 100644 --- a/x/claimsmanager/handler.go +++ b/x/claimsmanager/handler.go @@ -1,6 +1,7 @@ package claimsmanager import ( + sdkioerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -12,6 +13,6 @@ func NewHandler(k keeper.Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { _ = ctx.WithEventManager(sdk.NewEventManager()) - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized claimsmanager message type: %T", msg) + return nil, sdkioerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized claimsmanager message type: %T", msg) } } diff --git a/x/claimsmanager/types/errors.go b/x/claimsmanager/types/errors.go index 360aa382b..88b6bb2ef 100644 --- a/x/claimsmanager/types/errors.go +++ b/x/claimsmanager/types/errors.go @@ -3,13 +3,13 @@ package types import ( fmt "fmt" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + sdkioerrors "cosmossdk.io/errors" ) // x/claimsmanager module sentinel errors var ( - ErrUndefinedAttribute = sdkerrors.Register(ModuleName, 1, "expected attribute not defined") - ErrNegativeAttribute = sdkerrors.Register(ModuleName, 2, "expected attribute must not be negative") - ErrNotPositive = sdkerrors.Register(ModuleName, 3, "expected attribute must be positive") - ErrClaimTypeOutOfBounds = sdkerrors.Register(ModuleName, 4, fmt.Sprintf("invalid claim type, expects range [1-%d]", len(ClaimType_value)-1)) + ErrUndefinedAttribute = sdkioerrors.Register(ModuleName, 1, "expected attribute not defined") + ErrNegativeAttribute = sdkioerrors.Register(ModuleName, 2, "expected attribute must not be negative") + ErrNotPositive = sdkioerrors.Register(ModuleName, 3, "expected attribute must be positive") + ErrClaimTypeOutOfBounds = sdkioerrors.Register(ModuleName, 4, fmt.Sprintf("invalid claim type, expects range [1-%d]", len(ClaimType_value)-1)) ) diff --git a/x/epochs/handler.go b/x/epochs/handler.go index 02f100e0f..d1bbcb7b7 100644 --- a/x/epochs/handler.go +++ b/x/epochs/handler.go @@ -3,6 +3,7 @@ package epochs import ( "fmt" + sdkioerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -14,6 +15,6 @@ import ( func NewHandler(k keeper.Keeper) sdk.Handler { return func(_ sdk.Context, msg sdk.Msg) (*sdk.Result, error) { errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) + return nil, sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) } } diff --git a/x/interchainquery/handler.go b/x/interchainquery/handler.go index cfda31b45..8ee7bf7be 100644 --- a/x/interchainquery/handler.go +++ b/x/interchainquery/handler.go @@ -3,9 +3,9 @@ package interchainquery import ( "fmt" + sdkioerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/ingenuity-build/quicksilver/x/interchainquery/keeper" "github.com/ingenuity-build/quicksilver/x/interchainquery/types" ) @@ -14,6 +14,6 @@ import ( func NewHandler(k keeper.Keeper) sdk.Handler { return func(_ sdk.Context, msg sdk.Msg) (*sdk.Result, error) { errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) + return nil, sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) } } diff --git a/x/interchainstaking/handler.go b/x/interchainstaking/handler.go index d7a649d33..d241121ca 100644 --- a/x/interchainstaking/handler.go +++ b/x/interchainstaking/handler.go @@ -1,6 +1,7 @@ package interchainstaking import ( + sdkioerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" @@ -26,7 +27,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler { return sdk.WrapServiceResult(ctx, res, err) default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized interchainstaking message type: %T", msg) + return nil, sdkioerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized interchainstaking message type: %T", msg) } } } @@ -40,7 +41,7 @@ func NewProposalHandler(k keeper.Keeper) govv1beta1.Handler { return keeper.HandleUpdateZoneProposal(ctx, k, c) default: - return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized interchainstaking proposal content type: %T", c) + return sdkioerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized interchainstaking proposal content type: %T", c) } } } diff --git a/x/interchainstaking/keeper/callbacks.go b/x/interchainstaking/keeper/callbacks.go index 738b48598..6beb938a3 100644 --- a/x/interchainstaking/keeper/callbacks.go +++ b/x/interchainstaking/keeper/callbacks.go @@ -6,9 +6,9 @@ import ( "fmt" "time" + sdkioerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/bech32" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -244,14 +244,14 @@ func DepositIntervalCallback(k Keeper, ctx sdk.Context, args []byte, query icqty func checkTrustedHeader(header *tmclienttypes.Header, consState *tmclienttypes.ConsensusState) error { tmTrustedValidators, err := tmtypes.ValidatorSetFromProto(header.TrustedValidators) if err != nil { - return sdkerrors.Wrap(err, "trusted validator set in not tendermint validator set type") + return sdkioerrors.Wrap(err, "trusted validator set in not tendermint validator set type") } // assert that trustedVals is NextValidators of last trusted header // to do this, we check that trustedVals.Hash() == consState.NextValidatorsHash tvalHash := tmTrustedValidators.Hash() if !bytes.Equal(consState.NextValidatorsHash, tvalHash) { - return sdkerrors.Wrapf( + return sdkioerrors.Wrapf( tmclienttypes.ErrInvalidValidatorSet, "trusted validators %s, does not hash to latest trusted validators. Expected: %X, got: %X", header.TrustedValidators, consState.NextValidatorsHash, tvalHash, @@ -274,7 +274,7 @@ func checkValidity( // UpdateClient only accepts updates with a header at the same revision // as the trusted consensus state if header.GetHeight().GetRevisionNumber() != header.TrustedHeight.RevisionNumber { - return sdkerrors.Wrapf( + return sdkioerrors.Wrapf( tmclienttypes.ErrInvalidHeaderHeight, "header height revision %d does not match trusted header revision %d", header.GetHeight().GetRevisionNumber(), header.TrustedHeight.RevisionNumber, @@ -283,22 +283,22 @@ func checkValidity( tmTrustedValidators, err := tmtypes.ValidatorSetFromProto(header.TrustedValidators) if err != nil { - return sdkerrors.Wrap(err, "trusted validator set in not tendermint validator set type") + return sdkioerrors.Wrap(err, "trusted validator set in not tendermint validator set type") } tmSignedHeader, err := tmtypes.SignedHeaderFromProto(header.SignedHeader) if err != nil { - return sdkerrors.Wrap(err, "signed header in not tendermint signed header type") + return sdkioerrors.Wrap(err, "signed header in not tendermint signed header type") } tmValidatorSet, err := tmtypes.ValidatorSetFromProto(header.ValidatorSet) if err != nil { - return sdkerrors.Wrap(err, "validator set in not tendermint validator set type") + return sdkioerrors.Wrap(err, "validator set in not tendermint validator set type") } // assert header height is newer than consensus state // if header.GetHeight().LTE(header.TrustedHeight) { - // return sdkerrors.Wrapf( + // return sdkioerrors.Wrapf( // tmclienttypes.ErrInvalidHeader, // "header height ≤ consensus state height (%s ≤ %s)", header.GetHeight(), header.TrustedHeight, // ) @@ -338,7 +338,7 @@ func checkValidity( clientState.TrustingPeriod, currentTimestamp, clientState.MaxClockDrift, clientState.TrustLevel.ToTendermint(), ) if err != nil { - return sdkerrors.Wrap(err, "failed to verify header") + return sdkioerrors.Wrap(err, "failed to verify header") } return nil } diff --git a/x/interchainstaking/keeper/receipt.go b/x/interchainstaking/keeper/receipt.go index 1c0706b62..d01b91b84 100644 --- a/x/interchainstaking/keeper/receipt.go +++ b/x/interchainstaking/keeper/receipt.go @@ -5,10 +5,10 @@ import ( "fmt" "time" + sdkioerrors "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/bech32" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx" bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" @@ -167,12 +167,12 @@ func (k *Keeper) SubmitTx(ctx sdk.Context, msgs []sdk.Msg, account *types.ICAAcc } channelID, found := k.ICAControllerKeeper.GetActiveChannelID(ctx, connectionID, portID) if !found { - return sdkerrors.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel for port %s in submittx", portID) + return sdkioerrors.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel for port %s in submittx", portID) } chanCap, found := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(portID, channelID)) if !found { - return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") + return sdkioerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") } chunkSize := ICAMsgChunkSize diff --git a/x/participationrewards/handler.go b/x/participationrewards/handler.go index 9d31eb6dc..52ef884be 100644 --- a/x/participationrewards/handler.go +++ b/x/participationrewards/handler.go @@ -1,6 +1,7 @@ package participationrewards import ( + sdkioerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" @@ -22,7 +23,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler { return sdk.WrapServiceResult(ctx, res, err) default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized participationrewards message type: %T", msg) + return nil, sdkioerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized participationrewards message type: %T", msg) } } } @@ -34,7 +35,7 @@ func NewProposalHandler(k keeper.Keeper) govv1beta1.Handler { return keeper.HandleAddProtocolDataProposal(ctx, k, c) default: - return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized participationrewards proposal content type: %T", c) + return sdkioerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized participationrewards proposal content type: %T", c) } } } diff --git a/x/participationrewards/types/errors.go b/x/participationrewards/types/errors.go index 4e86c9650..9396d20cd 100644 --- a/x/participationrewards/types/errors.go +++ b/x/participationrewards/types/errors.go @@ -1,19 +1,19 @@ package types import ( - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + sdkioerrors "cosmossdk.io/errors" ) // x/participationrewards module sentinel errors var ( - ErrUndefinedAttribute = sdkerrors.Register(ModuleName, 1, "expected attribute not defined") - ErrNegativeAttribute = sdkerrors.Register(ModuleName, 2, "expected attribute must not be negative") - ErrNegativeDistributionRatio = sdkerrors.Register(ModuleName, 3, "distribution ratio must not be negative") - ErrInvalidTotalProportions = sdkerrors.Register(ModuleName, 4, "total distribution proportions must be 1.0") - ErrNotPositive = sdkerrors.Register(ModuleName, 5, "expected attribute must be positive") - ErrUnknownProtocolDataType = sdkerrors.Register(ModuleName, 6, "unknown protocol data type") - ErrUnimplementedProtocolDataType = sdkerrors.Register(ModuleName, 7, "protocol data type not implemented") - ErrNothingToAllocate = sdkerrors.Register(ModuleName, 9, "balance is zero, nothing to allocate") - ErrInvalidAssetName = sdkerrors.Register(ModuleName, 10, "invalid ibc asset name") - ErrInvalidChainID = sdkerrors.Register(ModuleName, 11, "invalid chain id") + ErrUndefinedAttribute = sdkioerrors.Register(ModuleName, 1, "expected attribute not defined") + ErrNegativeAttribute = sdkioerrors.Register(ModuleName, 2, "expected attribute must not be negative") + ErrNegativeDistributionRatio = sdkioerrors.Register(ModuleName, 3, "distribution ratio must not be negative") + ErrInvalidTotalProportions = sdkioerrors.Register(ModuleName, 4, "total distribution proportions must be 1.0") + ErrNotPositive = sdkioerrors.Register(ModuleName, 5, "expected attribute must be positive") + ErrUnknownProtocolDataType = sdkioerrors.Register(ModuleName, 6, "unknown protocol data type") + ErrUnimplementedProtocolDataType = sdkioerrors.Register(ModuleName, 7, "protocol data type not implemented") + ErrNothingToAllocate = sdkioerrors.Register(ModuleName, 9, "balance is zero, nothing to allocate") + ErrInvalidAssetName = sdkioerrors.Register(ModuleName, 10, "invalid ibc asset name") + ErrInvalidChainID = sdkioerrors.Register(ModuleName, 11, "invalid chain id") ) diff --git a/x/tokenfactory/types/denoms.go b/x/tokenfactory/types/denoms.go index c87569085..0d3f1ada0 100644 --- a/x/tokenfactory/types/denoms.go +++ b/x/tokenfactory/types/denoms.go @@ -4,8 +4,8 @@ import ( fmt "fmt" "strings" + sdkerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" ) diff --git a/x/tokenfactory/types/errors.go b/x/tokenfactory/types/errors.go index 06991f19b..5f76a78e2 100644 --- a/x/tokenfactory/types/errors.go +++ b/x/tokenfactory/types/errors.go @@ -5,7 +5,7 @@ package types import ( fmt "fmt" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + sdkerrors "cosmossdk.io/errors" ) // x/tokenfactory module sentinel errors diff --git a/x/tokenfactory/types/genesis.go b/x/tokenfactory/types/genesis.go index bf439106f..9519cf81e 100644 --- a/x/tokenfactory/types/genesis.go +++ b/x/tokenfactory/types/genesis.go @@ -1,8 +1,8 @@ package types import ( + sdkioerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) // this line is used by starport scaffolding # genesis/types/import @@ -30,7 +30,7 @@ func (gs GenesisState) Validate() error { for _, denom := range gs.GetFactoryDenoms() { if seenDenoms[denom.GetDenom()] { - return sdkerrors.Wrapf(ErrInvalidGenesis, "duplicate denom: %s", denom.GetDenom()) + return sdkioerrors.Wrapf(ErrInvalidGenesis, "duplicate denom: %s", denom.GetDenom()) } seenDenoms[denom.GetDenom()] = true @@ -43,7 +43,7 @@ func (gs GenesisState) Validate() error { if denom.AuthorityMetadata.Admin != "" { _, err = sdk.AccAddressFromBech32(denom.AuthorityMetadata.Admin) if err != nil { - return sdkerrors.Wrapf(ErrInvalidAuthorityMetadata, "Invalid admin address (%s)", err) + return sdkioerrors.Wrapf(ErrInvalidAuthorityMetadata, "Invalid admin address (%s)", err) } } } diff --git a/x/tokenfactory/types/msgs.go b/x/tokenfactory/types/msgs.go index 9c78328e1..b412f29fb 100644 --- a/x/tokenfactory/types/msgs.go +++ b/x/tokenfactory/types/msgs.go @@ -1,6 +1,7 @@ package types import ( + sdkioerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -31,12 +32,12 @@ func (m MsgCreateDenom) Type() string { return TypeMsgCreateDenom } func (m MsgCreateDenom) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(m.Sender) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) } _, err = GetTokenDenom(m.Sender, m.Subdenom) if err != nil { - return sdkerrors.Wrap(ErrInvalidDenom, err.Error()) + return sdkioerrors.Wrap(ErrInvalidDenom, err.Error()) } return nil @@ -66,11 +67,11 @@ func (m MsgMint) Type() string { return TypeMsgMint } func (m MsgMint) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(m.Sender) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) } if !m.Amount.IsValid() || m.Amount.Amount.Equal(sdk.ZeroInt()) { - return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) + return sdkioerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) } return nil @@ -100,11 +101,11 @@ func (m MsgBurn) Type() string { return TypeMsgBurn } func (m MsgBurn) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(m.Sender) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) } if !m.Amount.IsValid() || m.Amount.Amount.Equal(sdk.ZeroInt()) { - return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) + return sdkioerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) } return nil @@ -136,20 +137,20 @@ func (m MsgBurn) GetSigners() []sdk.AccAddress { // func (m MsgForceTransfer) ValidateBasic() error { // _, err := sdk.AccAddressFromBech32(m.Sender) // if err != nil { -// return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) +// return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) // } // _, err = sdk.AccAddressFromBech32(m.TransferFromAddress) // if err != nil { -// return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) +// return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) // } // _, err = sdk.AccAddressFromBech32(m.TransferToAddress) // if err != nil { -// return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) +// return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) // } // if !m.Amount.IsValid() { -// return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) +// return sdkioerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) // } // return nil @@ -180,12 +181,12 @@ func (m MsgChangeAdmin) Type() string { return TypeMsgChangeAdmin } func (m MsgChangeAdmin) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(m.Sender) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) } _, err = sdk.AccAddressFromBech32(m.NewAdmin) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) + return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) } _, _, err = DeconstructDenom(m.Denom) @@ -220,7 +221,7 @@ func (m MsgSetDenomMetadata) Type() string { return TypeMsgSetDenomMetadata } func (m MsgSetDenomMetadata) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(m.Sender) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + return sdkioerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) } err = m.Metadata.Validate()