Conversation
|
For VaultManager, my singleton conversion still has a state record. What happens to everything in that state record? |
|
I thought I pushed a review earlier, but it's disappeared, sorry. This seems like it might be too simple. It looks much more like our normal JS code, and not much like our durable code at this point. I think that might be a point against it. |
That is exactly why I am so excited ;) |
Just that it doesn't look like the other durable objects, It's not recognizably durable at a glance. |
|
Github mystery: I thought I had originally listed @Chris-Hibbert as a reviewer. When I try to add him (back), Github does not add him. I have never seen this before. Any idea? |
|
You definitely had listed me. I remember seeing it. I don't know what's going on. |
96bb0bc to
767e937
Compare
ab2192f to
68d27f3
Compare
Chris-Hibbert
left a comment
There was a problem hiding this comment.
I misunderstood. This is a significant improvement.
| behavior, | ||
| options = undefined, | ||
| ) => { | ||
| export const ProvideFar = (baggage, kindName, methods, options = undefined) => { |
There was a problem hiding this comment.
| export const ProvideFar = (baggage, kindName, methods, options = undefined) => { | |
| /** | |
| * @template T | |
| * @param {import('@agoric/store').MapStore<string, unknown>} baggage | |
| * @param {string} kindName | |
| * @param {T} methods | |
| * @param {import('./types.js').DefineKindOptions<unknown>} [options] | |
| * @returns {import('@endo/far').ERef<T>} | |
| */ | |
| export const ProvideFar = (baggage, kindName, methods, options) => { |
There was a problem hiding this comment.
I did something similar but different at 98a96e9
I left the optional parameter syntax on the options argument. I think we should in general.
I replaced the ERef<T> with simply T. However, I see at https://github.com/endojs/endo/blob/8077e2134615d6a1cbe8c8f5350f664b56f0a17b/packages/marshal/src/make-far.js#L88 the similar T & RemotableBrand<{}, T>. Please let me know if I should use this instead.
Attn @michaelfig who authored RemotableBrand
PTAL
There was a problem hiding this comment.
I'm not sure. I need to better understand the remote call and marshalling systems. I do know the types are a loose approximation so far.
packages/vat-data/src/kind-utils.js
Outdated
| const behavior = fromEntries( | ||
| entries(methods).map(([k, m]) => [k, dropContext(m)]), | ||
| ); |
There was a problem hiding this comment.
mapping object values at the existing keys is a common need so in run-protocol package we have a helper
agoric-sdk/packages/run-protocol/src/collect.js
Lines 6 to 8 in 68d27f3
should we have it in a more shared package? @agoric/utils?
There was a problem hiding this comment.
Yes, I have a similar one, yes with an extensive comment, at
agoric-sdk/packages/zoe/src/objArrayConversion.js
Lines 45 to 48 in 86d58b9
Which of these two do you prefer?
Like mapValues it is not reusable only because of where it is. However, @agoric/utils would imply that it is in agoric-sdk and so not reusable from the endo repository. Attn @kriskowal is there a natural endo package to migrate such things to? Should there be?
In the meantime, vat-data should clearly not depend on run-protocol or zoe. But I can at least make it a copy of one of these with a note to depend on a common one once a suitable place is found. In the absence of other feedback, I'll copy objectMap. Thanks.
There was a problem hiding this comment.
Agree we should find a place for utilities like this and it should be somewhere in @endo. I'd like to see something analogous to Lodash but SES-smart. @kriskowal WDYT of that? I can make a ticket and I'd be very happy to work on it after MN-1.
As to whether mapValues or objectMap goes in the utility package, I think mapValues fits the common use case better: mapping values without regard to the keys. objectMap takes a function that allows keyword transformations so it's not doing much abstracting over Object.fromEntries(Object.entries.map(mapPairFn));
767e937 to
4ba2c9e
Compare
68d27f3 to
03476ed
Compare
4ba2c9e to
3552107
Compare
98a96e9 to
c6e251a
Compare
3552107 to
4ba2c9e
Compare
c6e251a to
1c13422
Compare
4ba2c9e to
3c6f10c
Compare
1c13422 to
3a856b6
Compare
We've already noticed that singletons always have empty state records, and so their behavior methods never need to use their
state. @dtribble noticed that we can simply use JS's const scoping (temporal dead zone) to make theselforfacetsarguments unnecessary. At that point the context is unnecessary and we just need the "normal" methods. Without common state, there's also little reason to group these into a cohort. Thus, our support for singletons can be much closer toFar. To emphasize this, at this time this PR used the termProvideFar, but we should bikeshed.