@agoric/deploy-script-support 0.10.4-mainnet1B-dev-26244e8.0 → 0.10.4-orchestration-dev-096c4e8.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/exported.js +0 -2
- package/package.json +27 -20
- package/src/coreProposalBehavior.js +117 -64
- package/src/endo-pieces-contract.js +3 -0
- package/src/externalTypes.js +9 -10
- package/src/extract-proposal.js +232 -154
- package/src/getBundlerMaker.js +4 -0
- package/src/helpers.js +4 -1
- package/src/install.js +2 -11
- package/src/offer.js +5 -6
- package/src/saveIssuer.js +2 -2
- package/src/startInstance.js +3 -4
- package/src/writeCoreProposal.js +76 -14
- package/CHANGELOG.md +0 -563
package/src/writeCoreProposal.js
CHANGED
|
@@ -7,6 +7,25 @@ import { createBundles } from '@agoric/internal/src/node/createBundles.js';
|
|
|
7
7
|
import { defangAndTrim, mergePermits, stringify } from './code-gen.js';
|
|
8
8
|
import { makeCoreProposalBehavior, permits } from './coreProposalBehavior.js';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @callback WriteCoreProposal
|
|
12
|
+
* @param {string} filePrefix
|
|
13
|
+
* @param {import('./externalTypes.js').ProposalBuilder} proposalBuilder
|
|
14
|
+
* @returns {Promise<void>}
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {*} homeP
|
|
20
|
+
* @param {*} endowments
|
|
21
|
+
* @param {{
|
|
22
|
+
* getBundlerMaker: () => Promise<import('./getBundlerMaker.js').BundleMaker>,
|
|
23
|
+
* getBundleSpec: (...args: *) => Promise<import('./externalTypes.js').ManifestBundleRef>,
|
|
24
|
+
* log?: typeof console.log,
|
|
25
|
+
* writeFile?: typeof fs.promises.writeFile
|
|
26
|
+
* }} io
|
|
27
|
+
* @returns {WriteCoreProposal}
|
|
28
|
+
*/
|
|
10
29
|
export const makeWriteCoreProposal = (
|
|
11
30
|
homeP,
|
|
12
31
|
endowments,
|
|
@@ -20,6 +39,7 @@ export const makeWriteCoreProposal = (
|
|
|
20
39
|
const { bundleSource, pathResolve } = endowments;
|
|
21
40
|
|
|
22
41
|
let bundlerCache;
|
|
42
|
+
/** @returns {import('./getBundlerMaker.js').Bundler} */
|
|
23
43
|
const getBundler = () => {
|
|
24
44
|
if (!bundlerCache) {
|
|
25
45
|
bundlerCache = E(getBundlerMaker()).makeBundler({
|
|
@@ -32,15 +52,15 @@ export const makeWriteCoreProposal = (
|
|
|
32
52
|
const mergeProposalPermit = async (proposal, additionalPermits) => {
|
|
33
53
|
const {
|
|
34
54
|
sourceSpec,
|
|
35
|
-
getManifestCall: [
|
|
55
|
+
getManifestCall: [manifestGetterName, ...manifestGetterArgs],
|
|
36
56
|
} = proposal;
|
|
37
57
|
|
|
38
|
-
const
|
|
58
|
+
const proposalNS = await import(pathResolve(sourceSpec));
|
|
39
59
|
|
|
40
60
|
// We only care about the manifest, not any restoreRef calls.
|
|
41
|
-
const { manifest } = await
|
|
42
|
-
{ restoreRef: x => `restoreRef:${x}` },
|
|
43
|
-
...
|
|
61
|
+
const { manifest } = await proposalNS[manifestGetterName](
|
|
62
|
+
harden({ restoreRef: x => `restoreRef:${x}` }),
|
|
63
|
+
...manifestGetterArgs,
|
|
44
64
|
);
|
|
45
65
|
|
|
46
66
|
const mergedPermits = mergePermits(manifest);
|
|
@@ -50,8 +70,18 @@ export const makeWriteCoreProposal = (
|
|
|
50
70
|
};
|
|
51
71
|
};
|
|
52
72
|
|
|
53
|
-
let mutex =
|
|
73
|
+
let mutex =
|
|
74
|
+
/** @type {Promise<import('./externalTypes.js').ManifestBundleRef | undefined>} */ (
|
|
75
|
+
Promise.resolve()
|
|
76
|
+
);
|
|
77
|
+
/** @type {WriteCoreProposal} */
|
|
54
78
|
const writeCoreProposal = async (filePrefix, proposalBuilder) => {
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param {string} entrypoint
|
|
82
|
+
* @param {string} [bundlePath]
|
|
83
|
+
* @returns {Promise<NodeModule>}
|
|
84
|
+
*/
|
|
55
85
|
const getBundle = async (entrypoint, bundlePath) => {
|
|
56
86
|
if (!bundlePath) {
|
|
57
87
|
return bundleSource(pathResolve(entrypoint));
|
|
@@ -62,20 +92,36 @@ export const makeWriteCoreProposal = (
|
|
|
62
92
|
return ns.default;
|
|
63
93
|
};
|
|
64
94
|
|
|
65
|
-
|
|
95
|
+
const bundles = [];
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Install an entrypoint.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} entrypoint
|
|
101
|
+
* @param {string} [bundlePath]
|
|
102
|
+
* @param {unknown} [opts]
|
|
103
|
+
* @returns {Promise<import('./externalTypes.js').ManifestBundleRef>}
|
|
104
|
+
*/
|
|
66
105
|
const install = async (entrypoint, bundlePath, opts) => {
|
|
67
106
|
const bundle = getBundle(entrypoint, bundlePath);
|
|
68
107
|
|
|
69
108
|
// Serialise the installations.
|
|
70
|
-
mutex = E.when(mutex, () => {
|
|
109
|
+
mutex = E.when(mutex, async () => {
|
|
71
110
|
// console.log('installing', { filePrefix, entrypoint, bundlePath });
|
|
72
|
-
|
|
111
|
+
const spec = await getBundleSpec(bundle, getBundler, opts);
|
|
112
|
+
bundles.push({
|
|
113
|
+
entrypoint,
|
|
114
|
+
...spec,
|
|
115
|
+
});
|
|
116
|
+
return spec;
|
|
73
117
|
});
|
|
118
|
+
// @ts-expect-error xxx mutex type narrowing
|
|
74
119
|
return mutex;
|
|
75
120
|
};
|
|
76
121
|
|
|
77
122
|
// Await a reference then publish to the board.
|
|
78
123
|
const cmds = [];
|
|
124
|
+
/** @param {Promise<import('./externalTypes.js').ManifestBundleRef>} refP */
|
|
79
125
|
const publishRef = async refP => {
|
|
80
126
|
const { fileName, ...ref } = await refP;
|
|
81
127
|
if (fileName) {
|
|
@@ -93,7 +139,7 @@ export const makeWriteCoreProposal = (
|
|
|
93
139
|
// console.log('created', { filePrefix, sourceSpec, getManifestCall });
|
|
94
140
|
|
|
95
141
|
// Extract the top-level permit.
|
|
96
|
-
const { permits: proposalPermit, manifest:
|
|
142
|
+
const { permits: proposalPermit, manifest: customManifest } =
|
|
97
143
|
await mergeProposalPermit(proposal, permits);
|
|
98
144
|
|
|
99
145
|
// Get an install
|
|
@@ -106,10 +152,14 @@ export const makeWriteCoreProposal = (
|
|
|
106
152
|
|
|
107
153
|
const manifestBundleRef = ${stringify(manifestBundleRef)};
|
|
108
154
|
const getManifestCall = harden(${stringify(getManifestCall, true)});
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
// Make
|
|
112
|
-
|
|
155
|
+
const customManifest = ${stringify(customManifest, true)};
|
|
156
|
+
|
|
157
|
+
// Make a behavior function and "export" it by way of script completion value.
|
|
158
|
+
// It is constructed by an anonymous invocation to ensure the absence of a global binding
|
|
159
|
+
// for makeCoreProposalBehavior, which may not be necessary but preserves behavior pre-dating
|
|
160
|
+
// https://github.com/Agoric/agoric-sdk/pull/8712 .
|
|
161
|
+
const behavior = (${makeCoreProposalBehavior})({ manifestBundleRef, getManifestCall, customManifest, E });
|
|
162
|
+
behavior;
|
|
113
163
|
`;
|
|
114
164
|
|
|
115
165
|
const trimmed = defangAndTrim(code);
|
|
@@ -125,6 +175,18 @@ const overrideManifest = ${stringify(overrideManifest, true)};
|
|
|
125
175
|
log(`creating ${proposalJsFile}`);
|
|
126
176
|
await writeFile(proposalJsFile, trimmed);
|
|
127
177
|
|
|
178
|
+
const plan = {
|
|
179
|
+
name: filePrefix,
|
|
180
|
+
script: proposalJsFile,
|
|
181
|
+
permit: proposalPermitJsonFile,
|
|
182
|
+
bundles,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
await writeFile(
|
|
186
|
+
`${filePrefix}-plan.json`,
|
|
187
|
+
`${JSON.stringify(plan, null, 2)}\n`,
|
|
188
|
+
);
|
|
189
|
+
|
|
128
190
|
log(`\
|
|
129
191
|
You can now run a governance submission command like:
|
|
130
192
|
agd tx gov submit-proposal swingset-core-eval ${proposalPermitJsonFile} ${proposalJsFile} \\
|