@agoric/internal 0.3.3-other-dev-8f8782b.0 → 0.3.3-other-dev-fbe72e7.0.fbe72e7

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 (131) hide show
  1. package/README.md +7 -2
  2. package/exported.js +2 -0
  3. package/package.json +41 -19
  4. package/src/action-types.d.ts +51 -5
  5. package/src/action-types.d.ts.map +1 -1
  6. package/src/action-types.js +74 -15
  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 +24 -17
  11. package/src/callback.d.ts.map +1 -1
  12. package/src/callback.js +55 -61
  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 +27 -0
  17. package/src/chain-utils.d.ts.map +1 -0
  18. package/src/chain-utils.js +62 -0
  19. package/src/cli-utils.d.ts +2 -0
  20. package/src/cli-utils.d.ts.map +1 -0
  21. package/src/cli-utils.js +21 -0
  22. package/src/config.d.ts +22 -12
  23. package/src/config.d.ts.map +1 -1
  24. package/src/config.js +23 -10
  25. package/src/debug.d.ts +1 -1
  26. package/src/errors.d.ts +2 -0
  27. package/src/errors.d.ts.map +1 -0
  28. package/src/errors.js +16 -0
  29. package/src/hex.d.ts +15 -0
  30. package/src/hex.d.ts.map +1 -0
  31. package/src/hex.js +105 -0
  32. package/src/index.d.ts +10 -1
  33. package/src/index.js +13 -2
  34. package/src/install-ses-debug.d.ts +2 -0
  35. package/src/install-ses-debug.d.ts.map +1 -0
  36. package/src/install-ses-debug.js +6 -0
  37. package/src/js-utils.d.ts +40 -0
  38. package/src/js-utils.d.ts.map +1 -0
  39. package/src/js-utils.js +237 -0
  40. package/src/lib-chainStorage.d.ts +59 -67
  41. package/src/lib-chainStorage.d.ts.map +1 -1
  42. package/src/lib-chainStorage.js +95 -92
  43. package/src/lib-nodejs/ava-unhandled-rejection.d.ts +13 -0
  44. package/src/lib-nodejs/ava-unhandled-rejection.d.ts.map +1 -0
  45. package/src/lib-nodejs/ava-unhandled-rejection.js +66 -0
  46. package/src/lib-nodejs/engine-gc.d.ts +3 -0
  47. package/src/lib-nodejs/engine-gc.d.ts.map +1 -0
  48. package/src/lib-nodejs/engine-gc.js +22 -0
  49. package/src/lib-nodejs/gc-and-finalize.d.ts +2 -0
  50. package/src/lib-nodejs/gc-and-finalize.d.ts.map +1 -0
  51. package/src/lib-nodejs/gc-and-finalize.js +91 -0
  52. package/src/lib-nodejs/spawnSubprocessWorker.d.ts +15 -0
  53. package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -0
  54. package/src/lib-nodejs/spawnSubprocessWorker.js +89 -0
  55. package/src/lib-nodejs/waitUntilQuiescent.d.ts +2 -0
  56. package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -0
  57. package/src/lib-nodejs/waitUntilQuiescent.js +18 -0
  58. package/src/lib-nodejs/worker-protocol.d.ts +4 -0
  59. package/src/lib-nodejs/worker-protocol.d.ts.map +1 -0
  60. package/src/lib-nodejs/worker-protocol.js +54 -0
  61. package/src/magic-cookie-test-only.js +2 -2
  62. package/src/marshal.d.ts +33 -0
  63. package/src/marshal.d.ts.map +1 -0
  64. package/src/marshal.js +156 -0
  65. package/src/method-tools.d.ts +1 -0
  66. package/src/method-tools.d.ts.map +1 -1
  67. package/src/method-tools.js +33 -62
  68. package/src/metrics.d.ts +183 -0
  69. package/src/metrics.d.ts.map +1 -0
  70. package/src/metrics.js +476 -0
  71. package/src/module-utils.d.ts +2 -0
  72. package/src/module-utils.d.ts.map +1 -0
  73. package/src/module-utils.js +27 -0
  74. package/src/natural-sort.d.ts +2 -0
  75. package/src/natural-sort.d.ts.map +1 -0
  76. package/src/natural-sort.js +48 -0
  77. package/src/netstring.d.ts +24 -0
  78. package/src/netstring.d.ts.map +1 -0
  79. package/src/netstring.js +125 -0
  80. package/src/node/buffer-line-transform.d.ts +20 -16
  81. package/src/node/buffer-line-transform.d.ts.map +1 -1
  82. package/src/node/buffer-line-transform.js +12 -9
  83. package/src/node/createBundles.d.ts.map +1 -1
  84. package/src/node/createBundles.js +12 -3
  85. package/src/node/fs-stream.d.ts +1 -1
  86. package/src/node/fs-stream.d.ts.map +1 -1
  87. package/src/node/fs-stream.js +48 -37
  88. package/src/node/shutdown.d.ts.map +1 -1
  89. package/src/node/shutdown.js +0 -1
  90. package/src/priority-senders.d.ts +2 -1
  91. package/src/priority-senders.d.ts.map +1 -1
  92. package/src/priority-senders.js +10 -4
  93. package/src/queue.d.ts +1 -1
  94. package/src/queue.d.ts.map +1 -1
  95. package/src/queue.js +7 -8
  96. package/src/scratch.d.ts +1 -1
  97. package/src/scratch.d.ts.map +1 -1
  98. package/src/ses-utils.d.ts +68 -0
  99. package/src/ses-utils.d.ts.map +1 -0
  100. package/src/ses-utils.js +422 -0
  101. package/src/storage-test-utils.d.ts +49 -84
  102. package/src/storage-test-utils.d.ts.map +1 -1
  103. package/src/storage-test-utils.js +234 -116
  104. package/src/tagged.d.ts +152 -0
  105. package/src/testing-utils.d.ts +2 -0
  106. package/src/testing-utils.d.ts.map +1 -1
  107. package/src/testing-utils.js +44 -5
  108. package/src/tmpDir.d.ts +2 -0
  109. package/src/tmpDir.d.ts.map +1 -0
  110. package/src/tmpDir.js +17 -0
  111. package/src/tokens.d.ts +34 -0
  112. package/src/tokens.d.ts.map +1 -0
  113. package/src/tokens.js +35 -0
  114. package/src/typeCheck.d.ts +9 -0
  115. package/src/typeCheck.d.ts.map +1 -0
  116. package/src/typeCheck.js +23 -0
  117. package/src/typeGuards.d.ts +17 -0
  118. package/src/typeGuards.d.ts.map +1 -1
  119. package/src/typeGuards.js +20 -0
  120. package/src/types-index.d.ts +1 -0
  121. package/src/types-index.js +2 -0
  122. package/src/types.d.ts +83 -18
  123. package/src/types.d.ts.map +1 -0
  124. package/src/types.ts +129 -0
  125. package/src/upgrade-api.d.ts +14 -4
  126. package/src/upgrade-api.d.ts.map +1 -1
  127. package/src/upgrade-api.js +50 -18
  128. package/CHANGELOG.md +0 -106
  129. package/src/utils.d.ts +0 -67
  130. package/src/utils.d.ts.map +0 -1
  131. package/src/utils.js +0 -451
