@agoric/internal 0.3.3-other-dev-8f8782b.0 → 0.3.3-other-dev-3eb1a1d.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 (110) hide show
  1. package/README.md +7 -2
  2. package/exported.js +2 -0
  3. package/package.json +35 -17
  4. package/src/action-types.d.ts +50 -5
  5. package/src/action-types.d.ts.map +1 -1
  6. package/src/action-types.js +73 -14
  7. package/src/batched-deliver.d.ts +9 -6
  8. package/src/batched-deliver.d.ts.map +1 -1
  9. package/src/batched-deliver.js +9 -3
  10. package/src/callback.d.ts +23 -16
  11. package/src/callback.d.ts.map +1 -1
  12. package/src/callback.js +48 -55
  13. package/src/chain-storage-paths.d.ts +2 -3
  14. package/src/chain-storage-paths.d.ts.map +1 -1
  15. package/src/chain-storage-paths.js +2 -3
  16. package/src/chain-utils.d.ts +25 -0
  17. package/src/chain-utils.d.ts.map +1 -0
  18. package/src/chain-utils.js +57 -0
  19. package/src/config.d.ts +24 -12
  20. package/src/config.d.ts.map +1 -1
  21. package/src/config.js +21 -10
  22. package/src/debug.d.ts +1 -1
  23. package/src/errors.d.ts +2 -0
  24. package/src/errors.d.ts.map +1 -0
  25. package/src/errors.js +16 -0
  26. package/src/index.d.ts +8 -1
  27. package/src/index.js +12 -2
  28. package/src/install-ses-debug.d.ts +2 -0
  29. package/src/install-ses-debug.d.ts.map +1 -0
  30. package/src/install-ses-debug.js +6 -0
  31. package/src/js-utils.d.ts +7 -0
  32. package/src/js-utils.d.ts.map +1 -0
  33. package/src/js-utils.js +89 -0
  34. package/src/lib-chainStorage.d.ts +42 -52
  35. package/src/lib-chainStorage.d.ts.map +1 -1
  36. package/src/lib-chainStorage.js +88 -77
  37. package/src/lib-nodejs/engine-gc.d.ts +3 -0
  38. package/src/lib-nodejs/engine-gc.d.ts.map +1 -0
  39. package/src/lib-nodejs/engine-gc.js +22 -0
  40. package/src/lib-nodejs/gc-and-finalize.d.ts +2 -0
  41. package/src/lib-nodejs/gc-and-finalize.d.ts.map +1 -0
  42. package/src/lib-nodejs/gc-and-finalize.js +91 -0
  43. package/src/lib-nodejs/spawnSubprocessWorker.d.ts +15 -0
  44. package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -0
  45. package/src/lib-nodejs/spawnSubprocessWorker.js +89 -0
  46. package/src/lib-nodejs/waitUntilQuiescent.d.ts +2 -0
  47. package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -0
  48. package/src/lib-nodejs/waitUntilQuiescent.js +18 -0
  49. package/src/lib-nodejs/worker-protocol.d.ts +4 -0
  50. package/src/lib-nodejs/worker-protocol.d.ts.map +1 -0
  51. package/src/lib-nodejs/worker-protocol.js +54 -0
  52. package/src/magic-cookie-test-only.js +2 -2
  53. package/src/marshal.d.ts +20 -0
  54. package/src/marshal.d.ts.map +1 -0
  55. package/src/marshal.js +137 -0
  56. package/src/method-tools.d.ts +1 -0
  57. package/src/method-tools.d.ts.map +1 -1
  58. package/src/method-tools.js +29 -16
  59. package/src/netstring.d.ts +24 -0
  60. package/src/netstring.d.ts.map +1 -0
  61. package/src/netstring.js +124 -0
  62. package/src/node/buffer-line-transform.d.ts +17 -13
  63. package/src/node/buffer-line-transform.d.ts.map +1 -1
  64. package/src/node/buffer-line-transform.js +12 -9
  65. package/src/node/createBundles.d.ts.map +1 -1
  66. package/src/node/createBundles.js +12 -3
  67. package/src/node/fs-stream.d.ts +1 -1
  68. package/src/node/fs-stream.d.ts.map +1 -1
  69. package/src/node/fs-stream.js +42 -30
  70. package/src/node/shutdown.d.ts.map +1 -1
  71. package/src/node/shutdown.js +0 -1
  72. package/src/priority-senders.d.ts +1 -1
  73. package/src/priority-senders.d.ts.map +1 -1
  74. package/src/priority-senders.js +8 -5
  75. package/src/queue.d.ts +1 -1
  76. package/src/queue.d.ts.map +1 -1
  77. package/src/queue.js +7 -8
  78. package/src/scratch.d.ts +1 -1
  79. package/src/scratch.d.ts.map +1 -1
  80. package/src/ses-utils.d.ts +60 -0
  81. package/src/ses-utils.d.ts.map +1 -0
  82. package/src/ses-utils.js +346 -0
  83. package/src/storage-test-utils.d.ts +41 -84
  84. package/src/storage-test-utils.d.ts.map +1 -1
  85. package/src/storage-test-utils.js +169 -116
  86. package/src/tagged.d.ts +149 -0
  87. package/src/testing-utils.d.ts +2 -0
  88. package/src/testing-utils.d.ts.map +1 -1
  89. package/src/testing-utils.js +44 -5
  90. package/src/tokens.d.ts +34 -0
  91. package/src/tokens.d.ts.map +1 -0
  92. package/src/tokens.js +35 -0
  93. package/src/typeCheck.d.ts +9 -0
  94. package/src/typeCheck.d.ts.map +1 -0
  95. package/src/typeCheck.js +23 -0
  96. package/src/typeGuards.d.ts +2 -0
  97. package/src/typeGuards.d.ts.map +1 -1
  98. package/src/typeGuards.js +8 -0
  99. package/src/types-index.d.ts +1 -0
  100. package/src/types-index.js +2 -0
  101. package/src/types.d.ts +71 -18
  102. package/src/types.d.ts.map +1 -0
  103. package/src/types.ts +108 -0
  104. package/src/upgrade-api.d.ts +14 -4
  105. package/src/upgrade-api.d.ts.map +1 -1
  106. package/src/upgrade-api.js +50 -18
  107. package/CHANGELOG.md +0 -106
  108. package/src/utils.d.ts +0 -67
  109. package/src/utils.d.ts.map +0 -1
  110. package/src/utils.js +0 -451
