@agoric/internal 0.3.3-u11wf.0 → 0.3.3-upgrade-16-dev-8879538.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 (77) hide show
  1. package/README.md +7 -2
  2. package/exported.js +2 -0
  3. package/package.json +32 -16
  4. package/src/batched-deliver.d.ts +6 -6
  5. package/src/batched-deliver.d.ts.map +1 -1
  6. package/src/batched-deliver.js +6 -3
  7. package/src/callback.d.ts +23 -16
  8. package/src/callback.d.ts.map +1 -1
  9. package/src/callback.js +19 -25
  10. package/src/config.d.ts +21 -12
  11. package/src/config.d.ts.map +1 -1
  12. package/src/config.js +10 -2
  13. package/src/debug.d.ts +1 -1
  14. package/src/index.d.ts +3 -0
  15. package/src/index.js +7 -1
  16. package/src/install-ses-debug.d.ts +2 -0
  17. package/src/install-ses-debug.d.ts.map +1 -0
  18. package/src/install-ses-debug.js +6 -0
  19. package/src/lib-chainStorage.d.ts +25 -45
  20. package/src/lib-chainStorage.d.ts.map +1 -1
  21. package/src/lib-chainStorage.js +16 -41
  22. package/src/lib-nodejs/engine-gc.d.ts +3 -0
  23. package/src/lib-nodejs/engine-gc.d.ts.map +1 -0
  24. package/src/lib-nodejs/engine-gc.js +22 -0
  25. package/src/lib-nodejs/gc-and-finalize.d.ts +2 -0
  26. package/src/lib-nodejs/gc-and-finalize.d.ts.map +1 -0
  27. package/src/lib-nodejs/gc-and-finalize.js +91 -0
  28. package/src/lib-nodejs/spawnSubprocessWorker.d.ts +15 -0
  29. package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -0
  30. package/src/lib-nodejs/spawnSubprocessWorker.js +87 -0
  31. package/src/lib-nodejs/waitUntilQuiescent.d.ts +2 -0
  32. package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -0
  33. package/src/lib-nodejs/waitUntilQuiescent.js +18 -0
  34. package/src/lib-nodejs/worker-protocol.d.ts +4 -0
  35. package/src/lib-nodejs/worker-protocol.d.ts.map +1 -0
  36. package/src/lib-nodejs/worker-protocol.js +56 -0
  37. package/src/marshal.d.ts +19 -0
  38. package/src/marshal.d.ts.map +1 -0
  39. package/src/marshal.js +132 -0
  40. package/src/method-tools.d.ts +1 -0
  41. package/src/method-tools.d.ts.map +1 -1
  42. package/src/method-tools.js +12 -0
  43. package/src/netstring.d.ts +25 -0
  44. package/src/netstring.d.ts.map +1 -0
  45. package/src/netstring.js +127 -0
  46. package/src/node/buffer-line-transform.d.ts +2 -3
  47. package/src/node/buffer-line-transform.d.ts.map +1 -1
  48. package/src/node/createBundles.d.ts.map +1 -1
  49. package/src/node/createBundles.js +9 -2
  50. package/src/node/fs-stream.d.ts.map +1 -1
  51. package/src/node/fs-stream.js +1 -2
  52. package/src/priority-senders.d.ts +1 -1
  53. package/src/priority-senders.d.ts.map +1 -1
  54. package/src/queue.d.ts +1 -1
  55. package/src/queue.d.ts.map +1 -1
  56. package/src/queue.js +5 -6
  57. package/src/scratch.d.ts +1 -1
  58. package/src/scratch.d.ts.map +1 -1
  59. package/src/storage-test-utils.d.ts +34 -77
  60. package/src/storage-test-utils.d.ts.map +1 -1
  61. package/src/storage-test-utils.js +24 -12
  62. package/src/tagged.d.ts +155 -0
  63. package/src/tokens.d.ts +34 -0
  64. package/src/tokens.d.ts.map +1 -0
  65. package/src/tokens.js +35 -0
  66. package/src/typeGuards.d.ts +2 -0
  67. package/src/typeGuards.d.ts.map +1 -1
  68. package/src/typeGuards.js +8 -0
  69. package/src/types.d.ts +37 -0
  70. package/src/types.js +2 -0
  71. package/src/upgrade-api.d.ts +13 -4
  72. package/src/upgrade-api.d.ts.map +1 -1
  73. package/src/upgrade-api.js +26 -18
  74. package/src/utils.d.ts +5 -13
  75. package/src/utils.d.ts.map +1 -1
  76. package/src/utils.js +9 -164
  77. package/CHANGELOG.md +0 -115