package/src/tmpDir.js ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Create a `tmpDir` function that synchronously creates a temporary directory
3
+ * and a function for deleting it along with any added contents.
4
+ *
5
+ * @param {Pick<import('tmp'), 'dirSync'>} tmp
6
+ */
7
+ export const makeTempDirFactory = tmp => {
8
+ /** @type {(prefix?: string) => [dirName: string, cleanup: () => void]} */
9
+ const tmpDir = prefix => {
10
+ const { name, removeCallback } = tmp.dirSync({
11
+ prefix,
12
+ unsafeCleanup: true,
13
+ });
14
+ return [name, removeCallback];
15
+ };
16
+ return tmpDir;
17
+ };
@@ -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,mBAAY,KAAK,CAAC"}
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,19 @@
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>;
4
+ /**
5
+ * @typedef {number | `${bigint}`} BridgeBigInt Ensure that callees passed a
6
+ * bridge message that was serialised from a Golang int64 or uint64 accept
7
+ * either a JS number or a stringified JS bigint.
8
+ */
9
+ /**
10
+ * @type {import('./types.js').TypedPattern<BridgeBigInt>}
11
+ */
12
+ export const BridgeBigIntShape: import("./types.js").TypedPattern<BridgeBigInt>;
13
+ /**
14
+ * Ensure that callees passed a
15
+ * bridge message that was serialised from a Golang int64 or uint64 accept
16
+ * either a JS number or a stringified JS bigint.
17
+ */
18
+ export type BridgeBigInt = number | `${bigint}`;
2
19
  //# 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":"AAKA,gEAA2D;AAE3D,iFAAiF;AACjF,4EAKE;AAEF;;;;GAIG;AAEH;;GAEG;AACH,gCAFU,OAAO,YAAY,EAAE,YAAY,CAAC,YAAY,CAAC,CAEK;;;;;;2BARjD,MAAM,GAAG,GAAG,MAAM,EAAE"}
