@agoric/deploy-script-support 0.10.3 → 0.10.4-calypso-dev-84eb287.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/README.md +106 -2
- package/package.json +30 -24
- package/src/coreProposalBehavior.js +121 -64
- package/src/endo-pieces-contract.js +3 -0
- package/src/externalTypes.js +20 -17
- package/src/extract-proposal.js +235 -154
- package/src/getBundlerMaker.js +4 -0
- package/src/helpers.js +13 -3
- 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/writeCoreEvalParts.js +227 -0
- package/CHANGELOG.md +0 -538
- package/exported.js +0 -3
- package/src/writeCoreProposal.js +0 -139
package/src/extract-proposal.js
CHANGED
|
@@ -11,21 +11,47 @@ import {
|
|
|
11
11
|
} from './coreProposalBehavior.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* @typedef {string | {
|
|
14
|
+
* @typedef {string | {module: string, entrypoint?: string, args?: Array<unknown>}} ConfigProposal
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {{steps: ConfigProposal[][]}} SequentialCoreProposals
|
|
19
|
+
* @typedef {ConfigProposal[] | SequentialCoreProposals} CoreProposals
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const { Fail } = assert;
|
|
18
23
|
|
|
19
24
|
const req = createRequire(import.meta.url);
|
|
20
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @param {...(CoreProposals | undefined | null)} args
|
|
28
|
+
* @returns {SequentialCoreProposals}
|
|
29
|
+
*/
|
|
30
|
+
export const mergeCoreProposals = (...args) => {
|
|
31
|
+
/** @type {ConfigProposal[][]} */
|
|
32
|
+
const steps = [];
|
|
33
|
+
for (const coreProposal of args) {
|
|
34
|
+
if (!coreProposal) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if ('steps' in coreProposal) {
|
|
38
|
+
steps.push(...coreProposal.steps);
|
|
39
|
+
} else {
|
|
40
|
+
steps.push(coreProposal);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return harden({ steps });
|
|
44
|
+
};
|
|
45
|
+
harden(mergeCoreProposals);
|
|
46
|
+
|
|
21
47
|
/**
|
|
22
48
|
* @param {(ModuleSpecifier | FilePath)[]} paths
|
|
23
49
|
* @typedef {string} ModuleSpecifier
|
|
24
50
|
* @typedef {string} FilePath
|
|
25
51
|
*/
|
|
26
52
|
const pathResolve = (...paths) => {
|
|
27
|
-
const fileName = paths.pop();
|
|
28
|
-
|
|
53
|
+
const fileName = /** @type {string} */ (paths.pop());
|
|
54
|
+
fileName || Fail`base name required`;
|
|
29
55
|
try {
|
|
30
56
|
return req.resolve(fileName, {
|
|
31
57
|
paths,
|
|
@@ -35,6 +61,24 @@ const pathResolve = (...paths) => {
|
|
|
35
61
|
}
|
|
36
62
|
};
|
|
37
63
|
|
|
64
|
+
const findModule = (initDir, srcSpec) =>
|
|
65
|
+
srcSpec.match(/^(\.\.?)?\//)
|
|
66
|
+
? pathResolve(initDir, srcSpec)
|
|
67
|
+
: req.resolve(srcSpec);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {{ bundleID?: string, bundleName?: string }} handle - mutated then hardened
|
|
71
|
+
* @param {string} sourceSpec - the specifier of a module to load
|
|
72
|
+
* @param {string} key - the key of the proposal
|
|
73
|
+
* @param {string} piece - the piece of the proposal
|
|
74
|
+
* @returns {Promise<[string, any]>}
|
|
75
|
+
*/
|
|
76
|
+
const namedHandleToBundleSpec = async (handle, sourceSpec, key, piece) => {
|
|
77
|
+
handle.bundleName = `coreProposal${String(key)}_${piece}`;
|
|
78
|
+
harden(handle);
|
|
79
|
+
return harden([handle.bundleName, { sourceSpec }]);
|
|
80
|
+
};
|
|
81
|
+
|
|
38
82
|
/**
|
|
39
83
|
* Format core proposals to be run at bootstrap:
|
|
40
84
|
* SwingSet `bundles` configuration
|
|
@@ -46,188 +90,225 @@ const pathResolve = (...paths) => {
|
|
|
46
90
|
* but for sim-chain and such, they can be declared statically in
|
|
47
91
|
* the chain configuration, in which case they are run at bootstrap.
|
|
48
92
|
*
|
|
49
|
-
* @param {
|
|
93
|
+
* @param {CoreProposals} coreProposals - governance
|
|
50
94
|
* proposals to run at chain bootstrap for scenarios such as sim-chain.
|
|
51
95
|
* @param {FilePath} [dirname]
|
|
52
|
-
* @param {
|
|
53
|
-
* @param {
|
|
96
|
+
* @param {object} [opts]
|
|
97
|
+
* @param {typeof makeEnactCoreProposalsFromBundleRef} [opts.makeEnactCoreProposals]
|
|
98
|
+
* @param {(key: PropertyKey) => PropertyKey} [opts.getSequenceForProposal]
|
|
99
|
+
* @param {typeof namedHandleToBundleSpec} [opts.handleToBundleSpec]
|
|
54
100
|
*/
|
|
55
101
|
export const extractCoreProposalBundles = async (
|
|
56
102
|
coreProposals,
|
|
57
103
|
dirname = '.',
|
|
58
|
-
|
|
59
|
-
getSequenceForProposal,
|
|
104
|
+
opts,
|
|
60
105
|
) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
getSequenceForProposal =
|
|
64
|
-
|
|
106
|
+
const {
|
|
107
|
+
makeEnactCoreProposals = makeEnactCoreProposalsFromBundleRef,
|
|
108
|
+
getSequenceForProposal = key => key,
|
|
109
|
+
handleToBundleSpec = namedHandleToBundleSpec,
|
|
110
|
+
} = opts || {};
|
|
65
111
|
|
|
66
112
|
dirname = pathResolve(dirname);
|
|
67
113
|
dirname = await fs.promises
|
|
68
114
|
.stat(dirname)
|
|
69
115
|
.then(stbuf => (stbuf.isDirectory() ? dirname : path.dirname(dirname)));
|
|
70
116
|
|
|
71
|
-
/** @type {Map<{ bundleName?: string }, { source: string, bundle?: string }>} */
|
|
117
|
+
/** @type {Map<{ bundleID?: string, bundleName?: string }, { source: string, bundle?: string }>} */
|
|
72
118
|
const bundleHandleToAbsolutePaths = new Map();
|
|
73
119
|
|
|
120
|
+
const proposalSteps =
|
|
121
|
+
'steps' in coreProposals ? coreProposals.steps : [coreProposals];
|
|
74
122
|
const bundleToSource = new Map();
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
typeof module === 'string' ||
|
|
94
|
-
Fail`coreProposal module ${module} must be string`;
|
|
95
|
-
typeof entrypoint === 'string' ||
|
|
96
|
-
Fail`coreProposal entrypoint ${entrypoint} must be string`;
|
|
97
|
-
Array.isArray(args) || Fail`coreProposal args ${args} must be array`;
|
|
98
|
-
|
|
99
|
-
const thisProposalBundleHandles = new Set();
|
|
100
|
-
assert(getSequenceForProposal);
|
|
101
|
-
const thisProposalSequence = getSequenceForProposal(i);
|
|
102
|
-
const initPath = pathResolve(dirname, module);
|
|
103
|
-
const initDir = path.dirname(initPath);
|
|
104
|
-
/** @type {Record<string, import('./externalTypes.js').ProposalBuilder>} */
|
|
105
|
-
const ns = await import(initPath);
|
|
106
|
-
const install = (srcSpec, bundlePath) => {
|
|
107
|
-
const absoluteSrc = pathResolve(initDir, srcSpec);
|
|
108
|
-
const bundleHandle = {};
|
|
109
|
-
const absolutePaths = { source: absoluteSrc };
|
|
110
|
-
if (bundlePath) {
|
|
111
|
-
const absoluteBundle = pathResolve(initDir, bundlePath);
|
|
112
|
-
absolutePaths.bundle = absoluteBundle;
|
|
113
|
-
const oldSource = bundleToSource.get(absoluteBundle);
|
|
114
|
-
if (oldSource) {
|
|
115
|
-
assert.equal(
|
|
116
|
-
oldSource,
|
|
117
|
-
absoluteSrc,
|
|
118
|
-
X`${bundlePath} already installed from ${oldSource}, now ${absoluteSrc}`,
|
|
119
|
-
);
|
|
123
|
+
const extractedSteps = await Promise.all(
|
|
124
|
+
proposalSteps.map((proposalStep, i) =>
|
|
125
|
+
Promise.all(
|
|
126
|
+
proposalStep.map(async (coreProposal, j) => {
|
|
127
|
+
const key = `${i}.${j}`;
|
|
128
|
+
// console.debug(`Parsing core proposal:`, coreProposal);
|
|
129
|
+
|
|
130
|
+
/** @type {string} */
|
|
131
|
+
let entrypoint;
|
|
132
|
+
/** @type {unknown[]} */
|
|
133
|
+
let args;
|
|
134
|
+
/** @type {string} */
|
|
135
|
+
let module;
|
|
136
|
+
if (typeof coreProposal === 'string') {
|
|
137
|
+
module = coreProposal;
|
|
138
|
+
entrypoint = 'defaultProposalBuilder';
|
|
139
|
+
args = [];
|
|
120
140
|
} else {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
thisProposalBundleHandles.add(bundleHandle);
|
|
127
|
-
bundleHandleToAbsolutePaths.set(bundleHandle, harden(absolutePaths));
|
|
128
|
-
return bundleHandle;
|
|
129
|
-
};
|
|
130
|
-
/** @type {import('./externalTypes.js').PublishBundleRef} */
|
|
131
|
-
const publishRef = async handleP => {
|
|
132
|
-
const handle = await handleP;
|
|
133
|
-
bundleHandleToAbsolutePaths.has(handle) ||
|
|
134
|
-
Fail`${handle} not in installed bundles`;
|
|
135
|
-
return handle;
|
|
136
|
-
};
|
|
137
|
-
const proposal = await ns[entrypoint]({ publishRef, install }, ...args);
|
|
138
|
-
|
|
139
|
-
// Add the proposal bundle handles in sorted order.
|
|
140
|
-
const bundleSpecEntries = [...thisProposalBundleHandles.keys()]
|
|
141
|
-
.map(handle => [handle, bundleHandleToAbsolutePaths.get(handle)])
|
|
142
|
-
.sort(([_hnda, { source: a }], [_hndb, { source: b }]) => {
|
|
143
|
-
if (a < b) {
|
|
144
|
-
return -1;
|
|
141
|
+
({
|
|
142
|
+
module,
|
|
143
|
+
entrypoint = 'defaultProposalBuilder',
|
|
144
|
+
args = [],
|
|
145
|
+
} = coreProposal);
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
147
|
+
|
|
148
|
+
typeof module === 'string' ||
|
|
149
|
+
Fail`coreProposal module ${module} must be string`;
|
|
150
|
+
typeof entrypoint === 'string' ||
|
|
151
|
+
Fail`coreProposal entrypoint ${entrypoint} must be string`;
|
|
152
|
+
Array.isArray(args) || Fail`coreProposal args ${args} must be array`;
|
|
153
|
+
|
|
154
|
+
const thisProposalBundleHandles = new Set();
|
|
155
|
+
assert(getSequenceForProposal);
|
|
156
|
+
const thisProposalSequence = getSequenceForProposal(key);
|
|
157
|
+
const initPath = findModule(dirname, module);
|
|
158
|
+
const initDir = path.dirname(initPath);
|
|
159
|
+
/** @type {Record<string, import('./externalTypes.js').CoreEvalBuilder>} */
|
|
160
|
+
const ns = await import(initPath);
|
|
161
|
+
const install = (srcSpec, bundlePath) => {
|
|
162
|
+
const absoluteSrc = findModule(initDir, srcSpec);
|
|
163
|
+
const bundleHandle = {};
|
|
164
|
+
const absolutePaths = { source: absoluteSrc };
|
|
165
|
+
if (bundlePath) {
|
|
166
|
+
const absoluteBundle = pathResolve(initDir, bundlePath);
|
|
167
|
+
absolutePaths.bundle = absoluteBundle;
|
|
168
|
+
const oldSource = bundleToSource.get(absoluteBundle);
|
|
169
|
+
if (oldSource) {
|
|
170
|
+
oldSource === absoluteSrc ||
|
|
171
|
+
Fail`${bundlePath} already installed from ${oldSource}, now ${absoluteSrc}`;
|
|
172
|
+
} else {
|
|
173
|
+
bundleToSource.set(absoluteBundle, absoluteSrc);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// Don't harden the bundleHandle since we need to set the bundleName on
|
|
177
|
+
// its unique identity later.
|
|
178
|
+
thisProposalBundleHandles.add(bundleHandle);
|
|
179
|
+
bundleHandleToAbsolutePaths.set(
|
|
180
|
+
bundleHandle,
|
|
181
|
+
harden(absolutePaths),
|
|
182
|
+
);
|
|
183
|
+
return bundleHandle;
|
|
184
|
+
};
|
|
185
|
+
/** @type {import('./externalTypes.js').PublishBundleRef} */
|
|
186
|
+
const publishRef = async handleP => {
|
|
187
|
+
const handle = await handleP;
|
|
188
|
+
bundleHandleToAbsolutePaths.has(handle) ||
|
|
189
|
+
Fail`${handle} not in installed bundles`;
|
|
190
|
+
return handle;
|
|
191
|
+
};
|
|
192
|
+
const proposal = await ns[entrypoint](
|
|
193
|
+
{
|
|
194
|
+
publishRef,
|
|
195
|
+
// @ts-expect-error not statically verified to return a full obj
|
|
196
|
+
install,
|
|
197
|
+
},
|
|
198
|
+
...args,
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
// Add the proposal bundle handles in sorted order.
|
|
202
|
+
const bundleSpecEntries = await Promise.all(
|
|
203
|
+
[...thisProposalBundleHandles.keys()]
|
|
204
|
+
.map(handle => [handle, bundleHandleToAbsolutePaths.get(handle)])
|
|
205
|
+
.sort(([_hnda, { source: a }], [_hndb, { source: b }]) => {
|
|
206
|
+
if (a < b) {
|
|
207
|
+
return -1;
|
|
208
|
+
}
|
|
209
|
+
if (a > b) {
|
|
210
|
+
return 1;
|
|
211
|
+
}
|
|
212
|
+
return 0;
|
|
213
|
+
})
|
|
214
|
+
.map(async ([handle, absolutePaths], k) => {
|
|
215
|
+
// Transform the bundle handle identity into a bundleName reference.
|
|
216
|
+
const specEntry = await handleToBundleSpec(
|
|
217
|
+
handle,
|
|
218
|
+
absolutePaths.source,
|
|
219
|
+
thisProposalSequence,
|
|
220
|
+
String(k),
|
|
221
|
+
);
|
|
222
|
+
harden(handle);
|
|
223
|
+
return specEntry;
|
|
224
|
+
}),
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
// Now that we've assigned all the bundleNames and hardened the
|
|
228
|
+
// handles, we can extract the behavior bundle.
|
|
229
|
+
const { sourceSpec, getManifestCall } = await deeplyFulfilledObject(
|
|
230
|
+
harden(proposal),
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
const proposalSource = pathResolve(initDir, sourceSpec);
|
|
234
|
+
const proposalNS = await import(proposalSource);
|
|
235
|
+
const [manifestGetterName, ...manifestGetterArgs] = getManifestCall;
|
|
236
|
+
manifestGetterName in proposalNS ||
|
|
237
|
+
Fail`proposal ${proposalSource} missing export ${manifestGetterName}`;
|
|
238
|
+
const { manifest: customManifest } = await proposalNS[
|
|
239
|
+
manifestGetterName
|
|
240
|
+
](harden({ restoreRef: () => null }), ...manifestGetterArgs);
|
|
241
|
+
|
|
242
|
+
const behaviorBundleHandle = {};
|
|
243
|
+
const specEntry = await handleToBundleSpec(
|
|
244
|
+
behaviorBundleHandle,
|
|
245
|
+
proposalSource,
|
|
246
|
+
thisProposalSequence,
|
|
247
|
+
'proposalNS',
|
|
248
|
+
);
|
|
249
|
+
bundleSpecEntries.unshift(specEntry);
|
|
250
|
+
|
|
251
|
+
bundleHandleToAbsolutePaths.set(
|
|
252
|
+
behaviorBundleHandle,
|
|
253
|
+
harden({
|
|
254
|
+
source: proposalSource,
|
|
255
|
+
}),
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
return /** @type {const} */ ([
|
|
259
|
+
key,
|
|
260
|
+
{
|
|
261
|
+
ref: behaviorBundleHandle,
|
|
262
|
+
call: getManifestCall,
|
|
263
|
+
customManifest,
|
|
264
|
+
bundleSpecs: bundleSpecEntries,
|
|
265
|
+
},
|
|
266
|
+
]);
|
|
267
|
+
}),
|
|
268
|
+
),
|
|
269
|
+
),
|
|
200
270
|
);
|
|
201
271
|
|
|
202
272
|
// Extract all the bundle specs in already-sorted order.
|
|
203
273
|
const bundles = Object.fromEntries(
|
|
204
|
-
|
|
274
|
+
extractedSteps.flatMap(step =>
|
|
275
|
+
step.flatMap(([_key, { bundleSpecs }]) => bundleSpecs),
|
|
276
|
+
),
|
|
205
277
|
);
|
|
206
278
|
harden(bundles);
|
|
207
279
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
280
|
+
const codeSteps = extractedSteps.map(extractedStep => {
|
|
281
|
+
// Extract the manifest references and calls.
|
|
282
|
+
const metadataRecords = extractedStep.map(([_key, extractedSpec]) => {
|
|
283
|
+
const { ref, call, customManifest } = extractedSpec;
|
|
284
|
+
return { ref, call, customManifest };
|
|
285
|
+
});
|
|
286
|
+
harden(metadataRecords);
|
|
215
287
|
|
|
216
|
-
|
|
217
|
-
// This is generated by @agoric/
|
|
288
|
+
const code = `\
|
|
289
|
+
// This is generated by @agoric/deploy-script-support/src/extract-proposal.js - DO NOT EDIT
|
|
218
290
|
/* eslint-disable */
|
|
219
291
|
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
const makeCoreProposalBehavior = ${makeCoreProposalBehavior};
|
|
292
|
+
const metadataRecords = harden(${stringify(metadataRecords, true)});
|
|
223
293
|
|
|
224
|
-
|
|
294
|
+
// Make an enactCoreProposals function and "export" it by way of script completion value.
|
|
295
|
+
// It is constructed by an IIFE to ensure the absence of global bindings for
|
|
296
|
+
// makeCoreProposalBehavior and makeEnactCoreProposals (the latter referencing the former),
|
|
297
|
+
// which may not be necessary but preserves behavior pre-dating
|
|
298
|
+
// https://github.com/Agoric/agoric-sdk/pull/8712 .
|
|
299
|
+
const enactCoreProposals = ((
|
|
300
|
+
makeCoreProposalBehavior = ${makeCoreProposalBehavior},
|
|
301
|
+
makeEnactCoreProposals = ${makeEnactCoreProposals},
|
|
302
|
+
) => makeEnactCoreProposals({ metadataRecords, E }))();
|
|
303
|
+
enactCoreProposals;
|
|
225
304
|
`;
|
|
305
|
+
return defangAndTrim(code);
|
|
306
|
+
});
|
|
226
307
|
|
|
227
308
|
// console.debug('created bundles from proposals:', coreProposals, bundles);
|
|
228
|
-
return {
|
|
309
|
+
return harden({
|
|
229
310
|
bundles,
|
|
230
|
-
|
|
311
|
+
codeSteps,
|
|
231
312
|
bundleHandleToAbsolutePaths,
|
|
232
|
-
};
|
|
313
|
+
});
|
|
233
314
|
};
|
package/src/getBundlerMaker.js
CHANGED
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
import { E } from '@endo/far';
|
|
14
14
|
import url from 'url';
|
|
15
15
|
|
|
16
|
+
/** @typedef {ReturnType<import('./endo-pieces-contract.js')['start']>['publicFacet']} BundleMaker */
|
|
17
|
+
/** @typedef {ReturnType<BundleMaker['makeBundler']>} Bundler */
|
|
18
|
+
|
|
16
19
|
export const makeGetBundlerMaker =
|
|
17
20
|
(homeP, { lookup, bundleSource }) =>
|
|
18
21
|
async ({
|
|
@@ -20,6 +23,7 @@ export const makeGetBundlerMaker =
|
|
|
20
23
|
log = console.log,
|
|
21
24
|
} = {}) => {
|
|
22
25
|
const { board: optionalBoard, zoe, scratch } = await homeP;
|
|
26
|
+
/** @type {() => Promise<BundleMaker>} */
|
|
23
27
|
const lookupOrCreate = async () => {
|
|
24
28
|
// Locate the bundler maker if any already exists at the given path.
|
|
25
29
|
let bundlerMaker = await lookup(JSON.parse(BUNDLER_MAKER_LOOKUP));
|
package/src/helpers.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/// <reference path="../../zoe/exported.js" />
|
|
4
|
+
|
|
3
5
|
import { E } from '@endo/far';
|
|
4
6
|
import bundleSource from '@endo/bundle-source';
|
|
5
7
|
|
|
@@ -15,7 +17,7 @@ import { makeSaveIssuer } from './saveIssuer.js';
|
|
|
15
17
|
import { makeGetBundlerMaker } from './getBundlerMaker.js';
|
|
16
18
|
import { assertOfferResult } from './assertOfferResult.js';
|
|
17
19
|
import { installInPieces } from './installInPieces.js';
|
|
18
|
-
import {
|
|
20
|
+
import { makeWriteCoreEval } from './writeCoreEvalParts.js';
|
|
19
21
|
|
|
20
22
|
export * from '@agoric/internal/src/node/createBundles.js';
|
|
21
23
|
|
|
@@ -135,8 +137,16 @@ export const makeHelpers = async (homePromise, endowments) => {
|
|
|
135
137
|
get getBundlerMaker() {
|
|
136
138
|
return makeGetBundlerMaker(homePromise, { bundleSource, lookup });
|
|
137
139
|
},
|
|
140
|
+
/** @returns {import('./writeCoreEvalParts.js').WriteCoreEval} */
|
|
141
|
+
get writeCoreEval() {
|
|
142
|
+
return makeWriteCoreEval(homePromise, endowments, {
|
|
143
|
+
getBundleSpec: deps.cacheAndGetBundleSpec,
|
|
144
|
+
getBundlerMaker: helpers.getBundlerMaker,
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
/** @deprecated use writeCoreEval */
|
|
138
148
|
get writeCoreProposal() {
|
|
139
|
-
return
|
|
149
|
+
return makeWriteCoreEval(homePromise, endowments, {
|
|
140
150
|
getBundleSpec: deps.cacheAndGetBundleSpec,
|
|
141
151
|
getBundlerMaker: helpers.getBundlerMaker,
|
|
142
152
|
});
|
package/src/install.js
CHANGED
|
@@ -3,20 +3,11 @@ import './externalTypes.js';
|
|
|
3
3
|
|
|
4
4
|
import { E } from '@endo/far';
|
|
5
5
|
|
|
6
|
-
/** @
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @callback BundleSource
|
|
10
|
-
* @param {string} startFilename - the filepath to start the bundling from
|
|
11
|
-
* @param {ModuleFormat | BundleOptions} [moduleFormat]
|
|
12
|
-
* @param {object} [powers]
|
|
13
|
-
* @param {ReadFn} [powers.read]
|
|
14
|
-
* @param {CanonicalFn} [powers.canonical]
|
|
15
|
-
*/
|
|
6
|
+
/** @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js' */
|
|
16
7
|
|
|
17
8
|
// XXX board is Board but specifying that leads to type errors with imports which aren't worth fixing right now
|
|
18
9
|
/**
|
|
19
|
-
* @param {
|
|
10
|
+
* @param {typeof import('@endo/bundle-source')['default']} bundleSource
|
|
20
11
|
* @param {ERef<ZoeService>} zoe
|
|
21
12
|
* @param {ERef<import('./startInstance.js').InstallationManager>} installationManager
|
|
22
13
|
* @param {ERef<any>} board
|
package/src/offer.js
CHANGED
|
@@ -4,7 +4,7 @@ import { assert } from '@agoric/assert';
|
|
|
4
4
|
// Avoid pulling in too many dependencies like notifiers
|
|
5
5
|
import { AmountMath } from '@agoric/ertp/src/amountMath.js';
|
|
6
6
|
|
|
7
|
-
/** @
|
|
7
|
+
/** @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js' */
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {object} OfferHelperConfig
|
|
@@ -19,7 +19,7 @@ import { AmountMath } from '@agoric/ertp/src/amountMath.js';
|
|
|
19
19
|
* @param {ERef<any>} walletAdmin - an internal type of the
|
|
20
20
|
* wallet, not defined here
|
|
21
21
|
* @param {ERef<ZoeService>} zoe
|
|
22
|
-
* @param {ERef<Purse
|
|
22
|
+
* @param {ERef<Purse<'set', InvitationDetails>>} zoeInvitationPurse
|
|
23
23
|
*/
|
|
24
24
|
export const makeOfferAndFindInvitationAmount = (
|
|
25
25
|
walletAdmin,
|
|
@@ -28,7 +28,7 @@ export const makeOfferAndFindInvitationAmount = (
|
|
|
28
28
|
) => {
|
|
29
29
|
/**
|
|
30
30
|
* @param {Record<string, any>} invitationDetailsCriteria
|
|
31
|
-
* @returns {Promise<
|
|
31
|
+
* @returns {Promise<InvitationAmount>} invitationAmount
|
|
32
32
|
*/
|
|
33
33
|
const findInvitationAmount = async invitationDetailsCriteria => {
|
|
34
34
|
const invitationAmount = await E(zoeInvitationPurse).getCurrentAmount();
|
|
@@ -114,9 +114,8 @@ export const makeOfferAndFindInvitationAmount = (
|
|
|
114
114
|
} = config;
|
|
115
115
|
|
|
116
116
|
const invitationToUse = getInvitation(invitation, partialInvitationDetails);
|
|
117
|
-
const invitationDetails =
|
|
118
|
-
invitationToUse
|
|
119
|
-
);
|
|
117
|
+
const invitationDetails =
|
|
118
|
+
await E(zoe).getInvitationDetails(invitationToUse);
|
|
120
119
|
const payments = withdrawPayments(proposal, paymentsWithPursePetnames);
|
|
121
120
|
|
|
122
121
|
const seat = E(zoe).offer(invitationToUse, proposal, payments);
|
package/src/saveIssuer.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import { E } from '@endo/far';
|
|
3
3
|
|
|
4
|
-
/** @
|
|
4
|
+
/** @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js' */
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @param {ERef<any>} walletAdmin - an internal type of the
|
|
8
8
|
* wallet, not defined here
|
|
9
|
-
* @param {ERef<import('./startInstance').IssuerManager>} issuerManager
|
|
9
|
+
* @param {ERef<import('./startInstance.js').IssuerManager>} issuerManager
|
|
10
10
|
*/
|
|
11
11
|
export const makeSaveIssuer = (walletAdmin, issuerManager) => {
|
|
12
12
|
/**
|
package/src/startInstance.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { assert } from '@agoric/assert';
|
|
3
3
|
import { E, passStyleOf } from '@endo/far';
|
|
4
4
|
|
|
5
|
-
/** @
|
|
5
|
+
/** @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js' */
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @template T
|
|
@@ -100,9 +100,8 @@ export const makeStartInstance = (
|
|
|
100
100
|
`creatorInvitation must be defined to be deposited`,
|
|
101
101
|
);
|
|
102
102
|
console.log(`-- Adding Invitation for: ${instancePetname}`);
|
|
103
|
-
const invitationAmount =
|
|
104
|
-
creatorInvitation
|
|
105
|
-
);
|
|
103
|
+
const invitationAmount =
|
|
104
|
+
await E(zoeInvitationPurse).deposit(creatorInvitation);
|
|
106
105
|
console.log(`- Created Contract Instance: ${instancePetname}`);
|
|
107
106
|
|
|
108
107
|
const creatorInvitationDetails = invitationAmount.value[0];
|