@agoric/internal 0.3.3-dev-0142906.0 → 0.3.3-dev-7386420.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/internal",
3
- "version": "0.3.3-dev-0142906.0+0142906",
3
+ "version": "0.3.3-dev-7386420.0+7386420",
4
4
  "description": "Externally unsupported utilities internal to agoric-sdk",
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/assert": "0.6.1-dev-0142906.0+0142906",
24
- "@agoric/base-zone": "0.1.1-dev-0142906.0+0142906",
23
+ "@agoric/assert": "0.6.1-dev-7386420.0+7386420",
24
+ "@agoric/base-zone": "0.1.1-dev-7386420.0+7386420",
25
25
  "@endo/common": "^1.0.2",
26
26
  "@endo/far": "^1.0.2",
27
27
  "@endo/init": "^1.0.2",
@@ -53,5 +53,5 @@
53
53
  "typeCoverage": {
54
54
  "atLeast": 92.28
55
55
  },
56
- "gitHead": "01429068207eee29c412eadc15dabf70d519e5d3"
56
+ "gitHead": "738642095d444795a16ee23c6e34e97f0f8e37ba"
57
57
  }
@@ -1,7 +1,16 @@
1
- export function makeUpgradeDisconnection(upgradeMessage: string, toIncarnationNumber: number): DisconnectionObject;
2
- export function isUpgradeDisconnection(err: any): err is DisconnectionObject;
3
- export type DisconnectionObject = {
4
- name: string;
1
+ export namespace UpgradeDisconnectionShape {
2
+ let name: string;
3
+ let upgradeMessage: import("@endo/patterns").Matcher;
4
+ let incarnationNumber: import("@endo/patterns").Matcher;
5
+ }
6
+ export function makeUpgradeDisconnection(upgradeMessage: string, toIncarnationNumber: number): UpgradeDisconnection;
7
+ export function isUpgradeDisconnection(reason: any): reason is UpgradeDisconnection;
8
+ /**
9
+ * An Error-like object for use as the rejection reason of promises
10
+ * abandoned by upgrade.
11
+ */
12
+ export type UpgradeDisconnection = {
13
+ name: 'vatUpgraded';
5
14
  upgradeMessage: string;
6
15
  incarnationNumber: number;
7
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade-api.d.ts","sourceRoot":"","sources":["upgrade-api.js"],"names":[],"mappings":"AAgBO,yDAJI,MAAM,uBACN,MAAM,GACJ,mBAAmB,CAO5B;AAcG,4CAHI,GAAG,8BAO6B;kCAlC9B;IAAE,MAAM,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE"}
1
+ {"version":3,"file":"upgrade-api.d.ts","sourceRoot":"","sources":["upgrade-api.js"],"names":[],"mappings":";;;;;AAgCO,yDAJI,MAAM,uBACN,MAAM,GACJ,oBAAoB,CAO7B;AASG,+CALI,GAAG,kCAMkD;;;;;mCApCnD;IACZ,MAAU,aAAa,CAAC;IACxB,cAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAqB,EAAE,MAAM,CAAA;CAC1B"}
@@ -1,18 +1,34 @@
1
1
  // @ts-check
2
2
  // @jessie-check
3
- import { isObject } from '@endo/marshal';
3
+
4
+ import { M, matches } from '@endo/patterns';
5
+
6
+ const { isFrozen } = Object;
4
7
 
5
8
  /**
6
- * @typedef {{ name: string, upgradeMessage: string, incarnationNumber: number }} DisconnectionObject
9
+ * An Error-like object for use as the rejection reason of promises
10
+ * abandoned by upgrade.
11
+ *
12
+ * @typedef {{
13
+ * name: 'vatUpgraded',
14
+ * upgradeMessage: string,
15
+ * incarnationNumber: number
16
+ * }} UpgradeDisconnection
7
17
  */
8
18
 
19
+ export const UpgradeDisconnectionShape = harden({
20
+ name: 'vatUpgraded',
21
+ upgradeMessage: M.string(),
22
+ incarnationNumber: M.number(),
23
+ });
24
+
9
25
  /**
10
- * Makes an Error-like object for use as the rejection value of promises
26
+ * Makes an Error-like object for use as the rejection reason of promises
11
27
  * abandoned by upgrade.
12
28
  *
13
29
  * @param {string} upgradeMessage
14
30
  * @param {number} toIncarnationNumber
15
- * @returns {DisconnectionObject}
31
+ * @returns {UpgradeDisconnection}
16
32
  */
17
33
  export const makeUpgradeDisconnection = (upgradeMessage, toIncarnationNumber) =>
18
34
  harden({
@@ -22,20 +38,12 @@ export const makeUpgradeDisconnection = (upgradeMessage, toIncarnationNumber) =>
22
38
  });
23
39
  harden(makeUpgradeDisconnection);
24
40
 
25
- // TODO: Simplify once we have @endo/patterns (or just export the shape).
26
- // const upgradeDisconnectionShape = harden({
27
- // name: 'vatUpgraded',
28
- // upgradeMessage: M.string(),
29
- // incarnationNumber: M.number(),
30
- // });
31
- // const isUpgradeDisconnection = err => matches(err, upgradeDisconnectionShape);
32
41
  /**
33
- * @param {any} err
34
- * @returns {err is DisconnectionObject}
42
+ * @param {any} reason
43
+ * If `reason` is not frozen, it cannot be an UpgradeDisconnection,
44
+ * so returns false without even checking against the shape.
45
+ * @returns {reason is UpgradeDisconnection}
35
46
  */
36
- export const isUpgradeDisconnection = err =>
37
- isObject(err) &&
38
- err.name === 'vatUpgraded' &&
39
- typeof err.upgradeMessage === 'string' &&
40
- typeof err.incarnationNumber === 'number';
47
+ export const isUpgradeDisconnection = reason =>
48
+ isFrozen(reason) && matches(reason, UpgradeDisconnectionShape);
41
49
  harden(isUpgradeDisconnection);