@agoric/deploy-script-support 0.10.4-other-dev-3eb1a1d.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 +8 -3
- package/package.json +26 -25
- package/src/assertOfferResult.js +4 -0
- package/src/depositInvitation.js +5 -0
- package/src/helpers.js +1 -0
- package/src/offer.js +5 -1
- package/src/parseCoreEvalArgs.js +36 -0
- package/src/permissioned-deployment.js +168 -0
- package/src/saveIssuer.js +4 -1
- package/src/startInstance.js +5 -1
package/README.md
CHANGED
|
@@ -70,9 +70,11 @@ or an object whose keys identify child properties and whose corresponding values
|
|
|
70
70
|
are theirselves (recursive) permits. See `BootstrapManifiest` in
|
|
71
71
|
[lib-boot.js](../vats/src/core/lib-boot.js).
|
|
72
72
|
|
|
73
|
-
The object returned from a "getManifestCall" invocation may also
|
|
74
|
-
"installations"
|
|
75
|
-
|
|
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
|
+
|
|
76
78
|
```js
|
|
77
79
|
/** @type {import('@agoric/vats/src/core/lib-boot').BootstrapManifest} */
|
|
78
80
|
const gameManifest = harden({
|
|
@@ -87,9 +89,12 @@ const gameManifest = harden({
|
|
|
87
89
|
export const getManifestForGame1 = ({ restoreRef }, { game1Ref }) => {
|
|
88
90
|
return harden({
|
|
89
91
|
manifest: gameManifest,
|
|
92
|
+
// a reference to the game1 bundle will be published in agoricNames as "game1"
|
|
90
93
|
installations: {
|
|
91
94
|
game1: restoreRef(game1Ref),
|
|
92
95
|
},
|
|
96
|
+
// the second argument of `startGameContract` will be `{ options: ["foo"] }`
|
|
97
|
+
options: ["foo"],
|
|
93
98
|
});
|
|
94
99
|
};
|
|
95
100
|
```
|
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": "tsc",
|
|
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,27 +34,28 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@agoric/ertp": "0.16.3-other-dev-
|
|
38
|
-
"@agoric/import-manager": "0.3.12-other-dev-
|
|
39
|
-
"@agoric/internal": "0.3.3-other-dev-
|
|
40
|
-
"@agoric/notifier": "0.6.3-other-dev-
|
|
41
|
-
"@agoric/
|
|
42
|
-
"@agoric/
|
|
43
|
-
"@agoric/
|
|
44
|
-
"@
|
|
45
|
-
"@endo/
|
|
46
|
-
"@endo/
|
|
47
|
-
"@endo/
|
|
48
|
-
"@endo/
|
|
49
|
-
"@endo/
|
|
50
|
-
"@endo/
|
|
51
|
-
"@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"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@agoric/vats": "0.15.2-other-dev-
|
|
55
|
-
"@endo/init": "^1.1.
|
|
55
|
+
"@agoric/vats": "0.15.2-other-dev-fbe72e7.0.fbe72e7",
|
|
56
|
+
"@endo/init": "^1.1.12",
|
|
56
57
|
"ava": "^5.3.0",
|
|
57
|
-
"import-meta-resolve": "^
|
|
58
|
+
"import-meta-resolve": "^4.1.0"
|
|
58
59
|
},
|
|
59
60
|
"files": [
|
|
60
61
|
"src",
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
"access": "public"
|
|
73
74
|
},
|
|
74
75
|
"typeCoverage": {
|
|
75
|
-
"atLeast": 83.
|
|
76
|
+
"atLeast": 83.26
|
|
76
77
|
},
|
|
77
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "fbe72e72107f9997f788674e668c660d92ec4492"
|
|
78
79
|
}
|
package/src/assertOfferResult.js
CHANGED
package/src/depositInvitation.js
CHANGED
package/src/helpers.js
CHANGED
|
@@ -20,6 +20,7 @@ import { installInPieces } from './installInPieces.js';
|
|
|
20
20
|
import { makeWriteCoreEval } from './writeCoreEvalParts.js';
|
|
21
21
|
|
|
22
22
|
export * from '@agoric/internal/src/node/createBundles.js';
|
|
23
|
+
export { parseScriptArgs } from './parseCoreEvalArgs.js';
|
|
23
24
|
|
|
24
25
|
// These are also hard-coded in lib-wallet.js.
|
|
25
26
|
// TODO: Add methods to the wallet to access these without hard-coding
|
package/src/offer.js
CHANGED
|
@@ -4,7 +4,11 @@ import { E } from '@endo/far';
|
|
|
4
4
|
// Avoid pulling in too many dependencies like notifiers
|
|
5
5
|
import { AmountMath } from '@agoric/ertp/src/amountMath.js';
|
|
6
6
|
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js';
|
|
9
|
+
* @import {Amount, Brand, Issuer, Payment, Purse} from '@agoric/ertp';
|
|
10
|
+
* @import {InvitationDetails, Keyword, Proposal} from '@agoric/zoe';
|
|
11
|
+
*/
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* @typedef {object} OfferHelperConfig
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* To customize proposals for multiple environments, we pass the "variant"
|
|
3
|
+
* identifier in scriptArgs. The variant must match a knownVariant.
|
|
4
|
+
*
|
|
5
|
+
* @param {import('./externalTypes.js').DeployScriptEndownments} endowments
|
|
6
|
+
* @param {string} name a name to use in error messages or Usage suggestions.
|
|
7
|
+
* @param {string[]} knownVariants
|
|
8
|
+
*/
|
|
9
|
+
export const parseScriptArgs = async (endowments, name, knownVariants) => {
|
|
10
|
+
const { scriptArgs } = endowments;
|
|
11
|
+
// const variantOrConfig = scriptArgs?.[0];
|
|
12
|
+
const variantOrConfig =
|
|
13
|
+
scriptArgs && scriptArgs.length > 0 ? scriptArgs : undefined;
|
|
14
|
+
|
|
15
|
+
console.log(`${name}`, variantOrConfig);
|
|
16
|
+
|
|
17
|
+
const Usage = `agoric run ${name}.js ${[...knownVariants, '<json-config>'].join(' | ')}`;
|
|
18
|
+
const opts = {};
|
|
19
|
+
|
|
20
|
+
if (typeof variantOrConfig === 'string') {
|
|
21
|
+
if (variantOrConfig[0] === '{') {
|
|
22
|
+
try {
|
|
23
|
+
opts.config = JSON.parse(variantOrConfig);
|
|
24
|
+
} catch (err) {
|
|
25
|
+
throw Error(`Failed to parse config argument ${variantOrConfig}`);
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
opts.variant = variantOrConfig;
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
console.error(Usage);
|
|
32
|
+
throw Error(Usage);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return opts;
|
|
36
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file support for Contract Deployment Process
|
|
3
|
+
*
|
|
4
|
+
* 1. `agoric run XYZ.build.js` produces:
|
|
5
|
+
* - `b1-123.json` bundle x 2: contract, aux
|
|
6
|
+
* - `XYZ-permit.json`, `XYZ.js` script
|
|
7
|
+
* 2. Install bundles
|
|
8
|
+
* - permissionless with per-byte fee in IST
|
|
9
|
+
* 3. Submit CoreEval proposal to BLD stakers
|
|
10
|
+
* - `XYZ-permit.json`, `XYZ.js`
|
|
11
|
+
*
|
|
12
|
+
* @see {runBuilder}
|
|
13
|
+
* @see {installBundles}
|
|
14
|
+
* @see {submitCoreEval}
|
|
15
|
+
*/
|
|
16
|
+
import { toCLIOptions } from '@agoric/internal/src/cli-utils.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @import {CmdRunner} from '@agoric/pola-io';
|
|
20
|
+
* @import {FileRd} from '@agoric/pola-io';
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* TODO: builder should be a FileRd
|
|
26
|
+
* TODO: parameterize dest dir
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* to use npx to find `agoric` in node_modules/.bin:
|
|
30
|
+
* const execP = promisify(childProcess.execFile)
|
|
31
|
+
* const agoric = makeCmdRunner('npx', { execFile: execP }).subCommand('agoric');
|
|
32
|
+
*
|
|
33
|
+
* XXX use a different name from execFile since the meaning is different
|
|
34
|
+
*
|
|
35
|
+
* @param {CmdRunner} agoric
|
|
36
|
+
* @param {FileRd} builder
|
|
37
|
+
* @param {string[]} [builderOpts]
|
|
38
|
+
* @param {{cwd?: FileRd}} [io]
|
|
39
|
+
*
|
|
40
|
+
* @returns {Promise<Plan>}
|
|
41
|
+
*
|
|
42
|
+
* @typedef {{
|
|
43
|
+
* name: string,
|
|
44
|
+
* script: string,
|
|
45
|
+
* permit: string,
|
|
46
|
+
* bundles: { entrypoint:string, bundleID:string, fileName:string}[];
|
|
47
|
+
* }} Plan
|
|
48
|
+
*/
|
|
49
|
+
export const runBuilder = async (
|
|
50
|
+
agoric,
|
|
51
|
+
builder,
|
|
52
|
+
builderOpts = [],
|
|
53
|
+
{ cwd = builder.join('../../') } = {},
|
|
54
|
+
) => {
|
|
55
|
+
const cmd = agoric.withFlags(...builderOpts);
|
|
56
|
+
const { stdout } = await cmd.exec(['run', String(builder)]);
|
|
57
|
+
const match = stdout?.match(/ (?<name>[-\w]+)-permit.json/);
|
|
58
|
+
if (!(match && match.groups)) {
|
|
59
|
+
throw Error('no permit found');
|
|
60
|
+
}
|
|
61
|
+
/** @type {Plan} */
|
|
62
|
+
const plan = await cwd.join(`${match.groups.name}-plan.json`).readJSON();
|
|
63
|
+
return plan;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const txFlags = ({
|
|
67
|
+
node,
|
|
68
|
+
from,
|
|
69
|
+
chainId,
|
|
70
|
+
keyringBackend = 'test',
|
|
71
|
+
broadcastMode = 'block',
|
|
72
|
+
}) => ({
|
|
73
|
+
node,
|
|
74
|
+
from,
|
|
75
|
+
'chain-id': chainId,
|
|
76
|
+
'keyring-backend': keyringBackend,
|
|
77
|
+
'broadcast-mode': broadcastMode,
|
|
78
|
+
// TODO: parameterize these?
|
|
79
|
+
gas: 'auto',
|
|
80
|
+
'gas-adjustment': '1.4',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {CmdRunner} agd
|
|
85
|
+
* @param {number} n
|
|
86
|
+
*/
|
|
87
|
+
export const waitForBlock = async (agd, n = 1) => {
|
|
88
|
+
const getHeight = async () => {
|
|
89
|
+
const { stdout } = await agd.exec(['status']);
|
|
90
|
+
const status = JSON.parse(stdout);
|
|
91
|
+
const { latest_block_height: height } = status.sync_info || status.SyncInfo;
|
|
92
|
+
return height;
|
|
93
|
+
};
|
|
94
|
+
const initialHeight = await getHeight();
|
|
95
|
+
const SEC = 1000;
|
|
96
|
+
let currentHeight;
|
|
97
|
+
do {
|
|
98
|
+
await new Promise(resolve => setTimeout(resolve, 1 * SEC)); // XXX ambient
|
|
99
|
+
currentHeight = await getHeight();
|
|
100
|
+
} while (currentHeight - initialHeight < n);
|
|
101
|
+
console.log('block height:', initialHeight, currentHeight);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @param {CmdRunner} agd - agd with --from etc.
|
|
106
|
+
* @param {string[]} txArgs
|
|
107
|
+
*/
|
|
108
|
+
export const runTx = async (agd, txArgs) => {
|
|
109
|
+
const { stdout } = await agd.withFlags('-o', 'json').exec(['tx', ...txArgs]);
|
|
110
|
+
const result = JSON.parse(stdout);
|
|
111
|
+
if (result.code !== 0) {
|
|
112
|
+
throw Object.assign(Error(result.raw_log), result);
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @param {CmdRunner} agd
|
|
119
|
+
* @param {FileRd} bundle
|
|
120
|
+
*/
|
|
121
|
+
export const installBundle = async (agd, bundle) =>
|
|
122
|
+
runTx(agd, ['swingset', 'install-bundle', `@${bundle}`]);
|
|
123
|
+
|
|
124
|
+
export const txAbbr = tx => {
|
|
125
|
+
const { txhash, code, height, gas_used: g } = tx;
|
|
126
|
+
|
|
127
|
+
return { txhash, code, height, gas_used: g };
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @param {CmdRunner} agd
|
|
132
|
+
* @param {Plan['bundles']} bundles
|
|
133
|
+
* @param {FileRd} files
|
|
134
|
+
*/
|
|
135
|
+
export const installBundles = (agd, bundles, files) => {
|
|
136
|
+
const ps = bundles.map(b =>
|
|
137
|
+
installBundle(agd, files.join(files.relative(b.fileName))),
|
|
138
|
+
);
|
|
139
|
+
return Promise.all(ps);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @param {CmdRunner} agd
|
|
144
|
+
* @param {Pick<Plan, 'permit' | 'script'>[]} evals
|
|
145
|
+
* @param {object} [opts]
|
|
146
|
+
* @param {string} [opts.title]
|
|
147
|
+
* @param {string} [opts.description]
|
|
148
|
+
* @param {object} [opts.depositOpts]
|
|
149
|
+
* @param {string} [opts.depositOpts.denom]
|
|
150
|
+
* @param {number} [opts.depositOpts.unit]
|
|
151
|
+
* @param {number} [opts.depositOpts.qty]
|
|
152
|
+
* @param {string} [opts.deposit]
|
|
153
|
+
*/
|
|
154
|
+
export const submitCoreEval = async (
|
|
155
|
+
agd,
|
|
156
|
+
evals,
|
|
157
|
+
{
|
|
158
|
+
title = evals[0].script,
|
|
159
|
+
description = title,
|
|
160
|
+
depositOpts: { denom = 'ubld', unit = 1_000_000, qty = 10 } = {},
|
|
161
|
+
deposit = `${qty * unit}${denom}`,
|
|
162
|
+
} = {},
|
|
163
|
+
) =>
|
|
164
|
+
runTx(agd, [
|
|
165
|
+
...'gov submit-proposal swingset-core-eval'.split(' '),
|
|
166
|
+
...evals.map(e => [e.permit, e.script]).flat(),
|
|
167
|
+
...toCLIOptions({ title, description, deposit }),
|
|
168
|
+
]);
|
package/src/saveIssuer.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import { E } from '@endo/far';
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js';
|
|
6
|
+
* @import {Amount, Brand, Issuer, Payment} from '@agoric/ertp';
|
|
7
|
+
*/
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* @param {ERef<any>} walletAdmin - an internal type of the
|
package/src/startInstance.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
import { assert } from '@endo/errors';
|
|
3
3
|
import { E, passStyleOf } from '@endo/far';
|
|
4
4
|
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js';
|
|
7
|
+
* @import {Amount, Brand, Issuer, Payment, Purse} from '@agoric/ertp';
|
|
8
|
+
* @import {IssuerKeywordRecord, Keyword} from '@agoric/zoe';
|
|
9
|
+
*/
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* @template T
|