Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: implement ADR 21: Subspace specific custom fee tokens #1138

Merged
merged 31 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
72ecbe5
chore: update changeset
dadamu May 11, 2023
35e9fde
feat: build types
dadamu May 10, 2023
e0a9796
feat: setup msg server
dadamu May 10, 2023
8c08cd5
feat: add msg server tests and modify keeper
dadamu May 10, 2023
a52f76f
feat: add simulation tests
dadamu May 10, 2023
9a2e6e1
docs: update Swagger definition
dadamu May 10, 2023
6e11a2a
chore: setup simulation propsal msgs properly
dadamu May 11, 2023
6af2569
tests: fix cli tests
dadamu May 11, 2023
1387f79
feat: implement subspaces tx checker
dadamu May 12, 2023
0734269
chore: add changeset
dadamu May 12, 2023
3292aaa
feat: add gov codec
dadamu May 15, 2023
d0f02ab
chore: fix rebase error
dadamu May 17, 2023
74e9439
fix: fix rebase error
dadamu May 19, 2023
059e70c
fix: fix app wring
dadamu Jun 5, 2023
7776912
chore: add since version for proto
dadamu Jun 5, 2023
a1b1a3a
chore: remove merged entries
dadamu Jun 5, 2023
c648364
Update proto/desmos/subspaces/v3/msgs.proto
dadamu Jun 13, 2023
26b190c
Update proto/desmos/subspaces/v3/msgs.proto
dadamu Jun 13, 2023
f681d12
Update x/subspaces/keeper/msg_server.go
dadamu Jun 13, 2023
f0c3aff
Update x/subspaces/keeper/msg_server_test.go
dadamu Jun 13, 2023
2a4ff30
chore: rename allowed fee tokens into additional fee tokens
dadamu Jun 13, 2023
4ea1474
chore: add new parameter to NewSubspace
dadamu Jun 13, 2023
25b08c7
feat: implement additional fee tokens update
dadamu Jun 13, 2023
450e6b2
docs: update Swagger definition
dadamu Jun 13, 2023
7fba7f8
chore: run gofmt
dadamu Jun 13, 2023
9078ab5
feat: add social msg to exclude subspace management msg
dadamu Jun 13, 2023
94daa7d
chore: rename msg allowed fee tokens field into additional fee tokens
dadamu Jun 13, 2023
5aae05c
test: fix msg server tests
dadamu Jun 13, 2023
98a1a59
Revert "feat: add social msg to exclude subspace management msg"
dadamu Jun 14, 2023
e674ee7
chore: implement manage subspace msg for custom tx fee checker
dadamu Jun 14, 2023
5f0d45f
docs: update Swagger definition
dadamu Jun 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: feat
module: x/subspaces
pull_request: 1138
description: implement subspace specific custom fee tokens
backward_compatible: true
date: 2023-05-12T08:32:20.5983359Z
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ func NewDesmosApp(
)

// Create subspaces keeper and module
subspacesKeeper := subspaceskeeper.NewKeeper(app.appCodec, keys[subspacestypes.StoreKey], app.AccountKeeper, app.AuthzKeeper)
subspacesKeeper := subspaceskeeper.NewKeeper(app.appCodec, keys[subspacestypes.StoreKey], app.AccountKeeper, app.AuthzKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String())

