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

[SG-235] feat: integrate token factory #803

Merged
merged 26 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
12 changes: 6 additions & 6 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ steps:
password:
from_secret: docker_password
tags:
- v10.0.1.alpha-1
- v11.0.0-alpha.1
when:
event:
- push
branch:
- jhernandezb/update-libwasmvm
- spoorthi/token-factory
- name: docker_release
image: plugins/docker
settings:
Expand Down Expand Up @@ -313,7 +313,7 @@ steps:
environment:
GOPROXY: http://goproxy
- name: stargaze
image: publicawesome/stargaze:9.0.0
image: publicawesome/stargaze:10.0.1
commands:
- ./scripts/ci/upgrade/setup-preinstalled-stargaze.sh
environment:
Expand Down Expand Up @@ -350,7 +350,7 @@ steps:
- ./scripts/ci/upgrade/proposal.sh
- name: stargaze-upgraded
pull: always
image: publicawesome/stargaze:v10.0.1.alpha-1
image: publicawesome/stargaze:v11.0.0-alpha.1
commands:
- ./scripts/ci/upgrade/run-upgrade.sh
environment:
Expand All @@ -369,7 +369,7 @@ steps:
- http://icad:26657
- name: check-params
pull: always
image: publicawesome/stargaze:v10.0.1.alpha-1
image: publicawesome/stargaze:v11.0.0-alpha.1
commands:
- starsd q globalfee params --node http://stargaze-upgraded:26657
environment:
Expand Down Expand Up @@ -411,6 +411,6 @@ volumes:

---
kind: signature
hmac: b2d583e9b1cde6ac36be1e9c239762e3af7717daf94cf73dd401b9e026866dff
hmac: 71444d9f3946dc2f7b52f73c6063e53bd69cdcce971772a09d2fc405e7916137

