@agoric/internal 0.3.3-mainnet1B-dev-867dea5.0 → 0.3.3-orchestration-dev-096c4e8.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 (64) hide show
  1. package/README.md +7 -2
  2. package/package.json +24 -13
  3. package/src/batched-deliver.d.ts +6 -6
  4. package/src/batched-deliver.d.ts.map +1 -1
  5. package/src/batched-deliver.js +6 -3
  6. package/src/callback.d.ts +23 -16
  7. package/src/callback.d.ts.map +1 -1
  8. package/src/callback.js +14 -13
  9. package/src/config.d.ts +19 -12
  10. package/src/config.js +6 -0
  11. package/src/index.d.ts +2 -0
  12. package/src/index.js +3 -0
  13. package/src/install-ses-debug.d.ts +2 -0
  14. package/src/install-ses-debug.d.ts.map +1 -0
  15. package/src/install-ses-debug.js +6 -0
  16. package/src/lib-chainStorage.d.ts +4 -31
  17. package/src/lib-chainStorage.d.ts.map +1 -1
  18. package/src/lib-chainStorage.js +7 -37
  19. package/src/lib-nodejs/engine-gc.d.ts +3 -0
  20. package/src/lib-nodejs/engine-gc.d.ts.map +1 -0
  21. package/src/lib-nodejs/engine-gc.js +22 -0
  22. package/src/lib-nodejs/gc-and-finalize.d.ts +2 -0
  23. package/src/lib-nodejs/gc-and-finalize.d.ts.map +1 -0
  24. package/src/lib-nodejs/gc-and-finalize.js +91 -0
  25. package/src/lib-nodejs/spawnSubprocessWorker.d.ts +16 -0
  26. package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -0
  27. package/src/lib-nodejs/spawnSubprocessWorker.js +87 -0
  28. package/src/lib-nodejs/waitUntilQuiescent.d.ts +2 -0
  29. package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -0
  30. package/src/lib-nodejs/waitUntilQuiescent.js +18 -0
  31. package/src/lib-nodejs/worker-protocol.d.ts +4 -0
  32. package/src/lib-nodejs/worker-protocol.d.ts.map +1 -0
  33. package/src/lib-nodejs/worker-protocol.js +56 -0
  34. package/src/marshal.d.ts +19 -0
  35. package/src/marshal.d.ts.map +1 -0
  36. package/src/marshal.js +131 -0
  37. package/src/method-tools.d.ts +1 -0
  38. package/src/method-tools.d.ts.map +1 -1
  39. package/src/method-tools.js +12 -0
  40. package/src/netstring.d.ts +13 -0
  41. package/src/netstring.d.ts.map +1 -0
  42. package/src/netstring.js +119 -0
  43. package/src/node/buffer-line-transform.d.ts +1 -1
  44. package/src/node/buffer-line-transform.d.ts.map +1 -1
  45. package/src/node/createBundles.js +1 -1
  46. package/src/queue.d.ts +1 -1
  47. package/src/queue.d.ts.map +1 -1
  48. package/src/queue.js +6 -6
  49. package/src/storage-test-utils.d.ts +14 -9
  50. package/src/storage-test-utils.d.ts.map +1 -1
  51. package/src/storage-test-utils.js +2 -5
  52. package/src/tokens.d.ts +34 -0
  53. package/src/tokens.d.ts.map +1 -0
  54. package/src/tokens.js +35 -0
  55. package/src/typeGuards.d.ts +2 -0
  56. package/src/typeGuards.d.ts.map +1 -1
  57. package/src/typeGuards.js +8 -0
  58. package/src/upgrade-api.d.ts +13 -4
  59. package/src/upgrade-api.d.ts.map +1 -1
  60. package/src/upgrade-api.js +26 -18
  61. package/src/utils.d.ts +3 -6
  62. package/src/utils.d.ts.map +1 -1
  63. package/src/utils.js +6 -144
  64. package/CHANGELOG.md +0 -115
