@agoric/deploy-script-support 0.10.4-dev-4c174a2.0 → 0.10.4-dev-51399d1.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/coreProposalBehavior.js +78 -46
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-51399d1.0+51399d1",
|
|
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-51399d1.0+51399d1",
|
|
38
|
+
"@agoric/ertp": "0.16.3-dev-51399d1.0+51399d1",
|
|
39
|
+
"@agoric/import-manager": "0.3.12-dev-51399d1.0+51399d1",
|
|
40
|
+
"@agoric/internal": "0.3.3-dev-51399d1.0+51399d1",
|
|
41
|
+
"@agoric/notifier": "0.6.3-dev-51399d1.0+51399d1",
|
|
42
|
+
"@agoric/store": "0.9.3-dev-51399d1.0+51399d1",
|
|
43
|
+
"@agoric/time": "0.3.3-dev-51399d1.0+51399d1",
|
|
44
|
+
"@agoric/zoe": "0.26.3-dev-51399d1.0+51399d1",
|
|
45
45
|
"@endo/base64": "^0.2.34",
|
|
46
46
|
"@endo/bundle-source": "^2.7.0",
|
|
47
47
|
"@endo/far": "^0.2.21",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@endo/zip": "^0.2.34"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@agoric/vats": "0.15.2-dev-
|
|
54
|
+
"@agoric/vats": "0.15.2-dev-51399d1.0+51399d1",
|
|
55
55
|
"@endo/init": "^0.5.59",
|
|
56
56
|
"ava": "^5.3.0",
|
|
57
57
|
"import-meta-resolve": "^2.2.1"
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"typeCoverage": {
|
|
76
76
|
"atLeast": 79.84
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "51399d19e8b32f794e2e0b6af990cc439d60dfaa"
|
|
79
79
|
}
|
|
@@ -8,7 +8,14 @@ const t = 'makeCoreProposalBehavior';
|
|
|
8
8
|
* @typedef {*} BootstrapPowers
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* These permits are expected to be the minimum powers required by the
|
|
13
|
+
* `coreProposalBehavior` function returned from `makeCoreProposalBehavior`.
|
|
14
|
+
* They are merged with all of the manifest getter's permits to produce the
|
|
15
|
+
* total permits needed by the resulting core proposal (such as might be---and
|
|
16
|
+
* generally are---written into a *-permit.json file).
|
|
17
|
+
* @see {@link ./writeCoreProposal.js}
|
|
18
|
+
*/
|
|
12
19
|
export const permits = {
|
|
13
20
|
consume: { agoricNamesAdmin: t, vatAdminSvc: t, zoe: t },
|
|
14
21
|
evaluateBundleCap: t,
|
|
@@ -25,7 +32,7 @@ export const permits = {
|
|
|
25
32
|
*
|
|
26
33
|
* @param {object} opts
|
|
27
34
|
* @param {import('./externalTypes.js').ManifestBundleRef} opts.manifestBundleRef
|
|
28
|
-
* @param {[string, ...unknown[]]} opts.getManifestCall
|
|
35
|
+
* @param {[methodName: string, ...args: unknown[]]} opts.getManifestCall
|
|
29
36
|
* @param {Record<string, Record<string, unknown>>} [opts.overrideManifest]
|
|
30
37
|
* @param {typeof import('@endo/far').E} opts.E
|
|
31
38
|
* @param {(...args: unknown[]) => void} [opts.log]
|
|
@@ -34,7 +41,7 @@ export const permits = {
|
|
|
34
41
|
*/
|
|
35
42
|
export const makeCoreProposalBehavior = ({
|
|
36
43
|
manifestBundleRef,
|
|
37
|
-
getManifestCall,
|
|
44
|
+
getManifestCall: [manifestGetterName, ...manifestGetterArgs],
|
|
38
45
|
overrideManifest,
|
|
39
46
|
E,
|
|
40
47
|
log = console.info,
|
|
@@ -42,24 +49,55 @@ export const makeCoreProposalBehavior = ({
|
|
|
42
49
|
}) => {
|
|
43
50
|
const { entries, fromEntries } = Object;
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Given an object whose properties may be promise-valued, return a promise
|
|
54
|
+
* for an analogous object in which each such value has been replaced with its
|
|
55
|
+
* fulfillment.
|
|
56
|
+
* This is a non-recursive form of endo `deeplyFulfilled`.
|
|
57
|
+
*
|
|
58
|
+
* @template T
|
|
59
|
+
* @param {{[K in keyof T]: (T[K] | Promise<T[K]>)}} obj
|
|
60
|
+
* @returns {Promise<T>}
|
|
61
|
+
*/
|
|
46
62
|
const shallowlyFulfilled = async obj => {
|
|
47
63
|
if (!obj) {
|
|
48
64
|
return obj;
|
|
49
65
|
}
|
|
50
|
-
const
|
|
66
|
+
const awaitedEntries = await Promise.all(
|
|
51
67
|
entries(obj).map(async ([key, valueP]) => {
|
|
52
68
|
const value = await valueP;
|
|
53
69
|
return [key, value];
|
|
54
70
|
}),
|
|
55
71
|
);
|
|
56
|
-
return fromEntries(
|
|
72
|
+
return fromEntries(awaitedEntries);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const makeRestoreRef = (vatAdminSvc, zoe) => {
|
|
76
|
+
/** @type {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise<Installation<unknown>>} */
|
|
77
|
+
const defaultRestoreRef = async bundleRef => {
|
|
78
|
+
// extract-proposal.js creates these records, and bundleName is
|
|
79
|
+
// the optional name under which the bundle was installed into
|
|
80
|
+
// config.bundles
|
|
81
|
+
const bundleIdP =
|
|
82
|
+
'bundleName' in bundleRef
|
|
83
|
+
? E(vatAdminSvc).getBundleIDByName(bundleRef.bundleName)
|
|
84
|
+
: bundleRef.bundleID;
|
|
85
|
+
const bundleID = await bundleIdP;
|
|
86
|
+
const label = bundleID.slice(0, 8);
|
|
87
|
+
return E(zoe).installBundleID(bundleID, label);
|
|
88
|
+
};
|
|
89
|
+
return defaultRestoreRef;
|
|
57
90
|
};
|
|
58
91
|
|
|
59
|
-
/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }}
|
|
60
|
-
const
|
|
61
|
-
// NOTE:
|
|
62
|
-
//
|
|
92
|
+
/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} powers */
|
|
93
|
+
const coreProposalBehavior = async powers => {
|
|
94
|
+
// NOTE: `powers` is expected to match or be a superset of the above `permits` export,
|
|
95
|
+
// which should therefore be kept in sync with this deconstruction code.
|
|
96
|
+
// HOWEVER, do note that this function is invoked with at least the *union* of powers
|
|
97
|
+
// required by individual moduleBehaviors declared by the manifest getter, which is
|
|
98
|
+
// necessary so it can use `runModuleBehaviors` to provide the appropriate subset to
|
|
99
|
+
// each one (see ./writeCoreProposal.js).
|
|
100
|
+
// Handle `powers` with the requisite care.
|
|
63
101
|
const {
|
|
64
102
|
consume: { vatAdminSvc, zoe, agoricNamesAdmin },
|
|
65
103
|
evaluateBundleCap,
|
|
@@ -67,59 +105,53 @@ export const makeCoreProposalBehavior = ({
|
|
|
67
105
|
modules: {
|
|
68
106
|
utils: { runModuleBehaviors },
|
|
69
107
|
},
|
|
70
|
-
} =
|
|
71
|
-
const [exportedGetManifest, ...manifestArgs] = getManifestCall;
|
|
72
|
-
|
|
73
|
-
/** @type {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise<Installation<unknown>>} */
|
|
74
|
-
const defaultRestoreRef = async ref => {
|
|
75
|
-
// extract-proposal.js creates these records, and bundleName is
|
|
76
|
-
// the name under which the bundle was installed into
|
|
77
|
-
// config.bundles
|
|
78
|
-
const p =
|
|
79
|
-
'bundleName' in ref
|
|
80
|
-
? E(vatAdminSvc).getBundleIDByName(ref.bundleName)
|
|
81
|
-
: ref.bundleID;
|
|
82
|
-
const bundleID = await p;
|
|
83
|
-
const label = bundleID.slice(0, 8);
|
|
84
|
-
return E(zoe).installBundleID(bundleID, label);
|
|
85
|
-
};
|
|
86
|
-
const restoreRef = overrideRestoreRef || defaultRestoreRef;
|
|
108
|
+
} = powers;
|
|
87
109
|
|
|
88
110
|
// Get the on-chain installation containing the manifest and behaviors.
|
|
89
|
-
|
|
111
|
+
log('evaluateBundleCap', {
|
|
90
112
|
manifestBundleRef,
|
|
91
|
-
|
|
113
|
+
manifestGetterName,
|
|
92
114
|
vatAdminSvc,
|
|
93
115
|
});
|
|
94
116
|
let bcapP;
|
|
95
117
|
if ('bundleName' in manifestBundleRef) {
|
|
96
118
|
bcapP = E(vatAdminSvc).getNamedBundleCap(manifestBundleRef.bundleName);
|
|
97
|
-
} else {
|
|
119
|
+
} else if ('bundleID' in manifestBundleRef) {
|
|
98
120
|
bcapP = E(vatAdminSvc).getBundleCap(manifestBundleRef.bundleID);
|
|
121
|
+
} else {
|
|
122
|
+
const keys = Reflect.ownKeys(manifestBundleRef).map(key =>
|
|
123
|
+
typeof key === 'string' ? JSON.stringify(key) : String(key),
|
|
124
|
+
);
|
|
125
|
+
const keysStr = `[${keys.join(', ')}]`;
|
|
126
|
+
throw Error(
|
|
127
|
+
`bundleRef must have own bundleName or bundleID, missing in ${keysStr}`,
|
|
128
|
+
);
|
|
99
129
|
}
|
|
100
130
|
const bundleCap = await bcapP;
|
|
101
131
|
|
|
102
|
-
const
|
|
132
|
+
const proposalNS = await evaluateBundleCap(bundleCap);
|
|
103
133
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
134
|
+
// Get the manifest and its metadata.
|
|
135
|
+
log('execute', {
|
|
136
|
+
manifestGetterName,
|
|
137
|
+
bundleExports: Object.keys(proposalNS),
|
|
107
138
|
});
|
|
139
|
+
const restoreRef = overrideRestoreRef || makeRestoreRef(vatAdminSvc, zoe);
|
|
108
140
|
const {
|
|
109
141
|
manifest,
|
|
110
142
|
options: rawOptions,
|
|
111
143
|
installations: rawInstallations,
|
|
112
|
-
} = await
|
|
144
|
+
} = await proposalNS[manifestGetterName](
|
|
113
145
|
harden({ restoreRef }),
|
|
114
|
-
...
|
|
146
|
+
...manifestGetterArgs,
|
|
115
147
|
);
|
|
116
148
|
|
|
117
|
-
// Await
|
|
149
|
+
// Await promises in the returned options and installations records.
|
|
118
150
|
const [options, installations] = await Promise.all(
|
|
119
151
|
[rawOptions, rawInstallations].map(shallowlyFulfilled),
|
|
120
152
|
);
|
|
121
153
|
|
|
122
|
-
// Publish the installations for
|
|
154
|
+
// Publish the installations for our dependencies.
|
|
123
155
|
const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation');
|
|
124
156
|
await Promise.all(
|
|
125
157
|
entries(installations || {}).map(([key, value]) => {
|
|
@@ -128,10 +160,11 @@ export const makeCoreProposalBehavior = ({
|
|
|
128
160
|
}),
|
|
129
161
|
);
|
|
130
162
|
|
|
131
|
-
// Evaluate the manifest
|
|
163
|
+
// Evaluate the manifest.
|
|
132
164
|
return runModuleBehaviors({
|
|
133
|
-
|
|
134
|
-
|
|
165
|
+
// Remember that `powers` may be arbitrarily broad.
|
|
166
|
+
allPowers: powers,
|
|
167
|
+
behaviors: proposalNS,
|
|
135
168
|
manifest: overrideManifest || manifest,
|
|
136
169
|
makeConfig: (name, _permit) => {
|
|
137
170
|
log('coreProposal:', name);
|
|
@@ -140,22 +173,21 @@ export const makeCoreProposalBehavior = ({
|
|
|
140
173
|
});
|
|
141
174
|
};
|
|
142
175
|
|
|
143
|
-
|
|
144
|
-
return behavior;
|
|
176
|
+
return coreProposalBehavior;
|
|
145
177
|
};
|
|
146
178
|
|
|
147
179
|
export const makeEnactCoreProposalsFromBundleRef =
|
|
148
180
|
({ makeCoreProposalArgs, E }) =>
|
|
149
|
-
async
|
|
181
|
+
async powers => {
|
|
150
182
|
await Promise.all(
|
|
151
183
|
makeCoreProposalArgs.map(async ({ ref, call, overrideManifest }) => {
|
|
152
|
-
const
|
|
184
|
+
const coreProposalBehavior = makeCoreProposalBehavior({
|
|
153
185
|
manifestBundleRef: ref,
|
|
154
186
|
getManifestCall: call,
|
|
155
187
|
overrideManifest,
|
|
156
188
|
E,
|
|
157
189
|
});
|
|
158
|
-
return
|
|
190
|
+
return coreProposalBehavior(powers);
|
|
159
191
|
}),
|
|
160
192
|
);
|
|
161
193
|
};
|