@@ -1,2 +1,4 @@
1
1
  export function eventLoopIteration(): Promise<any>;
2
+ export function inspectMapStore(store: MapStore): object;
3
+ import type { MapStore } from '@agoric/store';
2
4
  //# sourceMappingURL=testing-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing-utils.d.ts","sourceRoot":"","sources":["testing-utils.js"],"names":[],"mappings":"AAWO,mDACwC"}
1
+ {"version":3,"file":"testing-utils.d.ts","sourceRoot":"","sources":["testing-utils.js"],"names":[],"mappings":"AAeO,mDACwC;AAgBxC,uCAHI,QAAQ,GACN,MAAM,CAqBlB;8BA7C2B,eAAe"}
@@ -1,14 +1,53 @@
1
- /** @file note this cannot be called test-utils.js due to https://github.com/Agoric/agoric-sdk/issues/7503 */
1
+ // @ts-check
2
+ /**
3
+ * @file note this cannot be called test-utils.js due to
4
+ * https://github.com/Agoric/agoric-sdk/issues/7503
5
+ */
2
6
  /* global setImmediate */
7
+ /** @import {MapStore} from '@agoric/store'; */
3
8
 
4
9
  /**
5
10
  * A workaround for some issues with fake time in tests.
6
11
  *
7
- * Lines of test code can depend on async promises outside the test
8
- * resolving before they run. Awaiting this function result ensures
9
- * that all promises that can do resolve.
10
- * Note that this doesn't mean all outstanding promises.
12
+ * Lines of test code can depend on async promises outside the test resolving
13
+ * before they run. Awaiting this function result ensures that all promises that
14
+ * can do resolve. Note that this doesn't mean all outstanding promises.
11
15
  */
12
16
  export const eventLoopIteration = async () =>
13
17
  new Promise(resolve => setImmediate(resolve));
14
18
  harden(eventLoopIteration);
