Skip to content

Commit

Permalink
refactor(types): module for vat-loader types
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Oct 2, 2023
1 parent 2abe8ec commit 7864b57
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
insistVatSyscallObject,
insistVatDeliveryResult,
} from '../../lib/message.js';
import '../../types-ambient.js';
/// <reference path="./types.js" />

/// <reference path="../../types-ambient.js" />

/**
* @typedef {import('@agoric/swingset-liveslots').VatDeliveryObject} VatDeliveryObject
Expand All @@ -27,7 +27,7 @@ function parentLog(first, ...args) {
const encoder = new TextEncoder();
const decoder = new TextDecoder();

/** @param { (item: Tagged) => unknown } [handleUpstream] */
/** @param { (item: import('./types.js').Tagged) => unknown } [handleUpstream] */
const makeRevokableHandleCommandKit = handleUpstream => {
/**
* @param {Uint8Array} msg
Expand Down Expand Up @@ -96,7 +96,7 @@ export function makeXsSubprocessFactory({

const mk = makeManagerKit();

/** @type { (item: Tagged) => unknown } */
/** @type { (item: import('./types.js').Tagged) => unknown } */
function handleUpstream([type, ...args]) {
parentLog(vatID, `handleUpstream`, type, args.length);
switch (type) {
Expand Down Expand Up @@ -148,7 +148,7 @@ export function makeXsSubprocessFactory({
init: snapshotInfo && { from: 'snapStore', vatID },
});

/** @type { (item: Tagged) => Promise<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 @@ -185,7 +185,7 @@ export function makeXsSubprocessFactory({
*/
async function deliverToWorker(delivery) {
parentLog(vatID, `sending delivery`, delivery);
/** @type { WorkerResults } */
/** @type { import('./types.js').WorkerResults } */
let result;
await null;
try {
Expand Down
2 changes: 2 additions & 0 deletions packages/SwingSet/src/kernel/vat-loader/types.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export {};

/**
* @typedef { [string, ...unknown[]] } Tagged
* @typedef { { meterType: string, allocate: number|null, compute: number|null } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const build = async (log, zoe) => {
});
};

/** @type {BuildRootObjectForTestVat} */
/** @type {import('@agoric/swingset-vat/src/kernel/vat-loader/types.js').BuildRootObjectForTestVat} */
export const buildRootObject = vatPowers =>
Far('root', {
/** @param {ZoeService} zoe */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const build = async (log, zoe) => {
* @typedef {ReturnType<Awaited<ReturnType<typeof build>>['createVoter']>} EVatVoter
*/

/** @type {BuildRootObjectForTestVat} */
/** @type {import('@agoric/swingset-vat/src/kernel/vat-loader/types.js').BuildRootObjectForTestVat} */
export const buildRootObject = vatPowers =>
Far('root', {
build: (...args) => build(vatPowers.testLog, ...args),
Expand Down

0 comments on commit 7864b57

Please sign in to comment.