@@ -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
+ );
@@ -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
+ );
package/src/types.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  /* eslint-disable max-classes-per-file */
2
+ import type { Callable, RemotableBrand } from '@endo/eventual-send';
3
+ import type { Primitive } from '@endo/pass-style';
4
+
2
5
  export declare class Callback<I extends (...args: unknown[]) => any> {
3
6
  private iface: I;
4
7
 
@@ -18,3 +21,37 @@ export declare class SyncCallback<
18
21
 
19
22
  public isSync: true;
20
23
  }
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
+
42
+ /** Recursively extract the non-callable properties of T */
43
+ export type DataOnly<T> =
44
+ IsPrimitive<T> extends true
45
+ ? T
46
+ : T extends Callable
47
+ ? never
48
+ : { [P in keyof T as T[P] extends Callable ? never : P]: DataOnly<T[P]> };
49
+
50
+ /**
51
+ * A type that doesn't assume its parameter is local, but is satisfied with both
52
+ * local and remote references. It accepts both near and marshalled references
53
+ * that were returned from `Remotable` or `Far`.
54
+ */
55
+ export type Remote<Primary, Local = DataOnly<Primary>> =
56
+ | Primary
57
+ | RemotableBrand<Local, Primary>;
package/src/types.js ADDED
@@ -0,0 +1,2 @@
1
+ // Empty JS file to correspond with its .d.ts twin
2
+ export {};
@@ -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,GAGD,MAAM,IAAI,oBAAoB,CAGqB;;;;;mCApCnD;IACZ,IAAQ,EAAE,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);
package/src/utils.d.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  export const BASIS_POINTS: 10000n;
2
- export function fromUniqueEntries<K, V>(allEntries: Iterable<[K, V]>): {};
3
- export function objectMap<O extends Record<string, any>, R>(original: O, mapFn: (value: O[keyof O], key: keyof O) => R): { [P in keyof O]: R; };
4
- export function listDifference(leftNames: Array<string | symbol>, rightNames: Array<string | symbol>): (string | symbol)[];
5
- export function throwLabeled(innerErr: Error, label: string | number, ErrorConstructor?: ErrorConstructor | undefined): never;
6
- export function applyLabelingError<A, R>(func: (...args: A[]) => R, args: A[], label?: string | number | undefined): R;
2
+ /** @import { ERef } from '@endo/far' */
7
3
  /**
8
4
  * @template T
9
5
  * @typedef {{[KeyType in keyof T]: T[KeyType]} & {}} Simplify
@@ -30,18 +26,18 @@ export function applyLabelingError<A, R>(func: (...args: A[]) => R, args: A[], l
30
26
  * @type {<T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>}
31
27
  */
32
28
  export const deeplyFulfilledObject: <T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>;
33
- export function makeMeasureSeconds(currentTimeMillisec: typeof import('perf_hooks').performance.now): <T>(fn: () => Promise<T>) => Promise<{
29
+ export function makeMeasureSeconds(currentTimeMillisec: typeof import("perf_hooks").performance.now): <T>(fn: () => Promise<T>) => Promise<{
34
30
  result: T;
35
31
  duration: number;
36
32
  }>;
37
- export function makeAggregateError(errors: Error[], message?: string | undefined): Error;
38
33
  export function PromiseAllOrErrors<T>(items: readonly (T | PromiseLike<T>)[]): Promise<T[]>;
39
34
  /**
40
35
  * @type {<T>(
41
36
  * trier: () => Promise<T>,
42
37
  * finalizer: (error?: unknown) => Promise<void>,
43
38
  * ) => Promise<T>}
44
- */ export const aggregateTryFinally: <T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<void>) => Promise<T>;
39
+ */
40
+ export const aggregateTryFinally: <T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<void>) => Promise<T>;
45
41
  export function assertAllDefined<T extends Record<string, unknown>>(obj: T): asserts obj is AllDefined<T>;
