@agoric/deploy-script-support 0.10.4-20230923T000433-dev-63b1fb6.0 → 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 +230 -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 -555
- package/exported.js +0 -3
- package/src/writeCoreProposal.js +0 -139
package/README.md
CHANGED
|
@@ -1,4 +1,108 @@
|
|
|
1
1
|
# Deploy Script Support
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
To install code on chain or in the a3p-integration environment, you'll have to
|
|
4
|
+
generate a proposal, and write a script to build the core proposal. The
|
|
5
|
+
proposals have limited access to bootstrap powers, described by their manifests.
|
|
6
|
+
|
|
7
|
+
There are collections of proposals in .../vats/src/proposals,
|
|
8
|
+
smart-wallet/src/proposals, orchestration/src/proposals, pegasus/src/proposals.
|
|
9
|
+
|
|
10
|
+
The overall format is a proposalBuilder script (There are several in
|
|
11
|
+
.../builders/scripts/vats/) which has a default export that passes resources to
|
|
12
|
+
the proposal. The resources include bundled source code and string-value
|
|
13
|
+
parameters. The ProposalBuilder specifies (as an import string) the proposal
|
|
14
|
+
it uses, identifies the "manifest", (which associates permissions to access
|
|
15
|
+
powers in the bootstrap space with functions to be called), and builds bundles
|
|
16
|
+
of source code needed by the proposal.
|
|
17
|
+
|
|
18
|
+
`.../builders/scripts/vats/upgradeVaults.js` is a canonical example. It says the
|
|
19
|
+
proposal to run is '@agoric/inter-protocol/src/proposals/upgrade-vaults.js',
|
|
20
|
+
lists the manifest there as `'getManifestForUpgradeVaults'`, and directs the
|
|
21
|
+
creation of a bundle from
|
|
22
|
+
'@agoric/inter-protocol/src/vaultFactory/vaultFactory.js', which will be made
|
|
23
|
+
available to the proposal as `vaultsRef` in options.
|
|
24
|
+
|
|
25
|
+
`upgrade-vaults.js` defines `getManifestForUpgradeVaults()`, which returns a
|
|
26
|
+
`manifest` that says `upgradeVaults()` should be executed, and specifies what
|
|
27
|
+
powers it should have access to.
|
|
28
|
+
|
|
29
|
+
### Proposal
|
|
30
|
+
|
|
31
|
+
The proposal is called with `(powers, options)` available. The manifest
|
|
32
|
+
detailing the powers that will be used is usually in the same file, and
|
|
33
|
+
conventionally provided by a function named `getManifestForFoo`. The manifest
|
|
34
|
+
needs to have a unique name, since it will be referenced by name from the
|
|
35
|
+
script. The usual format is
|
|
36
|
+
```js
|
|
37
|
+
export const foo = async (
|
|
38
|
+
{
|
|
39
|
+
consume: {
|
|
40
|
+
...
|
|
41
|
+
},
|
|
42
|
+
brands: {
|
|
43
|
+
...
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
options,
|
|
47
|
+
) => {
|
|
48
|
+
const { fooRef } = options;
|
|
49
|
+
// do the things using powers and options
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const getManifestForFoo = (powers, options) => {
|
|
53
|
+
manifest: {
|
|
54
|
+
[foo.name]: {
|
|
55
|
+
consume: {
|
|
56
|
+
...
|
|
57
|
+
},
|
|
58
|
+
options,
|
|
59
|
+
)};
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`manifest` contains descriptions of powers to be provided to the proposals.
|
|
63
|
+
|
|
64
|
+
**TODO** what happens with the `installations` in [`startPsm.js`](https://github.com/Agoric/agoric-sdk/blob/b13743a2cccf0cb63a412b54384435596d4e81ea/packages/inter-protocol/src/proposals/startPSM.js#L496)?
|
|
65
|
+
|
|
66
|
+
`options` allows the proposal to be provided with arbitray other powerful
|
|
67
|
+
objects.
|
|
68
|
+
|
|
69
|
+
### proposalBuilder Script
|
|
70
|
+
|
|
71
|
+
The script describes how to build the core proposal. For
|
|
72
|
+
`agoric-3-proposals` and uploading to the chain, the script must be named in the
|
|
73
|
+
`CoreProposalSteps` section in
|
|
74
|
+
[`app.go`](https://github.com/Agoric/agoric-sdk/blob/b13743a2cccf0cb63a412b54384435596d4e81ea/golang/cosmos/app/app.go#L881),
|
|
75
|
+
and its `defaultProposalBuilder` will be invoked directly.
|
|
76
|
+
|
|
77
|
+
Script files should export `defaultProposalBuilder` and a `default` function
|
|
78
|
+
that invokes `writeCoreProposal` one or more times to generate sets of files
|
|
79
|
+
describing the proposal.
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
export const defaultProposalBuilder = ({ publishRef, install }) => {
|
|
83
|
+
return harden({
|
|
84
|
+
sourceSpec: '@agoric/vats/src/proposals/foo.js',
|
|
85
|
+
getManifestCall: [
|
|
86
|
+
'getManifestForFoo',
|
|
87
|
+
{
|
|
88
|
+
fooRef: publishRef(install('@agoric/...')),
|
|
89
|
+
...otherParams,
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
`
|
|
95
|
+
export default async (homeP, endowments) => {
|
|
96
|
+
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
|
|
97
|
+
await writeCoreProposal('proposalName', defaultProposalBuilder);
|
|
98
|
+
};
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The first element of `getManifestCall` is interpreted as the name of a proposal.
|
|
102
|
+
The second element of `getManifestCall` produces the `options` argument passed
|
|
103
|
+
to the proposal. (`fooRef` in the example above). A common thing to want to pass
|
|
104
|
+
in options is a reference to code to be installed on-chain. The `fooRef` example
|
|
105
|
+
above shows how. `publishRef(install(<path>))` is built from sources in the
|
|
106
|
+
sdk, and passed as a `bundleRef`, which contains a `bundleID` suitable for
|
|
107
|
+
passing to Zoe (for contracts) or `vatAdminService` (for non-contract vat code).
|
|
108
|
+
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/deploy-script-support",
|
|
3
|
-
"version": "0.10.4-
|
|
3
|
+
"version": "0.10.4-calypso-dev-84eb287.0+84eb287",
|
|
4
4
|
"description": "Helpers and other support for writing deploy scripts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/helpers.js",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": "
|
|
8
|
+
"node": "^18.12 || ^20.9"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "exit 0",
|
|
@@ -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,39 +34,45 @@
|
|
|
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.3.3-
|
|
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-calypso-dev-84eb287.0+84eb287",
|
|
38
|
+
"@agoric/ertp": "0.16.3-calypso-dev-84eb287.0+84eb287",
|
|
39
|
+
"@agoric/import-manager": "0.3.12-calypso-dev-84eb287.0+84eb287",
|
|
40
|
+
"@agoric/internal": "0.3.3-calypso-dev-84eb287.0+84eb287",
|
|
41
|
+
"@agoric/notifier": "0.6.3-calypso-dev-84eb287.0+84eb287",
|
|
42
|
+
"@agoric/store": "0.9.3-calypso-dev-84eb287.0+84eb287",
|
|
43
|
+
"@agoric/time": "0.3.3-calypso-dev-84eb287.0+84eb287",
|
|
44
|
+
"@agoric/zoe": "0.26.3-calypso-dev-84eb287.0+84eb287",
|
|
45
|
+
"@endo/base64": "^1.0.5",
|
|
46
|
+
"@endo/bundle-source": "^3.2.3",
|
|
47
|
+
"@endo/far": "^1.1.2",
|
|
48
|
+
"@endo/marshal": "^1.5.0",
|
|
49
|
+
"@endo/nat": "^5.0.7",
|
|
50
|
+
"@endo/promise-kit": "^1.1.2",
|
|
51
|
+
"@endo/zip": "^1.0.5"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@agoric/vats": "0.15.2-
|
|
54
|
-
"@endo/init": "
|
|
55
|
-
"ava": "^5.
|
|
54
|
+
"@agoric/vats": "0.15.2-calypso-dev-84eb287.0+84eb287",
|
|
55
|
+
"@endo/init": "^1.1.2",
|
|
56
|
+
"ava": "^5.3.0",
|
|
56
57
|
"import-meta-resolve": "^2.2.1"
|
|
57
58
|
},
|
|
58
59
|
"files": [
|
|
59
60
|
"src",
|
|
60
|
-
"NEWS.md"
|
|
61
|
-
"exported.js"
|
|
61
|
+
"NEWS.md"
|
|
62
62
|
],
|
|
63
63
|
"ava": {
|
|
64
64
|
"files": [
|
|
65
|
-
"test
|
|
65
|
+
"test/**/*.test.*"
|
|
66
|
+
],
|
|
67
|
+
"require": [
|
|
68
|
+
"@endo/init/debug.js"
|
|
66
69
|
]
|
|
67
70
|
},
|
|
68
71
|
"publishConfig": {
|
|
69
72
|
"access": "public"
|
|
70
73
|
},
|
|
71
|
-
"
|
|
74
|
+
"typeCoverage": {
|
|
75
|
+
"atLeast": 81.63
|
|
76
|
+
},
|
|
77
|
+
"gitHead": "84eb287915c8255d68e845a9b6e10c790f0d54cb"
|
|
72
78
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
const t = 'makeCoreProposalBehavior';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @import {Installation} from '@agoric/zoe/src/zoeService/utils.js';
|
|
6
|
+
*/
|
|
7
|
+
|
|
4
8
|
/**
|
|
5
9
|
* TODO import these from @agoric/vats when the types are better managed
|
|
6
10
|
*
|
|
@@ -8,7 +12,20 @@ const t = 'makeCoreProposalBehavior';
|
|
|
8
12
|
* @typedef {*} BootstrapPowers
|
|
9
13
|
*/
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @import {ManifestBundleRef} from './externalTypes.js'
|
|
17
|
+
* @typedef {[methodName: string, ...args: unknown[]]} FlatMethargs
|
|
18
|
+
* @typedef {Record<string, Record<string, unknown>>} Manifest
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* These permits are expected to be the minimum powers required by the
|
|
23
|
+
* `coreProposalBehavior` function returned from `makeCoreProposalBehavior`.
|
|
24
|
+
* They are merged with all of the manifest getter's permits to produce the
|
|
25
|
+
* total permits needed by the resulting core proposal (such as might be---and
|
|
26
|
+
* generally are---written into a *-permit.json file).
|
|
27
|
+
* @see {@link ./writeCoreEvalParts.js}
|
|
28
|
+
*/
|
|
12
29
|
export const permits = {
|
|
13
30
|
consume: { agoricNamesAdmin: t, vatAdminSvc: t, zoe: t },
|
|
14
31
|
evaluateBundleCap: t,
|
|
@@ -23,43 +40,74 @@ export const permits = {
|
|
|
23
40
|
* for catching bugs. Thus, this maker must not reference any other modules or
|
|
24
41
|
* definitions.
|
|
25
42
|
*
|
|
26
|
-
* @param {object}
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {typeof import('@endo/far').E}
|
|
31
|
-
* @param {(...args: unknown[]) => void} [
|
|
32
|
-
* @param {(ref:
|
|
43
|
+
* @param {object} inputs
|
|
44
|
+
* @param {ManifestBundleRef} inputs.manifestBundleRef
|
|
45
|
+
* @param {FlatMethargs} inputs.getManifestCall
|
|
46
|
+
* @param {Manifest} [inputs.customManifest]
|
|
47
|
+
* @param {typeof import('@endo/far').E} inputs.E
|
|
48
|
+
* @param {(...args: unknown[]) => void} [inputs.log]
|
|
49
|
+
* @param {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise<import('@agoric/zoe/src/zoeService/utils.js').Installation<unknown>>} [inputs.customRestoreRef]
|
|
33
50
|
* @returns {(vatPowers: unknown) => Promise<unknown>}
|
|
34
51
|
*/
|
|
35
52
|
export const makeCoreProposalBehavior = ({
|
|
36
53
|
manifestBundleRef,
|
|
37
|
-
getManifestCall,
|
|
38
|
-
|
|
54
|
+
getManifestCall: [manifestGetterName, ...manifestGetterArgs],
|
|
55
|
+
customManifest,
|
|
39
56
|
E,
|
|
40
57
|
log = console.info,
|
|
41
|
-
|
|
58
|
+
customRestoreRef,
|
|
42
59
|
}) => {
|
|
43
60
|
const { entries, fromEntries } = Object;
|
|
44
61
|
|
|
45
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Given an object whose properties may be promise-valued, return a promise
|
|
64
|
+
* for an analogous object in which each such value has been replaced with its
|
|
65
|
+
* fulfillment.
|
|
66
|
+
* This is a non-recursive form of endo `deeplyFulfilled`.
|
|
67
|
+
*
|
|
68
|
+
* @template T
|
|
69
|
+
* @param {{[K in keyof T]: (T[K] | Promise<T[K]>)}} obj
|
|
70
|
+
* @returns {Promise<T>}
|
|
71
|
+
*/
|
|
46
72
|
const shallowlyFulfilled = async obj => {
|
|
47
73
|
if (!obj) {
|
|
48
74
|
return obj;
|
|
49
75
|
}
|
|
50
|
-
const
|
|
76
|
+
const awaitedEntries = await Promise.all(
|
|
51
77
|
entries(obj).map(async ([key, valueP]) => {
|
|
52
78
|
const value = await valueP;
|
|
53
79
|
return [key, value];
|
|
54
80
|
}),
|
|
55
81
|
);
|
|
56
|
-
return fromEntries(
|
|
82
|
+
return fromEntries(awaitedEntries);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const makeRestoreRef = (vatAdminSvc, zoe) => {
|
|
86
|
+
/** @type {(ref: import('./externalTypes.js').ManifestBundleRef) => Promise<Installation<unknown>>} */
|
|
87
|
+
const defaultRestoreRef = async bundleRef => {
|
|
88
|
+
// extract-proposal.js creates these records, and bundleName is
|
|
89
|
+
// the optional name under which the bundle was installed into
|
|
90
|
+
// config.bundles
|
|
91
|
+
const bundleIdP =
|
|
92
|
+
'bundleName' in bundleRef
|
|
93
|
+
? E(vatAdminSvc).getBundleIDByName(bundleRef.bundleName)
|
|
94
|
+
: bundleRef.bundleID;
|
|
95
|
+
const bundleID = await bundleIdP;
|
|
96
|
+
const label = bundleID.slice(0, 8);
|
|
97
|
+
return E(zoe).installBundleID(bundleID, label);
|
|
98
|
+
};
|
|
99
|
+
return defaultRestoreRef;
|
|
57
100
|
};
|
|
58
101
|
|
|
59
|
-
/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }}
|
|
60
|
-
const
|
|
61
|
-
// NOTE:
|
|
62
|
-
//
|
|
102
|
+
/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} powers */
|
|
103
|
+
const coreProposalBehavior = async powers => {
|
|
104
|
+
// NOTE: `powers` is expected to match or be a superset of the above `permits` export,
|
|
105
|
+
// which should therefore be kept in sync with this deconstruction code.
|
|
106
|
+
// HOWEVER, do note that this function is invoked with at least the *union* of powers
|
|
107
|
+
// required by individual moduleBehaviors declared by the manifest getter, which is
|
|
108
|
+
// necessary so it can use `runModuleBehaviors` to provide the appropriate subset to
|
|
109
|
+
// each one (see ./writeCoreEvalParts.js).
|
|
110
|
+
// Handle `powers` with the requisite care.
|
|
63
111
|
const {
|
|
64
112
|
consume: { vatAdminSvc, zoe, agoricNamesAdmin },
|
|
65
113
|
evaluateBundleCap,
|
|
@@ -67,70 +115,70 @@ export const makeCoreProposalBehavior = ({
|
|
|
67
115
|
modules: {
|
|
68
116
|
utils: { runModuleBehaviors },
|
|
69
117
|
},
|
|
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;
|
|
118
|
+
} = powers;
|
|
85
119
|
|
|
86
120
|
// Get the on-chain installation containing the manifest and behaviors.
|
|
87
|
-
|
|
121
|
+
log('evaluateBundleCap', {
|
|
88
122
|
manifestBundleRef,
|
|
89
|
-
|
|
123
|
+
manifestGetterName,
|
|
90
124
|
vatAdminSvc,
|
|
91
125
|
});
|
|
92
126
|
let bcapP;
|
|
93
127
|
if ('bundleName' in manifestBundleRef) {
|
|
94
128
|
bcapP = E(vatAdminSvc).getNamedBundleCap(manifestBundleRef.bundleName);
|
|
95
|
-
} else {
|
|
129
|
+
} else if ('bundleID' in manifestBundleRef) {
|
|
96
130
|
bcapP = E(vatAdminSvc).getBundleCap(manifestBundleRef.bundleID);
|
|
131
|
+
} else {
|
|
132
|
+
const keys = Reflect.ownKeys(manifestBundleRef).map(key =>
|
|
133
|
+
typeof key === 'string' ? JSON.stringify(key) : String(key),
|
|
134
|
+
);
|
|
135
|
+
const keysStr = `[${keys.join(', ')}]`;
|
|
136
|
+
throw Error(
|
|
137
|
+
`bundleRef must have own bundleName or bundleID, missing in ${keysStr}`,
|
|
138
|
+
);
|
|
97
139
|
}
|
|
98
140
|
const bundleCap = await bcapP;
|
|
99
141
|
|
|
100
|
-
const
|
|
142
|
+
const proposalNS = await evaluateBundleCap(bundleCap);
|
|
101
143
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
144
|
+
// Get the manifest and its metadata.
|
|
145
|
+
log('execute', {
|
|
146
|
+
manifestGetterName,
|
|
147
|
+
bundleExports: Object.keys(proposalNS),
|
|
105
148
|
});
|
|
149
|
+
const restoreRef = customRestoreRef || makeRestoreRef(vatAdminSvc, zoe);
|
|
106
150
|
const {
|
|
107
151
|
manifest,
|
|
108
152
|
options: rawOptions,
|
|
109
153
|
installations: rawInstallations,
|
|
110
|
-
} = await
|
|
154
|
+
} = await proposalNS[manifestGetterName](
|
|
111
155
|
harden({ restoreRef }),
|
|
112
|
-
...
|
|
156
|
+
...manifestGetterArgs,
|
|
113
157
|
);
|
|
114
158
|
|
|
115
|
-
// Await
|
|
159
|
+
// Await promises in the returned options and installations records.
|
|
116
160
|
const [options, installations] = await Promise.all(
|
|
117
161
|
[rawOptions, rawInstallations].map(shallowlyFulfilled),
|
|
118
162
|
);
|
|
119
163
|
|
|
120
|
-
// Publish the installations for
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
164
|
+
// Publish the installations for our dependencies.
|
|
165
|
+
const installationEntries = entries(installations || {});
|
|
166
|
+
if (installationEntries.length > 0) {
|
|
167
|
+
const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation');
|
|
168
|
+
await Promise.all(
|
|
169
|
+
installationEntries.map(([key, value]) => {
|
|
170
|
+
produceInstallations[key].resolve(value);
|
|
171
|
+
return E(installAdmin).update(key, value);
|
|
172
|
+
}),
|
|
173
|
+
);
|
|
174
|
+
}
|
|
128
175
|
|
|
129
|
-
// Evaluate the manifest
|
|
176
|
+
// Evaluate the manifest.
|
|
130
177
|
return runModuleBehaviors({
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
178
|
+
// Remember that `powers` may be arbitrarily broad.
|
|
179
|
+
allPowers: powers,
|
|
180
|
+
behaviors: proposalNS,
|
|
181
|
+
manifest: customManifest || manifest,
|
|
134
182
|
makeConfig: (name, _permit) => {
|
|
135
183
|
log('coreProposal:', name);
|
|
136
184
|
return { options };
|
|
@@ -138,22 +186,31 @@ export const makeCoreProposalBehavior = ({
|
|
|
138
186
|
});
|
|
139
187
|
};
|
|
140
188
|
|
|
141
|
-
|
|
142
|
-
return behavior;
|
|
189
|
+
return coreProposalBehavior;
|
|
143
190
|
};
|
|
144
191
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
192
|
+
/**
|
|
193
|
+
* @param {object} inputs
|
|
194
|
+
* @param {Array<{ ref: ManifestBundleRef, call: FlatMethargs, customManifest?: Manifest }>} inputs.metadataRecords
|
|
195
|
+
* @param {typeof import('@endo/far').E} inputs.E
|
|
196
|
+
*/
|
|
197
|
+
export const makeEnactCoreProposalsFromBundleRef = ({ metadataRecords, E }) => {
|
|
198
|
+
/**
|
|
199
|
+
* @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} powers
|
|
200
|
+
* @returns {Promise<void>}
|
|
201
|
+
*/
|
|
202
|
+
const enactCoreProposals = async powers => {
|
|
148
203
|
await Promise.all(
|
|
149
|
-
|
|
150
|
-
const
|
|
204
|
+
metadataRecords.map(async ({ ref, call, customManifest }) => {
|
|
205
|
+
const coreProposalBehavior = makeCoreProposalBehavior({
|
|
151
206
|
manifestBundleRef: ref,
|
|
152
207
|
getManifestCall: call,
|
|
153
|
-
|
|
208
|
+
customManifest,
|
|
154
209
|
E,
|
|
155
210
|
});
|
|
156
|
-
return
|
|
211
|
+
return coreProposalBehavior(powers);
|
|
157
212
|
}),
|
|
158
213
|
);
|
|
159
214
|
};
|
|
215
|
+
return enactCoreProposals;
|
|
216
|
+
};
|
package/src/externalTypes.js
CHANGED
|
@@ -10,37 +10,40 @@ export {};
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @typedef
|
|
14
|
-
* @property {string} sourceSpec
|
|
15
|
-
* @property {[exportedGetManifest: string, ...manifestArgs: any[]]} getManifestCall
|
|
13
|
+
* @typedef {{fileName?: string} & ({ bundleName: string } | { bundleID: string}) } ManifestBundleRef
|
|
16
14
|
*/
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
|
-
* @
|
|
20
|
-
* @
|
|
17
|
+
* @callback PublishBundleRef
|
|
18
|
+
* @param {ERef<ManifestBundleRef>} bundle
|
|
19
|
+
* @returns {Promise<ManifestBundleRef>}
|
|
21
20
|
*/
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
|
-
* @callback
|
|
25
|
-
* @param {
|
|
26
|
-
* @
|
|
23
|
+
* @callback InstallEntrypoint
|
|
24
|
+
* @param {string} srcSpec
|
|
25
|
+
* @param {string} [bundlePath]
|
|
26
|
+
* @param {unknown} [opts]
|
|
27
|
+
* @returns {Promise<ManifestBundleRef>}
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
32
|
-
* @
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* @typedef CoreEvalDescriptor
|
|
32
|
+
* @property {string} sourceSpec import specifier for a module
|
|
33
|
+
* @property {[manifestGetterName: string, ...manifestGetterArgs: any[]]} getManifestCall
|
|
34
|
+
* the name of a function exported by the module and arguments to invoke it
|
|
35
|
+
* with in order to get a manifest (a Record that associates functions to be
|
|
36
|
+
* invoked and permits defining bootstrap-space powers they will have access
|
|
37
|
+
* to, see {@link ../README.md} and {@link runModuleBehaviors})
|
|
35
38
|
*/
|
|
36
39
|
|
|
37
40
|
/**
|
|
38
|
-
* @callback
|
|
41
|
+
* @callback CoreEvalBuilder
|
|
39
42
|
* @param {{
|
|
40
43
|
* publishRef: PublishBundleRef,
|
|
41
|
-
* install:
|
|
42
|
-
* wrapInstall?: <T>(f: T) => T }
|
|
44
|
+
* install: InstallEntrypoint,
|
|
45
|
+
* wrapInstall?: <T extends InstallEntrypoint>(f: T) => T }
|
|
43
46
|
* } powers
|
|
44
47
|
* @param {...any} args
|
|
45
|
-
* @returns {Promise<
|
|
48
|
+
* @returns {Promise<CoreEvalDescriptor>}
|
|
46
49
|
*/
|