-
Notifications
You must be signed in to change notification settings - Fork 233
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
contract start types #7436
contract start types #7436
Conversation
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 was reviewing by commit and then a force-push made me wonder if I should wait.
zcf?: ZCF, | ||
privateArgs?: {}, | ||
baggage?: Baggage, | ||
) => ERef<{ creatorFacet?: {}; publicFacet?: {} }>; |
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 {}
mean any
in this context?
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.
here it's specifically an empty object, vs the any
several lines down
: SF extends (zcf: { getTerms: () => {} }) => unknown | ||
? { terms: any } | ||
: {}; | ||
: never; | ||
|
||
type StartResult<S> = S extends (...args: any) => Promise<infer U> |
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.
infer U
is magic I have yet to learn. That makes this an "I don't see any critical problems" review and not a "I'm prepared to maintain this code" review.
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.
It's a sort of syntactic sugar for extracting what matches in the condition https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types
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 need to understand the change in vats/src/core/types.js
better.
* centralSupply: Promise<Installation<import('@agoric/vats/src/centralSupply.js').start>>, | ||
* committee: Promise<Installation<import('@agoric/governance/src/committee.js').start>>, | ||
* contractGovernor: Promise<Installation<import('@agoric/governance/src/contractGovernor.js').start>>, | ||
* econCommitteeCharter: Promise<Installation<import('@agoric/inter-protocol/src/econCommitteeCharter.js').start>>, | ||
* feeDistributor: Promise<Installation<import('@agoric/inter-protocol/src/feeDistributor.js').start>>, | ||
* mintHolder: Promise<Installation<import('@agoric/vats/src/mintHolder.js').prepare>>, | ||
* psm: Promise<Installation<import('@agoric/inter-protocol/src/psm/psm.js').start>>, | ||
* reserve: Promise<Installation<import('@agoric/inter-protocol/src/reserve/assetReserve.js').start>>, | ||
* VaultFactory: Promise<Installation<import('@agoric/inter-protocol/src/vaultFactory/vaultFactory.js').start>>, |
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.
This looks like a significant regression. I need to understand the motivation better.
There was some attempt to layer EconomyBootstrapSpace
on top rather than putting that stuff here.
agoric-sdk/packages/inter-protocol/src/proposals/econ-behaviors.js
Lines 86 to 87 in 7c17a16
* }>} EconomyBootstrapSpace | |
*/ |
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'll put these wherever they go. I just command-clicked installation
in the param destructuring to find out where the defs were coming from. I'll try EconomyBootstrapSpace
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.
Now I remember why I put them here: the keys are from WellKnownName
which is the key of the installation
property Record.
Changing that is out of scope, imo. Acceptable?
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.
yes.
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.
oic how this works now: econCommitteeCharter
is not just any old installation... got it.
return harden({}); | ||
return harden([]); |
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.
!
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.
amended 9c4e487 after review to prevent drifts in the future
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 don't see any problems with this, but, echoing @dckc, I can't approve this without understanding the answers to his questions.
@@ -302,3 +292,43 @@ test('initialPrice', /** @param {ExecutionContext} t */ async t => { | |||
const q400 = await E(pa).quoteGiven(make(collateral.brand, 400n), debt.brand); | |||
t.deepEqual(q400.quoteAmount.value[0].amountOut, make(debt.brand, 14200n)); | |||
}); | |||
|
|||
test.skip('types', async t => { |
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.
If it's intended that this be checked in with test.skip
, it should have a comment saying why.
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.
the comment on 303-305 works for me.
I guess moving it up could have made it easier to see.
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 put in into a separate (non-Ava) test file to avoid the confusion. Doing that also let me use .ts syntax for better test coverage.
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'm still confused. I infer from the latest comment that the .ts file was intended to replace this test, but the test is still here.
I don't understand how a skipped test helps to declare types, or what other function it might serve.
Does the .ts file add code to our system, or does it only impact type declarations?
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.
looks good
@@ -302,3 +292,43 @@ test('initialPrice', /** @param {ExecutionContext} t */ async t => { | |||
const q400 = await E(pa).quoteGiven(make(collateral.brand, 400n), debt.brand); | |||
t.deepEqual(q400.quoteAmount.value[0].amountOut, make(debt.brand, 14200n)); | |||
}); | |||
|
|||
test.skip('types', async t => { |
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'm still confused. I infer from the latest comment that the .ts file was intended to replace this test, but the test is still here.
I don't understand how a skipped test helps to declare types, or what other function it might serve.
Does the .ts file add code to our system, or does it only impact type declarations?
* @file uses .ts syntax to be able to declare types (e.g. of kit.creatorFacet as {}) | ||
* because "there is no JavaScript syntax for passing a a type argument" | ||
* https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html |
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'm confused about the contribution of this file. I thought .ts fles were for type declarations, but this looks like imperative code, though not working code. What is its impact? What types are being declared or implied? Does it run as code during tests, or is it parsed and discarded, or something else?
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'm still confused. I infer from the latest comment that the .ts file was intended to replace this test, but the test is still here.
Sorry about that. I must have messed up a rebase. I've amended and push ed with the test.skip('types')
removed.
I don't understand how a skipped test helps to declare types, or what other function it might serve.
The intent was to have some types tests co-located with the runtime tests for a particular specimen (e.g. scaledPriceAuthority
). But it's better to keep purely types tests out of Ava tests so it doesn't report about skipping. Indeed, the thing being tested (type check) isn't being skipped at all.
Does the .ts file add code to our system, or does it only impact type declarations?
It's only read by the tsc
checker run by yarn lint:types
.
I thought .ts fles were for type declarations, but this looks like imperative code, though not working code.
.d.ts
is for type declarations. .ts
is transpiled to .js
so it's for any code.. The test-d.ts
is meant to convey that while it's a .ts
it's for testing type defs. That's a convention of the tsd
package.
What is its impact?
It just gets included in the tsc
type check. So if something here starts erroring (or stops, because the ts-expect-error
is not finding one) then it'll cause lint:types
(and thus CI) to fail.
Does it run as code during tests, or is it parsed and discarded, or something else?
Ava won't run it because it doesn't match the pattern Ava looks for. It's parsed only by tsc
. When the package gets built the tsc config will transpile it, but to a similarly ignored test file.
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.
Thanks for the explanations. Would it make sense to add any of this as a comment to the file?
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.
It would have to be duplicated for each file. I've put it in the wiki: https://github.com/Agoric/agoric-sdk/wiki/Static-types-testing
"@jest/schemas@^29.4.3": | ||
version "29.4.3" | ||
resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.4.3.tgz#39cf1b8469afc40b6f5a2baaa146e332c4151788" | ||
integrity sha512-VLYKXQmtmuEz6IxJsrZwzG9NvtkQsWNnWMsKxqWNu3+CnfzJQhp0WDDKWLVV9hLKr0l3SLLFRqcYHjhtyuDVxg== | ||
dependencies: | ||
"@sinclair/typebox" "^0.25.16" | ||
|
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.
it's unusual for check-ins to contain yarn.lock
. Is it intentional here? What would it take to review it for correctness?
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.
The commit added a devDpendency upon tsd
. Almost any change in dependencies will change yarn.lock
. Because that's automated there's not much to review. The important thing to review is the package.json changes. For yarn.lock you might want to verify there are no duplicates or that it hasn't grown dramatically. If there are duplicates they can be fixed with npx yarn-deduplicate
.
Description
No ticket. Nerd-sniped in #7426 (comment)
Tighter definition for
startInstance
, resulting in more installation types required in bootstrap.That then brought up some governance types inconsistencies. Those have an issue so I punted with a comment.
There were two runtime changes to vaultFactory types which I separated.
Review by commit recommended.
Security Considerations
n/a
Scaling Considerations
n/a
Documentation Considerations
--
Testing Considerations
CI