46
42
  export const forever: AsyncIterable<undefined>;
47
43
  export function whileTrue<T>(produce: () => T): AsyncIterable<Awaited<T>>;
@@ -51,15 +47,11 @@ export const zip: <X, Y>(xs: X[], ys: Y[]) => [X, Y][];
51
47
  /** @type { <T extends Record<string, ERef<any>>>(obj: T) => Promise<{ [K in keyof T]: Awaited<T[K]>}> } */
52
48
  export const allValues: <T extends Record<string, any>>(obj: T) => Promise<{ [K in keyof T]: Awaited<T[K]>; }>;
53
49
  export function synchronizedTee<T = unknown>(sourceStream: AsyncIterator<T, void, void>, readerCount: number): AsyncGenerator<T, void, void>[];
54
- /**
55
- * <T>
56
- */
57
- export type ERef<T> = import('@endo/eventual-send').ERef<T>;
58
50
  /**
59
51
  * flatten the type output to improve type hints shown in editors
60
52
  * https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.ts
61
53
  */
62
- export type Simplify<T> = { [KeyType_1 in keyof T]: T[KeyType_1]; };
54
+ export type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
63
55
  export type Callable = (...args: any[]) => any;
64
56
  export type DeeplyAwaitedObject<T extends {}> = { [K in keyof T]: T[K] extends Callable ? T[K] : DeeplyAwaited<T[K]>; };
65
57
  export type DeeplyAwaited<T> = T extends PromiseLike<any> ? Awaited<T> : T extends {} ? Simplify<DeeplyAwaitedObject<T>> : Awaited<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAcA,kCAAoC;AAa7B,0EAcN;AA0CM,gJAIN;AAOM,0CAHI,MAAM,MAAM,GAAG,MAAM,CAAC,cACtB,MAAM,MAAM,GAAG,MAAM,CAAC,uBAKhC;AASM,uCALI,KAAK,SACL,MAAM,GAAC,MAAM,oDAEX,KAAK,CAYjB;AAUM,uHAyBN;AAGD;;;;;GAKG;AAEH;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;;;;GAOG;AACH,qGAGE;AAUK,wDAHI,cAAc,YAAY,EAAE,WAAW,CAAC,GAAG;;cACmB,MAAM;GAW9E;AAMM,2CAHI,KAAK,EAAE,uCAcjB;AAOM,4FAeN;AAED;;;;;GAKG,CAAC,mFAFoB,OAAO,KAAK,QAAQ,IAAI,CAAC,gBAY7C;AAiBG,0GAUN;AAQD,+CAAoD;AAU7C,0EAUH;AAUG,0EAaH;AAEJ,oDAAoD;AACpD,uDAAqE;AAErE,2GAA2G;AAC3G,+GAIE;AAWK,sGAFI,MAAM,mCA4FhB;;;;sBAlbyB,OAAO,qBAAqB,EAAE,IAAI,CAAC,CAAC,CAAC;;;;;;iCAkJxC,GAAG,EAAE,KAAK,GAAG;;+BAUvB,CAAC,SAAS,YAAY,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,SAAS,oBAAoB,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAYA,kCAAoC;AAEpC,wCAAwC;AAExC;;;;;GAKG;AAEH;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;;;;GAOG;AACH,oCAFU,CAAC,CAAC,SAAS,EAAE,EAAE,gBAAgB,EAA8B,CAAC,AAA5B,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAKxE;AAUK,wDAHI,cAAc,YAAY,EAAE,WAAW,CAAC,GAAG,GACzC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAWjF;AAOM,mCAFc,CAAC,SADX,SAAS,CACC,CAAC,AADA,GAAG,WAAW,CACf,CAAC,AADgB,CAAC,CAAC,EAAE,GAC7B,OAAO,CAAC,CAAC,EAAE,CAAC,CAiBxB;AAED;;;;;GAKG;AACH,kCALU,CAAC,CAAC,EACX,KAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,SAAY,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,KACzC,OAAO,CAAC,CAAC,CAAC,CAYd;AAgBG,iCAFgC,CAAC,uCAAD,CAAC,AAF5B,GAEC,OAAO,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAYxC;AAQD,+CAAoD;AAU7C,0BAF4B,CAAC,WAJzB,MAIwB,CAAC,AAJlB,GAIL,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAYlC;AAUG,0BAF4B,CAAC,WAJzB,MAIwB,CAAC,AAJlB,GAIL,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAelC;AAEJ,oDAAoD;AACpD,kBADY,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAoB,CAAC,AAAlB,EAAE,EAAE,EAAE,EAAc,CAAC,AAAZ,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CACqB;AAErE,2GAA2G;AAC3G,yBAD+F,CAAC,mCAAD,CAAC,AAAxC,KAAK,OAAO,CAAC,GAAG,CAAC,IAAI,MAAkB,CAAC,AAAZ,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAC,CAAC,CAKpG;AAWK,gCAHkB,CAAC,0BAAf,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,eAC5B,MAAM,mCA4FhB;;;;;qBArRmC,CAAC,IAAxB,GAAE,OAAO,IAAI,MAAU,CAAC,AAAJ,GAAG,CAAC,CAAC,OAAO,CAAC,GAAC,GAAG,EAAE;uBAMvC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;gCAKwC,CAAC,eAAhE,GAAG,CAAC,IAAI,MAAuD,CAAC,AAAjD,GAAgD,CAAC,AAA7C,CAA8C,CAAC,AAA7C,CAAC,SAAS,QAAQ,GAAwB,CAAC,AAArB,CAAsB,CAAC,AAArB,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAE;0BAK8B,CAAC,IAAD,CAAC,AAApG,SAAS,WAAW,CAAC,GAAG,CAAC,GAAG,OAAO,CAAgE,CAAC,AAA/D,CAAC,GAA6D,CAAC,AAA1D,SAAS,EAAE,GAAG,QAAQ,CAAC,mBAAmB,CAAe,CAAC,AAAd,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;uBA6E7E,CAAC,oCAA1B,GAAE,CAAC,IAAI,MAAkB,CAAC,AAAZ,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAE"}
