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

add sdk.Result decorator #500

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
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
14 changes: 12 additions & 2 deletions types/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ func (r TxResponse) GetTx() Tx {
return nil
}

type ResultDecorator interface {
DecorateSdkResult(*Result)
}

// WrapServiceResult wraps a result from a protobuf RPC service method call in
// a Result object or error. This method takes care of marshaling the res param to
// protobuf and attaching any events on the ctx.EventManager() to the Result.
Expand All @@ -248,8 +252,14 @@ func WrapServiceResult(ctx Context, res proto.Message, err error) (*Result, erro
events = evtMgr.ABCIEvents()
}

return &Result{
sdkRes := &Result{
Data: data,
Events: events,
}, nil
}
if res != nil {
if decorator, ok := res.(ResultDecorator); ok {
decorator.DecorateSdkResult(sdkRes)
}
}
return sdkRes, nil
}
Loading