From 19f1f60dc061b91223ca12c4aa65d49e5a2f6c26 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 20 Jun 2023 10:27:30 -0700 Subject: [PATCH] chore(types): correct ManifestBundleRef --- .../test/upgrade-contract/propose-buggy-contract.js | 1 + .../upgrade-contract/propose-upgrade-contract.js | 1 + .../src/coreProposalBehavior.js | 12 +++++++----- packages/deploy-script-support/src/externalTypes.js | 9 ++++----- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/agoric-cli/test/upgrade-contract/propose-buggy-contract.js b/packages/agoric-cli/test/upgrade-contract/propose-buggy-contract.js index 1e5829e6511b..1420d080f7eb 100644 --- a/packages/agoric-cli/test/upgrade-contract/propose-buggy-contract.js +++ b/packages/agoric-cli/test/upgrade-contract/propose-buggy-contract.js @@ -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', diff --git a/packages/agoric-cli/test/upgrade-contract/propose-upgrade-contract.js b/packages/agoric-cli/test/upgrade-contract/propose-upgrade-contract.js index b149f7ef75be..60ad54bb46cb 100644 --- a/packages/agoric-cli/test/upgrade-contract/propose-upgrade-contract.js +++ b/packages/agoric-cli/test/upgrade-contract/propose-upgrade-contract.js @@ -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', diff --git a/packages/deploy-script-support/src/coreProposalBehavior.js b/packages/deploy-script-support/src/coreProposalBehavior.js index 477e8dddd7a3..75f3e20e6953 100644 --- a/packages/deploy-script-support/src/coreProposalBehavior.js +++ b/packages/deploy-script-support/src/coreProposalBehavior.js @@ -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>} [opts.overrideManifest] * @param {typeof import('@endo/far').E} opts.E * @param {(...args: unknown[]) => void} [opts.log] - * @param {(ref: unknown) => Promise} [opts.restoreRef] + * @param {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise>} [opts.restoreRef] * @returns {(vatPowers: unknown) => Promise} */ export const makeCoreProposalBehavior = ({ @@ -70,13 +70,15 @@ export const makeCoreProposalBehavior = ({ } = allPowers; const [exportedGetManifest, ...manifestArgs] = getManifestCall; + /** @type {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise>} */ 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); diff --git a/packages/deploy-script-support/src/externalTypes.js b/packages/deploy-script-support/src/externalTypes.js index 35535dcf66a5..442ea8bcce38 100644 --- a/packages/deploy-script-support/src/externalTypes.js +++ b/packages/deploy-script-support/src/externalTypes.js @@ -16,14 +16,13 @@ export {}; */ /** - * @typedef BundleHandle - * @property {string} [bundleName] + * @typedef {{ bundleName: string } | { bundleID: string} } ManifestBundleRef */ /** * @callback PublishBundleRef - * @param {ERef} bundle - * @returns {Promise} + * @param {ERef} bundle + * @returns {Promise} */ /** @@ -31,7 +30,7 @@ export {}; * @param {string} srcSpec * @param {string} bundlePath * @param {any} [opts] - * @returns {BundleHandle} + * @returns {ManifestBundleRef} */ /**