19
+
20
+ /** @type {(value: any) => string} */
21
+ const stringOrTag = value => {
22
+ if (typeof value === 'string') {
23
+ return value;
24
+ } else if (typeof value === 'object' && Symbol.toStringTag in value) {
25
+ return value[Symbol.toStringTag];
26
+ }
27
+ return String(value);
28
+ };
29
+ /**
30
+ * @param {MapStore} store
31
+ * @returns {object} tree of the contents of the storeÂ
32
+ */
33
+ export const inspectMapStore = store => {
34
+ /** @type {Record<string, unknown>} */
35
+ const obj = {};
36
+ for (const key of store.keys()) {
37
+ const value = store.get(key);
38
+ const hasKeys = typeof value === 'object' && 'keys' in value;
39
+ const index = stringOrTag(key);
40
+ if (hasKeys && 'get' in value) {
41
+ obj[index] = inspectMapStore(value);
42
+ } else if (hasKeys) {
43
+ obj[index] = Array.from(value.keys());
44
+ } else {
45
+ obj[index] =
46
+ value instanceof Object && Symbol.toStringTag in value
47
+ ? value[Symbol.toStringTag]
48
+ : value;
49
+ }
50
+ }
51
+ return obj;
52
+ };
53
+ harden(inspectMapStore);
@@ -0,0 +1,34 @@
1
+ export namespace Stable {
2
+ export let symbol: "IST";
3
+ export let denom: "uist";
4
+ export let proposedName: "Agoric stable token";
5
+ export { NAT as assetKind };
6
+ export namespace displayInfo {
7
+ export let decimalPlaces: 6;
8
+ export { NAT as assetKind };
9
+ }
10
+ }
11
+ export namespace Stake {
12
+ let symbol_1: "BLD";
13
+ export { symbol_1 as symbol };
14
+ let denom_1: "ubld";
15
+ export { denom_1 as denom };
16
+ let proposedName_1: "Agoric staking token";
17
+ export { proposedName_1 as proposedName };
18
+ export { NAT as assetKind };
19
+ export namespace displayInfo_1 {
20
+ let decimalPlaces_1: 6;
21
+ export { decimalPlaces_1 as decimalPlaces };
22
+ export { NAT as assetKind };
23
+ }
24
+ export { displayInfo_1 as displayInfo };
25
+ }
26
+ export type TokenKeyword = "IST" | "BLD";
27
+ /** @typedef {'IST' | 'BLD'} TokenKeyword */
28
+ /**
29
+ * This is defined by ERTP. For dependency pragmatism it's repeated here. We
30
+ * rely on the static type check and unit tests to detect any incompatibility.
31
+ */
32
+ declare const NAT: "nat";
33
+ export {};
34
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["tokens.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;2BAEc,KAAK,GAAG,KAAK;AAA3B,4CAA4C;AAE5C;;;GAGG;AACH,yBAAkB"}
package/src/tokens.js ADDED
@@ -0,0 +1,35 @@
1
+ // @ts-check
2
+
3
+ /** @typedef {'IST' | 'BLD'} TokenKeyword */
4
+
5
+ /**
6
+ * This is defined by ERTP. For dependency pragmatism it's repeated here. We
7
+ * rely on the static type check and unit tests to detect any incompatibility.
8
+ */
9
+ const NAT = 'nat';
10
+
11
+ export const Stable = harden(
12
+ /** @type {const} */ ({
13
+ symbol: 'IST',
14
+ denom: 'uist',
15
+ proposedName: 'Agoric stable token',
16
+ assetKind: NAT,
17
+ displayInfo: {
18
+ decimalPlaces: 6,
19
+ assetKind: NAT,
20
+ },
21
+ }),
22
+ );
23
+
24
+ export const Stake = harden(
25
+ /** @type {const} */ ({
26
+ symbol: 'BLD',
27
+ denom: 'ubld',
28
+ proposedName: 'Agoric staking token',
29
+ assetKind: NAT,
30
+ displayInfo: {
31
+ decimalPlaces: 6,
32
+ assetKind: NAT,
33
+ },
34
+ }),
35
+ );
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @import {MustMatch, PatternType, TypedPattern} from './types.js';
3
+ */
4
+ /** @type {MustMatch} */
5
+ export const mustMatch: MustMatch;
6
+ export function cast<M>(specimen: unknown, patt: TypedPattern<M>): M;
7
+ import type { MustMatch } from './types.js';
8
+ import type { TypedPattern } from './types.js';
9
+ //# sourceMappingURL=typeCheck.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeCheck.d.ts","sourceRoot":"","sources":["typeCheck.js"],"names":[],"mappings":"AAGA;;GAEG;AAEH,wBAAwB;AACxB,wBADW,SAAS,CACuB;AAQpC,qBALM,CAAC,YACH,OAAO,QACP,aAAa,CAAC,CAAC,GACb,CAAC,CAQb;+BAlBsD,YAAY;kCAAZ,YAAY"}
@@ -0,0 +1,23 @@
1
+ // @ts-check
2
+ import { mustMatch as typelessMustMatch } from '@endo/patterns';
3
+
4
+ /**
5
+ * @import {MustMatch, PatternType, TypedPattern} from './types.js';
6
+ */
7
+
8
+ /** @type {MustMatch} */
9
+ export const mustMatch = typelessMustMatch;
10
+
11
+ /**
12
+ * @template M
13
+ * @param {unknown} specimen
14
+ * @param {TypedPattern<M>} patt
15
+ * @returns {M}
16
+ */
17
+ export const cast = (specimen, patt) => {
18
+ // mustMatch throws if they don't, which means that `cast` also narrows the
19
+ // type but a function can't both narrow and return a type. That is by design:
20
+ // https://github.com/microsoft/TypeScript/issues/34636#issuecomment-545025916
21
+ mustMatch(specimen, patt);
22
+ return specimen;
23
+ };
@@ -1,2 +1,4 @@
1
1
  export const StorageNodeShape: import("@endo/patterns").Matcher;
