@agoric/internal
Advanced tools
Comparing version 0.3.3-dev-db972d4.0 to 0.3.3-dev-dc77e16.0
{ | ||
"name": "@agoric/internal", | ||
"version": "0.3.3-dev-db972d4.0+db972d4", | ||
"version": "0.3.3-dev-dc77e16.0+dc77e16", | ||
"description": "Externally unsupported utilities internal to agoric-sdk", | ||
@@ -13,3 +13,3 @@ "type": "module", | ||
"prepack": "tsc --build tsconfig.build.json", | ||
"postpack": "git clean -f '*.d.ts*'", | ||
"postpack": "git clean -f '*.d.ts*' '*.tsbuildinfo'", | ||
"test": "ava", | ||
@@ -24,18 +24,21 @@ "test:nyc": "exit 0", | ||
"dependencies": { | ||
"@agoric/assert": "0.6.1-dev-db972d4.0+db972d4", | ||
"@agoric/base-zone": "0.1.1-dev-db972d4.0+db972d4", | ||
"@endo/common": "^1.1.0", | ||
"@endo/far": "^1.0.4", | ||
"@endo/init": "^1.0.4", | ||
"@endo/marshal": "^1.3.0", | ||
"@endo/patterns": "^1.2.0", | ||
"@endo/promise-kit": "^1.0.4", | ||
"@endo/stream": "^1.1.0", | ||
"@agoric/base-zone": "0.1.1-dev-dc77e16.0+dc77e16", | ||
"@endo/common": "^1.2.9", | ||
"@endo/errors": "^1.2.9", | ||
"@endo/far": "^1.1.10", | ||
"@endo/init": "^1.1.8", | ||
"@endo/marshal": "^1.6.3", | ||
"@endo/pass-style": "^1.4.8", | ||
"@endo/patterns": "^1.4.8", | ||
"@endo/promise-kit": "^1.1.9", | ||
"@endo/stream": "^1.2.9", | ||
"anylogger": "^0.21.0", | ||
"jessie.js": "^0.3.2" | ||
"jessie.js": "^0.3.4" | ||
}, | ||
"devDependencies": { | ||
"@endo/init": "^1.0.4", | ||
"@agoric/cosmic-proto": "0.4.1-dev-dc77e16.0+dc77e16", | ||
"@endo/exo": "^1.5.8", | ||
"@endo/init": "^1.1.8", | ||
"ava": "^5.3.0", | ||
"tsd": "^0.30.4" | ||
"tsd": "^0.31.1" | ||
}, | ||
@@ -45,2 +48,5 @@ "ava": { | ||
"@endo/init/debug.js" | ||
], | ||
"files": [ | ||
"test/**/*.test.*" | ||
] | ||
@@ -51,3 +57,4 @@ }, | ||
"files": [ | ||
"src" | ||
"src", | ||
"exported.js" | ||
], | ||
@@ -58,5 +65,5 @@ "publishConfig": { | ||
"typeCoverage": { | ||
"atLeast": 93.01 | ||
"atLeast": 93.04 | ||
}, | ||
"gitHead": "db972d4615b3aaee60659a6c97f3d42487e50771" | ||
"gitHead": "dc77e169321b8c2cf4d6c81699dbe7cc4cba0177" | ||
} |
@@ -13,7 +13,7 @@ **NOTE: unsupported** | ||
It is meant to be a home for modules that have no Agoric-specific dependencies themselves. It does depend on a these other @agoric packages but they are all destined to migrate out of the repo, | ||
It is meant to be a home for modules that have no dependencies on other packages in this repository, except for the following packages that do not theirselves depend upon any other @agoric packages and may be destined for migration elsewhere: | ||
- base-zone | ||
- store | ||
- assert | ||
- [base-zone](../base-zone) | ||
- [store](../store) | ||
- [cosmic-proto](../cosmic-proto) | ||
@@ -20,0 +20,0 @@ This package may not take dependencies on any others in this repository. |
@@ -0,11 +1,56 @@ | ||
/** | ||
* Types of messages used for communication between a cosmos-sdk blockchain node | ||
* and its paired swingset VM, especially for the ABCI lifecycle. See: | ||
* | ||
* - https://github.com/tendermint/tendermint/blob/v0.34.x/spec/abci/abci.md#block-execution | ||
* - ../../../golang/cosmos/vm/action.go | ||
* - ../../../golang/cosmos/app/app.go | ||
* - ../../../golang/cosmos/x/swingset/abci.go | ||
* - ../../../golang/cosmos/x/swingset/keeper/swing_store_exports_handler.go | ||
* - ../../cosmic-swingset/src/chain-main.js | ||
* - ../../cosmic-swingset/src/launch-chain.js | ||
*/ | ||
export type SwingsetMessageType = (typeof SwingsetMessageType)[keyof typeof SwingsetMessageType]; | ||
export namespace SwingsetMessageType { | ||
let AG_COSMOS_INIT: "AG_COSMOS_INIT"; | ||
let BEGIN_BLOCK: "BEGIN_BLOCK"; | ||
let END_BLOCK: "END_BLOCK"; | ||
let COMMIT_BLOCK: "COMMIT_BLOCK"; | ||
let AFTER_COMMIT_BLOCK: "AFTER_COMMIT_BLOCK"; | ||
let SWING_STORE_EXPORT: "SWING_STORE_EXPORT"; | ||
} | ||
export const AG_COSMOS_INIT: "AG_COSMOS_INIT"; | ||
export const SWING_STORE_EXPORT: "SWING_STORE_EXPORT"; | ||
export const BEGIN_BLOCK: "BEGIN_BLOCK"; | ||
export const CALCULATE_FEES_IN_BEANS: "CALCULATE_FEES_IN_BEANS"; | ||
export const CORE_EVAL: "CORE_EVAL"; | ||
export const DELIVER_INBOUND: "DELIVER_INBOUND"; | ||
export const END_BLOCK: "END_BLOCK"; | ||
export const COMMIT_BLOCK: "COMMIT_BLOCK"; | ||
export const AFTER_COMMIT_BLOCK: "AFTER_COMMIT_BLOCK"; | ||
export const SWING_STORE_EXPORT: "SWING_STORE_EXPORT"; | ||
/** | ||
* Types of "action" messages consumed by the swingset VM from actionQueue or | ||
* highPriorityQueue during END_BLOCK. See: | ||
* | ||
* - ../../../golang/cosmos/x/swingset/keeper/msg_server.go | ||
* - ../../../golang/cosmos/x/swingset/keeper/proposal.go | ||
* - ../../../golang/cosmos/x/vbank/vbank.go | ||
* - ../../../golang/cosmos/x/vibc/handler.go | ||
* - ../../../golang/cosmos/x/vibc/keeper/triggers.go | ||
* - ../../../golang/cosmos/x/vibc/types/ibc_module.go | ||
*/ | ||
export type QueuedActionType = (typeof QueuedActionType)[keyof typeof QueuedActionType]; | ||
export namespace QueuedActionType { | ||
let CORE_EVAL: "CORE_EVAL"; | ||
let DELIVER_INBOUND: "DELIVER_INBOUND"; | ||
let IBC_EVENT: "IBC_EVENT"; | ||
let INSTALL_BUNDLE: "INSTALL_BUNDLE"; | ||
let PLEASE_PROVISION: "PLEASE_PROVISION"; | ||
let VBANK_BALANCE_UPDATE: "VBANK_BALANCE_UPDATE"; | ||
let WALLET_ACTION: "WALLET_ACTION"; | ||
let WALLET_SPEND_ACTION: "WALLET_SPEND_ACTION"; | ||
let VTRANSFER_IBC_EVENT: "VTRANSFER_IBC_EVENT"; | ||
let KERNEL_UPGRADE_EVENTS: "KERNEL_UPGRADE_EVENTS"; | ||
} | ||
export const CORE_EVAL: "CORE_EVAL"; | ||
export const DELIVER_INBOUND: "DELIVER_INBOUND"; | ||
export const IBC_EVENT: "IBC_EVENT"; | ||
export const INSTALL_BUNDLE: "INSTALL_BUNDLE"; | ||
export const PLEASE_PROVISION: "PLEASE_PROVISION"; | ||
@@ -15,3 +60,4 @@ export const VBANK_BALANCE_UPDATE: "VBANK_BALANCE_UPDATE"; | ||
export const WALLET_SPEND_ACTION: "WALLET_SPEND_ACTION"; | ||
export const INSTALL_BUNDLE: "INSTALL_BUNDLE"; | ||
export const VTRANSFER_IBC_EVENT: "VTRANSFER_IBC_EVENT"; | ||
export const KERNEL_UPGRADE_EVENTS: "KERNEL_UPGRADE_EVENTS"; | ||
//# sourceMappingURL=action-types.d.ts.map |
// @jessie-check | ||
export const AG_COSMOS_INIT = 'AG_COSMOS_INIT'; | ||
export const SWING_STORE_EXPORT = 'SWING_STORE_EXPORT'; | ||
export const BEGIN_BLOCK = 'BEGIN_BLOCK'; | ||
export const CALCULATE_FEES_IN_BEANS = 'CALCULATE_FEES_IN_BEANS'; | ||
export const CORE_EVAL = 'CORE_EVAL'; | ||
export const DELIVER_INBOUND = 'DELIVER_INBOUND'; | ||
export const END_BLOCK = 'END_BLOCK'; | ||
export const COMMIT_BLOCK = 'COMMIT_BLOCK'; | ||
export const AFTER_COMMIT_BLOCK = 'AFTER_COMMIT_BLOCK'; | ||
export const IBC_EVENT = 'IBC_EVENT'; | ||
export const PLEASE_PROVISION = 'PLEASE_PROVISION'; | ||
export const VBANK_BALANCE_UPDATE = 'VBANK_BALANCE_UPDATE'; | ||
export const WALLET_ACTION = 'WALLET_ACTION'; | ||
export const WALLET_SPEND_ACTION = 'WALLET_SPEND_ACTION'; | ||
export const INSTALL_BUNDLE = 'INSTALL_BUNDLE'; | ||
/** | ||
* Types of messages used for communication between a cosmos-sdk blockchain node | ||
* and its paired swingset VM, especially for the ABCI lifecycle. See: | ||
* | ||
* - https://github.com/tendermint/tendermint/blob/v0.34.x/spec/abci/abci.md#block-execution | ||
* - ../../../golang/cosmos/vm/action.go | ||
* - ../../../golang/cosmos/app/app.go | ||
* - ../../../golang/cosmos/x/swingset/abci.go | ||
* - ../../../golang/cosmos/x/swingset/keeper/swing_store_exports_handler.go | ||
* - ../../cosmic-swingset/src/chain-main.js | ||
* - ../../cosmic-swingset/src/launch-chain.js | ||
* | ||
* @enum {(typeof SwingsetMessageType)[keyof typeof SwingsetMessageType]} | ||
*/ | ||
export const SwingsetMessageType = /** @type {const} */ ({ | ||
AG_COSMOS_INIT: 'AG_COSMOS_INIT', // used to synchronize at process launch | ||
BEGIN_BLOCK: 'BEGIN_BLOCK', | ||
END_BLOCK: 'END_BLOCK', | ||
COMMIT_BLOCK: 'COMMIT_BLOCK', | ||
AFTER_COMMIT_BLOCK: 'AFTER_COMMIT_BLOCK', | ||
SWING_STORE_EXPORT: 'SWING_STORE_EXPORT', // used to synchronize data export | ||
}); | ||
harden(SwingsetMessageType); | ||
// TODO: Update all imports to use SwingsetMessageType. But until then... | ||
export const { | ||
AG_COSMOS_INIT, | ||
BEGIN_BLOCK, | ||
END_BLOCK, | ||
COMMIT_BLOCK, | ||
AFTER_COMMIT_BLOCK, | ||
SWING_STORE_EXPORT, | ||
} = SwingsetMessageType; | ||
/** | ||
* Types of "action" messages consumed by the swingset VM from actionQueue or | ||
* highPriorityQueue during END_BLOCK. See: | ||
* | ||
* - ../../../golang/cosmos/x/swingset/keeper/msg_server.go | ||
* - ../../../golang/cosmos/x/swingset/keeper/proposal.go | ||
* - ../../../golang/cosmos/x/vbank/vbank.go | ||
* - ../../../golang/cosmos/x/vibc/handler.go | ||
* - ../../../golang/cosmos/x/vibc/keeper/triggers.go | ||
* - ../../../golang/cosmos/x/vibc/types/ibc_module.go | ||
* | ||
* @enum {(typeof QueuedActionType)[keyof typeof QueuedActionType]} | ||
*/ | ||
export const QueuedActionType = /** @type {const} */ ({ | ||
CORE_EVAL: 'CORE_EVAL', | ||
DELIVER_INBOUND: 'DELIVER_INBOUND', | ||
IBC_EVENT: 'IBC_EVENT', | ||
INSTALL_BUNDLE: 'INSTALL_BUNDLE', | ||
PLEASE_PROVISION: 'PLEASE_PROVISION', | ||
VBANK_BALANCE_UPDATE: 'VBANK_BALANCE_UPDATE', | ||
WALLET_ACTION: 'WALLET_ACTION', | ||
WALLET_SPEND_ACTION: 'WALLET_SPEND_ACTION', | ||
VTRANSFER_IBC_EVENT: 'VTRANSFER_IBC_EVENT', | ||
KERNEL_UPGRADE_EVENTS: 'KERNEL_UPGRADE_EVENTS', | ||
}); | ||
harden(QueuedActionType); | ||
// TODO: Update all imports to use QueuedActionType. But until then... | ||
export const { | ||
CORE_EVAL, | ||
DELIVER_INBOUND, | ||
IBC_EVENT, | ||
INSTALL_BUNDLE, | ||
PLEASE_PROVISION, | ||
VBANK_BALANCE_UPDATE, | ||
WALLET_ACTION, | ||
WALLET_SPEND_ACTION, | ||
VTRANSFER_IBC_EVENT, | ||
KERNEL_UPGRADE_EVENTS, | ||
} = QueuedActionType; |
@@ -6,8 +6,11 @@ /** | ||
* @param {DeliverMessages} deliver | ||
* @param {{ clearTimeout: import('node:timers').clearTimeout, setTimeout: import('node:timers').setTimeout }} io | ||
* @param {{ | ||
* clearTimeout: import('node:timers').clearTimeout; | ||
* setTimeout: import('node:timers').setTimeout; | ||
* }} io | ||
* @param {number} batchTimeoutMs | ||
*/ | ||
export function makeBatchedDeliver(deliver: DeliverMessages, { clearTimeout, setTimeout }: { | ||
clearTimeout: typeof clearTimeout; | ||
setTimeout: typeof setTimeout; | ||
clearTimeout: typeof globalThis.clearTimeout; | ||
setTimeout: typeof globalThis.setTimeout; | ||
}, batchTimeoutMs?: number): (message: unknown[], ackNum: number) => Promise<void>; | ||
@@ -14,0 +17,0 @@ export const DEFAULT_BATCH_TIMEOUT_MS: 1000; |
@@ -12,3 +12,6 @@ // @jessie-check | ||
* @param {DeliverMessages} deliver | ||
* @param {{ clearTimeout: import('node:timers').clearTimeout, setTimeout: import('node:timers').setTimeout }} io | ||
* @param {{ | ||
* clearTimeout: import('node:timers').clearTimeout; | ||
* setTimeout: import('node:timers').setTimeout; | ||
* }} io | ||
* @param {number} batchTimeoutMs | ||
@@ -15,0 +18,0 @@ */ |
@@ -1,9 +0,9 @@ | ||
export function callSync<I extends (...args: unknown[]) => any>(callback: import("./types.js").SyncCallback<I>, ...args: Parameters<I>): ReturnType<I>; | ||
export function callE<I extends (...args: unknown[]) => any>(callback: import("./types.js").Callback<I>, ...args: Parameters<I>): Promise<Awaited<ReturnType<I>>>; | ||
export function makeSyncFunctionCallback<I extends (...args: unknown[]) => any, T extends (...args: [...B, ...Parameters<I>]) => ReturnType<I> = I, B extends unknown[] = []>(target: T, ...bound: B): import("./types.js").SyncCallback<I>; | ||
export function makeFunctionCallback<I extends (...args: unknown[]) => any, T extends import("@endo/far").ERef<(...args: [...B, ...Parameters<I>]) => ReturnType<I>> = import("@endo/far").ERef<I>, B extends unknown[] = []>(target: T, ...bound: B): import("./types.js").Callback<I>; | ||
export function makeSyncMethodCallback<I extends (...args: unknown[]) => any, P extends PropertyKey, T extends { [x in P]: (...args: [...B, ...Parameters<I>]) => ReturnType<I>; } = { [x_1 in P]: I; }, B extends unknown[] = []>(target: T, methodName: P, ...bound: B): import("./types.js").SyncCallback<I>; | ||
export function makeMethodCallback<I extends (...args: unknown[]) => any, P extends PropertyKey, T extends import("@endo/far").ERef<{ [x in P]: (...args: [...B, ...Parameters<I>]) => ReturnType<I>; }> = import("@endo/far").ERef<{ [x_1 in P]: I; }>, B extends unknown[] = []>(target: T, methodName: P, ...bound: B): import("./types.js").Callback<I>; | ||
export function isCallback(callback: any): callback is import("./types.js").Callback<any>; | ||
export function prepareAttenuator<M extends PropertyKey>(zone: import('@agoric/base-zone').Zone, methodNames: M[], { interfaceGuard, tag }?: { | ||
export function callSync<I extends (...args: any[]) => any>(callback: SyncCallback<I>, ...args: Parameters<I>): ReturnType<I>; | ||
export function callE<I extends (...args: any[]) => any>(callback: Callback<I>, ...args: Parameters<I>): Promise<Awaited<ReturnType<I>>>; | ||
export function makeSyncFunctionCallback<I extends (...args: any[]) => any, T extends (...args: [...B, ...Parameters<I>]) => ReturnType<I> = I, B extends any[] = []>(target: T, ...bound: B): SyncCallback<I>; | ||
export function makeFunctionCallback<I extends (...args: any[]) => any, T extends ERef<(...args: [...B, ...Parameters<I>]) => ReturnType<I>> = ERef<I>, B extends any[] = []>(target: T, ...bound: B): Callback<I>; | ||
export function makeSyncMethodCallback<I extends (...args: any[]) => any, P extends PropertyKey, T extends { [x in P]: (...args: [...B, ...Parameters<I>]) => ReturnType<I>; } = { [x in P]: I; }, B extends any[] = []>(target: T, methodName: P, ...bound: B): SyncCallback<I>; | ||
export function makeMethodCallback<I extends (...args: any[]) => any, P extends PropertyKey, T extends ERef<{ [x in P]: (...args: [...B, ...Parameters<I>]) => ReturnType<I>; }> = ERef<{ [x in P]: I; }>, B extends any[] = []>(target: T, methodName: P, ...bound: B): Callback<I>; | ||
export function isCallback(callback: any): callback is Callback<any>; | ||
export function prepareAttenuator<M extends PropertyKey>(zone: import("@agoric/base-zone").Zone, methodNames: M[], { interfaceGuard, tag }?: { | ||
interfaceGuard?: import("@endo/patterns").InterfaceGuard<{ [K in M]: import("@endo/patterns").MethodGuard; }> | undefined; | ||
@@ -14,18 +14,18 @@ tag?: string | undefined; | ||
isSync?: boolean | undefined; | ||
overrides?: { [K_1 in M]?: import("./types.js").Callback<any> | null | undefined; } | undefined; | ||
}) => import("@endo/exo/src/exo-makers.js").Guarded<{ [K_2 in M]: (this: any, ...args: unknown[]) => any; }>; | ||
export function prepareGuardedAttenuator<G extends import("@endo/patterns").InterfaceGuard<Record<PropertyKey, import("@endo/patterns").MethodGuard>>>(zone: import('@agoric/base-zone').Zone, interfaceGuard: G, opts?: { | ||
overrides?: { [K_1 in M]?: Callback<any> | null | undefined; } | undefined; | ||
}) => import("@endo/exo").Guarded<{ [K_2 in M]: (this: any, ...args: any[]) => any; }>; | ||
export function prepareGuardedAttenuator<G extends import("@endo/patterns").InterfaceGuard>(zone: import("@agoric/base-zone").Zone, interfaceGuard: G, opts?: { | ||
tag?: string | undefined; | ||
} | undefined): MakeAttenuator<any>; | ||
export type MakeAttenuator<T extends import("@endo/exo/src/exo-tools.js").Methods> = (args_0: { | ||
}): MakeAttenuator<any>; | ||
export type MakeAttenuator<T extends import("@endo/exo").Methods> = (...args: Parameters<ReturnType<(<M extends PropertyKey>(zone: import("@agoric/base-zone").Zone, methodNames: M[], { interfaceGuard, tag }?: { | ||
interfaceGuard?: import("@endo/patterns").InterfaceGuard<{ [K in M]: import("@endo/patterns").MethodGuard; }> | undefined; | ||
tag?: string | undefined; | ||
}) => (args_0: { | ||
target?: any; | ||
isSync?: boolean | undefined; | ||
overrides?: { | ||
[x: string]: import("./types.js").Callback<any> | null | undefined; | ||
[x: number]: import("./types.js").Callback<any> | null | undefined; | ||
[x: symbol]: import("./types.js").Callback<any> | null | undefined; | ||
} | undefined; | ||
}) => import('@endo/exo/src/exo-makers.js').Farable<T>; | ||
export type Callback<I extends (...args: unknown[]) => any> = import('./types.js').Callback<I>; | ||
export type SyncCallback<I extends (...args: unknown[]) => any> = import('./types.js').SyncCallback<I>; | ||
overrides?: { [K_1 in M]?: Callback<any> | null | undefined; } | undefined; | ||
}) => import("@endo/exo").Guarded<{ [K_2 in M]: (this: any, ...args: any[]) => any; }>)>>) => import("@endo/exo").Farable<T>; | ||
import type { SyncCallback } from './types.js'; | ||
import type { Callback } from './types.js'; | ||
import type { ERef } from '@endo/far'; | ||
//# sourceMappingURL=callback.d.ts.map |
// @ts-check | ||
import { Fail, makeError, q } from '@endo/errors'; | ||
import { E } from '@endo/far'; | ||
@@ -6,3 +7,4 @@ import { isObject, isPassableSymbol } from '@endo/marshal'; | ||
const { Fail, quote: q } = assert; | ||
/** @import {ERef} from '@endo/far' */ | ||
/** @import {Callback, SyncCallback} from './types.js' */ | ||
@@ -13,3 +15,3 @@ const { fromEntries } = Object; | ||
const ownKeys = | ||
/** @type {<T extends PropertyKey>(obj: {[K in T]?: unknown}) => T[]} */ ( | ||
/** @type {<T extends PropertyKey>(obj: { [K in T]?: unknown }) => T[]} */ ( | ||
rawOwnKeys | ||
@@ -19,20 +21,12 @@ ); | ||
/** | ||
* @template {import('@endo/exo/src/exo-makers.js').Methods} T | ||
* @typedef {(...args: Parameters<ReturnType<prepareAttenuator>>) => import('@endo/exo/src/exo-makers.js').Farable<T>} MakeAttenuator | ||
* @template {import('@endo/exo').Methods} T | ||
* @typedef {( | ||
* ...args: Parameters<ReturnType<prepareAttenuator>> | ||
* ) => import('@endo/exo').Farable<T>} MakeAttenuator | ||
*/ | ||
/** | ||
* @template {(...args: unknown[]) => any} I | ||
* @typedef {import('./types.js').Callback<I>} Callback | ||
*/ | ||
/** | ||
* @template {(...args: unknown[]) => any} I | ||
* @typedef {import('./types.js').SyncCallback<I>} SyncCallback | ||
*/ | ||
/** | ||
* @param {unknown} key | ||
* @returns {key is PropertyKey} FIXME: should be just `PropertyKey` but TS | ||
* complains it can't be used as an index type. | ||
* complains it can't be used as an index type. | ||
*/ | ||
@@ -53,3 +47,3 @@ const isPropertyKey = key => { | ||
* | ||
* @template {(...args: unknown[]) => any} I | ||
* @template {(...args: any[]) => any} I | ||
* @param {SyncCallback<I>} callback | ||
@@ -71,3 +65,3 @@ * @param {Parameters<I>} args | ||
* | ||
* @template {(...args: unknown[]) => any} I | ||
* @template {(...args: any[]) => any} I | ||
* @param {Callback<I>} callback | ||
@@ -89,5 +83,5 @@ * @param {Parameters<I>} args | ||
* | ||
* @template {(...args: unknown[]) => any} I | ||
* @template {(...args: any[]) => any} I | ||
* @template {(...args: [...B, ...Parameters<I>]) => ReturnType<I>} [T=I] | ||
* @template {unknown[]} [B=[]] | ||
* @template {any[]} [B=[]] | ||
* @param {T} target | ||
@@ -109,7 +103,5 @@ * @param {B} bound | ||
* | ||
* @template {(...args: unknown[]) => any} I | ||
* @template {import('@endo/far').ERef< | ||
* (...args: [...B, ...Parameters<I>]) => ReturnType<I> | ||
* >} [T=import('@endo/far').ERef<I>] | ||
* @template {unknown[]} [B=[]] | ||
* @template {(...args: any[]) => any} I | ||
* @template {ERef<(...args: [...B, ...Parameters<I>]) => ReturnType<I>>} [T=ERef<I>] | ||
* @template {any[]} [B=[]] | ||
* @param {T} target | ||
@@ -131,8 +123,8 @@ * @param {B} bound | ||
* | ||
* @template {(...args: unknown[]) => any} I | ||
* @template {(...args: any[]) => any} I | ||
* @template {PropertyKey} P | ||
* @template {{ | ||
* [x in P]: (...args: [...B, ...Parameters<I>]) => ReturnType<I> | ||
* [x in P]: (...args: [...B, ...Parameters<I>]) => ReturnType<I>; | ||
* }} [T={ [x in P]: I }] | ||
* @template {unknown[]} [B=[]] | ||
* @template {any[]} [B=[]] | ||
* @param {T} target | ||
@@ -158,8 +150,8 @@ * @param {P} methodName | ||
* | ||
* @template {(...args: unknown[]) => any} I | ||
* @template {(...args: any[]) => any} I | ||
* @template {PropertyKey} P | ||
* @template {import('@endo/far').ERef<{ | ||
* [x in P]: (...args: [...B, ...Parameters<I>]) => ReturnType<I> | ||
* }>} [T=import('@endo/far').ERef<{ [x in P]: I }>] | ||
* @template {unknown[]} [B=[]] | ||
* @template {ERef<{ | ||
* [x in P]: (...args: [...B, ...Parameters<I>]) => ReturnType<I>; | ||
* }>} [T=ERef<{ [x in P]: I }>] | ||
* @template {any[]} [B=[]] | ||
* @param {T} target | ||
@@ -204,9 +196,10 @@ * @param {P} methodName | ||
* @template {PropertyKey} M | ||
* @param {import('@agoric/base-zone').Zone} zone The zone in which to allocate attenuators. | ||
* @param {import('@agoric/base-zone').Zone} zone The zone in which to allocate | ||
* attenuators. | ||
* @param {M[]} methodNames Methods to forward. | ||
* @param {object} opts | ||
* @param {import('@endo/patterns').InterfaceGuard<{ | ||
* [K in M]: import('@endo/patterns').MethodGuard | ||
* }>} [opts.interfaceGuard] An interface guard for the | ||
* new attenuator. | ||
* [K in M]: import('@endo/patterns').MethodGuard; | ||
* }>} [opts.interfaceGuard] | ||
* An interface guard for the new attenuator. | ||
* @param {string} [opts.tag] A tag for the new attenuator exoClass. | ||
@@ -220,5 +213,7 @@ */ | ||
/** | ||
* @typedef {(this: any, ...args: unknown[]) => any} Method | ||
* @typedef {{ [K in M]?: Callback<any> | null}} Overrides | ||
* @typedef {{ [K in M]: (this: any, ...args: unknown[]) => any }} Methods | ||
* @typedef {(this: any, ...args: any[]) => any} Method | ||
* | ||
* @typedef {{ [K in M]?: Callback<any> | null }} Overrides | ||
* | ||
* @typedef {{ [K in M]: (this: any, ...args: any[]) => any }} Methods | ||
*/ | ||
@@ -241,5 +236,3 @@ const methods = /** @type {Methods} */ ( | ||
if (!cb) { | ||
const err = assert.error( | ||
`unimplemented ${q(tag)} method ${q(key)}`, | ||
); | ||
const err = makeError(`unimplemented ${q(tag)} method ${q(key)}`); | ||
if (this.state.isSync) { | ||
@@ -266,10 +259,9 @@ throw err; | ||
* @param {object} opts | ||
* @param {unknown} [opts.target] The target for any methods that | ||
* weren't specified in `opts.overrides`. | ||
* @param {unknown} [opts.target] The target for any methods that weren't | ||
* specified in `opts.overrides`. | ||
* @param {boolean} [opts.isSync=false] Whether the target should be treated | ||
* as synchronously available. | ||
* @param {Overrides} [opts.overrides] Set individual | ||
* callbacks for methods (whose names must be defined in the | ||
* `prepareAttenuator` or `prepareGuardedAttenuator` call). Nullish overrides | ||
* mean to throw. | ||
* as synchronously available. | ||
* @param {Overrides} [opts.overrides] Set individual callbacks for methods | ||
* (whose names must be defined in the `prepareAttenuator` or | ||
* `prepareGuardedAttenuator` call). Nullish overrides mean to throw. | ||
*/ | ||
@@ -276,0 +268,0 @@ const makeAttenuator = zone.exoClass( |
/** | ||
* These identify top-level paths for SwingSet chain storage | ||
* (and serve as prefixes). | ||
* To avoid collisions, they should remain synchronized with | ||
* These identify top-level paths for SwingSet chain storage (and serve as | ||
* prefixes). To avoid collisions, they should remain synchronized with | ||
* golang/cosmos/x/swingset/keeper/keeper.go | ||
@@ -6,0 +5,0 @@ */ |
// @jessie-check | ||
/** | ||
* These identify top-level paths for SwingSet chain storage | ||
* (and serve as prefixes). | ||
* To avoid collisions, they should remain synchronized with | ||
* These identify top-level paths for SwingSet chain storage (and serve as | ||
* prefixes). To avoid collisions, they should remain synchronized with | ||
* golang/cosmos/x/swingset/keeper/keeper.go | ||
@@ -8,0 +7,0 @@ */ |
@@ -0,29 +1,34 @@ | ||
/** | ||
* Event source ids used by the bridge device. | ||
*/ | ||
export type BridgeId = (typeof BridgeId)[keyof typeof BridgeId]; | ||
export namespace BridgeId { | ||
let BANK: string; | ||
let CORE: string; | ||
let DIBC: string; | ||
let STORAGE: string; | ||
let PROVISION: string; | ||
let PROVISION_SMART_WALLET: string; | ||
let VLOCALCHAIN: string; | ||
let WALLET: string; | ||
let BANK: "bank"; | ||
let CORE: "core"; | ||
let DIBC: "dibc"; | ||
let STORAGE: "storage"; | ||
let PROVISION: "provision"; | ||
let PROVISION_SMART_WALLET: "provisionWallet"; | ||
let VLOCALCHAIN: "vlocalchain"; | ||
let VTRANSFER: "vtransfer"; | ||
let WALLET: "wallet"; | ||
} | ||
export namespace CosmosInitKeyToBridgeId { | ||
import vbankPort = BridgeId.BANK; | ||
import vbankPort = BANK; | ||
export { vbankPort }; | ||
import vibcPort = BridgeId.DIBC; | ||
import vibcPort = DIBC; | ||
export { vibcPort }; | ||
} | ||
export namespace WalletName { | ||
let depositFacet: string; | ||
let depositFacet: "depositFacet"; | ||
} | ||
export namespace VBankAccount { | ||
namespace reserve { | ||
let module: string; | ||
let address: string; | ||
let module: "vbank/reserve"; | ||
let address: "agoric1ae0lmtzlgrcnla9xjkpaarq5d5dfez63h3nucl"; | ||
} | ||
namespace provision { | ||
let module_1: string; | ||
let module_1: "vbank/provision"; | ||
export { module_1 as module }; | ||
let address_1: string; | ||
let address_1: "agoric1megzytg65cyrgzs6fvzxgrcqvwwl7ugpt62346"; | ||
export { address_1 as address }; | ||
@@ -30,0 +35,0 @@ } |
@@ -7,7 +7,9 @@ // @ts-check | ||
* | ||
* Some of this config info may make more sense in a particular package. However | ||
* due to https://github.com/Agoric/agoric-sdk/issues/4620 and our lax package | ||
* dependency graph, sometimes rational placements cause type resolution errors. | ||
* Some of this config info may make more sense in a particular package. However | ||
* due to https://github.com/Agoric/agoric-sdk/issues/4620 and our lax package | ||
* dependency graph, sometimes rational placements cause type resolution | ||
* errors. | ||
* | ||
* So as a work-around some constants that need access from more than one package are placed here. | ||
* So as a work-around some constants that need access from more than one | ||
* package are placed here. | ||
*/ | ||
@@ -17,4 +19,6 @@ | ||
* Event source ids used by the bridge device. | ||
* | ||
* @enum {(typeof BridgeId)[keyof typeof BridgeId]} | ||
*/ | ||
export const BridgeId = { | ||
export const BridgeId = /** @type {const} */ ({ | ||
BANK: 'bank', | ||
@@ -27,4 +31,5 @@ CORE: 'core', | ||
VLOCALCHAIN: 'vlocalchain', | ||
VTRANSFER: 'vtransfer', | ||
WALLET: 'wallet', | ||
}; | ||
}); | ||
harden(BridgeId); | ||
@@ -37,9 +42,9 @@ | ||
export const WalletName = { | ||
export const WalletName = /** @type {const} */ ({ | ||
depositFacet: 'depositFacet', | ||
}; | ||
}); | ||
harden(WalletName); | ||
// defined in golang/cosmos/x/vbank | ||
export const VBankAccount = { | ||
export const VBankAccount = /** @type {const} */ ({ | ||
reserve: { | ||
@@ -53,3 +58,3 @@ module: 'vbank/reserve', | ||
}, | ||
}; | ||
}); | ||
harden(VBankAccount); |
@@ -1,2 +0,2 @@ | ||
export function makeTracer(name: string, enable?: boolean | 'verbose'): (..._args: any[]) => void; | ||
export function makeTracer(name: string, enable?: boolean | "verbose"): (..._args: any[]) => void; | ||
//# sourceMappingURL=debug.d.ts.map |
export * from "./config.js"; | ||
export * from "./debug.js"; | ||
export * from "./utils.js"; | ||
export * from "./errors.js"; | ||
export * from "./js-utils.js"; | ||
export * from "./method-tools.js"; | ||
export * from "./ses-utils.js"; | ||
export * from "./typeCheck.js"; | ||
export * from "./typeGuards.js"; | ||
export * from "./types-index.js"; | ||
export { pureDataMarshaller } from "./marshal.js"; | ||
export { objectMap } from "@endo/common/object-map.js"; | ||
export { objectMetaMap } from "@endo/common/object-meta-map.js"; | ||
export { fromUniqueEntries } from "@endo/common/from-unique-entries.js"; | ||
//# sourceMappingURL=index.d.ts.map |
// @jessie-check | ||
/// <reference types="ses"/> | ||
/// <reference types="ses" /> | ||
export * from './config.js'; | ||
export * from './debug.js'; | ||
export * from './utils.js'; | ||
export * from './errors.js'; | ||
export * from './js-utils.js'; | ||
export { pureDataMarshaller } from './marshal.js'; | ||
export * from './method-tools.js'; | ||
export * from './ses-utils.js'; | ||
export * from './typeCheck.js'; | ||
export * from './typeGuards.js'; | ||
// eslint-disable-next-line import/export -- just types | ||
export * from './types-index.js'; | ||
export { objectMap } from '@endo/common/object-map.js'; | ||
export { objectMetaMap } from '@endo/common/object-meta-map.js'; | ||
export { fromUniqueEntries } from '@endo/common/from-unique-entries.js'; |
/** | ||
* Create a heap-based root storage node for a given backing function and root path. | ||
* Create a heap-based root storage node for a given backing function and root | ||
* path. | ||
* | ||
* @param {(message: StorageMessage) => any} handleStorageMessage a function for | ||
* sending a storageMessage object to the storage implementation | ||
* (cf. golang/cosmos/x/vstorage/vstorage.go) | ||
* sending a storageMessage object to the storage implementation (cf. | ||
* golang/cosmos/x/vstorage/vstorage.go) | ||
* @param {string} rootPath | ||
* @param {object} [rootOptions] | ||
* @param {boolean} [rootOptions.sequence] employ a wrapping structure that | ||
* preserves each value set within a single block, and default child nodes | ||
* to do the same | ||
* preserves each value set within a single block, and default child nodes to | ||
* do the same | ||
*/ | ||
export function makeChainStorageRoot(handleStorageMessage: (message: StorageMessage) => any, rootPath: string, rootOptions?: { | ||
sequence?: boolean | undefined; | ||
} | undefined): import("@endo/exo/src/exo-makers.js").Guarded<{ | ||
}): import("@endo/exo").Guarded<{ | ||
getPath(): string; | ||
/** | ||
* @deprecated use getPath | ||
* @type {() => Promise<VStorageKey>} | ||
*/ | ||
getStoreKey(): Promise<VStorageKey>; | ||
/** @type {(name: string, childNodeOptions?: {sequence?: boolean}) => StorageNode} */ | ||
makeChildNode(name: string, childNodeOptions?: { | ||
sequence?: boolean | undefined; | ||
} | undefined): StorageNode; | ||
/** @type {(value: string) => Promise<void>} */ | ||
sequence?: boolean; | ||
}): StorageNode; | ||
setValue(value: string): Promise<void>; | ||
@@ -34,30 +29,24 @@ }>; | ||
* | ||
* @param {import('@endo/far').ERef<StorageNode?>} storageNodeRef | ||
* @param {ERef<StorageNode?>} storageNodeRef | ||
* @param {string} childName | ||
* @returns {Promise<StorageNode>} | ||
*/ | ||
export function makeStorageNodeChild(storageNodeRef: import('@endo/far').ERef<StorageNode | null>, childName: string): Promise<StorageNode>; | ||
export function isStreamCell(cell: any): cell is StreamCell<unknown>; | ||
export function makeStorageNodeChild(storageNodeRef: ERef<StorageNode | null>, childName: string): Promise<StorageNode>; | ||
export function isStreamCell(cell: any): cell is StreamCell; | ||
export function assertCapData(data: unknown): asserts data is import("@endo/marshal").CapData<string>; | ||
/** @type {(name: string) => void} */ | ||
export const assertPathSegment: (name: string) => void; | ||
export function prepareChainStorageNode(zone: import('@agoric/base-zone').Zone): (messenger: import("./types.js").Callback<(message: StorageMessage) => any>, path: string, args_2?: { | ||
export function prepareChainStorageNode(zone: import("@agoric/base-zone").Zone): (messenger: import("./types.js").Callback<(message: StorageMessage) => any>, path: string, args_2?: { | ||
sequence?: boolean | undefined; | ||
} | undefined) => import("@endo/exo/src/exo-makers.js").Guarded<{ | ||
} | undefined) => import("@endo/exo").Guarded<{ | ||
getPath(): string; | ||
/** | ||
* @deprecated use getPath | ||
* @type {() => Promise<VStorageKey>} | ||
*/ | ||
getStoreKey(): Promise<VStorageKey>; | ||
/** @type {(name: string, childNodeOptions?: {sequence?: boolean}) => StorageNode} */ | ||
makeChildNode(name: string, childNodeOptions?: { | ||
sequence?: boolean | undefined; | ||
} | undefined): StorageNode; | ||
/** @type {(value: string) => Promise<void>} */ | ||
sequence?: boolean; | ||
}): StorageNode; | ||
setValue(value: string): Promise<void>; | ||
}>; | ||
export function makeSerializeToStorage(storageNode: import('@endo/far').ERef<StorageNode>, marshaller: import('@endo/far').ERef<Marshaller>): (value: unknown) => Promise<void>; | ||
export type Marshaller = ReturnType<typeof import('@endo/marshal').makeMarshal>; | ||
export type Unserializer = Pick<Marshaller, 'fromCapData'>; | ||
export function makeSerializeToStorage(storageNode: ERef<StorageNode>, marshaller: ERef<Marshaller>): (value: PassableCap) => Promise<void>; | ||
export type Marshaller = ReturnType<typeof import("@endo/marshal").makeMarshal>; | ||
export type Unserializer = Pick<Marshaller, "fromCapData">; | ||
/** | ||
@@ -82,3 +71,4 @@ * Defined by vstorageStoreKey in vstorage.go | ||
* | ||
* The active implementation is x/vstorage, an Agoric extension of the Cosmos SDK. | ||
* The active implementation is x/vstorage, an Agoric extension of the Cosmos | ||
* SDK. | ||
* | ||
@@ -95,3 +85,4 @@ * Vstorage is a hierarchical externally-reachable storage structure that | ||
/** | ||
* the chain storage path at which the node was constructed | ||
* the chain storage path at which the node was | ||
* constructed | ||
*/ | ||
@@ -109,3 +100,4 @@ getPath: () => string; | ||
/** | ||
* the chain storage path at which the node was constructed | ||
* the chain storage path at which the | ||
* node was constructed | ||
*/ | ||
@@ -116,5 +108,6 @@ getPath: () => Promise<string>; | ||
*/ | ||
getStoreKey: StorageNode['getStoreKey']; | ||
getStoreKey: StorageNode["getStoreKey"]; | ||
/** | ||
* get the unserializer for the stored data | ||
* get the unserializer for the | ||
* stored data | ||
*/ | ||
@@ -126,7 +119,7 @@ getUnserializer: () => Unserializer; | ||
*/ | ||
export type StorageGetByPathMessageMethod = 'get' | 'getStoreKey' | 'has' | 'children' | 'entries' | 'values' | 'size'; | ||
export type StorageGetByPathMessageMethod = "get" | "getStoreKey" | "has" | "children" | "entries" | "values" | "size"; | ||
/** | ||
* Must match the switch in vstorage.go using `vstorageMessage` type | ||
*/ | ||
export type StorageUpdateEntriesMessageMethod = 'set' | 'setWithoutNotify' | 'append'; | ||
export type StorageUpdateEntriesMessageMethod = "set" | "setWithoutNotify" | "append"; | ||
/** | ||
@@ -147,3 +140,3 @@ * Must match the switch in vstorage.go using `vstorageMessage` type | ||
*/ | ||
export type StorageUpdateEntriesMessageArgs = [path: string, value?: string | null | undefined][]; | ||
export type StorageUpdateEntriesMessageArgs = StorageEntry[]; | ||
/** | ||
@@ -154,7 +147,9 @@ * Must match the switch in vstorage.go using `vstorageMessage` type | ||
method: StorageGetByPathMessageMethod; | ||
args: [path: string]; | ||
args: StorageGetByPathMessageArgs; | ||
} | { | ||
method: StorageUpdateEntriesMessageMethod; | ||
args: StorageEntry[]; | ||
args: StorageUpdateEntriesMessageArgs; | ||
}; | ||
import type { ERef } from '@endo/far'; | ||
import type { PassableCap } from '@endo/marshal'; | ||
//# sourceMappingURL=lib-chainStorage.d.ts.map |
// @ts-check | ||
import { E } from '@endo/far'; | ||
import { Fail } from '@endo/errors'; | ||
import { E, Far } from '@endo/far'; | ||
import { M } from '@endo/patterns'; | ||
@@ -8,3 +9,6 @@ import { makeHeapZone } from '@agoric/base-zone/heap.js'; | ||
const { Fail } = assert; | ||
/** | ||
* @import {ERef} from '@endo/far'; | ||
* @import {PassableCap} from '@endo/marshal'; | ||
*/ | ||
@@ -34,3 +38,4 @@ /** @typedef {ReturnType<typeof import('@endo/marshal').makeMarshal>} Marshaller */ | ||
* | ||
* The active implementation is x/vstorage, an Agoric extension of the Cosmos SDK. | ||
* The active implementation is x/vstorage, an Agoric extension of the Cosmos | ||
* SDK. | ||
* | ||
@@ -43,5 +48,9 @@ * Vstorage is a hierarchical externally-reachable storage structure that | ||
* @property {(data: string) => Promise<void>} setValue publishes some data | ||
* @property {() => string} getPath the chain storage path at which the node was constructed | ||
* @property {() => string} getPath the chain storage path at which the node was | ||
* constructed | ||
* @property {() => Promise<VStorageKey>} getStoreKey DEPRECATED use getPath | ||
* @property {(subPath: string, options?: {sequence?: boolean}) => StorageNode} makeChildNode | ||
* @property {( | ||
* subPath: string, | ||
* options?: { sequence?: boolean }, | ||
* ) => StorageNode} makeChildNode | ||
*/ | ||
@@ -60,5 +69,4 @@ | ||
* This is an imperfect heuristic to navigate the migration from value cells to | ||
* stream cells. | ||
* At time of writing, no legacy cells have the same shape as a stream cell, | ||
* and we do not intend to create any more legacy value cells. | ||
* stream cells. At time of writing, no legacy cells have the same shape as a | ||
* stream cell, and we do not intend to create any more legacy value cells. | ||
* | ||
@@ -93,5 +101,7 @@ * @param {any} cell | ||
* @typedef {object} StoredFacet | ||
* @property {() => Promise<string>} getPath the chain storage path at which the node was constructed | ||
* @property {() => Promise<string>} getPath the chain storage path at which the | ||
* node was constructed | ||
* @property {StorageNode['getStoreKey']} getStoreKey DEPRECATED use getPath | ||
* @property {() => Unserializer} getUnserializer get the unserializer for the stored data | ||
* @property {() => Unserializer} getUnserializer get the unserializer for the | ||
* stored data | ||
*/ | ||
@@ -116,15 +126,32 @@ | ||
* | ||
* @typedef { 'get' | 'getStoreKey' | 'has' | 'children' | 'entries' | 'values' |'size' } StorageGetByPathMessageMethod | ||
* @typedef { 'set' | 'setWithoutNotify' | 'append' } StorageUpdateEntriesMessageMethod | ||
* @typedef {StorageGetByPathMessageMethod | StorageUpdateEntriesMessageMethod } StorageMessageMethod | ||
* @typedef { [path: string] } StorageGetByPathMessageArgs | ||
* @typedef { [path: string, value?: string | null] } StorageEntry | ||
* @typedef { StorageEntry[] } StorageUpdateEntriesMessageArgs | ||
* @typedef {'get' | ||
* | 'getStoreKey' | ||
* | 'has' | ||
* | 'children' | ||
* | 'entries' | ||
* | 'values' | ||
* | 'size'} StorageGetByPathMessageMethod | ||
* | ||
* | ||
* @typedef {'set' | 'setWithoutNotify' | 'append'} StorageUpdateEntriesMessageMethod | ||
* | ||
* | ||
* @typedef {StorageGetByPathMessageMethod | ||
* | StorageUpdateEntriesMessageMethod} StorageMessageMethod | ||
* | ||
* | ||
* @typedef {[path: string]} StorageGetByPathMessageArgs | ||
* | ||
* @typedef {[path: string, value?: string | null]} StorageEntry | ||
* | ||
* @typedef {StorageEntry[]} StorageUpdateEntriesMessageArgs | ||
* | ||
* @typedef {{ | ||
* method: StorageGetByPathMessageMethod; | ||
* args: StorageGetByPathMessageArgs; | ||
* } | { | ||
* method: StorageUpdateEntriesMessageMethod; | ||
* args: StorageUpdateEntriesMessageArgs; | ||
* }} StorageMessage | ||
* method: StorageGetByPathMessageMethod; | ||
* args: StorageGetByPathMessageArgs; | ||
* } | ||
* | { | ||
* method: StorageUpdateEntriesMessageMethod; | ||
* args: StorageUpdateEntriesMessageArgs; | ||
* }} StorageMessage | ||
*/ | ||
@@ -139,11 +166,13 @@ | ||
* | ||
* @param {import('./callback.js').Callback<(message: StorageMessage) => any>} messenger a callback | ||
* for sending a storageMessage object to the storage implementation | ||
* (cf. golang/cosmos/x/vstorage/vstorage.go) | ||
* @param {import('./types.js').Callback< | ||
* (message: StorageMessage) => any | ||
* >} messenger | ||
* a callback for sending a storageMessage object to the storage | ||
* implementation (cf. golang/cosmos/x/vstorage/vstorage.go) | ||
* @param {string} path | ||
* @param {object} [options] | ||
* @param {boolean} [options.sequence] set values with `append` messages rather than `set` messages | ||
* so the backing implementation employs a wrapping structure that | ||
* preserves each value set within a single block. | ||
* Child nodes default to inheriting this option from their parent. | ||
* @param {boolean} [options.sequence] set values with `append` messages | ||
* rather than `set` messages so the backing implementation employs a | ||
* wrapping structure that preserves each value set within a single block. | ||
* Child nodes default to inheriting this option from their parent. | ||
* @returns {StorageNode} | ||
@@ -155,3 +184,5 @@ */ | ||
/** | ||
* @param {import('./callback.js').Callback<(message: StorageMessage) => any>} messenger | ||
* @param {import('./types.js').Callback< | ||
* (message: StorageMessage) => any | ||
* >} messenger | ||
* @param {string} path | ||
@@ -181,3 +212,8 @@ * @param {object} [options] | ||
}, | ||
/** @type {(name: string, childNodeOptions?: {sequence?: boolean}) => StorageNode} */ | ||
/** | ||
* @type {( | ||
* name: string, | ||
* childNodeOptions?: { sequence?: boolean }, | ||
* ) => StorageNode} | ||
*/ | ||
makeChildNode(name, childNodeOptions = {}) { | ||
@@ -224,12 +260,13 @@ const { sequence, path, messenger } = this.state; | ||
/** | ||
* Create a heap-based root storage node for a given backing function and root path. | ||
* Create a heap-based root storage node for a given backing function and root | ||
* path. | ||
* | ||
* @param {(message: StorageMessage) => any} handleStorageMessage a function for | ||
* sending a storageMessage object to the storage implementation | ||
* (cf. golang/cosmos/x/vstorage/vstorage.go) | ||
* sending a storageMessage object to the storage implementation (cf. | ||
* golang/cosmos/x/vstorage/vstorage.go) | ||
* @param {string} rootPath | ||
* @param {object} [rootOptions] | ||
* @param {boolean} [rootOptions.sequence] employ a wrapping structure that | ||
* preserves each value set within a single block, and default child nodes | ||
* to do the same | ||
* preserves each value set within a single block, and default child nodes to | ||
* do the same | ||
*/ | ||
@@ -249,7 +286,11 @@ export function makeChainStorageRoot( | ||
/** | ||
* @returns {StorageNode} an object that confirms to StorageNode API but does not store anywhere. | ||
* @returns {StorageNode} an object that confirms to StorageNode API but does | ||
* not store anywhere. | ||
*/ | ||
const makeNullStorageNode = () => { | ||
// XXX re-use "ChainStorage" methods above which don't actually depend on chains | ||
return makeChainStorageRoot(() => null, 'null'); | ||
return makeChainStorageRoot( | ||
Far('NullMessenger', () => null), | ||
'null', | ||
); | ||
}; | ||
@@ -262,3 +303,3 @@ | ||
* | ||
* @param {import('@endo/far').ERef<StorageNode?>} storageNodeRef | ||
* @param {ERef<StorageNode?>} storageNodeRef | ||
* @param {string} childName | ||
@@ -276,5 +317,5 @@ * @returns {Promise<StorageNode>} | ||
/** | ||
* @param {import('@endo/far').ERef<StorageNode>} storageNode | ||
* @param {import('@endo/far').ERef<Marshaller>} marshaller | ||
* @returns {(value: unknown) => Promise<void>} | ||
* @param {ERef<StorageNode>} storageNode | ||
* @param {ERef<Marshaller>} marshaller | ||
* @returns {(value: PassableCap) => Promise<void>} | ||
*/ | ||
@@ -281,0 +322,0 @@ export const makeSerializeToStorage = (storageNode, marshaller) => { |
export default engineGC; | ||
declare const engineGC: () => void; | ||
declare const engineGC: GCFunction; | ||
//# sourceMappingURL=engine-gc.d.ts.map |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
export function startSubprocessWorker(execPath: any, procArgs?: any[], { netstringMaxChunkSize }?: { | ||
@@ -14,4 +13,4 @@ netstringMaxChunkSize?: undefined; | ||
}; | ||
export type IOType = import('child_process').IOType; | ||
export type Writable = import('stream').Writable; | ||
export type IOType = import("child_process").IOType; | ||
export type Writable = import("stream").Writable; | ||
//# sourceMappingURL=spawnSubprocessWorker.d.ts.map |
// this file is loaded by the controller, in the start compartment | ||
import { spawn } from 'child_process'; | ||
import { makePromiseKit } from '@endo/promise-kit'; | ||
import { NonNullish } from '@agoric/assert'; | ||
import { NonNullish } from '../errors.js'; | ||
import { arrayEncoderStream, arrayDecoderStream } from './worker-protocol.js'; | ||
@@ -21,4 +21,4 @@ import { | ||
/** @typedef { import('child_process').IOType } IOType */ | ||
/** @typedef { import('stream').Writable } Writable */ | ||
/** @typedef {import('child_process').IOType} IOType */ | ||
/** @typedef {import('stream').Writable} Writable */ | ||
@@ -29,3 +29,3 @@ // we send on fd3, and receive on fd4. We pass fd1/2 (stdout/err) through, so | ||
// always be Node. | ||
/** @type { IOType[] } */ | ||
/** @type {IOType[]} */ | ||
const stdio = harden(['inherit', 'inherit', 'inherit', 'pipe', 'pipe']); | ||
@@ -73,3 +73,5 @@ | ||
on: (...args) => | ||
fromChild.on(.../** @type {Parameters<typeof fromChild['on']>} */ (args)), | ||
fromChild.on( | ||
.../** @type {Parameters<(typeof fromChild)['on']>} */ (args), | ||
), | ||
}; | ||
@@ -80,3 +82,3 @@ /* @type {typeof toChild} */ | ||
toChild.write( | ||
.../** @type {Parameters<typeof toChild['write']>} */ (args), | ||
.../** @type {Parameters<(typeof toChild)['write']>} */ (args), | ||
), | ||
@@ -83,0 +85,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
/* global Buffer */ | ||
/* eslint-env node */ | ||
import { Transform } from 'stream'; | ||
@@ -9,7 +9,6 @@ | ||
/** | ||
* | ||
* @param {any} object | ||
* @param {BufferEncoding} encoding | ||
* @param {any} callback | ||
* @this {{ push: (b: Buffer) => void }} | ||
* @param {*} object | ||
* @param {BufferEncoding} encoding | ||
* @param {*} callback | ||
*/ | ||
@@ -34,7 +33,6 @@ function transform(object, encoding, callback) { | ||
/** | ||
* | ||
* @this {{ push: (b: Buffer) => void }} | ||
* @param {Buffer} buf | ||
* @param {BufferEncoding} encoding | ||
* @param {*} callback | ||
* @param {any} callback | ||
* @this {{ push: (b: Buffer) => void }} | ||
*/ | ||
@@ -41,0 +39,0 @@ function transform(buf, encoding, callback) { |
@@ -6,4 +6,4 @@ // @jessie-check | ||
/** | ||
* Facilitate static analysis to prevent | ||
* demo/test facilities from being bundled in production. | ||
* Facilitate static analysis to prevent demo/test facilities from being bundled | ||
* in production. | ||
*/ | ||
@@ -10,0 +10,0 @@ export const notForProductionUse = () => { |
@@ -6,5 +6,5 @@ export function makeBoardRemote({ boardId, iface }: { | ||
export function slotToBoardRemote(boardId: string, iface: string): BoardRemote; | ||
export function boardSlottingMarshaller(slotToVal?: ((slot: string, iface: string) => any) | undefined): Omit<import('@endo/marshal').Marshal<string | null>, 'serialize' | 'unserialize'>; | ||
export function unmarshalFromVstorage(data: Map<string, string>, key: string, fromCapData: ReturnType<typeof import('@endo/marshal').makeMarshal>['fromCapData'], index: number): any; | ||
export function makeHistoryReviver(entries: Array<[string, string]>, slotToVal?: ((slot: string, iface?: string) => any) | undefined): { | ||
export function boardSlottingMarshaller(slotToVal?: (slot: string, iface: string) => any): Omit<import("@endo/marshal").Marshal<string | null>, "serialize" | "unserialize">; | ||
export function unmarshalFromVstorage(data: Map<string, string>, key: string, fromCapData: ReturnType<typeof import("@endo/marshal").makeMarshal>["fromCapData"], index: number): any; | ||
export function makeHistoryReviver(entries: [string, string][], slotToVal?: (slot: string, iface?: string) => any): { | ||
getItem: (key: string) => any; | ||
@@ -14,4 +14,11 @@ children: (prefix: string) => string[]; | ||
}; | ||
export const pureDataMarshaller: { | ||
toCapData: import("@endo/marshal").ToCapData<import("@endo/marshal").CapData<unknown>>; | ||
fromCapData: import("@endo/marshal").FromCapData<import("@endo/marshal").CapData<unknown>>; | ||
serialize: import("@endo/marshal").ToCapData<import("@endo/marshal").CapData<unknown>>; | ||
unserialize: import("@endo/marshal").FromCapData<import("@endo/marshal").CapData<unknown>>; | ||
}; | ||
/** | ||
* Should be a union with Remotable, but that's `any`, making this type meaningless | ||
* Should be a union with Remotable, but that's `any`, making this type | ||
* meaningless | ||
*/ | ||
@@ -18,0 +25,0 @@ export type BoardRemote = { |
// @ts-check | ||
import { Fail } from '@endo/errors'; | ||
import { Far } from '@endo/far'; | ||
@@ -6,6 +7,5 @@ import { makeMarshal } from '@endo/marshal'; | ||
const { Fail } = assert; | ||
/** | ||
* Should be a union with Remotable, but that's `any`, making this type meaningless | ||
* Should be a union with Remotable, but that's `any`, making this type | ||
* meaningless | ||
* | ||
@@ -16,3 +16,3 @@ * @typedef {{ getBoardId: () => string | null }} BoardRemote | ||
/** | ||
* @param {{ boardId: string | null, iface?: string }} slotInfo | ||
* @param {{ boardId: string | null; iface?: string }} slotInfo | ||
* @returns {BoardRemote} | ||
@@ -41,9 +41,11 @@ */ | ||
/** | ||
* A marshaller which can serialize getBoardId() -bearing | ||
* Remotables. This allows the caller to pick their slots. The | ||
* deserializer is configurable: the default cannot handle | ||
* Remotable-bearing data. | ||
* A marshaller which can serialize getBoardId() -bearing Remotables. This | ||
* allows the caller to pick their slots. The deserializer is configurable: the | ||
* default cannot handle Remotable-bearing data. | ||
* | ||
* @param {(slot: string, iface: string) => any} [slotToVal] | ||
* @returns {Omit<import('@endo/marshal').Marshal<string | null>, 'serialize' | 'unserialize'>} | ||
* @returns {Omit< | ||
* import('@endo/marshal').Marshal<string | null>, | ||
* 'serialize' | 'unserialize' | ||
* >} | ||
*/ | ||
@@ -76,4 +78,8 @@ export const boardSlottingMarshaller = (slotToVal = undefined) => { | ||
* @param {string} key | ||
* @param {ReturnType<typeof import('@endo/marshal').makeMarshal>['fromCapData']} fromCapData | ||
* @param {number} index index of the desired value in a deserialized stream cell | ||
* @param {ReturnType< | ||
* typeof import('@endo/marshal').makeMarshal | ||
* >['fromCapData']} fromCapData | ||
* @param {number} index index of the desired value in a deserialized stream | ||
* cell | ||
* @returns {any} | ||
*/ | ||
@@ -96,3 +102,3 @@ export const unmarshalFromVstorage = (data, key, fromCapData, index) => { | ||
/** @type {import("@endo/marshal").CapData<string>} */ | ||
/** @type {import('@endo/marshal').CapData<string>} */ | ||
const capData = harden(JSON.parse(marshalled)); | ||
@@ -109,3 +115,3 @@ assertCapData(capData); | ||
* | ||
* @param {Array<[string, string]>} entries | ||
* @param {[string, string][]} entries | ||
* @param {(slot: string, iface?: string) => any} [slotToVal] | ||
@@ -138,1 +144,8 @@ */ | ||
}; | ||
/** @param {import('@endo/marshal').CapData<unknown>} cap */ | ||
const rejectOCap = cap => Fail`${cap} is not pure data`; | ||
export const pureDataMarshaller = makeMarshal(rejectOCap, rejectOCap, { | ||
serializeBodyFormat: 'smallcaps', | ||
}); | ||
harden(pureDataMarshaller); |
@@ -5,3 +5,4 @@ // @ts-check | ||
/** | ||
* @file method-tools use dynamic property lookup, which is not Jessie-compatible | ||
* @file method-tools use dynamic property lookup, which is not | ||
* Jessie-compatible | ||
*/ | ||
@@ -16,4 +17,4 @@ | ||
* | ||
* @param {string|symbol} a | ||
* @param {string|symbol} b | ||
* @param {string | symbol} a | ||
* @param {string | symbol} b | ||
* @returns {-1 | 0 | 1} | ||
@@ -82,18 +83,18 @@ */ | ||
* https://github.com/Agoric/agoric-sdk/pull/5970 transition, from all methods | ||
* being own properties to methods being inherited from a common prototype. | ||
* This transition breaks two patterns used in prior code: autobinding, | ||
* and enumerating methods by enumerating own properties. For both, the | ||
* preferred repairs are | ||
* * autobinding: Replace, for example, | ||
* `foo(obj.method)` with `foo(arg => `obj.method(arg))`. IOW, stop relying | ||
* on expressions like `obj.method` to extract a method still bound to the | ||
* state of `obj` because, for virtual and durable objects, | ||
* they no longer will after #5970. | ||
* * method enumeration: Replace, for example | ||
* `Reflect.ownKeys(obj)` with `getMethodNames(obj)`. | ||
* being own properties to methods being inherited from a common prototype. This | ||
* transition breaks two patterns used in prior code: autobinding, and | ||
* enumerating methods by enumerating own properties. For both, the preferred | ||
* repairs are | ||
* | ||
* - autobinding: Replace, for example, `foo(obj.method)` with `foo(arg => | ||
* `obj.method(arg))`. IOW, stop relying on expressions like `obj.method`to | ||
* extract a method still bound to the state of`obj` because, for virtual and | ||
* durable objects, they no longer will after #5970. | ||
* - method enumeration: Replace, for example `Reflect.ownKeys(obj)` with | ||
* `getMethodNames(obj)`. | ||
* | ||
* Once all problematic cases have been converted in this manner, this | ||
* `bindAllMethods` hack can and TODO should be deleted. However, we currently | ||
* have no reliable static way to track down and fix all autobinding sites. | ||
* For those objects that have not yet been fully repaired by the above two | ||
* have no reliable static way to track down and fix all autobinding sites. For | ||
* those objects that have not yet been fully repaired by the above two | ||
* techniques, `bindAllMethods` creates an object that acts much like the | ||
@@ -100,0 +101,0 @@ * pre-#5970 objects, with all their methods as instance-bound own properties. |
@@ -7,8 +7,19 @@ /** | ||
export function netstringEncoderStream(): Transform; | ||
export function decode(data: any, optMaxChunkSize: any): { | ||
leftover: any; | ||
payloads: any[]; | ||
/** | ||
* @param {Buffer} data containing zero or more netstrings and maybe some | ||
* leftover bytes | ||
* @param {number} [optMaxChunkSize] | ||
* @returns {{ leftover: Buffer; payloads: Buffer[] }} zero or more decoded | ||
* Buffers, one per netstring, | ||
*/ | ||
export function decode(data: Buffer, optMaxChunkSize?: number): { | ||
leftover: Buffer; | ||
payloads: Buffer[]; | ||
}; | ||
export function netstringDecoderStream(optMaxChunkSize: any): Transform; | ||
/** | ||
* @param {number} [optMaxChunkSize] | ||
* @returns {Transform} | ||
*/ | ||
export function netstringDecoderStream(optMaxChunkSize?: number): Transform; | ||
import { Transform } from 'stream'; | ||
//# sourceMappingURL=netstring.d.ts.map |
@@ -1,3 +0,3 @@ | ||
/* global Buffer */ | ||
import { Fail } from '@agoric/assert'; | ||
/* eslint-env node */ | ||
import { Fail } from '@endo/errors'; | ||
@@ -23,7 +23,6 @@ // adapted from 'netstring-stream', https://github.com/tlivings/netstring-stream/ | ||
/** | ||
* | ||
* @this {{ push: (b: Buffer) => void }} | ||
* @param {Buffer} chunk | ||
* @param {BufferEncoding} encoding | ||
* @param {*} callback | ||
* @param {any} callback | ||
* @this {{ push: (b: Buffer) => void }} | ||
*/ | ||
@@ -47,6 +46,9 @@ function transform(chunk, encoding, callback) { | ||
// Input is a Buffer containing zero or more netstrings and maybe some | ||
// leftover bytes. Output is zero or more decoded Buffers, one per netstring, | ||
// plus a Buffer of leftover bytes. | ||
// | ||
/** | ||
* @param {Buffer} data containing zero or more netstrings and maybe some | ||
* leftover bytes | ||
* @param {number} [optMaxChunkSize] | ||
* @returns {{ leftover: Buffer; payloads: Buffer[] }} zero or more decoded | ||
* Buffers, one per netstring, | ||
*/ | ||
export function decode(data, optMaxChunkSize) { | ||
@@ -86,11 +88,15 @@ // TODO: it would be more efficient to accumulate pending data in an array, | ||
/** | ||
* @param {number} [optMaxChunkSize] | ||
* @returns {Transform} | ||
*/ | ||
// input is a byte pipe, output is a sequence of Buffers | ||
export function netstringDecoderStream(optMaxChunkSize) { | ||
/** @type {Buffer<ArrayBufferLike>} */ | ||
let buffered = Buffer.from(''); | ||
/** | ||
* | ||
* @this {{ push: (b: Buffer) => void }} | ||
* @param {Buffer} chunk | ||
* @param {BufferEncoding} encoding | ||
* @param {*} callback | ||
* @param {any} callback | ||
* @this {{ push: (b: Buffer) => void }} | ||
*/ | ||
@@ -97,0 +103,0 @@ function transform(chunk, encoding, callback) { |
@@ -1,27 +0,29 @@ | ||
/// <reference types="node" /> | ||
/** | ||
* @typedef {object} BufferLineTransformOptions | ||
* @property {Buffer | string | number} [break] line break matcher for Buffer.indexOf() (default: 10) | ||
* @property {BufferEncoding} [breakEncoding] if break is a string, the encoding to use | ||
* @property {Buffer | string | number} [break] line break matcher for | ||
* Buffer.indexOf() (default: 10) | ||
* @property {BufferEncoding} [breakEncoding] if break is a string, the encoding | ||
* to use | ||
*/ | ||
export default class BufferLineTransform extends Transform { | ||
/** | ||
* The BufferLineTransform is reading String or Buffer content from a Readable stream | ||
* and writing each line as a Buffer in object mode | ||
* The BufferLineTransform is reading String or Buffer content from a Readable | ||
* stream and writing each line as a Buffer in object mode | ||
* | ||
* @param {import('node:stream').TransformOptions & BufferLineTransformOptions} [options] | ||
* @param {import('node:stream').TransformOptions & | ||
* BufferLineTransformOptions} [options] | ||
*/ | ||
constructor(options?: (import("stream").TransformOptions & BufferLineTransformOptions) | undefined); | ||
_breakValue: string | number | Buffer; | ||
constructor(options?: import("node:stream").TransformOptions & BufferLineTransformOptions); | ||
_breakValue: string | number | Buffer<ArrayBufferLike>; | ||
_breakEncoding: BufferEncoding | undefined; | ||
_breakLength: number; | ||
/** @type {Array<Buffer>} */ | ||
_chunks: Array<Buffer>; | ||
/** @type {Buffer[]} */ | ||
_chunks: Buffer[]; | ||
/** | ||
* @override | ||
* @param {any} chunk | ||
* @param {BufferEncoding | 'buffer'} encoding | ||
* @param {import('node:stream').TransformCallback} cb | ||
* @override | ||
*/ | ||
override _transform(chunk: any, encoding: BufferEncoding | 'buffer', cb: import('node:stream').TransformCallback): void; | ||
override _transform(chunk: any, encoding: BufferEncoding | "buffer", cb: import("node:stream").TransformCallback): void; | ||
/** @param {Buffer} line */ | ||
@@ -32,7 +34,9 @@ _writeItem(line: Buffer): void; | ||
/** | ||
* line break matcher for Buffer.indexOf() (default: 10) | ||
* line break matcher for | ||
* Buffer.indexOf() (default: 10) | ||
*/ | ||
break?: string | number | Buffer | undefined; | ||
break?: string | number | Buffer<ArrayBufferLike> | undefined; | ||
/** | ||
* if break is a string, the encoding to use | ||
* if break is a string, the encoding | ||
* to use | ||
*/ | ||
@@ -39,0 +43,0 @@ breakEncoding?: BufferEncoding | undefined; |
@@ -1,2 +0,2 @@ | ||
/* global Buffer */ | ||
/* eslint-env node */ | ||
/* eslint-disable no-underscore-dangle */ | ||
@@ -8,4 +8,6 @@ | ||
* @typedef {object} BufferLineTransformOptions | ||
* @property {Buffer | string | number} [break] line break matcher for Buffer.indexOf() (default: 10) | ||
* @property {BufferEncoding} [breakEncoding] if break is a string, the encoding to use | ||
* @property {Buffer | string | number} [break] line break matcher for | ||
* Buffer.indexOf() (default: 10) | ||
* @property {BufferEncoding} [breakEncoding] if break is a string, the encoding | ||
* to use | ||
*/ | ||
@@ -15,6 +17,7 @@ | ||
/** | ||
* The BufferLineTransform is reading String or Buffer content from a Readable stream | ||
* and writing each line as a Buffer in object mode | ||
* The BufferLineTransform is reading String or Buffer content from a Readable | ||
* stream and writing each line as a Buffer in object mode | ||
* | ||
* @param {import('node:stream').TransformOptions & BufferLineTransformOptions} [options] | ||
* @param {import('node:stream').TransformOptions & | ||
* BufferLineTransformOptions} [options] | ||
*/ | ||
@@ -42,3 +45,3 @@ constructor(options) { | ||
/** @type {Array<Buffer>} */ | ||
/** @type {Buffer[]} */ | ||
this._chunks = []; | ||
@@ -48,6 +51,6 @@ } | ||
/** | ||
* @override | ||
* @param {any} chunk | ||
* @param {BufferEncoding | 'buffer'} encoding | ||
* @param {import('node:stream').TransformCallback} cb | ||
* @override | ||
*/ | ||
@@ -103,4 +106,4 @@ _transform(chunk, encoding, cb) { | ||
/** | ||
* @param {import('node:stream').TransformCallback} cb | ||
* @override | ||
* @param {import('node:stream').TransformCallback} cb | ||
*/ | ||
@@ -107,0 +110,0 @@ _flush(cb) { |
@@ -1,2 +0,2 @@ | ||
/* global process */ | ||
/* eslint-env node */ | ||
// Use modules not prefixed with `node:` since some deploy scripts may | ||
@@ -8,3 +8,4 @@ // still be running in esm emulation | ||
const { Fail, quote: q } = assert; | ||
import { Fail, q } from '@endo/errors'; | ||
const BUNDLE_SOURCE_PROGRAM = 'bundle-source'; | ||
@@ -28,2 +29,3 @@ const req = createRequire(import.meta.url); | ||
const args = cacheToArgs.get(cache) || ['--cache-js', cache]; | ||
args.push('--elide-comments'); | ||
args.push(srcPath, bundle); | ||
@@ -30,0 +32,0 @@ cacheToArgs.set(cache, args); |
@@ -1,2 +0,2 @@ | ||
export function fsStreamReady(stream: import("fs").ReadStream | import("fs").WriteStream): Promise<void>; | ||
export function fsStreamReady(stream: import("fs").ReadStream | import("fs").WriteStream | import("net").Socket): Promise<void>; | ||
export function makeFsStreamWriter(filePath: string | undefined | null): Promise<{ | ||
@@ -3,0 +3,0 @@ write: (data: any) => Promise<void>; |
import { createWriteStream } from 'node:fs'; | ||
import process from 'node:process'; | ||
import { open } from 'node:fs/promises'; | ||
import { makeAggregateError } from '../utils.js'; | ||
/** | ||
* @param {import("fs").ReadStream | import("fs").WriteStream} stream | ||
* @param {import('fs').ReadStream | ||
* | import('fs').WriteStream | ||
* | import('net').Socket} stream | ||
* @returns {Promise<void>} | ||
@@ -22,3 +24,3 @@ */ | ||
const onReady = () => { | ||
cleanup(); // eslint-disable-line no-use-before-define | ||
cleanup(); | ||
resolve(); | ||
@@ -29,3 +31,3 @@ }; | ||
const onError = err => { | ||
cleanup(); // eslint-disable-line no-use-before-define | ||
cleanup(); | ||
reject(err); | ||
@@ -54,5 +56,7 @@ }; | ||
const handle = await open(filePath, 'a'); | ||
const handle = await (filePath !== '-' ? open(filePath, 'a') : undefined); | ||
const stream = createWriteStream(noPath, { fd: handle.fd }); | ||
const stream = handle | ||
? createWriteStream(noPath, { fd: handle.fd }) | ||
: process.stdout; | ||
await fsStreamReady(stream); | ||
@@ -63,27 +67,31 @@ | ||
const write = async data => { | ||
if (closed) { | ||
throw Error('Stream closed'); | ||
} | ||
/** @type {Promise<void>} */ | ||
const written = new Promise((resolve, reject) => { | ||
stream.write(data, err => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
const updateFlushed = p => { | ||
flushed = flushed.then( | ||
() => written, | ||
async err => | ||
Promise.reject( | ||
written.then( | ||
() => err, | ||
writtenError => makeAggregateError([err, writtenError]), | ||
), | ||
() => p, | ||
err => | ||
p.then( | ||
() => Promise.reject(err), | ||
pError => | ||
Promise.reject( | ||
pError !== err ? AggregateError([err, pError]) : err, | ||
), | ||
), | ||
); | ||
flushed.catch(() => {}); | ||
}; | ||
const write = async data => { | ||
/** @type {Promise<void>} */ | ||
const written = closed | ||
? Promise.reject(Error('Stream closed')) | ||
: new Promise((resolve, reject) => { | ||
stream.write(data, err => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
updateFlushed(written); | ||
return written; | ||
@@ -94,3 +102,3 @@ }; | ||
await flushed; | ||
await handle.sync().catch(err => { | ||
await handle?.sync().catch(err => { | ||
if (err.code === 'EINVAL') { | ||
@@ -104,8 +112,12 @@ return; | ||
const close = async () => { | ||
// TODO: Consider creating a single Error here to use a write rejection | ||
closed = true; | ||
await flush(); | ||
stream.close(); | ||
// @ts-expect-error calling a possibly missing method | ||
stream.close?.(); | ||
}; | ||
stream.on('error', err => updateFlushed(Promise.reject(err))); | ||
return harden({ write, flush, close }); | ||
}; |
@@ -25,3 +25,2 @@ import process from 'node:process'; | ||
process.off('beforeExit', shutdown); | ||
// eslint-disable-next-line no-use-before-define | ||
process.off('uncaughtException', uncaughtShutdown); | ||
@@ -28,0 +27,0 @@ verbose && console.error(`Shutting down cleanly...`); |
@@ -16,3 +16,3 @@ /** @type {(namespace: string) => string} */ | ||
remove: (rawNamespace: string, address: string) => Promise<void>; | ||
} & import("@endo/eventual-send").RemotableBrand<{}, { | ||
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, { | ||
/** | ||
@@ -32,2 +32,3 @@ * @param {string} rawNamespace | ||
export type PrioritySendersManager = ReturnType<typeof makePrioritySendersManager>; | ||
import type { ERef } from '@endo/far'; | ||
//# sourceMappingURL=priority-senders.d.ts.map |
@@ -0,4 +1,6 @@ | ||
import { Fail, q } from '@endo/errors'; | ||
import { E, Far } from '@endo/far'; | ||
const { Fail, quote: q } = assert; | ||
/** @import {ERef} from '@endo/far'; */ | ||
/** @import {StorageNode} from './lib-chainStorage.js'; */ | ||
@@ -23,5 +25,9 @@ const PRIORITY_SENDERS_NAMESPACE_RE = /^[a-zA-Z0-9_-]{1,50}$/; | ||
/** | ||
* address to tuple with storage node and set of namespaces that requested priority | ||
* address to tuple with storage node and set of namespaces that requested | ||
* priority | ||
* | ||
* @type {Map<string, readonly [node: StorageNode, namespaces: Set<string>]>} | ||
* @type {Map< | ||
* string, | ||
* readonly [node: StorageNode, namespaces: Set<string>] | ||
* >} | ||
*/ | ||
@@ -51,3 +57,3 @@ const addressRecords = new Map(); | ||
}); | ||
/** @type {readonly [ node: StorageNode, namespaces: Set<string> ]} */ | ||
/** @type {readonly [node: StorageNode, namespaces: Set<string>]} */ | ||
const r = [node, new Set()]; | ||
@@ -54,0 +60,0 @@ addressRecords.set(address, r); |
@@ -1,2 +0,2 @@ | ||
export function makeWithQueue(): <T extends (...args: any[]) => any>(inner: T) => (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>; | ||
export function makeWithQueue(): (inner: T) => (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>; | ||
//# sourceMappingURL=queue.d.ts.map |
// @jessie-check | ||
/* eslint @typescript-eslint/no-floating-promises: "warn" */ | ||
@@ -7,4 +6,4 @@ import { makePromiseKit } from '@endo/promise-kit'; | ||
/** | ||
* Return a function that can wrap an async or sync method, but | ||
* ensures only one of them (in order) is running at a time. | ||
* Return a function that can wrap an async or sync method, but ensures only one | ||
* of them (in order) is running at a time. | ||
*/ | ||
@@ -11,0 +10,0 @@ export const makeWithQueue = () => { |
@@ -9,3 +9,3 @@ export default function makeScratchPad(): { | ||
set: (keyP: any, objP: any) => Promise<any>; | ||
} & import("@endo/eventual-send").RemotableBrand<{}, { | ||
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, { | ||
delete: (keyP: any) => Promise<void>; | ||
@@ -12,0 +12,0 @@ get: (keyP: any) => Promise<any>; |
@@ -1,106 +0,66 @@ | ||
export function slotToRemotable(_slotId: string, iface?: string): import("@endo/eventual-send").RemotableBrand<{}, {}>; | ||
export function slotToRemotable(_slotId: string, iface?: string): import("@endo/pass-style").RemotableObject<string> & import("@endo/eventual-send").RemotableBrand<{}, {}>; | ||
/** | ||
* A basic marshaller whose unserializer produces Remotables. It can | ||
* only serialize plain data, not Remotables. | ||
* A basic marshaller whose unserializer produces Remotables. It can only | ||
* serialize plain data, not Remotables. | ||
*/ | ||
export const defaultMarshaller: { | ||
toCapData: import("@endo/marshal/src/marshal.js").ToCapData<string>; | ||
fromCapData: import("@endo/marshal/src/marshal.js").FromCapData<string>; | ||
serialize: import("@endo/marshal/src/marshal.js").ToCapData<string>; | ||
unserialize: import("@endo/marshal/src/marshal.js").FromCapData<string>; | ||
toCapData: import("@endo/marshal").ToCapData<string>; | ||
fromCapData: import("@endo/marshal").FromCapData<string>; | ||
serialize: import("@endo/marshal").ToCapData<string>; | ||
unserialize: import("@endo/marshal").FromCapData<string>; | ||
}; | ||
export function slotStringUnserialize(capData: any): any; | ||
export function makeFakeStorageKit(rootPath: string, rootOptions?: [handleStorageMessage: (message: import("./lib-chainStorage.js").StorageMessage) => any, rootPath: string, rootOptions?: { | ||
sequence?: boolean | undefined; | ||
} | undefined][2]): { | ||
rootNode: import("@endo/exo/src/exo-makers.js").Guarded<{ | ||
export namespace defaultSerializer { | ||
let parse: (text: string) => unknown; | ||
let stringify: (obj: any) => string; | ||
} | ||
export const slotStringUnserialize: (capData: any) => any; | ||
export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<typeof makeChainStorageRoot>[2]): { | ||
rootNode: import("@endo/exo").Guarded<{ | ||
getPath(): string; | ||
getStoreKey(): Promise<import("./lib-chainStorage.js").VStorageKey>; | ||
getStoreKey(): Promise<VStorageKey>; | ||
makeChildNode(name: string, childNodeOptions?: { | ||
sequence?: boolean | undefined; | ||
} | undefined): import("./lib-chainStorage.js").StorageNode; | ||
sequence?: boolean; | ||
}): StorageNode; | ||
setValue(value: string): Promise<void>; | ||
}>; | ||
data: Map<string, string>; | ||
messages: import("./lib-chainStorage.js").StorageMessage[]; | ||
toStorage: (message: import('../src/lib-chainStorage.js').StorageMessage) => string | number | any[] | { | ||
updateNewCellBlockHeight: (blockHeight?: number) => void; | ||
getValues: (path: string) => string[]; | ||
messages: StorageMessage[]; | ||
toStorage: ((message: StorageMessage) => string | number | true | any[] | { | ||
storeName: string; | ||
storeSubkey: string; | ||
} | null | undefined; | ||
} | null) & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (message: StorageMessage) => string | number | true | any[] | { | ||
storeName: string; | ||
storeSubkey: string; | ||
} | null>; | ||
}; | ||
export function makeMockChainStorageRoot(): { | ||
export function makeMockChainStorageRoot(): MockChainStorageRoot; | ||
export function documentStorageSchema(t: import("ava").ExecutionContext<unknown>, storage: MockChainStorageRoot | FakeStorageKit, opts: ({ | ||
note: string; | ||
} | { | ||
node: string; | ||
owner: string; | ||
}) & ({ | ||
pattern: string; | ||
replacement: string; | ||
} | {}) & { | ||
showValue?: (v: string) => unknown; | ||
}): Promise<void>; | ||
export type FakeStorageKit = ReturnType<typeof makeFakeStorageKit>; | ||
export type MockChainStorageRootMethods = { | ||
/** | ||
* Defaults to deserializing slot references into plain Remotable | ||
* objects having the specified interface name (as from `Far(iface)`), | ||
* but can accept a different marshaller for producing Remotables | ||
* that e.g. embed the slot string in their iface name. | ||
* | ||
* @param {string} path | ||
* @param {import('./lib-chainStorage.js').Marshaller} marshaller | ||
* @param {number} [index] | ||
* @returns {unknown} | ||
* Defaults to deserializing slot references into plain Remotable objects having | ||
* the specified interface name (as from `Far(iface)`), but can accept a | ||
* different marshaller for producing Remotables that e.g. embed the slot | ||
* string in their iface name. | ||
*/ | ||
getBody: (path: string, marshaller?: import('./lib-chainStorage.js').Marshaller, index?: number | undefined) => unknown; | ||
getBody: (path: string, marshaller?: Marshaller, index?: number) => unknown; | ||
keys: () => string[]; | ||
getPath(): string; | ||
getStoreKey(): Promise<import("./lib-chainStorage.js").VStorageKey>; | ||
makeChildNode(name: string, childNodeOptions?: { | ||
sequence?: boolean | undefined; | ||
} | undefined): import("./lib-chainStorage.js").StorageNode; | ||
setValue(value: string): Promise<void>; | ||
__getInterfaceGuard__?: (() => import("@endo/patterns").InterfaceGuard<{ | ||
getPath: import("@endo/patterns").MethodGuard; | ||
getStoreKey: import("@endo/patterns").MethodGuard; | ||
makeChildNode: import("@endo/patterns").MethodGuard; | ||
setValue: import("@endo/patterns").MethodGuard; | ||
}> | undefined) | undefined; | ||
} & import("@endo/eventual-send").RemotableBrand<{}, { | ||
/** | ||
* Defaults to deserializing slot references into plain Remotable | ||
* objects having the specified interface name (as from `Far(iface)`), | ||
* but can accept a different marshaller for producing Remotables | ||
* that e.g. embed the slot string in their iface name. | ||
* | ||
* @param {string} path | ||
* @param {import('./lib-chainStorage.js').Marshaller} marshaller | ||
* @param {number} [index] | ||
* @returns {unknown} | ||
*/ | ||
getBody: (path: string, marshaller?: import('./lib-chainStorage.js').Marshaller, index?: number | undefined) => unknown; | ||
keys: () => string[]; | ||
getPath(): string; | ||
getStoreKey(): Promise<import("./lib-chainStorage.js").VStorageKey>; | ||
makeChildNode(name: string, childNodeOptions?: { | ||
sequence?: boolean | undefined; | ||
} | undefined): import("./lib-chainStorage.js").StorageNode; | ||
setValue(value: string): Promise<void>; | ||
__getInterfaceGuard__?: (() => import("@endo/patterns").InterfaceGuard<{ | ||
getPath: import("@endo/patterns").MethodGuard; | ||
getStoreKey: import("@endo/patterns").MethodGuard; | ||
makeChildNode: import("@endo/patterns").MethodGuard; | ||
setValue: import("@endo/patterns").MethodGuard; | ||
}> | undefined) | undefined; | ||
}>; | ||
/** | ||
* A map corresponding with a total function such that `get(key)` | ||
* is assumed to always succeed. | ||
*/ | ||
export type TotalMap<K, V> = { | ||
[Symbol.iterator]: () => IterableIterator<[K, V]>; | ||
[Symbol.toStringTag]: string; | ||
forEach: (callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any) => void; | ||
entries: () => IterableIterator<[K, V]>; | ||
keys: () => IterableIterator<K>; | ||
values: () => IterableIterator<V>; | ||
has: (key: K) => boolean; | ||
size: number; | ||
set: (key: K, value: V) => Map<K, V>; | ||
clear: () => void; | ||
delete: (key: K) => boolean; | ||
} & { | ||
get: (key: K) => V; | ||
}; | ||
export type TotalMapFrom<T> = T extends Map<infer K, infer V> ? TotalMap<K, V> : never; | ||
export type FakeStorageKit = ReturnType<typeof makeFakeStorageKit>; | ||
export type MockChainStorageRoot = ReturnType<typeof makeMockChainStorageRoot>; | ||
export type MockChainStorageRoot = StorageNode & MockChainStorageRootMethods; | ||
import { makeChainStorageRoot } from './lib-chainStorage.js'; | ||
import type { StorageNode } from './lib-chainStorage.js'; | ||
import type { StorageMessage } from './lib-chainStorage.js'; | ||
import type { Marshaller } from './lib-chainStorage.js'; | ||
//# sourceMappingURL=storage-test-utils.d.ts.map |
// @ts-check | ||
import { Fail } from '@endo/errors'; | ||
import { Far } from '@endo/far'; | ||
import { makeMarshal, Remotable } from '@endo/marshal'; | ||
import { unmarshalFromVstorage } from './marshal.js'; | ||
import { makeTracer } from './debug.js'; | ||
import { NonNullish } from './errors.js'; | ||
import { isStreamCell, makeChainStorageRoot } from './lib-chainStorage.js'; | ||
import { unmarshalFromVstorage } from './marshal.js'; | ||
import { bindAllMethods } from './method-tools.js'; | ||
import { eventLoopIteration } from './testing-utils.js'; | ||
const { Fail } = assert; | ||
/** | ||
* @import {TotalMap} from './types.js'; | ||
* @import {Marshaller, StorageEntry, StorageMessage, StorageNode, StreamCell} from './lib-chainStorage.js'; | ||
*/ | ||
@@ -14,17 +20,5 @@ const trace = makeTracer('StorTU', false); | ||
/** | ||
* A map corresponding with a total function such that `get(key)` | ||
* is assumed to always succeed. | ||
* A convertSlotToVal function that produces basic Remotables. Assumes that all | ||
* slots are Remotables (i.e. none are Promises). | ||
* | ||
* @template K, V | ||
* @typedef {{[k in Exclude<keyof Map<K, V>, 'get'>]: Map<K, V>[k]} & {get: (key: K) => V}} TotalMap | ||
*/ | ||
/** | ||
* @template T | ||
* @typedef {T extends Map<infer K, infer V> ? TotalMap<K, V> : never} TotalMapFrom | ||
*/ | ||
/** | ||
* A convertSlotToVal function that produces basic Remotables. Assumes | ||
* that all slots are Remotables (i.e. none are Promises). | ||
* | ||
* @param {string} _slotId | ||
@@ -37,4 +31,4 @@ * @param {string} iface | ||
/** | ||
* A basic marshaller whose unserializer produces Remotables. It can | ||
* only serialize plain data, not Remotables. | ||
* A basic marshaller whose unserializer produces Remotables. It can only | ||
* serialize plain data, not Remotables. | ||
*/ | ||
@@ -46,6 +40,16 @@ export const defaultMarshaller = makeMarshal(undefined, slotToRemotable, { | ||
/** | ||
* A deserializer which produces slot strings instead of Remotables, | ||
* so if `a = Far('iface')`, and serializing `{ a }` into `capData` | ||
* assigned it slot `board123`, then `slotStringUnserialize(capData)` | ||
* would produce `{ a: 'board123' }`. | ||
* Serialize/deserialize functions using {@link defaultMarshaller} | ||
*/ | ||
export const defaultSerializer = { | ||
/** @type {(text: string) => unknown} */ | ||
parse: txt => defaultMarshaller.fromCapData(JSON.parse(txt)), | ||
/** @type {(obj: any) => string} */ | ||
stringify: obj => JSON.stringify(defaultMarshaller.toCapData(obj)), | ||
}; | ||
/** | ||
* A deserializer which produces slot strings instead of Remotables, so if `a = | ||
* Far('iface')`, and serializing `{ a }` into `capData` assigned it slot | ||
* `board123`, then `slotStringUnserialize(capData)` would produce `{ a: | ||
* 'board123' }`. | ||
* | ||
@@ -55,14 +59,14 @@ * This may be useful for display purposes. | ||
* Limitations: | ||
* * it cannot handle Symbols (registered or well-known) | ||
* * it can handle BigInts, but serialized data that contains a | ||
* particular unusual string will be unserialized into a BigInt by | ||
* mistake | ||
* * it cannot handle Promises, NaN, +/- Infinity, undefined, or | ||
* other non-JSONable JavaScript values | ||
* | ||
* - it cannot handle Symbols (registered or well-known) | ||
* - it can handle BigInts, but serialized data that contains a particular unusual | ||
* string will be unserialized into a BigInt by mistake | ||
* - it cannot handle Promises, NaN, +/- Infinity, undefined, or other | ||
* non-JSONable JavaScript values | ||
*/ | ||
const makeSlotStringUnserialize = () => { | ||
/** @type { (slot: string, iface: string) => any } */ | ||
/** @type {(slot: string, iface: string) => any} */ | ||
const identitySlotToValFn = (slot, _) => Far('unk', { toJSON: () => slot }); | ||
const { fromCapData } = makeMarshal(undefined, identitySlotToValFn); | ||
/** @type { (capData: any) => any } */ | ||
/** @type {(capData: any) => any} */ | ||
const unserialize = capData => | ||
@@ -92,5 +96,5 @@ JSON.parse( | ||
/** | ||
* For testing, creates a chainStorage root node over an in-memory map | ||
* and exposes both the map and the sequence of received messages. | ||
* The `sequence` option defaults to true. | ||
* For testing, creates a chainStorage root node over an in-memory map and | ||
* exposes both the map and the sequence of received messages. The `sequence` | ||
* option defaults to true. | ||
* | ||
@@ -104,2 +108,10 @@ * @param {string} rootPath | ||
const data = new Map(); | ||
let currentBlockHeight = 0; | ||
const updateNewCellBlockHeight = (blockHeight = currentBlockHeight + 1) => { | ||
blockHeight > currentBlockHeight || | ||
Fail`blockHeight ${blockHeight} must be greater than ${currentBlockHeight}`; | ||
currentBlockHeight = blockHeight; | ||
}; | ||
/** @param {string} prefix */ | ||
@@ -122,81 +134,111 @@ const getChildEntries = prefix => { | ||
}; | ||
/** @type {import('../src/lib-chainStorage.js').StorageMessage[]} */ | ||
/** @type {StorageMessage[]} */ | ||
const messages = []; | ||
/** @param {import('../src/lib-chainStorage.js').StorageMessage} message */ | ||
const toStorage = message => { | ||
messages.push(message); | ||
switch (message.method) { | ||
case 'getStoreKey': { | ||
const [key] = message.args; | ||
return { storeName: 'swingset', storeSubkey: `fake:${key}` }; | ||
} | ||
case 'get': { | ||
const [key] = message.args; | ||
return data.has(key) ? data.get(key) : null; | ||
} | ||
case 'children': { | ||
const [key] = message.args; | ||
const childEntries = getChildEntries(`${key}.`); | ||
return [...childEntries.keys()]; | ||
} | ||
case 'entries': { | ||
const [key] = message.args; | ||
const childEntries = getChildEntries(`${key}.`); | ||
return [...childEntries.entries()].map(entry => | ||
entry[1] != null ? entry : [entry[0]], | ||
); | ||
} | ||
case 'set': | ||
case 'setWithoutNotify': { | ||
trace('toStorage set', message); | ||
/** @type {import('../src/lib-chainStorage.js').StorageEntry[]} */ | ||
const newEntries = message.args; | ||
for (const [key, value] of newEntries) { | ||
if (value != null) { | ||
data.set(key, value); | ||
} else { | ||
data.delete(key); | ||
const toStorage = Far( | ||
'ToStorage', | ||
/** @param {StorageMessage} message */ | ||
message => { | ||
messages.push(message); | ||
switch (message.method) { | ||
case 'getStoreKey': { | ||
const [key] = message.args; | ||
return { storeName: 'swingset', storeSubkey: `fake:${key}` }; | ||
} | ||
case 'get': { | ||
const [key] = message.args; | ||
return data.has(key) ? data.get(key) : null; | ||
} | ||
case 'children': { | ||
const [key] = message.args; | ||
const childEntries = getChildEntries(`${key}.`); | ||
return [...childEntries.keys()]; | ||
} | ||
case 'entries': { | ||
const [key] = message.args; | ||
const childEntries = getChildEntries(`${key}.`); | ||
return [...childEntries.entries()].map(entry => | ||
entry[1] != null ? entry : [entry[0]], | ||
); | ||
} | ||
case 'set': | ||
case 'setWithoutNotify': { | ||
trace('toStorage set', message); | ||
/** @type {StorageEntry[]} */ | ||
const newEntries = message.args; | ||
for (const [key, value] of newEntries) { | ||
if (value != null) { | ||
data.set(key, value); | ||
} else { | ||
data.delete(key); | ||
} | ||
} | ||
return true; | ||
} | ||
break; | ||
} | ||
case 'append': { | ||
trace('toStorage append', message); | ||
/** @type {import('../src/lib-chainStorage.js').StorageEntry[]} */ | ||
const newEntries = message.args; | ||
for (const [key, value] of newEntries) { | ||
value != null || Fail`attempt to append with no value`; | ||
// In the absence of block boundaries, everything goes in a single StreamCell. | ||
const oldVal = data.get(key); | ||
let streamCell; | ||
if (oldVal != null) { | ||
try { | ||
streamCell = JSON.parse(oldVal); | ||
assert(isStreamCell(streamCell)); | ||
} catch (_err) { | ||
streamCell = undefined; | ||
case 'append': { | ||
trace('toStorage append', message); | ||
/** @type {StorageEntry[]} */ | ||
const newEntries = message.args; | ||
for (const [key, value] of newEntries) { | ||
value != null || Fail`attempt to append with no value`; | ||
/** @type {string | undefined} */ | ||
let oldVal = data.get(key); | ||
/** @type {StreamCell | undefined} */ | ||
let streamCell; | ||
if (oldVal != null) { | ||
try { | ||
streamCell = JSON.parse(oldVal); | ||
assert(isStreamCell(streamCell)); | ||
} catch (_err) { | ||
streamCell = undefined; | ||
} | ||
// StreamCells reset at block boundaries. | ||
if ( | ||
streamCell && | ||
Number(streamCell.blockHeight) !== currentBlockHeight | ||
) { | ||
streamCell = undefined; | ||
oldVal = undefined; | ||
} | ||
} | ||
if (streamCell === undefined) { | ||
streamCell = { | ||
blockHeight: String(currentBlockHeight), | ||
values: oldVal != null ? [oldVal] : [], | ||
}; | ||
} | ||
streamCell.values.push(value); | ||
data.set(key, JSON.stringify(streamCell)); | ||
} | ||
if (streamCell === undefined) { | ||
streamCell = { | ||
blockHeight: '0', | ||
values: oldVal != null ? [oldVal] : [], | ||
}; | ||
} | ||
streamCell.values.push(value); | ||
data.set(key, JSON.stringify(streamCell)); | ||
return true; | ||
} | ||
break; | ||
case 'size': | ||
// Intentionally incorrect because it counts non-child descendants, | ||
// but nevertheless supports a "has children" test. | ||
return [...data.keys()].filter(k => | ||
k.startsWith(`${message.args[0]}.`), | ||
).length; | ||
default: | ||
throw Error(`unsupported method: ${message.method}`); | ||
} | ||
case 'size': | ||
// Intentionally incorrect because it counts non-child descendants, | ||
// but nevertheless supports a "has children" test. | ||
return [...data.keys()].filter(k => k.startsWith(`${message.args[0]}.`)) | ||
.length; | ||
default: | ||
throw Error(`unsupported method: ${message.method}`); | ||
} | ||
}, | ||
); | ||
const rootNode = makeChainStorageRoot(toStorage, rootPath, resolvedOptions); | ||
/** | ||
* Get the values at a sequence node | ||
* | ||
* @param {string} path | ||
* @returns {string[]} | ||
*/ | ||
const getValues = path => { | ||
assert(resolvedOptions.sequence); | ||
const nodeData = data.get(path); | ||
assert(nodeData, `no data at path ${path}`); | ||
const wrapper = JSON.parse(nodeData); | ||
return wrapper.values; | ||
}; | ||
const rootNode = makeChainStorageRoot(toStorage, rootPath, resolvedOptions); | ||
return { | ||
@@ -206,2 +248,4 @@ rootNode, | ||
data: /** @type {Map<string, string>} */ (data), | ||
updateNewCellBlockHeight, | ||
getValues, | ||
messages, | ||
@@ -212,4 +256,20 @@ toStorage, | ||
harden(makeFakeStorageKit); | ||
/** @typedef {ReturnType< typeof makeFakeStorageKit>} FakeStorageKit */ | ||
/** @typedef {ReturnType<typeof makeFakeStorageKit>} FakeStorageKit */ | ||
/** | ||
* @typedef MockChainStorageRootMethods | ||
* @property {( | ||
* path: string, | ||
* marshaller?: Marshaller, | ||
* index?: number, | ||
* ) => unknown} getBody | ||
* Defaults to deserializing slot references into plain Remotable objects having | ||
* the specified interface name (as from `Far(iface)`), but can accept a | ||
* different marshaller for producing Remotables that e.g. embed the slot | ||
* string in their iface name. | ||
* @property {() => string[]} keys | ||
*/ | ||
/** @typedef {StorageNode & MockChainStorageRootMethods} MockChainStorageRoot */ | ||
/** @returns {MockChainStorageRoot} */ | ||
export const makeMockChainStorageRoot = () => { | ||
@@ -220,9 +280,9 @@ const { rootNode, data } = makeFakeStorageKit('mockChainStorageRoot'); | ||
/** | ||
* Defaults to deserializing slot references into plain Remotable | ||
* objects having the specified interface name (as from `Far(iface)`), | ||
* but can accept a different marshaller for producing Remotables | ||
* that e.g. embed the slot string in their iface name. | ||
* Defaults to deserializing slot references into plain Remotable objects | ||
* having the specified interface name (as from `Far(iface)`), but can | ||
* accept a different marshaller for producing Remotables that e.g. embed | ||
* the slot string in their iface name. | ||
* | ||
* @param {string} path | ||
* @param {import('./lib-chainStorage.js').Marshaller} marshaller | ||
* @param {Marshaller} marshaller | ||
* @param {number} [index] | ||
@@ -233,3 +293,7 @@ * @returns {unknown} | ||
data.size || Fail`no data in storage`; | ||
/** @type {ReturnType<typeof import('@endo/marshal').makeMarshal>['fromCapData']} */ | ||
/** | ||
* @type {ReturnType< | ||
* typeof import('@endo/marshal').makeMarshal | ||
* >['fromCapData']} | ||
*/ | ||
const fromCapData = (...args) => | ||
@@ -242,2 +306,59 @@ Reflect.apply(marshaller.fromCapData, marshaller, args); | ||
}; | ||
/** @typedef {ReturnType<typeof makeMockChainStorageRoot>} MockChainStorageRoot */ | ||
/** | ||
* @param {import('ava').ExecutionContext<unknown>} t | ||
* @param {MockChainStorageRoot | FakeStorageKit} storage | ||
* @param {({ note: string } | { node: string; owner: string }) & | ||
* ({ pattern: string; replacement: string } | {}) & { | ||
* showValue?: (v: string) => unknown; | ||
* }} opts | ||
*/ | ||
export const documentStorageSchema = async (t, storage, opts) => { | ||
// chainStorage publication is unsynchronized | ||
await eventLoopIteration(); | ||
const getLast = (/** @type {string} */ cell) => | ||
JSON.parse(cell).values.at(-1) || assert.fail(); | ||
const { showValue = s => s } = opts; | ||
/** @type {(d: Map<string, string>, k: string) => unknown} */ | ||
const getBodyDefault = (d, k) => showValue(getLast(NonNullish(d.get(k)))); | ||
const [keys, getBody] = | ||
'keys' in storage | ||
? [storage.keys(), (/** @type {string} */ k) => storage.getBody(k)] | ||
: [ | ||
storage.data.keys(), | ||
(/** @type {string} */ k) => getBodyDefault(storage.data, k), | ||
]; | ||
const { pattern, replacement } = | ||
'pattern' in opts | ||
? opts | ||
: { pattern: 'mockChainStorageRoot.', replacement: 'published.' }; | ||
const pruned = [...keys] | ||
.sort() | ||
.filter( | ||
'node' in opts | ||
? key => | ||
key | ||
.replace(pattern, replacement) | ||
.startsWith(`published.${opts.node}`) | ||
: _entry => true, | ||
); | ||
const illustration = pruned.map( | ||
/** @type {(k: string) => [string, unknown]} */ | ||
key => [key.replace(pattern, replacement), getBody(key)], | ||
); | ||
const note = | ||
'note' in opts | ||
? opts.note | ||
: `Under "published", the "${opts.node}" node is delegated to ${opts.owner}.`; | ||
const boilerplate = ` | ||
The example below illustrates the schema of the data published there. | ||
See also board marshalling conventions (_to appear_).`; | ||
t.snapshot(illustration, note + boilerplate); | ||
}; |
export function eventLoopIteration(): Promise<any>; | ||
export function inspectMapStore(store: MapStore): object; | ||
import type { MapStore } from '@agoric/store'; | ||
//# sourceMappingURL=testing-utils.d.ts.map |
@@ -1,3 +0,8 @@ | ||
/** @file note this cannot be called test-utils.js due to https://github.com/Agoric/agoric-sdk/issues/7503 */ | ||
// @ts-check | ||
/** | ||
* @file note this cannot be called test-utils.js due to | ||
* https://github.com/Agoric/agoric-sdk/issues/7503 | ||
*/ | ||
/* global setImmediate */ | ||
/** @import {MapStore} from '@agoric/store'; */ | ||
@@ -7,6 +12,5 @@ /** | ||
* | ||
* Lines of test code can depend on async promises outside the test | ||
* resolving before they run. Awaiting this function result ensures | ||
* that all promises that can do resolve. | ||
* Note that this doesn't mean all outstanding promises. | ||
* Lines of test code can depend on async promises outside the test resolving | ||
* before they run. Awaiting this function result ensures that all promises that | ||
* can do resolve. Note that this doesn't mean all outstanding promises. | ||
*/ | ||
@@ -16,1 +20,36 @@ export const eventLoopIteration = async () => | ||
harden(eventLoopIteration); | ||
/** @type {(value: any) => string} */ | ||
const stringOrTag = value => { | ||
if (typeof value === 'string') { | ||
return value; | ||
} else if (typeof value === 'object' && Symbol.toStringTag in value) { | ||
return value[Symbol.toStringTag]; | ||
} | ||
return String(value); | ||
}; | ||
/** | ||
* @param {MapStore} store | ||
* @returns {object} tree of the contents of the store | ||
*/ | ||
export const inspectMapStore = store => { | ||
/** @type {Record<string, unknown>} */ | ||
const obj = {}; | ||
for (const key of store.keys()) { | ||
const value = store.get(key); | ||
const hasKeys = typeof value === 'object' && 'keys' in value; | ||
const index = stringOrTag(key); | ||
if (hasKeys && 'get' in value) { | ||
obj[index] = inspectMapStore(value); | ||
} else if (hasKeys) { | ||
obj[index] = Array.from(value.keys()); | ||
} else { | ||
obj[index] = | ||
value instanceof Object && Symbol.toStringTag in value | ||
? value[Symbol.toStringTag] | ||
: value; | ||
} | ||
} | ||
return obj; | ||
}; | ||
harden(inspectMapStore); |
@@ -26,3 +26,3 @@ export namespace Stable { | ||
} | ||
export type TokenKeyword = 'IST' | 'BLD'; | ||
export type TokenKeyword = "IST" | "BLD"; | ||
/** @typedef {'IST' | 'BLD'} TokenKeyword */ | ||
@@ -29,0 +29,0 @@ /** |
export const StorageNodeShape: import("@endo/patterns").Matcher; | ||
/** To be used only for 'helper' facets where the calls are from trusted code. */ | ||
export const UnguardedHelperI: import("@endo/patterns").InterfaceGuard<any>; | ||
/** | ||
* @typedef {number | `${bigint}`} BridgeBigInt Ensure that callees passed a | ||
* bridge message that was serialised from a Golang int64 or uint64 accept | ||
* either a JS number or a stringified JS bigint. | ||
*/ | ||
/** | ||
* @type {import('./types.js').TypedPattern<BridgeBigInt>} | ||
*/ | ||
export const BridgeBigIntShape: import("./types.js").TypedPattern<BridgeBigInt>; | ||
/** | ||
* Ensure that callees passed a | ||
* bridge message that was serialised from a Golang int64 or uint64 accept | ||
* either a JS number or a stringified JS bigint. | ||
*/ | ||
export type BridgeBigInt = number | `${bigint}`; | ||
//# sourceMappingURL=typeGuards.d.ts.map |
// @jessie-check | ||
// @ts-check | ||
@@ -14,1 +15,12 @@ import { M } from '@endo/patterns'; | ||
); | ||
/** | ||
* @typedef {number | `${bigint}`} BridgeBigInt Ensure that callees passed a | ||
* bridge message that was serialised from a Golang int64 or uint64 accept | ||
* either a JS number or a stringified JS bigint. | ||
*/ | ||
/** | ||
* @type {import('./types.js').TypedPattern<BridgeBigInt>} | ||
*/ | ||
export const BridgeBigIntShape = M.or(M.number(), M.string()); |
@@ -1,20 +0,73 @@ | ||
/* eslint-disable max-classes-per-file */ | ||
export declare class Callback<I extends (...args: unknown[]) => any> { | ||
private iface: I; | ||
public target: any; | ||
public methodName?: PropertyKey; | ||
public bound: unknown[]; | ||
public isSync: boolean; | ||
import type { ERef, RemotableBrand } from '@endo/eventual-send'; | ||
import type { Primitive } from '@endo/pass-style'; | ||
import type { Pattern } from '@endo/patterns'; | ||
import type { Callable } from './ses-utils.js'; | ||
/** | ||
* A map corresponding with a total function such that `get(key)` is assumed to | ||
* always succeed. | ||
*/ | ||
export type TotalMap<K, V> = Omit<Map<K, V>, 'get'> & { | ||
/** Returns the element associated with the specified key in the TotalMap. */ | ||
get: (key: K) => V; | ||
}; | ||
export type TotalMapFrom<M extends Map<any, any>> = M extends Map<infer K, infer V> ? TotalMap<K, V> : never; | ||
export declare class Callback<I extends (...args: any[]) => any> { | ||
private iface; | ||
target: any; | ||
methodName?: PropertyKey; | ||
bound: unknown[]; | ||
isSync: boolean; | ||
} | ||
export declare class SyncCallback< | ||
I extends (...args: unknown[]) => any, | ||
> extends Callback<I> { | ||
private syncIface: I; | ||
public isSync: true; | ||
export declare class SyncCallback<I extends (...args: unknown[]) => any> extends Callback<I> { | ||
private syncIface; | ||
isSync: true; | ||
} | ||
/** | ||
Returns a boolean for whether the given type is primitive value or primitive type. | ||
@example | ||
``` | ||
IsPrimitive<'string'> | ||
//=> true | ||
IsPrimitive<string> | ||
//=> true | ||
IsPrimitive<Object> | ||
//=> false | ||
``` | ||
*/ | ||
export type IsPrimitive<T> = [T] extends [Primitive] ? true : false; | ||
/** Recursively extract the non-callable properties of T */ | ||
export type DataOnly<T> = IsPrimitive<T> extends true ? T : T extends Callable ? never : { | ||
[P in keyof T as T[P] extends Callable ? never : P]: DataOnly<T[P]>; | ||
}; | ||
/** | ||
* A type that doesn't assume its parameter is local, but is satisfied with both | ||
* local and remote references. It accepts both near and marshalled references | ||
* that were returned from `Remotable` or `Far`. | ||
*/ | ||
export type Remote<Primary, Local = DataOnly<Primary>> = Primary | RemotableBrand<Local, Primary>; | ||
/** | ||
* Potentially remote promises or settled references. | ||
*/ | ||
export type FarRef<Primary, Local = DataOnly<Primary>> = ERef<Remote<Primary, Local>>; | ||
declare const validatedType: unique symbol; | ||
/** | ||
* Tag a pattern with the static type it represents. | ||
*/ | ||
export type TypedPattern<T> = Pattern & { | ||
[validatedType]?: T; | ||
}; | ||
export declare type PatternType<TM extends TypedPattern<any>> = TM extends TypedPattern<infer T> ? T : never; | ||
/** | ||
* Returning normally indicates success. Match failure is indicated by | ||
* throwing. | ||
* | ||
* Note: remotables can only be matched as "remotable", not the specific kind. | ||
* | ||
* @see {import('@endo/patterns').mustMatch} for the implementation. This one has a type annotation to narrow if the pattern is a TypedPattern. | ||
*/ | ||
export declare type MustMatch = <P extends Pattern>(specimen: unknown, pattern: P, label?: string | number) => asserts specimen is P extends TypedPattern<any> ? PatternType<P> : unknown; | ||
export {}; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -8,8 +8,9 @@ export namespace UpgradeDisconnectionShape { | ||
export function isUpgradeDisconnection(reason: any): reason is UpgradeDisconnection; | ||
export function isAbandonedError(reason: any): reason is Error; | ||
/** | ||
* An Error-like object for use as the rejection reason of promises | ||
* abandoned by upgrade. | ||
* An Error-like object for use as the rejection reason of promises abandoned by | ||
* upgrade. | ||
*/ | ||
export type UpgradeDisconnection = { | ||
name: 'vatUpgraded'; | ||
name: "vatUpgraded"; | ||
upgradeMessage: string; | ||
@@ -16,0 +17,0 @@ incarnationNumber: number; |
@@ -9,9 +9,9 @@ // @ts-check | ||
/** | ||
* An Error-like object for use as the rejection reason of promises | ||
* abandoned by upgrade. | ||
* An Error-like object for use as the rejection reason of promises abandoned by | ||
* upgrade. | ||
* | ||
* @typedef {{ | ||
* name: 'vatUpgraded', | ||
* upgradeMessage: string, | ||
* incarnationNumber: number | ||
* name: 'vatUpgraded'; | ||
* upgradeMessage: string; | ||
* incarnationNumber: number; | ||
* }} UpgradeDisconnection | ||
@@ -43,9 +43,33 @@ */ | ||
/** | ||
* @param {any} reason | ||
* If `reason` is not frozen, it cannot be an UpgradeDisconnection, | ||
* so returns false without even checking against the shape. | ||
* @param {any} reason If `reason` is not frozen, it cannot be an | ||
* UpgradeDisconnection, so returns false without even checking against the | ||
* shape. | ||
* @returns {reason is UpgradeDisconnection} | ||
*/ | ||
export const isUpgradeDisconnection = reason => | ||
isFrozen(reason) && matches(reason, UpgradeDisconnectionShape); | ||
reason != null && // eslint-disable-line eqeqeq | ||
isFrozen(reason) && | ||
matches(reason, UpgradeDisconnectionShape); | ||
harden(isUpgradeDisconnection); | ||
/** | ||
* Returns whether a reason is a 'vat terminated' error generated when an object | ||
* is abandoned by a vat during an upgrade. | ||
* | ||
* Normally we do not want to rely on the `message` of an error object, but this | ||
* is a pragmatic solution to the current state of vat upgrade errors. In the | ||
* future we'd prefer having an error with a cause referencing a disconnection | ||
* object like for promise rejections. See | ||
* https://github.com/Agoric/agoric-sdk/issues/9582 | ||
* | ||
* @param {any} reason | ||
* @returns {reason is Error} | ||
*/ | ||
export const isAbandonedError = reason => | ||
reason != null && // eslint-disable-line eqeqeq | ||
isFrozen(reason) && | ||
matches(reason, M.error()) && | ||
// We're not using a constant here since this special value is already | ||
// sprinkled throughout the SDK | ||
reason.message === 'vat terminated'; | ||
harden(isAbandonedError); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
177336
118
4060
12
5
+ Added@endo/errors@^1.2.9
+ Added@endo/pass-style@^1.4.8
Updated@endo/common@^1.2.9
Updated@endo/far@^1.1.10
Updated@endo/init@^1.1.8
Updated@endo/marshal@^1.6.3
Updated@endo/patterns@^1.4.8
Updated@endo/promise-kit@^1.1.9
Updated@endo/stream@^1.2.9
Updatedjessie.js@^0.3.4