@agoric/internal
Advanced tools
Comparing version 0.3.3-dev-cab101e.0 to 0.3.3-dev-cb12196.0
{ | ||
"name": "@agoric/internal", | ||
"version": "0.3.3-dev-cab101e.0+cab101e", | ||
"version": "0.3.3-dev-cb12196.0+cb12196", | ||
"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,12 +24,12 @@ "test:nyc": "exit 0", | ||
"dependencies": { | ||
"@agoric/assert": "0.6.1-dev-cab101e.0+cab101e", | ||
"@agoric/base-zone": "0.1.1-dev-cab101e.0+cab101e", | ||
"@endo/common": "^1.2.2", | ||
"@endo/far": "^1.1.2", | ||
"@endo/init": "^1.1.2", | ||
"@endo/marshal": "^1.5.0", | ||
"@endo/pass-style": "^1.4.0", | ||
"@endo/patterns": "^1.4.0", | ||
"@endo/promise-kit": "^1.1.2", | ||
"@endo/stream": "^1.2.2", | ||
"@agoric/base-zone": "0.1.1-dev-cb12196.0+cb12196", | ||
"@endo/common": "^1.2.8", | ||
"@endo/errors": "^1.2.8", | ||
"@endo/far": "^1.1.9", | ||
"@endo/init": "^1.1.7", | ||
"@endo/marshal": "^1.6.2", | ||
"@endo/pass-style": "^1.4.7", | ||
"@endo/patterns": "^1.4.7", | ||
"@endo/promise-kit": "^1.1.8", | ||
"@endo/stream": "^1.2.8", | ||
"anylogger": "^0.21.0", | ||
@@ -39,5 +39,7 @@ "jessie.js": "^0.3.4" | ||
"devDependencies": { | ||
"@endo/init": "^1.1.2", | ||
"@agoric/cosmic-proto": "0.4.1-dev-cb12196.0+cb12196", | ||
"@endo/exo": "^1.5.7", | ||
"@endo/init": "^1.1.7", | ||
"ava": "^5.3.0", | ||
"tsd": "^0.30.7" | ||
"tsd": "^0.31.1" | ||
}, | ||
@@ -62,5 +64,5 @@ "ava": { | ||
"typeCoverage": { | ||
"atLeast": 93.89 | ||
"atLeast": 93.06 | ||
}, | ||
"gitHead": "cab101ec0aa316d6407687088e5f088e972da5e2" | ||
"gitHead": "cb12196e58c3809ce7d997fa29399c4bf0e4393b" | ||
} |
@@ -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,54 @@ | ||
/** | ||
* 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"; | ||
} | ||
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 +58,5 @@ export const VBANK_BALANCE_UPDATE: "VBANK_BALANCE_UPDATE"; | ||
export const WALLET_SPEND_ACTION: "WALLET_SPEND_ACTION"; | ||
export const INSTALL_BUNDLE: "INSTALL_BUNDLE"; | ||
export const CALCULATE_FEES_IN_BEANS: "CALCULATE_FEES_IN_BEANS"; | ||
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'; | ||
/** | ||
* 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', | ||
}); | ||
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, | ||
} = QueuedActionType; | ||
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'; | ||
export const KERNEL_UPGRADE_EVENTS = 'KERNEL_UPGRADE_EVENTS'; |
@@ -1,7 +0,7 @@ | ||
export function callSync<I extends (...args: unknown[]) => any>(callback: SyncCallback<I>, ...args: Parameters<I>): ReturnType<I>; | ||
export function callE<I extends (...args: unknown[]) => any>(callback: 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): SyncCallback<I>; | ||
export function makeFunctionCallback<I extends (...args: unknown[]) => any, T extends ERef<(...args: [...B, ...Parameters<I>]) => ReturnType<I>> = ERef<I>, B extends unknown[] = []>(target: T, ...bound: B): 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 in P]: I; }, B extends unknown[] = []>(target: T, methodName: P, ...bound: B): SyncCallback<I>; | ||
export function makeMethodCallback<I extends (...args: unknown[]) => any, P extends PropertyKey, T extends ERef<{ [x in P]: (...args: [...B, ...Parameters<I>]) => ReturnType<I>; }> = ERef<{ [x in P]: I; }>, B extends unknown[] = []>(target: T, methodName: P, ...bound: B): Callback<I>; | ||
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>; | ||
@@ -15,6 +15,6 @@ export function prepareAttenuator<M extends PropertyKey>(zone: import("@agoric/base-zone").Zone, methodNames: M[], { interfaceGuard, tag }?: { | ||
overrides?: { [K_1 in M]?: Callback<any> | null | undefined; } | undefined; | ||
}) => import("@endo/exo").Guarded<{ [K_2 in M]: (this: any, ...args: unknown[]) => any; }>; | ||
}) => 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>; | ||
}): 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 }?: { | ||
@@ -27,3 +27,3 @@ interfaceGuard?: import("@endo/patterns").InterfaceGuard<{ [K in M]: import("@endo/patterns").MethodGuard; }> | undefined; | ||
overrides?: { [K_1 in M]?: Callback<any> | null | undefined; } | undefined; | ||
}) => import("@endo/exo").Guarded<{ [K_2 in M]: (this: any, ...args: unknown[]) => any; }>)>>) => import("@endo/exo").Farable<T>; | ||
}) => import("@endo/exo").Guarded<{ [K_2 in M]: (this: any, ...args: any[]) => any; }>)>>) => import("@endo/exo").Farable<T>; | ||
import type { SyncCallback } from './types.js'; | ||
@@ -30,0 +30,0 @@ import type { Callback } from './types.js'; |
// @ts-check | ||
import { Fail, makeError, q } from '@endo/errors'; | ||
import { E } from '@endo/far'; | ||
@@ -9,4 +10,2 @@ import { isObject, isPassableSymbol } from '@endo/marshal'; | ||
const { Fail, quote: q } = assert; | ||
const { fromEntries } = Object; | ||
@@ -46,3 +45,3 @@ | ||
* | ||
* @template {(...args: unknown[]) => any} I | ||
* @template {(...args: any[]) => any} I | ||
* @param {SyncCallback<I>} callback | ||
@@ -64,3 +63,3 @@ * @param {Parameters<I>} args | ||
* | ||
* @template {(...args: unknown[]) => any} I | ||
* @template {(...args: any[]) => any} I | ||
* @param {Callback<I>} callback | ||
@@ -82,5 +81,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 | ||
@@ -102,5 +101,5 @@ * @param {B} bound | ||
* | ||
* @template {(...args: unknown[]) => any} I | ||
* @template {(...args: any[]) => any} I | ||
* @template {ERef<(...args: [...B, ...Parameters<I>]) => ReturnType<I>>} [T=ERef<I>] | ||
* @template {unknown[]} [B=[]] | ||
* @template {any[]} [B=[]] | ||
* @param {T} target | ||
@@ -122,3 +121,3 @@ * @param {B} bound | ||
* | ||
* @template {(...args: unknown[]) => any} I | ||
* @template {(...args: any[]) => any} I | ||
* @template {PropertyKey} P | ||
@@ -128,3 +127,3 @@ * @template {{ | ||
* }} [T={ [x in P]: I }] | ||
* @template {unknown[]} [B=[]] | ||
* @template {any[]} [B=[]] | ||
* @param {T} target | ||
@@ -150,3 +149,3 @@ * @param {P} methodName | ||
* | ||
* @template {(...args: unknown[]) => any} I | ||
* @template {(...args: any[]) => any} I | ||
* @template {PropertyKey} P | ||
@@ -156,3 +155,3 @@ * @template {ERef<{ | ||
* }>} [T=ERef<{ [x in P]: I }>] | ||
* @template {unknown[]} [B=[]] | ||
* @template {any[]} [B=[]] | ||
* @param {T} target | ||
@@ -213,7 +212,7 @@ * @param {P} methodName | ||
/** | ||
* @typedef {(this: any, ...args: unknown[]) => any} Method | ||
* @typedef {(this: any, ...args: any[]) => any} Method | ||
* | ||
* @typedef {{ [K in M]?: Callback<any> | null }} Overrides | ||
* | ||
* @typedef {{ [K in M]: (this: any, ...args: unknown[]) => any }} Methods | ||
* @typedef {{ [K in M]: (this: any, ...args: any[]) => any }} Methods | ||
*/ | ||
@@ -236,5 +235,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) { | ||
@@ -241,0 +238,0 @@ throw err; |
@@ -0,1 +1,5 @@ | ||
/** | ||
* Event source ids used by the bridge device. | ||
*/ | ||
export type BridgeId = (typeof BridgeId)[keyof typeof BridgeId]; | ||
export namespace BridgeId { | ||
@@ -12,4 +16,2 @@ let BANK: "bank"; | ||
} | ||
/** @typedef {(typeof BridgeId)[keyof typeof BridgeId]} BridgeIdValue */ | ||
export const VTRANSFER_IBC_EVENT: "VTRANSFER_IBC_EVENT"; | ||
export namespace CosmosInitKeyToBridgeId { | ||
@@ -36,3 +38,2 @@ import vbankPort = BANK; | ||
} | ||
export type BridgeIdValue = (typeof BridgeId)[keyof typeof BridgeId]; | ||
//# sourceMappingURL=config.d.ts.map |
@@ -18,2 +18,4 @@ // @ts-check | ||
* Event source ids used by the bridge device. | ||
* | ||
* @enum {(typeof BridgeId)[keyof typeof BridgeId]} | ||
*/ | ||
@@ -32,6 +34,3 @@ export const BridgeId = /** @type {const} */ ({ | ||
harden(BridgeId); | ||
/** @typedef {(typeof BridgeId)[keyof typeof BridgeId]} BridgeIdValue */ | ||
export const VTRANSFER_IBC_EVENT = 'VTRANSFER_IBC_EVENT'; | ||
export const CosmosInitKeyToBridgeId = { | ||
@@ -38,0 +37,0 @@ vbankPort: BridgeId.BANK, |
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.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 |
@@ -7,10 +7,15 @@ // @jessie-check | ||
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.js'; | ||
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'; |
@@ -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 @@ }>; |
// @ts-check | ||
import { E } from '@endo/far'; | ||
import { Fail } from '@endo/errors'; | ||
import { E, Far } from '@endo/far'; | ||
import { M } from '@endo/patterns'; | ||
@@ -13,4 +14,2 @@ import { makeHeapZone } from '@agoric/base-zone/heap.js'; | ||
const { Fail } = assert; | ||
/** @typedef {ReturnType<typeof import('@endo/marshal').makeMarshal>} Marshaller */ | ||
@@ -283,3 +282,6 @@ /** @typedef {Pick<Marshaller, 'fromCapData'>} Unserializer */ | ||
// XXX re-use "ChainStorage" methods above which don't actually depend on chains | ||
return makeChainStorageRoot(() => null, 'null'); | ||
return makeChainStorageRoot( | ||
Far('NullMessenger', () => null), | ||
'null', | ||
); | ||
}; | ||
@@ -286,0 +288,0 @@ |
export default engineGC; | ||
declare const engineGC: () => void; | ||
declare const engineGC: GCFunction; | ||
//# sourceMappingURL=engine-gc.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'; | ||
@@ -6,0 +6,0 @@ import { |
@@ -1,2 +0,2 @@ | ||
/* global Buffer */ | ||
/* eslint-env node */ | ||
import { Transform } from 'stream'; | ||
@@ -3,0 +3,0 @@ |
@@ -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 |
// @ts-check | ||
import { Fail } from '@endo/errors'; | ||
import { Far } from '@endo/far'; | ||
@@ -6,4 +7,2 @@ import { makeMarshal } from '@endo/marshal'; | ||
const { Fail } = assert; | ||
/** | ||
@@ -140,1 +139,8 @@ * Should be a union with Remotable, but that's `any`, making this type | ||
}; | ||
/** @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 |
@@ -1,3 +0,3 @@ | ||
/* global Buffer */ | ||
import { Fail } from '@agoric/assert'; | ||
/* eslint-env node */ | ||
import { Fail } from '@endo/errors'; | ||
@@ -92,2 +92,3 @@ // adapted from 'netstring-stream', https://github.com/tlivings/netstring-stream/ | ||
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 @@ | ||
/* global Buffer */ | ||
/* eslint-env node */ | ||
/* eslint-disable no-underscore-dangle */ | ||
@@ -3,0 +3,0 @@ |
@@ -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'; | ||
/** | ||
* @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...`); |
@@ -0,5 +1,4 @@ | ||
import { Fail, q } from '@endo/errors'; | ||
import { E, Far } from '@endo/far'; | ||
const { Fail, quote: q } = assert; | ||
const PRIORITY_SENDERS_NAMESPACE_RE = /^[a-zA-Z0-9_-]{1,50}$/; | ||
@@ -6,0 +5,0 @@ |
@@ -1,2 +0,2 @@ | ||
export function slotToRemotable(_slotId: string, iface?: string): import("@endo/marshal").RemotableObject<string> & import("@endo/eventual-send").RemotableBrand<{}, {}>; | ||
export function slotToRemotable(_slotId: string, iface?: string): import("@endo/pass-style").RemotableObject<string> & import("@endo/eventual-send").RemotableBrand<{}, {}>; | ||
/** | ||
@@ -12,2 +12,6 @@ * A basic marshaller whose unserializer produces Remotables. It can only | ||
}; | ||
export namespace defaultSerializer { | ||
let parse: (text: string) => unknown; | ||
let stringify: (obj: any) => string; | ||
} | ||
export const slotStringUnserialize: (capData: any) => any; | ||
@@ -24,7 +28,11 @@ export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<typeof makeChainStorageRoot>[2]): { | ||
data: Map<string, string>; | ||
getValues: (path: string) => string[]; | ||
messages: StorageMessage[]; | ||
toStorage: (message: StorageMessage) => string | number | any[] | { | ||
toStorage: ((message: StorageMessage) => string | number | any[] | { | ||
storeName: string; | ||
storeSubkey: string; | ||
} | null | undefined; | ||
} | null | undefined) & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (message: StorageMessage) => string | number | any[] | { | ||
storeName: string; | ||
storeSubkey: string; | ||
} | null | undefined>; | ||
}; | ||
@@ -40,11 +48,5 @@ export function makeMockChainStorageRoot(): MockChainStorageRoot; | ||
replacement: string; | ||
} | {})): Promise<void>; | ||
/** | ||
* A map corresponding with a total function such that `get(key)` is assumed to | ||
* always succeed. | ||
*/ | ||
export type TotalMap<K, V> = { [k in Exclude<keyof Map<K, V>, "get">]: Map<K, V>[k]; } & { | ||
get: (key: K) => V; | ||
}; | ||
export type TotalMapFrom<T> = T extends Map<infer K, infer V> ? TotalMap<K, V> : never; | ||
} | {}) & { | ||
showValue?: (v: string) => unknown; | ||
}): Promise<void>; | ||
export type FakeStorageKit = ReturnType<typeof makeFakeStorageKit>; | ||
@@ -51,0 +53,0 @@ export type MockChainStorageRootMethods = { |
// @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'; | ||
@@ -11,24 +13,9 @@ import { eventLoopIteration } from './testing-utils.js'; | ||
/** | ||
* @import {TotalMap} from './types.js'; | ||
* @import {Marshaller, StorageEntry, StorageMessage, StorageNode} from './lib-chainStorage.js'; | ||
*/ | ||
const { Fail } = assert; | ||
const trace = makeTracer('StorTU', false); | ||
/** | ||
* A map corresponding with a total function such that `get(key)` is assumed to | ||
* always succeed. | ||
* | ||
* @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 | ||
@@ -52,2 +39,12 @@ * slots are Remotables (i.e. none are Promises). | ||
/** | ||
* 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 = | ||
@@ -127,79 +124,98 @@ * Far('iface')`, and serializing `{ a }` into `capData` assigned it slot | ||
const messages = []; | ||
/** @param {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 {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); | ||
} | ||
} | ||
break; | ||
} | ||
break; | ||
} | ||
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`; | ||
// 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`; | ||
// 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; | ||
} | ||
} | ||
if (streamCell === undefined) { | ||
streamCell = { | ||
blockHeight: '0', | ||
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)); | ||
break; | ||
} | ||
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 { | ||
@@ -209,2 +225,3 @@ rootNode, | ||
data: /** @type {Map<string, string>} */ (data), | ||
getValues, | ||
messages, | ||
@@ -267,3 +284,5 @@ toStorage, | ||
* @param {({ note: string } | { node: string; owner: string }) & | ||
* ({ pattern: string; replacement: string } | {})} opts | ||
* ({ pattern: string; replacement: string } | {}) & { | ||
* showValue?: (v: string) => unknown; | ||
* }} opts | ||
*/ | ||
@@ -274,6 +293,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), | ||
]; | ||
@@ -284,11 +312,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, | ||
); | ||
@@ -303,3 +338,3 @@ const note = | ||
See also board marshalling conventions (_to appear_).`; | ||
t.snapshot(pruned, note + boilerplate); | ||
t.snapshot(illustration, note + boilerplate); | ||
}; |
@@ -24,9 +24,9 @@ /** @file adapted from https://raw.githubusercontent.com/sindresorhus/type-fest/main/source/opaque.d.ts */ | ||
- the underlying (untagged) type of `A` is assignable to the underlying type of `B`; | ||
- `A` contains at least all the tags `B` has; | ||
- and the metadata type for each of `A`'s tags is assignable to the metadata type of `B`'s corresponding tag. | ||
- `A` contains at least all the tags `B` has; | ||
- and the metadata type for each of `A`'s tags is assignable to the metadata type of `B`'s corresponding tag. | ||
There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward: | ||
- [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202) | ||
- [Microsoft/TypeScript#4895](https://github.com/microsoft/TypeScript/issues/4895) | ||
- [Microsoft/TypeScript#33290](https://github.com/microsoft/TypeScript/pull/33290) | ||
- [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202) | ||
- [Microsoft/TypeScript#4895](https://github.com/microsoft/TypeScript/issues/4895) | ||
- [Microsoft/TypeScript#33290](https://github.com/microsoft/TypeScript/pull/33290) | ||
@@ -41,8 +41,8 @@ @example | ||
function createAccountNumber(): AccountNumber { | ||
// As you can see, casting from a `number` (the underlying type being tagged) is allowed. | ||
return 2 as AccountNumber; | ||
// As you can see, casting from a `number` (the underlying type being tagged) is allowed. | ||
return 2 as AccountNumber; | ||
} | ||
function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance { | ||
return 4 as AccountBalance; | ||
return 4 as AccountBalance; | ||
} | ||
@@ -74,4 +74,2 @@ | ||
``` | ||
@category Type | ||
*/ | ||
@@ -108,4 +106,2 @@ export type Tagged< | ||
``` | ||
@category Type | ||
*/ | ||
@@ -132,4 +128,4 @@ export type GetTagMetadata< | ||
const moneyByAccountType: Record<UnwrapTagged<AccountType>, number> = { | ||
SAVINGS: 99, | ||
CHECKING: 0.1 | ||
SAVINGS: 99, | ||
CHECKING: 0.1 | ||
}; | ||
@@ -143,4 +139,2 @@ | ||
``` | ||
@category Type | ||
*/ | ||
@@ -147,0 +141,0 @@ export type UnwrapTagged<TaggedType extends Tag<PropertyKey, any>> = |
export function eventLoopIteration(): Promise<any>; | ||
export function inspectMapStore(store: MapStore): object; | ||
import type { MapStore } from '@agoric/store'; | ||
//# sourceMappingURL=testing-utils.d.ts.map |
@@ -0,1 +1,2 @@ | ||
// @ts-check | ||
/** | ||
@@ -6,2 +7,3 @@ * @file note this cannot be called test-utils.js due to | ||
/* global setImmediate */ | ||
/** @import {MapStore} from '@agoric/store'; */ | ||
@@ -18,1 +20,36 @@ /** | ||
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); |
@@ -1,26 +0,25 @@ | ||
/* eslint-disable max-classes-per-file */ | ||
import type { ERef, RemotableBrand } from '@endo/eventual-send'; | ||
import type { Primitive } from '@endo/pass-style'; | ||
import type { Callable } from './utils.js'; | ||
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 { 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; | ||
} | ||
/** | ||
@@ -42,11 +41,6 @@ Returns a boolean for whether the given type is primitive value or primitive type. | ||
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]> }; | ||
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]>; | ||
}; | ||
/** | ||
@@ -57,12 +51,25 @@ * A type that doesn't assume its parameter is local, but is satisfied with both | ||
*/ | ||
export type Remote<Primary, Local = DataOnly<Primary>> = | ||
| Primary | ||
| RemotableBrand<Local, Primary>; | ||
// TODO: Add type tests for FarRef and Remote. | ||
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> | ||
>; | ||
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,2 +8,3 @@ export namespace UpgradeDisconnectionShape { | ||
export function isUpgradeDisconnection(reason: any): reason is UpgradeDisconnection; | ||
export function isAbandonedError(reason: any): reason is Error; | ||
/** | ||
@@ -10,0 +11,0 @@ * An Error-like object for use as the rejection reason of promises abandoned by |
@@ -48,3 +48,27 @@ // @ts-check | ||
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
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
173558
115
3966
5
+ Added@endo/errors@^1.2.8
Updated@endo/common@^1.2.8
Updated@endo/far@^1.1.9
Updated@endo/init@^1.1.7
Updated@endo/marshal@^1.6.2
Updated@endo/pass-style@^1.4.7
Updated@endo/patterns@^1.4.7
Updated@endo/promise-kit@^1.1.8
Updated@endo/stream@^1.2.8