@agoric/internal 0.3.3-dev-6c8bf5c.0 → 0.3.3-dev-35d20eb.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.
- package/package.json +4 -4
- package/src/batched-deliver.d.ts +4 -1
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/batched-deliver.js +4 -1
- package/src/callback.d.ts.map +1 -1
- package/src/callback.js +24 -22
- package/src/chain-storage-paths.d.ts +2 -3
- package/src/chain-storage-paths.d.ts.map +1 -1
- package/src/chain-storage-paths.js +2 -3
- package/src/config.d.ts.map +1 -1
- package/src/config.js +6 -4
- package/src/lib-chainStorage.d.ts +26 -11
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +69 -35
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -1
- package/src/lib-nodejs/spawnSubprocessWorker.js +7 -5
- package/src/lib-nodejs/worker-protocol.d.ts.map +1 -1
- package/src/lib-nodejs/worker-protocol.js +5 -7
- package/src/magic-cookie-test-only.js +2 -2
- package/src/marshal.d.ts +3 -2
- package/src/marshal.d.ts.map +1 -1
- package/src/marshal.js +18 -12
- package/src/method-tools.d.ts.map +1 -1
- package/src/method-tools.js +17 -16
- package/src/netstring.d.ts +4 -5
- package/src/netstring.d.ts.map +1 -1
- package/src/netstring.js +8 -11
- package/src/node/buffer-line-transform.d.ts +15 -10
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/buffer-line-transform.js +11 -8
- package/src/node/fs-stream.js +1 -1
- package/src/priority-senders.d.ts.map +1 -1
- package/src/priority-senders.js +7 -3
- package/src/queue.js +2 -2
- package/src/storage-test-utils.d.ts +8 -8
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +43 -33
- package/src/testing-utils.d.ts.map +1 -1
- package/src/testing-utils.js +7 -5
- package/src/upgrade-api.d.ts +2 -2
- package/src/upgrade-api.d.ts.map +1 -1
- package/src/upgrade-api.js +8 -8
- package/src/utils.d.ts +24 -14
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +50 -29
package/src/marshal.js
CHANGED
|
@@ -6,13 +6,14 @@ import { isStreamCell } from './lib-chainStorage.js';
|
|
|
6
6
|
const { Fail } = assert;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Should be a union with Remotable, but that's `any`, making this type
|
|
9
|
+
* Should be a union with Remotable, but that's `any`, making this type
|
|
10
|
+
* meaningless
|
|
10
11
|
*
|
|
11
12
|
* @typedef {{ getBoardId: () => string | null }} BoardRemote
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
|
-
* @param {{ boardId: string | null
|
|
16
|
+
* @param {{ boardId: string | null; iface?: string }} slotInfo
|
|
16
17
|
* @returns {BoardRemote}
|
|
17
18
|
*/
|
|
18
19
|
export const makeBoardRemote = ({ boardId, iface }) => {
|
|
@@ -36,13 +37,15 @@ const boardValToSlot = val => {
|
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
|
-
* A marshaller which can serialize getBoardId() -bearing
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* Remotable-bearing data.
|
|
40
|
+
* A marshaller which can serialize getBoardId() -bearing Remotables. This
|
|
41
|
+
* allows the caller to pick their slots. The deserializer is configurable: the
|
|
42
|
+
* default cannot handle Remotable-bearing data.
|
|
43
43
|
*
|
|
44
44
|
* @param {(slot: string, iface: string) => any} [slotToVal]
|
|
45
|
-
* @returns {Omit<
|
|
45
|
+
* @returns {Omit<
|
|
46
|
+
* import('@endo/marshal').Marshal<string | null>,
|
|
47
|
+
* 'serialize' | 'unserialize'
|
|
48
|
+
* >}
|
|
46
49
|
*/
|
|
47
50
|
export const boardSlottingMarshaller = (slotToVal = undefined) => {
|
|
48
51
|
return makeMarshal(boardValToSlot, slotToVal, {
|
|
@@ -70,9 +73,12 @@ harden(assertCapData);
|
|
|
70
73
|
*
|
|
71
74
|
* @param {Map<string, string>} data
|
|
72
75
|
* @param {string} key
|
|
73
|
-
* @param {ReturnType<
|
|
74
|
-
* @
|
|
75
|
-
*
|
|
76
|
+
* @param {ReturnType<
|
|
77
|
+
* typeof import('@endo/marshal').makeMarshal
|
|
78
|
+
* >['fromCapData']} fromCapData
|
|
79
|
+
* @param {number} index index of the desired value in a deserialized stream
|
|
80
|
+
* cell
|
|
81
|
+
* @returns {any}
|
|
76
82
|
*/
|
|
77
83
|
export const unmarshalFromVstorage = (data, key, fromCapData, index) => {
|
|
78
84
|
const serialized = data.get(key) || Fail`no data for ${key}`;
|
|
@@ -90,7 +96,7 @@ export const unmarshalFromVstorage = (data, key, fromCapData, index) => {
|
|
|
90
96
|
const marshalled = values.at(index);
|
|
91
97
|
assert.typeof(marshalled, 'string');
|
|
92
98
|
|
|
93
|
-
/** @type {import(
|
|
99
|
+
/** @type {import('@endo/marshal').CapData<string>} */
|
|
94
100
|
const capData = harden(JSON.parse(marshalled));
|
|
95
101
|
assertCapData(capData);
|
|
96
102
|
|
|
@@ -102,7 +108,7 @@ harden(unmarshalFromVstorage);
|
|
|
102
108
|
/**
|
|
103
109
|
* Provide access to object graphs serialized in vstorage.
|
|
104
110
|
*
|
|
105
|
-
* @param {
|
|
111
|
+
* @param {[string, string][]} entries
|
|
106
112
|
* @param {(slot: string, iface?: string) => any} [slotToVal]
|
|
107
113
|
*/
|
|
108
114
|
export const makeHistoryReviver = (entries, slotToVal = undefined) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-tools.d.ts","sourceRoot":"","sources":["method-tools.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"method-tools.d.ts","sourceRoot":"","sources":["method-tools.js"],"names":[],"mappings":"AA0CO,+BAFM,CAAC,2BADH,MAAM,CACJ,CAAC,AADK,EAAE,GAAG,CAAC,GACZ,CAAC,EAAE,CAsBf;AAUM,qCAHW,CAAC,2BAAR,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GACZ,MAAM,EAAE,CAKlB;AA+BI,+BAFM,CAAC,wCAAD,CAAC,AADF,GACC,CAAC,CAiBX"}
|
package/src/method-tools.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { isObject } from '@endo/marshal';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @file method-tools use dynamic property lookup, which is not
|
|
5
|
+
* @file method-tools use dynamic property lookup, which is not
|
|
6
|
+
* Jessie-compatible
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
const { getPrototypeOf, create, fromEntries, getOwnPropertyDescriptors } =
|
|
@@ -12,8 +13,8 @@ const { ownKeys, apply } = Reflect;
|
|
|
12
13
|
/**
|
|
13
14
|
* Prioritize symbols as earlier than strings.
|
|
14
15
|
*
|
|
15
|
-
* @param {string|symbol} a
|
|
16
|
-
* @param {string|symbol} b
|
|
16
|
+
* @param {string | symbol} a
|
|
17
|
+
* @param {string | symbol} b
|
|
17
18
|
* @returns {-1 | 0 | 1}
|
|
18
19
|
*/
|
|
19
20
|
const compareStringified = (a, b) => {
|
|
@@ -77,22 +78,22 @@ export const getStringMethodNames = val =>
|
|
|
77
78
|
/**
|
|
78
79
|
* TODO This function exists only to ease the
|
|
79
80
|
* https://github.com/Agoric/agoric-sdk/pull/5970 transition, from all methods
|
|
80
|
-
* being own properties to methods being inherited from a common prototype.
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
81
|
+
* being own properties to methods being inherited from a common prototype. This
|
|
82
|
+
* transition breaks two patterns used in prior code: autobinding, and
|
|
83
|
+
* enumerating methods by enumerating own properties. For both, the preferred
|
|
84
|
+
* repairs are
|
|
85
|
+
*
|
|
86
|
+
* - autobinding: Replace, for example, `foo(obj.method)` with `foo(arg =>
|
|
87
|
+
* `obj.method(arg))`. IOW, stop relying on expressions like `obj.method`to
|
|
88
|
+
* extract a method still bound to the state of`obj` because, for virtual and
|
|
89
|
+
* durable objects, they no longer will after #5970.
|
|
90
|
+
* - method enumeration: Replace, for example `Reflect.ownKeys(obj)` with
|
|
91
|
+
* `getMethodNames(obj)`.
|
|
91
92
|
*
|
|
92
93
|
* Once all problematic cases have been converted in this manner, this
|
|
93
94
|
* `bindAllMethods` hack can and TODO should be deleted. However, we currently
|
|
94
|
-
* have no reliable static way to track down and fix all autobinding sites.
|
|
95
|
-
*
|
|
95
|
+
* have no reliable static way to track down and fix all autobinding sites. For
|
|
96
|
+
* those objects that have not yet been fully repaired by the above two
|
|
96
97
|
* techniques, `bindAllMethods` creates an object that acts much like the
|
|
97
98
|
* pre-#5970 objects, with all their methods as instance-bound own properties.
|
|
98
99
|
* It does this by making a new object inheriting from `obj` where the new
|
package/src/netstring.d.ts
CHANGED
|
@@ -5,19 +5,18 @@
|
|
|
5
5
|
export function encode(data: Buffer): Buffer;
|
|
6
6
|
export function netstringEncoderStream(): Transform;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
8
|
* @param {Buffer} data containing zero or more netstrings and maybe some
|
|
10
|
-
*
|
|
9
|
+
* leftover bytes
|
|
11
10
|
* @param {number} [optMaxChunkSize]
|
|
12
|
-
* @returns {{ leftover: Buffer
|
|
11
|
+
* @returns {{ leftover: Buffer; payloads: Buffer[] }} zero or more decoded
|
|
12
|
+
* Buffers, one per netstring,
|
|
13
13
|
*/
|
|
14
14
|
export function decode(data: Buffer, optMaxChunkSize?: number | undefined): {
|
|
15
15
|
leftover: Buffer;
|
|
16
16
|
payloads: Buffer[];
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {number} [optMaxChunkSize ]
|
|
19
|
+
* @param {number} [optMaxChunkSize]
|
|
21
20
|
* @returns {Transform}
|
|
22
21
|
*/
|
|
23
22
|
export function netstringDecoderStream(optMaxChunkSize?: number | undefined): Transform;
|
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,
|
|
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,yCAGJ;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAmCpD;AAED;;;GAGG;AAEH,8EAHa,SAAS,CAoCrB;0BAvHyB,QAAQ"}
|
package/src/netstring.js
CHANGED
|
@@ -20,11 +20,10 @@ export function encode(data) {
|
|
|
20
20
|
// input is a sequence of strings, output is a byte pipe
|
|
21
21
|
export function netstringEncoderStream() {
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @this {{ push: (b: Buffer) => void }}
|
|
25
23
|
* @param {Buffer} chunk
|
|
26
24
|
* @param {BufferEncoding} encoding
|
|
27
|
-
* @param {
|
|
25
|
+
* @param {any} callback
|
|
26
|
+
* @this {{ push: (b: Buffer) => void }}
|
|
28
27
|
*/
|
|
29
28
|
function transform(chunk, encoding, callback) {
|
|
30
29
|
if (!Buffer.isBuffer(chunk)) {
|
|
@@ -44,11 +43,11 @@ export function netstringEncoderStream() {
|
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
/**
|
|
47
|
-
*
|
|
48
46
|
* @param {Buffer} data containing zero or more netstrings and maybe some
|
|
49
|
-
*
|
|
47
|
+
* leftover bytes
|
|
50
48
|
* @param {number} [optMaxChunkSize]
|
|
51
|
-
* @returns {{ leftover: Buffer
|
|
49
|
+
* @returns {{ leftover: Buffer; payloads: Buffer[] }} zero or more decoded
|
|
50
|
+
* Buffers, one per netstring,
|
|
52
51
|
*/
|
|
53
52
|
export function decode(data, optMaxChunkSize) {
|
|
54
53
|
// TODO: it would be more efficient to accumulate pending data in an array,
|
|
@@ -85,19 +84,17 @@ export function decode(data, optMaxChunkSize) {
|
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
/**
|
|
88
|
-
*
|
|
89
|
-
* @param {number} [optMaxChunkSize ]
|
|
87
|
+
* @param {number} [optMaxChunkSize]
|
|
90
88
|
* @returns {Transform}
|
|
91
89
|
*/
|
|
92
90
|
// input is a byte pipe, output is a sequence of Buffers
|
|
93
91
|
export function netstringDecoderStream(optMaxChunkSize) {
|
|
94
92
|
let buffered = Buffer.from('');
|
|
95
93
|
/**
|
|
96
|
-
*
|
|
97
|
-
* @this {{ push: (b: Buffer) => void }}
|
|
98
94
|
* @param {Buffer} chunk
|
|
99
95
|
* @param {BufferEncoding} encoding
|
|
100
|
-
* @param {
|
|
96
|
+
* @param {any} callback
|
|
97
|
+
* @this {{ push: (b: Buffer) => void }}
|
|
101
98
|
*/
|
|
102
99
|
function transform(chunk, encoding, callback) {
|
|
103
100
|
if (!Buffer.isBuffer(chunk)) {
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {object} BufferLineTransformOptions
|
|
3
|
-
* @property {Buffer | string | number} [break] line break matcher for
|
|
4
|
-
*
|
|
3
|
+
* @property {Buffer | string | number} [break] line break matcher for
|
|
4
|
+
* Buffer.indexOf() (default: 10)
|
|
5
|
+
* @property {BufferEncoding} [breakEncoding] if break is a string, the encoding
|
|
6
|
+
* to use
|
|
5
7
|
*/
|
|
6
8
|
export default class BufferLineTransform extends Transform {
|
|
7
9
|
/**
|
|
8
|
-
* The BufferLineTransform is reading String or Buffer content from a Readable
|
|
9
|
-
* and writing each line as a Buffer in object mode
|
|
10
|
+
* The BufferLineTransform is reading String or Buffer content from a Readable
|
|
11
|
+
* stream and writing each line as a Buffer in object mode
|
|
10
12
|
*
|
|
11
|
-
* @param {import('node:stream').TransformOptions &
|
|
13
|
+
* @param {import('node:stream').TransformOptions &
|
|
14
|
+
* BufferLineTransformOptions} [options]
|
|
12
15
|
*/
|
|
13
16
|
constructor(options?: (import("stream").TransformOptions & BufferLineTransformOptions) | undefined);
|
|
14
17
|
_breakValue: string | number | Buffer;
|
|
15
18
|
_breakEncoding: BufferEncoding | undefined;
|
|
16
19
|
_breakLength: number;
|
|
17
|
-
/** @type {
|
|
18
|
-
_chunks:
|
|
20
|
+
/** @type {Buffer[]} */
|
|
21
|
+
_chunks: Buffer[];
|
|
19
22
|
/**
|
|
20
|
-
* @override
|
|
21
23
|
* @param {any} chunk
|
|
22
24
|
* @param {BufferEncoding | 'buffer'} encoding
|
|
23
25
|
* @param {import('node:stream').TransformCallback} cb
|
|
26
|
+
* @override
|
|
24
27
|
*/
|
|
25
28
|
override _transform(chunk: any, encoding: BufferEncoding | "buffer", cb: import("node:stream").TransformCallback): void;
|
|
26
29
|
/** @param {Buffer} line */
|
|
@@ -28,11 +31,13 @@ export default class BufferLineTransform extends Transform {
|
|
|
28
31
|
}
|
|
29
32
|
export type BufferLineTransformOptions = {
|
|
30
33
|
/**
|
|
31
|
-
* line break matcher for
|
|
34
|
+
* line break matcher for
|
|
35
|
+
* Buffer.indexOf() (default: 10)
|
|
32
36
|
*/
|
|
33
37
|
break?: string | number | Buffer | undefined;
|
|
34
38
|
/**
|
|
35
|
-
* if break is a string, the encoding
|
|
39
|
+
* if break is a string, the encoding
|
|
40
|
+
* to use
|
|
36
41
|
*/
|
|
37
42
|
breakEncoding?: BufferEncoding | undefined;
|
|
38
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-line-transform.d.ts","sourceRoot":"","sources":["buffer-line-transform.js"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"buffer-line-transform.d.ts","sourceRoot":"","sources":["buffer-line-transform.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;IACE;;;;;;OAMG;IACH,oGAuBC;IAhBC,sCAAmC;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"}
|
|
@@ -5,16 +5,19 @@ import { Transform } from 'node:stream';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {object} BufferLineTransformOptions
|
|
8
|
-
* @property {Buffer | string | number} [break] line break matcher for
|
|
9
|
-
*
|
|
8
|
+
* @property {Buffer | string | number} [break] line break matcher for
|
|
9
|
+
* Buffer.indexOf() (default: 10)
|
|
10
|
+
* @property {BufferEncoding} [breakEncoding] if break is a string, the encoding
|
|
11
|
+
* to use
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
14
|
export default class BufferLineTransform extends Transform {
|
|
13
15
|
/**
|
|
14
|
-
* The BufferLineTransform is reading String or Buffer content from a Readable
|
|
15
|
-
* and writing each line as a Buffer in object mode
|
|
16
|
+
* The BufferLineTransform is reading String or Buffer content from a Readable
|
|
17
|
+
* stream and writing each line as a Buffer in object mode
|
|
16
18
|
*
|
|
17
|
-
* @param {import('node:stream').TransformOptions &
|
|
19
|
+
* @param {import('node:stream').TransformOptions &
|
|
20
|
+
* BufferLineTransformOptions} [options]
|
|
18
21
|
*/
|
|
19
22
|
constructor(options) {
|
|
20
23
|
const {
|
|
@@ -37,15 +40,15 @@ export default class BufferLineTransform extends Transform {
|
|
|
37
40
|
}
|
|
38
41
|
this._breakLength = breakLength;
|
|
39
42
|
|
|
40
|
-
/** @type {
|
|
43
|
+
/** @type {Buffer[]} */
|
|
41
44
|
this._chunks = [];
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
/**
|
|
45
|
-
* @override
|
|
46
48
|
* @param {any} chunk
|
|
47
49
|
* @param {BufferEncoding | 'buffer'} encoding
|
|
48
50
|
* @param {import('node:stream').TransformCallback} cb
|
|
51
|
+
* @override
|
|
49
52
|
*/
|
|
50
53
|
_transform(chunk, encoding, cb) {
|
|
51
54
|
try {
|
|
@@ -96,8 +99,8 @@ export default class BufferLineTransform extends Transform {
|
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
/**
|
|
99
|
-
* @override
|
|
100
102
|
* @param {import('node:stream').TransformCallback} cb
|
|
103
|
+
* @override
|
|
101
104
|
*/
|
|
102
105
|
_flush(cb) {
|
|
103
106
|
if (this._chunks.length) {
|
package/src/node/fs-stream.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createWriteStream } from 'node:fs';
|
|
|
2
2
|
import { open } from 'node:fs/promises';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @param {import(
|
|
5
|
+
* @param {import('fs').ReadStream | import('fs').WriteStream} stream
|
|
6
6
|
* @returns {Promise<void>}
|
|
7
7
|
*/
|
|
8
8
|
export const fsStreamReady = stream =>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"priority-senders.d.ts","sourceRoot":"","sources":["priority-senders.js"],"names":[],"mappings":"AAMA,4CAA4C;AAC5C,uCADW,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAMtC;AAQK,wDAFI,IAAI,CAAC,OAAO,uBAAuB,EAAE,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"priority-senders.d.ts","sourceRoot":"","sources":["priority-senders.js"],"names":[],"mappings":"AAMA,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"}
|
package/src/priority-senders.js
CHANGED
|
@@ -20,9 +20,13 @@ harden(normalizeSenderNamespace);
|
|
|
20
20
|
*/
|
|
21
21
|
export const makePrioritySendersManager = sendersNode => {
|
|
22
22
|
/**
|
|
23
|
-
* address to tuple with storage node and set of namespaces that requested
|
|
23
|
+
* address to tuple with storage node and set of namespaces that requested
|
|
24
|
+
* priority
|
|
24
25
|
*
|
|
25
|
-
* @type {Map<
|
|
26
|
+
* @type {Map<
|
|
27
|
+
* string,
|
|
28
|
+
* readonly [node: StorageNode, namespaces: Set<string>]
|
|
29
|
+
* >}
|
|
26
30
|
*/
|
|
27
31
|
const addressRecords = new Map();
|
|
28
32
|
|
|
@@ -47,7 +51,7 @@ export const makePrioritySendersManager = sendersNode => {
|
|
|
47
51
|
const node = await E(sendersNode).makeChildNode(address, {
|
|
48
52
|
sequence: false,
|
|
49
53
|
});
|
|
50
|
-
/** @type {readonly [
|
|
54
|
+
/** @type {readonly [node: StorageNode, namespaces: Set<string>]} */
|
|
51
55
|
const r = [node, new Set()];
|
|
52
56
|
addressRecords.set(address, r);
|
|
53
57
|
return r;
|
package/src/queue.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Return a function that can wrap an async or sync method, but
|
|
7
|
-
*
|
|
6
|
+
* Return a function that can wrap an async or sync method, but ensures only one
|
|
7
|
+
* of them (in order) is running at a time.
|
|
8
8
|
*/
|
|
9
9
|
export const makeWithQueue = () => {
|
|
10
10
|
const queue = [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function slotToRemotable(_slotId: string, iface?: string): import("@endo/marshal").RemotableObject<string> & import("@endo/eventual-send").RemotableBrand<{}, {}>;
|
|
2
2
|
/**
|
|
3
|
-
* A basic marshaller whose unserializer produces Remotables. It can
|
|
4
|
-
*
|
|
3
|
+
* A basic marshaller whose unserializer produces Remotables. It can only
|
|
4
|
+
* serialize plain data, not Remotables.
|
|
5
5
|
*/
|
|
6
6
|
export const defaultMarshaller: {
|
|
7
7
|
toCapData: import("@endo/marshal").ToCapData<string>;
|
|
@@ -28,8 +28,8 @@ export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<ty
|
|
|
28
28
|
};
|
|
29
29
|
export function makeMockChainStorageRoot(): MockChainStorageRoot;
|
|
30
30
|
/**
|
|
31
|
-
* A map corresponding with a total function such that `get(key)`
|
|
32
|
-
*
|
|
31
|
+
* A map corresponding with a total function such that `get(key)` is assumed to
|
|
32
|
+
* always succeed.
|
|
33
33
|
*/
|
|
34
34
|
export type TotalMap<K, V> = { [k in Exclude<keyof Map<K, V>, "get">]: Map<K, V>[k]; } & {
|
|
35
35
|
get: (key: K) => V;
|
|
@@ -38,10 +38,10 @@ export type TotalMapFrom<T> = T extends Map<infer K, infer V> ? TotalMap<K, V> :
|
|
|
38
38
|
export type FakeStorageKit = ReturnType<typeof makeFakeStorageKit>;
|
|
39
39
|
export type MockChainStorageRootMethods = {
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
41
|
+
* Defaults to deserializing slot references into plain Remotable objects having
|
|
42
|
+
* the specified interface name (as from `Far(iface)`), but can accept a
|
|
43
|
+
* different marshaller for producing Remotables that e.g. embed the slot
|
|
44
|
+
* string in their iface name.
|
|
45
45
|
*/
|
|
46
46
|
getBody: (path: string, marshaller?: {
|
|
47
47
|
toCapData: import("@endo/marshal").ToCapData<unknown>;
|
|
@@ -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":"AAqCO,yCAHI,MAAM,UACN,MAAM,0GAGC;AAElB;;;GAGG;AACH;;;;;EAEG;AA4CH,8CAtBuB,GAAG,KAAK,GAAG,CAsB+B;AAU1D,6CAHI,MAAM,gBACN,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;uDAqGtC;YAAE,QAAS,CAAC,UAAS;SAAE;;;UAIjB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;EAIvC;AAoBM,4CADO,oBAAoB,CA6BjC;;;;;qBAzOe,CAAC,EAAK,CAAC,IADV,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CACtB,CAAC,AADuB,EAClB,CAAC,AADoB,CAAC,EAAE,KAAK,CAAC,GAAG,GAAG,CAC1C,CAAC,AAD2C,EACtC,CAAC,AADwC,CAAC,CAAC,CAAC,CAAC,GAAE,GAAG;IACvE,GAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;CACpB;yBAIS,CAAC,IAAD,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK;6BAsLvD,UAAU,CAAC,OAAO,kBAAkB,CAAC;;;;;;;;oBAKxC,MAAM;;;;;2BAEJ,MAAM,KACX,OAAO;UAKD,MAAM,MAAM,EAAE;;;qCAzNuB,uBAAuB;iCAIF,uBAAuB;oCAAvB,uBAAuB"}
|
|
@@ -15,11 +15,13 @@ const { Fail } = assert;
|
|
|
15
15
|
const trace = makeTracer('StorTU', false);
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* A map corresponding with a total function such that `get(key)`
|
|
19
|
-
*
|
|
18
|
+
* A map corresponding with a total function such that `get(key)` is assumed to
|
|
19
|
+
* always succeed.
|
|
20
20
|
*
|
|
21
21
|
* @template K, V
|
|
22
|
-
* @typedef {{[k in Exclude<keyof Map<K, V>, 'get'>]: Map<K, V>[k]} & {
|
|
22
|
+
* @typedef {{ [k in Exclude<keyof Map<K, V>, 'get'>]: Map<K, V>[k] } & {
|
|
23
|
+
* get: (key: K) => V;
|
|
24
|
+
* }} TotalMap
|
|
23
25
|
*/
|
|
24
26
|
/**
|
|
25
27
|
* @template T
|
|
@@ -27,8 +29,8 @@ const trace = makeTracer('StorTU', false);
|
|
|
27
29
|
*/
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
|
-
* A convertSlotToVal function that produces basic Remotables. Assumes
|
|
31
|
-
*
|
|
32
|
+
* A convertSlotToVal function that produces basic Remotables. Assumes that all
|
|
33
|
+
* slots are Remotables (i.e. none are Promises).
|
|
32
34
|
*
|
|
33
35
|
* @param {string} _slotId
|
|
34
36
|
* @param {string} iface
|
|
@@ -37,34 +39,34 @@ export const slotToRemotable = (_slotId, iface = 'Remotable') =>
|
|
|
37
39
|
Remotable(iface);
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
|
-
* A basic marshaller whose unserializer produces Remotables. It can
|
|
41
|
-
*
|
|
42
|
+
* A basic marshaller whose unserializer produces Remotables. It can only
|
|
43
|
+
* serialize plain data, not Remotables.
|
|
42
44
|
*/
|
|
43
45
|
export const defaultMarshaller = makeMarshal(undefined, slotToRemotable, {
|
|
44
46
|
serializeBodyFormat: 'smallcaps',
|
|
45
47
|
});
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
|
-
* A deserializer which produces slot strings instead of Remotables,
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
50
|
+
* A deserializer which produces slot strings instead of Remotables, so if `a =
|
|
51
|
+
* Far('iface')`, and serializing `{ a }` into `capData` assigned it slot
|
|
52
|
+
* `board123`, then `slotStringUnserialize(capData)` would produce `{ a:
|
|
53
|
+
* 'board123' }`.
|
|
52
54
|
*
|
|
53
55
|
* This may be useful for display purposes.
|
|
54
56
|
*
|
|
55
57
|
* Limitations:
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
58
|
+
*
|
|
59
|
+
* - it cannot handle Symbols (registered or well-known)
|
|
60
|
+
* - it can handle BigInts, but serialized data that contains a particular unusual
|
|
61
|
+
* string will be unserialized into a BigInt by mistake
|
|
62
|
+
* - it cannot handle Promises, NaN, +/- Infinity, undefined, or other
|
|
63
|
+
* non-JSONable JavaScript values
|
|
62
64
|
*/
|
|
63
65
|
const makeSlotStringUnserialize = () => {
|
|
64
|
-
/** @type {
|
|
66
|
+
/** @type {(slot: string, iface: string) => any} */
|
|
65
67
|
const identitySlotToValFn = (slot, _) => Far('unk', { toJSON: () => slot });
|
|
66
68
|
const { fromCapData } = makeMarshal(undefined, identitySlotToValFn);
|
|
67
|
-
/** @type {
|
|
69
|
+
/** @type {(capData: any) => any} */
|
|
68
70
|
const unserialize = capData =>
|
|
69
71
|
JSON.parse(
|
|
70
72
|
JSON.stringify(fromCapData(capData), (_, val) => {
|
|
@@ -89,9 +91,9 @@ const makeSlotStringUnserialize = () => {
|
|
|
89
91
|
export const slotStringUnserialize = makeSlotStringUnserialize();
|
|
90
92
|
|
|
91
93
|
/**
|
|
92
|
-
* For testing, creates a chainStorage root node over an in-memory map
|
|
93
|
-
*
|
|
94
|
-
*
|
|
94
|
+
* For testing, creates a chainStorage root node over an in-memory map and
|
|
95
|
+
* exposes both the map and the sequence of received messages. The `sequence`
|
|
96
|
+
* option defaults to true.
|
|
95
97
|
*
|
|
96
98
|
* @param {string} rootPath
|
|
97
99
|
* @param {Parameters<typeof makeChainStorageRoot>[2]} [rootOptions]
|
|
@@ -205,15 +207,19 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
|
|
|
205
207
|
};
|
|
206
208
|
};
|
|
207
209
|
harden(makeFakeStorageKit);
|
|
208
|
-
/** @typedef {ReturnType<
|
|
210
|
+
/** @typedef {ReturnType<typeof makeFakeStorageKit>} FakeStorageKit */
|
|
209
211
|
|
|
210
212
|
/**
|
|
211
213
|
* @typedef MockChainStorageRootMethods
|
|
212
|
-
* @property {(
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
214
|
+
* @property {(
|
|
215
|
+
* path: string,
|
|
216
|
+
* marshaller?: Marshaller,
|
|
217
|
+
* index?: number,
|
|
218
|
+
* ) => unknown} getBody
|
|
219
|
+
* Defaults to deserializing slot references into plain Remotable objects having
|
|
220
|
+
* the specified interface name (as from `Far(iface)`), but can accept a
|
|
221
|
+
* different marshaller for producing Remotables that e.g. embed the slot
|
|
222
|
+
* string in their iface name.
|
|
217
223
|
* @property {() => string[]} keys
|
|
218
224
|
*/
|
|
219
225
|
/** @typedef {StorageNode & MockChainStorageRootMethods} MockChainStorageRoot */
|
|
@@ -224,10 +230,10 @@ export const makeMockChainStorageRoot = () => {
|
|
|
224
230
|
return Far('mockChainStorage', {
|
|
225
231
|
...bindAllMethods(rootNode),
|
|
226
232
|
/**
|
|
227
|
-
* Defaults to deserializing slot references into plain Remotable
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
233
|
+
* Defaults to deserializing slot references into plain Remotable objects
|
|
234
|
+
* having the specified interface name (as from `Far(iface)`), but can
|
|
235
|
+
* accept a different marshaller for producing Remotables that e.g. embed
|
|
236
|
+
* the slot string in their iface name.
|
|
231
237
|
*
|
|
232
238
|
* @param {string} path
|
|
233
239
|
* @param {Marshaller} marshaller
|
|
@@ -236,7 +242,11 @@ export const makeMockChainStorageRoot = () => {
|
|
|
236
242
|
*/
|
|
237
243
|
getBody: (path, marshaller = defaultMarshaller, index = -1) => {
|
|
238
244
|
data.size || Fail`no data in storage`;
|
|
239
|
-
/**
|
|
245
|
+
/**
|
|
246
|
+
* @type {ReturnType<
|
|
247
|
+
* typeof import('@endo/marshal').makeMarshal
|
|
248
|
+
* >['fromCapData']}
|
|
249
|
+
*/
|
|
240
250
|
const fromCapData = (...args) =>
|
|
241
251
|
Reflect.apply(marshaller.fromCapData, marshaller, args);
|
|
242
252
|
return unmarshalFromVstorage(data, path, fromCapData, index);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-utils.d.ts","sourceRoot":"","sources":["testing-utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testing-utils.d.ts","sourceRoot":"","sources":["testing-utils.js"],"names":[],"mappings":"AAaO,mDACwC"}
|
package/src/testing-utils.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* @file note this cannot be called test-utils.js due to
|
|
3
|
+
* https://github.com/Agoric/agoric-sdk/issues/7503
|
|
4
|
+
*/
|
|
2
5
|
/* global setImmediate */
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* A workaround for some issues with fake time in tests.
|
|
6
9
|
*
|
|
7
|
-
* Lines of test code can depend on async promises outside the test
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Note that this doesn't mean all outstanding promises.
|
|
10
|
+
* Lines of test code can depend on async promises outside the test resolving
|
|
11
|
+
* before they run. Awaiting this function result ensures that all promises that
|
|
12
|
+
* can do resolve. Note that this doesn't mean all outstanding promises.
|
|
11
13
|
*/
|
|
12
14
|
export const eventLoopIteration = async () =>
|
|
13
15
|
new Promise(resolve => setImmediate(resolve));
|
package/src/upgrade-api.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export namespace UpgradeDisconnectionShape {
|
|
|
6
6
|
export function makeUpgradeDisconnection(upgradeMessage: string, toIncarnationNumber: number): UpgradeDisconnection;
|
|
7
7
|
export function isUpgradeDisconnection(reason: any): reason is UpgradeDisconnection;
|
|
8
8
|
/**
|
|
9
|
-
* An Error-like object for use as the rejection reason of promises
|
|
10
|
-
*
|
|
9
|
+
* An Error-like object for use as the rejection reason of promises abandoned by
|
|
10
|
+
* upgrade.
|
|
11
11
|
*/
|
|
12
12
|
export type UpgradeDisconnection = {
|
|
13
13
|
name: "vatUpgraded";
|
package/src/upgrade-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-api.d.ts","sourceRoot":"","sources":["upgrade-api.js"],"names":[],"mappings":";;;;;AAgCO,yDAJI,MAAM,uBACN,MAAM,GACJ,oBAAoB,CAO7B;AASG,+CALI,GAAG,GAGD,MAAM,IAAI,oBAAoB,CAGqB;;;;;mCApCnD;IACZ,IAAQ,EAAE,aAAa,CAAC;IACxB,cAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"upgrade-api.d.ts","sourceRoot":"","sources":["upgrade-api.js"],"names":[],"mappings":";;;;;AAgCO,yDAJI,MAAM,uBACN,MAAM,GACJ,oBAAoB,CAO7B;AASG,+CALI,GAAG,GAGD,MAAM,IAAI,oBAAoB,CAGqB;;;;;mCApCnD;IACZ,IAAQ,EAAE,aAAa,CAAC;IACxB,cAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAqB,EAAE,MAAM,CAAC;CAC3B"}
|
package/src/upgrade-api.js
CHANGED
|
@@ -6,13 +6,13 @@ import { M, matches } from '@endo/patterns';
|
|
|
6
6
|
const { isFrozen } = Object;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* An Error-like object for use as the rejection reason of promises
|
|
10
|
-
*
|
|
9
|
+
* An Error-like object for use as the rejection reason of promises abandoned by
|
|
10
|
+
* upgrade.
|
|
11
11
|
*
|
|
12
12
|
* @typedef {{
|
|
13
|
-
* name: 'vatUpgraded'
|
|
14
|
-
* upgradeMessage: string
|
|
15
|
-
* incarnationNumber: number
|
|
13
|
+
* name: 'vatUpgraded';
|
|
14
|
+
* upgradeMessage: string;
|
|
15
|
+
* incarnationNumber: number;
|
|
16
16
|
* }} UpgradeDisconnection
|
|
17
17
|
*/
|
|
18
18
|
|
|
@@ -39,9 +39,9 @@ export const makeUpgradeDisconnection = (upgradeMessage, toIncarnationNumber) =>
|
|
|
39
39
|
harden(makeUpgradeDisconnection);
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* @param {any} reason
|
|
43
|
-
*
|
|
44
|
-
*
|
|
42
|
+
* @param {any} reason If `reason` is not frozen, it cannot be an
|
|
43
|
+
* UpgradeDisconnection, so returns false without even checking against the
|
|
44
|
+
* shape.
|
|
45
45
|
* @returns {reason is UpgradeDisconnection}
|
|
46
46
|
*/
|
|
47
47
|
export const isUpgradeDisconnection = reason =>
|