Skip to content

Commit

Permalink
refactor: x/feegrant to stand alone (#14649)
Browse files Browse the repository at this point in the history
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 25, 2023
1 parent 8cc3346 commit cc10614
Show file tree
Hide file tree
Showing 59 changed files with 1,788 additions and 176 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ updates:
labels:
- "A:automerge"
- dependencies

- package-ecosystem: gomod
directory: "x/feegrant"
schedule:
interval: weekly
labels:
- "A:automerge"
- dependencies

- package-ecosystem: gomod
directory: "/x/evidence"
schedule:
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,37 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: x/circuit/

test-x-feegrant:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19.4
cache: true
cache-dependency-path: x/feegrant/go.sum
- uses: technote-space/get-diff-action@v6.1.2
id: git_diff
with:
PATTERNS: |
x/feegrant/**/*.go
x/feegrant/go.mod
x/feegrant/go.sum
- name: tests
if: env.GIT_DIFF
run: |
cd x/feegrant
go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock rocksdb_build' ./...
- name: sonarcloud
if: ${{ env.GIT_DIFF && !github.event.pull_request.draft }}
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: x/feegrant/

test-x-evidence:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ extension interfaces. `module.Manager.Modules` is now of type `map[string]interf
* (baseapp) [#14050](https://github.com/cosmos/cosmos-sdk/pull/14050) refactor `ABCIListener` interface to accept go contexts
* (store/streaming)[#14603](https://github.com/cosmos/cosmos-sdk/pull/14603) `StoreDecoderRegistry` moved from store to `types/simulations` this breaks the `AppModuleSimulation` interface.
* (x/staking) [#14590](https://github.com/cosmos/cosmos-sdk/pull/14590) `MsgUndelegateResponse` now includes undelegated amount. `x/staking` module's `keeper.Undelegate` now returns 3 values (completionTime,undelegateAmount,error) instead of 2.
* (x/feegrant) [14649](https://github.com/cosmos/cosmos-sdk/pull/14649) Extract Feegrant in its own go.mod and rename the package to `cosmossdk.io/x/feegrant`.

### Client Breaking Changes

Expand Down
9 changes: 8 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ All the evidence imports are now renamed to use `cosmossdk.io/x/evidence` instea

##### Extract nft to a standalone module

The `x/nft` module is extracted to have a separate go.mod file which allows it be a standalone module.
The `x/nft` module is extracted to have a separate go.mod file which allows it to be a standalone module.

#### x/feegrant

##### Extract feegrant to a standalone module

The `x/feegrant` module is extracted to have a separate go.mod file which allows it to be a standalone module.
All the feegrant imports are now renamed to use `cosmossdk.io/x/feegrant` instead of `github.com/cosmos/cosmos-sdk/x/feegrant` across the SDK.

## [v0.47.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.0)

Expand Down Expand Up @@ -429,3 +435,4 @@ message MsgSetWithdrawAddress {
<!-- todo: cosmos.scalar types -->

When clients interract with a node they are required to set a codec in in the grpc.Dial. More information can be found in this [doc](https://docs.cosmos.network/v0.46/run-node/interact-node.html#programmatically-via-go).

7 changes: 3 additions & 4 deletions api/cosmos/feegrant/module/v1/module.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/cosmos/staking/v1beta1/tx.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ replace (
cosmossdk.io/collections => ./collections
cosmossdk.io/store => ./store
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0

// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
// TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
Expand Down
1 change: 1 addition & 0 deletions go.work.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ use (
./x/tx
./x/nft
./x/circuit
./x/feegrant
./x/evidence
)
2 changes: 1 addition & 1 deletion proto/cosmos/feegrant/module/v1/module.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import "cosmos/app/v1alpha1/module.proto";
// Module is the config object of the feegrant module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/cosmos/cosmos-sdk/x/feegrant"
go_import: "cosmossdk.io/x/feegrant"
};
}
2 changes: 1 addition & 1 deletion proto/cosmos/feegrant/v1beta1/feegrant.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "amino/amino.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant";
option go_package = "cosmossdk.io/x/feegrant";

// BasicAllowance implements Allowance with a one-time grant of coins
// that optionally expires. The grantee can use up to SpendLimit to cover fees.
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/feegrant/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "gogoproto/gogo.proto";
import "cosmos/feegrant/v1beta1/feegrant.proto";
import "amino/amino.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant";
option go_package = "cosmossdk.io/x/feegrant";

// GenesisState contains a set of fee allowances, persisted from the store
message GenesisState {
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/feegrant/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "cosmos/base/query/v1beta1/pagination.proto";
import "google/api/annotations.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant";
option go_package = "cosmossdk.io/x/feegrant";

// Query defines the gRPC querier service.
service Query {
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/feegrant/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "amino/amino.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant";
option go_package = "cosmossdk.io/x/feegrant";

// Msg defines the feegrant msg service.
service Msg {
Expand Down
6 changes: 3 additions & 3 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import (
nftmodule "cosmossdk.io/x/nft/module"

storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/feegrant"
feegrantkeeper "cosmossdk.io/x/feegrant/keeper"
feegrantmodule "cosmossdk.io/x/feegrant/module"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
Expand Down Expand Up @@ -71,9 +74,6 @@ import (
distr "github.com/cosmos/cosmos-sdk/x/distribution"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/gov"
Expand Down
2 changes: 1 addition & 1 deletion simapp/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
evidencetypes "cosmossdk.io/x/evidence/types"
"google.golang.org/protobuf/types/known/durationpb"

"cosmossdk.io/x/feegrant"
"cosmossdk.io/x/nft"
"github.com/cosmos/cosmos-sdk/runtime"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand All @@ -39,7 +40,6 @@ import (
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/group"
Expand Down
2 changes: 1 addition & 1 deletion simapp/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

feegrantmodule "cosmossdk.io/x/feegrant/module"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/testutil/mock"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
Expand All @@ -27,7 +28,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/capability"
"github.com/cosmos/cosmos-sdk/x/crisis"
"github.com/cosmos/cosmos-sdk/x/distribution"
feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module"
"github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/cosmos/cosmos-sdk/x/gov"
group "github.com/cosmos/cosmos-sdk/x/group/module"
Expand Down
4 changes: 2 additions & 2 deletions simapp/app_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
nftmodule "cosmossdk.io/x/nft/module"

storetypes "cosmossdk.io/store/types"
feegrantkeeper "cosmossdk.io/x/feegrant/keeper"
feegrantmodule "cosmossdk.io/x/feegrant/module"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -49,8 +51,6 @@ import (
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/gov"
Expand Down
4 changes: 4 additions & 0 deletions simapp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
cosmossdk.io/tools/confix v0.0.0-20230120150717-4f6f6c00021f
cosmossdk.io/tools/rosetta v0.2.0
cosmossdk.io/x/evidence v0.1.0
cosmossdk.io/x/feegrant v0.0.0-20230117113717-50e7c4a4ceff
cosmossdk.io/x/nft v0.0.0-20230113085233-fae3332d62fc
github.com/cosmos/cosmos-db v0.0.0-20230119180254-161cf3632b7c
// this version is not used as it is always replaced by the latest cosmos-sdk version
Expand Down Expand Up @@ -187,6 +188,8 @@ require (
// TODO tag all extracted modules after SDK refactor
replace (
cosmossdk.io/x/evidence => ../x/evidence
cosmossdk.io/x/feegrant => ../x/feegrant
// TODO tag all extracted modules after SDK refactor
cosmossdk.io/x/nft => ../x/nft
)

Expand All @@ -201,4 +204,5 @@ replace (
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1
// use informal systems fork of tendermint
github.com/tendermint/tendermint => github.com/informalsystems/tendermint v0.37.0-rc2

)
4 changes: 2 additions & 2 deletions tests/e2e/feegrant/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/cosmos/gogoproto/proto"
"github.com/stretchr/testify/suite"

"cosmossdk.io/x/feegrant"
"cosmossdk.io/x/feegrant/client/cli"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/hd"
Expand All @@ -17,8 +19,6 @@ import (
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
"github.com/cosmos/cosmos-sdk/x/feegrant/client/cli"
govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
Expand Down
3 changes: 3 additions & 0 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
cosmossdk.io/simapp v0.0.0-00010101000000-000000000000
cosmossdk.io/store v0.1.0
cosmossdk.io/x/evidence v0.1.0
cosmossdk.io/x/feegrant v0.0.0-20230117113717-50e7c4a4ceff
cosmossdk.io/x/nft v0.0.0-20230113085233-fae3332d62fc
github.com/cosmos/cosmos-db v0.0.0-20230119180254-161cf3632b7c
github.com/cosmos/cosmos-sdk v0.47.0-rc1
Expand Down Expand Up @@ -181,6 +182,8 @@ require (
replace (
cosmossdk.io/collections => ../collections
cosmossdk.io/x/evidence => ../x/evidence
cosmossdk.io/x/feegrant => ../x/feegrant
// TODO tag all extracted modules after SDK refactor
cosmossdk.io/x/nft => ../x/nft
)

Expand Down
30 changes: 30 additions & 0 deletions x/feegrant/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
Guiding Principles:
Changelogs are for humans, not machines.
There should be an entry for every single version.
The same types of changes should be grouped.
Versions and sections should be linkable.
The latest version comes first.
The release date of each version is displayed.
Mention whether you follow Semantic Versioning.
Usage:
Change log entries are to be added to the Unreleased section under the
appropriate stanza (see below). Each entry should ideally include a tag and
the Github issue reference in the following format:
* (<tag>) [#<issue-number>] Changelog message.
Types of changes (Stanzas):
"Features" for new features.
"Improvements" for changes in existing functionality.
"Deprecated" for soon-to-be removed features.
"Bug Fixes" for any bug fixes.
"API Breaking" for breaking exported APIs used by developers building on SDK.
Ref: https://keepachangelog.com/en/1.0.0/
-->

# Changelog

## [Unreleased]

### Features

* (x/feegrant) [14649](https://github.com/cosmos/cosmos-sdk/pull/14649) The `x/feegrant` module is extracted to have a separate go.mod file which allows it to be a standalone module.
2 changes: 1 addition & 1 deletion x/feegrant/basic_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/feegrant"

"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
)

func TestBasicFeeValidAllow(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/feegrant/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (

"github.com/spf13/cobra"

"cosmossdk.io/x/feegrant"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/feegrant"
)

// GetQueryCmd returns the cli query commands for this module
Expand Down
4 changes: 2 additions & 2 deletions x/feegrant/client/cli/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package cli_test
import (
"fmt"

"cosmossdk.io/x/feegrant"
"cosmossdk.io/x/feegrant/client/cli"
"github.com/cosmos/cosmos-sdk/client/flags"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/x/feegrant"
"github.com/cosmos/cosmos-sdk/x/feegrant/client/cli"
)

func (s *CLITestSuite) TestCmdGetFeeGrant() {
Expand Down
2 changes: 1 addition & 1 deletion x/feegrant/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (

"github.com/spf13/cobra"

"cosmossdk.io/x/feegrant"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/feegrant"
)

// flag for feegrant module
Expand Down
6 changes: 3 additions & 3 deletions x/feegrant/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
rpcclientmock "github.com/tendermint/tendermint/rpc/client/mock"

"cosmossdk.io/x/feegrant"
"cosmossdk.io/x/feegrant/client/cli"
"cosmossdk.io/x/feegrant/module"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/hd"
Expand All @@ -21,9 +24,6 @@ import (
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
sdk "github.com/cosmos/cosmos-sdk/types"
testutilmod "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/feegrant"
"github.com/cosmos/cosmos-sdk/x/feegrant/client/cli"
"github.com/cosmos/cosmos-sdk/x/feegrant/module"
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
Expand Down
Loading

0 comments on commit cc10614

Please sign in to comment.