Skip to content

Commit

Permalink
Merge pull request #7957 from Agoric/ta/bundle-types
Browse files Browse the repository at this point in the history
chore(types): correct ManifestBundleRef
  • Loading branch information
turadg authored Jun 21, 2023
2 parents 2c5dd59 + 8487735 commit 3a87a12
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { makeHelpers } from '@agoric/deploy-script-support';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
export const defaultProposalBuilder = async ({ publishRef, install }) =>
harden({
sourceSpec: './init-proposal.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { makeHelpers } from '@agoric/deploy-script-support';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
export const defaultProposalBuilder = async ({ publishRef, install }) =>
harden({
sourceSpec: './upgrade-proposal.js',
Expand Down
12 changes: 7 additions & 5 deletions packages/deploy-script-support/src/coreProposalBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export const permits = {
* definitions.
*
* @param {object} opts
* @param {{ bundleName: string } | { bundleID: string }} opts.manifestBundleRef
* @param {import('./externalTypes.js').ManifestBundleRef} opts.manifestBundleRef
* @param {[string, ...unknown[]]} opts.getManifestCall
* @param {Record<string, Record<string, unknown>>} [opts.overrideManifest]
* @param {typeof import('@endo/far').E} opts.E
* @param {(...args: unknown[]) => void} [opts.log]
* @param {(ref: unknown) => Promise<unknown>} [opts.restoreRef]
* @param {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise<import('@agoric/zoe/src/zoeService/utils.js').Installation<unknown>>} [opts.restoreRef]
* @returns {(vatPowers: unknown) => Promise<unknown>}
*/
export const makeCoreProposalBehavior = ({
Expand Down Expand Up @@ -70,13 +70,15 @@ export const makeCoreProposalBehavior = ({
} = allPowers;
const [exportedGetManifest, ...manifestArgs] = getManifestCall;

/** @type {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise<Installation<unknown>>} */
const defaultRestoreRef = async ref => {
// extract-proposal.js creates these records, and bundleName is
// the name under which the bundle was installed into
// config.bundles
const p = ref.bundleName
? E(vatAdminSvc).getBundleIDByName(ref.bundleName)
: ref.bundleID;
const p =
'bundleName' in ref
? E(vatAdminSvc).getBundleIDByName(ref.bundleName)
: ref.bundleID;
const bundleID = await p;
const label = bundleID.slice(0, 8);
return E(zoe).installBundleID(bundleID, label);
Expand Down
9 changes: 4 additions & 5 deletions packages/deploy-script-support/src/externalTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@ export {};
*/

/**
* @typedef BundleHandle
* @property {string} [bundleName]
* @typedef {{ bundleName: string } | { bundleID: string} } ManifestBundleRef
*/

/**
* @callback PublishBundleRef
* @param {ERef<BundleHandle>} bundle
* @returns {Promise<BundleHandle>}
* @param {ERef<ManifestBundleRef>} bundle
* @returns {Promise<ManifestBundleRef>}
*/

/**
* @callback InstallBundle
* @param {string} srcSpec
* @param {string} bundlePath
* @param {any} [opts]
* @returns {BundleHandle}
* @returns {ManifestBundleRef}
*/

/**
Expand Down
11 changes: 10 additions & 1 deletion packages/deploy-script-support/src/extract-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,20 @@ export const extractCoreProposalBundles = async (
/** @type {import('./externalTypes.js').PublishBundleRef} */
const publishRef = async handleP => {
const handle = await handleP;
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error -- https://github.com/Agoric/agoric-sdk/issues/4620 */
// @ts-ignore xxx types
bundleHandleToAbsolutePaths.has(handle) ||
Fail`${handle} not in installed bundles`;
return handle;
};
const proposal = await ns[entrypoint]({ publishRef, install }, ...args);
const proposal = await ns[entrypoint](
{
publishRef,
// @ts-expect-error not statically verified to return a full obj
install,
},
...args,
);

// Add the proposal bundle handles in sorted order.
const bundleSpecEntries = [...thisProposalBundleHandles.keys()]
Expand Down

0 comments on commit 3a87a12

Please sign in to comment.