@agoric/internal 0.3.3-other-dev-1f26562.0 → 0.3.3-other-dev-3eb1a1d.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/README.md +7 -2
- package/exported.js +2 -0
- package/package.json +35 -17
- package/src/action-types.d.ts +50 -5
- package/src/action-types.d.ts.map +1 -1
- package/src/action-types.js +73 -14
- package/src/batched-deliver.d.ts +9 -6
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/batched-deliver.js +9 -3
- package/src/callback.d.ts +23 -16
- package/src/callback.d.ts.map +1 -1
- package/src/callback.js +48 -55
- 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/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 +24 -12
- package/src/config.d.ts.map +1 -1
- package/src/config.js +21 -10
- package/src/debug.d.ts +1 -1
- package/src/errors.d.ts +2 -0
- package/src/errors.d.ts.map +1 -0
- package/src/errors.js +16 -0
- package/src/index.d.ts +8 -1
- package/src/index.js +12 -2
- package/src/install-ses-debug.d.ts +2 -0
- package/src/install-ses-debug.d.ts.map +1 -0
- package/src/install-ses-debug.js +6 -0
- 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 +42 -52
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +88 -77
- package/src/lib-nodejs/engine-gc.d.ts +3 -0
- package/src/lib-nodejs/engine-gc.d.ts.map +1 -0
- package/src/lib-nodejs/engine-gc.js +22 -0
- package/src/lib-nodejs/gc-and-finalize.d.ts +2 -0
- package/src/lib-nodejs/gc-and-finalize.d.ts.map +1 -0
- package/src/lib-nodejs/gc-and-finalize.js +91 -0
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts +15 -0
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -0
- package/src/lib-nodejs/spawnSubprocessWorker.js +89 -0
- package/src/lib-nodejs/waitUntilQuiescent.d.ts +2 -0
- package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -0
- package/src/lib-nodejs/waitUntilQuiescent.js +18 -0
- package/src/lib-nodejs/worker-protocol.d.ts +4 -0
- package/src/lib-nodejs/worker-protocol.d.ts.map +1 -0
- package/src/lib-nodejs/worker-protocol.js +54 -0
- package/src/magic-cookie-test-only.js +2 -2
- package/src/marshal.d.ts +20 -0
- package/src/marshal.d.ts.map +1 -0
- package/src/marshal.js +137 -0
- package/src/method-tools.d.ts +1 -0
- package/src/method-tools.d.ts.map +1 -1
- package/src/method-tools.js +29 -16
- package/src/netstring.d.ts +24 -0
- package/src/netstring.d.ts.map +1 -0
- package/src/netstring.js +124 -0
- package/src/node/buffer-line-transform.d.ts +17 -13
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/buffer-line-transform.js +12 -9
- package/src/node/createBundles.d.ts.map +1 -1
- package/src/node/createBundles.js +12 -3
- 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 -30
- package/src/node/shutdown.d.ts.map +1 -1
- package/src/node/shutdown.js +0 -1
- package/src/priority-senders.d.ts +1 -1
- package/src/priority-senders.d.ts.map +1 -1
- package/src/priority-senders.js +8 -5
- package/src/queue.d.ts +1 -1
- package/src/queue.d.ts.map +1 -1
- package/src/queue.js +7 -8
- package/src/scratch.d.ts +1 -1
- package/src/scratch.d.ts.map +1 -1
- package/src/ses-utils.d.ts +60 -0
- package/src/ses-utils.d.ts.map +1 -0
- package/src/ses-utils.js +346 -0
- package/src/storage-test-utils.d.ts +41 -84
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +169 -116
- package/src/tagged.d.ts +149 -0
- package/src/testing-utils.d.ts +2 -0
- package/src/testing-utils.d.ts.map +1 -1
- package/src/testing-utils.js +44 -5
- package/src/tokens.d.ts +34 -0
- package/src/tokens.d.ts.map +1 -0
- package/src/tokens.js +35 -0
- package/src/typeCheck.d.ts +9 -0
- package/src/typeCheck.d.ts.map +1 -0
- package/src/typeCheck.js +23 -0
- package/src/typeGuards.d.ts +2 -0
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +8 -0
- package/src/types-index.d.ts +1 -0
- package/src/types-index.js +2 -0
- package/src/types.d.ts +71 -18
- package/src/types.d.ts.map +1 -0
- package/src/types.ts +108 -0
- package/src/upgrade-api.d.ts +14 -4
- package/src/upgrade-api.d.ts.map +1 -1
- package/src/upgrade-api.js +50 -18
- package/CHANGELOG.md +0 -106
- package/src/utils.d.ts +0 -67
- package/src/utils.d.ts.map +0 -1
- package/src/utils.js +0 -451
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* These identify top-level paths for SwingSet chain storage
|
|
5
|
-
*
|
|
6
|
-
* To avoid collisions, they should remain synchronized with
|
|
4
|
+
* These identify top-level paths for SwingSet chain storage (and serve as
|
|
5
|
+
* prefixes). To avoid collisions, they should remain synchronized with
|
|
7
6
|
* golang/cosmos/x/swingset/keeper/keeper.go
|
|
8
7
|
*/
|
|
9
8
|
export const ACTION_QUEUE = 'actionQueue';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function makeInitMsg(initAction: any): InitMsg;
|
|
2
|
+
export type NatString = `${bigint}`;
|
|
3
|
+
export type BlockInfo = {
|
|
4
|
+
blockHeight: number;
|
|
5
|
+
/**
|
|
6
|
+
* POSIX Seconds Since the Epoch
|
|
7
|
+
*/
|
|
8
|
+
blockTime: number;
|
|
9
|
+
params: import("@agoric/cosmic-proto/swingset/swingset.js").ParamsSDKType;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* cosmosInitAction fields that are subject to consensus. See cosmosInitAction
|
|
13
|
+
* in {@link ../../../golang/cosmos/app/app.go}.
|
|
14
|
+
*/
|
|
15
|
+
export type InitMsg = BlockInfo & {
|
|
16
|
+
type: typeof _ActionType.AG_COSMOS_INIT;
|
|
17
|
+
chainID: string;
|
|
18
|
+
isBootstrap?: boolean;
|
|
19
|
+
supplyCoins: {
|
|
20
|
+
denom: string;
|
|
21
|
+
amount: NatString;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
import * as _ActionType from './action-types.js';
|
|
25
|
+
//# sourceMappingURL=chain-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-utils.d.ts","sourceRoot":"","sources":["chain-utils.js"],"names":[],"mappings":"AAsCO,wCAHI,GAAG,GACD,OAAO,CAoBnB;wBA1Ca,GAAG,MAAM,EAAE;;iBAIX,MAAM;;;;eACN,MAAM;YACN,OAAO,2CAA2C,EAAE,aAAa;;;;;;sBAIlE,SAAS,GAAG;IACpB,IAAI,EAAE,OAAO,WAAW,CAAC,cAAc,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,SAAS,CAAA;KAAE,EAAE,CAAC;CACrD;6BAjByB,mBAAmB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Types and utilities for supporting blockchain functionality without
|
|
3
|
+
* risking import cycles.
|
|
4
|
+
*
|
|
5
|
+
* TODO: Integrate (or integrate with) any/all of:
|
|
6
|
+
*
|
|
7
|
+
* - ./action-types.js
|
|
8
|
+
* - ./chain-storage-paths.js
|
|
9
|
+
* - ./config.js
|
|
10
|
+
* - ../../cosmic-proto (if comfortable co-residing with generated code)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import * as _ActionType from './action-types.js';
|
|
14
|
+
|
|
15
|
+
/** @typedef {`${bigint}`} NatString */
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {object} BlockInfo
|
|
19
|
+
* @property {number} blockHeight
|
|
20
|
+
* @property {number} blockTime POSIX Seconds Since the Epoch
|
|
21
|
+
* @property {import('@agoric/cosmic-proto/swingset/swingset.js').ParamsSDKType} params
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {BlockInfo & {
|
|
26
|
+
* type: typeof _ActionType.AG_COSMOS_INIT;
|
|
27
|
+
* chainID: string;
|
|
28
|
+
* isBootstrap?: boolean;
|
|
29
|
+
* supplyCoins: { denom: string; amount: NatString }[];
|
|
30
|
+
* }} InitMsg
|
|
31
|
+
* cosmosInitAction fields that are subject to consensus. See cosmosInitAction
|
|
32
|
+
* in {@link ../../../golang/cosmos/app/app.go}.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param {any} initAction
|
|
37
|
+
* @returns {InitMsg}
|
|
38
|
+
*/
|
|
39
|
+
export const makeInitMsg = initAction => {
|
|
40
|
+
const {
|
|
41
|
+
type,
|
|
42
|
+
blockHeight,
|
|
43
|
+
blockTime,
|
|
44
|
+
chainID,
|
|
45
|
+
params,
|
|
46
|
+
// NB: resolvedConfig is independent of consensus and MUST NOT be included
|
|
47
|
+
supplyCoins,
|
|
48
|
+
} = initAction;
|
|
49
|
+
return {
|
|
50
|
+
type,
|
|
51
|
+
blockHeight,
|
|
52
|
+
blockTime,
|
|
53
|
+
chainID,
|
|
54
|
+
params,
|
|
55
|
+
supplyCoins,
|
|
56
|
+
};
|
|
57
|
+
};
|
package/src/config.d.ts
CHANGED
|
@@ -1,24 +1,36 @@
|
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
let BANK: "bank";
|
|
7
|
+
let CORE: "core";
|
|
8
|
+
let DIBC: "dibc";
|
|
9
|
+
let STORAGE: "storage";
|
|
10
|
+
let PROVISION: "provision";
|
|
11
|
+
let PROVISION_SMART_WALLET: "provisionWallet";
|
|
12
|
+
let VLOCALCHAIN: "vlocalchain";
|
|
13
|
+
let VTRANSFER: "vtransfer";
|
|
14
|
+
let WALLET: "wallet";
|
|
15
|
+
}
|
|
16
|
+
export namespace CosmosInitKeyToBridgeId {
|
|
17
|
+
import vbankPort = BANK;
|
|
18
|
+
export { vbankPort };
|
|
19
|
+
import vibcPort = DIBC;
|
|
20
|
+
export { vibcPort };
|
|
9
21
|
}
|
|
10
22
|
export namespace WalletName {
|
|
11
|
-
|
|
23
|
+
let depositFacet: "depositFacet";
|
|
12
24
|
}
|
|
13
25
|
export namespace VBankAccount {
|
|
14
26
|
namespace reserve {
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
let module: "vbank/reserve";
|
|
28
|
+
let address: "agoric1ae0lmtzlgrcnla9xjkpaarq5d5dfez63h3nucl";
|
|
17
29
|
}
|
|
18
30
|
namespace provision {
|
|
19
|
-
|
|
31
|
+
let module_1: "vbank/provision";
|
|
20
32
|
export { module_1 as module };
|
|
21
|
-
|
|
33
|
+
let address_1: "agoric1megzytg65cyrgzs6fvzxgrcqvwwl7ugpt62346";
|
|
22
34
|
export { address_1 as address };
|
|
23
35
|
}
|
|
24
36
|
}
|
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
|
@@ -4,34 +4,45 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @file
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Some of this config info may make more sense in a particular package. However
|
|
8
|
+
* due to https://github.com/Agoric/agoric-sdk/issues/4620 and our lax package
|
|
9
|
+
* dependency graph, sometimes rational placements cause type resolution
|
|
10
|
+
* errors.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
+
* So as a work-around some constants that need access from more than one
|
|
13
|
+
* package are placed here.
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Event source ids used by the bridge device.
|
|
18
|
+
*
|
|
19
|
+
* @enum {(typeof BridgeId)[keyof typeof BridgeId]}
|
|
16
20
|
*/
|
|
17
|
-
export const BridgeId = {
|
|
21
|
+
export const BridgeId = /** @type {const} */ ({
|
|
18
22
|
BANK: 'bank',
|
|
19
23
|
CORE: 'core',
|
|
20
24
|
DIBC: 'dibc',
|
|
21
25
|
STORAGE: 'storage',
|
|
22
26
|
PROVISION: 'provision',
|
|
23
27
|
PROVISION_SMART_WALLET: 'provisionWallet',
|
|
28
|
+
VLOCALCHAIN: 'vlocalchain',
|
|
29
|
+
VTRANSFER: 'vtransfer',
|
|
24
30
|
WALLET: 'wallet',
|
|
25
|
-
};
|
|
31
|
+
});
|
|
26
32
|
harden(BridgeId);
|
|
27
33
|
|
|
28
|
-
export const
|
|
29
|
-
|
|
34
|
+
export const CosmosInitKeyToBridgeId = {
|
|
35
|
+
vbankPort: BridgeId.BANK,
|
|
36
|
+
vibcPort: BridgeId.DIBC,
|
|
30
37
|
};
|
|
38
|
+
|
|
39
|
+
export const WalletName = /** @type {const} */ ({
|
|
40
|
+
depositFacet: 'depositFacet',
|
|
41
|
+
});
|
|
31
42
|
harden(WalletName);
|
|
32
43
|
|
|
33
44
|
// defined in golang/cosmos/x/vbank
|
|
34
|
-
export const VBankAccount = {
|
|
45
|
+
export const VBankAccount = /** @type {const} */ ({
|
|
35
46
|
reserve: {
|
|
36
47
|
module: 'vbank/reserve',
|
|
37
48
|
address: 'agoric1ae0lmtzlgrcnla9xjkpaarq5d5dfez63h3nucl',
|
|
@@ -40,5 +51,5 @@ export const VBankAccount = {
|
|
|
40
51
|
module: 'vbank/provision',
|
|
41
52
|
address: 'agoric1megzytg65cyrgzs6fvzxgrcqvwwl7ugpt62346',
|
|
42
53
|
},
|
|
43
|
-
};
|
|
54
|
+
});
|
|
44
55
|
harden(VBankAccount);
|
package/src/debug.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function makeTracer(name: string, enable?: boolean |
|
|
1
|
+
export function makeTracer(name: string, enable?: boolean | "verbose"): (..._args: any[]) => void;
|
|
2
2
|
//# sourceMappingURL=debug.d.ts.map
|
package/src/errors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["errors.js"],"names":[],"mappings":"AAQO,2BALM,CAAC,OACH,CAAC,GAAG,IAAI,GAAG,SAAS,oCAElB,CAAC,CAQb"}
|
package/src/errors.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { q } from '@endo/errors';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @template T
|
|
5
|
+
* @param {T | null | undefined} val
|
|
6
|
+
* @param {string} [optDetails]
|
|
7
|
+
* @returns {T}
|
|
8
|
+
*/
|
|
9
|
+
export const NonNullish = (val, optDetails = `unexpected ${q(val)}`) => {
|
|
10
|
+
if (val != null) {
|
|
11
|
+
// This `!= null` idiom checks that `val` is neither `null` nor `undefined`.
|
|
12
|
+
return val;
|
|
13
|
+
}
|
|
14
|
+
assert.fail(optDetails);
|
|
15
|
+
};
|
|
16
|
+
harden(NonNullish);
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
export * from "./config.js";
|
|
2
2
|
export * from "./debug.js";
|
|
3
|
-
export * from "./
|
|
3
|
+
export * from "./errors.js";
|
|
4
|
+
export * from "./js-utils.js";
|
|
4
5
|
export * from "./method-tools.js";
|
|
6
|
+
export * from "./ses-utils.js";
|
|
7
|
+
export * from "./typeCheck.js";
|
|
5
8
|
export * from "./typeGuards.js";
|
|
9
|
+
export * from "./types-index.js";
|
|
10
|
+
export { objectMap } from "@endo/common/object-map.js";
|
|
11
|
+
export { objectMetaMap } from "@endo/common/object-meta-map.js";
|
|
12
|
+
export { fromUniqueEntries } from "@endo/common/from-unique-entries.js";
|
|
6
13
|
//# sourceMappingURL=index.d.ts.map
|
package/src/index.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
|
-
/// <reference types="ses"/>
|
|
3
|
+
/// <reference types="ses" />
|
|
4
4
|
|
|
5
5
|
export * from './config.js';
|
|
6
6
|
export * from './debug.js';
|
|
7
|
-
export * from './
|
|
7
|
+
export * from './errors.js';
|
|
8
|
+
export * from './js-utils.js';
|
|
8
9
|
export * from './method-tools.js';
|
|
10
|
+
export * from './ses-utils.js';
|
|
11
|
+
export * from './typeCheck.js';
|
|
9
12
|
export * from './typeGuards.js';
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line import/export -- just types
|
|
15
|
+
export * from './types-index.js';
|
|
16
|
+
|
|
17
|
+
export { objectMap } from '@endo/common/object-map.js';
|
|
18
|
+
export { objectMetaMap } from '@endo/common/object-meta-map.js';
|
|
19
|
+
export { fromUniqueEntries } from '@endo/common/from-unique-entries.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-ses-debug.d.ts","sourceRoot":"","sources":["install-ses-debug.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// This is like `@endo/init` but sacrificing safety to optimize
|
|
2
|
+
// for debugging and testing. The difference is only the lockdown options.
|
|
3
|
+
// The setting below are *unsafe* and should not be used in contact with
|
|
4
|
+
// genuinely malicious code.
|
|
5
|
+
|
|
6
|
+
import '@endo/init/debug.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function deepCopyJsonable<T>(value: T): T;
|
|
2
|
+
export function deepMapObject(obj: object, mapper: (value: any, name: string, record: object) => any): object;
|
|
3
|
+
export function makeMeasureSeconds(currentTimeMillisec: () => number): <T>(fn: () => Promise<T>) => Promise<{
|
|
4
|
+
result: T;
|
|
5
|
+
duration: number;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=js-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-utils.d.ts","sourceRoot":"","sources":["js-utils.js"],"names":[],"mappings":"AAgBO,iCAJM,CAAC,SACH,CAAC,GACC,CAAC,CAE4D;AAiDnE,mCAJI,MAAM,UACN,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,GAAG,GAC/C,MAAM,CAGuC;AASnD,wDAFI,MAAM,MAAM,IAIR,CAAC,MACH,MAAM,OAAO,CAAC,CAAC,CAAC,KACd,OAAO,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAStD"}
|
package/src/js-utils.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// @jessie-check
|
|
3
|
+
/**
|
|
4
|
+
* @file Pure JavaScript utility functions that are compatible with but not
|
|
5
|
+
* dependent upon a hardened environment.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Deep-copy a value by round-tripping it through JSON (which drops
|
|
10
|
+
* function/symbol/undefined values and properties that are non-enumerable
|
|
11
|
+
* and/or symbol-keyed, and rejects bigint values).
|
|
12
|
+
*
|
|
13
|
+
* @template T
|
|
14
|
+
* @param {T} value
|
|
15
|
+
* @returns {T}
|
|
16
|
+
*/
|
|
17
|
+
export const deepCopyJsonable = value => JSON.parse(JSON.stringify(value));
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {any} value
|
|
21
|
+
* @param {string | undefined} name
|
|
22
|
+
* @param {object | undefined} container
|
|
23
|
+
* @param {(value: any, name: string, record: object) => any} mapper
|
|
24
|
+
* @returns {any}
|
|
25
|
+
*/
|
|
26
|
+
const deepMapObjectInternal = (value, name, container, mapper) => {
|
|
27
|
+
if (container && typeof name === 'string') {
|
|
28
|
+
const mapped = mapper(value, name, container);
|
|
29
|
+
if (mapped !== value) {
|
|
30
|
+
return mapped;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (typeof value !== 'object' || !value) {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let wasMapped = false;
|
|
39
|
+
const mappedEntries = Object.entries(value).map(([innerName, innerValue]) => {
|
|
40
|
+
const mappedInnerValue = deepMapObjectInternal(
|
|
41
|
+
innerValue,
|
|
42
|
+
innerName,
|
|
43
|
+
value,
|
|
44
|
+
mapper,
|
|
45
|
+
);
|
|
46
|
+
wasMapped ||= mappedInnerValue !== innerValue;
|
|
47
|
+
return [innerName, mappedInnerValue];
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return wasMapped ? Object.fromEntries(mappedEntries) : value;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Recursively traverses a record object structure, calling a mapper function
|
|
55
|
+
* for each enumerable string-keyed property and returning a record composed of
|
|
56
|
+
* the results. If none of the values are changed, the original object is
|
|
57
|
+
* returned, maintaining its identity.
|
|
58
|
+
*
|
|
59
|
+
* When the property value is an object, it is sent to the mapper like any other
|
|
60
|
+
* value, and then recursively traversed unless replaced with a distinct value.
|
|
61
|
+
*
|
|
62
|
+
* @param {object} obj
|
|
63
|
+
* @param {(value: any, name: string, record: object) => any} mapper
|
|
64
|
+
* @returns {object}
|
|
65
|
+
*/
|
|
66
|
+
export const deepMapObject = (obj, mapper) =>
|
|
67
|
+
deepMapObjectInternal(obj, undefined, undefined, mapper);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Returns a function that uses a millisecond-based current-time capability
|
|
71
|
+
* (such as `performance.now`) to measure execution duration of an async
|
|
72
|
+
* function and report the result in seconds to match our telemetry standard.
|
|
73
|
+
*
|
|
74
|
+
* @param {() => number} currentTimeMillisec
|
|
75
|
+
*/
|
|
76
|
+
export const makeMeasureSeconds = currentTimeMillisec => {
|
|
77
|
+
/**
|
|
78
|
+
* @template T
|
|
79
|
+
* @param {() => Promise<T>} fn
|
|
80
|
+
* @returns {Promise<{ result: T; duration: number }>}
|
|
81
|
+
*/
|
|
82
|
+
const measureSeconds = async fn => {
|
|
83
|
+
const t0 = currentTimeMillisec();
|
|
84
|
+
const result = await fn();
|
|
85
|
+
const durationMillisec = currentTimeMillisec() - t0;
|
|
86
|
+
return { result, duration: durationMillisec / 1000 };
|
|
87
|
+
};
|
|
88
|
+
return measureSeconds;
|
|
89
|
+
};
|
|
@@ -1,41 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Create a heap-based root storage node for a given backing function and root
|
|
2
|
+
* Create a heap-based root storage node for a given backing function and root
|
|
3
|
+
* path.
|
|
3
4
|
*
|
|
4
5
|
* @param {(message: StorageMessage) => any} handleStorageMessage a function for
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* sending a storageMessage object to the storage implementation (cf.
|
|
7
|
+
* golang/cosmos/x/vstorage/vstorage.go)
|
|
7
8
|
* @param {string} rootPath
|
|
8
9
|
* @param {object} [rootOptions]
|
|
9
10
|
* @param {boolean} [rootOptions.sequence] employ a wrapping structure that
|
|
10
|
-
*
|
|
11
|
-
*
|
|
11
|
+
* preserves each value set within a single block, and default child nodes to
|
|
12
|
+
* do the same
|
|
12
13
|
*/
|
|
13
14
|
export function makeChainStorageRoot(handleStorageMessage: (message: StorageMessage) => any, rootPath: string, rootOptions?: {
|
|
14
15
|
sequence?: boolean | undefined;
|
|
15
|
-
} | undefined): {
|
|
16
|
+
} | undefined): import("@endo/exo").Guarded<{
|
|
16
17
|
getPath(): string;
|
|
17
18
|
/**
|
|
18
19
|
* @deprecated use getPath
|
|
19
20
|
* @type {() => Promise<VStorageKey>}
|
|
20
21
|
*/
|
|
21
22
|
getStoreKey(): Promise<VStorageKey>;
|
|
22
|
-
/** @type {(name: string, childNodeOptions?: {sequence?: boolean}) => StorageNode} */
|
|
23
|
-
makeChildNode(name: string, childNodeOptions?: {
|
|
24
|
-
sequence?: boolean | undefined;
|
|
25
|
-
} | undefined): StorageNode;
|
|
26
|
-
/** @type {(value: string) => Promise<void>} */
|
|
27
|
-
setValue(value: string): Promise<void>;
|
|
28
|
-
} & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
29
|
-
getPath(): string;
|
|
30
23
|
/**
|
|
31
|
-
* @
|
|
32
|
-
*
|
|
24
|
+
* @type {(
|
|
25
|
+
* name: string,
|
|
26
|
+
* childNodeOptions?: { sequence?: boolean },
|
|
27
|
+
* ) => StorageNode}
|
|
33
28
|
*/
|
|
34
|
-
getStoreKey(): Promise<VStorageKey>;
|
|
35
|
-
/** @type {(name: string, childNodeOptions?: {sequence?: boolean}) => StorageNode} */
|
|
36
29
|
makeChildNode(name: string, childNodeOptions?: {
|
|
37
|
-
sequence?: boolean
|
|
38
|
-
}
|
|
30
|
+
sequence?: boolean;
|
|
31
|
+
}): StorageNode;
|
|
39
32
|
/** @type {(value: string) => Promise<void>} */
|
|
40
33
|
setValue(value: string): Promise<void>;
|
|
41
34
|
}>;
|
|
@@ -44,48 +37,39 @@ export function makeChainStorageRoot(handleStorageMessage: (message: StorageMess
|
|
|
44
37
|
* falling back to an inert object with the correct interface (but incomplete
|
|
45
38
|
* behavior) when that is unavailable.
|
|
46
39
|
*
|
|
47
|
-
* @param {
|
|
40
|
+
* @param {ERef<StorageNode?>} storageNodeRef
|
|
48
41
|
* @param {string} childName
|
|
49
42
|
* @returns {Promise<StorageNode>}
|
|
50
43
|
*/
|
|
51
|
-
export function makeStorageNodeChild(storageNodeRef:
|
|
52
|
-
export function isStreamCell(cell: any): cell is StreamCell
|
|
44
|
+
export function makeStorageNodeChild(storageNodeRef: ERef<StorageNode | null>, childName: string): Promise<StorageNode>;
|
|
45
|
+
export function isStreamCell(cell: any): cell is StreamCell;
|
|
53
46
|
export function assertCapData(data: unknown): asserts data is import("@endo/marshal").CapData<string>;
|
|
54
|
-
export function unmarshalFromVstorage(data: Map<string, string>, key: string, fromCapData: ReturnType<typeof import('@endo/marshal').makeMarshal>['fromCapData'], index?: number | undefined): any;
|
|
55
47
|
/** @type {(name: string) => void} */
|
|
56
48
|
export const assertPathSegment: (name: string) => void;
|
|
57
|
-
export function prepareChainStorageNode(zone: import(
|
|
49
|
+
export function prepareChainStorageNode(zone: import("@agoric/base-zone").Zone): (messenger: import("./types.js").Callback<(message: StorageMessage) => any>, path: string, args_2?: {
|
|
58
50
|
sequence?: boolean | undefined;
|
|
59
|
-
} | undefined) => {
|
|
51
|
+
} | undefined) => import("@endo/exo").Guarded<{
|
|
60
52
|
getPath(): string;
|
|
61
53
|
/**
|
|
62
54
|
* @deprecated use getPath
|
|
63
55
|
* @type {() => Promise<VStorageKey>}
|
|
64
56
|
*/
|
|
65
57
|
getStoreKey(): Promise<VStorageKey>;
|
|
66
|
-
/** @type {(name: string, childNodeOptions?: {sequence?: boolean}) => StorageNode} */
|
|
67
|
-
makeChildNode(name: string, childNodeOptions?: {
|
|
68
|
-
sequence?: boolean | undefined;
|
|
69
|
-
} | undefined): StorageNode;
|
|
70
|
-
/** @type {(value: string) => Promise<void>} */
|
|
71
|
-
setValue(value: string): Promise<void>;
|
|
72
|
-
} & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
73
|
-
getPath(): string;
|
|
74
58
|
/**
|
|
75
|
-
* @
|
|
76
|
-
*
|
|
59
|
+
* @type {(
|
|
60
|
+
* name: string,
|
|
61
|
+
* childNodeOptions?: { sequence?: boolean },
|
|
62
|
+
* ) => StorageNode}
|
|
77
63
|
*/
|
|
78
|
-
getStoreKey(): Promise<VStorageKey>;
|
|
79
|
-
/** @type {(name: string, childNodeOptions?: {sequence?: boolean}) => StorageNode} */
|
|
80
64
|
makeChildNode(name: string, childNodeOptions?: {
|
|
81
|
-
sequence?: boolean
|
|
82
|
-
}
|
|
65
|
+
sequence?: boolean;
|
|
66
|
+
}): StorageNode;
|
|
83
67
|
/** @type {(value: string) => Promise<void>} */
|
|
84
68
|
setValue(value: string): Promise<void>;
|
|
85
69
|
}>;
|
|
86
|
-
export function makeSerializeToStorage(storageNode:
|
|
87
|
-
export type Marshaller = ReturnType<typeof import(
|
|
88
|
-
export type Unserializer = Pick<Marshaller,
|
|
70
|
+
export function makeSerializeToStorage(storageNode: ERef<StorageNode>, marshaller: ERef<Marshaller>): (value: PassableCap) => Promise<void>;
|
|
71
|
+
export type Marshaller = ReturnType<typeof import("@endo/marshal").makeMarshal>;
|
|
72
|
+
export type Unserializer = Pick<Marshaller, "fromCapData">;
|
|
89
73
|
/**
|
|
90
74
|
* Defined by vstorageStoreKey in vstorage.go
|
|
91
75
|
*/
|
|
@@ -105,7 +89,8 @@ export type StreamCell<T = unknown> = {
|
|
|
105
89
|
/**
|
|
106
90
|
* This represents a node in an IAVL tree.
|
|
107
91
|
*
|
|
108
|
-
* The active implementation is x/vstorage, an Agoric extension of the Cosmos
|
|
92
|
+
* The active implementation is x/vstorage, an Agoric extension of the Cosmos
|
|
93
|
+
* SDK.
|
|
109
94
|
*
|
|
110
95
|
* Vstorage is a hierarchical externally-reachable storage structure that
|
|
111
96
|
* identifies children by restricted ASCII name and is associated with arbitrary
|
|
@@ -117,7 +102,8 @@ export type StorageNode = {
|
|
|
117
102
|
*/
|
|
118
103
|
setValue: (data: string) => Promise<void>;
|
|
119
104
|
/**
|
|
120
|
-
* the chain storage path at which the node was
|
|
105
|
+
* the chain storage path at which the node was
|
|
106
|
+
* constructed
|
|
121
107
|
*/
|
|
122
108
|
getPath: () => string;
|
|
123
109
|
/**
|
|
@@ -130,26 +116,28 @@ export type StorageNode = {
|
|
|
130
116
|
};
|
|
131
117
|
export type StoredFacet = {
|
|
132
118
|
/**
|
|
133
|
-
* the chain storage path at which the
|
|
119
|
+
* the chain storage path at which the
|
|
120
|
+
* node was constructed
|
|
134
121
|
*/
|
|
135
122
|
getPath: () => Promise<string>;
|
|
136
123
|
/**
|
|
137
124
|
* DEPRECATED use getPath
|
|
138
125
|
*/
|
|
139
|
-
getStoreKey: StorageNode[
|
|
126
|
+
getStoreKey: StorageNode["getStoreKey"];
|
|
140
127
|
/**
|
|
141
|
-
* get the unserializer for the
|
|
128
|
+
* get the unserializer for the
|
|
129
|
+
* stored data
|
|
142
130
|
*/
|
|
143
131
|
getUnserializer: () => Unserializer;
|
|
144
132
|
};
|
|
145
133
|
/**
|
|
146
134
|
* Must match the switch in vstorage.go using `vstorageMessage` type
|
|
147
135
|
*/
|
|
148
|
-
export type StorageGetByPathMessageMethod =
|
|
136
|
+
export type StorageGetByPathMessageMethod = "get" | "getStoreKey" | "has" | "children" | "entries" | "values" | "size";
|
|
149
137
|
/**
|
|
150
138
|
* Must match the switch in vstorage.go using `vstorageMessage` type
|
|
151
139
|
*/
|
|
152
|
-
export type StorageUpdateEntriesMessageMethod =
|
|
140
|
+
export type StorageUpdateEntriesMessageMethod = "set" | "setWithoutNotify" | "append";
|
|
153
141
|
/**
|
|
154
142
|
* Must match the switch in vstorage.go using `vstorageMessage` type
|
|
155
143
|
*/
|
|
@@ -165,15 +153,17 @@ export type StorageEntry = [path: string, value?: string | null];
|
|
|
165
153
|
/**
|
|
166
154
|
* Must match the switch in vstorage.go using `vstorageMessage` type
|
|
167
155
|
*/
|
|
168
|
-
export type StorageUpdateEntriesMessageArgs = [
|
|
156
|
+
export type StorageUpdateEntriesMessageArgs = StorageEntry[];
|
|
169
157
|
/**
|
|
170
158
|
* Must match the switch in vstorage.go using `vstorageMessage` type
|
|
171
159
|
*/
|
|
172
160
|
export type StorageMessage = {
|
|
173
161
|
method: StorageGetByPathMessageMethod;
|
|
174
|
-
args:
|
|
162
|
+
args: StorageGetByPathMessageArgs;
|
|
175
163
|
} | {
|
|
176
164
|
method: StorageUpdateEntriesMessageMethod;
|
|
177
165
|
args: StorageUpdateEntriesMessageArgs;
|
|
178
166
|
};
|
|
167
|
+
import type { ERef } from '@endo/far';
|
|
168
|
+
import type { PassableCap } from '@endo/marshal';
|
|
179
169
|
//# sourceMappingURL=lib-chainStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib-chainStorage.d.ts","sourceRoot":"","sources":["lib-chainStorage.js"],"names":[],"mappings":"
|
|
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,CAQnE;AAmBD,qCAAqC;AACrC,gCADW,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAI/B;AAyCK,8CAFI,OAAO,mBAAmB,EAAE,IAAI,uDAwBxB,cAAc,KAAK,GAAG;;;;IAenC;;;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;GA0BhD;AA+DM,oDAJI,KAAK,WAAW,CAAC,cACjB,KAAK,UAAU,CAAC,GACd,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAQjD;yBA7Sa,UAAU,CAAC,cAAc,eAAe,EAAE,WAAW,CAAC;2BACtD,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC;;;;;eAM/B,MAAM;iBACN,MAAM;qBACN,MAAM;;;uBAKN,CAAC;;;;iBAED,MAAM;YACN,CAAC,EAAE;;;;;;;;;;;;;;;;cAcH,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;;;;;aAC/B,MAAM,MAAM;;;;iBAEZ,MAAM,OAAO,CAAC,WAAW,CAAC;mBAC1B,CACT,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAC7B,WAAW;;;;;;;aA6CL,MAAM,OAAO,CAAC,MAAM,CAAC;;;;iBAErB,WAAW,CAAC,aAAa,CAAC;;;;;qBAC1B,MAAM,YAAY;;;;;4CAqBnB,KAAK,GACX,aAAa,GACb,KAAK,GACL,UAAU,GACV,SAAS,GACT,QAAQ,GACR,MAAM;;;;gDAGA,KAAK,GAAG,kBAAkB,GAAG,QAAQ;;;;mCAGrC,6BAA6B,GACnC,iCAAiC;;;;0CAG3B,CAAC,IAAI,EAAE,MAAM,CAAC;;;;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"}
|