@agoric/vow 0.1.1-dev-cbe061c.0 → 0.1.1-dev-a3826e9.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.
Files changed (2) hide show
  1. package/package.json +5 -4
  2. package/vat.js +55 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/vow",
3
- "version": "0.1.1-dev-cbe061c.0+cbe061c",
3
+ "version": "0.1.1-dev-a3826e9.0+a3826e9",
4
4
  "description": "Remote (shortening and disconnection-tolerant) Promise-likes",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -20,8 +20,8 @@
20
20
  "lint:types": "tsc"
21
21
  },
22
22
  "dependencies": {
23
- "@agoric/base-zone": "0.1.1-dev-cbe061c.0+cbe061c",
24
- "@agoric/internal": "0.3.3-dev-cbe061c.0+cbe061c",
23
+ "@agoric/base-zone": "0.1.1-dev-a3826e9.0+a3826e9",
24
+ "@agoric/internal": "0.3.3-dev-a3826e9.0+a3826e9",
25
25
  "@endo/env-options": "^1.1.4",
26
26
  "@endo/eventual-send": "^1.2.2",
27
27
  "@endo/pass-style": "^1.4.0",
@@ -45,6 +45,7 @@
45
45
  "author": "Agoric",
46
46
  "license": "Apache-2.0",
47
47
  "files": [
48
+ "*.js",
48
49
  "src"
49
50
  ],
50
51
  "publishConfig": {
@@ -53,5 +54,5 @@
53
54
  "typeCoverage": {
54
55
  "atLeast": 89.6
55
56
  },
56
- "gitHead": "cbe061cdb847d99ea435c26131709527b40a1ce5"
57
+ "gitHead": "a3826e91d9c4f33dd4ce384e7b5de1447f93cf98"
57
58
  }
package/vat.js ADDED
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @file specialization of the `@agoric/vow` package for the vat disconnection rejections produced by
3
+ * the SwingSet kernel.
4
+ */
5
+
6
+ /* global globalThis */
7
+ // @ts-check
8
+ import { isUpgradeDisconnection } from '@agoric/internal/src/upgrade-api.js';
9
+ import { makeHeapZone } from '@agoric/base-zone/heap.js';
10
+ import { makeE, prepareVowTools as rawPrepareVowTools } from './src/index.js';
11
+
12
+ /** @type {import('./src/types.js').IsRetryableReason} */
13
+ const isRetryableReason = (reason, priorRetryValue) => {
14
+ if (
15
+ isUpgradeDisconnection(reason) &&
16
+ (!priorRetryValue ||
17
+ reason.incarnationNumber > priorRetryValue.incarnationNumber)
18
+ ) {
19
+ return reason;
20
+ }
21
+ return undefined;
22
+ };
23
+
24
+ export const defaultPowers = harden({
25
+ isRetryableReason,
26
+ });
27
+
28
+ /**
29
+ * Produce SwingSet-compatible vowTools, with an arbitrary Zone type
30
+ *
31
+ * @type {typeof rawPrepareVowTools}
32
+ */
33
+ export const prepareVowTools = (zone, powers = {}) =>
34
+ rawPrepareVowTools(zone, { ...defaultPowers, ...powers });
35
+
36
+ /**
37
+ * `vowTools` that are not durable, but are useful in non-durable clients that
38
+ * need to consume vows from other SwingSet vats.
39
+ */
40
+ export const heapVowTools = prepareVowTools(makeHeapZone());
41
+
42
+ /**
43
+ * A vow-shortening E, for use in vats that are not durable but receive vows.
44
+ *
45
+ * When the vows must be watched durably, use vowTools prepared in a durable zone.
46
+ *
47
+ * This produces long-lived ephemeral promises that encapsulate the shortening
48
+ * behaviour, and so provides no way for `watch` to durably shorten. Use the
49
+ * standard `import('@endo/far').E` if you need to `watch` its resulting
50
+ * promises.
51
+ */
52
+ export const heapVowE = makeE(globalThis.HandledPromise, {
53
+ unwrap: heapVowTools.when,
54
+ additional: { when: heapVowTools.when },
55
+ });