package/src/utils.js CHANGED
@@ -1,156 +1,18 @@
1
1
  // @ts-check
2
2
  // @jessie-check
3
3
 
4
- import { E } from '@endo/far';
5
4
  import { deeplyFulfilled, isObject } from '@endo/marshal';
6
- import { isPromise, makePromiseKit } from '@endo/promise-kit';
5
+ import { makePromiseKit } from '@endo/promise-kit';
7
6
  import { makeQueue } from '@endo/stream';
8
- import { asyncGenerate, makeSet } from 'jessie.js';
7
+ import { asyncGenerate } from 'jessie.js';
9
8
 
10
- const { entries, fromEntries, keys, values } = Object;
11
- const { ownKeys } = Reflect;
9
+ const { fromEntries, keys, values } = Object;
12
10
 
13
- const { details: X, quote: q, Fail } = assert;
11
+ const { quote: q, Fail } = assert;
14
12
 
15
13
  export const BASIS_POINTS = 10_000n;
16
14
 
17
- /** @template T @typedef {import('@endo/eventual-send').ERef<T>} ERef<T> */
18
-
19
- /**
20
- * Throws if multiple entries use the same property name. Otherwise acts
21
- * like `Object.fromEntries` but hardens the result.
22
- * Use it to protect from property names computed from user-provided data.
23
- *
24
- * @template K,V
25
- * @param {Iterable<[K,V]>} allEntries
26
- * @returns {{[k: K]: V}}
27
- */
28
- export const fromUniqueEntries = allEntries => {
29
- const entriesArray = [...allEntries];
30
- const result = harden(fromEntries(entriesArray));
31
- if (ownKeys(result).length === entriesArray.length) {
32
- return result;
33
- }
34
- const names = makeSet();
35
- for (const [name, _] of entriesArray) {
36
- if (names.has(name)) {
37
- Fail`collision on property name ${q(name)}: ${entriesArray}`;
38
- }
39
- names.add(name);
40
- }
41
- throw Fail`internal: failed to create object from unique entries`;
42
- };
43
- harden(fromUniqueEntries);
44
-
45
- /**
46
- * By analogy with how `Array.prototype.map` will map the elements of
47
- * an array to transformed elements of an array of the same shape,
48
- * `objectMap` will do likewise for the string-named own enumerable
49
- * properties of an object.
50
- *
51
- * Typical usage applies `objectMap` to a CopyRecord, i.e.,
52
- * an object for which `passStyleOf(original) === 'copyRecord'`. For these,
53
- * none of the following edge cases arise. The result will be a CopyRecord
54
- * with exactly the same property names, whose values are the mapped form of
55
- * the original's values.
56
- *
57
- * When the original is not a CopyRecord, some edge cases to be aware of
58
- * * No matter how mutable the original object, the returned object is
59
- * hardened.
60
- * * Only the string-named enumerable own properties of the original
61
- * are mapped. All other properties are ignored.
62
- * * If any of the original properties were accessors, `Object.entries`
63
- * will cause its `getter` to be called and will use the resulting
64
- * value.
65
- * * No matter whether the original property was an accessor, writable,
66
- * or configurable, all the properties of the returned object will be
67
- * non-writable, non-configurable, data properties.
68
- * * No matter what the original object may have inherited from, and
69
- * no matter whether it was a special kind of object such as an array,
70
- * the returned object will always be a plain object inheriting directly
71
- * from `Object.prototype` and whose state is only these new mapped
72
- * own properties.
73
- *
74
- * With these differences, even if the original object was not a CopyRecord,
75
- * if all the mapped values are Passable, then the returned object will be
76
- * a CopyRecord.
77
- *
78
- * @template {Record<string, any>} O
79
- * @param {O} original
80
- * @template R map result
81
- * @param {(value: O[keyof O], key: keyof O) => R} mapFn
82
- * @returns {{ [P in keyof O]: R}}
83
- */
84
- export const objectMap = (original, mapFn) => {
85
- const ents = entries(original);
86
- const mapEnts = ents.map(([k, v]) => [k, mapFn(v, k)]);
87
- return harden(fromEntries(mapEnts));
88
- };
89
- harden(objectMap);
90
-
91
- /**
92
- * @param {Array<string | symbol>} leftNames
93
- * @param {Array<string | symbol>} rightNames
94
- */
95
- export const listDifference = (leftNames, rightNames) => {
96
- const rightSet = makeSet(rightNames);
97
- return leftNames.filter(name => !rightSet.has(name));
98
- };
99
- harden(listDifference);
100
-
101
- /**
102
- * @param {Error} innerErr
103
- * @param {string|number} label
104
- * @param {ErrorConstructor} [ErrorConstructor]
105
- * @returns {never}
106
- */
107
- export const throwLabeled = (innerErr, label, ErrorConstructor = undefined) => {
108
- if (typeof label === 'number') {
109
- label = `[${label}]`;
110
- }
111
- const outerErr = assert.error(
112
- `${label}: ${innerErr.message}`,
113
- ErrorConstructor,
114
- );
115
- assert.note(outerErr, X`Caused by ${innerErr}`);
116
- throw outerErr;
117
- };
118
- harden(throwLabeled);
119
-
120
- /**
121
- * @template A,R
122
- * @param {(...args: A[]) => R} func
123
- * @param {A[]} args
124
- * @param {string|number} [label]
125
- * @returns {R}
126
- */
127
- export const applyLabelingError = (func, args, label = undefined) => {
128
- if (label === undefined) {
129
- return func(...args);
130
- }
131
- let result;
132
- try {
133
- result = func(...args);
134
- } catch (err) {
135
- throwLabeled(err, label);
136
- }
137
- if (isPromise(result)) {
138
- // If result is a rejected promise, this will return a promise with a
139
- // different rejection reason. But this confuses TypeScript because it types
140
- // that case as `Promise<never>` which is cool for a promise that will never
141
- // fulfill. But TypeScript doesn't understand that this will only happen
142
- // when `result` was a rejected promise. In only this case `R` should
143
- // already allow `Promise<never>` as a subtype.
144
- /** @type {unknown} */
145
- const relabeled = E.when(result, undefined, reason =>
146
- throwLabeled(reason, label),
147
- );
148
- return /** @type {R} */ (relabeled);
149
- } else {
150
- return result;
151
- }
152
- };
153
- harden(applyLabelingError);
15
+ /** @import { ERef } from '@endo/far' */
154
16
 
