@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 +11 -11
- package/src/extract-proposal.js +64 -44
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/deploy-script-support",
|
|
3
|
-
"version": "0.10.4-dev-
|
|
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-
|
|
38
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
39
|
-
"@agoric/import-manager": "0.3.12-dev-
|
|
40
|
-
"@agoric/internal": "0.3.3-dev-
|
|
41
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
42
|
-
"@agoric/store": "0.9.3-dev-
|
|
43
|
-
"@agoric/time": "0.3.3-dev-
|
|
44
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
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-
|
|
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": "
|
|
72
|
+
"gitHead": "35e67bed9eae0896e32b549ad0d1fd02fb83a905"
|
|
73
73
|
}
|
package/src/extract-proposal.js
CHANGED
|
@@ -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 {
|
|
58
|
-
* @param {
|
|
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
|
-
|
|
64
|
-
getSequenceForProposal,
|
|
78
|
+
opts,
|
|
65
79
|
) => {
|
|
66
|
-
|
|
67
|
-
|
|
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 =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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 =
|
|
192
|
-
|
|
193
|
-
});
|
|
194
|
-
const behaviorAbsolutePaths = harden({
|
|
195
|
-
source: behaviorSource,
|
|
196
|
-
});
|
|
197
|
-
bundleHandleToAbsolutePaths.set(
|
|
211
|
+
const behaviorBundleHandle = {};
|
|
212
|
+
const specEntry = await handleToBundleSpec(
|
|
198
213
|
behaviorBundleHandle,
|
|
199
|
-
|
|
214
|
+
behaviorSource,
|
|
215
|
+
thisProposalSequence,
|
|
216
|
+
'behaviors',
|
|
200
217
|
);
|
|
218
|
+
bundleSpecEntries.unshift(specEntry);
|
|
201
219
|
|
|
202
|
-
|
|
203
|
-
behaviorBundleHandle
|
|
204
|
-
{
|
|
205
|
-
|
|
220
|
+
bundleHandleToAbsolutePaths.set(
|
|
221
|
+
behaviorBundleHandle,
|
|
222
|
+
harden({
|
|
223
|
+
source: behaviorSource,
|
|
224
|
+
}),
|
|
225
|
+
);
|
|
206
226
|
|
|
207
227
|
return harden({
|
|
208
228
|
ref: behaviorBundleHandle,
|