@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/exported.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/deploy-script-support",
|
|
3
|
-
"version": "0.10.4-
|
|
3
|
+
"version": "0.10.4-orchestration-dev-096c4e8.0+096c4e8",
|
|
4
4
|
"description": "Helpers and other support for writing deploy scripts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/helpers.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"test:xs": "exit 0",
|
|
14
14
|
"lint-fix": "yarn lint:eslint --fix",
|
|
15
15
|
"lint:eslint": "eslint .",
|
|
16
|
-
"lint:types": "tsc
|
|
16
|
+
"lint:types": "tsc",
|
|
17
17
|
"lint": "run-s --continue-on-error lint:*"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
@@ -34,25 +34,26 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@agoric/assert": "0.6.1-
|
|
38
|
-
"@agoric/ertp": "0.16.3-
|
|
39
|
-
"@agoric/import-manager": "0.3.12-
|
|
40
|
-
"@agoric/internal": "0.
|
|
41
|
-
"@agoric/notifier": "0.6.3-
|
|
42
|
-
"@agoric/store": "0.9.3-
|
|
43
|
-
"@agoric/
|
|
44
|
-
"@
|
|
45
|
-
"@endo/
|
|
46
|
-
"@endo/
|
|
47
|
-
"@endo/
|
|
48
|
-
"@endo/
|
|
49
|
-
"@endo/
|
|
50
|
-
"@endo/
|
|
37
|
+
"@agoric/assert": "0.6.1-orchestration-dev-096c4e8.0+096c4e8",
|
|
38
|
+
"@agoric/ertp": "0.16.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
39
|
+
"@agoric/import-manager": "0.3.12-orchestration-dev-096c4e8.0+096c4e8",
|
|
40
|
+
"@agoric/internal": "0.3.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
41
|
+
"@agoric/notifier": "0.6.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
42
|
+
"@agoric/store": "0.9.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
43
|
+
"@agoric/time": "0.3.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
44
|
+
"@agoric/zoe": "0.26.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
45
|
+
"@endo/base64": "^1.0.2",
|
|
46
|
+
"@endo/bundle-source": "^3.1.0",
|
|
47
|
+
"@endo/far": "^1.0.4",
|
|
48
|
+
"@endo/marshal": "^1.3.0",
|
|
49
|
+
"@endo/nat": "^5.0.4",
|
|
50
|
+
"@endo/promise-kit": "^1.0.4",
|
|
51
|
+
"@endo/zip": "^1.0.2"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@agoric/vats": "0.15.2-
|
|
54
|
-
"@endo/init": "0.
|
|
55
|
-
"ava": "^5.
|
|
54
|
+
"@agoric/vats": "0.15.2-orchestration-dev-096c4e8.0+096c4e8",
|
|
55
|
+
"@endo/init": "^1.0.4",
|
|
56
|
+
"ava": "^5.3.0",
|
|
56
57
|
"import-meta-resolve": "^2.2.1"
|
|
57
58
|
},
|
|
58
59
|
"files": [
|
|
@@ -63,10 +64,16 @@
|
|
|
63
64
|
"ava": {
|
|
64
65
|
"files": [
|
|
65
66
|
"test/**/test-*.js"
|
|
67
|
+
],
|
|
68
|
+
"require": [
|
|
69
|
+
"@endo/init/debug.js"
|
|
66
70
|
]
|
|
67
71
|
},
|
|
68
72
|
"publishConfig": {
|
|
69
73
|
"access": "public"
|
|
70
74
|
},
|
|
71
|
-
"
|
|
75
|
+
"typeCoverage": {
|
|
76
|
+
"atLeast": 81.47
|
|
77
|
+
},
|
|
78
|
+
"gitHead": "096c4e8fce80e9a509b0e1a30fda11736c4570e1"
|
|
72
79
|
}
|
|
@@ -8,7 +8,20 @@ const t = 'makeCoreProposalBehavior';
|
|
|
8
8
|
* @typedef {*} BootstrapPowers
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {import('./externalTypes.js').ManifestBundleRef} ManifestBundleRef
|
|
13
|
+
* @typedef {[methodName: string, ...args: unknown[]]} FlatMethargs
|
|
14
|
+
* @typedef {Record<string, Record<string, unknown>>} Manifest
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* These permits are expected to be the minimum powers required by the
|
|
19
|
+
* `coreProposalBehavior` function returned from `makeCoreProposalBehavior`.
|
|
20
|
+
* They are merged with all of the manifest getter's permits to produce the
|
|
21
|
+
* total permits needed by the resulting core proposal (such as might be---and
|
|
22
|
+
* generally are---written into a *-permit.json file).
|
|
23
|
+
* @see {@link ./writeCoreProposal.js}
|
|
24
|
+
*/
|
|
12
25
|
export const permits = {
|
|
13
26
|
consume: { agoricNamesAdmin: t, vatAdminSvc: t, zoe: t },
|
|
14
27
|
evaluateBundleCap: t,
|
|
@@ -23,43 +36,74 @@ export const permits = {
|
|
|
23
36
|
* for catching bugs. Thus, this maker must not reference any other modules or
|
|
24
37
|
* definitions.
|
|
25
38
|
*
|
|
26
|
-
* @param {object}
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {typeof import('@endo/far').E}
|
|
31
|
-
* @param {(...args: unknown[]) => void} [
|
|
32
|
-
* @param {(ref:
|
|
39
|
+
* @param {object} inputs
|
|
40
|
+
* @param {ManifestBundleRef} inputs.manifestBundleRef
|
|
41
|
+
* @param {FlatMethargs} inputs.getManifestCall
|
|
42
|
+
* @param {Manifest} [inputs.customManifest]
|
|
43
|
+
* @param {typeof import('@endo/far').E} inputs.E
|
|
44
|
+
* @param {(...args: unknown[]) => void} [inputs.log]
|
|
45
|
+
* @param {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise<import('@agoric/zoe/src/zoeService/utils.js').Installation<unknown>>} [inputs.customRestoreRef]
|
|
33
46
|
* @returns {(vatPowers: unknown) => Promise<unknown>}
|
|
34
47
|
*/
|
|
35
48
|
export const makeCoreProposalBehavior = ({
|
|
36
49
|
manifestBundleRef,
|
|
37
|
-
getManifestCall,
|
|
38
|
-
|
|
50
|
+
getManifestCall: [manifestGetterName, ...manifestGetterArgs],
|
|
51
|
+
customManifest,
|
|
39
52
|
E,
|
|
40
53
|
log = console.info,
|
|
41
|
-
|
|
54
|
+
customRestoreRef,
|
|
42
55
|
}) => {
|
|
43
56
|
const { entries, fromEntries } = Object;
|
|
44
57
|
|
|
45
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Given an object whose properties may be promise-valued, return a promise
|
|
60
|
+
* for an analogous object in which each such value has been replaced with its
|
|
61
|
+
* fulfillment.
|
|
62
|
+
* This is a non-recursive form of endo `deeplyFulfilled`.
|
|
63
|
+
*
|
|
64
|
+
* @template T
|
|
65
|
+
* @param {{[K in keyof T]: (T[K] | Promise<T[K]>)}} obj
|
|
66
|
+
* @returns {Promise<T>}
|
|
67
|
+
*/
|
|
46
68
|
const shallowlyFulfilled = async obj => {
|
|
47
69
|
if (!obj) {
|
|
48
70
|
return obj;
|
|
49
71
|
}
|
|
50
|
-
const
|
|
72
|
+
const awaitedEntries = await Promise.all(
|
|
51
73
|
entries(obj).map(async ([key, valueP]) => {
|
|
52
74
|
const value = await valueP;
|
|
53
75
|
return [key, value];
|
|
54
76
|
}),
|
|
55
77
|
);
|
|
56
|
-
return fromEntries(
|
|
78
|
+
return fromEntries(awaitedEntries);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const makeRestoreRef = (vatAdminSvc, zoe) => {
|
|
82
|
+
/** @type {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise<Installation<unknown>>} */
|
|
83
|
+
const defaultRestoreRef = async bundleRef => {
|
|
84
|
+
// extract-proposal.js creates these records, and bundleName is
|
|
85
|
+
// the optional name under which the bundle was installed into
|
|
86
|
+
// config.bundles
|
|
87
|
+
const bundleIdP =
|
|
88
|
+
'bundleName' in bundleRef
|
|
89
|
+
? E(vatAdminSvc).getBundleIDByName(bundleRef.bundleName)
|
|
90
|
+
: bundleRef.bundleID;
|
|
91
|
+
const bundleID = await bundleIdP;
|
|
92
|
+
const label = bundleID.slice(0, 8);
|
|
93
|
+
return E(zoe).installBundleID(bundleID, label);
|
|
94
|
+
};
|
|
95
|
+
return defaultRestoreRef;
|
|
57
96
|
};
|
|
58
97
|
|
|
59
|
-
/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }}
|
|
60
|
-
const
|
|
61
|
-
// NOTE:
|
|
62
|
-
//
|
|
98
|
+
/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} powers */
|
|
99
|
+
const coreProposalBehavior = async powers => {
|
|
100
|
+
// NOTE: `powers` is expected to match or be a superset of the above `permits` export,
|
|
101
|
+
// which should therefore be kept in sync with this deconstruction code.
|
|
102
|
+
// HOWEVER, do note that this function is invoked with at least the *union* of powers
|
|
103
|
+
// required by individual moduleBehaviors declared by the manifest getter, which is
|
|
104
|
+
// necessary so it can use `runModuleBehaviors` to provide the appropriate subset to
|
|
105
|
+
// each one (see ./writeCoreProposal.js).
|
|
106
|
+
// Handle `powers` with the requisite care.
|
|
63
107
|
const {
|
|
64
108
|
consume: { vatAdminSvc, zoe, agoricNamesAdmin },
|
|
65
109
|
evaluateBundleCap,
|
|
@@ -67,70 +111,70 @@ export const makeCoreProposalBehavior = ({
|
|
|
67
111
|
modules: {
|
|
68
112
|
utils: { runModuleBehaviors },
|
|
69
113
|
},
|
|
70
|
-
} =
|
|
71
|
-
const [exportedGetManifest, ...manifestArgs] = getManifestCall;
|
|
72
|
-
|
|
73
|
-
const defaultRestoreRef = async ref => {
|
|
74
|
-
// extract-proposal.js creates these records, and bundleName is
|
|
75
|
-
// the name under which the bundle was installed into
|
|
76
|
-
// config.bundles
|
|
77
|
-
const p = ref.bundleName
|
|
78
|
-
? E(vatAdminSvc).getBundleIDByName(ref.bundleName)
|
|
79
|
-
: ref.bundleID;
|
|
80
|
-
const bundleID = await p;
|
|
81
|
-
const label = bundleID.slice(0, 8);
|
|
82
|
-
return E(zoe).installBundleID(bundleID, label);
|
|
83
|
-
};
|
|
84
|
-
const restoreRef = overrideRestoreRef || defaultRestoreRef;
|
|
114
|
+
} = powers;
|
|
85
115
|
|
|
86
116
|
// Get the on-chain installation containing the manifest and behaviors.
|
|
87
|
-
|
|
117
|
+
log('evaluateBundleCap', {
|
|
88
118
|
manifestBundleRef,
|
|
89
|
-
|
|
119
|
+
manifestGetterName,
|
|
90
120
|
vatAdminSvc,
|
|
91
121
|
});
|
|
92
122
|
let bcapP;
|
|
93
123
|
if ('bundleName' in manifestBundleRef) {
|
|
94
124
|
bcapP = E(vatAdminSvc).getNamedBundleCap(manifestBundleRef.bundleName);
|
|
95
|
-
} else {
|
|
125
|
+
} else if ('bundleID' in manifestBundleRef) {
|
|
96
126
|
bcapP = E(vatAdminSvc).getBundleCap(manifestBundleRef.bundleID);
|
|
127
|
+
} else {
|
|
128
|
+
const keys = Reflect.ownKeys(manifestBundleRef).map(key =>
|
|
129
|
+
typeof key === 'string' ? JSON.stringify(key) : String(key),
|
|
130
|
+
);
|
|
131
|
+
const keysStr = `[${keys.join(', ')}]`;
|
|
132
|
+
throw Error(
|
|
133
|
+
`bundleRef must have own bundleName or bundleID, missing in ${keysStr}`,
|
|
134
|
+
);
|
|
97
135
|
}
|
|
98
136
|
const bundleCap = await bcapP;
|
|
99
137
|
|
|
100
|
-
const
|
|
138
|
+
const proposalNS = await evaluateBundleCap(bundleCap);
|
|
101
139
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
140
|
+
// Get the manifest and its metadata.
|
|
141
|
+
log('execute', {
|
|
142
|
+
manifestGetterName,
|
|
143
|
+
bundleExports: Object.keys(proposalNS),
|
|
105
144
|
});
|
|
145
|
+
const restoreRef = customRestoreRef || makeRestoreRef(vatAdminSvc, zoe);
|
|
106
146
|
const {
|
|
107
147
|
manifest,
|
|
108
148
|
options: rawOptions,
|
|
109
149
|
installations: rawInstallations,
|
|
110
|
-
} = await
|
|
150
|
+
} = await proposalNS[manifestGetterName](
|
|
111
151
|
harden({ restoreRef }),
|
|
112
|
-
...
|
|
152
|
+
...manifestGetterArgs,
|
|
113
153
|
);
|
|
114
154
|
|
|
115
|
-
// Await
|
|
155
|
+
// Await promises in the returned options and installations records.
|
|
116
156
|
const [options, installations] = await Promise.all(
|
|
117
157
|
[rawOptions, rawInstallations].map(shallowlyFulfilled),
|
|
118
158
|
);
|
|
119
159
|
|
|
120
|
-
// Publish the installations for
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
160
|
+
// Publish the installations for our dependencies.
|
|
161
|
+
const installationEntries = entries(installations || {});
|
|
162
|
+
if (installationEntries.length > 0) {
|
|
163
|
+
const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation');
|
|
164
|
+
await Promise.all(
|
|
165
|
+
installationEntries.map(([key, value]) => {
|
|
166
|
+
produceInstallations[key].resolve(value);
|
|
167
|
+
return E(installAdmin).update(key, value);
|
|
168
|
+
}),
|
|
169
|
+
);
|
|
170
|
+
}
|
|
128
171
|
|
|
129
|
-
// Evaluate the manifest
|
|
172
|
+
// Evaluate the manifest.
|
|
130
173
|
return runModuleBehaviors({
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
174
|
+
// Remember that `powers` may be arbitrarily broad.
|
|
175
|
+
allPowers: powers,
|
|
176
|
+
behaviors: proposalNS,
|
|
177
|
+
manifest: customManifest || manifest,
|
|
134
178
|
makeConfig: (name, _permit) => {
|
|
135
179
|
log('coreProposal:', name);
|
|
136
180
|
return { options };
|
|
@@ -138,22 +182,31 @@ export const makeCoreProposalBehavior = ({
|
|
|
138
182
|
});
|
|
139
183
|
};
|
|
140
184
|
|
|
141
|
-
|
|
142
|
-
return behavior;
|
|
185
|
+
return coreProposalBehavior;
|
|
143
186
|
};
|
|
144
187
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
188
|
+
/**
|
|
189
|
+
* @param {object} inputs
|
|
190
|
+
* @param {Array<{ ref: ManifestBundleRef, call: FlatMethargs, customManifest?: Manifest }>} inputs.metadataRecords
|
|
191
|
+
* @param {typeof import('@endo/far').E} inputs.E
|
|
192
|
+
*/
|
|
193
|
+
export const makeEnactCoreProposalsFromBundleRef = ({ metadataRecords, E }) => {
|
|
194
|
+
/**
|
|
195
|
+
* @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} powers
|
|
196
|
+
* @returns {Promise<void>}
|
|
197
|
+
*/
|
|
198
|
+
const enactCoreProposals = async powers => {
|
|
148
199
|
await Promise.all(
|
|
149
|
-
|
|
150
|
-
const
|
|
200
|
+
metadataRecords.map(async ({ ref, call, customManifest }) => {
|
|
201
|
+
const coreProposalBehavior = makeCoreProposalBehavior({
|
|
151
202
|
manifestBundleRef: ref,
|
|
152
203
|
getManifestCall: call,
|
|
153
|
-
|
|
204
|
+
customManifest,
|
|
154
205
|
E,
|
|
155
206
|
});
|
|
156
|
-
return
|
|
207
|
+
return coreProposalBehavior(powers);
|
|
157
208
|
}),
|
|
158
209
|
);
|
|
159
210
|
};
|
|
211
|
+
return enactCoreProposals;
|
|
212
|
+
};
|
package/src/externalTypes.js
CHANGED
|
@@ -16,30 +16,29 @@ export {};
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @typedef
|
|
20
|
-
* @property {string} [bundleName]
|
|
19
|
+
* @typedef {{fileName?: string} & ({ bundleName: string } | { bundleID: string}) } ManifestBundleRef
|
|
21
20
|
*/
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
* @callback PublishBundleRef
|
|
25
|
-
* @param {ERef<
|
|
26
|
-
* @returns {Promise<
|
|
24
|
+
* @param {ERef<ManifestBundleRef>} bundle
|
|
25
|
+
* @returns {Promise<ManifestBundleRef>}
|
|
27
26
|
*/
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
|
-
* @callback
|
|
29
|
+
* @callback InstallEntrypoint
|
|
31
30
|
* @param {string} srcSpec
|
|
32
|
-
* @param {string} bundlePath
|
|
33
|
-
* @param {
|
|
34
|
-
* @returns {
|
|
31
|
+
* @param {string} [bundlePath]
|
|
32
|
+
* @param {unknown} [opts]
|
|
33
|
+
* @returns {Promise<ManifestBundleRef>}
|
|
35
34
|
*/
|
|
36
35
|
|
|
37
36
|
/**
|
|
38
37
|
* @callback ProposalBuilder
|
|
39
38
|
* @param {{
|
|
40
39
|
* publishRef: PublishBundleRef,
|
|
41
|
-
* install:
|
|
42
|
-
* wrapInstall?: <T>(f: T) => T }
|
|
40
|
+
* install: InstallEntrypoint,
|
|
41
|
+
* wrapInstall?: <T extends InstallEntrypoint>(f: T) => T }
|
|
43
42
|
* } powers
|
|
44
43
|
* @param {...any} args
|
|
45
44
|
* @returns {Promise<ProposalResult>}
|