// Create the relationships keeper
app.RelationshipsKeeper = relationshipskeeper.NewKeeper(
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

98 changes: 98 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4696,6 +4696,27 @@ paths:
type: string
format: date-time
title: the creation time of the subspace
additional_fee_tokens:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an
amount.


NOTE: The amount field is an Int which implements the
custom method

signatures required by gogoproto.
title: >-
List of fee token denoms with default minimum gas prices
allowed inside the subspace
title: Subspace contains all the data of a Desmos subspace
pagination:
type: object
Expand Down Expand Up @@ -5023,6 +5044,26 @@ paths:
type: string
format: date-time
title: the creation time of the subspace
additional_fee_tokens:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the
custom method

signatures required by gogoproto.
title: >-
List of fee token denoms with default minimum gas prices
allowed inside the subspace
title: Subspace contains all the data of a Desmos subspace
title: >-
QuerySubspaceResponse is the response type for the Query/Subspace
Expand Down Expand Up @@ -19533,6 +19574,26 @@ definitions:
type: string
format: date-time
title: the creation time of the subspace
additional_fee_tokens:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the custom
method

signatures required by gogoproto.
title: >-
List of fee token denoms with default minimum gas prices allowed
inside the subspace
title: Subspace contains all the data of a Desmos subspace
title: QuerySubspaceResponse is the response type for the Query/Subspace method
desmos.subspaces.v3.QuerySubspacesResponse:
Expand Down Expand Up @@ -19570,6 +19631,26 @@ definitions:
type: string
format: date-time
title: the creation time of the subspace
additional_fee_tokens:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the custom
method

signatures required by gogoproto.
title: >-
List of fee token denoms with default minimum gas prices allowed
inside the subspace
title: Subspace contains all the data of a Desmos subspace
pagination:
type: object
Expand Down Expand Up @@ -20233,6 +20314,23 @@ definitions:
type: string
format: date-time
title: the creation time of the subspace
additional_fee_tokens:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
title: >-
List of fee token denoms with default minimum gas prices allowed
inside the subspace
title: Subspace contains all the data of a Desmos subspace
desmos.subspaces.v3.UserGroup:
type: object
Expand Down
5 changes: 5 additions & 0 deletions proto/desmos/subspaces/module/v1/module.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ message Module {
// of module names which provide a subspaces hooks instance. If no order is
// provided, then hooks will be applied in alphabetical order of module names.
repeated string hooks_order = 1;


// authority defines the custom module authority. If not set, defaults to the
// governance module.
string authority = 2;
}
8 changes: 8 additions & 0 deletions proto/desmos/subspaces/v3/models.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package desmos.subspaces.v3;

import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/desmos-labs/desmos/v5/x/subspaces/types";

Expand Down Expand Up @@ -37,6 +38,13 @@ message Subspace {
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "yaml:\"creation_time\""
];

// List of fee token denoms with default minimum gas prices allowed inside the subspace
repeated cosmos.base.v1beta1.Coin additional_fee_tokens = 8 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "yaml:\"additional_fee_tokens\""
];
}

// Section contains the data of a single subspace section
Expand Down
39 changes: 39 additions & 0 deletions proto/desmos/subspaces/v3/msgs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ syntax = "proto3";
package desmos.subspaces.v3;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";

import "desmos/subspaces/v3/msgs_treasury.proto";
import "desmos/subspaces/v3/msgs_feegrant.proto";
Expand Down Expand Up @@ -78,6 +81,11 @@ service Msg {
// RevokeAllowance allows a granter to revoke any existing treasury allowance
// that has been granted to the grantee
rpc RevokeAllowance(MsgRevokeAllowance) returns (MsgRevokeAllowanceResponse);

// UpdateSubspaceFeeTokens allows subspace admins to update the list of fee tokens inside the subspace via a governance proposal
//
// Since: Desmos 6.0.0
rpc UpdateSubspaceFeeTokens(MsgUpdateSubspaceFeeTokens) returns (MsgUpdateSubspaceFeeTokensResponse);
}

// --------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -492,3 +500,34 @@ message MsgSetUserPermissions {
// MsgSetUserPermissionsResponse defines the Msg/SetPermissionsResponse
// response type
message MsgSetUserPermissionsResponse {}

// --------------------------------------------------------------------------------------------------------------------

// MsgUpdateSubspaceFeeTokens represents the message to be used to update the accepted fee tokens
// inside a given subspace, using an on-chain governance proposal
//
// Since: Desmos 6.0.0
message MsgUpdateSubspaceFeeTokens {
option (cosmos.msg.v1.signer) = "authority";

// Id of the subspace where the list of allowed fee tokens will be updated
uint64 subspace_id = 1 [
(gogoproto.customname) = "SubspaceID",
(gogoproto.moretags) = "yaml:\"subspace_id\""
];

// List of tokens allowed to be fee tokens inside the given subspace, represented as their gas prices
repeated cosmos.base.v1beta1.Coin additional_fee_tokens = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "yaml:\"additional_fee_tokens\""
];

// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// MsgUpdateSubspaceFeeTokensResponse represents the Msg/UpdateSubspaceFeeTokens response type
//
// Since: Desmos 6.0.0
message MsgUpdateSubspaceFeeTokensResponse {}
1 change: 1 addition & 0 deletions x/posts/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
},
[]subspacestypes.Section{
Expand Down
7 changes: 7 additions & 0 deletions x/posts/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() {
"cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5",
"cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
subspacestypes.NewSubspace(
2,
Expand All @@ -40,6 +41,7 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() {
"cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5",
"cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
}

Expand Down Expand Up @@ -306,6 +308,7 @@ func (suite *KeeperTestSuite) TestKeeper_ImportGenesis() {
"cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5",
"cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
}

Expand Down Expand Up @@ -339,6 +342,7 @@ func (suite *KeeperTestSuite) TestKeeper_ImportGenesis() {
"cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5",
"cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
}

Expand Down Expand Up @@ -402,6 +406,7 @@ func (suite *KeeperTestSuite) TestKeeper_ImportGenesis() {
"cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5",
"cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
}

Expand Down Expand Up @@ -435,6 +440,7 @@ func (suite *KeeperTestSuite) TestKeeper_ImportGenesis() {
"cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5",
"cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
}

Expand Down Expand Up @@ -492,6 +498,7 @@ func (suite *KeeperTestSuite) TestKeeper_ImportGenesis() {
"cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5",
"cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
}

Expand Down
2 changes: 2 additions & 0 deletions x/posts/keeper/invariants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (suite *KeeperTestSuite) TestValidSubspacesInvariant() {
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
}

Expand All @@ -54,6 +55,7 @@ func (suite *KeeperTestSuite) TestValidSubspacesInvariant() {
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
}

Expand Down
4 changes: 3 additions & 1 deletion x/posts/legacy/v2/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestMigrateStore(t *testing.T) {

paramsSubspace := newMockSubspace(types.Params{})

sk := subspaceskeeper.NewKeeper(cdc, keys[subspacestypes.StoreKey], nil, nil)
sk := subspaceskeeper.NewKeeper(cdc, keys[subspacestypes.StoreKey], nil, nil, "authority")

testCases := []struct {
name string
Expand All @@ -59,6 +59,7 @@ func TestMigrateStore(t *testing.T) {
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
))

sk.SaveSubspace(ctx, subspacestypes.NewSubspace(
Expand All @@ -69,6 +70,7 @@ func TestMigrateStore(t *testing.T) {
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
))
},
shouldErr: false,
Expand Down
2 changes: 1 addition & 1 deletion x/profiles/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestBeginBlocker(t *testing.T) {

ctx := sdk.NewContext(ms, tmproto.Header{ChainID: "test-chain"}, false, log.NewNopLogger())
cdc, legacyAmino := app.MakeCodecs()
sk := subspaceskeeper.NewKeeper(cdc, keys[subspacestypes.StoreKey], nil, nil)
sk := subspaceskeeper.NewKeeper(cdc, keys[subspacestypes.StoreKey], nil, nil, "authority")
rk := relationshipskeeper.NewKeeper(cdc, keys[relationshipstypes.StoreKey], sk)
ak := authkeeper.NewAccountKeeper(cdc, keys[authtypes.StoreKey], authtypes.ProtoBaseAccount, app.GetMaccPerms(), "cosmos", authtypes.NewModuleAddress("gov").String())
k := keeper.NewKeeper(cdc, legacyAmino, keys[types.StoreKey], ak, rk, nil, nil, nil, authtypes.NewModuleAddress("gov").String())
Expand Down
1 change: 1 addition & 0 deletions x/reactions/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
},
nil, nil, nil, nil, nil,
Expand Down
1 change: 1 addition & 0 deletions x/reactions/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() {
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
}

Expand Down
3 changes: 3 additions & 0 deletions x/reactions/keeper/invariants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (suite *KeeperTestSuite) TestValidSubspacesInvariant() {
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
}

Expand All @@ -55,6 +56,7 @@ func (suite *KeeperTestSuite) TestValidSubspacesInvariant() {
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
}

Expand All @@ -80,6 +82,7 @@ func (suite *KeeperTestSuite) TestValidSubspacesInvariant() {
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
"cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn",
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
),
}

Expand Down
Loading