@agoric/internal
Advanced tools
Comparing version 0.3.3-dev-1ac26b7.0 to 0.3.3-dev-1af1596.0
{ | ||
"name": "@agoric/internal", | ||
"version": "0.3.3-dev-1ac26b7.0+1ac26b7", | ||
"version": "0.3.3-dev-1af1596.0+1af1596", | ||
"description": "Externally unsupported utilities internal to agoric-sdk", | ||
@@ -23,12 +23,12 @@ "type": "module", | ||
"dependencies": { | ||
"@agoric/base-zone": "0.1.1-dev-1ac26b7.0+1ac26b7", | ||
"@endo/common": "^1.2.6", | ||
"@endo/errors": "^1.2.6", | ||
"@endo/far": "^1.1.6", | ||
"@endo/init": "^1.1.5", | ||
"@endo/marshal": "^1.5.4", | ||
"@endo/pass-style": "^1.4.4", | ||
"@endo/patterns": "^1.4.4", | ||
"@endo/promise-kit": "^1.1.6", | ||
"@endo/stream": "^1.2.6", | ||
"@agoric/base-zone": "0.1.1-dev-1af1596.0+1af1596", | ||
"@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", | ||
@@ -38,4 +38,5 @@ "jessie.js": "^0.3.4" | ||
"devDependencies": { | ||
"@endo/exo": "^1.5.4", | ||
"@endo/init": "^1.1.5", | ||
"@agoric/cosmic-proto": "0.4.1-dev-1af1596.0+1af1596", | ||
"@endo/exo": "^1.5.8", | ||
"@endo/init": "^1.1.8", | ||
"ava": "^5.3.0", | ||
@@ -62,5 +63,5 @@ "tsd": "^0.31.1" | ||
"typeCoverage": { | ||
"atLeast": 93.42 | ||
"atLeast": 93.04 | ||
}, | ||
"gitHead": "1ac26b7835bb832d23a967e057c15d0d358d3a5d" | ||
"gitHead": "1af1596ffa4d14c089c231825fbe5729be4b3ce3" | ||
} |
@@ -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,4 +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'; | ||
export const VTRANSFER_IBC_EVENT = 'VTRANSFER_IBC_EVENT'; | ||
/** | ||
* 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; |
@@ -18,3 +18,3 @@ export function callSync<I extends (...args: any[]) => any>(callback: SyncCallback<I>, ...args: Parameters<I>): ReturnType<I>; | ||
tag?: string | undefined; | ||
} | undefined): MakeAttenuator<any>; | ||
}): 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 }?: { | ||
@@ -21,0 +21,0 @@ interfaceGuard?: import("@endo/patterns").InterfaceGuard<{ [K in M]: import("@endo/patterns").MethodGuard; }> | undefined; |
@@ -1,2 +0,2 @@ | ||
export function NonNullish<T>(val: T | null | undefined, optDetails?: string | undefined): T; | ||
export function NonNullish<T>(val: T | null | undefined, optDetails?: string): T; | ||
//# sourceMappingURL=errors.d.ts.map |
export * from "./config.js"; | ||
export * from "./debug.js"; | ||
export * from "./errors.js"; | ||
export * from "./utils.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"; | ||
@@ -10,0 +12,0 @@ export { objectMetaMap } from "@endo/common/object-meta-map.js"; |
@@ -8,4 +8,6 @@ // @jessie-check | ||
export * from './errors.js'; | ||
export * from './utils.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'; | ||
@@ -12,0 +14,0 @@ export * from './typeGuards.js'; |
@@ -16,19 +16,8 @@ /** | ||
sequence?: boolean | undefined; | ||
} | undefined): import("@endo/exo").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; | ||
}): StorageNode; | ||
/** @type {(value: string) => Promise<void>} */ | ||
setValue(value: string): Promise<void>; | ||
@@ -54,17 +43,6 @@ }>; | ||
getPath(): string; | ||
/** | ||
* @deprecated use getPath | ||
* @type {() => Promise<VStorageKey>} | ||
*/ | ||
getStoreKey(): Promise<VStorageKey>; | ||
/** | ||
* @type {( | ||
* name: string, | ||
* childNodeOptions?: { sequence?: boolean }, | ||
* ) => StorageNode} | ||
*/ | ||
makeChildNode(name: string, childNodeOptions?: { | ||
sequence?: boolean; | ||
}): StorageNode; | ||
/** @type {(value: string) => Promise<void>} */ | ||
setValue(value: string): Promise<void>; | ||
@@ -71,0 +49,0 @@ }>; |
export default engineGC; | ||
declare const engineGC: () => void; | ||
declare const engineGC: GCFunction; | ||
//# sourceMappingURL=engine-gc.d.ts.map |
@@ -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 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) | undefined): { | ||
export function makeHistoryReviver(entries: [string, string][], slotToVal?: (slot: string, iface?: string) => any): { | ||
getItem: (key: string) => any; | ||
@@ -14,2 +14,8 @@ 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>>; | ||
}; | ||
/** | ||
@@ -16,0 +22,0 @@ * Should be a union with Remotable, but that's `any`, making this type |
@@ -138,1 +138,8 @@ // @ts-check | ||
}; | ||
/** @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); |
@@ -14,3 +14,3 @@ /** | ||
*/ | ||
export function decode(data: Buffer, optMaxChunkSize?: number | undefined): { | ||
export function decode(data: Buffer, optMaxChunkSize?: number): { | ||
leftover: Buffer; | ||
@@ -23,4 +23,4 @@ payloads: Buffer[]; | ||
*/ | ||
export function netstringDecoderStream(optMaxChunkSize?: number | undefined): Transform; | ||
export function netstringDecoderStream(optMaxChunkSize?: number): Transform; | ||
import { Transform } from 'stream'; | ||
//# sourceMappingURL=netstring.d.ts.map |
@@ -92,2 +92,3 @@ /* eslint-env node */ | ||
export function netstringDecoderStream(optMaxChunkSize) { | ||
/** @type {Buffer<ArrayBufferLike>} */ | ||
let buffered = Buffer.from(''); | ||
@@ -94,0 +95,0 @@ /** |
@@ -16,4 +16,4 @@ /** | ||
*/ | ||
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; | ||
@@ -38,3 +38,3 @@ _breakLength: number; | ||
*/ | ||
break?: string | number | Buffer | undefined; | ||
break?: string | number | Buffer<ArrayBufferLike> | undefined; | ||
/** | ||
@@ -41,0 +41,0 @@ * if break is a string, the encoding |
@@ -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'; | ||
/** | ||
* @param {import('fs').ReadStream | import('fs').WriteStream} stream | ||
* @param {import('fs').ReadStream | ||
* | import('fs').WriteStream | ||
* | import('net').Socket} stream | ||
* @returns {Promise<void>} | ||
@@ -21,3 +24,3 @@ */ | ||
const onReady = () => { | ||
cleanup(); // eslint-disable-line no-use-before-define | ||
cleanup(); | ||
resolve(); | ||
@@ -28,3 +31,3 @@ }; | ||
const onError = err => { | ||
cleanup(); // eslint-disable-line no-use-before-define | ||
cleanup(); | ||
reject(err); | ||
@@ -53,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); | ||
@@ -62,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 => AggregateError([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; | ||
@@ -93,3 +102,3 @@ }; | ||
await flushed; | ||
await handle.sync().catch(err => { | ||
await handle?.sync().catch(err => { | ||
if (err.code === 'EINVAL') { | ||
@@ -103,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...`); |
@@ -31,2 +31,3 @@ /** @type {(namespace: string) => string} */ | ||
export type PrioritySendersManager = ReturnType<typeof makePrioritySendersManager>; | ||
import type { ERef } from '@endo/far'; | ||
//# sourceMappingURL=priority-senders.d.ts.map |
import { Fail, q } from '@endo/errors'; | ||
import { E, Far } from '@endo/far'; | ||
/** @import {ERef} from '@endo/far'; */ | ||
/** @import {StorageNode} from './lib-chainStorage.js'; */ | ||
const PRIORITY_SENDERS_NAMESPACE_RE = /^[a-zA-Z0-9_-]{1,50}$/; | ||
@@ -5,0 +8,0 @@ |
@@ -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 |
@@ -12,2 +12,6 @@ export function slotToRemotable(_slotId: string, iface?: string): import("@endo/pass-style").RemotableObject<string> & import("@endo/eventual-send").RemotableBrand<{}, {}>; | ||
}; | ||
export namespace defaultSerializer { | ||
let parse: (text: string) => unknown; | ||
let stringify: (obj: any) => string; | ||
} | ||
export const slotStringUnserialize: (capData: any) => any; | ||
@@ -24,10 +28,12 @@ export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<typeof makeChainStorageRoot>[2]): { | ||
data: Map<string, string>; | ||
updateNewCellBlockHeight: (blockHeight?: number) => void; | ||
getValues: (path: string) => string[]; | ||
messages: StorageMessage[]; | ||
toStorage: ((message: StorageMessage) => string | number | any[] | { | ||
toStorage: ((message: StorageMessage) => string | number | true | any[] | { | ||
storeName: string; | ||
storeSubkey: string; | ||
} | null | undefined) & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (message: StorageMessage) => string | number | any[] | { | ||
} | null) & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (message: StorageMessage) => string | number | true | any[] | { | ||
storeName: string; | ||
storeSubkey: string; | ||
} | null | undefined>; | ||
} | null>; | ||
}; | ||
@@ -43,3 +49,5 @@ export function makeMockChainStorageRoot(): MockChainStorageRoot; | ||
replacement: string; | ||
} | {})): Promise<void>; | ||
} | {}) & { | ||
showValue?: (v: string) => unknown; | ||
}): Promise<void>; | ||
export type FakeStorageKit = ReturnType<typeof makeFakeStorageKit>; | ||
@@ -46,0 +54,0 @@ export type MockChainStorageRootMethods = { |
@@ -5,5 +5,6 @@ // @ts-check | ||
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'; | ||
@@ -14,3 +15,3 @@ import { eventLoopIteration } from './testing-utils.js'; | ||
* @import {TotalMap} from './types.js'; | ||
* @import {Marshaller, StorageEntry, StorageMessage, StorageNode} from './lib-chainStorage.js'; | ||
* @import {Marshaller, StorageEntry, StorageMessage, StorageNode, StreamCell} from './lib-chainStorage.js'; | ||
*/ | ||
@@ -39,2 +40,12 @@ | ||
/** | ||
* 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 = | ||
@@ -95,2 +106,10 @@ * Far('iface')`, and serializing `{ a }` into `capData` assigned it slot | ||
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 */ | ||
@@ -154,3 +173,3 @@ const getChildEntries = prefix => { | ||
} | ||
break; | ||
return true; | ||
} | ||
@@ -163,4 +182,6 @@ case 'append': { | ||
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); | ||
/** @type {string | undefined} */ | ||
let oldVal = data.get(key); | ||
/** @type {StreamCell | undefined} */ | ||
let streamCell; | ||
@@ -174,6 +195,15 @@ if (oldVal != null) { | ||
} | ||
// StreamCells reset at block boundaries. | ||
if ( | ||
streamCell && | ||
Number(streamCell.blockHeight) !== currentBlockHeight | ||
) { | ||
streamCell = undefined; | ||
oldVal = undefined; | ||
} | ||
} | ||
if (streamCell === undefined) { | ||
streamCell = { | ||
blockHeight: '0', | ||
blockHeight: String(currentBlockHeight), | ||
values: oldVal != null ? [oldVal] : [], | ||
@@ -185,3 +215,3 @@ }; | ||
} | ||
break; | ||
return true; | ||
} | ||
@@ -200,2 +230,17 @@ case 'size': | ||
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; | ||
}; | ||
return { | ||
@@ -205,2 +250,4 @@ rootNode, | ||
data: /** @type {Map<string, string>} */ (data), | ||
updateNewCellBlockHeight, | ||
getValues, | ||
messages, | ||
@@ -263,3 +310,5 @@ toStorage, | ||
* @param {({ note: string } | { node: string; owner: string }) & | ||
* ({ pattern: string; replacement: string } | {})} opts | ||
* ({ pattern: string; replacement: string } | {}) & { | ||
* showValue?: (v: string) => unknown; | ||
* }} opts | ||
*/ | ||
@@ -270,6 +319,15 @@ export const documentStorageSchema = async (t, storage, opts) => { | ||
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) => storage.data.get(k)]; | ||
: [ | ||
storage.data.keys(), | ||
(/** @type {string} */ k) => getBodyDefault(storage.data, k), | ||
]; | ||
@@ -280,11 +338,18 @@ const { pattern, replacement } = | ||
: { pattern: 'mockChainStorageRoot.', replacement: 'published.' }; | ||
const illustration = [...keys].sort().map( | ||
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 pruned = illustration.filter( | ||
'node' in opts | ||
? ([key, _]) => key.startsWith(`published.${opts.node}`) | ||
: _entry => true, | ||
); | ||
@@ -299,3 +364,3 @@ const note = | ||
See also board marshalling conventions (_to appear_).`; | ||
t.snapshot(pruned, note + boilerplate); | ||
t.snapshot(illustration, note + boilerplate); | ||
}; |
@@ -1,3 +0,6 @@ | ||
/** @file adapted from https://raw.githubusercontent.com/sindresorhus/type-fest/main/source/opaque.d.ts */ | ||
/** @file adapted from https://raw.githubusercontent.com/sindresorhus/type-fest/main/source/tagged.d.ts */ | ||
// different name to avoid confusion with pass-style "tagged" | ||
export { Tagged as TypeTag }; | ||
declare const tag: unique symbol; | ||
@@ -4,0 +7,0 @@ |
@@ -31,3 +31,3 @@ // @ts-check | ||
* @param {MapStore} store | ||
* @returns {object} tree of the contents of the store | ||
* @returns {object} tree of the contents of the store | ||
*/ | ||
@@ -34,0 +34,0 @@ export const inspectMapStore = store => { |
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()); |
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 './utils.js'; | ||
import type { Callable } from './ses-utils.js'; | ||
/** | ||
@@ -6,0 +6,0 @@ * A map corresponding with a total function such that `get(key)` is assumed to |
@@ -5,3 +5,3 @@ /* eslint-disable max-classes-per-file */ | ||
import type { Pattern } from '@endo/patterns'; | ||
import type { Callable } from './utils.js'; | ||
import type { Callable } from './ses-utils.js'; | ||
@@ -8,0 +8,0 @@ /** |
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
5
Updated@endo/common@^1.2.9
Updated@endo/errors@^1.2.9
Updated@endo/far@^1.1.10
Updated@endo/init@^1.1.8
Updated@endo/marshal@^1.6.3
Updated@endo/pass-style@^1.4.8
Updated@endo/patterns@^1.4.8
Updated@endo/promise-kit@^1.1.9
Updated@endo/stream@^1.2.9