155
17
  /**
156
18
  * @template T
@@ -205,23 +67,6 @@ export const makeMeasureSeconds = currentTimeMillisec => {
205
67
  return measureSeconds;
206
68
  };
207
69
 
208
- /**
209
- * @param {Error[]} errors
210
- * @param {string} [message]
211
- */
212
- export const makeAggregateError = (errors, message) => {
213
- const err = Error(message);
214
- Object.defineProperties(err, {
215
- name: {
216
- value: 'AggregateError',
217
- },
218
- errors: {
219
- value: errors,
220
- },
221
- });
222
- return err;
223
- };
224
-
225
70
  /**
226
71
  * @template T
227
72
  * @param {readonly (T | PromiseLike<T>)[]} items
@@ -239,7 +84,7 @@ export const PromiseAllOrErrors = async items => {
239
84
  } else if (errors.length === 1) {
240
85
  throw errors[0];
241
86
  } else {
242
- throw makeAggregateError(errors);
87
+ throw AggregateError(errors);
243
88
  }
244
89
  });
245
90
  };
@@ -249,14 +94,15 @@ export const PromiseAllOrErrors = async items => {
249
94
  * trier: () => Promise<T>,
250
95
  * finalizer: (error?: unknown) => Promise<void>,
251
96
  * ) => Promise<T>}
252
- */ export const aggregateTryFinally = async (trier, finalizer) =>
97
+ */
98
+ export const aggregateTryFinally = async (trier, finalizer) =>
253
99
  trier().then(
254
100
  async result => finalizer().then(() => result),
255
101
  async tryError =>
256
102
  finalizer(tryError)
257
103
  .then(
258
104
  () => tryError,
259
- finalizeError => makeAggregateError([tryError, finalizeError]),
105
+ finalizeError => AggregateError([tryError, finalizeError]),
260
106
  )
261
107
  .then(error => Promise.reject(error)),
262
108
  );
