@agoric/deploy-script-support 0.10.4-dev-82d3548.0 → 0.10.4-dev-ba2f0d9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/deploy-script-support",
3
- "version": "0.10.4-dev-82d3548.0+82d3548",
3
+ "version": "0.10.4-dev-ba2f0d9.0+ba2f0d9",
4
4
  "description": "Helpers and other support for writing deploy scripts",
5
5
  "type": "module",
6
6
  "main": "src/helpers.js",
@@ -34,14 +34,14 @@
34
34
  },
35
35
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
36
36
  "dependencies": {
37
- "@agoric/assert": "0.6.1-dev-82d3548.0+82d3548",
38
- "@agoric/ertp": "0.16.3-dev-82d3548.0+82d3548",
39
- "@agoric/import-manager": "0.3.12-dev-82d3548.0+82d3548",
40
- "@agoric/internal": "0.3.3-dev-82d3548.0+82d3548",
41
- "@agoric/notifier": "0.6.3-dev-82d3548.0+82d3548",
42
- "@agoric/store": "0.9.3-dev-82d3548.0+82d3548",
43
- "@agoric/time": "0.3.3-dev-82d3548.0+82d3548",
44
- "@agoric/zoe": "0.26.3-dev-82d3548.0+82d3548",
37
+ "@agoric/assert": "0.6.1-dev-ba2f0d9.0+ba2f0d9",
38
+ "@agoric/ertp": "0.16.3-dev-ba2f0d9.0+ba2f0d9",
39
+ "@agoric/import-manager": "0.3.12-dev-ba2f0d9.0+ba2f0d9",
40
+ "@agoric/internal": "0.3.3-dev-ba2f0d9.0+ba2f0d9",
41
+ "@agoric/notifier": "0.6.3-dev-ba2f0d9.0+ba2f0d9",
42
+ "@agoric/store": "0.9.3-dev-ba2f0d9.0+ba2f0d9",
43
+ "@agoric/time": "0.3.3-dev-ba2f0d9.0+ba2f0d9",
44
+ "@agoric/zoe": "0.26.3-dev-ba2f0d9.0+ba2f0d9",
45
45
  "@endo/base64": "^1.0.0",
46
46
  "@endo/bundle-source": "^3.0.1",
47
47
  "@endo/far": "^1.0.1",
@@ -51,7 +51,7 @@
51
51
  "@endo/zip": "^1.0.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@agoric/vats": "0.15.2-dev-82d3548.0+82d3548",
54
+ "@agoric/vats": "0.15.2-dev-ba2f0d9.0+ba2f0d9",
55
55
  "@endo/init": "^1.0.1",
56
56
  "ava": "^5.3.0",
57
57
  "import-meta-resolve": "^2.2.1"
@@ -75,5 +75,5 @@
75
75
  "typeCoverage": {
76
76
  "atLeast": 80.06
77
77
  },
78
- "gitHead": "82d35483fc88a1ec5c873ead92c215bba1372731"
78
+ "gitHead": "ba2f0d94e904cef1fdbf93c84a81fdf7005fb3be"
79
79
  }
@@ -8,6 +8,12 @@ const t = 'makeCoreProposalBehavior';
8
8
  * @typedef {*} BootstrapPowers
9
9
  */
10
10
 
11
+ /**
12
+ * @typedef {import('./externalTypes.js').ManifestBundleRef} ManifestBundleRef
13
+ * @typedef {[methodName: string, ...args: unknown[]]} FlatMethargs
14
+ * @typedef {Record<string, Record<string, unknown>>} Manifest
15
+ */
16
+
11
17
  /**
12
18
  * These permits are expected to be the minimum powers required by the
13
19
  * `coreProposalBehavior` function returned from `makeCoreProposalBehavior`.
@@ -30,22 +36,22 @@ export const permits = {
30
36
  * for catching bugs. Thus, this maker must not reference any other modules or
31
37
  * definitions.
32
38
  *
33
- * @param {object} opts
34
- * @param {import('./externalTypes.js').ManifestBundleRef} opts.manifestBundleRef
35
- * @param {[methodName: string, ...args: unknown[]]} opts.getManifestCall
36
- * @param {Record<string, Record<string, unknown>>} [opts.overrideManifest]
37
- * @param {typeof import('@endo/far').E} opts.E
38
- * @param {(...args: unknown[]) => void} [opts.log]
39
- * @param {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise<import('@agoric/zoe/src/zoeService/utils.js').Installation<unknown>>} [opts.restoreRef]
39
+ * @param {object} inputs
40
+ * @param {ManifestBundleRef} inputs.manifestBundleRef
41
+ * @param {FlatMethargs} inputs.getManifestCall
42
+ * @param {Manifest} [inputs.customManifest]
43
+ * @param {typeof import('@endo/far').E} inputs.E
44
+ * @param {(...args: unknown[]) => void} [inputs.log]
45
+ * @param {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise<import('@agoric/zoe/src/zoeService/utils.js').Installation<unknown>>} [inputs.customRestoreRef]
40
46
  * @returns {(vatPowers: unknown) => Promise<unknown>}
41
47
  */
