@agoric/deploy-script-support 0.10.4-dev-fed2b5e.0 → 0.10.4-dev-35e67be.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-fed2b5e.0+fed2b5e",
3
+ "version": "0.10.4-dev-35e67be.0+35e67be",
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-fed2b5e.0+fed2b5e",
38
- "@agoric/ertp": "0.16.3-dev-fed2b5e.0+fed2b5e",
39
- "@agoric/import-manager": "0.3.12-dev-fed2b5e.0+fed2b5e",
40
- "@agoric/internal": "0.3.3-dev-fed2b5e.0+fed2b5e",
41
- "@agoric/notifier": "0.6.3-dev-fed2b5e.0+fed2b5e",
42
- "@agoric/store": "0.9.3-dev-fed2b5e.0+fed2b5e",
43
- "@agoric/time": "0.3.3-dev-fed2b5e.0+fed2b5e",
44
- "@agoric/zoe": "0.26.3-dev-fed2b5e.0+fed2b5e",
37
+ "@agoric/assert": "0.6.1-dev-35e67be.0+35e67be",
38
+ "@agoric/ertp": "0.16.3-dev-35e67be.0+35e67be",
39
+ "@agoric/import-manager": "0.3.12-dev-35e67be.0+35e67be",
40
+ "@agoric/internal": "0.3.3-dev-35e67be.0+35e67be",
41
+ "@agoric/notifier": "0.6.3-dev-35e67be.0+35e67be",
42
+ "@agoric/store": "0.9.3-dev-35e67be.0+35e67be",
43
+ "@agoric/time": "0.3.3-dev-35e67be.0+35e67be",
44
+ "@agoric/zoe": "0.26.3-dev-35e67be.0+35e67be",
45
45
  "@endo/base64": "^0.2.32",
46
46
  "@endo/bundle-source": "^2.5.2",
47
47
  "@endo/far": "^0.2.19",
@@ -51,7 +51,7 @@
51
51
  "@endo/zip": "^0.2.32"
52
52
  },
53
53
  "devDependencies": {
54
- "@agoric/vats": "0.15.2-dev-fed2b5e.0+fed2b5e",
54
+ "@agoric/vats": "0.15.2-dev-35e67be.0+35e67be",
55
55
  "@endo/init": "^0.5.57",
56
56
  "ava": "^5.3.0",
57
57
  "import-meta-resolve": "^2.2.1"
@@ -69,5 +69,5 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  },
72
- "gitHead": "fed2b5e4658fc5b55c794622aa1684a8093f1604"
72
+ "gitHead": "35e67bed9eae0896e32b549ad0d1fd02fb83a905"
73
73
  }
@@ -40,6 +40,19 @@ const findModule = (initDir, srcSpec) =>
40
40
  ? pathResolve(initDir, srcSpec)
41
41
  : req.resolve(srcSpec);
42
42
 
43
+ /**
44
+ * @param {{ bundleID?: string, bundleName?: string }} handle - mutated then hardened
45
+ * @param {string} sourceSpec - the specifier of a module to load
46
+ * @param {number} sequence - the sequence number of the proposal
47
+ * @param {string} piece - the piece of the proposal
48
+ * @returns {Promise<[string, any]>}
49
+ */
50
+ const namedHandleToBundleSpec = async (handle, sourceSpec, sequence, piece) => {
51
+ handle.bundleName = `coreProposal${sequence}_${piece}`;
52
+ harden(handle);
53
+ return harden([handle.bundleName, { sourceSpec }]);
54
+ };
55
+
43
56
  /**
44
57
  * Format core proposals to be run at bootstrap:
45
58
  * SwingSet `bundles` configuration
@@ -54,26 +67,28 @@ const findModule = (initDir, srcSpec) =>
54
67
  * @param {ConfigProposal[]} coreProposals - governance
55
68
  * proposals to run at chain bootstrap for scenarios such as sim-chain.
56
69
  * @param {FilePath} [dirname]
57
- * @param {typeof makeEnactCoreProposalsFromBundleRef} [makeEnactCoreProposals]
58
- * @param {(i: number) => number} [getSequenceForProposal]
70
+ * @param {object} [opts]
71
+ * @param {typeof makeEnactCoreProposalsFromBundleRef} [opts.makeEnactCoreProposals]
72
+ * @param {(i: number) => number} [opts.getSequenceForProposal]
73
+ * @param {typeof namedHandleToBundleSpec} [opts.handleToBundleSpec]
59
74
  */