@@ -275,7 +121,6 @@ export const PromiseAllOrErrors = async items => {
275
121
  * @throws if any value in the object entries is not defined
276
122
  * @returns {asserts obj is AllDefined<T>}
277
123
  */
278
-
279
124
  export const assertAllDefined = obj => {
280
125
  const missing = [];
281
126
  for (const [key, val] of Object.entries(obj)) {
package/CHANGELOG.md DELETED
@@ -1,115 +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-u11wf.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.3.3-u11.0...@agoric/internal@0.3.3-u11wf.0) (2023-09-23)
7
-
8
-
9
- ### Features
10
-
11
- * **internal:** fakeStorage.getBody() supports index other than -1 ([d2e05c4](https://github.com/Agoric/agoric-sdk/commit/d2e05c43dcd5dfa3719feecc0b303b8294efeef0))
12
-
13
-
14
-
15
- ### [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)
16
-
17
- **Note:** Version bump only for package @agoric/internal
18
-
19
-
20
-
21
-
22
-
23
- ### [0.3.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.3.1...@agoric/internal@0.3.2) (2023-06-02)
24
-
25
- **Note:** Version bump only for package @agoric/internal
26
-
27
-
28
-
29
-
30
-
31
- ### [0.3.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.3.0...@agoric/internal@0.3.1) (2023-05-24)
32
-
33
- **Note:** Version bump only for package @agoric/internal
34
-
35
-
36
-
37
-
38
-
39
- ## [0.3.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.2.1...@agoric/internal@0.3.0) (2023-05-19)
40
-
41
-
42
- ### ⚠ BREAKING CHANGES
43
-
44
- * emit smallcaps-format data in all marshallers
45
-
46
- ### Features
47
-
48
- * 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)
49
- * **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)
50
- * **casting:** handle noData value encoding ([530bc41](https://github.com/Agoric/agoric-sdk/commit/530bc41854cc7f5e5749e97e87fabc6163a17864))
51
- * **cosmic-swingset:** add after-commit action ([970a53f](https://github.com/Agoric/agoric-sdk/commit/970a53f827ded21b27525f6b0042bbc124c62d48))
52
- * **internal:** makeFakeStorageKit supports "get" and "entries" ([6a69aab](https://github.com/Agoric/agoric-sdk/commit/6a69aab5cb54faae5af631bbc2281e4fc4ede8e0))
53
- * **internal:** new `prepareAttenuator` leveraging callbacks ([55599df](https://github.com/Agoric/agoric-sdk/commit/55599dfe7ec43a27387ca64e8bae57be13a38115))
54
- * 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)
55
- * **core:** HighPrioritySendersManager ([7b382e4](https://github.com/Agoric/agoric-sdk/commit/7b382e49a1521d367c5b8db18fa7efa2b77ef7e3))
56
- * **cosmic-swingset:** basic snapshot wiring ([b1072d8](https://github.com/Agoric/agoric-sdk/commit/b1072d8b1ddabbb5f2835eb503c945fed3b6b080))
57
- * **cosmic-swingset:** export swingStore kvData to vstorage ([be68431](https://github.com/Agoric/agoric-sdk/commit/be684315dc68ecf0cb603a8eb38ddd5418e996a6))
58
- * **cosmic-swingset:** process highPriorityQueue actions ([182a96e](https://github.com/Agoric/agoric-sdk/commit/182a96e169c8cac7f31fbce014783fd6db72b64c))
59
- * **cosmic-swingset:** remove unnecessary explicit activityhash ([5dcc44d](https://github.com/Agoric/agoric-sdk/commit/5dcc44d31be0c8a95a5749d768791fa35b72dbd3))
60
- * **internal:** add BufferLineTransform ([6e7db7a](https://github.com/Agoric/agoric-sdk/commit/6e7db7af7d93500caf71d817afbb358d33ef01f6))
61
- * **internal:** add sync tee util ([#7560](https://github.com/Agoric/agoric-sdk/issues/7560)) ([0f800a6](https://github.com/Agoric/agoric-sdk/commit/0f800a622b81c61101d96b0ad620ab3065f4b146))
62
- * **internal:** build `chainStorage` from `zone` ([74c62da](https://github.com/Agoric/agoric-sdk/commit/74c62dae7964b488bfdf7c7ee8a9bd930074cea8))
63
- * **internal:** iterable produces values and can be async ([cf4110f](https://github.com/Agoric/agoric-sdk/commit/cf4110f59c228e42e09254b271209a66b9faf3e0))
64
- * **internal:** new `callback` module for durable classless callbacks ([b94d600](https://github.com/Agoric/agoric-sdk/commit/b94d60052e1043fd6fb1ce39530a6072e38ef0d9))
65
- * **internal:** shutdown informs of interrupt signal ([2ce1e89](https://github.com/Agoric/agoric-sdk/commit/2ce1e892eb381a28c31805f48ba65511896ef406))
66
- * assertAllDefined ([d4d6cbd](https://github.com/Agoric/agoric-sdk/commit/d4d6cbd798eee051a8a699c85cc620c6a8298258))
67
- * board-utils ([4f80ad3](https://github.com/Agoric/agoric-sdk/commit/4f80ad3cac3e47a89834f7f98330a47141b6e235))
68
- * type assertion for assertAllDefined ([afa7b5b](https://github.com/Agoric/agoric-sdk/commit/afa7b5bfaf4558a38bdba2c44bf91691f6db26b8))
69
- * **store:** M.splitArray and M.splitRecord ([#6597](https://github.com/Agoric/agoric-sdk/issues/6597)) ([e7427e3](https://github.com/Agoric/agoric-sdk/commit/e7427e386bcbfbe99312b41342b1fa2e722c57c7))
70
- * **vats:** harmonise core/boot.js and boot-psm.js ([4f6635e](https://github.com/Agoric/agoric-sdk/commit/4f6635e550b926d3ca43d9075f26fef3b810817d))
71
-
72
-
73
- ### Bug Fixes
74
-
75
- * **internal:** add typing to makeWithQueue ([5b1539b](https://github.com/Agoric/agoric-sdk/commit/5b1539bfc61ea4f937e2f85cbe93c7bccfc84a40))
76
- * **internal:** Make makeFakeStorageKit value auto-wrapping depend upon `sequence: true` ([2751e76](https://github.com/Agoric/agoric-sdk/commit/2751e7626e0ca617cdb2b1d92e5d4d9315b5674a))
77
- * **internal:** more callback typing ([e78e14d](https://github.com/Agoric/agoric-sdk/commit/e78e14d60a78d2e5f9fb9a899053bf778bb51360))
78
- * **internal:** properly inherit from `chainStorageNode` ([134a977](https://github.com/Agoric/agoric-sdk/commit/134a977f7bc4a2fc6eff3868d4d415c8c9714b4b))
79
- * **internal:** Restore support for passable-symbol method keys ([54271af](https://github.com/Agoric/agoric-sdk/commit/54271af10adb144fe6d562193afa473d74425854))
80
- * **internal:** shutdown beforeExit avoids forced exit ([34c9f44](https://github.com/Agoric/agoric-sdk/commit/34c9f442f124cd7181b538cf8754c6180c863b32))
81
- * **internal:** Validate Callback targets ([8880ada](https://github.com/Agoric/agoric-sdk/commit/8880ada791d70dd487770e8a0fa4b6b725aa8769))
82
- * **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)
83
- * adapt to deeplyFulfilled being async ([#6816](https://github.com/Agoric/agoric-sdk/issues/6816)) ([ec315e1](https://github.com/Agoric/agoric-sdk/commit/ec315e1634f6d5cdef1cddafc18777de7c04fecc))
84
- * **telemetry:** partially undo [#6684](https://github.com/Agoric/agoric-sdk/issues/6684) ([b9fa85b](https://github.com/Agoric/agoric-sdk/commit/b9fa85b7307124e50cc3a84d3b694307cde55f54))
85
- * avoid using top-level `require` ([57ca2db](https://github.com/Agoric/agoric-sdk/commit/57ca2dbfbadb373f97d43b2fb4e90302c9149976))
86
- * **types:** type assertion for assertAllDefined ([25f16b2](https://github.com/Agoric/agoric-sdk/commit/25f16b2e935931b81313d2ee1d491b305088bb7a))
87
- * track endo 1382 fix to 6570 ([#6612](https://github.com/Agoric/agoric-sdk/issues/6612)) ([7897761](https://github.com/Agoric/agoric-sdk/commit/7897761d6e19e6bbba42e7bd0bd5befb507afa08))
88
-
89
-
90
-
91
- ### [0.2.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.2.0...@agoric/internal@0.2.1) (2022-10-05)
92
-
93
-
94
- ### Bug Fixes
95
-
96
- * protect zoe from keyword collision ([#6370](https://github.com/Agoric/agoric-sdk/issues/6370)) ([02af4a0](https://github.com/Agoric/agoric-sdk/commit/02af4a07ad1f99b545d0bf525bd1ea97d74639d1))
97
-
98
-
99
-
100
- ## 0.2.0 (2022-09-20)
101
-
102
-
103
- ### ⚠ BREAKING CHANGES
104
-
105
- * **SwingSet:** Representatives inherit bound methods (#5970)
106
-
107
- ### Features
108
-
109
- * **internal:** add async utils from loadgen ([5d9f411](https://github.com/Agoric/agoric-sdk/commit/5d9f411a124e4028cd88764084999fb1fd791609))
110
- * **internal:** deeplyFulfilledObject ([11fd071](https://github.com/Agoric/agoric-sdk/commit/11fd071005741719286ae6a1bb6bb9a7fd1f65b7))
111
-
112
-
113
- ### Bug Fixes
114
-
115
- * **SwingSet:** Representatives inherit bound methods ([#5970](https://github.com/Agoric/agoric-sdk/issues/5970)) ([ba1ed62](https://github.com/Agoric/agoric-sdk/commit/ba1ed62062a63862e2eecb598b0bd1d2ac828e1f))