42
48
  export const makeCoreProposalBehavior = ({
43
49
  manifestBundleRef,
44
50
  getManifestCall: [manifestGetterName, ...manifestGetterArgs],
45
- overrideManifest,
51
+ customManifest,
46
52
  E,
47
53
  log = console.info,
48
- restoreRef: overrideRestoreRef,
54
+ customRestoreRef,
49
55
  }) => {
50
56
  const { entries, fromEntries } = Object;
51
57
 
@@ -136,7 +142,7 @@ export const makeCoreProposalBehavior = ({
136
142
  manifestGetterName,
137
143
  bundleExports: Object.keys(proposalNS),
138
144
  });
139
- const restoreRef = overrideRestoreRef || makeRestoreRef(vatAdminSvc, zoe);
145
+ const restoreRef = customRestoreRef || makeRestoreRef(vatAdminSvc, zoe);
140
146
  const {
141
147
  manifest,
142
148
  options: rawOptions,
@@ -152,20 +158,23 @@ export const makeCoreProposalBehavior = ({
152
158
  );
153
159
 
154
160
  // Publish the installations for our dependencies.
155
- const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation');
156
- await Promise.all(
157
- entries(installations || {}).map(([key, value]) => {
158
- produceInstallations[key].resolve(value);
159
- return E(installAdmin).update(key, value);
160
- }),
161
- );
161
+ const installationEntries = entries(installations || {});
162
+ if (installationEntries.length > 0) {
163
+ const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation');
164
+ await Promise.all(
165
+ installationEntries.map(([key, value]) => {
166
+ produceInstallations[key].resolve(value);
167
+ return E(installAdmin).update(key, value);
168
+ }),
169
+ );
170
+ }
162
171
 
163
172
  // Evaluate the manifest.
164
173
  return runModuleBehaviors({
165
174
  // Remember that `powers` may be arbitrarily broad.
166
175
  allPowers: powers,
167
176
  behaviors: proposalNS,
168
- manifest: overrideManifest || manifest,
177
+ manifest: customManifest || manifest,
169
178
  makeConfig: (name, _permit) => {
170
179
  log('coreProposal:', name);
171
180
  return { options };
@@ -176,18 +185,28 @@ export const makeCoreProposalBehavior = ({
176
185
  return coreProposalBehavior;
177
186
  };
178
187
 
179
- export const makeEnactCoreProposalsFromBundleRef =
180
- ({ makeCoreProposalArgs, E }) =>
181
- async powers => {
188
+ /**
189
+ * @param {object} inputs
190
+ * @param {Array<{ ref: ManifestBundleRef, call: FlatMethargs, customManifest?: Manifest }>} inputs.metadataRecords
191
+ * @param {typeof import('@endo/far').E} inputs.E
192
+ */
193
+ export const makeEnactCoreProposalsFromBundleRef = ({ metadataRecords, E }) => {
194
+ /**
195
+ * @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} powers
196
+ * @returns {Promise<void>}
197
+ */
198
+ const enactCoreProposals = async powers => {
182
199
  await Promise.all(
183
- makeCoreProposalArgs.map(async ({ ref, call, overrideManifest }) => {
200
+ metadataRecords.map(async ({ ref, call, customManifest }) => {
184
201
  const coreProposalBehavior = makeCoreProposalBehavior({
185
202
  manifestBundleRef: ref,
186
203
  getManifestCall: call,
187
- overrideManifest,
204
+ customManifest,
188
205
  E,
189
206
  });
190
207
  return coreProposalBehavior(powers);
191
208
  }),
192
209
  );
193
210
  };
211
+ return enactCoreProposals;
212
+ };
@@ -14,7 +14,7 @@ import {
14
14
  * @typedef {string | { module: string, entrypoint: string, args?: Array<unknown> }} ConfigProposal
15
15
  */
16
16
 
17
- const { details: X, Fail } = assert;
17
+ const { Fail } = assert;
18
18
 
19
19
  const req = createRequire(import.meta.url);
20
20
 
@@ -24,8 +24,8 @@ const req = createRequire(import.meta.url);
24
24
  * @typedef {string} FilePath
25
25
  */
26
26
  const pathResolve = (...paths) => {
27
- const fileName = paths.pop();
28
- assert(fileName, '>=1 paths required');
27
+ const fileName = /** @type {string} */ (paths.pop());
28
+ fileName || Fail`base name required`;
29
29
  try {
30
30
  return req.resolve(fileName, {
31
31
  paths,
@@ -132,11 +132,8 @@ export const extractCoreProposalBundles = async (
132
132
  absolutePaths.bundle = absoluteBundle;
133
133
  const oldSource = bundleToSource.get(absoluteBundle);
134
134
  if (oldSource) {
135
- assert.equal(
136
- oldSource,
137
- absoluteSrc,
138
- X`${bundlePath} already installed from ${oldSource}, now ${absoluteSrc}`,
139
- );
135
+ oldSource === absoluteSrc ||
136
+ Fail`${bundlePath} already installed from ${oldSource}, now ${absoluteSrc}`;
140
137
  } else {
141
138
  bundleToSource.set(absoluteBundle, absoluteSrc);
142
139
  }
@@ -197,21 +194,20 @@ export const extractCoreProposalBundles = async (
197
194
  harden(proposal),
198
195
  );
199
196
 
200
- const behaviorSource = pathResolve(initDir, sourceSpec);
201
- const behaviors = await import(behaviorSource);
202
- const [exportedGetManifest, ...manifestArgs] = getManifestCall;
203
- assert(
204
- exportedGetManifest in behaviors,
205
- `behavior ${behaviorSource} missing ${exportedGetManifest}`,
197
+ const proposalSource = pathResolve(initDir, sourceSpec);
198
+ const proposalNS = await import(proposalSource);
199
+ const [manifestGetterName, ...manifestGetterArgs] = getManifestCall;
200
+ manifestGetterName in proposalNS ||
201
+ Fail`proposal ${proposalSource} missing export ${manifestGetterName}`;
202
+ const { manifest: customManifest } = await proposalNS[manifestGetterName](
203
+ harden({ restoreRef: () => null }),
204
+ ...manifestGetterArgs,
206
205
  );
207
- const { manifest: overrideManifest } = await behaviors[
208
- exportedGetManifest
209
- ](harden({ restoreRef: () => null }), ...manifestArgs);
210
206
 
211
207
  const behaviorBundleHandle = {};
212
208
  const specEntry = await handleToBundleSpec(
213
209
  behaviorBundleHandle,
214
- behaviorSource,
210
+ proposalSource,
215
211
  thisProposalSequence,
216
212
  'behaviors',
217
213
  );
@@ -220,14 +216,14 @@ export const extractCoreProposalBundles = async (
220
216
  bundleHandleToAbsolutePaths.set(
221
217
  behaviorBundleHandle,
222
218
  harden({
223
- source: behaviorSource,
219
+ source: proposalSource,
224
220
  }),
225
221
  );
226
222
 
227
223
  return harden({
228
224
  ref: behaviorBundleHandle,
229
225
  call: getManifestCall,
230
- overrideManifest,
226
+ customManifest,
231
227
  bundleSpecs: bundleSpecEntries,
232
228
  });
233
229
  }),
@@ -240,22 +236,29 @@ export const extractCoreProposalBundles = async (
240
236
  harden(bundles);
241
237
 
242
238
  // Extract the manifest references and calls.
243
- const makeCPArgs = extracted.map(({ ref, call, overrideManifest }) => ({
239
+ const metadataRecords = extracted.map(({ ref, call, customManifest }) => ({
244
240
  ref,
245
241
  call,
246
- overrideManifest,
242
+ customManifest,
247
243
  }));
248
- harden(makeCPArgs);
244
+ harden(metadataRecords);
249
245
 
250
246
  const code = `\
251
- // This is generated by @agoric/cosmic-swingset/src/extract-proposal.js - DO NOT EDIT
247
+ // This is generated by @agoric/deploy-script-support/src/extract-proposal.js - DO NOT EDIT
252
248
  /* eslint-disable */
253
249
 
254
- const makeCoreProposalArgs = harden(${stringify(makeCPArgs, true)});
255
-
256
- const makeCoreProposalBehavior = ${makeCoreProposalBehavior};
250
+ const metadataRecords = harden(${stringify(metadataRecords, true)});
257
251
 
258
- (${makeEnactCoreProposals})({ makeCoreProposalArgs, E });
252
+ // Make an enactCoreProposals function and "export" it by way of script completion value.
253
+ // It is constructed by an IIFE to ensure the absence of global bindings for
254
+ // makeCoreProposalBehavior and makeEnactCoreProposals (the latter referencing the former),
255
+ // which may not be necessary but preserves behavior pre-dating
256
+ // https://github.com/Agoric/agoric-sdk/pull/8712 .
257
+ const enactCoreProposals = ((
258
+ makeCoreProposalBehavior = ${makeCoreProposalBehavior},
259
+ makeEnactCoreProposals = ${makeEnactCoreProposals},
260
+ ) => makeEnactCoreProposals({ metadataRecords, E }))();
261
+ enactCoreProposals;
259
262
  `;
260
263
 
261
264
  // console.debug('created bundles from proposals:', coreProposals, bundles);
@@ -51,15 +51,15 @@ export const makeWriteCoreProposal = (
51
51
  const mergeProposalPermit = async (proposal, additionalPermits) => {
52
52
  const {
53
53
  sourceSpec,
54
- getManifestCall: [exportedGetManifest, ...manifestArgs],
54
+ getManifestCall: [manifestGetterName, ...manifestGetterArgs],
55
55
  } = proposal;
56
56
 
57
- const manifestNs = await import(pathResolve(sourceSpec));
57
+ const proposalNS = await import(pathResolve(sourceSpec));
58
58
 
59
59
  // We only care about the manifest, not any restoreRef calls.
60
- const { manifest } = await manifestNs[exportedGetManifest](
61
- { restoreRef: x => `restoreRef:${x}` },
62
- ...manifestArgs,
60
+ const { manifest } = await proposalNS[manifestGetterName](
61
+ harden({ restoreRef: x => `restoreRef:${x}` }),
62
+ ...manifestGetterArgs,
63
63
  );
64
64
 
65
65
  const mergedPermits = mergePermits(manifest);
@@ -98,7 +98,7 @@ export const makeWriteCoreProposal = (
98
98
  *
99
99
  * @param {string} entrypoint
100
100
  * @param {string} [bundlePath]
101
- * @param [opts]
101
+ * @param {unknown} [opts]
102
102
  * @returns {Promise<import('./externalTypes.js').ManifestBundleRef>}
103
103
  */
104
104
  const install = async (entrypoint, bundlePath, opts) => {
@@ -137,7 +137,7 @@ export const makeWriteCoreProposal = (
137
137
  // console.log('created', { filePrefix, sourceSpec, getManifestCall });
138
138
 
139
139
  // Extract the top-level permit.
140
- const { permits: proposalPermit, manifest: overrideManifest } =
140
+ const { permits: proposalPermit, manifest: customManifest } =
141
141
  await mergeProposalPermit(proposal, permits);
142
142
 
143
143
  // Get an install
@@ -150,10 +150,14 @@ export const makeWriteCoreProposal = (
150
150
 
151
151
  const manifestBundleRef = ${stringify(manifestBundleRef)};
152
152
  const getManifestCall = harden(${stringify(getManifestCall, true)});
153
- const overrideManifest = ${stringify(overrideManifest, true)};
154
-
155
- // Make the behavior the completion value.
156
- (${makeCoreProposalBehavior})({ manifestBundleRef, getManifestCall, overrideManifest, E });
153
+ const customManifest = ${stringify(customManifest, true)};
154
+
155
+ // Make a behavior function and "export" it by way of script completion value.
156
+ // It is constructed by an anonymous invocation to ensure the absence of a global binding
157
+ // for makeCoreProposalBehavior, which may not be necessary but preserves behavior pre-dating
158
+ // https://github.com/Agoric/agoric-sdk/pull/8712 .
159
+ const behavior = (${makeCoreProposalBehavior})({ manifestBundleRef, getManifestCall, customManifest, E });
160
+ behavior;
157
161
  `;
158
162
 
159
163
  const trimmed = defangAndTrim(code);