fix(zoe): Fix OfferHandlerI.handle returns guard #8748
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes: #XXXX
refs: #8745
Description
At #8745 (comment) @dckc suggests extracting this one fix into a separate change. This PR is that.
An OfferResult is the value returned by a offer handler.
E(userSeat).getOfferResult()
returns a promise for an OfferResult.By design, an OfferResult can be any
Passable
. Indeed, its static type is often theOR
ofwhich is the type parameter of
UserSeat
.However, the OfferResult is so often a string, that the incorrect assumption that it is a string has crept into our code in at least the two places fixed by this PR. One is an incorrect
returns
guard. The other is an incorrect promise type parameter.Security Considerations
More accurate types help security review. The too-narrow results guard would only cause inappropriate failures, which at least usually preserve integrity while sacrificing availability. The incorrect promise type arg is unsound in a way that might cause a reviewer to miss a loss of integrity: The
@returns {Promise<string>}
statically makes a claim that might silently be violated by runtime behavior. (Note though that neither has yet resulted in any known such problem.)Scaling Considerations
None.
Documentation Considerations
The documentation at https://docs.agoric.com/reference/zoe-api/user-seat.html#e-userseat-getofferresult is already correct. This brings the code into agreement with the existing docs.
More accurate types will also help generate more accurate docs.
Testing Considerations
None.
Upgrade Considerations
None, I think.