package/src/queue.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // @jessie-check
2
+ /* eslint @typescript-eslint/no-floating-promises: "warn" */
2
3
 
3
4
  import { makePromiseKit } from '@endo/promise-kit';
4
5
 
@@ -16,7 +17,7 @@ export const makeWithQueue = () => {
16
17
  }
17
18
  const [thunk, resolve, reject] = queue[0];
18
19
  // Run the thunk in a new turn.
19
- Promise.resolve()
20
+ void Promise.resolve()
20
21
  .then(thunk)
21
22
  // Resolve or reject our caller with the thunk's value.
22
23
  .then(resolve, reject)
@@ -30,14 +31,13 @@ export const makeWithQueue = () => {
30
31
  };
31
32
 
32
33
  /**
33
- * @template {any[]} T
34
- * @template R
35
- * @param {(...args: T) => Promise<R>} inner
34
+ * @template {(...args: any[]) => any} T
35
+ * @param {T} inner
36
36
  */
37
37
  return function withQueue(inner) {
38
38
  /**
39
- * @param {T} args
40
- * @returns {Promise<R>}
39
+ * @param {Parameters<T>} args
40
+ * @returns {Promise<Awaited<ReturnType<T>>>}
41
41
  */
42
42
  return function queueCall(...args) {
43
43
  // Curry the arguments into the inner function, and
@@ -13,14 +13,7 @@ export function slotStringUnserialize(capData: any): any;
13
13
  export function makeFakeStorageKit(rootPath: string, rootOptions?: [handleStorageMessage: (message: import("./lib-chainStorage.js").StorageMessage) => any, rootPath: string, rootOptions?: {
14
14
  sequence?: boolean | undefined;
15
15
  } | undefined][2]): {
16
- rootNode: {
17
- getPath(): string;
18
- getStoreKey(): Promise<import("./lib-chainStorage.js").VStorageKey>;
19
- makeChildNode(name: string, childNodeOptions?: {
20
- sequence?: boolean | undefined;
21
- } | undefined): import("./lib-chainStorage.js").StorageNode;
22
- setValue(value: string): Promise<void>;
23
- } & import("@endo/eventual-send").RemotableBrand<{}, {
16
+ rootNode: import("@endo/exo/src/exo-makers.js").Guarded<{
24
17
  getPath(): string;
25
18
  getStoreKey(): Promise<import("./lib-chainStorage.js").VStorageKey>;
26
19
  makeChildNode(name: string, childNodeOptions?: {
@@ -55,6 +48,12 @@ export function makeMockChainStorageRoot(): {
55
48
  sequence?: boolean | undefined;
56
49
  } | undefined): import("./lib-chainStorage.js").StorageNode;
57
50
  setValue(value: string): Promise<void>;
51
+ __getInterfaceGuard__?: (() => import("@endo/patterns").InterfaceGuard<{
52
+ getPath: import("@endo/patterns").MethodGuard;
53
+ getStoreKey: import("@endo/patterns").MethodGuard;
54
+ makeChildNode: import("@endo/patterns").MethodGuard;
55
+ setValue: import("@endo/patterns").MethodGuard;
56
+ }> | undefined) | undefined;
58
57
  } & import("@endo/eventual-send").RemotableBrand<{}, {
59
58
  /**
60
59
  * Defaults to deserializing slot references into plain Remotable
@@ -75,6 +74,12 @@ export function makeMockChainStorageRoot(): {
75
74
  sequence?: boolean | undefined;
76
75
  } | undefined): import("./lib-chainStorage.js").StorageNode;
77
76
  setValue(value: string): Promise<void>;
77
+ __getInterfaceGuard__?: (() => import("@endo/patterns").InterfaceGuard<{
78
+ getPath: import("@endo/patterns").MethodGuard;
79
+ getStoreKey: import("@endo/patterns").MethodGuard;
80
+ makeChildNode: import("@endo/patterns").MethodGuard;
81
+ setValue: import("@endo/patterns").MethodGuard;
82
+ }> | undefined) | undefined;
78
83
  }>;
79
84
  /**
80
85
  * A map corresponding with a total function such that `get(key)`
@@ -83,6 +88,7 @@ export function makeMockChainStorageRoot(): {
83
88
  export type TotalMap<K, V> = {
84
89
  [Symbol.iterator]: () => IterableIterator<[K, V]>;
85
90
  [Symbol.toStringTag]: string;
91
+ forEach: (callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any) => void;
86
92
  entries: () => IterableIterator<[K, V]>;
87
93
  keys: () => IterableIterator<K>;
88
94
  values: () => IterableIterator<V>;
@@ -91,7 +97,6 @@ export type TotalMap<K, V> = {
91
97
  set: (key: K, value: V) => Map<K, V>;
92
98
  clear: () => void;
93
99
  delete: (key: K) => boolean;
94
- forEach: (callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any) => void;
95
100
  } & {
96
101
  get: (key: K) => V;
97
102
  };
@@ -1 +1 @@
1
- {"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AAkCO,yCAHI,MAAM,UACN,MAAM,wDAGC;AAElB;;;GAGG;AACH;;;;;EAEG;AAsBW,+CAAU,GAAG,GAAK,GAAG,CAAA;AAgC5B,6CAHI,MAAM,gBACN;;eAAwC,CAAC,CAAC;;;;;;;;;;;;;;;;;;yBAyBvC,OAAO,4BAA4B,EAAE,cAAc;;;;EAoFhE;AAIM;IAIH;;;;;;;;;;OAUG;oBAJQ,MAAM,eACN,OAAO,uBAAuB,EAAE,UAAU,iCAExC,OAAO;;;;;;;;;IATpB;;;;;;;;;;OAUG;oBAJQ,MAAM,eACN,OAAO,uBAAuB,EAAE,UAAU,iCAExC,OAAO;;;;;;;;GAWvB;;;;;;;;;;;;;;;;;;eApNiF,CAAC,KAAK,CAAC;;;6BA0L3E,WAAY,yBAAyB,CAAC;mCA2BtC,WAAW,+BAA+B,CAAC"}
1
+ {"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AA+BO,yCAHI,MAAM,UACN,MAAM,wDAGC;AAElB;;;GAGG;AACH;;;;;EAEG;AAsBW,+CAAU,GAAG,GAAK,GAAG,CAAA;AAgC5B,6CAHI,MAAM,gBACN;;eAAwC,CAAC,CAAC;;;;;;;;;;;yBAyBvC,OAAO,4BAA4B,EAAE,cAAc;;;;EAoFhE;AAIM;IAIH;;;;;;;;;;OAUG;oBAJQ,MAAM,eACN,OAAO,uBAAuB,EAAE,UAAU,iCAExC,OAAO;;;;;;;;;;;;;;;IATpB;;;;;;;;;;OAUG;oBAJQ,MAAM,eACN,OAAO,uBAAuB,EAAE,UAAU,iCAExC,OAAO;;;;;;;;;;;;;;GAWvB;;;;;;;;;;;;;;;;;;eApNiF,CAAC,KAAK,CAAC;;;6BA0L3E,WAAY,yBAAyB,CAAC;mCA2BtC,WAAW,+BAA+B,CAAC"}
@@ -1,12 +1,9 @@
1
1
  // @ts-check
2
2
  import { Far } from '@endo/far';
3
3
  import { makeMarshal, Remotable } from '@endo/marshal';
4
+ import { unmarshalFromVstorage } from './marshal.js';
4
5
  import { makeTracer } from './debug.js';
5
- import {
6
- isStreamCell,
7
- makeChainStorageRoot,
8
- unmarshalFromVstorage,
9
- } from './lib-chainStorage.js';
6
+ import { isStreamCell, makeChainStorageRoot } from './lib-chainStorage.js';
10
7
  import { bindAllMethods } from './method-tools.js';
11
8
 
12
9
  const { Fail } = assert;
@@ -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
+ );
@@ -1,7 +1,16 @@
1
- export function makeUpgradeDisconnection(upgradeMessage: string, toIncarnationNumber: number): DisconnectionObject;
2
- export function isUpgradeDisconnection(err: any): err is DisconnectionObject;
3
- export type DisconnectionObject = {
4
- name: string;
1
+ export namespace UpgradeDisconnectionShape {
2
+ let name: string;
3
+ let upgradeMessage: import("@endo/patterns").Matcher;
4
+ let incarnationNumber: import("@endo/patterns").Matcher;
5
+ }
6
+ export function makeUpgradeDisconnection(upgradeMessage: string, toIncarnationNumber: number): UpgradeDisconnection;
7
+ export function isUpgradeDisconnection(reason: any): reason is UpgradeDisconnection;
8
+ /**
9
+ * An Error-like object for use as the rejection reason of promises
10
+ * abandoned by upgrade.
11
+ */
12
+ export type UpgradeDisconnection = {
13
+ name: 'vatUpgraded';
5
14
  upgradeMessage: string;
6
15
  incarnationNumber: number;
7
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade-api.d.ts","sourceRoot":"","sources":["upgrade-api.js"],"names":[],"mappings":"AAgBO,yDAJI,MAAM,uBACN,MAAM,GACJ,mBAAmB,CAO5B;AAcG,4CAHI,GAAG,8BAO6B;kCAlC9B;IAAE,MAAM,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE"}
1
+ {"version":3,"file":"upgrade-api.d.ts","sourceRoot":"","sources":["upgrade-api.js"],"names":[],"mappings":";;;;;AAgCO,yDAJI,MAAM,uBACN,MAAM,GACJ,oBAAoB,CAO7B;AASG,+CALI,GAAG,kCAMkD;;;;;mCApCnD;IACZ,MAAU,aAAa,CAAC;IACxB,cAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAqB,EAAE,MAAM,CAAA;CAC1B"}
@@ -1,18 +1,34 @@
1
1
  // @ts-check
2
2
  // @jessie-check
3
- import { isObject } from '@endo/marshal';
3
+
4
+ import { M, matches } from '@endo/patterns';
5
+
6
+ const { isFrozen } = Object;
4
7
 
5
8
  /**
6
- * @typedef {{ name: string, upgradeMessage: string, incarnationNumber: number }} DisconnectionObject
9
+ * An Error-like object for use as the rejection reason of promises
10
+ * abandoned by upgrade.
11
+ *
12
+ * @typedef {{
13
+ * name: 'vatUpgraded',
14
+ * upgradeMessage: string,
15
+ * incarnationNumber: number
16
+ * }} UpgradeDisconnection
7
17
  */
8
18
 
19
+ export const UpgradeDisconnectionShape = harden({
20
+ name: 'vatUpgraded',
21
+ upgradeMessage: M.string(),
22
+ incarnationNumber: M.number(),
23
+ });
24
+
9
25
  /**
10
- * Makes an Error-like object for use as the rejection value of promises
26
+ * Makes an Error-like object for use as the rejection reason of promises
11
27
  * abandoned by upgrade.
12
28
  *
13
29
  * @param {string} upgradeMessage
14
30
  * @param {number} toIncarnationNumber
15
- * @returns {DisconnectionObject}
31
+ * @returns {UpgradeDisconnection}
16
32
  */
17
33
  export const makeUpgradeDisconnection = (upgradeMessage, toIncarnationNumber) =>
18
34
  harden({
@@ -22,20 +38,12 @@ export const makeUpgradeDisconnection = (upgradeMessage, toIncarnationNumber) =>
22
38
  });
23
39
  harden(makeUpgradeDisconnection);
24
40
 
25
- // TODO: Simplify once we have @endo/patterns (or just export the shape).
26
- // const upgradeDisconnectionShape = harden({
27
- // name: 'vatUpgraded',
28
- // upgradeMessage: M.string(),
29
- // incarnationNumber: M.number(),
30
- // });
31
- // const isUpgradeDisconnection = err => matches(err, upgradeDisconnectionShape);
32
41
  /**
33
- * @param {any} err
34
- * @returns {err is DisconnectionObject}
42
+ * @param {any} reason
43
+ * If `reason` is not frozen, it cannot be an UpgradeDisconnection,
44
+ * so returns false without even checking against the shape.
45
+ * @returns {reason is UpgradeDisconnection}
35
46
  */
36
- export const isUpgradeDisconnection = err =>
37
- isObject(err) &&
38
- err.name === 'vatUpgraded' &&
39
- typeof err.upgradeMessage === 'string' &&
40
- typeof err.incarnationNumber === 'number';
47
+ export const isUpgradeDisconnection = reason =>
48
+ isFrozen(reason) && matches(reason, UpgradeDisconnectionShape);
41
49
  harden(isUpgradeDisconnection);
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
+ /** @template T @typedef {import('@endo/eventual-send').ERef<T>} ERef<T> */
7
3
  /**
8
4
  * @template T
9
5
  * @typedef {{[KeyType in keyof T]: T[KeyType]} & {}} Simplify
@@ -41,7 +37,8 @@ export function PromiseAllOrErrors<T>(items: readonly (T | PromiseLike<T>)[]): P
41
37
  * trier: () => Promise<T>,
42
38
  * finalizer: (error?: unknown) => Promise<void>,
43
39
  * ) => Promise<T>}
44
- */ export const aggregateTryFinally: <T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<void>) => Promise<T>;
40
+ */
41
+ export const aggregateTryFinally: <T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<void>) => Promise<T>;
45
42
  export function assertAllDefined<T extends Record<string, unknown>>(obj: T): asserts obj is AllDefined<T>;
46
43
  export const forever: AsyncIterable<undefined>;
47
44
  export function whileTrue<T>(produce: () => T): AsyncIterable<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,2EAA2E;AAE3E;;;;;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;AACH,mFAHwB,OAAO,KAAK,QAAQ,IAAI,CAAC,gBAa7C;AAgBG,0GAUN;AAQD,+CAAoD;AAU7C,0EAUH;AAUG,0EAaH;AAEJ,oDAAoD;AACpD,uDAAqE;AAErE,2GAA2G;AAC3G,+GAIE;AAWK,sGAFI,MAAM,mCA4FhB;;;;sBA1SyB,OAAO,qBAAqB,EAAE,IAAI,CAAC,CAAC,CAAC;;;;;;iCAUxC,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"}
package/src/utils.js CHANGED
@@ -1,157 +1,19 @@
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
15
  /** @template T @typedef {import('@endo/eventual-send').ERef<T>} ERef<T> */
18
16
 
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);
154
-
155
17
  /**
156
18
  * @template T
157
19
  * @typedef {{[KeyType in keyof T]: T[KeyType]} & {}} Simplify
@@ -249,7 +111,8 @@ export const PromiseAllOrErrors = async items => {
249
111
  * trier: () => Promise<T>,
250
112
  * finalizer: (error?: unknown) => Promise<void>,
251
113
  * ) => Promise<T>}
252
- */ export const aggregateTryFinally = async (trier, finalizer) =>
114
+ */
115
+ export const aggregateTryFinally = async (trier, finalizer) =>
253
116
  trier().then(
254
117
  async result => finalizer().then(() => result),
255
118
  async tryError =>
@@ -275,7 +138,6 @@ export const PromiseAllOrErrors = async items => {
275
138
  * @throws if any value in the object entries is not defined
276
139
  * @returns {asserts obj is AllDefined<T>}
277
140
  */
278
-
279
141
  export const assertAllDefined = obj => {
280
142
  const missing = [];
281
143
  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))