@agoric/internal 0.4.0-upgrade-17-dev-a1453b2.0 → 0.4.0-upgrade-18-dev-bf39b10.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 +16 -16
- package/src/action-types.d.ts +1 -0
- package/src/action-types.d.ts.map +1 -1
- package/src/action-types.js +1 -0
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/config.d.ts +4 -1
- package/src/config.d.ts.map +1 -1
- package/src/config.js +2 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +5 -2
- package/src/lib-nodejs/worker-protocol.js +1 -1
- package/src/netstring.js +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 +40 -27
- package/src/storage-test-utils.d.ts +6 -3
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +73 -69
- package/src/types-index.d.ts +1 -0
- package/src/types.d.ts +24 -58
- 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 +1 -1
- package/src/utils.js +4 -0
- /package/src/{types.js → types-index.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/internal",
|
|
3
|
-
"version": "0.4.0-upgrade-
|
|
3
|
+
"version": "0.4.0-upgrade-18-dev-bf39b10.0+bf39b10",
|
|
4
4
|
"description": "Externally unsupported utilities internal to agoric-sdk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "exit 0",
|
|
12
12
|
"prepack": "tsc --build tsconfig.build.json",
|
|
13
|
-
"postpack": "git clean -f '*.d.ts*'",
|
|
13
|
+
"postpack": "git clean -f '*.d.ts*' '*.tsbuildinfo'",
|
|
14
14
|
"test": "ava",
|
|
15
15
|
"test:nyc": "exit 0",
|
|
16
16
|
"test:xs": "exit 0",
|
|
@@ -20,22 +20,22 @@
|
|
|
20
20
|
"lint:types": "tsc"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@agoric/base-zone": "0.1.1-upgrade-
|
|
24
|
-
"@endo/common": "^1.2.
|
|
25
|
-
"@endo/errors": "^1.2.
|
|
26
|
-
"@endo/far": "^1.1.
|
|
27
|
-
"@endo/init": "^1.1.
|
|
28
|
-
"@endo/marshal": "^1.
|
|
29
|
-
"@endo/pass-style": "^1.4.
|
|
30
|
-
"@endo/patterns": "^1.4.
|
|
31
|
-
"@endo/promise-kit": "^1.1.
|
|
32
|
-
"@endo/stream": "^1.2.
|
|
23
|
+
"@agoric/base-zone": "0.1.1-upgrade-18-dev-bf39b10.0+bf39b10",
|
|
24
|
+
"@endo/common": "^1.2.7",
|
|
25
|
+
"@endo/errors": "^1.2.7",
|
|
26
|
+
"@endo/far": "^1.1.8",
|
|
27
|
+
"@endo/init": "^1.1.6",
|
|
28
|
+
"@endo/marshal": "^1.6.1",
|
|
29
|
+
"@endo/pass-style": "^1.4.6",
|
|
30
|
+
"@endo/patterns": "^1.4.6",
|
|
31
|
+
"@endo/promise-kit": "^1.1.7",
|
|
32
|
+
"@endo/stream": "^1.2.7",
|
|
33
33
|
"anylogger": "^0.21.0",
|
|
34
34
|
"jessie.js": "^0.3.4"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@endo/exo": "^1.5.
|
|
38
|
-
"@endo/init": "^1.1.
|
|
37
|
+
"@endo/exo": "^1.5.6",
|
|
38
|
+
"@endo/init": "^1.1.6",
|
|
39
39
|
"ava": "^5.3.0",
|
|
40
40
|
"tsd": "^0.31.1"
|
|
41
41
|
},
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"typeCoverage": {
|
|
60
|
-
"atLeast": 93.
|
|
60
|
+
"atLeast": 93.42
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "bf39b100f0da4380bab0ce2464aaca1988f0b76a"
|
|
63
63
|
}
|
package/src/action-types.d.ts
CHANGED
|
@@ -14,4 +14,5 @@ export const WALLET_ACTION: "WALLET_ACTION";
|
|
|
14
14
|
export const WALLET_SPEND_ACTION: "WALLET_SPEND_ACTION";
|
|
15
15
|
export const INSTALL_BUNDLE: "INSTALL_BUNDLE";
|
|
16
16
|
export const VTRANSFER_IBC_EVENT: "VTRANSFER_IBC_EVENT";
|
|
17
|
+
export const KERNEL_UPGRADE_EVENTS: "KERNEL_UPGRADE_EVENTS";
|
|
17
18
|
//# sourceMappingURL=action-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-types.d.ts","sourceRoot":"","sources":["action-types.js"],"names":[],"mappings":"AAEA,8CAA+C;AAC/C,sDAAuD;AACvD,wCAAyC;AACzC,gEAAiE;AACjE,oCAAqC;AACrC,gDAAiD;AACjD,oCAAqC;AACrC,0CAA2C;AAC3C,sDAAuD;AACvD,oCAAqC;AACrC,kDAAmD;AACnD,0DAA2D;AAC3D,4CAA6C;AAC7C,wDAAyD;AACzD,8CAA+C;AAC/C,wDAAyD"}
|
|
1
|
+
{"version":3,"file":"action-types.d.ts","sourceRoot":"","sources":["action-types.js"],"names":[],"mappings":"AAEA,8CAA+C;AAC/C,sDAAuD;AACvD,wCAAyC;AACzC,gEAAiE;AACjE,oCAAqC;AACrC,gDAAiD;AACjD,oCAAqC;AACrC,0CAA2C;AAC3C,sDAAuD;AACvD,oCAAqC;AACrC,kDAAmD;AACnD,0DAA2D;AAC3D,4CAA6C;AAC7C,wDAAyD;AACzD,8CAA+C;AAC/C,wDAAyD;AACzD,4DAA6D"}
|
package/src/action-types.js
CHANGED
|
@@ -16,3 +16,4 @@ export const WALLET_ACTION = 'WALLET_ACTION';
|
|
|
16
16
|
export const WALLET_SPEND_ACTION = 'WALLET_SPEND_ACTION';
|
|
17
17
|
export const INSTALL_BUNDLE = 'INSTALL_BUNDLE';
|
|
18
18
|
export const VTRANSFER_IBC_EVENT = 'VTRANSFER_IBC_EVENT';
|
|
19
|
+
export const KERNEL_UPGRADE_EVENTS = 'KERNEL_UPGRADE_EVENTS';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batched-deliver.d.ts","sourceRoot":"","sources":["batched-deliver.js"],"names":[],"mappings":"AAKA;;GAEG;AAEH;;;;;;;GAOG;AACH,4CAPW,eAAe,gCACf;
|
|
1
|
+
{"version":3,"file":"batched-deliver.d.ts","sourceRoot":"","sources":["batched-deliver.js"],"names":[],"mappings":"AAKA;;GAEG;AAEH;;;;;;;GAOG;AACH,4CAPW,eAAe,gCACf;IACN,YAAY,EAAE,8BAAkC,CAAC;IACjD,UAAU,EAAE,4BAAgC,CAAC;CAC9C,mBACO,MAAM,aATM,OAAO,EAAE,UAAU,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAiDjE;AApDD,4CAA6C;8BAGhC,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC"}
|
package/src/config.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event source ids used by the bridge device.
|
|
3
|
+
*/
|
|
4
|
+
export type BridgeId = (typeof BridgeId)[keyof typeof BridgeId];
|
|
1
5
|
export namespace BridgeId {
|
|
2
6
|
let BANK: "bank";
|
|
3
7
|
let CORE: "core";
|
|
@@ -30,5 +34,4 @@ export namespace VBankAccount {
|
|
|
30
34
|
export { address_1 as address };
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
|
-
export type BridgeIdValue = (typeof BridgeId)[keyof typeof BridgeId];
|
|
34
37
|
//# sourceMappingURL=config.d.ts.map
|
package/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.js"],"names":[],"mappings":";;;uBAkBU,CAAC,OAAO,QAAQ,EAAE,MAAM,OAAO,QAAQ,CAAC"}
|
package/src/config.js
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Event source ids used by the bridge device.
|
|
18
|
+
*
|
|
19
|
+
* @enum {(typeof BridgeId)[keyof typeof BridgeId]}
|
|
18
20
|
*/
|
|
19
21
|
export const BridgeId = /** @type {const} */ ({
|
|
20
22
|
BANK: 'bank',
|
|
@@ -28,7 +30,6 @@ export const BridgeId = /** @type {const} */ ({
|
|
|
28
30
|
WALLET: 'wallet',
|
|
29
31
|
});
|
|
30
32
|
harden(BridgeId);
|
|
31
|
-
/** @typedef {(typeof BridgeId)[keyof typeof BridgeId]} BridgeIdValue */
|
|
32
33
|
|
|
33
34
|
export const CosmosInitKeyToBridgeId = {
|
|
34
35
|
vbankPort: BridgeId.BANK,
|
package/src/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * from "./utils.js";
|
|
|
5
5
|
export * from "./method-tools.js";
|
|
6
6
|
export * from "./typeCheck.js";
|
|
7
7
|
export * from "./typeGuards.js";
|
|
8
|
-
export * from "./types.js";
|
|
8
|
+
export * from "./types-index.js";
|
|
9
9
|
export { objectMap } from "@endo/common/object-map.js";
|
|
10
10
|
export { objectMetaMap } from "@endo/common/object-meta-map.js";
|
|
11
11
|
export { fromUniqueEntries } from "@endo/common/from-unique-entries.js";
|
package/src/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export * from './typeCheck.js';
|
|
|
11
11
|
export * from './typeGuards.js';
|
|
12
12
|
|
|
13
13
|
// eslint-disable-next-line import/export -- just types
|
|
14
|
-
export * from './types.js';
|
|
14
|
+
export * from './types-index.js';
|
|
15
15
|
|
|
16
16
|
export { objectMap } from '@endo/common/object-map.js';
|
|
17
17
|
export { objectMetaMap } from '@endo/common/object-meta-map.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib-chainStorage.d.ts","sourceRoot":"","sources":["lib-chainStorage.js"],"names":[],"mappings":"AAyPA;;;;;;;;;;;;GAYG;AACH,2DATW,CAAC,OAAO,EAAE,cAAc,KAAK,GAAG,YAGhC,MAAM;;;;IAhEX;;;OAGG;mBADa,OAAO,CAAC,WAAW,CAAC;IASpC;;;;;OAKG;wBAHQ,MAAM,qBACO;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GACtC,WAAW;IAYnB,+CAA+C;oBAA5B,MAAM,GAAK,OAAO,CAAC,IAAI,CAAC;GAqDhD;
|
|
1
|
+
{"version":3,"file":"lib-chainStorage.d.ts","sourceRoot":"","sources":["lib-chainStorage.js"],"names":[],"mappings":"AAyPA;;;;;;;;;;;;GAYG;AACH,2DATW,CAAC,OAAO,EAAE,cAAc,KAAK,GAAG,YAGhC,MAAM;;;;IAhEX;;;OAGG;mBADa,OAAO,CAAC,WAAW,CAAC;IASpC;;;;;OAKG;wBAHQ,MAAM,qBACO;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GACtC,WAAW;IAYnB,+CAA+C;oBAA5B,MAAM,GAAK,OAAO,CAAC,IAAI,CAAC;GAqDhD;AAcD;;;;;;;;GAQG;AACH,qDAJW,KAAK,WAAW,OAAC,CAAC,aAClB,MAAM,GACJ,OAAO,CAAC,WAAW,CAAC,CAMhC;AApOM,mCAHI,GAAG,GACD,IAAI,IAAI,UAAU,CAOa;AASrC,oCAHI,OAAO,GACL,QAAQ,IAAI,IAAI,OAAO,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,CA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;2BAEd,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;;;;8CAErC,YAAY,EAAE;;;;6BAEd;IACJ,MAAM,EAAE,6BAA6B,CAAC;IACtC,IAAI,EAAE,2BAA2B,CAAC;CACnC,GACD;IACE,MAAM,EAAE,iCAAiC,CAAC;IAC1C,IAAI,EAAE,+BAA+B,CAAC;CACvC;0BA5Ie,WAAW;iCACJ,eAAe"}
|
package/src/lib-chainStorage.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
import { Fail } from '@endo/errors';
|
|
4
|
-
import { E } from '@endo/far';
|
|
4
|
+
import { E, Far } from '@endo/far';
|
|
5
5
|
import { M } from '@endo/patterns';
|
|
6
6
|
import { makeHeapZone } from '@agoric/base-zone/heap.js';
|
|
7
7
|
import * as cb from './callback.js';
|
|
@@ -278,7 +278,10 @@ export function makeChainStorageRoot(
|
|
|
278
278
|
*/
|
|
279
279
|
const makeNullStorageNode = () => {
|
|
280
280
|
// XXX re-use "ChainStorage" methods above which don't actually depend on chains
|
|
281
|
-
return makeChainStorageRoot(
|
|
281
|
+
return makeChainStorageRoot(
|
|
282
|
+
Far('NullMessenger', () => null),
|
|
283
|
+
'null',
|
|
284
|
+
);
|
|
282
285
|
};
|
|
283
286
|
|
|
284
287
|
/**
|
package/src/netstring.js
CHANGED
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 =>
|
|
@@ -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,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.
|
|
@@ -21,10 +21,13 @@ export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<ty
|
|
|
21
21
|
}>;
|
|
22
22
|
data: Map<string, string>;
|
|
23
23
|
messages: StorageMessage[];
|
|
24
|
-
toStorage: (message: StorageMessage) => string | number | any[] | {
|
|
24
|
+
toStorage: ((message: StorageMessage) => string | number | any[] | {
|
|
25
25
|
storeName: string;
|
|
26
26
|
storeSubkey: string;
|
|
27
|
-
} | null | undefined
|
|
27
|
+
} | null | undefined) & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (message: StorageMessage) => string | number | any[] | {
|
|
28
|
+
storeName: string;
|
|
29
|
+
storeSubkey: string;
|
|
30
|
+
} | null | undefined>;
|
|
28
31
|
};
|
|
29
32
|
export function makeMockChainStorageRoot(): MockChainStorageRoot;
|
|
30
33
|
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":"AAwBO,yCAHI,MAAM,UACN,MAAM,
|
|
1
|
+
{"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AAwBO,yCAHI,MAAM,UACN,MAAM,6GAGC;AAElB;;;GAGG;AACH;;;;;EAEG;AA4CH,8CAtBuB,GAAG,KAAK,GAAG,CAsB+B;AAU1D,6CAHI,MAAM,gBACN,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;;oBA2GjD,CAAA;;;;UAEiB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;;0BAjFxB,cAAc;;;0JAAd,cAAc;;;;EAqF7B;AAoBM,4CADO,oBAAoB,CA6BjC;AAQM,yCALI,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,iBAkCnD;6BAtFa,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;qCAjNJ,uBAAuB;iCAMF,uBAAuB;oCAAvB,uBAAuB;gCAAvB,uBAAuB"}
|
|
@@ -108,82 +108,86 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
|
|
|
108
108
|
};
|
|
109
109
|
/** @type {StorageMessage[]} */
|
|
110
110
|
const messages = [];
|
|
111
|
-
/** @param {StorageMessage} message */
|
|
112
111
|
|
|
113
|
-
const toStorage =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return data.has(key) ? data.get(key) : null;
|
|
123
|
-
}
|
|
124
|
-
case 'children': {
|
|
125
|
-
const [key] = message.args;
|
|
126
|
-
const childEntries = getChildEntries(`${key}.`);
|
|
127
|
-
return [...childEntries.keys()];
|
|
128
|
-
}
|
|
129
|
-
case 'entries': {
|
|
130
|
-
const [key] = message.args;
|
|
131
|
-
const childEntries = getChildEntries(`${key}.`);
|
|
132
|
-
return [...childEntries.entries()].map(entry =>
|
|
133
|
-
entry[1] != null ? entry : [entry[0]],
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
case 'set':
|
|
137
|
-
case 'setWithoutNotify': {
|
|
138
|
-
trace('toStorage set', message);
|
|
139
|
-
/** @type {StorageEntry[]} */
|
|
140
|
-
const newEntries = message.args;
|
|
141
|
-
for (const [key, value] of newEntries) {
|
|
142
|
-
if (value != null) {
|
|
143
|
-
data.set(key, value);
|
|
144
|
-
} else {
|
|
145
|
-
data.delete(key);
|
|
146
|
-
}
|
|
112
|
+
const toStorage = Far(
|
|
113
|
+
'ToStorage',
|
|
114
|
+
/** @param {StorageMessage} message */
|
|
115
|
+
message => {
|
|
116
|
+
messages.push(message);
|
|
117
|
+
switch (message.method) {
|
|
118
|
+
case 'getStoreKey': {
|
|
119
|
+
const [key] = message.args;
|
|
120
|
+
return { storeName: 'swingset', storeSubkey: `fake:${key}` };
|
|
147
121
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
122
|
+
case 'get': {
|
|
123
|
+
const [key] = message.args;
|
|
124
|
+
return data.has(key) ? data.get(key) : null;
|
|
125
|
+
}
|
|
126
|
+
case 'children': {
|
|
127
|
+
const [key] = message.args;
|
|
128
|
+
const childEntries = getChildEntries(`${key}.`);
|
|
129
|
+
return [...childEntries.keys()];
|
|
130
|
+
}
|
|
131
|
+
case 'entries': {
|
|
132
|
+
const [key] = message.args;
|
|
133
|
+
const childEntries = getChildEntries(`${key}.`);
|
|
134
|
+
return [...childEntries.entries()].map(entry =>
|
|
135
|
+
entry[1] != null ? entry : [entry[0]],
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
case 'set':
|
|
139
|
+
case 'setWithoutNotify': {
|
|
140
|
+
trace('toStorage set', message);
|
|
141
|
+
/** @type {StorageEntry[]} */
|
|
142
|
+
const newEntries = message.args;
|
|
143
|
+
for (const [key, value] of newEntries) {
|
|
144
|
+
if (value != null) {
|
|
145
|
+
data.set(key, value);
|
|
146
|
+
} else {
|
|
147
|
+
data.delete(key);
|
|
165
148
|
}
|
|
166
149
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case 'append': {
|
|
153
|
+
trace('toStorage append', message);
|
|
154
|
+
/** @type {StorageEntry[]} */
|
|
155
|
+
const newEntries = message.args;
|
|
156
|
+
for (const [key, value] of newEntries) {
|
|
157
|
+
value != null || Fail`attempt to append with no value`;
|
|
158
|
+
// In the absence of block boundaries, everything goes in a single StreamCell.
|
|
159
|
+
const oldVal = data.get(key);
|
|
160
|
+
let streamCell;
|
|
161
|
+
if (oldVal != null) {
|
|
162
|
+
try {
|
|
163
|
+
streamCell = JSON.parse(oldVal);
|
|
164
|
+
assert(isStreamCell(streamCell));
|
|
165
|
+
} catch (_err) {
|
|
166
|
+
streamCell = undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (streamCell === undefined) {
|
|
170
|
+
streamCell = {
|
|
171
|
+
blockHeight: '0',
|
|
172
|
+
values: oldVal != null ? [oldVal] : [],
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
streamCell.values.push(value);
|
|
176
|
+
data.set(key, JSON.stringify(streamCell));
|
|
172
177
|
}
|
|
173
|
-
|
|
174
|
-
data.set(key, JSON.stringify(streamCell));
|
|
178
|
+
break;
|
|
175
179
|
}
|
|
176
|
-
|
|
180
|
+
case 'size':
|
|
181
|
+
// Intentionally incorrect because it counts non-child descendants,
|
|
182
|
+
// but nevertheless supports a "has children" test.
|
|
183
|
+
return [...data.keys()].filter(k =>
|
|
184
|
+
k.startsWith(`${message.args[0]}.`),
|
|
185
|
+
).length;
|
|
186
|
+
default:
|
|
187
|
+
throw Error(`unsupported method: ${message.method}`);
|
|
177
188
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
// but nevertheless supports a "has children" test.
|
|
181
|
-
return [...data.keys()].filter(k => k.startsWith(`${message.args[0]}.`))
|
|
182
|
-
.length;
|
|
183
|
-
default:
|
|
184
|
-
throw Error(`unsupported method: ${message.method}`);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
189
|
+
},
|
|
190
|
+
);
|
|
187
191
|
const rootNode = makeChainStorageRoot(toStorage, rootPath, resolvedOptions);
|
|
188
192
|
return {
|
|
189
193
|
rootNode,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './types.js';
|
package/src/types.d.ts
CHANGED
|
@@ -1,39 +1,27 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
1
|
import type { ERef, RemotableBrand } from '@endo/eventual-send';
|
|
3
2
|
import type { Primitive } from '@endo/pass-style';
|
|
3
|
+
import type { Pattern } from '@endo/patterns';
|
|
4
4
|
import type { Callable } from './utils.js';
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* A map corresponding with a total function such that `get(key)` is assumed to
|
|
8
7
|
* always succeed.
|
|
9
8
|
*/
|
|
10
9
|
export type TotalMap<K, V> = Omit<Map<K, V>, 'get'> & {
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/** Returns the element associated with the specified key in the TotalMap. */
|
|
11
|
+
get: (key: K) => V;
|
|
13
12
|
};
|
|
14
|
-
export type TotalMapFrom<M extends Map>
|
|
15
|
-
M extends Map<infer K, infer V> ? TotalMap<K, V> : never;
|
|
16
|
-
|
|
13
|
+
export type TotalMapFrom<M extends Map<any, any>> = M extends Map<infer K, infer V> ? TotalMap<K, V> : never;
|
|
17
14
|
export declare class Callback<I extends (...args: any[]) => any> {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
public bound: unknown[];
|
|
25
|
-
|
|
26
|
-
public isSync: boolean;
|
|
15
|
+
private iface;
|
|
16
|
+
target: any;
|
|
17
|
+
methodName?: PropertyKey;
|
|
18
|
+
bound: unknown[];
|
|
19
|
+
isSync: boolean;
|
|
27
20
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
> extends Callback<I> {
|
|
32
|
-
private syncIface: I;
|
|
33
|
-
|
|
34
|
-
public isSync: true;
|
|
21
|
+
export declare class SyncCallback<I extends (...args: unknown[]) => any> extends Callback<I> {
|
|
22
|
+
private syncIface;
|
|
23
|
+
isSync: true;
|
|
35
24
|
}
|
|
36
|
-
|
|
37
25
|
/**
|
|
38
26
|
Returns a boolean for whether the given type is primitive value or primitive type.
|
|
39
27
|
|
|
@@ -50,48 +38,28 @@ IsPrimitive<Object>
|
|
|
50
38
|
```
|
|
51
39
|
*/
|
|
52
40
|
export type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
|
|
53
|
-
|
|
54
41
|
/** Recursively extract the non-callable properties of T */
|
|
55
|
-
export type DataOnly<T> =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
: T extends Callable
|
|
59
|
-
? never
|
|
60
|
-
: { [P in keyof T as T[P] extends Callable ? never : P]: DataOnly<T[P]> };
|
|
61
|
-
|
|
42
|
+
export type DataOnly<T> = IsPrimitive<T> extends true ? T : T extends Callable ? never : {
|
|
43
|
+
[P in keyof T as T[P] extends Callable ? never : P]: DataOnly<T[P]>;
|
|
44
|
+
};
|
|
62
45
|
/**
|
|
63
46
|
* A type that doesn't assume its parameter is local, but is satisfied with both
|
|
64
47
|
* local and remote references. It accepts both near and marshalled references
|
|
65
48
|
* that were returned from `Remotable` or `Far`.
|
|
66
49
|
*/
|
|
67
|
-
export type Remote<Primary, Local = DataOnly<Primary>> =
|
|
68
|
-
| Primary
|
|
69
|
-
| RemotableBrand<Local, Primary>;
|
|
70
|
-
|
|
71
|
-
// TODO: Add type tests for FarRef and Remote.
|
|
50
|
+
export type Remote<Primary, Local = DataOnly<Primary>> = Primary | RemotableBrand<Local, Primary>;
|
|
72
51
|
/**
|
|
73
52
|
* Potentially remote promises or settled references.
|
|
74
53
|
*/
|
|
75
|
-
export type FarRef<Primary, Local = DataOnly<Primary>> = ERef<
|
|
76
|
-
Remote<Primary, Local>
|
|
77
|
-
>;
|
|
78
|
-
|
|
79
|
-
/*
|
|
80
|
-
* Stop-gap until https://github.com/Agoric/agoric-sdk/issues/6160
|
|
81
|
-
* explictly specify the type that the Pattern will verify through a match.
|
|
82
|
-
*
|
|
83
|
-
* TODO move all this pattern typing stuff to @endo/patterns
|
|
84
|
-
*/
|
|
54
|
+
export type FarRef<Primary, Local = DataOnly<Primary>> = ERef<Remote<Primary, Local>>;
|
|
85
55
|
declare const validatedType: unique symbol;
|
|
86
56
|
/**
|
|
87
57
|
* Tag a pattern with the static type it represents.
|
|
88
58
|
*/
|
|
89
|
-
export type TypedPattern<T> = Pattern & {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
// TODO make Endo's mustMatch do this
|
|
59
|
+
export type TypedPattern<T> = Pattern & {
|
|
60
|
+
[validatedType]?: T;
|
|
61
|
+
};
|
|
62
|
+
export declare type PatternType<TM extends TypedPattern<any>> = TM extends TypedPattern<infer T> ? T : never;
|
|
95
63
|
/**
|
|
96
64
|
* Returning normally indicates success. Match failure is indicated by
|
|
97
65
|
* throwing.
|
|
@@ -100,8 +68,6 @@ export declare type PatternType<TM extends TypedPattern<any>> =
|
|
|
100
68
|
*
|
|
101
69
|
* @see {import('@endo/patterns').mustMatch} for the implementation. This one has a type annotation to narrow if the pattern is a TypedPattern.
|
|
102
70
|
*/
|
|
103
|
-
export declare type MustMatch = <P extends Pattern>(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
label?: string | number,
|
|
107
|
-
) => asserts specimen is P extends TypedPattern<any> ? PatternType<P> : unknown;
|
|
71
|
+
export declare type MustMatch = <P extends Pattern>(specimen: unknown, pattern: P, label?: string | number) => asserts specimen is P extends TypedPattern<any> ? PatternType<P> : unknown;
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG;IACpD,6EAA6E;IAC7E,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,IAC9C,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG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AE,KAAK,CAAC,CACvB,CAAC;AAQF,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAC3C;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,OAAO,GAAG;IAAE,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC;AAEhE,MAAM,CAAC,OAAO,MAAM,WAAW,CAAC,EAAE,SAAS,YAAY,CAAC,GAAG,CAAC,IAC1D,EAAE,SAAS,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAG/C;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,MAAM,SAAS,GAAG,CAAC,CAAC,SAAS,OAAO,EAChD,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,CAAC,EACV,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,KACpB,OAAO,CAAC,QAAQ,IAAI,CAAC,SAAS,YAAY,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC"}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import type { ERef, RemotableBrand } from '@endo/eventual-send';
|
|
3
|
+
import type { Primitive } from '@endo/pass-style';
|
|
4
|
+
import type { Pattern } from '@endo/patterns';
|
|
5
|
+
import type { Callable } from './utils.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A map corresponding with a total function such that `get(key)` is assumed to
|
|
9
|
+
* always succeed.
|
|
10
|
+
*/
|
|
11
|
+
export type TotalMap<K, V> = Omit<Map<K, V>, 'get'> & {
|
|
12
|
+
/** Returns the element associated with the specified key in the TotalMap. */
|
|
13
|
+
get: (key: K) => V;
|
|
14
|
+
};
|
|
15
|
+
export type TotalMapFrom<M extends Map<any, any>> =
|
|
16
|
+
M extends Map<infer K, infer V> ? TotalMap<K, V> : never;
|
|
17
|
+
|
|
18
|
+
export declare class Callback<I extends (...args: any[]) => any> {
|
|
19
|
+
private iface: I;
|
|
20
|
+
|
|
21
|
+
public target: any;
|
|
22
|
+
|
|
23
|
+
public methodName?: PropertyKey;
|
|
24
|
+
|
|
25
|
+
public bound: unknown[];
|
|
26
|
+
|
|
27
|
+
public isSync: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare class SyncCallback<
|
|
31
|
+
I extends (...args: unknown[]) => any,
|
|
32
|
+
> extends Callback<I> {
|
|
33
|
+
private syncIface: I;
|
|
34
|
+
|
|
35
|
+
public isSync: true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
Returns a boolean for whether the given type is primitive value or primitive type.
|
|
40
|
+
|
|
41
|
+
@example
|
|
42
|
+
```
|
|
43
|
+
IsPrimitive<'string'>
|
|
44
|
+
//=> true
|
|
45
|
+
|
|
46
|
+
IsPrimitive<string>
|
|
47
|
+
//=> true
|
|
48
|
+
|
|
49
|
+
IsPrimitive<Object>
|
|
50
|
+
//=> false
|
|
51
|
+
```
|
|
52
|
+
*/
|
|
53
|
+
export type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
|
|
54
|
+
|
|
55
|
+
/** Recursively extract the non-callable properties of T */
|
|
56
|
+
export type DataOnly<T> =
|
|
57
|
+
IsPrimitive<T> extends true
|
|
58
|
+
? T
|
|
59
|
+
: T extends Callable
|
|
60
|
+
? never
|
|
61
|
+
: { [P in keyof T as T[P] extends Callable ? never : P]: DataOnly<T[P]> };
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A type that doesn't assume its parameter is local, but is satisfied with both
|
|
65
|
+
* local and remote references. It accepts both near and marshalled references
|
|
66
|
+
* that were returned from `Remotable` or `Far`.
|
|
67
|
+
*/
|
|
68
|
+
export type Remote<Primary, Local = DataOnly<Primary>> =
|
|
69
|
+
| Primary
|
|
70
|
+
| RemotableBrand<Local, Primary>;
|
|
71
|
+
|
|
72
|
+
// TODO: Add type tests for FarRef and Remote.
|
|
73
|
+
/**
|
|
74
|
+
* Potentially remote promises or settled references.
|
|
75
|
+
*/
|
|
76
|
+
export type FarRef<Primary, Local = DataOnly<Primary>> = ERef<
|
|
77
|
+
Remote<Primary, Local>
|
|
78
|
+
>;
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
* Stop-gap until https://github.com/Agoric/agoric-sdk/issues/6160
|
|
82
|
+
* explictly specify the type that the Pattern will verify through a match.
|
|
83
|
+
*
|
|
84
|
+
* TODO move all this pattern typing stuff to @endo/patterns
|
|
85
|
+
*/
|
|
86
|
+
declare const validatedType: unique symbol;
|
|
87
|
+
/**
|
|
88
|
+
* Tag a pattern with the static type it represents.
|
|
89
|
+
*/
|
|
90
|
+
export type TypedPattern<T> = Pattern & { [validatedType]?: T };
|
|
91
|
+
|
|
92
|
+
export declare type PatternType<TM extends TypedPattern<any>> =
|
|
93
|
+
TM extends TypedPattern<infer T> ? T : never;
|
|
94
|
+
|
|
95
|
+
// TODO make Endo's mustMatch do this
|
|
96
|
+
/**
|
|
97
|
+
* Returning normally indicates success. Match failure is indicated by
|
|
98
|
+
* throwing.
|
|
99
|
+
*
|
|
100
|
+
* Note: remotables can only be matched as "remotable", not the specific kind.
|
|
101
|
+
*
|
|
102
|
+
* @see {import('@endo/patterns').mustMatch} for the implementation. This one has a type annotation to narrow if the pattern is a TypedPattern.
|
|
103
|
+
*/
|
|
104
|
+
export declare type MustMatch = <P extends Pattern>(
|
|
105
|
+
specimen: unknown,
|
|
106
|
+
pattern: P,
|
|
107
|
+
label?: string | number,
|
|
108
|
+
) => asserts specimen is P extends TypedPattern<any> ? PatternType<P> : unknown;
|
package/src/upgrade-api.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export namespace UpgradeDisconnectionShape {
|
|
|
5
5
|
}
|
|
6
6
|
export function makeUpgradeDisconnection(upgradeMessage: string, toIncarnationNumber: number): UpgradeDisconnection;
|
|
7
7
|
export function isUpgradeDisconnection(reason: any): reason is UpgradeDisconnection;
|
|
8
|
+
export function isAbandonedError(reason: any): reason is Error;
|
|
8
9
|
/**
|
|
9
10
|
* An Error-like object for use as the rejection reason of promises abandoned by
|
|
10
11
|
* upgrade.
|
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,
|
|
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,CAKC;AAgBrC,yCAHI,GAAG,GACD,MAAM,IAAI,KAAK,CAQS;;;;;mCA5DxB;IACR,IAAI,EAAE,aAAa,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;CAC3B"}
|
package/src/upgrade-api.js
CHANGED
|
@@ -45,5 +45,29 @@ harden(makeUpgradeDisconnection);
|
|
|
45
45
|
* @returns {reason is UpgradeDisconnection}
|
|
46
46
|
*/
|
|
47
47
|
export const isUpgradeDisconnection = reason =>
|
|
48
|
-
|
|
48
|
+
reason != null && // eslint-disable-line eqeqeq
|
|
49
|
+
isFrozen(reason) &&
|
|
50
|
+
matches(reason, UpgradeDisconnectionShape);
|
|
49
51
|
harden(isUpgradeDisconnection);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Returns whether a reason is a 'vat terminated' error generated when an object
|
|
55
|
+
* is abandoned by a vat during an upgrade.
|
|
56
|
+
*
|
|
57
|
+
* Normally we do not want to rely on the `message` of an error object, but this
|
|
58
|
+
* is a pragmatic solution to the current state of vat upgrade errors. In the
|
|
59
|
+
* future we'd prefer having an error with a cause referencing a disconnection
|
|
60
|
+
* object like for promise rejections. See
|
|
61
|
+
* https://github.com/Agoric/agoric-sdk/issues/9582
|
|
62
|
+
*
|
|
63
|
+
* @param {any} reason
|
|
64
|
+
* @returns {reason is Error}
|
|
65
|
+
*/
|
|
66
|
+
export const isAbandonedError = reason =>
|
|
67
|
+
reason != null && // eslint-disable-line eqeqeq
|
|
68
|
+
isFrozen(reason) &&
|
|
69
|
+
matches(reason, M.error()) &&
|
|
70
|
+
// We're not using a constant here since this special value is already
|
|
71
|
+
// sprinkled throughout the SDK
|
|
72
|
+
reason.message === 'vat terminated';
|
|
73
|
+
harden(isAbandonedError);
|
package/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAWA,kCAAoC;AAEpC,sCAAsC;AAEtC;;;;;GAKG;AAEH;;GAEG;AAEH;;;;;GAKG;AAEH;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,oCAFU,CAAC,CAAY,SAAF,EAAE,EAAE,gBAAgB,EAAE,CAAC,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAKxE;AAgDK,mCAJI,MAAM,UACN,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,GAAG,GAC/C,MAAM,CAGuC;AAsBnD,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,
|
|
1
|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GAAG,CAAC,GAC9B,OAAO,CAAC,CAAC,CAAC,GACV,CAAC,SAAS,EAAE,GACV,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,GAChC,OAAO,CAAC,CAAC,CAAC;uBAyKkB,CAAC,SAA1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE,IACzB,GAAG,CAAY,IAAP,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAE;0BApMjC,WAAW"}
|
package/src/utils.js
CHANGED
|
@@ -401,6 +401,10 @@ export const synchronizedTee = (sourceStream, readerCount) => {
|
|
|
401
401
|
[Symbol.asyncIterator]() {
|
|
402
402
|
return reader;
|
|
403
403
|
},
|
|
404
|
+
// eslint-disable-next-line no-restricted-globals
|
|
405
|
+
async [Symbol.asyncDispose]() {
|
|
406
|
+
await reader.return();
|
|
407
|
+
},
|
|
404
408
|
});
|
|
405
409
|
return reader;
|
|
406
410
|
});
|
|
File without changes
|