Skip to content

Commit

Permalink
yarn format
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Dec 20, 2023
1 parent 746ccda commit 8cb331d
Show file tree
Hide file tree
Showing 88 changed files with 716 additions and 492 deletions.
16 changes: 10 additions & 6 deletions packages/SwingSet/misc-tools/replay-transcript.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,11 @@ async function replay(transcriptFile) {
}

// @ts-expect-error missing symbol
/** @type {Partial<
Record<ReturnType<typeof getResultKind>, Map<string, number[]>>
>} */
/**
* @type {Partial<
* Record<ReturnType<typeof getResultKind>, Map<string, number[]>>
* >}
*/
let syscallResults = {};

const analyzeSyscallResults = () => {
Expand Down Expand Up @@ -427,9 +429,11 @@ async function replay(transcriptFile) {
const currentBundleIDs = await bundleHandler.getCurrentBundleIDs();
const managerOptions =
/** @type {import('../src/types-internal.js').ManagerOptions} */ (
/** @type {Partial<
import('../src/types-internal.js').ManagerOptions
>} */ ({
/**
* @type {Partial<
* import('../src/types-internal.js').ManagerOptions
* >}
*/ ({
sourcedConsole: console,
vatParameters,
useTranscript: true,
Expand Down
8 changes: 5 additions & 3 deletions packages/SwingSet/src/controller/startXSnap.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ const NETSTRING_MAX_CHUNK_SIZE = 12_000_000;
* TODO: transition to direct snapshot stream, and remove this option
*/

/** @typedef {StartXSnapInitFromBundlesDetails
| StartXSnapInitFromSnapshotStreamDetails
| StartXSnapInitFromSnapStoreDetails} StartXSnapInitDetails */
/**
* @typedef {StartXSnapInitFromBundlesDetails
* | StartXSnapInitFromSnapshotStreamDetails
* | StartXSnapInitFromSnapStoreDetails} StartXSnapInitDetails
*/

/** @typedef {ReturnType<typeof makeStartXSnap>} StartXSnap */

Expand Down
8 changes: 5 additions & 3 deletions packages/SwingSet/src/kernel/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,11 @@ export default function buildKernel(
if (!vatWarehouse.lookup(vatID)) {
return NO_DELIVERY_CRANK_RESULTS; // can't collect from the dead
}
/** @type {KernelDeliveryDropExports
| KernelDeliveryRetireExports
| KernelDeliveryRetireImports} */
/**
* @type {KernelDeliveryDropExports
* | KernelDeliveryRetireExports
* | KernelDeliveryRetireImports}
*/
const kd = harden([type, krefs]);
if (type === 'retireExports') {
for (const kref of krefs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ export function makeXsSubprocessFactory({
init: snapshotInfo && { from: 'snapStore', vatID },
});

/** @type {(
item: import('./types.js').Tagged,
) => Promise<import('./types.js').WorkerResults>} */
/**
* @type {(
* item: import('./types.js').Tagged,
* ) => Promise<import('./types.js').WorkerResults>}
*/
async function issueTagged(item) {
parentLog(item[0], '...', item.length - 1);
const result = await worker.issueStringCommand(JSON.stringify(item));
Expand Down Expand Up @@ -273,9 +275,11 @@ export function makeXsSubprocessFactory({
]);
await closeP;

/** @type {Partial<
import('@agoric/swing-store/src/snapStore.js').SnapshotInfo
>} */
/**
* @type {Partial<
* import('@agoric/swing-store/src/snapStore.js').SnapshotInfo
* >}
*/
const reloadSnapshotInfo = {
snapPos,
hash: snapshotResults.hash,
Expand Down
14 changes: 8 additions & 6 deletions packages/SwingSet/src/kernel/vat-warehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,12 +510,14 @@ export function makeVatWarehouse({
await evict(lru);
}

/** @type {(
vatID: string,
kd: KernelDeliveryObject,
d: VatDeliveryObject,
vs: VatSlog,
) => Promise<VatDeliveryResult>} */
/**
* @type {(
* vatID: string,
* kd: KernelDeliveryObject,
* d: VatDeliveryObject,
* vs: VatSlog,
* ) => Promise<VatDeliveryResult>}
*/
async function deliverToVat(vatID, kd, vd, vs) {
await applyAvailabilityPolicy(vatID);

Expand Down
14 changes: 8 additions & 6 deletions packages/SwingSet/src/supervisors/supervisor-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ function makeSupervisorSyscall(syscallToManager) {
// this will be given to liveslots, it should have distinct methods that
// return immediate results or throw errors
const syscallForVat = {
/** @type {(
target: string,
method: string,
args: SwingSetCapData,
result?: string,
) => unknown} */
/**
* @type {(
* target: string,
* method: string,
* args: SwingSetCapData,
* result?: string,
* ) => unknown}
*/
send: (target, methargs, result) =>
doSyscall(['send', target, { methargs, result }]),
subscribe: vpid => doSyscall(['subscribe', vpid]),
Expand Down
24 changes: 12 additions & 12 deletions packages/SwingSet/src/types-external.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ export {};
*/

/**
* @typedef {{ meter?: Meter }} OptMeter If a meter is provided, the new
* dynamic vat is limited to a fixed amount of computation and allocation that
* can occur during any given crank. Peak stack frames are limited as well. In
* @typedef {{ meter?: Meter }} OptMeter If a meter is provided, the new dynamic
* vat is limited to a fixed amount of computation and allocation that can
* occur during any given crank. Peak stack frames are limited as well. In
* addition, the given meter's "remaining" value will be reduced by the amount
* of computation used by each crank. The meter will eventually underflow
* unless it is topped up, at which point the vat is terminated. If undefined,
Expand All @@ -374,13 +374,13 @@ export {};
*
* @typedef {{ vatParameters?: object; upgradeMessage?: string }} VatUpgradeOptions
* @typedef {{ incarnationNumber: number }} VatUpgradeResults
* @callback ShutdownWithFailure Called to shut something down because
* something went wrong, where the reason is supposed to be an Error that
* describes what went wrong. Some valid implementations of
* `ShutdownWithFailure` will never return, either because they throw or
* because they immediately shutdown the enclosing unit of computation.
* However, they also might return, so the caller should follow this call by
* their own defensive `throw reason;` if appropriate.
* @callback ShutdownWithFailure Called to shut something down because something
* went wrong, where the reason is supposed to be an Error that describes what
* went wrong. Some valid implementations of `ShutdownWithFailure` will never
* return, either because they throw or because they immediately shutdown the
* enclosing unit of computation. However, they also might return, so the
* caller should follow this call by their own defensive `throw reason;` if
* appropriate.
* @param {Error} reason
* @returns {void}
* @typedef {object} VatAdminFacet A powerful object corresponding with a vat
Expand All @@ -390,8 +390,8 @@ export {};
* or rejected when the vat is terminated. If the vat terminates with a
* failure, the promise will be rejected with the reason. If the vat
* terminates successfully, the promise will fulfill to the completion value.
* @property {ShutdownWithFailure} terminateWithFailure Terminate the vat with
* a failure reason.
* @property {ShutdownWithFailure} terminateWithFailure Terminate the vat with a
* failure reason.
* @property {(
* bundlecap: BundleCap,
* options?: VatUpgradeOptions,
Expand Down
5 changes: 2 additions & 3 deletions packages/access-token/src/json-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,8 @@ export function setAllState(storage, stuff) {
*
* @param {string} dirPath Path to a directory in which database files might be
* present. This directory need not actually exist
* @returns {boolean} If the directory is present and contains the files
* created by initJSONStore or openJSONStore, returns true. Else returns
* false.
* @returns {boolean} If the directory is present and contains the files created
* by initJSONStore or openJSONStore, returns true. Else returns false.
*/
export function isJSONStore(dirPath) {
if (`${dirPath}` !== dirPath) {
Expand Down
8 changes: 5 additions & 3 deletions packages/agoric-cli/src/commands/auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ const { Fail } = assert;
* }} ParamValues
*/

/** @typedef {ReturnType<
import('@agoric/inter-protocol/src/auction/params.js').makeAuctioneerParams
>} AuctionParamRecord */
/**
* @typedef {ReturnType<
* import('@agoric/inter-protocol/src/auction/params.js').makeAuctioneerParams
* >} AuctionParamRecord
*/
/** @typedef {ParamValues<ParamTypesMapFromRecord<AuctionParamRecord>>} AuctionParams */

/**
Expand Down
14 changes: 8 additions & 6 deletions packages/agoric-cli/src/lib/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,14 @@ export const pollTx = async (txhash, opts) => {
{ stdio: ['ignore', 'pipe', 'ignore'] },
);
// XXX this type is defined in a .proto file somewhere
/** @type {{
height: string;
txhash: string;
code: number;
timestamp: string;
}} */
/**
* @type {{
* height: string;
* txhash: string;
* code: number;
* timestamp: string;
* }}
*/
const info = JSON.parse(out.toString());
return info;
};
Expand Down
8 changes: 5 additions & 3 deletions packages/agoric-cli/src/lib/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ export const Natural = str => {
*/
export const bigintReplacer = (k, v) => (typeof v === 'bigint' ? `${v}` : v);

/** @type {Partial<
import('@agoric/vats/tools/board-utils.js').VBankAssetDetail
>} */
/**
* @type {Partial<
* import('@agoric/vats/tools/board-utils.js').VBankAssetDetail
* >}
*/
// eslint-disable-next-line no-unused-vars
const exampleAsset = {
brand: makeBoardRemote({ boardId: 'board0425', iface: 'Alleged: BLD brand' }),
Expand Down
8 changes: 5 additions & 3 deletions packages/agoric-cli/src/lib/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,11 @@ export const makeAgoricNames = async (ctx, vstorage) => {
const content = await vstorage.readLatest(
`published.agoricNames.${kind}`,
);
/** @type {Array<
[string, import('@agoric/vats/tools/board-utils.js').BoardRemote]
>} */
/**
* @type {Array<
* [string, import('@agoric/vats/tools/board-utils.js').BoardRemote]
* >}
*/
const parts = storageHelper.unserializeTxt(content, ctx).at(-1);
for (const [name, remote] of parts) {
if ('getBoardId' in remote) {
Expand Down
10 changes: 6 additions & 4 deletions packages/agoric-cli/src/lib/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ const emptyCurrentRecord = {
export const getCurrent = async (addr, { readLatestHead }) => {
// Partial because older writes may not have had all properties
// NB: assumes changes are only additions
let current = /** @type {Partial<
import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord
>
| undefined} */ (await readLatestHead(`published.wallet.${addr}.current`));
let current = /**
* @type {Partial<
* import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord
* >
* | undefined}
*/ (await readLatestHead(`published.wallet.${addr}.current`));
if (current === undefined) {
throw new Error(`undefined current node for ${addr}`);
}
Expand Down
10 changes: 6 additions & 4 deletions packages/agoric-cli/test/test-inter-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ const agoricNames = harden({
auctioneer: makeBoardRemote({ boardId: 'board434', iface: 'Instance' }),
},

/** @type {Record<
string,
import('agoric/src/lib/format.js').AssetDescriptor
>} */
/**
* @type {Record<
* string,
* import('agoric/src/lib/format.js').AssetDescriptor
* >}
*/
vbankAsset: {
ubld: {
denom: 'ubld',
Expand Down
11 changes: 5 additions & 6 deletions packages/assert/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,9 @@
// /////////////////////////////////////////////////////////////////////////////

/**
* @typedef {{}} DetailsToken A call to the `details` template literal makes
* and returns a fresh details token, which is a frozen empty object
* associated with the arguments of that `details` template literal
* expression.
* @typedef {{}} DetailsToken A call to the `details` template literal makes and
* returns a fresh details token, which is a frozen empty object associated
* with the arguments of that `details` template literal expression.
*/

/**
Expand All @@ -181,8 +180,8 @@
*/

/**
* @typedef {object} StringablePayload Holds the payload passed to quote so
* that its printed form is visible.
* @typedef {object} StringablePayload Holds the payload passed to quote so that
* its printed form is visible.
* @property {() => string} toString How to print the payload
*/

Expand Down
1 change: 1 addition & 0 deletions packages/base-zone/src/is-passable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { passStyleOf } from '@endo/pass-style';
* normal circumstance should `isPassable(specimen)` throw.
*
* TODO implement an isPassable that does not rely on try/catch, and move it to
*
* @endo/pass-style. This implementation is just a standin until then

Check warning on line 10 in packages/base-zone/src/is-passable.js

View workflow job for this annotation

GitHub Actions / lint-rest

Invalid JSDoc tag name "endo/pass-style."
*
* @param {any} specimen
Expand Down
8 changes: 5 additions & 3 deletions packages/boot/test/test-boot-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ const importConfig = configName =>
u => new URL(u).pathname,
);

const test = /** @type {import('ava').TestFn<
Awaited<ReturnType<typeof makeTestContext>>
>} } */ (anyTest);
const test = /**
* @type {import('ava').TestFn<
* Awaited<ReturnType<typeof makeTestContext>>
* >} }
*/ (anyTest);

const PROD_CONFIG_FILES = [
'decentral-main-vaults-config.json',
Expand Down
8 changes: 5 additions & 3 deletions packages/casting/src/follower-cosmjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ const { Tendermint34Client } = tendermint34;
const { details: X, quote: q, Fail } = assert;
const textDecoder = new TextDecoder();

/** @template T @typedef
{import('./types.js').Follower<import('./types.js').ValueFollowerElement<T>>}
ValueFollower */
/**
* @template T @typedef
* {import('./types.js').Follower<import('./types.js').ValueFollowerElement<T>>}
* ValueFollower
*/

// Copied from https://github.com/cosmos/cosmjs/pull/1328/files until release
/**
Expand Down
8 changes: 5 additions & 3 deletions packages/casting/src/follower.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import { makeCastingSpec } from './casting-spec.js';
const makeSubscriptionFollower = spec => {
const transform = value =>
harden({ value, blockHeight: NaN, currentBlockHeight: NaN });
/** @type {import('./types').Follower<
import('./types.js').ValueFollowerElement<T>
>} */
/**
* @type {import('./types').Follower<
* import('./types.js').ValueFollowerElement<T>
* >}
*/
const follower = Far('subscription/notifier follower', {
getLatestIterable: async () => {
const { notifier, subscription } = await spec;
Expand Down
8 changes: 5 additions & 3 deletions packages/casting/test/fake-rpc-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ const fakeStatusResult = {
},
};

/** @typedef {Partial<
import('ava').ExecutionContext<{ cleanups: Array<() => void> }>
> & { context }} FakeServerTestContext */
/**
* @typedef {Partial<
* import('ava').ExecutionContext<{ cleanups: Array<() => void> }>
* > & { context }} FakeServerTestContext
*/
/**
* @param {FakeServerTestContext} t
* @param {Array<{ any }>} fakeValues
Expand Down
4 changes: 2 additions & 2 deletions packages/casting/test/net-access-fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ const normalizeID = argsKey => {
/**
* Wrap `fetch` to capture JSON RPC IO traffic.
*
* @param {typeof window.fetch} fetch returns wraped fetch along with a .web
* map for use with {@link replayIO}
* @param {typeof window.fetch} fetch returns wraped fetch along with a .web map
* for use with {@link replayIO}
*/
export const captureIO = fetch => {
const web = new Map();
Expand Down
Loading

0 comments on commit 8cb331d

Please sign in to comment.