-
Notifications
You must be signed in to change notification settings - Fork 215
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
fix Payment type #10828
base: master
Are you sure you want to change the base?
fix Payment type #10828
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
c7d1762
to
38fd3af
Compare
* @param {ERef<Purse>} recoveryPurse | ||
* @param {ERef<P>} srcPaymentP | ||
* @template {AssetKind} K | ||
* @template {Key} M |
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 rename all these to something other than M
.
packages/ERTP/src/issuerKit.js
Outdated
@@ -322,7 +322,7 @@ harden(prepareIssuerKit); | |||
* anything else is corrupted by that corrupted state. See | |||
* https://github.com/Agoric/agoric-sdk/issues/3434 | |||
* @param {IssuerOptionsRecord} [options] | |||
* @returns {IssuerKit<K, any>} | |||
* @returns {IssuerKit<K>} |
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.
Why not also parameterize the type of makeIssuerKit
with the thing you're currently calling M
? Is this where the inference on the elementShape
would go?
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.
just a matter of prioritization. done now
packages/ERTP/src/types.ts
Outdated
getAllegedBrand: () => Brand<K>; | ||
}; | ||
> = RemotableObject & | ||
Tagged< |
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.
I understand that the unfortunate name collision on Tagged
comes from elsewhere, so we cannot easily fix it. But especially when juxtaposed with Remotable
or other passable type names, it is terribly confusing. Please at least comment all such usage sites.
I see you're passing this through '@agoric/internal/src/tagged.js'
anyway. Perhaps we could have the reexport a rename, and then avoid this unfortunate name collision everywhere else? This would be better than commenting each confusing usage site.
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.
Fair. I've added an alternate export. I kept the rest of the source to make it easier to maintain with changes upstream
* @type {IssuerKit<'set', { seat: number; show: string; start: string }>} | ||
*/ (makeIssuerKit('Agoric Ballet Opera tickets', AssetKind.SET)); |
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.
Does it make sense to also pass a corresponding elementShape
to this call to makeIssuerKit
?
As a test, maybe not worth bothering, so I ask hypothetically: would it have made sense, if code like this appears in production?
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.
Several sites now use elementShape. I think the illustration is best when there's a TypedPattern shape available, like with InvitationElementShape
which I was happy to find. This instance I think serves as a useful example of typing when you don't have an elementShape defined.
const { mint, issuer, brand } = makeIssuerKit('invitations', AssetKind.SET); | ||
const { mint, issuer, brand } = | ||
/** @type {IssuerKit<'set', InvitationDetails>} */ ( | ||
makeIssuerKit('invitations', AssetKind.SET) |
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.
Likewise
* @returns {O['elementShape'] extends TypedPattern<infer T> | ||
* ? IssuerKit<K, T> | ||
* : IssuerKit<K>} |
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.
OMG cool!
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!
1ec2322
to
bc25555
Compare
Stuck on this error:
I'll come back to it when I have time |
refs: https://github.com/Agoric/agoric-private/issues/236
Description
The
Payment
type wasn't using theM extends Key
parameter, causing an error in type checking whennoUnusedLocals
is enabled.That was placed there in anticipation of using it to convey the type of keys in a set-like amount. This implements that.
It also adds a
makePriceQuoteIssuer
to reduce the boilerplate of casting themakeIssuerKit('quote', 'set')
to carry thePriceDescription
key.Security Considerations
none
Scaling Considerations
none
Documentation Considerations
nothing new
Testing Considerations
existing tests
Upgrade Considerations
none