Skip to content

Commit

Permalink
feat: implement ADR-22: Per-subspace token factory (#1141)
Browse files Browse the repository at this point in the history
## Description

Deps: #1174 
This PR implements ADR-22: Per-subspace token factory.

Closes: [DCD-316](https://desmoslabs.atlassian.net/browse/DCD-316)

<!-- Add a description of the changes that this PR introduces and the
files that
are the most critical to review. -->

---

### Author Checklist

*All items are required. Please add a note to the item if the item is
not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type
prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json)
in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR
Targeting](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building
modules](https://docs.cosmos.network/v0.44/building-modules/intro.html)
- [x] included the necessary unit and integration
[tests](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go
code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable
and please add
your handle next to the items reviewed if you only reviewed selected
items.*

I have...

- [ ] confirmed the correct [type
prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json)
in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

[DCD-316]:
https://forbole.atlassian.net/browse/DCD-316?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: dadamu <dadamu@users.noreply.github.com>
Co-authored-by: Riccardo <riccardo.montagnin@gmail.com>
  • Loading branch information
3 people committed Jul 4, 2023
1 parent 9788688 commit c9d7b38
Show file tree
Hide file tree
Showing 70 changed files with 11,869 additions and 18 deletions.
583 changes: 583 additions & 0 deletions api/desmos/tokenfactory/module/v1/module.pulsar.go

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ import (
relationshipskeeper "github.com/desmos-labs/desmos/v5/x/relationships/keeper"
reportskeeper "github.com/desmos-labs/desmos/v5/x/reports/keeper"
subspaceskeeper "github.com/desmos-labs/desmos/v5/x/subspaces/keeper"

supplykeeper "github.com/desmos-labs/desmos/v5/x/supply/keeper"
tokenfactorykeeper "github.com/desmos-labs/desmos/v5/x/tokenfactory/keeper"

authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
Expand Down Expand Up @@ -171,6 +171,7 @@ type DesmosApp struct {
ReportsKeeper reportskeeper.Keeper
ReactionsKeeper reactionskeeper.Keeper
SupplyKeeper supplykeeper.Keeper
TokenFactoryKeeper tokenfactorykeeper.Keeper

// Simulation manager
sm *module.SimulationManager
Expand Down Expand Up @@ -248,6 +249,7 @@ func NewDesmosApp(
&app.ReportsKeeper,
&app.ReactionsKeeper,
&app.SupplyKeeper,
&app.TokenFactoryKeeper,
); err != nil {
panic(err)
}
Expand Down
23 changes: 14 additions & 9 deletions app/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ import (
"os"
"path/filepath"

"github.com/desmos-labs/desmos/v5/x/reactions"
supplytypes "github.com/desmos-labs/desmos/v5/x/supply/types"

postskeeper "github.com/desmos-labs/desmos/v5/x/posts/keeper"
poststypes "github.com/desmos-labs/desmos/v5/x/posts/types"

"github.com/desmos-labs/desmos/v5/x/posts"
"github.com/desmos-labs/desmos/v5/x/relationships"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
Expand Down Expand Up @@ -75,11 +66,16 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/desmos-labs/desmos/v5/x/posts"
postskeeper "github.com/desmos-labs/desmos/v5/x/posts/keeper"
poststypes "github.com/desmos-labs/desmos/v5/x/posts/types"
"github.com/desmos-labs/desmos/v5/x/profiles"
profileskeeper "github.com/desmos-labs/desmos/v5/x/profiles/keeper"
profilestypes "github.com/desmos-labs/desmos/v5/x/profiles/types"
"github.com/desmos-labs/desmos/v5/x/reactions"
reactionskeeper "github.com/desmos-labs/desmos/v5/x/reactions/keeper"
reactionstypes "github.com/desmos-labs/desmos/v5/x/reactions/types"
"github.com/desmos-labs/desmos/v5/x/relationships"
relationshipskeeper "github.com/desmos-labs/desmos/v5/x/relationships/keeper"
relationshipstypes "github.com/desmos-labs/desmos/v5/x/relationships/types"
"github.com/desmos-labs/desmos/v5/x/reports"
Expand All @@ -88,6 +84,9 @@ import (
"github.com/desmos-labs/desmos/v5/x/subspaces"
subspaceskeeper "github.com/desmos-labs/desmos/v5/x/subspaces/keeper"
subspacestypes "github.com/desmos-labs/desmos/v5/x/subspaces/types"
supplytypes "github.com/desmos-labs/desmos/v5/x/supply/types"
"github.com/desmos-labs/desmos/v5/x/tokenfactory"
tokenfactorytypes "github.com/desmos-labs/desmos/v5/x/tokenfactory/types"

"github.com/desmos-labs/desmos/v5/x/supply"

Expand Down Expand Up @@ -198,6 +197,7 @@ var (
reports.AppModuleBasic{},
reactions.AppModuleBasic{},
supply.AppModuleBasic{},
tokenfactory.AppModuleBasic{},
)

// Module account permissions
Expand All @@ -212,6 +212,7 @@ var (
{Account: wasm.ModuleName, Permissions: []string{authtypes.Burner}},
{Account: ibcfeetypes.ModuleName},
{Account: icatypes.ModuleName},
{Account: tokenfactorytypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}},
}

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -252,6 +253,7 @@ var (
reportstypes.ModuleName,
reactionstypes.ModuleName,
supplytypes.ModuleName,
tokenfactorytypes.ModuleName,

wasm.ModuleName,
}
Expand Down Expand Up @@ -289,6 +291,7 @@ var (
reportstypes.ModuleName,
reactionstypes.ModuleName,
supplytypes.ModuleName,
tokenfactorytypes.ModuleName,

wasm.ModuleName,
}
Expand Down Expand Up @@ -333,6 +336,7 @@ var (
reportstypes.ModuleName,
reactionstypes.ModuleName,
supplytypes.ModuleName,
tokenfactorytypes.ModuleName,

// wasm module should be at the end of app modules
wasm.ModuleName,
Expand Down Expand Up @@ -374,6 +378,7 @@ var (
reportstypes.ModuleName,
reactionstypes.ModuleName,
supplytypes.ModuleName,
tokenfactorytypes.ModuleName,

wasm.ModuleName,
crisistypes.ModuleName,
Expand Down
7 changes: 7 additions & 0 deletions app/app_module_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import (
reportsmodulev1 "github.com/desmos-labs/desmos/v5/api/desmos/reports/module/v1"
subspacesmodulev1 "github.com/desmos-labs/desmos/v5/api/desmos/subspaces/module/v1"
supplymodulev1 "github.com/desmos-labs/desmos/v5/api/desmos/supply/module/v1"
tokenfactorymodulev1 "github.com/desmos-labs/desmos/v5/api/desmos/tokenfactory/module/v1"

poststypes "github.com/desmos-labs/desmos/v5/x/posts/types"
profilestypes "github.com/desmos-labs/desmos/v5/x/profiles/types"
Expand All @@ -63,6 +64,7 @@ import (
reportstypes "github.com/desmos-labs/desmos/v5/x/reports/types"
subspacestypes "github.com/desmos-labs/desmos/v5/x/subspaces/types"
supplytypes "github.com/desmos-labs/desmos/v5/x/supply/types"
tokenfactorytypes "github.com/desmos-labs/desmos/v5/x/tokenfactory/types"
)

var (
Expand All @@ -77,6 +79,7 @@ var (
ibcfeetypes.ModuleName,
icatypes.ModuleName,
wasmtypes.ModuleName,
tokenfactorytypes.ModuleName,

// We allow the following module accounts to receive funds:
// govtypes.ModuleName
Expand Down Expand Up @@ -224,6 +227,10 @@ var (
Name: supplytypes.ModuleName,
Config: appconfig.WrapAny(&supplymodulev1.Module{}),
},
{
Name: tokenfactorytypes.ModuleName,
Config: appconfig.WrapAny(&tokenfactorymodulev1.Module{}),
},
},
})
)
2 changes: 2 additions & 0 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
relationshipstypes "github.com/desmos-labs/desmos/v5/x/relationships/types"
reportstypes "github.com/desmos-labs/desmos/v5/x/reports/types"
subspacestypes "github.com/desmos-labs/desmos/v5/x/subspaces/types"
tokenfactorytypes "github.com/desmos-labs/desmos/v5/x/tokenfactory/types"

authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
Expand Down Expand Up @@ -258,6 +259,7 @@ func TestAppImportExport(t *testing.T) {
{app.GetKey(poststypes.StoreKey), newApp.GetKey(poststypes.StoreKey), [][]byte{}},
{app.GetKey(reportstypes.StoreKey), newApp.GetKey(reportstypes.StoreKey), [][]byte{}},
{app.GetKey(reactionstypes.StoreKey), newApp.GetKey(reactionstypes.StoreKey), [][]byte{}},
{app.GetKey(tokenfactorytypes.StoreKey), newApp.GetKey(tokenfactorytypes.StoreKey), [][]byte{}},

{app.GetKey(wasmtypes.StoreKey), newApp.GetKey(wasmtypes.StoreKey), [][]byte{wasmtypes.TXCounterPrefix}},
}
Expand Down
3 changes: 3 additions & 0 deletions client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
},
{
"url": "./tmp-swagger-gen/desmos/supply/v1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/desmos/tokenfactory/v1beta1/query.swagger.json"
}
]
}
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

189 changes: 189 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14797,6 +14797,125 @@ paths:
format: uint64
tags:
- Query
/desmos/tokenfactory/v1beta1/params:
get:
summary: >-
Params defines a gRPC query method that returns the tokenfactory
module's

parameters.
operationId: Params
responses:
'200':
description: A successful response.
schema:
type: object
properties:
params:
description: params defines the parameters of the module.
type: object
properties:
denom_creation_fee:
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.
description: >-
DenomCreationFee defines the fee to be charged on the
creation of a new

denom. The fee is drawn from the subspace treasruy
account, and

burned.
description: >-
QueryParamsResponse is the response type for the Query/Params RPC
method.
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
tags:
- Query
/desmos/tokenfactory/v1beta1/subspaces/{subspace_id}/denoms:
get:
summary: |-
SubspaceDenoms defines a gRPC query method for fetching all
denominations created by a specific subspace.
operationId: SubspaceDenoms
responses:
'200':
description: A successful response.
schema:
type: object
properties:
denoms:
type: array
items:
type: string
description: |-
QuerySubspaceDenomsResponse defines the response structure for the
SubspaceDenoms gRPC query.
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
parameters:
- name: subspace_id
in: path
required: true
type: string
format: uint64
tags:
- Query
definitions:
cosmos.base.query.v1beta1.PageRequest:
type: object
Expand Down Expand Up @@ -23482,3 +23601,73 @@ definitions:
total_supply:
type: string
title: QueryTotalResponse is the response type for the Query/Total RPC method
desmos.tokenfactory.v1beta1.Params:
type: object
properties:
denom_creation_fee:
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.
description: >-
DenomCreationFee defines the fee to be charged on the creation of a
new

denom. The fee is drawn from the subspace treasruy account, and

burned.
description: |-
Params defines the parameters for the tokenfactory module.

Since: Desmos 6.0.0
desmos.tokenfactory.v1beta1.QueryParamsResponse:
type: object
properties:
params:
description: params defines the parameters of the module.
type: object
properties:
denom_creation_fee:
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.
description: >-
DenomCreationFee defines the fee to be charged on the creation of
a new

denom. The fee is drawn from the subspace treasruy account, and

burned.
description: QueryParamsResponse is the response type for the Query/Params RPC method.
desmos.tokenfactory.v1beta1.QuerySubspaceDenomsResponse:
type: object
properties:
denoms:
type: array
items:
type: string
description: |-
QuerySubspaceDenomsResponse defines the response structure for the
SubspaceDenoms gRPC query.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ require (
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
mvdan.cc/unparam v0.0.0-20221223090309-7455f1af531d // indirect
nhooyr.io/websocket v1.8.6 // indirect
nhooyr.io/websocket v1.8.7 // indirect
pgregory.net/rapid v0.5.5 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2236,8 +2236,9 @@ mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b h1:DxJ5nJdkhDlLok9K6qO+5290kphD
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4=
mvdan.cc/unparam v0.0.0-20221223090309-7455f1af531d h1:3rvTIIM22r9pvXk+q3swxUQAQOxksVMGK7sml4nG57w=
mvdan.cc/unparam v0.0.0-20221223090309-7455f1af531d/go.mod h1:IeHQjmn6TOD+e4Z3RFiZMMsLVL+A96Nvptar8Fj71is=
nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k=
nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g=
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
pgregory.net/rapid v0.5.5 h1:jkgx1TjbQPD/feRoK+S/mXw9e1uj6WilpHrXJowi6oA=
pgregory.net/rapid v0.5.5/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
Loading

0 comments on commit c9d7b38

Please sign in to comment.