-
Notifications
You must be signed in to change notification settings - Fork 217
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
make userSeat.getPayout(foo) throw if foo is not present #10738
Conversation
2666d59
to
a8c4ad5
Compare
Deploying agoric-sdk with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Design change LGTM but I'd want to hear from @erights too
@@ -143,8 +148,8 @@ export const makeZoeSeatAdminFactory = baggage => { | |||
// doExit(), which ensures that finalPayouts() has set state.payouts. | |||
return E.when( | |||
state.subscriber.subscribeAfter(), | |||
() => state.payouts[keyword], | |||
() => state.payouts[keyword], | |||
() => getPayoutOrThrow(state, keyword), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use NonNullish() instead of a new function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When switching to NonNullish
, please remember to use the second optional optDetails
argument so the error message remains informative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Yes, as a general principle we should prefer errors rather than nullish for failures that most likely indicate that there's a bug somewhere that needs to be fixed.
@@ -143,8 +148,8 @@ export const makeZoeSeatAdminFactory = baggage => { | |||
// doExit(), which ensures that finalPayouts() has set state.payouts. | |||
return E.when( | |||
state.subscriber.subscribeAfter(), | |||
() => state.payouts[keyword], | |||
() => state.payouts[keyword], | |||
() => getPayoutOrThrow(state, keyword), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When switching to NonNullish
, please remember to use the second optional optDetails
argument so the error message remains informative.
Please correct this PR comment before merging. I looked, and #8610 correctly explains that it returned state.payouts[keyword] || Fail`No payout for ${keyword}`; (that '' || 3; // 3
'' ?? 3; // '' Yes, it sucks that JS forces all these usually-pointless distinctions on us. But given that it does, we need to avoid any further muddying of these treacherous waters. |
closes: #8610
Description
#8610 explains that
getPayout(foo)
returnsundefined
, which doesn't match the declarations. I explored changing the types to indicate thatundefined
is possible, but that would have required that many tests override the types.It seems cleaner to change the implementation to
throw
if the named key doesn't correspond to a payment. Callers shouldn't make that mistake outside of tests. If they're uncertain they should callgetPayouts()
instead.Security Considerations
No impact
Scaling Considerations
Not relevant
Documentation Considerations
I update the declaration in
types-ambient.js
, so the generated docs will be updated automatically. I'll create a separate PR to update github.com/Agoric/documentation.Testing Considerations
Added a test that shows the throw. Nothing else was impacted.
Upgrade Considerations
No relevance.