-
Notifications
You must be signed in to change notification settings - Fork 212
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
feat(vowTools): add asVow helper #9577
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.
Very quick review, LGTM
packages/vow/src/vow-utils.js
Outdated
const kit = makeVowKit(); | ||
try { | ||
kit.resolver.resolve(fn()); | ||
} catch (e) { | ||
kit.resolver.reject(e); | ||
} | ||
return kit.vow; |
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 think we could simply support not resolving a vow to a vow with the following:
const kit = makeVowKit(); | |
try { | |
kit.resolver.resolve(fn()); | |
} catch (e) { | |
kit.resolver.reject(e); | |
} | |
return kit.vow; | |
let result; | |
try { | |
result = fn(); | |
} catch (e) { | |
result = Promise.reject(e); | |
} | |
if (isVow(result)) { | |
return result; | |
} | |
const kit = makeVowKit(); | |
kit.resolver.resolve(result); | |
return kit.vow; |
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.
LGTM once the small test feedback is addressed
packages/vow/test/asVow.test.js
Outdated
const testVow = watch(Promise.resolve('payload')); | ||
const testVowAsVow = asVow(() => testVow); | ||
|
||
t.is(testVow, testVowAsVow, 'asVow does not rewrap vows'); |
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.
So technically we should do a "passable compare" here. The tagged vow could be a different object, but the nested payload must contain the same remotable. Not sure if we have a common way to do such passable comparisons.
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 closest thing I'm aware of is getInterfaceOf
, which doesn't quite seem to fit the bill for a "passable compare".
In this testing context, where there's no disconnection, this was a cheap way to verify the behavior. I added a comment with this feedback and context above this line.
- adds asVow() helper function that coerces the result of a function to a Vow - see comment from @mhofman for inspiration: #9454 (comment)
git rebase-todo ``` # Branch pc/as-vow label base-pc-as-vow pick b6b5f5f feat(vowTools): add asVow helper pick 0cdcd5f feat(vowTools): asVow should not wrap a vow as a vow label pc-as-vow reset base-pc-as-vow merge -C 0ad10c6 pc-as-vow # feat(vowTools): add asVow helper (#9577) # Branch pc/watch-utils-as-promise label base-pc-watch-utils-as-promise pick bf430a1 feat(watchUtils): add asPromise helper # To resolve conflicts in the following commit: # * In packages/vow/src/types.js, keep inbound changes and (after that) the # definition of VowTools. # * In packages/vow/test/watch-utils.test.js, keep only inbound changes and # limit them to start at "asPromise converts a vow to a promise" (i.e., # just the additions of # https://github.com/Agoric/agoric-sdk/pull/9620/files#diff-fd7cabcc7d1097036e2981c3262aa20612bec349f6e418d53324fc33b1b26946 ). pick c940d5c feat(vowTools): asPromise helper for unwrapping vows pick 8c27c67 feat(watchUtils): handle non-storables pick 3d5a3f3 feat(types): EVow pick 1c0b964 refactor: don't re-use index pick 274df18 fix(vow): clearer stored/non-stored values pick ff92211 refactor: 'extra' field for future properties label pc-watch-utils-as-promise reset base-pc-watch-utils-as-promise merge -C 8edf902 pc-watch-utils-as-promise # feat(vows): improve handling of ephemeral values (#9620) ```
refs: #9449
Description
asVow
helper toVowTools
to ensure we always return vows, even in the event of early synchronous errors.ChainAccountKit
against feat: ChainAccountKit returns vows #9562