60
75
  export const extractCoreProposalBundles = async (
61
76
  coreProposals,
62
77
  dirname = '.',
63
- makeEnactCoreProposals = makeEnactCoreProposalsFromBundleRef,
64
- getSequenceForProposal,
78
+ opts,
65
79
  ) => {
66
- if (!getSequenceForProposal) {
67
- // Deterministic proposal numbers.
68
- getSequenceForProposal = i => i;
69
- }
80
+ const {
81
+ makeEnactCoreProposals = makeEnactCoreProposalsFromBundleRef,
82
+ getSequenceForProposal = i => i,
83
+ handleToBundleSpec = namedHandleToBundleSpec,
84
+ } = opts || {};
70
85
 
71
86
  dirname = pathResolve(dirname);
72
87
  dirname = await fs.promises
73
88
  .stat(dirname)
74
89
  .then(stbuf => (stbuf.isDirectory() ? dirname : path.dirname(dirname)));
75
90
 
76
- /** @type {Map<{ bundleName?: string }, { source: string, bundle?: string }>} */
91
+ /** @type {Map<{ bundleID?: string, bundleName?: string }, { source: string, bundle?: string }>} */
77
92
  const bundleHandleToAbsolutePaths = new Map();
78
93
 
79
94
  const bundleToSource = new Map();
@@ -151,29 +166,30 @@ export const extractCoreProposalBundles = async (
151
166
  );
152
167
 
153
168
  // Add the proposal bundle handles in sorted order.
154
- const bundleSpecEntries = [...thisProposalBundleHandles.keys()]
155
- .map(handle => [handle, bundleHandleToAbsolutePaths.get(handle)])
156
- .sort(([_hnda, { source: a }], [_hndb, { source: b }]) => {
157
- if (a < b) {
158
- return -1;
159
- }
160
- if (a > b) {
161
- return 1;
162
- }
163
- return 0;
164
- })
165
- .map(([handle, absolutePaths], j) => {
166
- // Transform the bundle handle identity into a bundleName reference.
167
- handle.bundleName = `coreProposal${thisProposalSequence}_${j}`;
168
- harden(handle);
169
-
170
- /** @type {[string, { sourceSpec: string }]} */
171
- const specEntry = [
172
- handle.bundleName,
173
- { sourceSpec: absolutePaths.source },
174
- ];
175
- return specEntry;
176
- });
169
+ const bundleSpecEntries = await Promise.all(
170
+ [...thisProposalBundleHandles.keys()]
171
+ .map(handle => [handle, bundleHandleToAbsolutePaths.get(handle)])
172
+ .sort(([_hnda, { source: a }], [_hndb, { source: b }]) => {
173
+ if (a < b) {
174
+ return -1;
175
+ }
176
+ if (a > b) {
177
+ return 1;
178
+ }
179
+ return 0;
180
+ })
181
+ .map(async ([handle, absolutePaths], j) => {
182
+ // Transform the bundle handle identity into a bundleName reference.
183
+ const specEntry = await handleToBundleSpec(
184
+ handle,
185
+ absolutePaths.source,
186
+ thisProposalSequence,
187
+ String(j),
188
+ );
189
+ harden(handle);
190
+ return specEntry;
191
+ }),
192
+ );
177
193
 
178
194
  // Now that we've assigned all the bundleNames and hardened the
179
195
  // handles, we can extract the behavior bundle.
@@ -184,25 +200,29 @@ export const extractCoreProposalBundles = async (
184
200
  const behaviorSource = pathResolve(initDir, sourceSpec);
185
201
  const behaviors = await import(behaviorSource);
186
202
  const [exportedGetManifest, ...manifestArgs] = getManifestCall;
203
+ assert(
204
+ exportedGetManifest in behaviors,
205
+ `behavior ${behaviorSource} missing ${exportedGetManifest}`,
206
+ );
187
207
  const { manifest: overrideManifest } = await behaviors[
188
208
  exportedGetManifest
189
209
  ](harden({ restoreRef: () => null }), ...manifestArgs);
190
210
 
191
- const behaviorBundleHandle = harden({
192
- bundleName: `coreProposal${thisProposalSequence}_behaviors`,
193
- });
194
- const behaviorAbsolutePaths = harden({
195
- source: behaviorSource,
196
- });
197
- bundleHandleToAbsolutePaths.set(
211
+ const behaviorBundleHandle = {};
212
+ const specEntry = await handleToBundleSpec(
198
213
  behaviorBundleHandle,
199
- behaviorAbsolutePaths,
214
+ behaviorSource,
215
+ thisProposalSequence,
216
+ 'behaviors',
200
217
  );
218
+ bundleSpecEntries.unshift(specEntry);
201
219
 
202
- bundleSpecEntries.unshift([
203
- behaviorBundleHandle.bundleName,
204
- { sourceSpec: behaviorAbsolutePaths.source },
205
- ]);
220
+ bundleHandleToAbsolutePaths.set(
221
+ behaviorBundleHandle,
222
+ harden({
223
+ source: behaviorSource,
224
+ }),
225
+ );
206
226
 
207
227
  return harden({
208
228
  ref: behaviorBundleHandle,