@agoric/internal 0.4.0-u18a.0 → 0.4.0-u19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/internal",
3
- "version": "0.4.0-u18a.0",
3
+ "version": "0.4.0-u19.1",
4
4
  "description": "Externally unsupported utilities internal to agoric-sdk",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -20,23 +20,23 @@
20
20
  "lint:types": "tsc"
21
21
  },
22
22
  "dependencies": {
23
- "@agoric/base-zone": "^0.1.1-u18.1",
24
- "@endo/common": "^1.2.8",
25
- "@endo/errors": "^1.2.8",
26
- "@endo/far": "^1.1.9",
27
- "@endo/init": "^1.1.7",
28
- "@endo/marshal": "^1.6.2",
29
- "@endo/pass-style": "^1.4.7",
30
- "@endo/patterns": "^1.4.7",
31
- "@endo/promise-kit": "^1.1.8",
32
- "@endo/stream": "^1.2.8",
23
+ "@agoric/base-zone": "^0.1.1-u19.0",
24
+ "@endo/common": "^1.2.9",
25
+ "@endo/errors": "^1.2.9",
26
+ "@endo/far": "^1.1.10",
27
+ "@endo/init": "^1.1.8",
28
+ "@endo/marshal": "^1.6.3",
29
+ "@endo/pass-style": "^1.4.8",
30
+ "@endo/patterns": "^1.4.8",
31
+ "@endo/promise-kit": "^1.1.9",
32
+ "@endo/stream": "^1.2.9",
33
33
  "anylogger": "^0.21.0",
34
34
  "jessie.js": "^0.3.4"
35
35
  },
36
36
  "devDependencies": {
37
- "@agoric/cosmic-proto": "^0.5.0-u18a.0",
38
- "@endo/exo": "^1.5.7",
39
- "@endo/init": "^1.1.7",
37
+ "@agoric/cosmic-proto": "^0.5.0-u19.1",
38
+ "@endo/exo": "^1.5.8",
39
+ "@endo/init": "^1.1.8",
40
40
  "ava": "^5.3.0",
41
41
  "tsd": "^0.31.1"
42
42
  },
@@ -58,7 +58,7 @@
58
58
  "access": "public"
59
59
  },
60
60
  "typeCoverage": {
61
- "atLeast": 93.06
61
+ "atLeast": 93.04
62
62
  },
63
- "gitHead": "4e4d2b4dedc5a268178712fc6beb89496518480a"
63
+ "gitHead": "a04d2bf43a9753d123954b52c6ba8d35083a3c8f"
64
64
  }
@@ -46,6 +46,8 @@ export namespace QueuedActionType {
46
46
  let VBANK_BALANCE_UPDATE: "VBANK_BALANCE_UPDATE";
47
47
  let WALLET_ACTION: "WALLET_ACTION";
48
48
  let WALLET_SPEND_ACTION: "WALLET_SPEND_ACTION";
49
+ let VTRANSFER_IBC_EVENT: "VTRANSFER_IBC_EVENT";
50
+ let KERNEL_UPGRADE_EVENTS: "KERNEL_UPGRADE_EVENTS";
49
51
  }
50
52
  export const CORE_EVAL: "CORE_EVAL";
51
53
  export const DELIVER_INBOUND: "DELIVER_INBOUND";
@@ -55,7 +57,6 @@ export const PLEASE_PROVISION: "PLEASE_PROVISION";
55
57
  export const VBANK_BALANCE_UPDATE: "VBANK_BALANCE_UPDATE";
56
58
  export const WALLET_ACTION: "WALLET_ACTION";
57
59
  export const WALLET_SPEND_ACTION: "WALLET_SPEND_ACTION";
58
- export const CALCULATE_FEES_IN_BEANS: "CALCULATE_FEES_IN_BEANS";
59
60
  export const VTRANSFER_IBC_EVENT: "VTRANSFER_IBC_EVENT";
60
61
  export const KERNEL_UPGRADE_EVENTS: "KERNEL_UPGRADE_EVENTS";
