From 844393fc397036825bb3cba36c7da168327283e9 Mon Sep 17 00:00:00 2001 From: emidev98 Date: Thu, 9 Nov 2023 10:14:01 +0200 Subject: [PATCH] feat: remove golang 21 features and change logos --- Makefile | 19 ++++++++++++------- app/app.go | 8 +++++--- app/keepers/keepers.go | 14 ++++++++------ app/modules.go | 16 +++++++++------- app/post/post.go | 3 ++- app/upgrade_handler.go | 9 +++++---- app/upgrades/v2.7/upgrade.go | 5 +++-- core_logo.svg => docs/core_logo.svg | 0 docs/terra_logo.svg | 1 + readme.md | 4 ++-- x/bank/types/errors.go | 1 + x/feeshare/post/post.go | 9 +++++---- x/tokenfactory/bindings/wasm.go | 3 ++- x/wasm/keeper/contracts.go | 3 ++- x/wasm/keeper/keeper.go | 10 +++++----- x/wasm/keeper/msg_server.go | 1 + x/wasm/module.go | 3 ++- 17 files changed, 65 insertions(+), 44 deletions(-) rename core_logo.svg => docs/core_logo.svg (100%) create mode 100644 docs/terra_logo.svg diff --git a/Makefile b/Makefile index dc670180..98a69f38 100644 --- a/Makefile +++ b/Makefile @@ -328,11 +328,16 @@ lint: lint-fix: golangci-lint run --fix --out-format=tab --issues-exit-code=0 - -.PHONY: lint lint-fix -format: - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' -not -path "./_build/*" | xargs gofmt -w -s - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' -not -path "./_build/*" | xargs misspell -w - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' -not -path "./_build/*" | xargs goimports -w -local github.com/cosmos/cosmos-sdk -.PHONY: format +format-tools: + go install mvdan.cc/gofumpt@latest + go install github.com/client9/misspell/cmd/misspell@latest + go install golang.org/x/tools/cmd/goimports@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + +format: format-tools + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*statik*" -not -name '*.pb.go' | xargs gofmt -w -s + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*statik*" -not -name '*.pb.go' | xargs misspell -w + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*statik*" -not -name '*.pb.go' | xargs goimports -w -local github.com/cosmos/cosmos-sdk + +.PHONY: lint format-tools format \ No newline at end of file diff --git a/app/app.go b/app/app.go index 7d53b3cc..95270325 100644 --- a/app/app.go +++ b/app/app.go @@ -8,9 +8,10 @@ import ( "path/filepath" "reflect" // #nosec G702 - authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" "github.com/prometheus/client_golang/prometheus" + authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" "github.com/terra-money/core/v2/app/keepers" "github.com/terra-money/core/v2/app/post" @@ -28,6 +29,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec/types" + custombankmodule "github.com/terra-money/core/v2/x/bank" + customwasmodule "github.com/terra-money/core/v2/x/wasm" + "github.com/cosmos/cosmos-sdk/baseapp" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" @@ -52,8 +56,6 @@ import ( distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" "github.com/cosmos/cosmos-sdk/x/evidence" feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" - custombankmodule "github.com/terra-money/core/v2/x/bank" - customwasmodule "github.com/terra-money/core/v2/x/wasm" "github.com/cosmos/cosmos-sdk/x/gov" govclient "github.com/cosmos/cosmos-sdk/x/gov/client" diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 4bbd70d4..5186053e 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -6,6 +6,12 @@ import ( "path/filepath" + "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router" + ibctransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer" + ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client" + ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "github.com/spf13/cast" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" @@ -28,11 +34,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/params" paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" "github.com/cosmos/cosmos-sdk/x/upgrade" - "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router" - ibctransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer" - ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client" - ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - "github.com/spf13/cast" "github.com/cosmos/cosmos-sdk/x/feegrant" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" @@ -58,7 +59,6 @@ import ( routerkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/keeper" routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" icq "github.com/cosmos/ibc-apps/modules/async-icq/v7" icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper" @@ -71,6 +71,8 @@ import ( porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + icqkeeper "github.com/cosmos/ibc-apps/modules/async-icq/v7/keeper" icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types" diff --git a/app/modules.go b/app/modules.go index 3b1e98be..29d7767d 100644 --- a/app/modules.go +++ b/app/modules.go @@ -39,12 +39,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/upgrade" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router" routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types" icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types" @@ -60,6 +54,13 @@ import ( feesharetypes "github.com/terra-money/core/v2/x/feeshare/types" tokenfactorytypes "github.com/terra-money/core/v2/x/tokenfactory/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + icq "github.com/cosmos/ibc-apps/modules/async-icq/v7" solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine" @@ -79,9 +80,10 @@ import ( pob "github.com/skip-mev/pob/x/builder" pobtype "github.com/skip-mev/pob/x/builder/types" - "github.com/cosmos/cosmos-sdk/x/feegrant" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" terrappsparams "github.com/terra-money/core/v2/app/params" + + "github.com/cosmos/cosmos-sdk/x/feegrant" ) // ModuleBasics defines the module BasicManager is in charge of setting up basic, diff --git a/app/post/post.go b/app/post/post.go index 4eb194ef..d10d3668 100644 --- a/app/post/post.go +++ b/app/post/post.go @@ -1,10 +1,11 @@ package post import ( - sdk "github.com/cosmos/cosmos-sdk/types" feesharepost "github.com/terra-money/core/v2/x/feeshare/post" customwasmkeeper "github.com/terra-money/core/v2/x/wasm/keeper" wasmpost "github.com/terra-money/core/v2/x/wasm/post" + + sdk "github.com/cosmos/cosmos-sdk/types" ) type HandlerOptions struct { diff --git a/app/upgrade_handler.go b/app/upgrade_handler.go index f51d7984..47966114 100644 --- a/app/upgrade_handler.go +++ b/app/upgrade_handler.go @@ -1,10 +1,6 @@ package app import ( - storetypes "github.com/cosmos/cosmos-sdk/store/types" - consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" - crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ibchookstypes "github.com/cosmos/ibc-apps/modules/ibc-hooks/v7/types" icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" @@ -20,6 +16,11 @@ import ( feesharetypes "github.com/terra-money/core/v2/x/feeshare/types" tokenfactorytypes "github.com/terra-money/core/v2/x/tokenfactory/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types" ) diff --git a/app/upgrades/v2.7/upgrade.go b/app/upgrades/v2.7/upgrade.go index e4be4bdd..431f11e7 100644 --- a/app/upgrades/v2.7/upgrade.go +++ b/app/upgrades/v2.7/upgrade.go @@ -1,12 +1,13 @@ package v2_7 import ( + icqkeeper "github.com/cosmos/ibc-apps/modules/async-icq/v7/keeper" + icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - icqkeeper "github.com/cosmos/ibc-apps/modules/async-icq/v7/keeper" - icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types" ) func CreateUpgradeHandler( diff --git a/core_logo.svg b/docs/core_logo.svg similarity index 100% rename from core_logo.svg rename to docs/core_logo.svg diff --git a/docs/terra_logo.svg b/docs/terra_logo.svg new file mode 100644 index 00000000..ec50ff71 --- /dev/null +++ b/docs/terra_logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index 17ea811c..0da5e8ce 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@

 

