@agoric/internal 0.4.0-u17.1 → 0.4.0-u18.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/README.md +4 -4
- package/package.json +17 -16
- package/src/action-types.d.ts +49 -5
- package/src/action-types.d.ts.map +1 -1
- package/src/action-types.js +72 -14
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/callback.d.ts +1 -1
- package/src/callback.d.ts.map +1 -1
- package/src/chain-storage-paths.d.ts.map +1 -1
- package/src/chain-utils.d.ts +25 -0
- package/src/chain-utils.d.ts.map +1 -0
- package/src/chain-utils.js +57 -0
- package/src/config.d.ts +4 -1
- package/src/config.d.ts.map +1 -1
- package/src/config.js +2 -1
- package/src/errors.d.ts +1 -1
- package/src/errors.d.ts.map +1 -1
- package/src/index.d.ts +4 -2
- package/src/index.js +4 -2
- package/src/js-utils.d.ts +7 -0
- package/src/js-utils.d.ts.map +1 -0
- package/src/js-utils.js +89 -0
- package/src/lib-chainStorage.d.ts +1 -23
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +5 -2
- package/src/lib-nodejs/engine-gc.d.ts +1 -1
- package/src/lib-nodejs/worker-protocol.js +1 -1
- package/src/marshal.d.ts +8 -2
- package/src/marshal.d.ts.map +1 -1
- package/src/marshal.js +7 -0
- package/src/netstring.d.ts +2 -2
- package/src/netstring.d.ts.map +1 -1
- package/src/netstring.js +2 -1
- package/src/node/buffer-line-transform.d.ts +3 -3
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/buffer-line-transform.js +1 -1
- package/src/node/createBundles.js +1 -1
- package/src/node/fs-stream.d.ts +1 -1
- package/src/node/fs-stream.d.ts.map +1 -1
- package/src/node/fs-stream.js +42 -29
- package/src/node/shutdown.d.ts.map +1 -1
- package/src/node/shutdown.js +0 -1
- package/src/{utils.d.ts → ses-utils.d.ts} +1 -7
- package/src/ses-utils.d.ts.map +1 -0
- package/src/{utils.js → ses-utils.js} +8 -72
- package/src/storage-test-utils.d.ts +14 -4
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +128 -79
- package/src/tokens.d.ts.map +1 -1
- package/src/types-index.d.ts +1 -0
- package/src/types.d.ts +25 -59
- package/src/types.d.ts.map +1 -0
- package/src/types.ts +108 -0
- package/src/upgrade-api.d.ts +1 -0
- package/src/upgrade-api.d.ts.map +1 -1
- package/src/upgrade-api.js +25 -1
- package/src/utils.d.ts.map +0 -1
- /package/src/{types.js → types-index.js} +0 -0
package/src/marshal.d.ts
CHANGED
|
@@ -3,13 +3,19 @@ export function makeBoardRemote({ boardId, iface }: {
|
|
|
3
3
|
iface?: string;
|
|
4
4
|
}): BoardRemote;
|
|
5
5
|
export function slotToBoardRemote(boardId: string, iface: string): BoardRemote;
|
|
6
|
-
export function boardSlottingMarshaller(slotToVal?: (
|
|
6
|
+
export function boardSlottingMarshaller(slotToVal?: (slot: string, iface: string) => any): Omit<import("@endo/marshal").Marshal<string | null>, "serialize" | "unserialize">;
|
|
7
7
|
export function unmarshalFromVstorage(data: Map<string, string>, key: string, fromCapData: ReturnType<typeof import("@endo/marshal").makeMarshal>["fromCapData"], index: number): any;
|
|
8
|
-
export function makeHistoryReviver(entries: [string, string][], slotToVal?: (
|
|
8
|
+
export function makeHistoryReviver(entries: [string, string][], slotToVal?: (slot: string, iface?: string) => any): {
|
|
9
9
|
getItem: (key: string) => any;
|
|
10
10
|
children: (prefix: string) => string[];
|
|
11
11
|
has: (k: string) => boolean;
|
|
12
12
|
};
|
|
13
|
+
export const pureDataMarshaller: {
|
|
14
|
+
toCapData: import("@endo/marshal").ToCapData<import("@endo/marshal").CapData<unknown>>;
|
|
15
|
+
fromCapData: import("@endo/marshal").FromCapData<import("@endo/marshal").CapData<unknown>>;
|
|
16
|
+
serialize: import("@endo/marshal").ToCapData<import("@endo/marshal").CapData<unknown>>;
|
|
17
|
+
unserialize: import("@endo/marshal").FromCapData<import("@endo/marshal").CapData<unknown>>;
|
|
18
|
+
};
|
|
13
19
|
/**
|
|
14
20
|
* Should be a union with Remotable, but that's `any`, making this type
|
|
15
21
|
* meaningless
|
package/src/marshal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marshal.d.ts","sourceRoot":"","sources":["marshal.js"],"names":[],"mappings":"AAiBO,oDAHI;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC,WAAW,CAKvB;AAMM,2CAHI,MAAM,SACN,MAAM,eAGoB;AAqB9B,
|
|
1
|
+
{"version":3,"file":"marshal.d.ts","sourceRoot":"","sources":["marshal.js"],"names":[],"mappings":"AAiBO,oDAHI;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC,WAAW,CAKvB;AAMM,2CAHI,MAAM,SACN,MAAM,eAGoB;AAqB9B,oDANI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,GAClC,IAAI,CAChB,OAAW,eAAe,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAClD,WAAe,GAAG,aAAa,CAC5B,CAMH;AA6BM,4CATI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OACnB,MAAM,eACN,UAAU,CACpB,cAAkB,eAAe,EAAE,WAAW,CAC3C,CAAC,aAAa,CAAC,SACR,MAAM,GAEJ,GAAG,CAwBf;AASM,4CAHI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,cAClB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,GAAG;mBAQlC,MAAM;uBAEN,MAAM;aAYN,MAAM;EAInB;AAID;;;;;EAEG;;;;;0BApIU;IAAE,UAAU,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;CAAE"}
|
package/src/marshal.js
CHANGED
|
@@ -135,3 +135,10 @@ export const makeHistoryReviver = (entries, slotToVal = undefined) => {
|
|
|
135
135
|
|
|
136
136
|
return harden({ getItem, children, has });
|
|
137
137
|
};
|
|
138
|
+
|
|
139
|
+
/** @param {import('@endo/marshal').CapData<unknown>} cap */
|
|
140
|
+
const rejectOCap = cap => Fail`${cap} is not pure data`;
|
|
141
|
+
export const pureDataMarshaller = makeMarshal(rejectOCap, rejectOCap, {
|
|
142
|
+
serializeBodyFormat: 'smallcaps',
|
|
143
|
+
});
|
|
144
|
+
harden(pureDataMarshaller);
|
package/src/netstring.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export function netstringEncoderStream(): Transform;
|
|
|
11
11
|
* @returns {{ leftover: Buffer; payloads: Buffer[] }} zero or more decoded
|
|
12
12
|
* Buffers, one per netstring,
|
|
13
13
|
*/
|
|
14
|
-
export function decode(data: Buffer, optMaxChunkSize?: number
|
|
14
|
+
export function decode(data: Buffer, optMaxChunkSize?: number): {
|
|
15
15
|
leftover: Buffer;
|
|
16
16
|
payloads: Buffer[];
|
|
17
17
|
};
|
|
@@ -19,6 +19,6 @@ export function decode(data: Buffer, optMaxChunkSize?: number | undefined): {
|
|
|
19
19
|
* @param {number} [optMaxChunkSize]
|
|
20
20
|
* @returns {Transform}
|
|
21
21
|
*/
|
|
22
|
-
export function netstringDecoderStream(optMaxChunkSize?: number
|
|
22
|
+
export function netstringDecoderStream(optMaxChunkSize?: number): Transform;
|
|
23
23
|
import { Transform } from 'stream';
|
|
24
24
|
//# sourceMappingURL=netstring.d.ts.map
|
package/src/netstring.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"netstring.d.ts","sourceRoot":"","sources":["netstring.js"],"names":[],"mappings":"AASA;;;GAGG;AACH,6BAHW,MAAM,GACJ,MAAM,CAMlB;AAGD,oDAsBC;AAED;;;;;;GAMG;AACH,6BANW,MAAM,
|
|
1
|
+
{"version":3,"file":"netstring.d.ts","sourceRoot":"","sources":["netstring.js"],"names":[],"mappings":"AASA;;;GAGG;AACH,6BAHW,MAAM,GACJ,MAAM,CAMlB;AAGD,oDAsBC;AAED;;;;;;GAMG;AACH,6BANW,MAAM,oBAEN,MAAM,GACJ;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAmCpD;AAED;;;GAGG;AAEH,yDAJW,MAAM,GACJ,SAAS,CAqCrB;0BAxHyB,QAAQ"}
|
package/src/netstring.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* eslint-env node */
|
|
2
2
|
import { Fail } from '@endo/errors';
|
|
3
3
|
|
|
4
4
|
// adapted from 'netstring-stream', https://github.com/tlivings/netstring-stream/
|
|
@@ -89,6 +89,7 @@ export function decode(data, optMaxChunkSize) {
|
|
|
89
89
|
*/
|
|
90
90
|
// input is a byte pipe, output is a sequence of Buffers
|
|
91
91
|
export function netstringDecoderStream(optMaxChunkSize) {
|
|
92
|
+
/** @type {Buffer<ArrayBufferLike>} */
|
|
92
93
|
let buffered = Buffer.from('');
|
|
93
94
|
/**
|
|
94
95
|
* @param {Buffer} chunk
|
|
@@ -13,8 +13,8 @@ export default class BufferLineTransform extends Transform {
|
|
|
13
13
|
* @param {import('node:stream').TransformOptions &
|
|
14
14
|
* BufferLineTransformOptions} [options]
|
|
15
15
|
*/
|
|
16
|
-
constructor(options?:
|
|
17
|
-
_breakValue: string | number | Buffer
|
|
16
|
+
constructor(options?: import("node:stream").TransformOptions & BufferLineTransformOptions);
|
|
17
|
+
_breakValue: string | number | Buffer<ArrayBufferLike>;
|
|
18
18
|
_breakEncoding: BufferEncoding | undefined;
|
|
19
19
|
_breakLength: number;
|
|
20
20
|
/** @type {Buffer[]} */
|
|
@@ -34,7 +34,7 @@ export type BufferLineTransformOptions = {
|
|
|
34
34
|
* line break matcher for
|
|
35
35
|
* Buffer.indexOf() (default: 10)
|
|
36
36
|
*/
|
|
37
|
-
break?: string | number | Buffer | undefined;
|
|
37
|
+
break?: string | number | Buffer<ArrayBufferLike> | undefined;
|
|
38
38
|
/**
|
|
39
39
|
* if break is a string, the encoding
|
|
40
40
|
* to use
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-line-transform.d.ts","sourceRoot":"","sources":["buffer-line-transform.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;IACE;;;;;;OAMG;IACH,
|
|
1
|
+
{"version":3,"file":"buffer-line-transform.d.ts","sourceRoot":"","sources":["buffer-line-transform.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;IACE;;;;;;OAMG;IACH,sBAHW,OAAO,aAAa,EAAE,gBAAgB,GAC5C,0BAA0B,EAyB9B;IAhBC,uDAAmC;IACnC,2CAAmC;IAWnC,qBAA+B;IAE/B,uBAAuB;IACvB,SADW,MAAM,EAAE,CACF;IAGnB;;;;;OAKG;IACH,2BALW,GAAG,YACH,cAAc,GAAG,QAAQ,MACzB,OAAO,aAAa,EAAE,iBAAiB,QAiDjD;IAeD,2BAA2B;IAC3B,iBADY,MAAM,QAOjB;CACF;;;;;;;;;;;;;0BAtHyB,aAAa"}
|
package/src/node/fs-stream.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function fsStreamReady(stream: import("fs").ReadStream | import("fs").WriteStream): Promise<void>;
|
|
1
|
+
export function fsStreamReady(stream: import("fs").ReadStream | import("fs").WriteStream | import("net").Socket): Promise<void>;
|
|
2
2
|
export function makeFsStreamWriter(filePath: string | undefined | null): Promise<{
|
|
3
3
|
write: (data: any) => Promise<void>;
|
|
4
4
|
flush: () => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-stream.d.ts","sourceRoot":"","sources":["fs-stream.js"],"names":[],"mappings":"
|
|
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"}
|
package/src/node/fs-stream.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { createWriteStream } from 'node:fs';
|
|
2
|
+
import process from 'node:process';
|
|
2
3
|
import { open } from 'node:fs/promises';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* @param {import('fs').ReadStream
|
|
6
|
+
* @param {import('fs').ReadStream
|
|
7
|
+
* | import('fs').WriteStream
|
|
8
|
+
* | import('net').Socket} stream
|
|
6
9
|
* @returns {Promise<void>}
|
|
7
10
|
*/
|
|
8
11
|
export const fsStreamReady = stream =>
|
|
@@ -18,13 +21,13 @@ export const fsStreamReady = stream =>
|
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
const onReady = () => {
|
|
21
|
-
cleanup();
|
|
24
|
+
cleanup();
|
|
22
25
|
resolve();
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
/** @param {Error} err */
|
|
26
29
|
const onError = err => {
|
|
27
|
-
cleanup();
|
|
30
|
+
cleanup();
|
|
28
31
|
reject(err);
|
|
29
32
|
};
|
|
30
33
|
|
|
@@ -48,45 +51,51 @@ export const makeFsStreamWriter = async filePath => {
|
|
|
48
51
|
return undefined;
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
const handle = await open(filePath, 'a');
|
|
54
|
+
const handle = await (filePath !== '-' ? open(filePath, 'a') : undefined);
|
|
52
55
|
|
|
53
|
-
const stream =
|
|
56
|
+
const stream = handle
|
|
57
|
+
? createWriteStream(noPath, { fd: handle.fd })
|
|
58
|
+
: process.stdout;
|
|
54
59
|
await fsStreamReady(stream);
|
|
55
60
|
|
|
56
61
|
let flushed = Promise.resolve();
|
|
57
62
|
let closed = false;
|
|
58
63
|
|
|
59
|
-
const
|
|
60
|
-
if (closed) {
|
|
61
|
-
throw Error('Stream closed');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** @type {Promise<void>} */
|
|
65
|
-
const written = new Promise((resolve, reject) => {
|
|
66
|
-
stream.write(data, err => {
|
|
67
|
-
if (err) {
|
|
68
|
-
reject(err);
|
|
69
|
-
} else {
|
|
70
|
-
resolve();
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
});
|
|
64
|
+
const updateFlushed = p => {
|
|
74
65
|
flushed = flushed.then(
|
|
75
|
-
() =>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
66
|
+
() => p,
|
|
67
|
+
err =>
|
|
68
|
+
p.then(
|
|
69
|
+
() => Promise.reject(err),
|
|
70
|
+
pError =>
|
|
71
|
+
Promise.reject(
|
|
72
|
+
pError !== err ? AggregateError([err, pError]) : err,
|
|
73
|
+
),
|
|
82
74
|
),
|
|
83
75
|
);
|
|
76
|
+
flushed.catch(() => {});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const write = async data => {
|
|
80
|
+
/** @type {Promise<void>} */
|
|
81
|
+
const written = closed
|
|
82
|
+
? 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
|
+
});
|
|
92
|
+
updateFlushed(written);
|
|
84
93
|
return written;
|
|
85
94
|
};
|
|
86
95
|
|
|
87
96
|
const flush = async () => {
|
|
88
97
|
await flushed;
|
|
89
|
-
await handle
|
|
98
|
+
await handle?.sync().catch(err => {
|
|
90
99
|
if (err.code === 'EINVAL') {
|
|
91
100
|
return;
|
|
92
101
|
}
|
|
@@ -95,10 +104,14 @@ export const makeFsStreamWriter = async filePath => {
|
|
|
95
104
|
};
|
|
96
105
|
|
|
97
106
|
const close = async () => {
|
|
107
|
+
// TODO: Consider creating a single Error here to use a write rejection
|
|
98
108
|
closed = true;
|
|
99
109
|
await flush();
|
|
100
|
-
|
|
110
|
+
// @ts-expect-error calling a possibly missing method
|
|
111
|
+
stream.close?.();
|
|
101
112
|
};
|
|
102
113
|
|
|
114
|
+
stream.on('error', err => updateFlushed(Promise.reject(err)));
|
|
115
|
+
|
|
103
116
|
return harden({ write, flush, close });
|
|
104
117
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["shutdown.js"],"names":[],"mappings":"AAKO;;
|
|
1
|
+
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["shutdown.js"],"names":[],"mappings":"AAKO;;EA8DN;AAGM,wDAON"}
|
package/src/node/shutdown.js
CHANGED
|
@@ -22,7 +22,6 @@ export const makeFreshShutdown = (verbose = true) => {
|
|
|
22
22
|
process.off('SIGINT', shutdown);
|
|
23
23
|
process.off('SIGTERM', shutdown);
|
|
24
24
|
process.off('beforeExit', shutdown);
|
|
25
|
-
// eslint-disable-next-line no-use-before-define
|
|
26
25
|
process.off('uncaughtException', uncaughtShutdown);
|
|
27
26
|
verbose && console.error(`Shutting down cleanly...`);
|
|
28
27
|
const shutdowners = [...shutdownThunks.keys()];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export const BASIS_POINTS: 10000n;
|
|
2
1
|
/** @import {ERef} from '@endo/far' */
|
|
3
2
|
/**
|
|
4
3
|
* @template T
|
|
@@ -31,14 +30,9 @@ export const BASIS_POINTS: 10000n;
|
|
|
31
30
|
* @type {<T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>}
|
|
32
31
|
*/
|
|
33
32
|
export const deeplyFulfilledObject: <T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>;
|
|
34
|
-
export function deepMapObject(obj: object, mapper: (value: any, name: string, record: object) => any): object;
|
|
35
33
|
export function PromiseAllOrErrors<T>(items: readonly (T | PromiseLike<T>)[]): Promise<T[]>;
|
|
36
34
|
export function aggregateTryFinally<T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<unknown>): ReturnType<() => Promise<T>>;
|
|
37
35
|
export function withDeferredCleanup<T>(fn: (addCleanup: (fn: (err?: unknown) => Promise<void>) => void) => Promise<T>): ReturnType<(addCleanup: (fn: (err?: unknown) => Promise<void>) => void) => Promise<T>>;
|
|
38
|
-
export function makeMeasureSeconds(currentTimeMillisec: typeof import("perf_hooks").performance.now): <T>(fn: () => Promise<T>) => Promise<{
|
|
39
|
-
result: T;
|
|
40
|
-
duration: number;
|
|
41
|
-
}>;
|
|
42
36
|
export function assertAllDefined<T extends Record<string, unknown>>(obj: T): asserts obj is AllDefined<T>;
|
|
43
37
|
export const forever: AsyncIterable<undefined>;
|
|
44
38
|
export function whileTrue<T>(produce: () => T): AsyncIterable<Awaited<T>>;
|
|
@@ -63,4 +57,4 @@ export type DeeplyAwaitedObject<T extends {}> = { [K in keyof T]: T[K] extends C
|
|
|
63
57
|
export type DeeplyAwaited<T> = T extends PromiseLike<any> ? Awaited<T> : T extends {} ? Simplify<DeeplyAwaitedObject<T>> : Awaited<T>;
|
|
64
58
|
export type AllDefined<T extends Record<string, unknown>> = { [P in keyof T]: Exclude<T[P], undefined>; };
|
|
65
59
|
import type { ERef } from '@endo/far';
|
|
66
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
60
|
+
//# sourceMappingURL=ses-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ses-utils.d.ts","sourceRoot":"","sources":["ses-utils.js"],"names":[],"mappings":"AAeA,sCAAsC;AAEtC;;;;;GAKG;AAEH;;GAEG;AAEH;;;;;GAKG;AAEH;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,oCAFU,CAAC,CAAC,SAAS,EAAE,EAAE,gBAAgB,EAAE,CAAC,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAKxE;AAsBK,mCAJM,CAAC,SACH,SAAS,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,GAC7B,OAAO,CAAC,CAAC,EAAE,CAAC,CAiBxB;AAQM,oCALM,CAAC,SACH,MAAM,OAAO,CAAC,CAAC,CAAC,aAChB,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GACnC,UAAU,OAFN,OAAO,CAAC,CAAC,CAAC,CAEG,CAY3B;AAWI,oCANM,CAAC,MACH,CACN,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,KACvD,OAAO,CAAC,CAAC,CAAC,GACL,UAAU,cAFN,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,KACvD,OAAO,CAAC,CAAC,CAAC,CACS,CAmB1B;AAgBM,iCALgC,CAAC,SAA1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE,OAC3B,CAAC,GACC,QAAQ,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAaxC;AAQD,+CAAoD;AAS7C,0BANM,CAAC,WACH,MAAM,CAAC,GAGL,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAYlC;AASG,0BANM,CAAC,WACH,MAAM,CAAC,GAGL,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAelC;AAEJ,mDAAmD;AACnD,kBADW,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CACsB;AAErE;;;;GAIG;AACH,wBAJU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,EACzC,GAAG,EAAE,CAAC,KACH,OAAO,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAE,CAAC,CAMhD;AAWK,gCAJO,CAAC,0BACJ,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,eAC5B,MAAM,mCA8GhB;;;;;;qBAvUY,CAAC,IACD,GAAG,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAE,GAAG,EAAE;uBAMzC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;gCAIlB,CAAC,SAAN,EAAI,IACJ,GACP,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACnE;0BAIS,CAAC,IACD,CAAC,SAAS,WAAW,CAAC,GAAG,CAAC,GAC9B,OAAO,CAAC,CAAC,CAAC,GACV,CAAC,SAAS,EAAE,GACV,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,GAChC,OAAO,CAAC,CAAC,CAAC;uBAmGkB,CAAC,SAA1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE,IACzB,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAE;0BA9HjC,WAAW"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
// @jessie-check
|
|
3
|
+
/**
|
|
4
|
+
* @file Utility functions that are dependent upon a hardened environment,
|
|
5
|
+
* either directly or indirectly (e.g. by @endo imports).
|
|
6
|
+
*/
|
|
3
7
|
|
|
4
8
|
import { q, Fail, makeError, annotateError, X } from '@endo/errors';
|
|
5
9
|
import { deeplyFulfilled, isObject } from '@endo/marshal';
|
|
@@ -9,8 +13,6 @@ import { asyncGenerate } from 'jessie.js';
|
|
|
9
13
|
|
|
10
14
|
const { fromEntries, keys, values } = Object;
|
|
11
15
|
|
|
12
|
-
export const BASIS_POINTS = 10_000n;
|
|
13
|
-
|
|
14
16
|
/** @import {ERef} from '@endo/far' */
|
|
15
17
|
|
|
16
18
|
/**
|
|
@@ -52,55 +54,6 @@ export const deeplyFulfilledObject = async obj => {
|
|
|
52
54
|
return deeplyFulfilled(obj);
|
|
53
55
|
};
|
|
54
56
|
|
|
55
|
-
/**
|
|
56
|
-
* @param {any} value
|
|
57
|
-
* @param {string | undefined} name
|
|
58
|
-
* @param {object | undefined} container
|
|
59
|
-
* @param {(value: any, name: string, record: object) => any} mapper
|
|
60
|
-
* @returns {any}
|
|
61
|
-
*/
|
|
62
|
-
const deepMapObjectInternal = (value, name, container, mapper) => {
|
|
63
|
-
if (container && typeof name === 'string') {
|
|
64
|
-
const mapped = mapper(value, name, container);
|
|
65
|
-
if (mapped !== value) {
|
|
66
|
-
return mapped;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (typeof value !== 'object' || !value) {
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
let wasMapped = false;
|
|
75
|
-
const mappedEntries = Object.entries(value).map(([innerName, innerValue]) => {
|
|
76
|
-
const mappedInnerValue = deepMapObjectInternal(
|
|
77
|
-
innerValue,
|
|
78
|
-
innerName,
|
|
79
|
-
value,
|
|
80
|
-
mapper,
|
|
81
|
-
);
|
|
82
|
-
wasMapped ||= mappedInnerValue !== innerValue;
|
|
83
|
-
return [innerName, mappedInnerValue];
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
return wasMapped ? Object.fromEntries(mappedEntries) : value;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Traverses a record object structure deeply, calling a replacer for each
|
|
91
|
-
* enumerable string property values of an object. If none of the values are
|
|
92
|
-
* changed, the original object is used as-is, maintaining its identity.
|
|
93
|
-
*
|
|
94
|
-
* When an object is found as a property value, the replacer is first called on
|
|
95
|
-
* it. If not replaced, the object is then traversed.
|
|
96
|
-
*
|
|
97
|
-
* @param {object} obj
|
|
98
|
-
* @param {(value: any, name: string, record: object) => any} mapper
|
|
99
|
-
* @returns {object}
|
|
100
|
-
*/
|
|
101
|
-
export const deepMapObject = (obj, mapper) =>
|
|
102
|
-
deepMapObjectInternal(obj, undefined, undefined, mapper);
|
|
103
|
-
|
|
104
57
|
/**
|
|
105
58
|
* Tolerate absence of AggregateError in e.g. xsnap.
|
|
106
59
|
*
|
|
@@ -184,27 +137,6 @@ export const withDeferredCleanup = async fn => {
|
|
|
184
137
|
return aggregateTryFinally(() => fn(addCleanup), finalizer);
|
|
185
138
|
};
|
|
186
139
|
|
|
187
|
-
/**
|
|
188
|
-
* Returns a function that uses a millisecond-based time-since-epoch capability
|
|
189
|
-
* (such as `performance.now`) to measure execution time of an async function
|
|
190
|
-
* and report the result in seconds to match our telemetry standard.
|
|
191
|
-
*
|
|
192
|
-
* @param {typeof import('perf_hooks').performance.now} currentTimeMillisec
|
|
193
|
-
* @returns {<T>(
|
|
194
|
-
* fn: () => Promise<T>,
|
|
195
|
-
* ) => Promise<{ result: T; duration: number }>}
|
|
196
|
-
*/
|
|
197
|
-
export const makeMeasureSeconds = currentTimeMillisec => {
|
|
198
|
-
/** @param {() => any} fn */
|
|
199
|
-
const measureSeconds = async fn => {
|
|
200
|
-
const t0 = currentTimeMillisec();
|
|
201
|
-
const result = await fn();
|
|
202
|
-
const durationMillisec = currentTimeMillisec() - t0;
|
|
203
|
-
return { result, duration: durationMillisec / 1000 };
|
|
204
|
-
};
|
|
205
|
-
return measureSeconds;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
140
|
/**
|
|
209
141
|
* @template {Record<string, unknown>} T
|
|
210
142
|
* @typedef {{ [P in keyof T]: Exclude<T[P], undefined> }} AllDefined
|
|
@@ -401,6 +333,10 @@ export const synchronizedTee = (sourceStream, readerCount) => {
|
|
|
401
333
|
[Symbol.asyncIterator]() {
|
|
402
334
|
return reader;
|
|
403
335
|
},
|
|
336
|
+
// eslint-disable-next-line no-restricted-globals
|
|
337
|
+
async [Symbol.asyncDispose]() {
|
|
338
|
+
await reader.return();
|
|
339
|
+
},
|
|
404
340
|
});
|
|
405
341
|
return reader;
|
|
406
342
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function slotToRemotable(_slotId: string, iface?: string): import("@endo/
|
|
1
|
+
export function slotToRemotable(_slotId: string, iface?: string): import("@endo/pass-style").RemotableObject<string> & import("@endo/eventual-send").RemotableBrand<{}, {}>;
|
|
2
2
|
/**
|
|
3
3
|
* A basic marshaller whose unserializer produces Remotables. It can only
|
|
4
4
|
* serialize plain data, not Remotables.
|
|
@@ -9,6 +9,10 @@ export const defaultMarshaller: {
|
|
|
9
9
|
serialize: import("@endo/marshal").ToCapData<string>;
|
|
10
10
|
unserialize: import("@endo/marshal").FromCapData<string>;
|
|
11
11
|
};
|
|
12
|
+
export namespace defaultSerializer {
|
|
13
|
+
let parse: (text: string) => unknown;
|
|
14
|
+
let stringify: (obj: any) => string;
|
|
15
|
+
}
|
|
12
16
|
export const slotStringUnserialize: (capData: any) => any;
|
|
13
17
|
export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<typeof makeChainStorageRoot>[2]): {
|
|
14
18
|
rootNode: import("@endo/exo").Guarded<{
|
|
@@ -20,11 +24,15 @@ export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<ty
|
|
|
20
24
|
setValue(value: string): Promise<void>;
|
|
21
25
|
}>;
|
|
22
26
|
data: Map<string, string>;
|
|
27
|
+
getValues: (path: string) => string[];
|
|
23
28
|
messages: StorageMessage[];
|
|
24
|
-
toStorage: (message: StorageMessage) => string | number | any[] | {
|
|
29
|
+
toStorage: ((message: StorageMessage) => string | number | any[] | {
|
|
25
30
|
storeName: string;
|
|
26
31
|
storeSubkey: string;
|
|
27
|
-
} | null | undefined
|
|
32
|
+
} | null | undefined) & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (message: StorageMessage) => string | number | any[] | {
|
|
33
|
+
storeName: string;
|
|
34
|
+
storeSubkey: string;
|
|
35
|
+
} | null | undefined>;
|
|
28
36
|
};
|
|
29
37
|
export function makeMockChainStorageRoot(): MockChainStorageRoot;
|
|
30
38
|
export function documentStorageSchema(t: import("ava").ExecutionContext<unknown>, storage: MockChainStorageRoot | FakeStorageKit, opts: ({
|
|
@@ -35,7 +43,9 @@ export function documentStorageSchema(t: import("ava").ExecutionContext<unknown>
|
|
|
35
43
|
}) & ({
|
|
36
44
|
pattern: string;
|
|
37
45
|
replacement: string;
|
|
38
|
-
} | {})
|
|
46
|
+
} | {}) & {
|
|
47
|
+
showValue?: (v: string) => unknown;
|
|
48
|
+
}): Promise<void>;
|
|
39
49
|
export type FakeStorageKit = ReturnType<typeof makeFakeStorageKit>;
|
|
40
50
|
export type MockChainStorageRootMethods = {
|
|
41
51
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"
|
|
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,EAAE,MAAM,KACX,OAAO;UAKD,MAAM,MAAM,EAAE;;mCAEd,WAAW,GAAG,2BAA2B;qCA5OJ,uBAAuB;iCAOF,uBAAuB;oCAAvB,uBAAuB;gCAAvB,uBAAuB"}
|