...
39 changes: 33 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ import (
"github.com/public-awesome/stargaze/v11/x/mint"
mintkeeper "github.com/public-awesome/stargaze/v11/x/mint/keeper"
minttypes "github.com/public-awesome/stargaze/v11/x/mint/types"
"github.com/public-awesome/stargaze/v11/x/tokenfactory"
tokenfactorykeeper "github.com/public-awesome/stargaze/v11/x/tokenfactory/keeper"
tokenfactorytypes "github.com/public-awesome/stargaze/v11/x/tokenfactory/types"
"github.com/spf13/cast"
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
Expand Down Expand Up @@ -214,6 +217,7 @@ var (
allocmodule.AppModuleBasic{},
cronmodule.AppModuleBasic{},
globalfeemodule.AppModuleBasic{},
tokenfactory.AppModuleBasic{},
wasm.AppModuleBasic{},
ica.AppModuleBasic{},
)
Expand All @@ -234,6 +238,7 @@ var (
icatypes.ModuleName: nil,
cronmoduletypes.ModuleName: nil,
globalfeemoduletypes.ModuleName: nil,
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
// this line is used by starport scaffolding # stargate/app/maccPerms
}
)
Expand Down Expand Up @@ -299,10 +304,11 @@ type App struct {
ScopedWasmKeeper capabilitykeeper.ScopedKeeper

// stargaze modules
ClaimKeeper claimmodulekeeper.Keeper
AllocKeeper allocmodulekeeper.Keeper
CronKeeper cronmodulekeeper.Keeper
GlobalFeeKeeper globalfeemodulekeeper.Keeper
AllocKeeper allocmodulekeeper.Keeper
ClaimKeeper claimmodulekeeper.Keeper
CronKeeper cronmodulekeeper.Keeper
GlobalFeeKeeper globalfeemodulekeeper.Keeper
TokenFactoryKeeper tokenfactorykeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration

// the module manager
Expand Down Expand Up @@ -343,6 +349,7 @@ func NewStargazeApp(
authzkeeper.StoreKey,
wasm.StoreKey,
cronmoduletypes.StoreKey,
tokenfactorytypes.StoreKey,
icahosttypes.StoreKey,
globalfeemoduletypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
Expand Down Expand Up @@ -515,12 +522,21 @@ func NewStargazeApp(

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
availableCapabilities := "iterator,staking,stargate,stargaze,cosmwasm_1_1,cosmwasm_1_2"
availableCapabilities := "iterator,staking,stargate,stargaze,cosmwasm_1_1,cosmwasm_1_2,token_factory"

// Wasm accepted Stargate Queries
acceptStargateQueriesList := wasmkeeper.AcceptedStargateQueries{
"/stargaze.tokenfactory.v1.Query/Params": &tokenfactorytypes.QueryParamsResponse{},
"/stargaze.tokenfactory.v1.Query/DenomAuthorityMetadata": &tokenfactorytypes.QueryDenomAuthorityMetadataResponse{},
"/stargaze.tokenfactory.v1.Query/DenomsFromCreator": &tokenfactorytypes.QueryDenomsFromCreatorResponse{},
}

wasmOpts = append(
wasmOpts,
wasmkeeper.WithMessageEncoders(sgwasm.MessageEncoders(registry)),
wasmkeeper.WithQueryPlugins(nil),
wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{
Stargate: wasmkeeper.AcceptListStargateQuerier(acceptStargateQueriesList, app.GRPCQueryRouter(), appCodec),
}),
)
app.WasmKeeper = wasm.NewKeeper(
appCodec,
Expand Down Expand Up @@ -582,6 +598,12 @@ func NewStargazeApp(
)
allocModule := allocmodule.NewAppModule(appCodec, app.AllocKeeper)

tokenfactoryKeeper := tokenfactorykeeper.NewKeeper(keys[tokenfactorytypes.StoreKey], app.GetSubspace(tokenfactorytypes.ModuleName),
app.AccountKeeper, app.BankKeeper, app.DistrKeeper)
app.TokenFactoryKeeper = tokenfactoryKeeper

// this line is used by starport scaffolding # stargate/app/keeperDefinition

/**** Module Options ****/

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
Expand Down Expand Up @@ -619,6 +641,7 @@ func NewStargazeApp(
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
cronModule,
globalfeeModule,
tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper),
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand All @@ -639,6 +662,7 @@ func NewStargazeApp(
wasm.ModuleName,
cronmoduletypes.ModuleName,
globalfeemoduletypes.ModuleName,
tokenfactorytypes.ModuleName,
)

app.mm.SetOrderEndBlockers(
Expand All @@ -654,6 +678,7 @@ func NewStargazeApp(
wasm.ModuleName,
cronmoduletypes.ModuleName,
globalfeemoduletypes.ModuleName,
tokenfactorytypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -681,6 +706,7 @@ func NewStargazeApp(
paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName,
claimmoduletypes.ModuleName,
allocmoduletypes.ModuleName,
tokenfactorytypes.ModuleName,
// wasm after ibc transfer
wasm.ModuleName,
cronmoduletypes.ModuleName,
Expand Down Expand Up @@ -906,6 +932,7 @@ func initParamsKeeper(
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(claimmoduletypes.ModuleName)
paramsKeeper.Subspace(allocmoduletypes.ModuleName)
paramsKeeper.Subspace(tokenfactorytypes.ModuleName)
paramsKeeper.Subspace(wasm.ModuleName)
paramsKeeper.Subspace(cronmoduletypes.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
Expand Down
10 changes: 9 additions & 1 deletion app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

tokenfactorytypes "github.com/public-awesome/stargaze/v11/x/tokenfactory/types"
)

// next upgrade name
Expand All @@ -20,6 +22,10 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
if err != nil {
return nil, err
}
params := app.TokenFactoryKeeper.GetParams(ctx)
params.DenomCreationFee = nil
params.DenomCreationGasConsume = 50_000_000 // 50STARS at 1ustars
app.TokenFactoryKeeper.SetParams(ctx, params)
return migrations, nil
})

Expand All @@ -29,7 +35,9 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
}

if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := store.StoreUpgrades{}
storeUpgrades := store.StoreUpgrades{
Added: []string{tokenfactorytypes.ModuleName},
}
// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
Expand Down
Loading