From 44b10c0b91cf10ff8b17b86737067ff1ee47586a Mon Sep 17 00:00:00 2001 From: Arnaud Mimart <33665250+amimart@users.noreply.github.com> Date: Wed, 22 Jun 2022 13:49:18 +0200 Subject: [PATCH] feat: handle wasm proposals in app --- app/app.go | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index 3597bd2a..7b93f77f 100644 --- a/app/app.go +++ b/app/app.go @@ -119,16 +119,40 @@ import ( const ( AccountAddressPrefix = "okp4" Name = "okp4d" + + // If EnabledSpecificProposals is "", and this is "true", then enable all x/wasm proposals. + // If EnabledSpecificProposals is "", and this is not "true", then disable all x/wasm proposals. + ProposalsEnabled = "false" + // If set to non-empty string it must be comma-separated list of values that are all a subset + // of "EnableAllProposals" (takes precedence over ProposalsEnabled) + // https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34 + EnableSpecificProposals = "" ) +// GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to +// produce a list of enabled proposals to pass into wasmd app. +func GetEnabledProposals() []wasm.ProposalType { + if EnableSpecificProposals == "" { + if ProposalsEnabled == "true" { + return wasm.EnableAllProposals + } + return wasm.DisableAllProposals + } + chunks := strings.Split(EnableSpecificProposals, ",") + proposals, err := wasm.ConvertToProposals(chunks) + if err != nil { + panic(err) + } + return proposals +} + // this line is used by starport scaffolding # stargate/wasm/app/enabledProposals func getGovProposalHandlers() []govclient.ProposalHandler { var govProposalHandlers []govclient.ProposalHandler // this line is used by starport scaffolding # stargate/app/govProposalHandlers - govProposalHandlers = append(govProposalHandlers, wasmclient.ProposalHandlers...) - govProposalHandlers = append(govProposalHandlers, + govProposalHandlers = append(wasmclient.ProposalHandlers, paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler,