@agoric/deploy-script-support 0.10.4-other-dev-8f8782b.0 → 0.10.4-other-dev-fbe72e7.0.fbe72e7
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 +120 -2
- package/package.json +34 -27
- package/src/assertOfferResult.js +5 -1
- package/src/cachedBundleSpec.js +4 -1
- package/src/coreProposalBehavior.js +122 -64
- package/src/depositInvitation.js +5 -0
- package/src/endo-pieces-contract.js +4 -2
- package/src/externalTypes.js +63 -17
- package/src/extract-proposal.js +229 -154
- package/src/getBundlerMaker.js +4 -0
- package/src/helpers.js +22 -3
- package/src/install.js +2 -11
- package/src/offer.js +10 -7
- package/src/parseCoreEvalArgs.js +36 -0
- package/src/permissioned-deployment.js +168 -0
- package/src/saveIssuer.js +5 -2
- package/src/startInstance.js +8 -5
- package/src/writeCoreEvalParts.js +228 -0
- package/CHANGELOG.md +0 -546
- package/exported.js +0 -3
- package/src/writeCoreProposal.js +0 -139
package/README.md
CHANGED
|
@@ -1,4 +1,122 @@
|
|
|
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
|
+
write a script to build the core proposal. The proposals' access to bootstrap
|
|
5
|
+
powers is limited 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
|
+
and inter-protocol/src/proposals.
|
|
10
|
+
|
|
11
|
+
The overall format is a proposalBuilder script (There are several in
|
|
12
|
+
.../builders/scripts/vats/) which has a default export that passes resources to
|
|
13
|
+
the proposal. The resources include bundled source code and string-value
|
|
14
|
+
parameters. The script exports a CoreEvalBuilder named `defaultProposalBuilder`
|
|
15
|
+
that specifies (as an import string) the proposal it uses, identifies the
|
|
16
|
+
"manifest", (which associates permissions to access powers in the bootstrap
|
|
17
|
+
space with functions to be called), and builds bundles of source code needed by
|
|
18
|
+
the proposal.
|
|
19
|
+
|
|
20
|
+
Here's a simple example:
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { makeHelpers } from '@agoric/deploy-script-support';
|
|
24
|
+
import { getManifestForGame1 } from '@agoric/smart-wallet/test/start-game1-proposal.js';
|
|
25
|
+
|
|
26
|
+
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
|
|
27
|
+
const game1ProposalBuilder = async ({ publishRef, install }) => {
|
|
28
|
+
return harden({
|
|
29
|
+
sourceSpec: '@agoric/smart-wallet/test/start-game1-proposal.js',
|
|
30
|
+
getManifestCall: [
|
|
31
|
+
getManifestForGame1.name,
|
|
32
|
+
{
|
|
33
|
+
game1Ref: publishRef(
|
|
34
|
+
install(
|
|
35
|
+
'@agoric/smart-wallet/test/gameAssetContract.js',
|
|
36
|
+
'../bundles/bundle-game1.js',
|
|
37
|
+
{ persist: true },
|
|
38
|
+
),
|
|
39
|
+
),
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default async (homeP, endowments) => {
|
|
46
|
+
const { writeCoreEval } = await makeHelpers(homeP, endowments);
|
|
47
|
+
await writeCoreEval('start-game1', game1ProposalBuilder);
|
|
48
|
+
};
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
This CoreEvalBuilder returns an object whose "sourceSpec" indicates that the
|
|
52
|
+
proposal to run is "@agoric/smart-wallet/test/start-game1-proposal.js" and whose
|
|
53
|
+
"getManifestCall" is a [functionName, ...args] array describing an invocation of
|
|
54
|
+
`getManifestForGame1` exported from that file which is expected to return an
|
|
55
|
+
object including a "manifest" as described below (but the actual invocation will
|
|
56
|
+
insert as the first argument a "powers" object that includes functions such as
|
|
57
|
+
`restoreRef`). A common thing to want to pass in `args` is a reference to code
|
|
58
|
+
to be installed on-chain, and the example above shows how.
|
|
59
|
+
`publishRef(install(...))` is built from sources in agoric-sdk, and passed as a
|
|
60
|
+
`bundleRef`, which contains a `bundleID` suitable for passing to Zoe (for
|
|
61
|
+
contracts) or `vatAdminService` (for non-contract vat code).
|
|
62
|
+
|
|
63
|
+
The manifest from such an invocation is a JSON-serializable object in which each
|
|
64
|
+
key is the name of a function to itself be invoked and the corresponding value
|
|
65
|
+
is a "permit" describing an attenuation of the core-eval promise space to be
|
|
66
|
+
provided as its first argument. A permit is either `true` or a string (_both
|
|
67
|
+
meaning no attenuation of the respective subtree of the promise space, with a
|
|
68
|
+
string serving as a grouping label for convenience and/or diagram generation_),
|
|
69
|
+
or an object whose keys identify child properties and whose corresponding values
|
|
70
|
+
are theirselves (recursive) permits. See `BootstrapManifiest` in
|
|
71
|
+
[lib-boot.js](../vats/src/core/lib-boot.js).
|
|
72
|
+
|
|
73
|
+
The manifest object returned from a "getManifestCall" invocation may also
|
|
74
|
+
include "installations" (they'll be registered with `agoricNames` and in the
|
|
75
|
+
bootstrap promise space) and/or "options" (they'll be provided as the "options"
|
|
76
|
+
property of the second argument for each call of the manifest's functions):
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
/** @type {import('@agoric/vats/src/core/lib-boot').BootstrapManifest} */
|
|
80
|
+
const gameManifest = harden({
|
|
81
|
+
[startGameContract.name]: {
|
|
82
|
+
consume: {...},
|
|
83
|
+
brand: {...},
|
|
84
|
+
issuer: {...},
|
|
85
|
+
...
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
export const getManifestForGame1 = ({ restoreRef }, { game1Ref }) => {
|
|
90
|
+
return harden({
|
|
91
|
+
manifest: gameManifest,
|
|
92
|
+
// a reference to the game1 bundle will be published in agoricNames as "game1"
|
|
93
|
+
installations: {
|
|
94
|
+
game1: restoreRef(game1Ref),
|
|
95
|
+
},
|
|
96
|
+
// the second argument of `startGameContract` will be `{ options: ["foo"] }`
|
|
97
|
+
options: ["foo"],
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Invoking the coreEval Behavior
|
|
103
|
+
|
|
104
|
+
The proposalBuilder script's default export is responsible for calling
|
|
105
|
+
`writeCoreEval()` to produce the scripts that will be evaluated by the chain.
|
|
106
|
+
These define behavior functions that will be invoked based on the keys in the
|
|
107
|
+
manifest and passed arguments declared in the manifest. The manifest is usually
|
|
108
|
+
in the same file, and conventionally provided by a function named
|
|
109
|
+
`getManifestForFoo`. The manifest needs to have a unique name, since it will be
|
|
110
|
+
referenced by name from the script.
|
|
111
|
+
|
|
112
|
+
### proposalBuilder Script
|
|
113
|
+
|
|
114
|
+
The script describes how to build the core proposal. Script files should export
|
|
115
|
+
`defaultProposalBuilder` and a `default` function that invokes
|
|
116
|
+
`writeCoreProposal` one or more times to generate sets of files describing the
|
|
117
|
+
proposal.
|
|
118
|
+
|
|
119
|
+
Chain-halting SoftwareUpgrades can include coreEvals, by adding them to the
|
|
120
|
+
`CoreProposalSteps` section in [`upgrade.go`](../../golang/cosmos/app/upgrade.go). To execute a proposal via
|
|
121
|
+
CoreEval, follow [the instructions at
|
|
122
|
+
docs.agoric.com](https://docs.agoric.com/guides/coreeval/local-testnet.html).
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/deploy-script-support",
|
|
3
|
-
"version": "0.10.4-other-dev-
|
|
3
|
+
"version": "0.10.4-other-dev-fbe72e7.0.fbe72e7",
|
|
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": "^20.9 || ^22.11"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "exit 0",
|
|
12
12
|
"test": "ava",
|
|
13
13
|
"test:xs": "exit 0",
|
|
14
14
|
"lint-fix": "yarn lint:eslint --fix",
|
|
15
|
-
"lint:eslint": "eslint .",
|
|
16
|
-
"lint:types": "
|
|
17
|
-
"lint": "run-s --continue-on-error lint:*"
|
|
15
|
+
"lint:eslint": "yarn run -T eslint .",
|
|
16
|
+
"lint:types": "yarn run -T tsc",
|
|
17
|
+
"lint": "yarn run -T run-s --continue-on-error 'lint:*'"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -34,39 +34,46 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@agoric/
|
|
38
|
-
"@agoric/
|
|
39
|
-
"@agoric/
|
|
40
|
-
"@agoric/
|
|
41
|
-
"@agoric/
|
|
42
|
-
"@agoric/store": "0.9.3-other-dev-
|
|
43
|
-
"@agoric/
|
|
44
|
-
"@
|
|
45
|
-
"@endo/
|
|
46
|
-
"@endo/
|
|
47
|
-
"@endo/
|
|
48
|
-
"@endo/
|
|
49
|
-
"@endo/
|
|
50
|
-
"@endo/
|
|
37
|
+
"@agoric/ertp": "0.16.3-other-dev-fbe72e7.0.fbe72e7",
|
|
38
|
+
"@agoric/import-manager": "0.3.12-other-dev-fbe72e7.0.fbe72e7",
|
|
39
|
+
"@agoric/internal": "0.3.3-other-dev-fbe72e7.0.fbe72e7",
|
|
40
|
+
"@agoric/notifier": "0.6.3-other-dev-fbe72e7.0.fbe72e7",
|
|
41
|
+
"@agoric/pola-io": "0.1.1-other-dev-fbe72e7.0.fbe72e7",
|
|
42
|
+
"@agoric/store": "0.9.3-other-dev-fbe72e7.0.fbe72e7",
|
|
43
|
+
"@agoric/time": "0.3.3-other-dev-fbe72e7.0.fbe72e7",
|
|
44
|
+
"@agoric/zoe": "0.26.3-other-dev-fbe72e7.0.fbe72e7",
|
|
45
|
+
"@endo/base64": "^1.0.12",
|
|
46
|
+
"@endo/bundle-source": "^4.1.2",
|
|
47
|
+
"@endo/errors": "^1.2.13",
|
|
48
|
+
"@endo/far": "^1.1.14",
|
|
49
|
+
"@endo/marshal": "^1.8.0",
|
|
50
|
+
"@endo/nat": "^5.1.3",
|
|
51
|
+
"@endo/promise-kit": "^1.1.13",
|
|
52
|
+
"@endo/zip": "^1.0.11"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
|
-
"@agoric/vats": "0.15.2-other-dev-
|
|
54
|
-
"@endo/init": "
|
|
55
|
-
"ava": "^5.
|
|
56
|
-
"import-meta-resolve": "^
|
|
55
|
+
"@agoric/vats": "0.15.2-other-dev-fbe72e7.0.fbe72e7",
|
|
56
|
+
"@endo/init": "^1.1.12",
|
|
57
|
+
"ava": "^5.3.0",
|
|
58
|
+
"import-meta-resolve": "^4.1.0"
|
|
57
59
|
},
|
|
58
60
|
"files": [
|
|
59
61
|
"src",
|
|
60
|
-
"NEWS.md"
|
|
61
|
-
"exported.js"
|
|
62
|
+
"NEWS.md"
|
|
62
63
|
],
|
|
63
64
|
"ava": {
|
|
64
65
|
"files": [
|
|
65
|
-
"test
|
|
66
|
+
"test/**/*.test.*"
|
|
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": 83.26
|
|
77
|
+
},
|
|
78
|
+
"gitHead": "fbe72e72107f9997f788674e668c660d92ec4492"
|
|
72
79
|
}
|
package/src/assertOfferResult.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { Fail } from '@
|
|
2
|
+
import { Fail } from '@endo/errors';
|
|
3
3
|
import { E } from '@endo/far';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @import {InvitationDetails, PaymentPKeywordRecord, Proposal, UserSeat} from '@agoric/zoe';
|
|
7
|
+
*/
|
|
8
|
+
|
|
5
9
|
/**
|
|
6
10
|
* @param {ERef<UserSeat>} seat
|
|
7
11
|
* @param {string} expectedOfferResult
|
package/src/cachedBundleSpec.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { Fail } from '@endo/errors';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @param {string} cacheDir
|
|
@@ -6,6 +6,9 @@ const { Fail } = assert;
|
|
|
6
6
|
*/
|
|
7
7
|
export const makeCacheAndGetBundleSpec =
|
|
8
8
|
(cacheDir, { now, fs, pathResolve }) =>
|
|
9
|
+
/**
|
|
10
|
+
* @param {Promise<import('@endo/bundle-source').BundleSourceResult<'endoZipBase64'>>} bundleP
|
|
11
|
+
*/
|
|
9
12
|
async bundleP => {
|
|
10
13
|
const bundle = await bundleP;
|
|
11
14
|
const { endoZipBase64Sha512: hash } = bundle;
|
|
@@ -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,71 @@ 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].reset();
|
|
171
|
+
produceInstallations[key].resolve(value);
|
|
172
|
+
return E(installAdmin).update(key, value);
|
|
173
|
+
}),
|
|
174
|
+
);
|
|
175
|
+
}
|
|
128
176
|
|
|
129
|
-
// Evaluate the manifest
|
|
177
|
+
// Evaluate the manifest.
|
|
130
178
|
return runModuleBehaviors({
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
179
|
+
// Remember that `powers` may be arbitrarily broad.
|
|
180
|
+
allPowers: powers,
|
|
181
|
+
behaviors: proposalNS,
|
|
182
|
+
manifest: customManifest || manifest,
|
|
134
183
|
makeConfig: (name, _permit) => {
|
|
135
184
|
log('coreProposal:', name);
|
|
136
185
|
return { options };
|
|
@@ -138,22 +187,31 @@ export const makeCoreProposalBehavior = ({
|
|
|
138
187
|
});
|
|
139
188
|
};
|
|
140
189
|
|
|
141
|
-
|
|
142
|
-
return behavior;
|
|
190
|
+
return coreProposalBehavior;
|
|
143
191
|
};
|
|
144
192
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
193
|
+
/**
|
|
194
|
+
* @param {object} inputs
|
|
195
|
+
* @param {Array<{ ref: ManifestBundleRef, call: FlatMethargs, customManifest?: Manifest }>} inputs.metadataRecords
|
|
196
|
+
* @param {typeof import('@endo/far').E} inputs.E
|
|
197
|
+
*/
|
|
198
|
+
export const makeEnactCoreProposalsFromBundleRef = ({ metadataRecords, E }) => {
|
|
199
|
+
/**
|
|
200
|
+
* @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} powers
|
|
201
|
+
* @returns {Promise<void>}
|
|
202
|
+
*/
|
|
203
|
+
const enactCoreProposals = async powers => {
|
|
148
204
|
await Promise.all(
|
|
149
|
-
|
|
150
|
-
const
|
|
205
|
+
metadataRecords.map(async ({ ref, call, customManifest }) => {
|
|
206
|
+
const coreProposalBehavior = makeCoreProposalBehavior({
|
|
151
207
|
manifestBundleRef: ref,
|
|
152
208
|
getManifestCall: call,
|
|
153
|
-
|
|
209
|
+
customManifest,
|
|
154
210
|
E,
|
|
155
211
|
});
|
|
156
|
-
return
|
|
212
|
+
return coreProposalBehavior(powers);
|
|
157
213
|
}),
|
|
158
214
|
);
|
|
159
215
|
};
|
|
216
|
+
return enactCoreProposals;
|
|
217
|
+
};
|
package/src/depositInvitation.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
import { Fail, q } from '@endo/errors';
|
|
2
3
|
import { E, Far } from '@endo/far';
|
|
3
4
|
import { encodeBase64, decodeBase64 } from '@endo/base64';
|
|
4
5
|
import { ZipWriter } from '@endo/zip';
|
|
5
6
|
|
|
6
|
-
const { Fail, quote: q } = assert;
|
|
7
|
-
|
|
8
7
|
export const start = () => {
|
|
9
8
|
/** @type { Map<string, [string, Uint8Array]>} */
|
|
10
9
|
const hashToEntry = new Map();
|
|
@@ -18,6 +17,9 @@ export const start = () => {
|
|
|
18
17
|
});
|
|
19
18
|
};
|
|
20
19
|
|
|
20
|
+
/**
|
|
21
|
+
* @param {{ zoe: ERef<ZoeService> }} opts
|
|
22
|
+
*/
|
|
21
23
|
const makeBundler = ({ zoe }) => {
|
|
22
24
|
/** @type { Map<string, [string, Uint8Array]>} */
|
|
23
25
|
const nameToContent = new Map();
|
package/src/externalTypes.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
export {};
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @import {NameHub} from '@agoric/vats';
|
|
6
|
+
*/
|
|
7
|
+
|
|
4
8
|
// TODO move this type somewhere better
|
|
5
9
|
/**
|
|
6
10
|
* @typedef {string | string[]} Petname A petname can either be a plain string
|
|
@@ -10,37 +14,79 @@ export {};
|
|
|
10
14
|
*/
|
|
11
15
|
|
|
12
16
|
/**
|
|
13
|
-
* @typedef
|
|
14
|
-
* @property {string} sourceSpec
|
|
15
|
-
* @property {[exportedGetManifest: string, ...manifestArgs: any[]]} getManifestCall
|
|
17
|
+
* @typedef {{fileName?: string} & ({ bundleName: string } | { bundleID: string}) } ManifestBundleRef
|
|
16
18
|
*/
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
|
-
* @
|
|
20
|
-
* @
|
|
21
|
+
* @callback PublishBundleRef
|
|
22
|
+
* @param {ERef<ManifestBundleRef>} bundle
|
|
23
|
+
* @returns {Promise<ManifestBundleRef>}
|
|
21
24
|
*/
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
|
-
* @callback
|
|
25
|
-
* @param {
|
|
26
|
-
* @
|
|
27
|
+
* @callback InstallEntrypoint
|
|
28
|
+
* @param {string} srcSpec
|
|
29
|
+
* @param {string} [bundlePath]
|
|
30
|
+
* @param {unknown} [opts]
|
|
31
|
+
* @returns {Promise<ManifestBundleRef>}
|
|
27
32
|
*/
|
|
28
33
|
|
|
29
34
|
/**
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
32
|
-
* @
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
+
* @typedef CoreEvalDescriptor
|
|
36
|
+
* @property {string} sourceSpec import specifier for a module
|
|
37
|
+
* @property {[manifestGetterName: string, ...manifestGetterArgs: any[]]} getManifestCall
|
|
38
|
+
* the name of a function exported by the module and arguments to invoke it
|
|
39
|
+
* with in order to get a manifest (a Record that associates functions to be
|
|
40
|
+
* invoked and permits defining bootstrap-space powers they will have access
|
|
41
|
+
* to, see {@link ../README.md} and {@link runModuleBehaviors})
|
|
35
42
|
*/
|
|
36
43
|
|
|
37
44
|
/**
|
|
38
|
-
* @callback
|
|
45
|
+
* @callback CoreEvalBuilder
|
|
39
46
|
* @param {{
|
|
40
47
|
* publishRef: PublishBundleRef,
|
|
41
|
-
* install:
|
|
42
|
-
* wrapInstall?: <T>(f: T) => T }
|
|
48
|
+
* install: InstallEntrypoint,
|
|
49
|
+
* wrapInstall?: <T extends InstallEntrypoint>(f: T) => T }
|
|
43
50
|
* } powers
|
|
44
51
|
* @param {...any} args
|
|
45
|
-
* @returns {Promise<
|
|
52
|
+
* @returns {Promise<CoreEvalDescriptor>}
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @typedef {{
|
|
57
|
+
* bundleSource: typeof import('@endo/bundle-source').default,
|
|
58
|
+
* cacheDir: string,
|
|
59
|
+
* lookup: (...path: string[]) => unknown,
|
|
60
|
+
* now: () => number,
|
|
61
|
+
* pathResolve: (...path: string[]) => string,
|
|
62
|
+
* publishBundle: PublishBundleRef,
|
|
63
|
+
* scriptArgs?: string[],
|
|
64
|
+
* }} DeployScriptEndownments
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @typedef {{
|
|
69
|
+
* scratch: ERef<import('@agoric/internal/src/scratch.js').ScratchPad>,
|
|
70
|
+
* }} CommonHome
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
// TODO wallet as import('@agoric/wallet-backend/src/types').WalletAdmin once it's a module
|
|
74
|
+
/**
|
|
75
|
+
* @typedef {CommonHome & {
|
|
76
|
+
* agoricNames: ERef<NameHub>,
|
|
77
|
+
* bank: ERef<import("@agoric/vats/src/vat-bank.js").Bank>,
|
|
78
|
+
* board: ERef<import("@agoric/vats").Board>,
|
|
79
|
+
* faucet: unknown,
|
|
80
|
+
* myAddressNameAdmin: ERef<import("@agoric/vats").NameAdmin>,
|
|
81
|
+
* namesByAddress: ERef<NameHub>,
|
|
82
|
+
* wallet: any,
|
|
83
|
+
* zoe: ERef<ZoeService>,
|
|
84
|
+
* }} AgSoloHome
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @callback DeployScriptFunction
|
|
89
|
+
* @param {Promise<CommonHome>} homeP
|
|
90
|
+
* @param {DeployScriptEndownments} endowments
|
|
91
|
+
* @returns {Promise<void>}
|
|
46
92
|
*/
|