2
+ /** To be used only for 'helper' facets where the calls are from trusted code. */
3
+ export const UnguardedHelperI: import("@endo/patterns").InterfaceGuard<any>;
2
4
  //# sourceMappingURL=typeGuards.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA,gEAA2D"}
1
+ {"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA,gEAA2D;AAE3D,iFAAiF;AACjF,4EAKE"}
package/src/typeGuards.js CHANGED
@@ -3,3 +3,11 @@
3
3
  import { M } from '@endo/patterns';
4
4
 
5
5
  export const StorageNodeShape = M.remotable('StorageNode');
6
+
7
+ /** To be used only for 'helper' facets where the calls are from trusted code. */
8
+ export const UnguardedHelperI = M.interface(
9
+ 'helper',
10
+ {},
11
+ // not exposed so sloppy okay
12
+ { sloppy: true },
13
+ );
@@ -0,0 +1 @@
1
+ export type * from './types.js';
@@ -0,0 +1,2 @@
1
+ // Empty JS file to correspond with its .d.ts twin
2
+ export {};
package/src/types.d.ts CHANGED
@@ -1,20 +1,73 @@
1
- /* eslint-disable max-classes-per-file */
2
- export declare class Callback<I extends (...args: unknown[]) => any> {
3
- private iface: I;
4
-
5
- public target: any;
6
-
7
- public methodName?: PropertyKey;
8
-
9
- public bound: unknown[];
10
-
11
- public isSync: boolean;
1
+ import type { ERef, RemotableBrand } from '@endo/eventual-send';
2
+ import type { Primitive } from '@endo/pass-style';
3
+ import type { Pattern } from '@endo/patterns';
4
+ import type { Callable } from './ses-utils.js';
5
+ /**
6
+ * A map corresponding with a total function such that `get(key)` is assumed to
7
+ * always succeed.
8
+ */
9
+ export type TotalMap<K, V> = Omit<Map<K, V>, 'get'> & {
10
+ /** Returns the element associated with the specified key in the TotalMap. */
11
+ get: (key: K) => V;
12
+ };
13
+ export type TotalMapFrom<M extends Map<any, any>> = M extends Map<infer K, infer V> ? TotalMap<K, V> : never;
14
+ export declare class Callback<I extends (...args: any[]) => any> {
15
+ private iface;
16
+ target: any;
17
+ methodName?: PropertyKey;
18
+ bound: unknown[];
19
+ isSync: boolean;
12
20
  }
13
-
14
- export declare class SyncCallback<
15
- I extends (...args: unknown[]) => any,
16
- > extends Callback<I> {
17
- private syncIface: I;
18
-
19
- public isSync: true;
21
+ export declare class SyncCallback<I extends (...args: unknown[]) => any> extends Callback<I> {
22
+ private syncIface;
23
+ isSync: true;
20
24
  }
25
+ /**
26
+ Returns a boolean for whether the given type is primitive value or primitive type.
27
+
28
+ @example
29
+ ```
30
+ IsPrimitive<'string'>
31
+ //=> true
32
+
33
+ IsPrimitive<string>
34
+ //=> true
35
+
36
+ IsPrimitive<Object>
37
+ //=> false
38
+ ```
39
+ */
40
+ export type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
41
+ /** Recursively extract the non-callable properties of T */
42
+ export type DataOnly<T> = IsPrimitive<T> extends true ? T : T extends Callable ? never : {
43
+ [P in keyof T as T[P] extends Callable ? never : P]: DataOnly<T[P]>;
44
+ };
45
+ /**
46
+ * A type that doesn't assume its parameter is local, but is satisfied with both
47
+ * local and remote references. It accepts both near and marshalled references
48
+ * that were returned from `Remotable` or `Far`.
49
+ */
50
+ export type Remote<Primary, Local = DataOnly<Primary>> = Primary | RemotableBrand<Local, Primary>;
51
+ /**
52
+ * Potentially remote promises or settled references.
53
+ */
54
+ export type FarRef<Primary, Local = DataOnly<Primary>> = ERef<Remote<Primary, Local>>;
55
+ declare const validatedType: unique symbol;
56
+ /**
57
+ * Tag a pattern with the static type it represents.
58
+ */
59
+ export type TypedPattern<T> = Pattern & {
60
+ [validatedType]?: T;
61
+ };
62
+ export declare type PatternType<TM extends TypedPattern<any>> = TM extends TypedPattern<infer T> ? T : never;
63
+ /**
64
+ * Returning normally indicates success. Match failure is indicated by
65
+ * throwing.
66
+ *
67
+ * Note: remotables can only be matched as "remotable", not the specific kind.
68
+ *
69
+ * @see {import('@endo/patterns').mustMatch} for the implementation. This one has a type annotation to narrow if the pattern is a TypedPattern.
70
+ */
71
+ export declare type MustMatch = <P extends Pattern>(specimen: unknown, pattern: P, label?: string | number) => asserts specimen is P extends TypedPattern<any> ?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AC,SAAS,OAAO,EAChD,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,CAAC,EACV,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,KACpB,OAAO,CAAC,QAAQ,IAAI,CAAC,SAAS,YAAY,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC"}
package/src/types.ts ADDED
@@ -0,0 +1,108 @@
1
+ /* eslint-disable max-classes-per-file */
2
+ import type { ERef, RemotableBrand } from '@endo/eventual-send';
3
+ import type { Primitive } from '@endo/pass-style';
4
+ import type { Pattern } from '@endo/patterns';
5
+ import type { Callable } from './ses-utils.js';
6
+
7
+ /**
8
+ * A map corresponding with a total function such that `get(key)` is assumed to
9
+ * always succeed.
10
+ */
11
+ export type TotalMap<K, V> = Omit<Map<K, V>, 'get'> & {
12
+ /** Returns the element associated with the specified key in the TotalMap. */
13
+ get: (key: K) => V;
14
+ };
15
+ export type TotalMapFrom<M extends Map<any, any>> =
16
+ M extends Map<infer K, infer V> ? TotalMap<K, V> : never;
17
+
18
+ export declare class Callback<I extends (...args: any[]) => any> {
19
+ private iface: I;
20
+
21
+ public target: any;
22
+
23
+ public methodName?: PropertyKey;
24
+
25
+ public bound: unknown[];
26
+
27
+ public isSync: boolean;
28
+ }
29
+
30
+ export declare class SyncCallback<
31
+ I extends (...args: unknown[]) => any,
32
+ > extends Callback<I> {
33
+ private syncIface: I;
34
+
35
+ public isSync: true;
36
+ }
37
+
38
+ /**
39
+ Returns a boolean for whether the given type is primitive value or primitive type.
40
+
41
+ @example
42
+ ```
43
+ IsPrimitive<'string'>
44
+ //=> true
45
+
46
+ IsPrimitive<string>
47
+ //=> true
48
+
49
+ IsPrimitive<Object>
50
+ //=> false
51
+ ```
52
+ */
53
+ export type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
54
+
55
+ /** Recursively extract the non-callable properties of T */
56
+ export type DataOnly<T> =
57
+ IsPrimitive<T> extends true
58
+ ? T
59
+ : T extends Callable
60
+ ? never
61
+ : { [P in keyof T as T[P] extends Callable ? never : P]: DataOnly<T[P]> };
62
+
63
+ /**
64
+ * A type that doesn't assume its parameter is local, but is satisfied with both
65
+ * local and remote references. It accepts both near and marshalled references
66
+ * that were returned from `Remotable` or `Far`.
67
+ */
68
+ export type Remote<Primary, Local = DataOnly<Primary>> =
69
+ | Primary
70
+ | RemotableBrand<Local, Primary>;
71
+
72
+ // TODO: Add type tests for FarRef and Remote.
73
+ /**
74
+ * Potentially remote promises or settled references.
75
+ */
76
+ export type FarRef<Primary, Local = DataOnly<Primary>> = ERef<
77
+ Remote<Primary, Local>
78
+ >;
79
+
80
+ /*
81
+ * Stop-gap until https://github.com/Agoric/agoric-sdk/issues/6160
82
+ * explictly specify the type that the Pattern will verify through a match.
83
+ *
84
+ * TODO move all this pattern typing stuff to @endo/patterns
85
+ */
86
+ declare const validatedType: unique symbol;
87
+ /**
88
+ * Tag a pattern with the static type it represents.
89
+ */
90
+ export type TypedPattern<T> = Pattern & { [validatedType]?: T };
91
+
92
+ export declare type PatternType<TM extends TypedPattern<any>> =
93
+ TM extends TypedPattern<infer T> ? T : never;
94
+
95
+ // TODO make Endo's mustMatch do this
96
+ /**
97
+ * Returning normally indicates success. Match failure is indicated by
98
+ * throwing.
99
+ *
100
+ * Note: remotables can only be matched as "remotable", not the specific kind.
101
+ *
102
+ * @see {import('@endo/patterns').mustMatch} for the implementation. This one has a type annotation to narrow if the pattern is a TypedPattern.
103
+ */
104
+ export declare type MustMatch = <P extends Pattern>(
105
+ specimen: unknown,
106
+ pattern: P,
107
+ label?: string | number,
108
+ ) => asserts specimen is P extends TypedPattern<any> ? PatternType<P> : unknown;
@@ -1,7 +1,17 @@
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
+ export function isAbandonedError(reason: any): reason is Error;
9
+ /**
10
+ * An Error-like object for use as the rejection reason of promises abandoned by
11
+ * upgrade.
12
+ */
13
+ export type UpgradeDisconnection = {
14
+ name: "vatUpgraded";
5
15
  upgradeMessage: string;
6
16
  incarnationNumber: number;
7
17
  };
@@ -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,GAGD,MAAM,IAAI,oBAAoB,CAKC;AAgBrC,yCAHI,GAAG,GACD,MAAM,IAAI,KAAK,CAQS;;;;;mCA5DxB;IACR,IAAI,EAAE,aAAa,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;CAC3B"}
@@ -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 abandoned by
10
+ * 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,36 @@ 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 If `reason` is not frozen, it cannot be an
43
+ * UpgradeDisconnection, so returns false without even checking against the
44
+ * 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
+ reason != null && // eslint-disable-line eqeqeq
49
+ isFrozen(reason) &&
50
+ matches(reason, UpgradeDisconnectionShape);
41
51
  harden(isUpgradeDisconnection);
52
+
53
+ /**
54
+ * Returns whether a reason is a 'vat terminated' error generated when an object
55
+ * is abandoned by a vat during an upgrade.
56
+ *
57
+ * Normally we do not want to rely on the `message` of an error object, but this
58
+ * is a pragmatic solution to the current state of vat upgrade errors. In the
59
+ * future we'd prefer having an error with a cause referencing a disconnection
60
+ * object like for promise rejections. See
61
+ * https://github.com/Agoric/agoric-sdk/issues/9582
62
+ *
63
+ * @param {any} reason
64
+ * @returns {reason is Error}
65
+ */
66
+ export const isAbandonedError = reason =>
67
+ reason != null && // eslint-disable-line eqeqeq
68
+ isFrozen(reason) &&
69
+ matches(reason, M.error()) &&
70
+ // We're not using a constant here since this special value is already
71
+ // sprinkled throughout the SDK
72
+ reason.message === 'vat terminated';
73
+ harden(isAbandonedError);
package/CHANGELOG.md DELETED
@@ -1,106 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ### [0.3.3-u11.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.3.2...@agoric/internal@0.3.3-u11.0) (2023-08-24)
7
-
8
- **Note:** Version bump only for package @agoric/internal
9
-
10
-
11
-
12
-
13
-
14
- ### [0.3.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.3.1...@agoric/internal@0.3.2) (2023-06-02)
15
-
16
- **Note:** Version bump only for package @agoric/internal
17
-
18
-
19
-
20
-
21
-
22
- ### [0.3.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.3.0...@agoric/internal@0.3.1) (2023-05-24)
23
-
24
- **Note:** Version bump only for package @agoric/internal
25
-
26
-
27
-
28
-
29
-
30
- ## [0.3.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.2.1...@agoric/internal@0.3.0) (2023-05-19)
31
-
32
-
33
- ### ⚠ BREAKING CHANGES
34
-
35
- * emit smallcaps-format data in all marshallers
36
-
37
- ### Features
38
-
39
- * Add SwingSet configuration to purge vstorage within (re-)bootstrap ([f248e91](https://github.com/Agoric/agoric-sdk/commit/f248e9116512374fb95f789b26e27b66cd5c34ca)), closes [#7681](https://github.com/Agoric/agoric-sdk/issues/7681)
40
- * **auction:** add an auctioneer to manage vault liquidation ([#7000](https://github.com/Agoric/agoric-sdk/issues/7000)) ([398b70f](https://github.com/Agoric/agoric-sdk/commit/398b70f7e028f957afc1582f0ee31eb2574c94d0)), closes [#6992](https://github.com/Agoric/agoric-sdk/issues/6992) [#7047](https://github.com/Agoric/agoric-sdk/issues/7047) [#7074](https://github.com/Agoric/agoric-sdk/issues/7074)
41
- * **casting:** handle noData value encoding ([530bc41](https://github.com/Agoric/agoric-sdk/commit/530bc41854cc7f5e5749e97e87fabc6163a17864))
42
- * **cosmic-swingset:** add after-commit action ([970a53f](https://github.com/Agoric/agoric-sdk/commit/970a53f827ded21b27525f6b0042bbc124c62d48))
43
- * **internal:** makeFakeStorageKit supports "get" and "entries" ([6a69aab](https://github.com/Agoric/agoric-sdk/commit/6a69aab5cb54faae5af631bbc2281e4fc4ede8e0))
44
- * **internal:** new `prepareAttenuator` leveraging callbacks ([55599df](https://github.com/Agoric/agoric-sdk/commit/55599dfe7ec43a27387ca64e8bae57be13a38115))
45
- * emit smallcaps-format data in all marshallers ([1753df8](https://github.com/Agoric/agoric-sdk/commit/1753df83465785b5ee71b250770c9b012d750ffc)), closes [#6822](https://github.com/Agoric/agoric-sdk/issues/6822)
46
- * **core:** HighPrioritySendersManager ([7b382e4](https://github.com/Agoric/agoric-sdk/commit/7b382e49a1521d367c5b8db18fa7efa2b77ef7e3))
47
- * **cosmic-swingset:** basic snapshot wiring ([b1072d8](https://github.com/Agoric/agoric-sdk/commit/b1072d8b1ddabbb5f2835eb503c945fed3b6b080))
48
- * **cosmic-swingset:** export swingStore kvData to vstorage ([be68431](https://github.com/Agoric/agoric-sdk/commit/be684315dc68ecf0cb603a8eb38ddd5418e996a6))
49
- * **cosmic-swingset:** process highPriorityQueue actions ([182a96e](https://github.com/Agoric/agoric-sdk/commit/182a96e169c8cac7f31fbce014783fd6db72b64c))
50
- * **cosmic-swingset:** remove unnecessary explicit activityhash ([5dcc44d](https://github.com/Agoric/agoric-sdk/commit/5dcc44d31be0c8a95a5749d768791fa35b72dbd3))
51
- * **internal:** add BufferLineTransform ([6e7db7a](https://github.com/Agoric/agoric-sdk/commit/6e7db7af7d93500caf71d817afbb358d33ef01f6))
52
- * **internal:** add sync tee util ([#7560](https://github.com/Agoric/agoric-sdk/issues/7560)) ([0f800a6](https://github.com/Agoric/agoric-sdk/commit/0f800a622b81c61101d96b0ad620ab3065f4b146))
53
- * **internal:** build `chainStorage` from `zone` ([74c62da](https://github.com/Agoric/agoric-sdk/commit/74c62dae7964b488bfdf7c7ee8a9bd930074cea8))
54
- * **internal:** iterable produces values and can be async ([cf4110f](https://github.com/Agoric/agoric-sdk/commit/cf4110f59c228e42e09254b271209a66b9faf3e0))
55
- * **internal:** new `callback` module for durable classless callbacks ([b94d600](https://github.com/Agoric/agoric-sdk/commit/b94d60052e1043fd6fb1ce39530a6072e38ef0d9))
56
- * **internal:** shutdown informs of interrupt signal ([2ce1e89](https://github.com/Agoric/agoric-sdk/commit/2ce1e892eb381a28c31805f48ba65511896ef406))
57
- * assertAllDefined ([d4d6cbd](https://github.com/Agoric/agoric-sdk/commit/d4d6cbd798eee051a8a699c85cc620c6a8298258))
58
- * board-utils ([4f80ad3](https://github.com/Agoric/agoric-sdk/commit/4f80ad3cac3e47a89834f7f98330a47141b6e235))
59
- * type assertion for assertAllDefined ([afa7b5b](https://github.com/Agoric/agoric-sdk/commit/afa7b5bfaf4558a38bdba2c44bf91691f6db26b8))
60
- * **store:** M.splitArray and M.splitRecord ([#6597](https://github.com/Agoric/agoric-sdk/issues/6597)) ([e7427e3](https://github.com/Agoric/agoric-sdk/commit/e7427e386bcbfbe99312b41342b1fa2e722c57c7))
61
- * **vats:** harmonise core/boot.js and boot-psm.js ([4f6635e](https://github.com/Agoric/agoric-sdk/commit/4f6635e550b926d3ca43d9075f26fef3b810817d))
62
-
63
-
64
- ### Bug Fixes
65
-
66
- * **internal:** add typing to makeWithQueue ([5b1539b](https://github.com/Agoric/agoric-sdk/commit/5b1539bfc61ea4f937e2f85cbe93c7bccfc84a40))
67
- * **internal:** Make makeFakeStorageKit value auto-wrapping depend upon `sequence: true` ([2751e76](https://github.com/Agoric/agoric-sdk/commit/2751e7626e0ca617cdb2b1d92e5d4d9315b5674a))
68
- * **internal:** more callback typing ([e78e14d](https://github.com/Agoric/agoric-sdk/commit/e78e14d60a78d2e5f9fb9a899053bf778bb51360))
69
- * **internal:** properly inherit from `chainStorageNode` ([134a977](https://github.com/Agoric/agoric-sdk/commit/134a977f7bc4a2fc6eff3868d4d415c8c9714b4b))
70
- * **internal:** Restore support for passable-symbol method keys ([54271af](https://github.com/Agoric/agoric-sdk/commit/54271af10adb144fe6d562193afa473d74425854))
71
- * **internal:** shutdown beforeExit avoids forced exit ([34c9f44](https://github.com/Agoric/agoric-sdk/commit/34c9f442f124cd7181b538cf8754c6180c863b32))
72
- * **internal:** Validate Callback targets ([8880ada](https://github.com/Agoric/agoric-sdk/commit/8880ada791d70dd487770e8a0fa4b6b725aa8769))
73
- * **notifier:** Add a makeDurablePublishKit "onAdvance" option ([4c62b52](https://github.com/Agoric/agoric-sdk/commit/4c62b52b94cbc9ccb3c7388f5e94589809e6d7fd)), closes [#7303](https://github.com/Agoric/agoric-sdk/issues/7303)
74
- * adapt to deeplyFulfilled being async ([#6816](https://github.com/Agoric/agoric-sdk/issues/6816)) ([ec315e1](https://github.com/Agoric/agoric-sdk/commit/ec315e1634f6d5cdef1cddafc18777de7c04fecc))
75
- * **telemetry:** partially undo [#6684](https://github.com/Agoric/agoric-sdk/issues/6684) ([b9fa85b](https://github.com/Agoric/agoric-sdk/commit/b9fa85b7307124e50cc3a84d3b694307cde55f54))
76
- * avoid using top-level `require` ([57ca2db](https://github.com/Agoric/agoric-sdk/commit/57ca2dbfbadb373f97d43b2fb4e90302c9149976))
77
- * **types:** type assertion for assertAllDefined ([25f16b2](https://github.com/Agoric/agoric-sdk/commit/25f16b2e935931b81313d2ee1d491b305088bb7a))
78
- * track endo 1382 fix to 6570 ([#6612](https://github.com/Agoric/agoric-sdk/issues/6612)) ([7897761](https://github.com/Agoric/agoric-sdk/commit/7897761d6e19e6bbba42e7bd0bd5befb507afa08))
79
-
80
-
81
-
82
- ### [0.2.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.2.0...@agoric/internal@0.2.1) (2022-10-05)
83
-
84
-
85
- ### Bug Fixes
86
-
87
- * protect zoe from keyword collision ([#6370](https://github.com/Agoric/agoric-sdk/issues/6370)) ([02af4a0](https://github.com/Agoric/agoric-sdk/commit/02af4a07ad1f99b545d0bf525bd1ea97d74639d1))
88
-
89
-
90
-
91
- ## 0.2.0 (2022-09-20)
92
-
93
-
94
- ### ⚠ BREAKING CHANGES
95
-
96
- * **SwingSet:** Representatives inherit bound methods (#5970)
97
-
98
- ### Features
99
-
100
- * **internal:** add async utils from loadgen ([5d9f411](https://github.com/Agoric/agoric-sdk/commit/5d9f411a124e4028cd88764084999fb1fd791609))
101
- * **internal:** deeplyFulfilledObject ([11fd071](https://github.com/Agoric/agoric-sdk/commit/11fd071005741719286ae6a1bb6bb9a7fd1f65b7))
102
-
103
-
104
- ### Bug Fixes
105
-
106
- * **SwingSet:** Representatives inherit bound methods ([#5970](https://github.com/Agoric/agoric-sdk/issues/5970)) ([ba1ed62](https://github.com/Agoric/agoric-sdk/commit/ba1ed62062a63862e2eecb598b0bd1d2ac828e1f))