Skip to content

Commit

Permalink
chore(types): InstallEntrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg authored and anilhelvaci committed Mar 4, 2024
1 parent 54ecb35 commit 6604527
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 9 deletions.
3 changes: 3 additions & 0 deletions packages/deploy-script-support/src/endo-pieces-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const start = () => {
});
};

/**
* @param {{ zoe: ERef<ZoeService> }} opts
*/
const makeBundler = ({ zoe }) => {
/** @type { Map<string, [string, Uint8Array]>} */
const nameToContent = new Map();
Expand Down
12 changes: 6 additions & 6 deletions packages/deploy-script-support/src/externalTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export {};
*/

/**
* @typedef {{ bundleName: string } | { bundleID: string} } ManifestBundleRef
* @typedef {{fileName?: string} & ({ bundleName: string } | { bundleID: string}) } ManifestBundleRef
*/

/**
Expand All @@ -26,19 +26,19 @@ export {};
*/

/**
* @callback InstallBundle
* @callback InstallEntrypoint
* @param {string} srcSpec
* @param {string} bundlePath
* @param {any} [opts]
* @param {string} [bundlePath]
* @param {unknown} [opts]
* @returns {Promise<ManifestBundleRef>}
*/

/**
* @callback ProposalBuilder
* @param {{
* publishRef: PublishBundleRef,
* install: InstallBundle,
* wrapInstall?: <T>(f: T) => T }
* install: InstallEntrypoint,
* wrapInstall?: <T extends InstallEntrypoint>(f: T) => T }
* } powers
* @param {...any} args
* @returns {Promise<ProposalResult>}
Expand Down
1 change: 1 addition & 0 deletions packages/deploy-script-support/src/getBundlerMaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { E } from '@endo/far';
import url from 'url';

/** @typedef {ReturnType<import('./endo-pieces-contract.js')['start']>['publicFacet']} BundleMaker */
/** @typedef {ReturnType<BundleMaker['makeBundler']>} Bundler */

export const makeGetBundlerMaker =
(homeP, { lookup, bundleSource }) =>
Expand Down
2 changes: 2 additions & 0 deletions packages/deploy-script-support/src/writeCoreProposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const makeWriteCoreProposal = (
const { bundleSource, pathResolve } = endowments;

let bundlerCache;
/** @returns {import('./getBundlerMaker.js').Bundler} */
const getBundler = () => {
if (!bundlerCache) {
bundlerCache = E(getBundlerMaker()).makeBundler({
Expand Down Expand Up @@ -120,6 +121,7 @@ export const makeWriteCoreProposal = (

// Await a reference then publish to the board.
const cmds = [];
/** @param {Promise<import('./externalTypes.js').ManifestBundleRef>} refP */
const publishRef = async refP => {
const { fileName, ...ref } = await refP;
if (fileName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test('installInPieces', async t => {
},
};

// @ts-expect-error fake Zoe
const bundler = E(publicFacet).makeBundler({ zoe });

const installation = await installInPieces(endoPieces, bundler, {
Expand Down
1 change: 1 addition & 0 deletions packages/inter-protocol/scripts/add-collateral-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default async (homeP, endowments) => {

await writeCoreProposal('gov-add-collateral', defaultProposalBuilder);
await writeCoreProposal('gov-start-psm', opts =>
// @ts-expect-error XXX makeInstallCache types
psmProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }),
);
};
2 changes: 2 additions & 0 deletions packages/inter-protocol/scripts/init-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,11 @@ export default async (homeP, endowments) => {
});
await Promise.all([
writeCoreProposal('gov-econ-committee', opts =>
// @ts-expect-error XXX makeInstallCache types
committeeProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }),
),
writeCoreProposal('gov-amm-vaults-etc', opts =>
// @ts-expect-error XXX makeInstallCache types
mainProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }),
),
]);
Expand Down
1 change: 0 additions & 1 deletion packages/vats/scripts/build-game1-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const game1ProposalBuilder = async ({ publishRef, install }) => {
});
};

/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('start-game1', game1ProposalBuilder);
Expand Down
1 change: 0 additions & 1 deletion packages/vats/scripts/build-walletFactory-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const defaultProposalBuilder = async ({ publishRef, install }) => {
});
};

/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('upgrade-walletFactory', defaultProposalBuilder);
Expand Down
2 changes: 1 addition & 1 deletion packages/vats/scripts/set-core-proposal-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (!spec) {
}

const vatConfigFile = require.resolve(spec);
const configJson = fs.readFileSync(vatConfigFile);
const configJson = fs.readFileSync(vatConfigFile, 'utf-8');
const config = JSON.parse(configJson);

const envs = new Map();
Expand Down

0 comments on commit 6604527

Please sign in to comment.