Skip to content

Commit

Permalink
chore: mark WrapSdkContext as deprecated (cosmos#14072)
Browse files Browse the repository at this point in the history
* remove wrapping and mark wrapsdkContext as deprecated

* Update types/context.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
  • Loading branch information
tac0turtle and fedekunze committed Nov 29, 2022
1 parent 730d631 commit 04f9ad2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
13 changes: 3 additions & 10 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,7 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg

// call the hooks with the BeginBlock messages
for _, streamingListener := range app.abciListeners {

goCtx := sdk.WrapSDKContext(app.deliverState.ctx)

if err := streamingListener.ListenBeginBlock(goCtx, req, res); err != nil {
if err := streamingListener.ListenBeginBlock(app.deliverState.ctx, req, res); err != nil {
app.logger.Error("BeginBlock listening hook failed", "height", req.Header.Height, "err", err)
}
}
Expand All @@ -229,9 +226,7 @@ func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBloc

// call the streaming service hooks with the EndBlock messages
for _, streamingListener := range app.abciListeners {
goCtx := sdk.WrapSDKContext(app.deliverState.ctx)

if err := streamingListener.ListenEndBlock(goCtx, req, res); err != nil {
if err := streamingListener.ListenEndBlock(app.deliverState.ctx, req, res); err != nil {
app.logger.Error("EndBlock listening hook failed", "height", req.Height, "err", err)
}
}
Expand Down Expand Up @@ -334,9 +329,7 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDeliv

defer func() {
for _, streamingListener := range app.abciListeners {
goCtx := sdk.WrapSDKContext(app.deliverState.ctx)

if err := streamingListener.ListenDeliverTx(goCtx, req, res); err != nil {
if err := streamingListener.ListenDeliverTx(app.deliverState.ctx, req, res); err != nil {
app.logger.Error("DeliverTx listening hook failed", "err", err)
}
}
Expand Down
8 changes: 4 additions & 4 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,11 @@ func (app *BaseApp) Init() error {
app.setProcessProposalState(emptyHeader)
app.Seal()

if app.cms == nil {
return errors.New("commit multi-store must not be nil")
}
if app.cms == nil {
return errors.New("commit multi-store must not be nil")
}

return app.cms.GetPruning().Validate()
return app.cms.GetPruning().Validate()
}

func (app *BaseApp) setMinGasPrices(gasPrices sdk.DecCoins) {
Expand Down
2 changes: 2 additions & 0 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ const SdkContextKey ContextKey = "sdk-context"
// context as a value. It is useful for passing an sdk.Context through methods that take a
// stdlib context.Context parameter such as generated gRPC methods. To get the original
// sdk.Context back, call UnwrapSDKContext.
//
// Deprecated: there is no need to wrap anymore as the Cosmos SDK context implements context.Context.
func WrapSDKContext(ctx Context) context.Context {
return ctx
}
Expand Down

0 comments on commit 04f9ad2

Please sign in to comment.