From 7981af4c313a132c3005275d83a6293fd34e859e Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 4 Jan 2024 13:03:06 -0500 Subject: [PATCH 01/11] chore(deploy-script-support): Rename variable for clarity --- packages/deploy-script-support/src/coreProposalBehavior.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/deploy-script-support/src/coreProposalBehavior.js b/packages/deploy-script-support/src/coreProposalBehavior.js index 304e195b437a..c38a5e8f3c65 100644 --- a/packages/deploy-script-support/src/coreProposalBehavior.js +++ b/packages/deploy-script-support/src/coreProposalBehavior.js @@ -45,7 +45,7 @@ export const makeCoreProposalBehavior = ({ overrideManifest, E, log = console.info, - restoreRef: overrideRestoreRef, + restoreRef: customRestoreRef, }) => { const { entries, fromEntries } = Object; @@ -136,7 +136,7 @@ export const makeCoreProposalBehavior = ({ manifestGetterName, bundleExports: Object.keys(proposalNS), }); - const restoreRef = overrideRestoreRef || makeRestoreRef(vatAdminSvc, zoe); + const restoreRef = customRestoreRef || makeRestoreRef(vatAdminSvc, zoe); const { manifest, options: rawOptions, From 5c6e673b9dc5a8ade76a92a6418820d73b36880a Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 4 Jan 2024 14:26:38 -0500 Subject: [PATCH 02/11] chore(deploy-script-support): Improve JSDoc annotation --- .../src/coreProposalBehavior.js | 39 ++++++++++++++----- .../src/writeCoreProposal.js | 2 +- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/packages/deploy-script-support/src/coreProposalBehavior.js b/packages/deploy-script-support/src/coreProposalBehavior.js index c38a5e8f3c65..9d98c60d5370 100644 --- a/packages/deploy-script-support/src/coreProposalBehavior.js +++ b/packages/deploy-script-support/src/coreProposalBehavior.js @@ -8,6 +8,12 @@ const t = 'makeCoreProposalBehavior'; * @typedef {*} BootstrapPowers */ +/** + * @typedef {import('./externalTypes.js').ManifestBundleRef} ManifestBundleRef + * @typedef {[methodName: string, ...args: unknown[]]} FlatMethargs + * @typedef {Record>} Manifest + */ + /** * These permits are expected to be the minimum powers required by the * `coreProposalBehavior` function returned from `makeCoreProposalBehavior`. @@ -30,13 +36,13 @@ export const permits = { * for catching bugs. Thus, this maker must not reference any other modules or * definitions. * - * @param {object} opts - * @param {import('./externalTypes.js').ManifestBundleRef} opts.manifestBundleRef - * @param {[methodName: string, ...args: unknown[]]} opts.getManifestCall - * @param {Record>} [opts.overrideManifest] - * @param {typeof import('@endo/far').E} opts.E - * @param {(...args: unknown[]) => void} [opts.log] - * @param {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise>} [opts.restoreRef] + * @param {object} inputs + * @param {ManifestBundleRef} inputs.manifestBundleRef + * @param {FlatMethargs} inputs.getManifestCall + * @param {Manifest} [inputs.overrideManifest] + * @param {typeof import('@endo/far').E} inputs.E + * @param {(...args: unknown[]) => void} [inputs.log] + * @param {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise>} [inputs.restoreRef] * @returns {(vatPowers: unknown) => Promise} */ export const makeCoreProposalBehavior = ({ @@ -176,9 +182,20 @@ export const makeCoreProposalBehavior = ({ return coreProposalBehavior; }; -export const makeEnactCoreProposalsFromBundleRef = - ({ makeCoreProposalArgs, E }) => - async powers => { +/** + * @param {object} inputs + * @param {Array<{ ref: ManifestBundleRef, call: FlatMethargs, overrideManifest?: Manifest }>} inputs.makeCoreProposalArgs + * @param {typeof import('@endo/far').E} inputs.E + */ +export const makeEnactCoreProposalsFromBundleRef = ({ + makeCoreProposalArgs, + E, +}) => { + /** + * @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} powers + * @returns {Promise} + */ + const enactCoreProposals = async powers => { await Promise.all( makeCoreProposalArgs.map(async ({ ref, call, overrideManifest }) => { const coreProposalBehavior = makeCoreProposalBehavior({ @@ -191,3 +208,5 @@ export const makeEnactCoreProposalsFromBundleRef = }), ); }; + return enactCoreProposals; +}; diff --git a/packages/deploy-script-support/src/writeCoreProposal.js b/packages/deploy-script-support/src/writeCoreProposal.js index 8a489f473841..99c4ac510076 100644 --- a/packages/deploy-script-support/src/writeCoreProposal.js +++ b/packages/deploy-script-support/src/writeCoreProposal.js @@ -98,7 +98,7 @@ export const makeWriteCoreProposal = ( * * @param {string} entrypoint * @param {string} [bundlePath] - * @param [opts] + * @param {unknown} [opts] * @returns {Promise} */ const install = async (entrypoint, bundlePath, opts) => { From d5340b3422cfbfc0c6120bfc71c8cef97c8df40f Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 4 Jan 2024 14:28:45 -0500 Subject: [PATCH 03/11] chore(deploy-script-support): Fix package reference in comment --- packages/deploy-script-support/src/extract-proposal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deploy-script-support/src/extract-proposal.js b/packages/deploy-script-support/src/extract-proposal.js index 6d2952a8155f..fd3d208da9e7 100644 --- a/packages/deploy-script-support/src/extract-proposal.js +++ b/packages/deploy-script-support/src/extract-proposal.js @@ -248,7 +248,7 @@ export const extractCoreProposalBundles = async ( harden(makeCPArgs); const code = `\ -// This is generated by @agoric/cosmic-swingset/src/extract-proposal.js - DO NOT EDIT +// This is generated by @agoric/deploy-script-support/src/extract-proposal.js - DO NOT EDIT /* eslint-disable */ const makeCoreProposalArgs = harden(${stringify(makeCPArgs, true)}); From deae2766ae4dfa0f74ed524959b02c23463bd11f Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 4 Jan 2024 14:35:26 -0500 Subject: [PATCH 04/11] chore(deploy-script-support): For clarity, rename "override" paramaters to "custom" (the former can be read like a verb) --- .../src/coreProposalBehavior.js | 12 ++++++------ .../deploy-script-support/src/writeCoreProposal.js | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/deploy-script-support/src/coreProposalBehavior.js b/packages/deploy-script-support/src/coreProposalBehavior.js index 9d98c60d5370..24bc42cc44ba 100644 --- a/packages/deploy-script-support/src/coreProposalBehavior.js +++ b/packages/deploy-script-support/src/coreProposalBehavior.js @@ -39,19 +39,19 @@ export const permits = { * @param {object} inputs * @param {ManifestBundleRef} inputs.manifestBundleRef * @param {FlatMethargs} inputs.getManifestCall - * @param {Manifest} [inputs.overrideManifest] + * @param {Manifest} [inputs.customManifest] * @param {typeof import('@endo/far').E} inputs.E * @param {(...args: unknown[]) => void} [inputs.log] - * @param {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise>} [inputs.restoreRef] + * @param {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise>} [inputs.customRestoreRef] * @returns {(vatPowers: unknown) => Promise} */ export const makeCoreProposalBehavior = ({ manifestBundleRef, getManifestCall: [manifestGetterName, ...manifestGetterArgs], - overrideManifest, + customManifest, E, log = console.info, - restoreRef: customRestoreRef, + customRestoreRef, }) => { const { entries, fromEntries } = Object; @@ -171,7 +171,7 @@ export const makeCoreProposalBehavior = ({ // Remember that `powers` may be arbitrarily broad. allPowers: powers, behaviors: proposalNS, - manifest: overrideManifest || manifest, + manifest: customManifest || manifest, makeConfig: (name, _permit) => { log('coreProposal:', name); return { options }; @@ -201,7 +201,7 @@ export const makeEnactCoreProposalsFromBundleRef = ({ const coreProposalBehavior = makeCoreProposalBehavior({ manifestBundleRef: ref, getManifestCall: call, - overrideManifest, + customManifest: overrideManifest, E, }); return coreProposalBehavior(powers); diff --git a/packages/deploy-script-support/src/writeCoreProposal.js b/packages/deploy-script-support/src/writeCoreProposal.js index 99c4ac510076..18a1b22c688d 100644 --- a/packages/deploy-script-support/src/writeCoreProposal.js +++ b/packages/deploy-script-support/src/writeCoreProposal.js @@ -137,7 +137,7 @@ export const makeWriteCoreProposal = ( // console.log('created', { filePrefix, sourceSpec, getManifestCall }); // Extract the top-level permit. - const { permits: proposalPermit, manifest: overrideManifest } = + const { permits: proposalPermit, manifest: customManifest } = await mergeProposalPermit(proposal, permits); // Get an install @@ -150,10 +150,10 @@ export const makeWriteCoreProposal = ( const manifestBundleRef = ${stringify(manifestBundleRef)}; const getManifestCall = harden(${stringify(getManifestCall, true)}); -const overrideManifest = ${stringify(overrideManifest, true)}; +const customManifest = ${stringify(customManifest, true)}; // Make the behavior the completion value. -(${makeCoreProposalBehavior})({ manifestBundleRef, getManifestCall, overrideManifest, E }); +(${makeCoreProposalBehavior})({ manifestBundleRef, getManifestCall, customManifest, E }); `; const trimmed = defangAndTrim(code); From 711bf4ff04f08981e918ba397f2dd9469d1368e6 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 4 Jan 2024 14:39:32 -0500 Subject: [PATCH 05/11] =?UTF-8?q?chore(deploy-script-support):=20Complete?= =?UTF-8?q?=20the=20"override"=20=E2=86=92=20"custom"=20renaming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../deploy-script-support/src/coreProposalBehavior.js | 6 +++--- packages/deploy-script-support/src/extract-proposal.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/deploy-script-support/src/coreProposalBehavior.js b/packages/deploy-script-support/src/coreProposalBehavior.js index 24bc42cc44ba..03b8463e80b8 100644 --- a/packages/deploy-script-support/src/coreProposalBehavior.js +++ b/packages/deploy-script-support/src/coreProposalBehavior.js @@ -184,7 +184,7 @@ export const makeCoreProposalBehavior = ({ /** * @param {object} inputs - * @param {Array<{ ref: ManifestBundleRef, call: FlatMethargs, overrideManifest?: Manifest }>} inputs.makeCoreProposalArgs + * @param {Array<{ ref: ManifestBundleRef, call: FlatMethargs, customManifest?: Manifest }>} inputs.makeCoreProposalArgs * @param {typeof import('@endo/far').E} inputs.E */ export const makeEnactCoreProposalsFromBundleRef = ({ @@ -197,11 +197,11 @@ export const makeEnactCoreProposalsFromBundleRef = ({ */ const enactCoreProposals = async powers => { await Promise.all( - makeCoreProposalArgs.map(async ({ ref, call, overrideManifest }) => { + makeCoreProposalArgs.map(async ({ ref, call, customManifest }) => { const coreProposalBehavior = makeCoreProposalBehavior({ manifestBundleRef: ref, getManifestCall: call, - customManifest: overrideManifest, + customManifest, E, }); return coreProposalBehavior(powers); diff --git a/packages/deploy-script-support/src/extract-proposal.js b/packages/deploy-script-support/src/extract-proposal.js index fd3d208da9e7..4cda7c3e4ace 100644 --- a/packages/deploy-script-support/src/extract-proposal.js +++ b/packages/deploy-script-support/src/extract-proposal.js @@ -204,7 +204,7 @@ export const extractCoreProposalBundles = async ( exportedGetManifest in behaviors, `behavior ${behaviorSource} missing ${exportedGetManifest}`, ); - const { manifest: overrideManifest } = await behaviors[ + const { manifest: customManifest } = await behaviors[ exportedGetManifest ](harden({ restoreRef: () => null }), ...manifestArgs); @@ -227,7 +227,7 @@ export const extractCoreProposalBundles = async ( return harden({ ref: behaviorBundleHandle, call: getManifestCall, - overrideManifest, + customManifest, bundleSpecs: bundleSpecEntries, }); }), @@ -240,10 +240,10 @@ export const extractCoreProposalBundles = async ( harden(bundles); // Extract the manifest references and calls. - const makeCPArgs = extracted.map(({ ref, call, overrideManifest }) => ({ + const makeCPArgs = extracted.map(({ ref, call, customManifest }) => ({ ref, call, - overrideManifest, + customManifest, })); harden(makeCPArgs); From 09fb06570bb3f0a502763fc76dc5e8d7ba62a365 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 4 Jan 2024 15:02:36 -0500 Subject: [PATCH 06/11] chore(deploy-script-support): Clarify script completion value as pseudo-export --- packages/deploy-script-support/src/extract-proposal.js | 8 +++++--- packages/deploy-script-support/src/writeCoreProposal.js | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/deploy-script-support/src/extract-proposal.js b/packages/deploy-script-support/src/extract-proposal.js index 4cda7c3e4ace..976c2a90871e 100644 --- a/packages/deploy-script-support/src/extract-proposal.js +++ b/packages/deploy-script-support/src/extract-proposal.js @@ -253,9 +253,11 @@ export const extractCoreProposalBundles = async ( const makeCoreProposalArgs = harden(${stringify(makeCPArgs, true)}); -const makeCoreProposalBehavior = ${makeCoreProposalBehavior}; - -(${makeEnactCoreProposals})({ makeCoreProposalArgs, E }); +// Make an enactCoreProposals function and "export" it by way of script completion value. +(( + makeCoreProposalBehavior = ${makeCoreProposalBehavior}, + makeEnactCoreProposals = ${makeEnactCoreProposals}, +) => makeEnactCoreProposals({ makeCoreProposalArgs, E }))(); `; // console.debug('created bundles from proposals:', coreProposals, bundles); diff --git a/packages/deploy-script-support/src/writeCoreProposal.js b/packages/deploy-script-support/src/writeCoreProposal.js index 18a1b22c688d..3c75212a8a2b 100644 --- a/packages/deploy-script-support/src/writeCoreProposal.js +++ b/packages/deploy-script-support/src/writeCoreProposal.js @@ -152,8 +152,9 @@ const manifestBundleRef = ${stringify(manifestBundleRef)}; const getManifestCall = harden(${stringify(getManifestCall, true)}); const customManifest = ${stringify(customManifest, true)}; -// Make the behavior the completion value. -(${makeCoreProposalBehavior})({ manifestBundleRef, getManifestCall, customManifest, E }); +// Make a behavior function and "export" it by way of script completion value. +const behavior = (${makeCoreProposalBehavior})({ manifestBundleRef, getManifestCall, customManifest, E }); +behavior; `; const trimmed = defangAndTrim(code); From 87204249adaa792ebc97dea35c88693d182ed984 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 4 Jan 2024 15:15:08 -0500 Subject: [PATCH 07/11] =?UTF-8?q?chore(deploy-script-support):=20Avoid=20"?= =?UTF-8?q?make=E2=80=A6"=20names=20for=20non-function=20variables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../deploy-script-support/src/coreProposalBehavior.js | 9 +++------ packages/deploy-script-support/src/extract-proposal.js | 8 ++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/deploy-script-support/src/coreProposalBehavior.js b/packages/deploy-script-support/src/coreProposalBehavior.js index 03b8463e80b8..d8bb17b01350 100644 --- a/packages/deploy-script-support/src/coreProposalBehavior.js +++ b/packages/deploy-script-support/src/coreProposalBehavior.js @@ -184,20 +184,17 @@ export const makeCoreProposalBehavior = ({ /** * @param {object} inputs - * @param {Array<{ ref: ManifestBundleRef, call: FlatMethargs, customManifest?: Manifest }>} inputs.makeCoreProposalArgs + * @param {Array<{ ref: ManifestBundleRef, call: FlatMethargs, customManifest?: Manifest }>} inputs.metadataRecords * @param {typeof import('@endo/far').E} inputs.E */ -export const makeEnactCoreProposalsFromBundleRef = ({ - makeCoreProposalArgs, - E, -}) => { +export const makeEnactCoreProposalsFromBundleRef = ({ metadataRecords, E }) => { /** * @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} powers * @returns {Promise} */ const enactCoreProposals = async powers => { await Promise.all( - makeCoreProposalArgs.map(async ({ ref, call, customManifest }) => { + metadataRecords.map(async ({ ref, call, customManifest }) => { const coreProposalBehavior = makeCoreProposalBehavior({ manifestBundleRef: ref, getManifestCall: call, diff --git a/packages/deploy-script-support/src/extract-proposal.js b/packages/deploy-script-support/src/extract-proposal.js index 976c2a90871e..6820cbbba3c5 100644 --- a/packages/deploy-script-support/src/extract-proposal.js +++ b/packages/deploy-script-support/src/extract-proposal.js @@ -240,24 +240,24 @@ export const extractCoreProposalBundles = async ( harden(bundles); // Extract the manifest references and calls. - const makeCPArgs = extracted.map(({ ref, call, customManifest }) => ({ + const metadataRecords = extracted.map(({ ref, call, customManifest }) => ({ ref, call, customManifest, })); - harden(makeCPArgs); + harden(metadataRecords); const code = `\ // This is generated by @agoric/deploy-script-support/src/extract-proposal.js - DO NOT EDIT /* eslint-disable */ -const makeCoreProposalArgs = harden(${stringify(makeCPArgs, true)}); +const metadataRecords = harden(${stringify(metadataRecords, true)}); // Make an enactCoreProposals function and "export" it by way of script completion value. (( makeCoreProposalBehavior = ${makeCoreProposalBehavior}, makeEnactCoreProposals = ${makeEnactCoreProposals}, -) => makeEnactCoreProposals({ makeCoreProposalArgs, E }))(); +) => makeEnactCoreProposals({ metadataRecords, E }))(); `; // console.debug('created bundles from proposals:', coreProposals, bundles); From 6dfbc6e668bfdf304b5f0f2e52bfe0a789dfb1bc Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 4 Jan 2024 15:27:16 -0500 Subject: [PATCH 08/11] chore(deploy-script-support): Sync code patterns across files --- .../src/extract-proposal.js | 21 +++++++++---------- .../src/writeCoreProposal.js | 10 ++++----- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/deploy-script-support/src/extract-proposal.js b/packages/deploy-script-support/src/extract-proposal.js index 6820cbbba3c5..dc6112a8db2a 100644 --- a/packages/deploy-script-support/src/extract-proposal.js +++ b/packages/deploy-script-support/src/extract-proposal.js @@ -197,21 +197,20 @@ export const extractCoreProposalBundles = async ( harden(proposal), ); - const behaviorSource = pathResolve(initDir, sourceSpec); - const behaviors = await import(behaviorSource); - const [exportedGetManifest, ...manifestArgs] = getManifestCall; - assert( - exportedGetManifest in behaviors, - `behavior ${behaviorSource} missing ${exportedGetManifest}`, + const proposalSource = pathResolve(initDir, sourceSpec); + const proposalNS = await import(proposalSource); + const [manifestGetterName, ...manifestGetterArgs] = getManifestCall; + manifestGetterName in proposalNS || + Fail`proposal ${proposalSource} missing export ${manifestGetterName}`; + const { manifest: customManifest } = await proposalNS[manifestGetterName]( + harden({ restoreRef: () => null }), + ...manifestGetterArgs, ); - const { manifest: customManifest } = await behaviors[ - exportedGetManifest - ](harden({ restoreRef: () => null }), ...manifestArgs); const behaviorBundleHandle = {}; const specEntry = await handleToBundleSpec( behaviorBundleHandle, - behaviorSource, + proposalSource, thisProposalSequence, 'behaviors', ); @@ -220,7 +219,7 @@ export const extractCoreProposalBundles = async ( bundleHandleToAbsolutePaths.set( behaviorBundleHandle, harden({ - source: behaviorSource, + source: proposalSource, }), ); diff --git a/packages/deploy-script-support/src/writeCoreProposal.js b/packages/deploy-script-support/src/writeCoreProposal.js index 3c75212a8a2b..cee6cf47a912 100644 --- a/packages/deploy-script-support/src/writeCoreProposal.js +++ b/packages/deploy-script-support/src/writeCoreProposal.js @@ -51,15 +51,15 @@ export const makeWriteCoreProposal = ( const mergeProposalPermit = async (proposal, additionalPermits) => { const { sourceSpec, - getManifestCall: [exportedGetManifest, ...manifestArgs], + getManifestCall: [manifestGetterName, ...manifestGetterArgs], } = proposal; - const manifestNs = await import(pathResolve(sourceSpec)); + const proposalNS = await import(pathResolve(sourceSpec)); // We only care about the manifest, not any restoreRef calls. - const { manifest } = await manifestNs[exportedGetManifest]( - { restoreRef: x => `restoreRef:${x}` }, - ...manifestArgs, + const { manifest } = await proposalNS[manifestGetterName]( + harden({ restoreRef: x => `restoreRef:${x}` }), + ...manifestGetterArgs, ); const mergedPermits = mergePermits(manifest); From d6b9a03c9175d5d17f2ad4a6c7f46309f0776688 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 4 Jan 2024 15:45:56 -0500 Subject: [PATCH 09/11] chore(deploy-script-support): Update assert(cond, X`...`) calls to cond || Fail`...` --- .../deploy-script-support/src/extract-proposal.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/deploy-script-support/src/extract-proposal.js b/packages/deploy-script-support/src/extract-proposal.js index dc6112a8db2a..5827c24a8997 100644 --- a/packages/deploy-script-support/src/extract-proposal.js +++ b/packages/deploy-script-support/src/extract-proposal.js @@ -14,7 +14,7 @@ import { * @typedef {string | { module: string, entrypoint: string, args?: Array }} ConfigProposal */ -const { details: X, Fail } = assert; +const { Fail } = assert; const req = createRequire(import.meta.url); @@ -24,8 +24,8 @@ const req = createRequire(import.meta.url); * @typedef {string} FilePath */ const pathResolve = (...paths) => { - const fileName = paths.pop(); - assert(fileName, '>=1 paths required'); + const fileName = /** @type {string} */ (paths.pop()); + fileName || Fail`base name required`; try { return req.resolve(fileName, { paths, @@ -132,11 +132,8 @@ export const extractCoreProposalBundles = async ( absolutePaths.bundle = absoluteBundle; const oldSource = bundleToSource.get(absoluteBundle); if (oldSource) { - assert.equal( - oldSource, - absoluteSrc, - X`${bundlePath} already installed from ${oldSource}, now ${absoluteSrc}`, - ); + oldSource === absoluteSrc || + Fail`${bundlePath} already installed from ${oldSource}, now ${absoluteSrc}`; } else { bundleToSource.set(absoluteBundle, absoluteSrc); } From 3e766950651cbbc32ece7f2d7aed7ce164ec673a Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Tue, 9 Jan 2024 18:54:42 -0500 Subject: [PATCH 10/11] chore(deploy-script-support): Apply suggestions from code review --- packages/deploy-script-support/src/extract-proposal.js | 7 ++++++- packages/deploy-script-support/src/writeCoreProposal.js | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/deploy-script-support/src/extract-proposal.js b/packages/deploy-script-support/src/extract-proposal.js index 5827c24a8997..1fb77e553a2e 100644 --- a/packages/deploy-script-support/src/extract-proposal.js +++ b/packages/deploy-script-support/src/extract-proposal.js @@ -250,10 +250,15 @@ export const extractCoreProposalBundles = async ( const metadataRecords = harden(${stringify(metadataRecords, true)}); // Make an enactCoreProposals function and "export" it by way of script completion value. -(( +// It is constructed by an IIFE to ensure the absence of global bindings for +// makeCoreProposalBehavior and makeEnactCoreProposals (the latter referencing the former), +// which may not be necessary but preserves behavior pre-dating +// https://github.com/Agoric/agoric-sdk/pull/8712 . +const enactCoreProposals = (( makeCoreProposalBehavior = ${makeCoreProposalBehavior}, makeEnactCoreProposals = ${makeEnactCoreProposals}, ) => makeEnactCoreProposals({ metadataRecords, E }))(); +enactCoreProposals; `; // console.debug('created bundles from proposals:', coreProposals, bundles); diff --git a/packages/deploy-script-support/src/writeCoreProposal.js b/packages/deploy-script-support/src/writeCoreProposal.js index cee6cf47a912..fab7bd3bffe6 100644 --- a/packages/deploy-script-support/src/writeCoreProposal.js +++ b/packages/deploy-script-support/src/writeCoreProposal.js @@ -153,6 +153,9 @@ const getManifestCall = harden(${stringify(getManifestCall, true)}); const customManifest = ${stringify(customManifest, true)}; // Make a behavior function and "export" it by way of script completion value. +// It is constructed by an anonymous invocation to ensure the absence of a global binding +// for makeCoreProposalBehavior, which may not be necessary but preserves behavior pre-dating +// https://github.com/Agoric/agoric-sdk/pull/8712 . const behavior = (${makeCoreProposalBehavior})({ manifestBundleRef, getManifestCall, customManifest, E }); behavior; `; From 9b97772834a0d96ff3d0cc7c7046ee273bbd2619 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Tue, 9 Jan 2024 18:58:32 -0500 Subject: [PATCH 11/11] chore(deploy-script-support): Lookup the agoricNames installation admin only when necessary --- .../src/coreProposalBehavior.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/deploy-script-support/src/coreProposalBehavior.js b/packages/deploy-script-support/src/coreProposalBehavior.js index d8bb17b01350..a3ed83133097 100644 --- a/packages/deploy-script-support/src/coreProposalBehavior.js +++ b/packages/deploy-script-support/src/coreProposalBehavior.js @@ -158,13 +158,16 @@ export const makeCoreProposalBehavior = ({ ); // Publish the installations for our dependencies. - const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation'); - await Promise.all( - entries(installations || {}).map(([key, value]) => { - produceInstallations[key].resolve(value); - return E(installAdmin).update(key, value); - }), - ); + const installationEntries = entries(installations || {}); + if (installationEntries.length > 0) { + const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation'); + await Promise.all( + installationEntries.map(([key, value]) => { + produceInstallations[key].resolve(value); + return E(installAdmin).update(key, value); + }), + ); + } // Evaluate the manifest. return runModuleBehaviors({