@agoric/vat-data 0.5.3-dev-8e94b2a.0 → 0.5.3-dev-459998d.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -9
- package/src/index.test-d.ts +1 -1
- package/vow.js +2 -51
- package/test/test-vow.js +0 -44
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/vat-data",
|
|
3
|
-
"version": "0.5.3-dev-
|
|
3
|
+
"version": "0.5.3-dev-459998d.0+459998d",
|
|
4
4
|
"description": "Safe access to VatData global",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/Agoric/agoric-sdk",
|
|
@@ -19,17 +19,15 @@
|
|
|
19
19
|
"author": "Agoric",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@agoric/assert": "0.6.1-dev-
|
|
23
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
24
|
-
"@agoric/
|
|
25
|
-
"@agoric/
|
|
26
|
-
"@agoric/
|
|
27
|
-
"@agoric/vow": "0.1.1-dev-8e94b2a.0+8e94b2a",
|
|
22
|
+
"@agoric/assert": "0.6.1-dev-459998d.0+459998d",
|
|
23
|
+
"@agoric/base-zone": "0.1.1-dev-459998d.0+459998d",
|
|
24
|
+
"@agoric/store": "0.9.3-dev-459998d.0+459998d",
|
|
25
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-459998d.0+459998d",
|
|
26
|
+
"@agoric/vow": "0.1.1-dev-459998d.0+459998d",
|
|
28
27
|
"@endo/exo": "^1.4.0",
|
|
29
28
|
"@endo/patterns": "^1.3.1"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
|
-
"@endo/far": "^1.1.1",
|
|
33
31
|
"@endo/init": "^1.1.1",
|
|
34
32
|
"@endo/ses-ava": "^1.2.1",
|
|
35
33
|
"ava": "^5.3.0",
|
|
@@ -52,5 +50,5 @@
|
|
|
52
50
|
"typeCoverage": {
|
|
53
51
|
"atLeast": 98.74
|
|
54
52
|
},
|
|
55
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "459998d3944d5ad9d495de146a6322aedcdd06d0"
|
|
56
54
|
}
|
package/src/index.test-d.ts
CHANGED
package/vow.js
CHANGED
|
@@ -1,51 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { makeE, prepareVowTools as rawPrepareVowTools } from '@agoric/vow';
|
|
4
|
-
import { makeHeapZone } from '@agoric/base-zone/heap.js';
|
|
5
|
-
import { isUpgradeDisconnection } from '@agoric/internal/src/upgrade-api.js';
|
|
6
|
-
|
|
7
|
-
/** @type {any} */
|
|
8
|
-
const vatData = globalThis.VatData;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Manually-extracted watchPromise so we don't accidentally get the 'unavailable'
|
|
12
|
-
* version. If it is `undefined`, `@agoric/vow` will shim it.
|
|
13
|
-
* @type {undefined | ((
|
|
14
|
-
* p: Promise<any>,
|
|
15
|
-
* watcher: import('@agoric/vow/src/watch-promise.js').PromiseWatcher,
|
|
16
|
-
* ...args: unknown[]
|
|
17
|
-
* ) => void)}
|
|
18
|
-
*/
|
|
19
|
-
const watchPromise = vatData && vatData.watchPromise;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Return truthy if a rejection reason should result in a retry.
|
|
23
|
-
* @param {any} reason
|
|
24
|
-
* @returns {boolean}
|
|
25
|
-
*/
|
|
26
|
-
const isRetryableReason = reason => isUpgradeDisconnection(reason);
|
|
27
|
-
|
|
28
|
-
export const defaultPowers = harden({
|
|
29
|
-
isRetryableReason,
|
|
30
|
-
watchPromise,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @type {typeof rawPrepareVowTools}
|
|
35
|
-
*/
|
|
36
|
-
export const prepareVowTools = (zone, powers = {}) =>
|
|
37
|
-
rawPrepareVowTools(zone, { ...defaultPowers, ...powers });
|
|
38
|
-
|
|
39
|
-
export const { watch, when, makeVowKit, allVows } =
|
|
40
|
-
prepareVowTools(makeHeapZone());
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* An vow-shortening E. CAVEAT: This produces long-lived ephemeral
|
|
44
|
-
* promises that encapsulate the shortening behaviour, and so provides no way
|
|
45
|
-
* for `watch` to durably shorten. Use the standard `import('@endo/far').E` if
|
|
46
|
-
* you need to `watch` its resulting promises.
|
|
47
|
-
*/
|
|
48
|
-
export const V = makeE(globalThis.HandledPromise, {
|
|
49
|
-
unwrap: when,
|
|
50
|
-
additional: { when },
|
|
51
|
-
});
|
|
1
|
+
// Backward-compatibility forwarding to the vow package.
|
|
2
|
+
export * from '@agoric/vow/vat.js';
|
package/test/test-vow.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import test from 'ava';
|
|
3
|
-
import { E, Far } from '@endo/far';
|
|
4
|
-
|
|
5
|
-
import { V, makeVowKit } from '../vow.js';
|
|
6
|
-
|
|
7
|
-
test('heap messages', async t => {
|
|
8
|
-
const greeter = Far('Greeter', {
|
|
9
|
-
hello: /** @param {string} name */ name => `Hello, ${name}!`,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
/** @type {ReturnType<typeof makeVowKit<typeof greeter>>} */
|
|
13
|
-
const { vow, resolver } = makeVowKit();
|
|
14
|
-
const retP = V(vow).hello('World');
|
|
15
|
-
resolver.resolve(greeter);
|
|
16
|
-
|
|
17
|
-
// Happy path: WE(vow)[method](...args) calls the method.
|
|
18
|
-
t.is(await retP, 'Hello, World!');
|
|
19
|
-
|
|
20
|
-
// Sad path: E(vow)[method](...args) rejects.
|
|
21
|
-
await t.throwsAsync(
|
|
22
|
-
// @ts-expect-error hello is not accessible via basicE
|
|
23
|
-
() => E(vow).hello('World'),
|
|
24
|
-
{
|
|
25
|
-
message: /target has no method "hello"/,
|
|
26
|
-
},
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
// Happy path: await WE.when unwraps the vow.
|
|
30
|
-
t.is(await V.when(vow), greeter);
|
|
31
|
-
|
|
32
|
-
t.is(
|
|
33
|
-
await V.when(vow, res => {
|
|
34
|
-
t.is(res, greeter);
|
|
35
|
-
return 'done';
|
|
36
|
-
}),
|
|
37
|
-
'done',
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
// Sad path: await by itself gives the raw vow.
|
|
41
|
-
const w = await vow;
|
|
42
|
-
t.not(w, greeter);
|
|
43
|
-
t.truthy(w.payload);
|
|
44
|
-
});
|