61
62
  //# sourceMappingURL=action-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"action-types.d.ts","sourceRoot":"","sources":["action-types.js"],"names":[],"mappings":";;;;;;;;;;;;kCAcU,CAAC,OAAO,mBAAmB,EAAE,MAAM,OAAO,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;+BAiC9D,CAAC,OAAO,gBAAgB,EAAE,MAAM,OAAO,gBAAgB,CAAC;;;;;;;;;;;;;;;;;;;AA0BlE,sCAAuC,yBAAyB,CAAC;AACjE,kCAAmC,qBAAqB,CAAC;AACzD,oCAAqC,uBAAuB,CAAC"}
1
+ {"version":3,"file":"action-types.d.ts","sourceRoot":"","sources":["action-types.js"],"names":[],"mappings":";;;;;;;;;;;;kCAcU,CAAC,OAAO,mBAAmB,EAAE,MAAM,OAAO,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;+BAiC9D,CAAC,OAAO,gBAAgB,EAAE,MAAM,OAAO,gBAAgB,CAAC"}
@@ -56,6 +56,8 @@ export const QueuedActionType = /** @type {const} */ ({
56
56
  VBANK_BALANCE_UPDATE: 'VBANK_BALANCE_UPDATE',
57
57
  WALLET_ACTION: 'WALLET_ACTION',
58
58
  WALLET_SPEND_ACTION: 'WALLET_SPEND_ACTION',
59
+ VTRANSFER_IBC_EVENT: 'VTRANSFER_IBC_EVENT',
60
+ KERNEL_UPGRADE_EVENTS: 'KERNEL_UPGRADE_EVENTS',
59
61
  });
60
62
  harden(QueuedActionType);
61
63
 
@@ -69,8 +71,6 @@ export const {
69
71
  VBANK_BALANCE_UPDATE,
70
72
  WALLET_ACTION,
71
73
  WALLET_SPEND_ACTION,
74
+ VTRANSFER_IBC_EVENT,
75
+ KERNEL_UPGRADE_EVENTS,
72
76
  } = QueuedActionType;
73
-
74
- export const CALCULATE_FEES_IN_BEANS = 'CALCULATE_FEES_IN_BEANS';
75
- export const VTRANSFER_IBC_EVENT = 'VTRANSFER_IBC_EVENT';
76
- export const KERNEL_UPGRADE_EVENTS = 'KERNEL_UPGRADE_EVENTS';
package/src/js-utils.d.ts CHANGED
@@ -1,7 +1,15 @@
1
+ /**
2
+ * @file Pure JavaScript utility functions that are compatible with but not
3
+ * dependent upon a hardened environment.
4
+ */
5
+ export const logLevels: readonly ["debug", "log", "info", "warn", "error"];
1
6
  export function deepCopyJsonable<T>(value: T): T;
2
7
  export function deepMapObject(obj: object, mapper: (value: any, name: string, record: object) => any): object;
8
+ export function objectMapMutable<O extends Record<PropertyKey, any>, V>(obj: O, mapFn: <K extends keyof O>(value: O[K], key: K) => V): { [K in keyof O]: V; };
3
9
  export function makeMeasureSeconds(currentTimeMillisec: () => number): <T>(fn: () => Promise<T>) => Promise<{
4
10
  result: T;
5
11
  duration: number;
6
12
  }>;
13
+ export type LogLevel = (typeof logLevels)[keyof readonly ["debug", "log", "info", "warn", "error"] & number];
14
+ export type LimitedConsole = Pick<Console, LogLevel>;
7
15
  //# sourceMappingURL=js-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"js-utils.d.ts","sourceRoot":"","sources":["js-utils.js"],"names":[],"mappings":"AAgBO,iCAJM,CAAC,SACH,CAAC,GACC,CAAC,CAE4D;AAiDnE,mCAJI,MAAM,UACN,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,GAAG,GAC/C,MAAM,CAGuC;AASnD,wDAFI,MAAM,MAAM,IAIR,CAAC,MACH,MAAM,OAAO,CAAC,CAAC,CAAC,KACd,OAAO,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAStD"}
