-
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: many typing improvements #9516
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
Producer<T>
and work around generic BridgeHandler.register
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.
Love to see all the red, especially of ts-expect-error.
I had a few questions before approving
/** | ||
* Helper to type the registered scoped bridge correctly. | ||
* | ||
* FIXME: This is needed because `register` is not an async function, so |
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.
interesting. it does seem like we would get it working without this but I agree it's not worth the time right now and this is an appropriate working solution
@@ -103,13 +103,16 @@ type ClientProvider = { | |||
}; | |||
|
|||
type Producer<T> = { | |||
resolve: (v: ERef<T>) => void; | |||
resolve: (v: ERef<T | import('@endo/exo').Guarded<T>>) => void; |
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.
shouldn't T
itself by the Guarded type?
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.
Good catch! This was a leftover attempt before I started typing KindFacet
correctly. Reverted.
const vatLoader = name => { | ||
/** @type {VatLoader} */ | ||
const vatLoader = async name => { | ||
/** @typedef {Awaited<WellKnownVats[typeof name]>} VatRoot */ |
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.
inline typedef seems smelly, but I don't have a better solution. Consider naming it ThisVatRoot
or something else to make clear it's just for this switch.
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 opted for ReturnedVat
.
@@ -117,13 +117,15 @@ export const makeMockTestSpace = async log => { | |||
produce.zoe.resolve(zoe); | |||
produce.feeMintAccess.resolve(feeMintAccessP); | |||
|
|||
const vatLoader = name => { | |||
/** @type {VatLoader} */ |
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.
a little loose since the type says it can load any vat and this handles just two of them
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 ended up restricting the loadable name
s.
orchestration: ERef< | ||
ReturnType< | ||
typeof import('@agoric/orchestration/src/vat-orchestration.js').buildRootObject | ||
> | ||
>; |
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.
vat-orchestration exports this
orchestration: ERef< | |
ReturnType< | |
typeof import('@agoric/orchestration/src/vat-orchestration.js').buildRootObject | |
> | |
>; | |
orchestration: OrchestrationVat; |
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.
Okay, adapted.
priceAuthority: PriceAuthorityVat; | ||
provisioning: ProvisioningVat; | ||
transfer: TransferVat; | ||
zoe: ERef<ReturnType<typeof import('../vat-zoe.js').buildRootObject>>; |
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.
shall we have vat-zoe
export this as vat-orchestration
does?
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.
We shall, so I did!
refs: #9441
Description
Finish adopting
WellKnownVats
inVatLoader
as proposed by @turadg in #9441Accommodate
Guarded
types in:Producer<T>.resolve
packages/swingset-liveslots:
KindFacet
impliesRemotableBrand
Cast the return type of
BridgeHandler.register
because it wasn't anasync
function, and there's no way I know using TypeScript to be able to transform the return type of a generic function toPromise<ReturnType<T>>
without losingT
's genericity.