- +

@@ -98,7 +98,7 @@ If you are interested in contributing to the Terra Core source code, please revi

 

- +

© 2023 Terraform Labs, PTE LTD diff --git a/x/bank/types/errors.go b/x/bank/types/errors.go index 30fcc409..1aba6a45 100644 --- a/x/bank/types/errors.go +++ b/x/bank/types/errors.go @@ -4,6 +4,7 @@ package types import ( sdkerrors "cosmossdk.io/errors" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) diff --git a/x/feeshare/post/post.go b/x/feeshare/post/post.go index 0e91037c..0a343c95 100644 --- a/x/feeshare/post/post.go +++ b/x/feeshare/post/post.go @@ -1,8 +1,6 @@ package ante import ( - "slices" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -139,8 +137,11 @@ func CalculateFee(fees sdk.Coins, govPercent sdk.Dec, pairs int, allowedDenoms [ alloedFeesDenoms = fees } else { for _, fee := range fees { - if slices.Contains(allowedDenoms, fee.Denom) { - alloedFeesDenoms = alloedFeesDenoms.Add(fee) + for _, allowedDenom := range allowedDenoms { + if fee.Denom == allowedDenom { + alloedFeesDenoms = alloedFeesDenoms.Add(fee) + break + } } } } diff --git a/x/tokenfactory/bindings/wasm.go b/x/tokenfactory/bindings/wasm.go index 3ce9b23c..1850b774 100644 --- a/x/tokenfactory/bindings/wasm.go +++ b/x/tokenfactory/bindings/wasm.go @@ -3,8 +3,9 @@ package bindings import ( "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" tokenfactorykeeper "github.com/terra-money/core/v2/x/tokenfactory/keeper" + + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" ) func RegisterCustomPlugins( diff --git a/x/wasm/keeper/contracts.go b/x/wasm/keeper/contracts.go index d085e0f2..deb9f0c1 100644 --- a/x/wasm/keeper/contracts.go +++ b/x/wasm/keeper/contracts.go @@ -1,8 +1,9 @@ package keeper import ( - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/terra-money/core/v2/x/wasm/types" + + sdk "github.com/cosmos/cosmos-sdk/types" ) func (k Keeper) GetExecutedContractAddresses(ctx sdk.Context) (contracts types.ExecutedContracts, found bool) { diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index c8e2e57e..3e5c9d2d 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -1,9 +1,8 @@ package keeper import ( - "slices" - wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -83,10 +82,11 @@ func (k Keeper) AfterExecuteContract(ctx sdk.Context, msg *types.MsgExecuteContr } // if the contract address has already been // added just skip it to avoid duplicates - if slices.Contains(contractAddresses, attr.Value) { - continue + for _, item := range contractAddresses { + if item == attr.Value { + continue + } } - contractAddresses = append(contractAddresses, attr.Value) } } diff --git a/x/wasm/keeper/msg_server.go b/x/wasm/keeper/msg_server.go index 5bccdb3a..1629aa60 100644 --- a/x/wasm/keeper/msg_server.go +++ b/x/wasm/keeper/msg_server.go @@ -5,6 +5,7 @@ import ( wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" "github.com/CosmWasm/wasmd/x/wasm/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/wasm/module.go b/x/wasm/module.go index 5ebd5e38..b80ba220 100644 --- a/x/wasm/module.go +++ b/x/wasm/module.go @@ -11,8 +11,9 @@ import ( "github.com/CosmWasm/wasmd/x/wasm/simulation" "github.com/CosmWasm/wasmd/x/wasm/types" - "github.com/cosmos/cosmos-sdk/types/module" customwasmkeeper "github.com/terra-money/core/v2/x/wasm/keeper" + + "github.com/cosmos/cosmos-sdk/types/module" ) // AppModule implements an application module for the wasm module.