1
+ {"version":3,"file":"js-utils.d.ts","sourceRoot":"","sources":["js-utils.js"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,2EAMG;AAkBI,iCAJM,CAAC,SACH,CAAC,GACC,CAAC,CAE4D;AAiDnE,mCAJI,MAAM,UACN,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,GAAG,GAC/C,MAAM,CAGuC;AASnD,iCANiC,CAAC,SAA3B,MAAM,CAAC,WAAW,EAAE,GAAG,CAAE,EAC1B,CAAC,OACH,CAAC,SACD,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,GAC3C,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAE,CAKjC;AASM,wDAFI,MAAM,MAAM,IAIR,CAAC,MACH,MAAM,OAAO,CAAC,CAAC,CAAC,KACd,OAAO,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAStD;uBAnGa,CAAC,OAAO,SAAS,EAAE,2DAAkB,MAAM,CAAC;6BAE5C,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC"}
package/src/js-utils.js CHANGED
@@ -5,6 +5,21 @@
5
5
  * dependent upon a hardened environment.
6
6
  */
7
7
 
8
+ export const logLevels = /** @type {const} */ ([
9
+ 'debug',
10
+ 'log',
11
+ 'info',
12
+ 'warn',
13
+ 'error',
14
+ ]);
15
+ Object.freeze(logLevels);
16
+
17
+ /** @typedef {(typeof logLevels)[keyof logLevels & number]} LogLevel */
18
+
19
+ /** @typedef {Pick<Console, LogLevel>} LimitedConsole */
20
+
21
+ const { entries, fromEntries } = Object;
22
+
8
23
  /**
9
24
  * Deep-copy a value by round-tripping it through JSON (which drops
10
25
  * function/symbol/undefined values and properties that are non-enumerable
@@ -66,6 +81,18 @@ const deepMapObjectInternal = (value, name, container, mapper) => {
66
81
  export const deepMapObject = (obj, mapper) =>
67
82
  deepMapObjectInternal(obj, undefined, undefined, mapper);
68
83
 
84
+ /**
85
+ * @template {Record<PropertyKey, any>} O
86
+ * @template V
87
+ * @param {O} obj
88
+ * @param {<K extends keyof O>(value: O[K], key: K) => V} mapFn
89
+ * @returns {{ [K in keyof O]: V }}
90
+ */
91
+ export const objectMapMutable = (obj, mapFn) => {
92
+ const newEntries = entries(obj).map(([k, v]) => [k, mapFn(v, k)]);
93
+ return /** @type {{ [K in keyof O]: V }} */ (fromEntries(newEntries));
94
+ };
95
+
69
96
  /**
70
97
  * Returns a function that uses a millisecond-based current-time capability
71
98
  * (such as `performance.now`) to measure execution duration of an async
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @import {ExecutionContext, Macro, TestFn} from 'ava';
3
+ */
4
+ export const AVA_EXPECT_UNHANDLED_REJECTIONS: "AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS";
5
+ export const SUBTEST_PREFIX: "(unhandled rejection subprocess): ";
6
+ export function makeExpectUnhandledRejection<C>({ test, importMetaUrl }: {
7
+ test: TestFn<C>;
8
+ importMetaUrl: string;
9
+ }): (expectedUnhandled: number) => Macro<[name: string, impl: (t: ExecutionContext<C>) => any], C>;
10
+ import type { TestFn } from 'ava';
11
+ import type { ExecutionContext } from 'ava';
12
+ import type { Macro } from 'ava';
13
+ //# sourceMappingURL=ava-unhandled-rejection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ava-unhandled-rejection.d.ts","sourceRoot":"","sources":["ava-unhandled-rejection.js"],"names":[],"mappings":"AAOA;;GAEG;AAEH,8CACE,wCAAwC,CAAC;AAE3C,6BAA8B,oCAAoC,CAAC;AAW5D,6CARM,CAAC,2BAEX;IAA0B,IAAI,EAAtB,OAAO,CAAC,CAAC;IACM,aAAa,EAA5B,MAAM;CACd,GAAU,CACR,iBAAiB,EAAE,MAAM,KACtB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CA0CtE;4BAzDiD,KAAK;sCAAL,KAAK;2BAAL,KAAK"}
@@ -0,0 +1,66 @@
1
+ // @ts-check
2
+ import { spawn } from 'child_process';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ import engineGC from './engine-gc.js';
6
+ import { makeGcAndFinalize } from './gc-and-finalize.js';
7
+
8
+ /**
9
+ * @import {ExecutionContext, Macro, TestFn} from 'ava';
10
+ */
11
+
12
+ export const AVA_EXPECT_UNHANDLED_REJECTIONS =
13
+ 'AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS';
14
+
15
+ export const SUBTEST_PREFIX = '(unhandled rejection subprocess): ';
16
+
17
+ /**
18
+ * @template C
19
+ * @param {object} powers
20
+ * @param {TestFn<C>} powers.test
21
+ * @param {string} powers.importMetaUrl
22
+ * @returns {(
23
+ * expectedUnhandled: number,
24
+ * ) => Macro<[name: string, impl: (t: ExecutionContext<C>) => any], C>}
25
+ */
26
+ export const makeExpectUnhandledRejection = ({ test, importMetaUrl }) => {
27
+ const self = fileURLToPath(importMetaUrl);
28
+ const gcAndFinalize = makeGcAndFinalize(engineGC);
29
+
30
+ if (process.env[AVA_EXPECT_UNHANDLED_REJECTIONS]) {
31
+ return _expectedUnhandled =>
32
+ test.macro({
33
+ title: (_, name, _impl) => SUBTEST_PREFIX + name,
34
+ exec: async (t, _name, impl) => {
35
+ await null;
36
+ try {
37
+ const result = await impl(t);
38
+ return result;
39
+ } finally {
40
+ await gcAndFinalize();
41
+ }
42
+ },
43
+ });
44
+ }
45
+
46
+ return expectedUnhandled =>
47
+ test.macro({
48
+ title: (_, name, _impl) => name,
49
+ exec: async (t, name, _impl) =>
50
+ new Promise((resolve, reject) => {
51
+ const ps = spawn('ava', [self, '-m', SUBTEST_PREFIX + name], {
52
+ env: {
53
+ ...process.env,
54
+ [AVA_EXPECT_UNHANDLED_REJECTIONS]: `${expectedUnhandled}`,
55
+ },
56
+ stdio: ['ignore', 'inherit', 'inherit', 'ignore'],
57
+ });
58
+
59
+ ps.on('close', code => {
60
+ t.is(code, 0, `got exit code ${code}, expected 0 for ${name}`);
61
+ resolve();
62
+ });
63
+ ps.on('error', reject);
64
+ }),
65
+ });
66
+ };
@@ -0,0 +1,2 @@
1
+ export function naturalCompare(a: string, b: string): -1 | 0 | 1;
2
+ //# sourceMappingURL=natural-sort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"natural-sort.d.ts","sourceRoot":"","sources":["natural-sort.js"],"names":[],"mappings":"AAqCO,kCAJI,MAAM,KACN,MAAM,GACJ,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAWtB"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @param {string} a
3
+ * @param {string} b
4
+ * @returns {-1 | 0 | 1}
5
+ */
6
+ const compareNats = (a, b) => {
7
+ // Default to IEEE 754 number arithmetic for speed, but fall back on bigint
8
+ // arithmetic to resolve ties because big numbers can lose resolution
9
+ // (sometimes even becoming infinite) and then ultimately on length to resolve
10
+ // ties by ascending count of leading zeros.
11
+ const diff = +a - +b;
12
+ const finiteDiff =
13
+ (Number.isFinite(diff) && diff) ||
14
+ (a === b ? 0 : Number(BigInt(a) - BigInt(b)) || a.length - b.length);
15
+
16
+ // @ts-expect-error this call really does return -1 | 0 | 1
17
+ return Math.sign(finiteDiff);
18
+ };
19
+
20
+ // TODO: compareByCodePoints
21
+ // https://github.com/endojs/endo/pull/2008
22
+ // eslint-disable-next-line no-nested-ternary
23
+ const compareStrings = (a, b) => (a > b ? 1 : a < b ? -1 : 0);
24
+
25
+ const rPrefixedDigits = /^(\D*)(\d+)(\D.*|)/s;
26
+
27
+ /**
28
+ * Perform a single-level natural-sort comparison, finding the first decimal
29
+ * digit sequence in each operand and comparing first by the (possibly empty)
30
+ * preceding prefix as strings, then by the digits as integers, then by any
31
+ * following suffix (e.g., sorting 'ko42' before 'ko100' as ['ko', 42] vs.
32
+ * ['ko', 100]).
33
+ *
34
+ * @param {string} a
35
+ * @param {string} b
36
+ * @returns {-1 | 0 | 1}
37
+ */
38
+ export const naturalCompare = (a, b) => {
39
+ const [_a, aPrefix, aDigits, aSuffix] = rPrefixedDigits.exec(a) || [];
40
+ if (aPrefix !== undefined) {
41
+ const [_b, bPrefix, bDigits, bSuffix] = rPrefixedDigits.exec(b) || [];
42
+ if (bPrefix === aPrefix) {
43
+ return compareNats(aDigits, bDigits) || compareStrings(aSuffix, bSuffix);
44
+ }
45
+ }
46
+ return compareStrings(a, b);
47
+ };
48
+ harden(naturalCompare);
@@ -1 +1 @@
1
- {"version":3,"file":"fs-stream.d.ts","sourceRoot":"","sources":["fs-stream.js"],"names":[],"mappings":"AAUO,sCALI,OAAO,IAAI,EAAE,UAAU,GAC3B,OAAO,IAAI,EAAE,WAAW,GACxB,OAAO,KAAK,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAgCtB;AAQG,6CADK,MAAM,GAAG,SAAS,GAAG,IAAI;;;;eAqEpC;6BAtEa,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"fs-stream.d.ts","sourceRoot":"","sources":["fs-stream.js"],"names":[],"mappings":"AAUO,sCALI,OAAO,IAAI,EAAE,UAAU,GAC3B,OAAO,IAAI,EAAE,WAAW,GACxB,OAAO,KAAK,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAgCtB;AAIG,6CADK,MAAM,GAAG,SAAS,GAAG,IAAI;;;;eAwEpC;6BAzEa,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
- import { createWriteStream } from 'node:fs';
2
- import process from 'node:process';
3
1
  import { open } from 'node:fs/promises';
2
+ import process from 'node:process';
3
+ import { promisify } from 'node:util';
4
4
 
5
5
  /**
6
6
  * @param {import('fs').ReadStream
@@ -40,10 +40,6 @@ export const fsStreamReady = stream =>
40
40
  stream.on('error', onError);
41
41
  });
42
42
 
43
- const noPath = /** @type {import('fs').PathLike} */ (
44
- /** @type {unknown} */ (undefined)
45
- );
46
-
47
43
  /** @typedef {NonNullable<Awaited<ReturnType<typeof makeFsStreamWriter>>>} FsStreamWriter */
48
44
  /** @param {string | undefined | null} filePath */
49
45
  export const makeFsStreamWriter = async filePath => {
@@ -51,12 +47,22 @@ export const makeFsStreamWriter = async filePath => {
51
47
  return undefined;
52
48
  }
53
49
 
54
- const handle = await (filePath !== '-' ? open(filePath, 'a') : undefined);
55
-
56
- const stream = handle
57
- ? createWriteStream(noPath, { fd: handle.fd })
58
- : process.stdout;
50
+ const useStdout = filePath === '-';
51
+ const { handle, stream } = await (async () => {
52
+ if (useStdout) {
53
+ return { handle: undefined, stream: process.stdout };
54
+ }
55
+ const fh = await open(filePath, 'a');
56
+ return { handle: fh, stream: fh.createWriteStream({ flush: true }) };
57
+ })();
59
58
  await fsStreamReady(stream);
59
+ const writeAsync = promisify(stream.write.bind(stream));
60
+ const closeAsync =
61
+ useStdout || !(/** @type {any} */ (stream).close)
62
+ ? undefined
63
+ : promisify(
64
+ /** @type {import('fs').WriteStream} */ (stream).close.bind(stream),
65
+ );
60
66
 
61
67
  let flushed = Promise.resolve();
62
68
  let closed = false;
@@ -77,20 +83,14 @@ export const makeFsStreamWriter = async filePath => {
77
83
  };
78
84
 
79
85
  const write = async data => {
80
- /** @type {Promise<void>} */
81
86
  const written = closed
82
87
  ? Promise.reject(Error('Stream closed'))
83
- : new Promise((resolve, reject) => {
84
- stream.write(data, err => {
85
- if (err) {
86
- reject(err);
87
- } else {
88
- resolve();
89
- }
90
- });
91
- });
88
+ : writeAsync(data);
92
89
  updateFlushed(written);
93
- return written;
90
+ const waitForDrain = await written;
91
+ if (waitForDrain) {
92
+ await new Promise(resolve => stream.once('drain', resolve));
93
+ }
94
94
  };
95
95
 
96
96
  const flush = async () => {
@@ -107,8 +107,7 @@ export const makeFsStreamWriter = async filePath => {
107
107
  // TODO: Consider creating a single Error here to use a write rejection
108
108
  closed = true;
109
109
  await flush();
110
- // @ts-expect-error calling a possibly missing method
111
- stream.close?.();
110
+ await closeAsync?.();
112
111
  };
113
112
 
114
113
  stream.on('error', err => updateFlushed(Promise.reject(err)));
@@ -28,4 +28,5 @@ export function makePrioritySendersManager(sendersNode: ERef<import("./lib-chain
28
28
  remove: (rawNamespace: string, address: string) => Promise<void>;
29
29
  }>;
30
30
  export type PrioritySendersManager = ReturnType<typeof makePrioritySendersManager>;
31
+ import type { ERef } from '@endo/far';
31
32
  //# sourceMappingURL=priority-senders.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"priority-senders.d.ts","sourceRoot":"","sources":["priority-senders.js"],"names":[],"mappings":"AAKA,4CAA4C;AAC5C,uCADW,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAMtC;AAQK,wDAFI,IAAI,CAAC,OAAO,uBAAuB,EAAE,WAAW,CAAC;IA0CxD;;;;OAIG;wBAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;IAe1B;;;;OAIG;2BAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;;IArB1B;;;;OAIG;wBAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;IAe1B;;;;OAIG;2BAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;GAuB7B;qCAGa,UAAU,CAAC,OAAO,0BAA0B,CAAC"}
1
+ {"version":3,"file":"priority-senders.d.ts","sourceRoot":"","sources":["priority-senders.js"],"names":[],"mappings":"AAQA,4CAA4C;AAC5C,uCADW,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAMtC;AAQK,wDAFI,KAAK,OAAO,uBAAuB,EAAE,WAAW,CAAC;IA0CxD;;;;OAIG;wBAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;IAe1B;;;;OAIG;2BAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;;IArB1B;;;;OAIG;wBAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;IAe1B;;;;OAIG;2BAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;GAuB7B;qCAGa,UAAU,CAAC,OAAO,0BAA0B,CAAC;0BA1GnC,WAAW"}
@@ -1,6 +1,9 @@
1
1
  import { Fail, q } from '@endo/errors';
2
2
  import { E, Far } from '@endo/far';
3
3
 
4
+ /** @import {ERef} from '@endo/far'; */
5
+ /** @import {StorageNode} from './lib-chainStorage.js'; */
6
+
4
7
  const PRIORITY_SENDERS_NAMESPACE_RE = /^[a-zA-Z0-9_-]{1,50}$/;
5
8
 
6
9
  /** @type {(namespace: string) => string} */
package/src/queue.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export function makeWithQueue(): <T extends (...args: any[]) => any>(inner: T) => (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>;
1
+ export function makeWithQueue(): (inner: T) => (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>;
2
2
  //# sourceMappingURL=queue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"AAQO,kCAwBkC,CAAC,SAA3B,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAI,SAC3B,CAAC,eAIC,UAAU,CAAC,CAAC,CAAC,KACX,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAkB/C"}
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"AAQO,kCA2BqB,OAFf,CAEoB,MAKH,GAAG,MAHlB,UAAU,CAAC,CAAC,CAGU,KAFpB,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAkB/C"}
@@ -1,4 +1,4 @@
1
- /** @import {ERef} from '@endo/far' */
1
+ export function makeLimitedConsole(makeLogger: (level: string) => (...args: unknown[]) => void): LimitedConsole;
2
2
  /**
3
3
  * @template T
4
4
  * @typedef {{ [KeyType in keyof T]: T[KeyType] } & {}} Simplify flatten the
@@ -56,5 +56,6 @@ export type Callable = (...args: any[]) => any;
56
56
  export type DeeplyAwaitedObject<T extends {}> = { [K in keyof T]: T[K] extends Callable ? T[K] : DeeplyAwaited<T[K]>; };
57
57
  export type DeeplyAwaited<T> = T extends PromiseLike<any> ? Awaited<T> : T extends {} ? Simplify<DeeplyAwaitedObject<T>> : Awaited<T>;
58
58
  export type AllDefined<T extends Record<string, unknown>> = { [P in keyof T]: Exclude<T[P], undefined>; };
59
+ import type { LimitedConsole } from './js-utils.js';
59
60
  import type { ERef } from '@endo/far';
60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C,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAE;oCA3IvB,eAAe;0BAIzB,WAAW"}
package/src/ses-utils.js CHANGED
@@ -10,11 +10,23 @@ import { deeplyFulfilled, isObject } from '@endo/marshal';
10
10
  import { makePromiseKit } from '@endo/promise-kit';
11
11
  import { makeQueue } from '@endo/stream';
12
12
  import { asyncGenerate } from 'jessie.js';
13
+ import { logLevels } from './js-utils.js';
14
+
15
+ /** @import {LimitedConsole} from './js-utils.js'; */
13
16
 
14
17
  const { fromEntries, keys, values } = Object;
15
18
 
16
19
  /** @import {ERef} from '@endo/far' */
17
20
 
21
+ /** @param {(level: string) => (...args: unknown[]) => void} makeLogger */
22
+ export const makeLimitedConsole = makeLogger => {
23
+ const limitedConsole = /** @type {any} */ (
24
+ fromEntries(logLevels.map(level => [level, makeLogger(level)]))
25
+ );
26
+ return /** @type {LimitedConsole} */ (harden(limitedConsole));
27
+ };
28
+ harden(makeLimitedConsole);
29
+
18
30
  /**
19
31
  * @template T
20
32
  * @typedef {{ [KeyType in keyof T]: T[KeyType] } & {}} Simplify flatten the
@@ -24,15 +24,16 @@ export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<ty
24
24
  setValue(value: string): Promise<void>;
25
25
  }>;
26
26
  data: Map<string, string>;
27
+ updateNewCellBlockHeight: (blockHeight?: number) => void;
27
28
  getValues: (path: string) => string[];
28
29
  messages: StorageMessage[];
29
- toStorage: ((message: StorageMessage) => string | number | any[] | {
30
+ toStorage: ((message: StorageMessage) => string | number | true | any[] | {
30
31
  storeName: string;
31
32
  storeSubkey: string;
32
- } | null | undefined) & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (message: StorageMessage) => string | number | any[] | {
33
+ } | null) & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (message: StorageMessage) => string | number | true | any[] | {
33
34
  storeName: string;
34
35
  storeSubkey: string;
35
- } | null | undefined>;
36
+ } | null>;
36
37
  };
37
38
  export function makeMockChainStorageRoot(): MockChainStorageRoot;
38
39
  export function documentStorageSchema(t: import("ava").ExecutionContext<unknown>, storage: MockChainStorageRoot | FakeStorageKit, opts: ({
@@ -1 +1 @@
1
- {"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AAyBO,yCAHI,MAAM,UACN,MAAM,6GAGC;AAElB;;;GAGG;AACH;;;;;EAEG;;eAMU,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO;mBAEzB,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM;;AA8CjC,8CAtBuB,GAAG,KAAK,GAAG,CAsB+B;AAU1D,6CAHI,MAAM,gBACN,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;;oBAiG3C,CADT;;;;UA4BoB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;sBAd3B,MAAM,KACJ,MAAM,EAAE;;0BAnFP,cAAc;;;0JAAd,cAAc;;;;EAqG7B;AAoBM,4CADO,oBAAoB,CA6BjC;AAUM,yCAPI,OAAO,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,WACvC,oBAAoB,GAAG,cAAc,QACrC,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9D,CAAK;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,EAAE,CAAC,GAAG;IAChD,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CACpC,iBAkDL;6BAxGa,UAAU,CAAC,OAAO,kBAAkB,CAAC;;;;;;;;aAIrC,CACT,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,UAAU,EACvB,KAAK,CAAC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,MAAM,EAAE;;mCAEd,WAAW,GAAG,2BAA2B;qCAhQJ,uBAAuB;iCAOU,uBAAuB;oCAAvB,uBAAuB;gCAAvB,uBAAuB"}
@@ -11,7 +11,7 @@ import { eventLoopIteration } from './testing-utils.js';
11
11
 
12
12
  /**
13
13
  * @import {TotalMap} from './types.js';
14
- * @import {Marshaller, StorageEntry, StorageMessage, StorageNode} from './lib-chainStorage.js';
14
+ * @import {Marshaller, StorageEntry, StorageMessage, StorageNode, StreamCell} from './lib-chainStorage.js';
15
15
  */
16
16
 
17
17
  const trace = makeTracer('StorTU', false);
@@ -100,6 +100,14 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
100
100
  const resolvedOptions = { sequence: true, ...rootOptions };
101
101
  /** @type {TotalMap<string, string>} */
102
102
  const data = new Map();
103
+ let currentBlockHeight = 0;
104
+
105
+ const updateNewCellBlockHeight = (blockHeight = currentBlockHeight + 1) => {
106
+ blockHeight > currentBlockHeight ||
107
+ Fail`blockHeight ${blockHeight} must be greater than ${currentBlockHeight}`;
108
+ currentBlockHeight = blockHeight;
109
+ };
110
+
103
111
  /** @param {string} prefix */
104
112
  const getChildEntries = prefix => {
105
113
  assert(prefix.endsWith('.'));
@@ -158,7 +166,7 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
158
166
  data.delete(key);
159
167
  }
160
168
  }
161
- break;
169
+ return true;
162
170
  }
163
171
  case 'append': {
164
172
  trace('toStorage append', message);
@@ -166,8 +174,10 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
166
174
  const newEntries = message.args;
167
175
  for (const [key, value] of newEntries) {
168
176
  value != null || Fail`attempt to append with no value`;
169
- // In the absence of block boundaries, everything goes in a single StreamCell.
170
- const oldVal = data.get(key);
177
+
178
+ /** @type {string | undefined} */
179
+ let oldVal = data.get(key);
180
+ /** @type {StreamCell | undefined} */
171
181
  let streamCell;
172
182
  if (oldVal != null) {
173
183
  try {
@@ -176,17 +186,26 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
176
186
  } catch (_err) {
177
187
  streamCell = undefined;
178
188
  }
189
+ // StreamCells reset at block boundaries.
190
+ if (
191
+ streamCell &&
192
+ Number(streamCell.blockHeight) !== currentBlockHeight
193
+ ) {
194
+ streamCell = undefined;
195
+ oldVal = undefined;
196
+ }
179
197
  }
198
+
180
199
  if (streamCell === undefined) {
181
200
  streamCell = {
182
- blockHeight: '0',
201
+ blockHeight: String(currentBlockHeight),
183
202
  values: oldVal != null ? [oldVal] : [],
184
203
  };
185
204
  }
186
205
  streamCell.values.push(value);
187
206
  data.set(key, JSON.stringify(streamCell));
188
207
  }
189
- break;
208
+ return true;
190
209
  }
191
210
  case 'size':
192
211
  // Intentionally incorrect because it counts non-child descendants,
@@ -219,6 +238,7 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
219
238
  rootNode,
220
239
  // eslint-disable-next-line object-shorthand
221
240
  data: /** @type {Map<string, string>} */ (data),
241
+ updateNewCellBlockHeight,
222
242
  getValues,
223
243
  messages,
224
244
  toStorage,
package/src/tagged.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- /** @file adapted from https://raw.githubusercontent.com/sindresorhus/type-fest/main/source/opaque.d.ts */
1
+ /** @file adapted from https://raw.githubusercontent.com/sindresorhus/type-fest/main/source/tagged.d.ts */
2
+
3
+ // different name to avoid confusion with pass-style "tagged"
4
+ export { Tagged as TypeTag };
2
5
 
3
6
  declare const tag: unique symbol;
4
7
 
@@ -28,7 +28,7 @@ const stringOrTag = value => {
28
28
  };
29
29
  /**
30
30
  * @param {MapStore} store
31
- * @returns {object} tree of the contents of the storeÂ
31
+ * @returns {object} tree of the contents of the store
32
32
  */
33
33
  export const inspectMapStore = store => {
34
34
  /** @type {Record<string, unknown>} */
@@ -1,4 +1,19 @@
1
1
  export const StorageNodeShape: import("@endo/patterns").Matcher;
2
2
  /** To be used only for 'helper' facets where the calls are from trusted code. */
3
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}`;
4
19
  //# sourceMappingURL=typeGuards.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA,gEAA2D;AAE3D,iFAAiF;AACjF,4EAKE"}
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,4 +1,5 @@
1
1
  // @jessie-check
2
+ // @ts-check
2
3
 
3
4
  import { M } from '@endo/patterns';
4
5
 
@@ -11,3 +12,14 @@ export const UnguardedHelperI = M.interface(
11
12
  // not exposed so sloppy okay
12
13
  { sloppy: true },
13
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());