package/src/typeGuards.js CHANGED
@@ -1,5 +1,25 @@
1
1
  // @jessie-check
2
+ // @ts-check
2
3
 
3
4
  import { M } from '@endo/patterns';
4
5
 
5
6
  export const StorageNodeShape = M.remotable('StorageNode');
7
+
8
+ /** To be used only for 'helper' facets where the calls are from trusted code. */
9
+ export const UnguardedHelperI = M.interface(
10
+ 'helper',
11
+ {},
12
+ // not exposed so sloppy okay
13
+ { sloppy: true },
14
+ );
15
+
16
+ /**
17
+ * @typedef {number | `${bigint}`} BridgeBigInt Ensure that callees passed a
18
+ * bridge message that was serialised from a Golang int64 or uint64 accept
19
+ * either a JS number or a stringified JS bigint.
20
+ */
21
+
22
+ /**
23
+ * @type {import('./types.js').TypedPattern<BridgeBigInt>}
24
+ */
25
+ export const BridgeBigIntShape = M.or(M.number(), M.string());
@@ -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,85 @@
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
+ /**
15
+ * A permit is either `true` or a string (both meaning no attenuation, with a
16
+ * string serving as a grouping label for convenience and/or diagram
17
+ * generation), or an object whose keys identify child properties and whose
18
+ * corresponding values are theirselves (recursive) Permits.
19
+ */
20
+ export type Permit<T> = true | string | Partial<{
21
+ [K in keyof T]: K extends string ? Permit<T[K]> : never;
22
+ }>;
23
+ export type Attenuated<T, P extends Permit<T>> = P extends object ? {
24
+ [K in keyof P]: K extends keyof T ? P[K] extends Permit<T[K]> ? Attenuated<T[K], P[K]> : never : never;
25
+ } : T;
26
+ export declare class Callback<I extends (...args: any[]) => any> {
27
+ private iface;
28
+ target: any;
29
+ methodName?: PropertyKey;
30
+ bound: unknown[];
31
+ isSync: boolean;
12
32
  }
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;
33
+ export declare class SyncCallback<I extends (...args: unknown[]) => any> extends Callback<I> {
34
+ private syncIface;
35
+ isSync: true;
20
36
  }
37
+ /**
38
+ Returns a boolean for whether the given type is primitive value or primitive type.
39
+
40
+ @example
41
+ ```
42
+ IsPrimitive<'string'>
43
+ //=> true
44
+
45
+ IsPrimitive<string>
46
+ //=> true
47
+
48
+ IsPrimitive<Object>
49
+ //=> false
50
+ ```
51
+ */
52
+ export type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
53
+ /** Recursively extract the non-callable properties of T */
54
+ export type DataOnly<T> = IsPrimitive<T> extends true ? T : T extends Callable ? never : {
55
+ [P in keyof T as T[P] extends Callable ? never : P]: DataOnly<T[P]>;
56
+ };
57
+ /**
58
+ * A type that doesn't assume its parameter is local, but is satisfied with both
59
+ * local and remote references. It accepts both near and marshalled references
60
+ * that were returned from `Remotable` or `Far`.
61
+ */
62
+ export type Remote<Primary, Local = DataOnly<Primary>> = Primary | RemotableBrand<Local, Primary>;
63
+ /**
64
+ * Potentially remote promises or settled references.
65
+ */
66
+ export type FarRef<Primary, Local = DataOnly<Primary>> = ERef<Remote<Primary, Local>>;
67
+ declare const validatedType: unique symbol;
68
+ /**
69
+ * Tag a pattern with the static type it represents.
70
+ */
71
+ export type TypedPattern<T> = Pattern & {
72
+ [validatedType]?: T;
73
+ };
74
+ export declare type PatternType<TM extends TypedPattern<any>> = TM extends TypedPattern<infer T> ? T : never;
75
+ /**
76
+ * Returning normally indicates success. Match failure is indicated by
77
+ * throwing.
78
+ *
79
+ * Note: remotables can only be matched as "remotable", not the specific kind.
80
+ *
81
+ * @see {import('@endo/patterns').mustMatch} for the implementation. This one has a type annotation to narrow if the pattern is a TypedPattern.
82
+ */
83
+ export declare type MustMatch = <P extends Pattern>(specimen: unknown, pattern: P, label?: string | number) => asserts specimen is P extends TypedPattern<any> ? PatternType<P> : unknown;
84
+ export {};
85
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG;IACpD,6EAA6E;IAC7E,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,IAC9C,CAAC,SAAS,GAAG,CAA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,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,129 @@
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
+ /**
19
+ * A permit is either `true` or a string (both meaning no attenuation, with a
20
+ * string serving as a grouping label for convenience and/or diagram
21
+ * generation), or an object whose keys identify child properties and whose
22
+ * corresponding values are theirselves (recursive) Permits.
23
+ */
24
+ export type Permit<T> =
25
+ | true
26
+ | string
27
+ | Partial<{ [K in keyof T]: K extends string ? Permit<T[K]> : never }>;
28
+
29
+ export type Attenuated<T, P extends Permit<T>> = P extends object
30
+ ? {
31
+ [K in keyof P]: K extends keyof T
32
+ ? P[K] extends Permit<T[K]>
33
+ ? Attenuated<T[K], P[K]>
34
+ : never
35
+ : never;
36
+ }
37
+ : T;
38
+
39
+ export declare class Callback<I extends (...args: any[]) => any> {
40
+ private iface: I;
41
+
42
+ public target: any;
43
+
44
+ public methodName?: PropertyKey;
45
+
46
+ public bound: unknown[];
47
+
48
+ public isSync: boolean;
49
+ }
50
+
51
+ export declare class SyncCallback<
52
+ I extends (...args: unknown[]) => any,
53
+ > extends Callback<I> {
54
+ private syncIface: I;
55
+
56
+ public isSync: true;
57
+ }
58
+
59
+ /**
60
+ Returns a boolean for whether the given type is primitive value or primitive type.
61
+
62
+ @example
63
+ ```
64
+ IsPrimitive<'string'>
65
+ //=> true
66
+
67
+ IsPrimitive<string>
68
+ //=> true
69
+
70
+ IsPrimitive<Object>
71
+ //=> false
72
+ ```
73
+ */
74
+ export type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
75
+
76
+ /** Recursively extract the non-callable properties of T */
77
+ export type DataOnly<T> =
78
+ IsPrimitive<T> extends true
79
+ ? T
80
+ : T extends Callable
81
+ ? never
82
+ : { [P in keyof T as T[P] extends Callable ? never : P]: DataOnly<T[P]> };
83
+
84
+ /**
85
+ * A type that doesn't assume its parameter is local, but is satisfied with both
86
+ * local and remote references. It accepts both near and marshalled references
87
+ * that were returned from `Remotable` or `Far`.
88
+ */
89
+ export type Remote<Primary, Local = DataOnly<Primary>> =
90
+ | Primary
91
+ | RemotableBrand<Local, Primary>;
92
+
93
+ // TODO: Add type tests for FarRef and Remote.
94
+ /**
95
+ * Potentially remote promises or settled references.
96
+ */
97
+ export type FarRef<Primary, Local = DataOnly<Primary>> = ERef<
98
+ Remote<Primary, Local>
99
+ >;
100
+
101
+ /*
102
+ * Stop-gap until https://github.com/Agoric/agoric-sdk/issues/6160
103
+ * explictly specify the type that the Pattern will verify through a match.
104
+ *
105
+ * TODO move all this pattern typing stuff to @endo/patterns
106
+ */
107
+ declare const validatedType: unique symbol;
108
+ /**
109
+ * Tag a pattern with the static type it represents.
110
+ */
111
+ export type TypedPattern<T> = Pattern & { [validatedType]?: T };
112
+
113
+ export declare type PatternType<TM extends TypedPattern<any>> =
114
+ TM extends TypedPattern<infer T> ? T : never;
115
+
116
+ // TODO make Endo's mustMatch do this
117
+ /**
118
+ * Returning normally indicates success. Match failure is indicated by
119
+ * throwing.
120
+ *
121
+ * Note: remotables can only be matched as "remotable", not the specific kind.
122
+ *
123
+ * @see {import('@endo/patterns').mustMatch} for the implementation. This one has a type annotation to narrow if the pattern is a TypedPattern.
124
+ */
125
+ export declare type MustMatch = <P extends Pattern>(
126
+ specimen: unknown,
127
+ pattern: P,
128
+ label?: string | number,
129
+ ) => 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))