refactor(x/gov): set environment in context for legacy proposals (#20521)
This commit is contained in:
parent
61da5d1c29
commit
7a87f2bb15
@ -688,6 +688,7 @@ To learn more see the [docs](https://docs.cosmos.network/main/learn/advanced/tra
|
||||
* mention changes with sdk context removal
|
||||
* mention changes with environment
|
||||
* mention changes with environment in context in interfaces
|
||||
* mention legacy proposal in gov when using server/v2 if using sdk context must be rewritten
|
||||
-->
|
||||
|
||||
#### `**all**`
|
||||
|
||||
@ -38,6 +38,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### Improvements
|
||||
|
||||
* [#20521](https://github.com/cosmos/cosmos-sdk/pull/20521) Legacy proposals can now access the `appmodule.Environment` present in the `context.Context` of the handler. This is useful when migrating to server/v2 and removing the sdk context dependency.
|
||||
* [#19741](https://github.com/cosmos/cosmos-sdk/pull/19741) Add `ExpeditedQuorum` parameter specifying a minimum quorum for expedited proposals, that can differ from the regular quorum.
|
||||
* [#19352](https://github.com/cosmos/cosmos-sdk/pull/19352) `TallyResult` include vote options counts. Those counts replicates the now deprecated (but not removed) yes, no, abstain and veto count fields.
|
||||
* [#18976](https://github.com/cosmos/cosmos-sdk/pull/18976) Log and send an event when a proposal deposit refund or burn has failed.
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
|
||||
corecontext "cosmossdk.io/core/context"
|
||||
"cosmossdk.io/core/event"
|
||||
"cosmossdk.io/errors"
|
||||
"cosmossdk.io/math"
|
||||
@ -209,7 +210,10 @@ func (k msgServer) ExecLegacyContent(ctx context.Context, msg *v1.MsgExecLegacyC
|
||||
}
|
||||
|
||||
handler := k.Keeper.legacyRouter.GetRoute(content.ProposalRoute())
|
||||
if err := handler(ctx, content); err != nil {
|
||||
|
||||
// NOTE: the support of legacy gov proposal in server/v2 is different than for baseapp.
|
||||
// Legacy proposal in server/v2 can only access services provided by the gov module environment.
|
||||
if err := handler(context.WithValue(ctx, corecontext.EnvironmentContextKey, k.Environment), content); err != nil {
|
||||
return nil, errors.Wrapf(govtypes.ErrInvalidProposalContent, "failed to run legacy handler %s, %+v", content.ProposalRoute(), err)
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
corecontext "cosmossdk.io/core/context"
|
||||
"cosmossdk.io/core/event"
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
@ -113,7 +114,9 @@ func (k Keeper) SubmitProposal(ctx context.Context, messages []sdk.Msg, metadata
|
||||
|
||||
if err = k.BranchService.Execute(ctx, func(ctx context.Context) error {
|
||||
handler := k.legacyRouter.GetRoute(content.ProposalRoute())
|
||||
if err := handler(ctx, content); err != nil {
|
||||
// NOTE: the support of legacy gov proposal in server/v2 is different than for baseapp.
|
||||
// Legacy proposal in server/v2 can only access services provided by the gov module environment.
|
||||
if err := handler(context.WithValue(ctx, corecontext.EnvironmentContextKey, k.Environment), content); err != nil {
|
||||
return types.ErrInvalidProposalContent.Wrapf("failed to run legacy handler %s, %+v", content.ProposalRoute(), err)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user