agoric 0.21.2-other-dev-8f8782b.0 → 0.21.2-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 +0 -73
- package/package.json +60 -43
- package/src/anylogger-agoric.js +31 -16
- package/src/bin-agops.js +8 -12
- package/src/chain-config.js +42 -16
- package/src/commands/auction.js +22 -19
- package/src/commands/gov.js +475 -0
- package/src/commands/inter.js +44 -62
- package/src/commands/oracle.js +144 -87
- package/src/commands/perf.js +20 -16
- package/src/commands/psm.js +29 -26
- package/src/commands/reserve.js +13 -6
- package/src/commands/test-upgrade.js +15 -8
- package/src/commands/vaults.js +31 -18
- package/src/commands/wallet.js +121 -48
- package/src/cosmos.js +3 -3
- package/src/deploy.js +10 -5
- package/src/entrypoint.js +2 -5
- package/src/follow.js +14 -10
- package/src/helpers.js +10 -5
- package/src/init.js +2 -9
- package/src/install.js +18 -25
- package/src/lib/bundles.js +102 -0
- package/src/lib/chain.js +71 -35
- package/src/lib/format.js +28 -34
- package/src/lib/index.js +7 -0
- package/src/lib/packageManager.js +24 -0
- package/src/lib/wallet.js +44 -144
- package/src/main-publish.js +2 -3
- package/src/main.js +95 -125
- package/src/open.js +8 -10
- package/src/publish.js +4 -9
- package/src/scripts.js +14 -32
- package/src/sdk-package-names.js +22 -9
- package/src/set-defaults.js +2 -1
- package/src/start.js +59 -68
- package/tools/getting-started.js +272 -0
- package/tools/resm-plugin/deploy.js +18 -0
- package/tools/resm-plugin/package.json +12 -0
- package/tools/resm-plugin/src/output.js +1 -0
- package/tools/resm-plugin/src/plugin.js +17 -0
- package/CHANGELOG.md +0 -1069
- package/src/commands/ec.js +0 -314
- package/src/lib/rpc.js +0 -272
package/src/open.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* eslint-env node */
|
|
2
2
|
import opener from 'opener';
|
|
3
|
-
|
|
3
|
+
import { assert, X } from '@endo/errors';
|
|
4
4
|
import { getAccessToken } from '@agoric/access-token';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export default async function walletMain(progname, rawArgs, powers, opts) {
|
|
9
|
-
const { anylogger, fs } = powers;
|
|
6
|
+
export default async function walletMain(_progname, _rawArgs, powers, opts) {
|
|
7
|
+
const { anylogger } = powers;
|
|
10
8
|
const console = anylogger('agoric:wallet');
|
|
11
9
|
|
|
12
10
|
let suffix;
|
|
@@ -39,10 +37,10 @@ export default async function walletMain(progname, rawArgs, powers, opts) {
|
|
|
39
37
|
1000,
|
|
40
38
|
);
|
|
41
39
|
|
|
42
|
-
const walletAccessToken = await getAccessToken(opts.hostport
|
|
43
|
-
console
|
|
44
|
-
|
|
45
|
-
})
|
|
40
|
+
const walletAccessToken = await getAccessToken(opts.hostport).catch(e => {
|
|
41
|
+
console.error(`Trying to fetch access token:`, e);
|
|
42
|
+
throw e;
|
|
43
|
+
});
|
|
46
44
|
|
|
47
45
|
clearInterval(progressTimer);
|
|
48
46
|
process.stderr.write('\n');
|
package/src/publish.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
/// <reference types="ses"/>
|
|
2
|
+
/// <reference types="ses" />
|
|
3
3
|
|
|
4
|
+
import { X, q, Fail } from '@endo/errors';
|
|
4
5
|
import { E } from '@endo/far';
|
|
5
6
|
|
|
6
7
|
import {
|
|
@@ -14,7 +15,6 @@ import { defaultRegistryTypes } from '@cosmjs/stargate';
|
|
|
14
15
|
import { stringToPath } from '@cosmjs/crypto';
|
|
15
16
|
import { Decimal } from '@cosmjs/math';
|
|
16
17
|
import { fromBech32 } from '@cosmjs/encoding';
|
|
17
|
-
|
|
18
18
|
import { MsgInstallBundle } from '@agoric/cosmic-proto/swingset/msgs.js';
|
|
19
19
|
|
|
20
20
|
// https://github.com/Agoric/agoric-sdk/blob/master/golang/cosmos/daemon/main.go
|
|
@@ -38,6 +38,7 @@ const Agoric = {
|
|
|
38
38
|
const hdPath = (coinType = 118, account = 0) =>
|
|
39
39
|
stringToPath(`m/44'/${coinType}'/${account}'/0/0`);
|
|
40
40
|
|
|
41
|
+
// @ts-expect-error difference in private property _push
|
|
41
42
|
const registry = new Registry([
|
|
42
43
|
...defaultRegistryTypes,
|
|
43
44
|
[Agoric.proto.swingset.InstallBundle.typeUrl, MsgInstallBundle],
|
|
@@ -82,8 +83,6 @@ const registry = new Registry([
|
|
|
82
83
|
* @typedef {SourceBundle | HashBundle} Bundle
|
|
83
84
|
*/
|
|
84
85
|
|
|
85
|
-
const { details: X, quote: q, Fail } = assert;
|
|
86
|
-
|
|
87
86
|
/**
|
|
88
87
|
* @template T
|
|
89
88
|
* @param {Array<T>} array
|
|
@@ -96,7 +95,6 @@ const choose = (array, randomNumber) => {
|
|
|
96
95
|
return array[index];
|
|
97
96
|
};
|
|
98
97
|
|
|
99
|
-
// eslint-disable-next-line jsdoc/require-returns-check
|
|
100
98
|
/**
|
|
101
99
|
* @param {unknown} connectionSpec
|
|
102
100
|
* @returns {asserts connectionSpec is HttpConnectionSpec}
|
|
@@ -124,7 +122,6 @@ const assertHttpConnectionSpec = connectionSpec => {
|
|
|
124
122
|
Fail`Expected integer "port" on "http" type connectionSpec, ${connectionSpec}`;
|
|
125
123
|
};
|
|
126
124
|
|
|
127
|
-
// eslint-disable-next-line jsdoc/require-returns-check
|
|
128
125
|
/**
|
|
129
126
|
* @param {unknown} connectionSpec
|
|
130
127
|
* @returns {asserts connectionSpec is CosmosConnectionSpec}
|
|
@@ -289,14 +286,12 @@ export const makeCosmosBundlePublisher = ({
|
|
|
289
286
|
const endpoint = urlForRpcAddress(rpcAddress);
|
|
290
287
|
|
|
291
288
|
// AWAIT
|
|
292
|
-
// eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
|
|
293
289
|
const stargateClient = await connectWithSigner(endpoint, wallet, {
|
|
294
290
|
gasPrice: Agoric.gasPrice,
|
|
295
291
|
registry,
|
|
296
292
|
});
|
|
297
293
|
|
|
298
294
|
// AWAIT
|
|
299
|
-
// eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
|
|
300
295
|
const result = await stargateClient
|
|
301
296
|
.signAndBroadcast(from.address, encodeObjects, Agoric.fee)
|
|
302
297
|
.catch(error => {
|
|
@@ -312,7 +307,6 @@ export const makeCosmosBundlePublisher = ({
|
|
|
312
307
|
}
|
|
313
308
|
|
|
314
309
|
// AWAIT
|
|
315
|
-
// eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
|
|
316
310
|
await E(leader).jitter('agoric CLI deploy');
|
|
317
311
|
}
|
|
318
312
|
|
|
@@ -426,6 +420,7 @@ const publishBundle = async (
|
|
|
426
420
|
)}, publishBundle supports only "endoZipBase64" with "endoZipBase64Sha512"`;
|
|
427
421
|
}
|
|
428
422
|
|
|
423
|
+
await null;
|
|
429
424
|
if (connectionSpec === undefined && getDefaultConnection !== undefined) {
|
|
430
425
|
connectionSpec = await getDefaultConnection();
|
|
431
426
|
}
|
package/src/scripts.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
/*
|
|
2
|
+
/* eslint-env node */
|
|
3
3
|
import bundleSource from '@endo/bundle-source';
|
|
4
4
|
import { E } from '@endo/captp';
|
|
5
|
-
import { search as readContainingPackageDescriptor } from '@endo/compartment-mapper';
|
|
6
5
|
|
|
7
|
-
import createEsmRequire from 'esm';
|
|
8
6
|
import { createRequire } from 'module';
|
|
9
7
|
import path from 'path';
|
|
10
|
-
import url from 'url';
|
|
11
8
|
|
|
12
9
|
const require = createRequire(import.meta.url);
|
|
13
|
-
const esmRequire = createEsmRequire(/** @type {NodeModule} */ ({}));
|
|
14
10
|
|
|
15
11
|
const PATH_SEP_RE = new RegExp(`${path.sep.replace(/\\/g, '\\\\')}`, 'g');
|
|
16
12
|
|
|
@@ -56,7 +52,7 @@ export const makeLookup =
|
|
|
56
52
|
|
|
57
53
|
/**
|
|
58
54
|
* @param {string[]} scripts
|
|
59
|
-
* @param {{ allowUnsafePlugins
|
|
55
|
+
* @param {{ allowUnsafePlugins?: boolean, progname: string, rawArgs: string[], endowments?: Record<string, any> }} opts
|
|
60
56
|
* @param {{ fs: import('fs/promises'), console: Console }} powers
|
|
61
57
|
*/
|
|
62
58
|
export const makeScriptLoader =
|
|
@@ -133,36 +129,22 @@ export { bootPlugin } from ${JSON.stringify(absPath)};
|
|
|
133
129
|
// Use a dynamic import to load the deploy script.
|
|
134
130
|
// It is unconfined.
|
|
135
131
|
|
|
136
|
-
// Use Node.js ESM support if package.json of template says "type":
|
|
137
|
-
// "module".
|
|
138
|
-
const read = async location => fs.readFile(url.fileURLToPath(location));
|
|
139
|
-
const { packageDescriptorText } = await readContainingPackageDescriptor(
|
|
140
|
-
read,
|
|
141
|
-
url.pathToFileURL(moduleFile).href,
|
|
142
|
-
).catch(cause => {
|
|
143
|
-
throw Error(
|
|
144
|
-
`Expected a package.json beside deploy script ${moduleFile}, ${cause}`,
|
|
145
|
-
{ cause },
|
|
146
|
-
);
|
|
147
|
-
});
|
|
148
|
-
const packageDescriptor = JSON.parse(packageDescriptorText);
|
|
149
|
-
const nativeEsm = packageDescriptor.type === 'module';
|
|
150
|
-
console.log(
|
|
151
|
-
`Deploy script will run with ${
|
|
152
|
-
nativeEsm ? 'Node.js ESM' : 'standardthings/esm emulation'
|
|
153
|
-
}`,
|
|
154
|
-
);
|
|
155
|
-
|
|
156
132
|
const modulePath = pathResolve(moduleFile);
|
|
157
|
-
|
|
158
|
-
if (!mainNS) {
|
|
159
|
-
mainNS = esmRequire(modulePath);
|
|
160
|
-
}
|
|
133
|
+
const mainNS = await import(modulePath);
|
|
161
134
|
|
|
162
135
|
const allEndowments = harden({
|
|
163
136
|
home: bootP,
|
|
164
|
-
|
|
165
|
-
|
|
137
|
+
/**
|
|
138
|
+
* @template {import('@endo/bundle-source').ModuleFormat} ModuleFormat
|
|
139
|
+
* @param {string} file
|
|
140
|
+
* @param {import('@endo/bundle-source').BundleOptions<ModuleFormat>} options
|
|
141
|
+
* @returns {Promise<import('@endo/bundle-source').BundleSourceResult<ModuleFormat>>}
|
|
142
|
+
*/
|
|
143
|
+
bundleSource: (file, options = {}) =>
|
|
144
|
+
bundleSource(pathResolve(file), {
|
|
145
|
+
elideComments: true,
|
|
146
|
+
...options,
|
|
147
|
+
}),
|
|
166
148
|
...endowments,
|
|
167
149
|
pathResolve,
|
|
168
150
|
installUnsafePlugin,
|
package/src/sdk-package-names.js
CHANGED
|
@@ -1,26 +1,41 @@
|
|
|
1
1
|
// DO NOT EDIT - automatically generated by get-sdk-package-names.js
|
|
2
|
-
/* eslint-disable comma-dangle,quotes */
|
|
3
2
|
// prettier-ignore
|
|
4
3
|
export default [
|
|
4
|
+
"@aglocal/benchmark",
|
|
5
|
+
"@aglocal/boot",
|
|
6
|
+
"@aglocal/deployment",
|
|
7
|
+
"@aglocal/fast-usdc-contract",
|
|
8
|
+
"@aglocal/fast-usdc-deploy",
|
|
9
|
+
"@aglocal/portfolio-contract",
|
|
10
|
+
"@aglocal/portfolio-deploy",
|
|
11
|
+
"@aglocal/swingset-runner",
|
|
12
|
+
"@aglocal/ymax-planner",
|
|
5
13
|
"@agoric/access-token",
|
|
6
|
-
"@agoric/
|
|
14
|
+
"@agoric/async-flow",
|
|
15
|
+
"@agoric/base-zone",
|
|
16
|
+
"@agoric/builders",
|
|
7
17
|
"@agoric/cache",
|
|
8
18
|
"@agoric/casting",
|
|
19
|
+
"@agoric/client-utils",
|
|
9
20
|
"@agoric/cosmic-proto",
|
|
10
21
|
"@agoric/cosmic-swingset",
|
|
11
22
|
"@agoric/cosmos",
|
|
23
|
+
"@agoric/create-dapp",
|
|
12
24
|
"@agoric/deploy-script-support",
|
|
13
|
-
"@agoric/deployment",
|
|
14
25
|
"@agoric/ertp",
|
|
15
26
|
"@agoric/eslint-config",
|
|
27
|
+
"@agoric/fast-usdc",
|
|
16
28
|
"@agoric/governance",
|
|
17
29
|
"@agoric/import-manager",
|
|
18
30
|
"@agoric/inter-protocol",
|
|
19
31
|
"@agoric/internal",
|
|
32
|
+
"@agoric/kmarshal",
|
|
33
|
+
"@agoric/network",
|
|
20
34
|
"@agoric/notifier",
|
|
35
|
+
"@agoric/orchestration",
|
|
21
36
|
"@agoric/pegasus",
|
|
22
|
-
"@agoric/
|
|
23
|
-
"@agoric/
|
|
37
|
+
"@agoric/pola-io",
|
|
38
|
+
"@agoric/portfolio-api",
|
|
24
39
|
"@agoric/smart-wallet",
|
|
25
40
|
"@agoric/solo",
|
|
26
41
|
"@agoric/sparse-ints",
|
|
@@ -29,18 +44,16 @@ export default [
|
|
|
29
44
|
"@agoric/store",
|
|
30
45
|
"@agoric/swing-store",
|
|
31
46
|
"@agoric/swingset-liveslots",
|
|
32
|
-
"@agoric/swingset-runner",
|
|
33
47
|
"@agoric/swingset-vat",
|
|
34
48
|
"@agoric/swingset-xsnap-supervisor",
|
|
35
49
|
"@agoric/telemetry",
|
|
36
50
|
"@agoric/time",
|
|
37
|
-
"@agoric/ui-components",
|
|
38
51
|
"@agoric/vat-data",
|
|
39
52
|
"@agoric/vats",
|
|
53
|
+
"@agoric/vm-config",
|
|
54
|
+
"@agoric/vow",
|
|
40
55
|
"@agoric/wallet",
|
|
41
56
|
"@agoric/wallet-backend",
|
|
42
|
-
"@agoric/wallet-connection",
|
|
43
|
-
"@agoric/web-components",
|
|
44
57
|
"@agoric/xsnap",
|
|
45
58
|
"@agoric/xsnap-lockdown",
|
|
46
59
|
"@agoric/zoe",
|
package/src/set-defaults.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { basename } from 'path';
|
|
2
|
-
import { Fail } from '@
|
|
2
|
+
import { Fail } from '@endo/errors';
|
|
3
3
|
import {
|
|
4
4
|
finishCosmosApp,
|
|
5
5
|
finishTendermintConfig,
|
|
@@ -42,6 +42,7 @@ export default async function setDefaultsMain(progname, rawArgs, powers, opts) {
|
|
|
42
42
|
return fs.writeFile(fileName, contents);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
+
await null;
|
|
45
46
|
if (appFile) {
|
|
46
47
|
log(`read ${appFile}`);
|
|
47
48
|
const appToml = await fs.readFile(appFile, 'utf-8');
|
package/src/start.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* eslint-env node */
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { createHash } from 'crypto';
|
|
4
4
|
import path from 'path';
|
|
@@ -40,6 +40,7 @@ const DELEGATE0_COINS = `50000000${STAKING_DENOM}`;
|
|
|
40
40
|
const SOLO_COINS = `13000000${STAKING_DENOM},500000000${CENTRAL_DENOM}`;
|
|
41
41
|
const CHAIN_ID = 'agoriclocal';
|
|
42
42
|
|
|
43
|
+
const SERVERS_ROOT_DIR = '_agstate/agoric-servers';
|
|
43
44
|
const FAKE_CHAIN_DELAY =
|
|
44
45
|
process.env.FAKE_CHAIN_DELAY === undefined
|
|
45
46
|
? 0
|
|
@@ -69,10 +70,10 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
69
70
|
const pspawnEnv = { ...process.env };
|
|
70
71
|
if (opts.verbose > 1) {
|
|
71
72
|
// Loudly verbose logs (nondeterministic).
|
|
72
|
-
pspawnEnv.DEBUG = 'agoric,SwingSet:vat,SwingSet:ls';
|
|
73
|
+
pspawnEnv.DEBUG = 'agoric:debug,SwingSet:vat,SwingSet:ls';
|
|
73
74
|
} else if (opts.verbose) {
|
|
74
75
|
// Verbose vat logs (nondeterministic).
|
|
75
|
-
pspawnEnv.DEBUG = 'SwingSet:vat,SwingSet:ls';
|
|
76
|
+
pspawnEnv.DEBUG = 'agoric:info,SwingSet:vat,SwingSet:ls';
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
const pspawn = makePspawn({ env: pspawnEnv, spawn, log, chalk });
|
|
@@ -151,6 +152,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
151
152
|
]);
|
|
152
153
|
|
|
153
154
|
const exists = async file => {
|
|
155
|
+
await null;
|
|
154
156
|
try {
|
|
155
157
|
await fs.stat(file);
|
|
156
158
|
return true;
|
|
@@ -159,6 +161,12 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
159
161
|
}
|
|
160
162
|
};
|
|
161
163
|
|
|
164
|
+
const rmVerbose = async filePath => {
|
|
165
|
+
log(chalk.green(`removing ${filePath}`));
|
|
166
|
+
// rm is available on all the unix-likes, so use it for speed.
|
|
167
|
+
await pspawn('rm', ['-rf', filePath]);
|
|
168
|
+
};
|
|
169
|
+
|
|
162
170
|
let agSolo;
|
|
163
171
|
let agSoloBuild;
|
|
164
172
|
if (opts.dockerTag) {
|
|
@@ -171,12 +179,11 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
171
179
|
const fakeDelay =
|
|
172
180
|
popts.delay === undefined ? FAKE_CHAIN_DELAY : Number(popts.delay);
|
|
173
181
|
|
|
174
|
-
const
|
|
182
|
+
const serverDir = `${SERVERS_ROOT_DIR}/${profileName}`;
|
|
175
183
|
|
|
184
|
+
await null;
|
|
176
185
|
if (popts.reset) {
|
|
177
|
-
|
|
178
|
-
// rm is available on all the unix-likes, so use it for speed.
|
|
179
|
-
await pspawn('rm', ['-rf', agServer]);
|
|
186
|
+
await rmVerbose(serverDir);
|
|
180
187
|
}
|
|
181
188
|
|
|
182
189
|
if (!opts.dockerTag) {
|
|
@@ -197,14 +204,14 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
197
204
|
}
|
|
198
205
|
|
|
199
206
|
const fakeGCI = 'sim-chain';
|
|
200
|
-
const serverExists = await exists(
|
|
207
|
+
const serverExists = await exists(serverDir);
|
|
201
208
|
if (!serverExists) {
|
|
202
209
|
log(chalk.yellow(`initializing ${profileName}`));
|
|
203
210
|
await pspawn(
|
|
204
211
|
agSolo,
|
|
205
212
|
['init', profileName, '--egresses=fake', `--webport=${HOST_PORT}`],
|
|
206
213
|
{
|
|
207
|
-
cwd:
|
|
214
|
+
cwd: SERVERS_ROOT_DIR,
|
|
208
215
|
},
|
|
209
216
|
);
|
|
210
217
|
}
|
|
@@ -215,7 +222,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
215
222
|
agSolo,
|
|
216
223
|
['set-fake-chain', `--delay=${fakeDelay}`, fakeGCI],
|
|
217
224
|
{
|
|
218
|
-
cwd:
|
|
225
|
+
cwd: serverDir,
|
|
219
226
|
},
|
|
220
227
|
);
|
|
221
228
|
}
|
|
@@ -226,7 +233,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
226
233
|
}
|
|
227
234
|
|
|
228
235
|
const ps = pspawn(agSolo, [...debugOpts, 'start'], {
|
|
229
|
-
cwd:
|
|
236
|
+
cwd: serverDir,
|
|
230
237
|
env: nodeDebugEnv,
|
|
231
238
|
});
|
|
232
239
|
process.on('SIGINT', () => ps.childProcess.kill('SIGINT'));
|
|
@@ -246,6 +253,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
246
253
|
}
|
|
247
254
|
|
|
248
255
|
const { cosmosChain, cosmosChainBuild } = getSDKBinaries(sdkPrefixes);
|
|
256
|
+
await null;
|
|
249
257
|
if (popts.pull || popts.rebuild) {
|
|
250
258
|
if (popts.dockerTag) {
|
|
251
259
|
const exitStatus = await pspawn('docker', ['pull', SDK_IMAGE]);
|
|
@@ -263,20 +271,18 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
263
271
|
}
|
|
264
272
|
}
|
|
265
273
|
|
|
266
|
-
const
|
|
274
|
+
const serverDir = `${SERVERS_ROOT_DIR}/${profileName}-${portNum}`;
|
|
267
275
|
if (popts.reset) {
|
|
268
|
-
|
|
269
|
-
// rm is available on all the unix-likes, so use it for speed.
|
|
270
|
-
await pspawn('rm', ['-rf', agServer]);
|
|
276
|
+
await rmVerbose(serverDir);
|
|
271
277
|
}
|
|
272
278
|
|
|
279
|
+
/** @type {(args: string[], spawnOpts?: Parameters<typeof pspawn>[2], dockerArgs?: string[]) => ReturnType<pspawn>} */
|
|
273
280
|
let chainSpawn;
|
|
274
281
|
if (!popts.dockerTag) {
|
|
275
|
-
chainSpawn = (args, spawnOpts
|
|
276
|
-
|
|
277
|
-
};
|
|
282
|
+
chainSpawn = (args, spawnOpts) =>
|
|
283
|
+
pspawn(cosmosChain, [...args, `--home=${serverDir}`], spawnOpts);
|
|
278
284
|
} else {
|
|
279
|
-
chainSpawn = (args, spawnOpts
|
|
285
|
+
chainSpawn = (args, spawnOpts, dockerArgs = []) =>
|
|
280
286
|
pspawn(
|
|
281
287
|
'docker',
|
|
282
288
|
[
|
|
@@ -287,13 +293,13 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
287
293
|
...terminalOnlyFlags(`-it`),
|
|
288
294
|
SDK_IMAGE,
|
|
289
295
|
...args,
|
|
290
|
-
`--home=/usr/src/dapp/${
|
|
296
|
+
`--home=/usr/src/dapp/${serverDir}`,
|
|
291
297
|
],
|
|
292
298
|
spawnOpts,
|
|
293
299
|
);
|
|
294
300
|
}
|
|
295
301
|
|
|
296
|
-
const serverExists = await exists(
|
|
302
|
+
const serverExists = await exists(serverDir);
|
|
297
303
|
if (!serverExists) {
|
|
298
304
|
const exitStatus = await chainSpawn([
|
|
299
305
|
'init',
|
|
@@ -308,7 +314,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
308
314
|
// Get or create the essential addresses.
|
|
309
315
|
const addrs = {};
|
|
310
316
|
for (const keyName of ['provision', 'delegate0']) {
|
|
311
|
-
/* eslint-disable no-await-in-loop */
|
|
312
317
|
let statusOut = showKey(keyName);
|
|
313
318
|
const exitStatusOut = await statusOut[0];
|
|
314
319
|
if (exitStatusOut) {
|
|
@@ -328,10 +333,9 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
328
333
|
}
|
|
329
334
|
}
|
|
330
335
|
addrs[keyName] = statusOut[1].trimRight();
|
|
331
|
-
/* eslint-enable no-await-in-loop */
|
|
332
336
|
}
|
|
333
337
|
|
|
334
|
-
const genesisFile = `${
|
|
338
|
+
const genesisFile = `${serverDir}/config/genesis.json`;
|
|
335
339
|
const stampExists = await exists(`${genesisFile}.stamp`);
|
|
336
340
|
if (!stampExists) {
|
|
337
341
|
let exitStatus;
|
|
@@ -361,7 +365,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
361
365
|
`--keyring-dir=${keysHome}`,
|
|
362
366
|
'--keyring-backend=test',
|
|
363
367
|
`--chain-id=${CHAIN_ID}`,
|
|
364
|
-
|
|
368
|
+
DELEGATE0_COINS,
|
|
365
369
|
]);
|
|
366
370
|
if (exitStatus) {
|
|
367
371
|
return exitStatus;
|
|
@@ -382,8 +386,8 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
382
386
|
|
|
383
387
|
// Complete the genesis file and launch the chain.
|
|
384
388
|
log('read ag-chain-cosmos config');
|
|
385
|
-
const configFile = `${
|
|
386
|
-
const appFile = `${
|
|
389
|
+
const configFile = `${serverDir}/config/config.toml`;
|
|
390
|
+
const appFile = `${serverDir}/config/app.toml`;
|
|
387
391
|
const [genesisJson, configToml, appToml] = await Promise.all([
|
|
388
392
|
fs.readFile(genesisFile, 'utf-8'),
|
|
389
393
|
fs.readFile(configFile, 'utf-8'),
|
|
@@ -446,9 +450,10 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
446
450
|
return 1;
|
|
447
451
|
}
|
|
448
452
|
|
|
449
|
-
const
|
|
453
|
+
const serverDir = `${SERVERS_ROOT_DIR}/${profileName}-${portNum}`;
|
|
450
454
|
|
|
451
455
|
const { cosmosClientBuild } = getSDKBinaries(sdkPrefixes);
|
|
456
|
+
await null;
|
|
452
457
|
if (popts.pull || popts.rebuild) {
|
|
453
458
|
if (popts.dockerTag) {
|
|
454
459
|
const exitStatus = await pspawn('docker', ['pull', SDK_IMAGE]);
|
|
@@ -474,24 +479,22 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
474
479
|
}
|
|
475
480
|
|
|
476
481
|
if (popts.reset) {
|
|
477
|
-
|
|
478
|
-
// rm is available on all the unix-likes, so use it for speed.
|
|
479
|
-
await pspawn('rm', ['-rf', agServer]);
|
|
482
|
+
await rmVerbose(serverDir);
|
|
480
483
|
}
|
|
481
484
|
|
|
485
|
+
/** @type {(args: string[], spawnOpts?: Parameters<typeof pspawn>[2], dockerArgs?: string[]) => ReturnType<pspawn>} */
|
|
482
486
|
let soloSpawn;
|
|
483
487
|
if (!popts.dockerTag) {
|
|
484
|
-
soloSpawn = (args, spawnOpts
|
|
485
|
-
pspawn(agSolo, args, spawnOpts);
|
|
488
|
+
soloSpawn = (args, spawnOpts) => pspawn(agSolo, args, spawnOpts);
|
|
486
489
|
} else {
|
|
487
|
-
soloSpawn = (args, spawnOpts
|
|
490
|
+
soloSpawn = (args, spawnOpts, dockerArgs = []) =>
|
|
488
491
|
pspawn(
|
|
489
492
|
'docker',
|
|
490
493
|
[
|
|
491
494
|
'run',
|
|
492
495
|
`--volume=${process.cwd()}:/usr/src/dapp`,
|
|
493
496
|
`--volume=${process.env.HOME}/.agoric:/root/.agoric`,
|
|
494
|
-
`-eAG_SOLO_BASEDIR=/usr/src/dapp/${
|
|
497
|
+
`-eAG_SOLO_BASEDIR=/usr/src/dapp/${serverDir}`,
|
|
495
498
|
`--rm`,
|
|
496
499
|
...terminalOnlyFlags(`-it`),
|
|
497
500
|
`--entrypoint=ag-solo`,
|
|
@@ -503,7 +506,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
503
506
|
);
|
|
504
507
|
}
|
|
505
508
|
|
|
506
|
-
const serverExists = await exists(
|
|
509
|
+
const serverExists = await exists(serverDir);
|
|
507
510
|
// Initialise the solo directory and key.
|
|
508
511
|
if (!serverExists) {
|
|
509
512
|
const initArgs = [`--webport=${portNum}`];
|
|
@@ -511,7 +514,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
511
514
|
initArgs.push(`--webhost=0.0.0.0`);
|
|
512
515
|
}
|
|
513
516
|
const exitStatus = await soloSpawn(
|
|
514
|
-
['init',
|
|
517
|
+
['init', serverDir, ...initArgs],
|
|
515
518
|
undefined,
|
|
516
519
|
[`--workdir=/usr/src/dapp`],
|
|
517
520
|
);
|
|
@@ -522,15 +525,15 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
522
525
|
|
|
523
526
|
// Create the full economy chain config.
|
|
524
527
|
const agServerResolve = spec =>
|
|
525
|
-
require.resolve(spec, { paths: [
|
|
528
|
+
require.resolve(spec, { paths: [serverDir] });
|
|
526
529
|
const coreConfigPath = agServerResolve(
|
|
527
|
-
'@agoric/
|
|
530
|
+
'@agoric/vm-config/decentral-core-config.json',
|
|
528
531
|
);
|
|
529
532
|
const economyTemplPath = agServerResolve(
|
|
530
533
|
'@agoric/cosmic-swingset/economy-template.json',
|
|
531
534
|
);
|
|
532
535
|
const [rawSoloAddr, coreConfigJson, economyTemplJson] = await Promise.all([
|
|
533
|
-
fs.readFile(`${
|
|
536
|
+
fs.readFile(`${serverDir}/ag-cosmos-helper-address`, 'utf-8'),
|
|
534
537
|
fs.readFile(coreConfigPath, 'utf-8'),
|
|
535
538
|
fs.readFile(economyTemplPath, 'utf-8'),
|
|
536
539
|
]);
|
|
@@ -541,7 +544,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
541
544
|
const economyConfig = JSON.parse(coreConfigJson);
|
|
542
545
|
economyConfig.coreProposals = economyProposals;
|
|
543
546
|
await fs.writeFile(
|
|
544
|
-
`${
|
|
547
|
+
`${serverDir}/decentral-economy-config.json`,
|
|
545
548
|
JSON.stringify(economyConfig, null, 2),
|
|
546
549
|
);
|
|
547
550
|
|
|
@@ -549,13 +552,12 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
549
552
|
return 0;
|
|
550
553
|
}
|
|
551
554
|
|
|
552
|
-
const gciFile =
|
|
555
|
+
const gciFile = `${SERVERS_ROOT_DIR}/local-chain-${CHAIN_PORT}/config/genesis.json.sha256`;
|
|
553
556
|
process.stdout.write(`Waiting for local-chain-${CHAIN_PORT} to start...`);
|
|
554
557
|
let hasGci = false;
|
|
555
558
|
for await (const _ of untilTrue(() => hasGci)) {
|
|
556
559
|
process.stdout.write('.');
|
|
557
560
|
|
|
558
|
-
// eslint-disable-next-line no-await-in-loop
|
|
559
561
|
await new Promise((resolve, reject) => {
|
|
560
562
|
fs.stat(gciFile).then(
|
|
561
563
|
_2 => {
|
|
@@ -576,7 +578,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
576
578
|
|
|
577
579
|
const spawnOpts = {};
|
|
578
580
|
if (!popts.dockerTag) {
|
|
579
|
-
spawnOpts.cwd =
|
|
581
|
+
spawnOpts.cwd = serverDir;
|
|
580
582
|
}
|
|
581
583
|
|
|
582
584
|
const rpcAddrs = [`localhost:${CHAIN_PORT}`];
|
|
@@ -590,13 +592,11 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
590
592
|
let bestRpcAddr;
|
|
591
593
|
for await (const _ of untilTrue(() => bestRpcAddr)) {
|
|
592
594
|
for await (const rpcAddr of rpcAddrs) {
|
|
593
|
-
// eslint-disable-next-line no-await-in-loop
|
|
594
595
|
exitStatus = await keysSpawn([
|
|
595
596
|
'query',
|
|
596
597
|
'swingset',
|
|
597
598
|
'egress',
|
|
598
599
|
soloAddr,
|
|
599
|
-
`--chain-id=${CHAIN_ID}`,
|
|
600
600
|
`--node=tcp://${rpcAddr}`,
|
|
601
601
|
]);
|
|
602
602
|
if (exitStatus) {
|
|
@@ -639,7 +639,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
639
639
|
];
|
|
640
640
|
for (/* await */ const cmd of provCmds) {
|
|
641
641
|
const statusOut = capture(keysSpawn, cmd, true);
|
|
642
|
-
// eslint-disable-next-line no-await-in-loop
|
|
643
642
|
exitStatus = await statusOut[0];
|
|
644
643
|
if (!exitStatus) {
|
|
645
644
|
const json = statusOut[1].replace(/^gas estimate: \d+$/m, '');
|
|
@@ -664,7 +663,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
664
663
|
}
|
|
665
664
|
}
|
|
666
665
|
if (!bestRpcAddr) {
|
|
667
|
-
// eslint-disable-next-line no-await-in-loop
|
|
668
666
|
await delay(2000);
|
|
669
667
|
}
|
|
670
668
|
}
|
|
@@ -690,6 +688,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
690
688
|
}
|
|
691
689
|
|
|
692
690
|
async function startTestnetDocker(profileName, startArgs, popts) {
|
|
691
|
+
await null;
|
|
693
692
|
if (popts.dockerTag && popts.pull) {
|
|
694
693
|
const exitStatus = await pspawn('docker', ['pull', SOLO_IMAGE]);
|
|
695
694
|
if (exitStatus) {
|
|
@@ -699,12 +698,10 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
699
698
|
|
|
700
699
|
const port = startArgs[0] || PORT;
|
|
701
700
|
const netconfig = startArgs[1] || DEFAULT_NETCONFIG;
|
|
702
|
-
const
|
|
701
|
+
const serverDir = `${SERVERS_ROOT_DIR}/${profileName}-${port}`;
|
|
703
702
|
|
|
704
703
|
if (popts.reset) {
|
|
705
|
-
|
|
706
|
-
// rm is available on all the unix-likes, so use it for speed.
|
|
707
|
-
await pspawn('rm', ['-rf', agServer]);
|
|
704
|
+
await rmVerbose(serverDir);
|
|
708
705
|
}
|
|
709
706
|
|
|
710
707
|
const setupRun = (...bonusArgs) =>
|
|
@@ -712,7 +709,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
712
709
|
'run',
|
|
713
710
|
`-p127.0.0.1:${HOST_PORT}:${port}`,
|
|
714
711
|
`--volume=${process.cwd()}:/usr/src/dapp`,
|
|
715
|
-
`-eAG_SOLO_BASEDIR=/usr/src/dapp/${
|
|
712
|
+
`-eAG_SOLO_BASEDIR=/usr/src/dapp/${serverDir}`,
|
|
716
713
|
`--rm`,
|
|
717
714
|
...terminalOnlyFlags(`-it`),
|
|
718
715
|
SOLO_IMAGE,
|
|
@@ -727,44 +724,38 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
727
724
|
async function startTestnetSdk(profileName, startArgs, popts) {
|
|
728
725
|
const port = startArgs[0] || PORT;
|
|
729
726
|
const netconfig = startArgs[1] || DEFAULT_NETCONFIG;
|
|
730
|
-
const
|
|
727
|
+
const serverDir = `${SERVERS_ROOT_DIR}/${profileName}-${port}`;
|
|
731
728
|
|
|
729
|
+
await null;
|
|
732
730
|
if (popts.reset) {
|
|
733
|
-
|
|
734
|
-
// rm is available on all the unix-likes, so use it for speed.
|
|
735
|
-
await pspawn('rm', ['-rf', agServer]);
|
|
731
|
+
await rmVerbose(serverDir);
|
|
736
732
|
}
|
|
737
733
|
|
|
738
734
|
const setupRun = (...bonusArgs) =>
|
|
739
735
|
pspawn(agSolo, [`--webport=${port}`, ...bonusArgs], {
|
|
740
|
-
env: { ...pspawnEnv, AG_SOLO_BASEDIR:
|
|
736
|
+
env: { ...pspawnEnv, AG_SOLO_BASEDIR: serverDir },
|
|
741
737
|
});
|
|
742
738
|
|
|
743
739
|
return setupRun('setup', `--netconfig=${netconfig}`);
|
|
744
740
|
}
|
|
745
741
|
|
|
746
742
|
const profiles = {
|
|
743
|
+
__proto__: null,
|
|
747
744
|
dev: startFakeChain,
|
|
748
745
|
'local-chain': startLocalChain,
|
|
749
746
|
'local-solo': startLocalSolo,
|
|
750
747
|
testnet: opts.dockerTag ? startTestnetDocker : startTestnetSdk,
|
|
751
748
|
};
|
|
752
749
|
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
const args = rawArgs.slice(1);
|
|
756
|
-
const profileName = args[0] || 'dev';
|
|
750
|
+
const [_command = 'start', profileName = 'dev', ...args] = rawArgs;
|
|
757
751
|
const startFn = profiles[profileName];
|
|
758
752
|
if (!startFn) {
|
|
753
|
+
const profileNames = Object.keys(profiles).join(', ');
|
|
759
754
|
log.error(
|
|
760
|
-
`unrecognized profile name ${profileName}; use one of: ${
|
|
761
|
-
profiles,
|
|
762
|
-
)
|
|
763
|
-
.sort()
|
|
764
|
-
.join(', ')}`,
|
|
755
|
+
`unrecognized profile name ${profileName}; use one of: ${profileNames}`,
|
|
765
756
|
);
|
|
766
757
|
return 1;
|
|
767
758
|
}
|
|
768
759
|
|
|
769
|
-
return startFn(profileName, args
|
|
760
|
+
return startFn(profileName, args, opts);
|
|
770
761
|
}
|