Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(types): correct ManifestBundleRef #7957

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a thought on product interface boundaries...

One consumer (metamask) pointed out that even though the types have no runtime impact, they can represent breaking changes in the sense that ci jobs fail and effort is needed to address them. This type is exported, so renaming it is a breaking change, from that angle. (I suppose changing its definition could be too)

I don't think that should hold up this PR, but I hope we decide soon on a pretty clear set of product interfaces.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to raise. I queued it for our discussion about breaking changes.

*/

/**
* @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
Loading