agoric 0.21.2-dev-57802f9.0 → 0.21.2-other-dev-1f26562.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/src/lib/wallet.js CHANGED
@@ -9,6 +9,7 @@ import { boardSlottingMarshaller, makeRpcUtils } from './rpc.js';
9
9
  /** @typedef {import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord} CurrentWalletRecord */
10
10
  /** @typedef {import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes} AgoricNamesRemotes */
11
11
 
12
+ const { values } = Object;
12
13
  const { Fail } = assert;
13
14
  const marshaller = boardSlottingMarshaller();
14
15
 
@@ -131,7 +132,6 @@ export const coalesceWalletState = async (follower, invitationBrand) => {
131
132
  * @param {import('@agoric/smart-wallet/src/smartWallet').BridgeAction} bridgeAction
132
133
  * @param {import('./rpc').MinimalNetworkConfig & {
133
134
  * from: string,
134
- * fees?: string,
135
135
  * verbose?: boolean,
136
136
  * keyring?: {home?: string, backend: string},
137
137
  * stdout: Pick<import('stream').Writable, 'write'>,
@@ -159,7 +159,7 @@ export const sendAction = async (bridgeAction, opts) => {
159
159
  assert(out); // not dry run
160
160
  const tx = JSON.parse(out);
161
161
  if (tx.code !== 0) {
162
- const err = Error(`failed to send tx: ${tx.raw_log} code: ${tx.code}`);
162
+ const err = Error(`failed to send action. code: ${tx.code}`);
163
163
  // @ts-expect-error XXX how to add properties to an error?
164
164
  err.code = tx.code;
165
165
  throw err;
@@ -247,6 +247,7 @@ export const makeWalletUtils = async (
247
247
  untilNumWantsSatisfied = false,
248
248
  ) => {
249
249
  const lookup = async () => {
250
+ // eslint-disable-next-line @jessie.js/no-nested-await, no-await-in-loop
250
251
  const { offerStatuses } = await storedWalletState(from, minHeight);
251
252
  const offerStatus = [...offerStatuses.values()].find(s => s.id === id);
252
253
  if (!offerStatus) throw Error('retry');
@@ -271,3 +272,44 @@ export const makeWalletUtils = async (
271
272
  pollOffer,
272
273
  };
273
274
  };
275
+
276
+ /**
277
+ * @param {{
278
+ * brand: Record<string, Brand>,
279
+ * vbankAsset: Record<string, { brand: Brand, displayInfo: DisplayInfo }>,
280
+ * }} agoricNames
281
+ * @param {(msg: string) => Error} makeError error constructor
282
+ * @returns {(a: string) => Amount<'nat'>}
283
+ */
284
+ export const makeParseAmount =
285
+ (agoricNames, makeError = msg => RangeError(msg)) =>
286
+ opt => {
287
+ assert.typeof(opt, 'string', 'parseAmount expected string');
288
+ const m = opt.match(/^(?<value>[\d_]+(\.[\d_]+)?)(?<brand>[A-Z]\w*?)$/);
289
+ if (!m || !m.groups) {
290
+ throw makeError(`invalid amount: ${opt}`);
291
+ }
292
+ const anyBrand = agoricNames.brand[m.groups.brand];
293
+ if (!anyBrand) {
294
+ throw makeError(`unknown brand: ${m.groups.brand}`);
295
+ }
296
+ const assetDesc = values(agoricNames.vbankAsset).find(
297
+ d => d.brand === anyBrand,
298
+ );
299
+ if (!assetDesc) {
300
+ throw makeError(`unknown brand: ${m.groups.brand}`);
301
+ }
302
+ const { displayInfo } = assetDesc;
303
+ if (!displayInfo.decimalPlaces || displayInfo.assetKind !== 'nat') {
304
+ throw makeError(`bad brand: ${displayInfo}`);
305
+ }
306
+ const value = BigInt(
307
+ Number(m.groups.value.replace(/_/g, '')) *
308
+ 10 ** displayInfo.decimalPlaces,
309
+ );
310
+ /** @type {Brand<'nat'>} */
311
+ // @ts-expect-error dynamic cast
312
+ const natBrand = anyBrand;
313
+ const amt = { value, brand: natBrand };
314
+ return amt;
315
+ };
@@ -31,9 +31,9 @@ const publishMain = async (progname, rawArgs, powers, opts) => {
31
31
  chainID,
32
32
  };
33
33
 
34
- await null;
35
34
  for (const bundlePath of rawArgs.slice(1)) {
36
35
  // AWAIT
36
+ // eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
37
37
  const bundleText = await fs.readFile(bundlePath, 'utf-8');
38
38
  const bundle = parseLocatedJson(bundleText, bundlePath);
39
39
 
@@ -53,6 +53,7 @@ const publishMain = async (progname, rawArgs, powers, opts) => {
53
53
  });
54
54
 
55
55
  // AWAIT
56
+ // eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
56
57
  const hashedBundle = await publishBundle(bundle, connectionSpec);
57
58
  process.stdout.write(`${JSON.stringify(hashedBundle)}\n`);
58
59
  }
package/src/main.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @jessie.js/no-nested-await */
1
2
  /* global process */
2
3
  import { Command } from 'commander';
3
4
  import path from 'path';
@@ -35,7 +36,6 @@ const main = async (progname, rawArgs, powers) => {
35
36
  const program = new Command();
36
37
 
37
38
  async function isNotBasedir() {
38
- await null;
39
39
  try {
40
40
  await fs.stat(STAMP);
41
41
  return false;
package/src/publish.js CHANGED
@@ -289,12 +289,14 @@ export const makeCosmosBundlePublisher = ({
289
289
  const endpoint = urlForRpcAddress(rpcAddress);
290
290
 
291
291
  // AWAIT
292
+ // eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
292
293
  const stargateClient = await connectWithSigner(endpoint, wallet, {
293
294
  gasPrice: Agoric.gasPrice,
294
295
  registry,
295
296
  });
296
297
 
297
298
  // AWAIT
299
+ // eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
298
300
  const result = await stargateClient
299
301
  .signAndBroadcast(from.address, encodeObjects, Agoric.fee)
300
302
  .catch(error => {
@@ -310,6 +312,7 @@ export const makeCosmosBundlePublisher = ({
310
312
  }
311
313
 
312
314
  // AWAIT
315
+ // eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
313
316
  await E(leader).jitter('agoric CLI deploy');
314
317
  }
315
318
 
@@ -423,7 +426,6 @@ const publishBundle = async (
423
426
  )}, publishBundle supports only "endoZipBase64" with "endoZipBase64Sha512"`;
424
427
  }
425
428
 
426
- await null;
427
429
  if (connectionSpec === undefined && getDefaultConnection !== undefined) {
428
430
  connectionSpec = await getDefaultConnection();
429
431
  }
@@ -4,9 +4,6 @@
4
4
  export default [
5
5
  "@agoric/access-token",
6
6
  "@agoric/assert",
7
- "@agoric/base-zone",
8
- "@agoric/boot",
9
- "@agoric/builders",
10
7
  "@agoric/cache",
11
8
  "@agoric/casting",
12
9
  "@agoric/cosmic-proto",
@@ -20,10 +17,10 @@ export default [
20
17
  "@agoric/import-manager",
21
18
  "@agoric/inter-protocol",
22
19
  "@agoric/internal",
23
- "@agoric/network",
24
20
  "@agoric/notifier",
25
21
  "@agoric/pegasus",
26
22
  "@agoric/same-structure",
23
+ "@agoric/sharing-service",
27
24
  "@agoric/smart-wallet",
28
25
  "@agoric/solo",
29
26
  "@agoric/sparse-ints",
@@ -37,11 +34,13 @@ export default [
37
34
  "@agoric/swingset-xsnap-supervisor",
38
35
  "@agoric/telemetry",
39
36
  "@agoric/time",
37
+ "@agoric/ui-components",
40
38
  "@agoric/vat-data",
41
39
  "@agoric/vats",
42
- "@agoric/vm-config",
43
40
  "@agoric/wallet",
44
41
  "@agoric/wallet-backend",
42
+ "@agoric/wallet-connection",
43
+ "@agoric/web-components",
45
44
  "@agoric/xsnap",
46
45
  "@agoric/xsnap-lockdown",
47
46
  "@agoric/zoe",
@@ -42,7 +42,6 @@ export default async function setDefaultsMain(progname, rawArgs, powers, opts) {
42
42
  return fs.writeFile(fileName, contents);
43
43
  };
44
44
 
45
- await null;
46
45
  if (appFile) {
47
46
  log(`read ${appFile}`);
48
47
  const appToml = await fs.readFile(appFile, 'utf-8');
package/src/start.js CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint @typescript-eslint/no-floating-promises: "warn" */
2
1
  /* global process setTimeout */
3
2
  import chalk from 'chalk';
4
3
  import { createHash } from 'crypto';
@@ -41,7 +40,6 @@ const DELEGATE0_COINS = `50000000${STAKING_DENOM}`;
41
40
  const SOLO_COINS = `13000000${STAKING_DENOM},500000000${CENTRAL_DENOM}`;
42
41
  const CHAIN_ID = 'agoriclocal';
43
42
 
44
- const SERVERS_ROOT_DIR = '_agstate/agoric-servers';
45
43
  const FAKE_CHAIN_DELAY =
46
44
  process.env.FAKE_CHAIN_DELAY === undefined
47
45
  ? 0
@@ -153,7 +151,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {
153
151
  ]);
154
152
 
155
153
  const exists = async file => {
156
- await null;
157
154
  try {
158
155
  await fs.stat(file);
159
156
  return true;
@@ -162,12 +159,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {
162
159
  }
163
160
  };
164
161
 
165
- const rmVerbose = async filePath => {
166
- log(chalk.green(`removing ${filePath}`));
167
- // rm is available on all the unix-likes, so use it for speed.
168
- await pspawn('rm', ['-rf', filePath]);
169
- };
170
-
171
162
  let agSolo;
172
163
  let agSoloBuild;
173
164
  if (opts.dockerTag) {
@@ -180,11 +171,12 @@ export default async function startMain(progname, rawArgs, powers, opts) {
180
171
  const fakeDelay =
181
172
  popts.delay === undefined ? FAKE_CHAIN_DELAY : Number(popts.delay);
182
173
 
183
- const serverDir = `${SERVERS_ROOT_DIR}/${profileName}`;
174
+ const agServer = `_agstate/agoric-servers/${profileName}`;
184
175
 
185
- await null;
186
176
  if (popts.reset) {
187
- rmVerbose(serverDir);
177
+ log(chalk.green(`removing ${agServer}`));
178
+ // rm is available on all the unix-likes, so use it for speed.
179
+ await pspawn('rm', ['-rf', agServer]);
188
180
  }
189
181
 
190
182
  if (!opts.dockerTag) {
@@ -205,14 +197,14 @@ export default async function startMain(progname, rawArgs, powers, opts) {
205
197
  }
206
198
 
207
199
  const fakeGCI = 'sim-chain';
208
- const serverExists = await exists(serverDir);
200
+ const serverExists = await exists(agServer);
209
201
  if (!serverExists) {
210
202
  log(chalk.yellow(`initializing ${profileName}`));
211
203
  await pspawn(
212
204
  agSolo,
213
205
  ['init', profileName, '--egresses=fake', `--webport=${HOST_PORT}`],
214
206
  {
215
- cwd: SERVERS_ROOT_DIR,
207
+ cwd: '_agstate/agoric-servers',
216
208
  },
217
209
  );
218
210
  }
@@ -223,7 +215,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
223
215
  agSolo,
224
216
  ['set-fake-chain', `--delay=${fakeDelay}`, fakeGCI],
225
217
  {
226
- cwd: serverDir,
218
+ cwd: agServer,
227
219
  },
228
220
  );
229
221
  }
@@ -234,7 +226,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
234
226
  }
235
227
 
236
228
  const ps = pspawn(agSolo, [...debugOpts, 'start'], {
237
- cwd: serverDir,
229
+ cwd: agServer,
238
230
  env: nodeDebugEnv,
239
231
  });
240
232
  process.on('SIGINT', () => ps.childProcess.kill('SIGINT'));
@@ -254,7 +246,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {
254
246
  }
255
247
 
256
248
  const { cosmosChain, cosmosChainBuild } = getSDKBinaries(sdkPrefixes);
257
- await null;
258
249
  if (popts.pull || popts.rebuild) {
259
250
  if (popts.dockerTag) {
260
251
  const exitStatus = await pspawn('docker', ['pull', SDK_IMAGE]);
@@ -272,15 +263,17 @@ export default async function startMain(progname, rawArgs, powers, opts) {
272
263
  }
273
264
  }
274
265
 
275
- const serverDir = `${SERVERS_ROOT_DIR}/${profileName}-${portNum}`;
266
+ const agServer = `_agstate/agoric-servers/${profileName}-${portNum}`;
276
267
  if (popts.reset) {
277
- rmVerbose(serverDir);
268
+ log(chalk.green(`removing ${agServer}`));
269
+ // rm is available on all the unix-likes, so use it for speed.
270
+ await pspawn('rm', ['-rf', agServer]);
278
271
  }
279
272
 
280
273
  let chainSpawn;
281
274
  if (!popts.dockerTag) {
282
275
  chainSpawn = (args, spawnOpts = undefined) => {
283
- return pspawn(cosmosChain, [...args, `--home=${serverDir}`], spawnOpts);
276
+ return pspawn(cosmosChain, [...args, `--home=${agServer}`], spawnOpts);
284
277
  };
285
278
  } else {
286
279
  chainSpawn = (args, spawnOpts = undefined, dockerArgs = []) =>
@@ -294,13 +287,13 @@ export default async function startMain(progname, rawArgs, powers, opts) {
294
287
  ...terminalOnlyFlags(`-it`),
295
288
  SDK_IMAGE,
296
289
  ...args,
297
- `--home=/usr/src/dapp/${serverDir}`,
290
+ `--home=/usr/src/dapp/${agServer}`,
298
291
  ],
299
292
  spawnOpts,
300
293
  );
301
294
  }
302
295
 
303
- const serverExists = await exists(serverDir);
296
+ const serverExists = await exists(agServer);
304
297
  if (!serverExists) {
305
298
  const exitStatus = await chainSpawn([
306
299
  'init',
@@ -315,6 +308,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
315
308
  // Get or create the essential addresses.
316
309
  const addrs = {};
317
310
  for (const keyName of ['provision', 'delegate0']) {
311
+ /* eslint-disable no-await-in-loop */
318
312
  let statusOut = showKey(keyName);
319
313
  const exitStatusOut = await statusOut[0];
320
314
  if (exitStatusOut) {
@@ -337,7 +331,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
337
331
  /* eslint-enable no-await-in-loop */
338
332
  }
339
333
 
340
- const genesisFile = `${serverDir}/config/genesis.json`;
334
+ const genesisFile = `${agServer}/config/genesis.json`;
341
335
  const stampExists = await exists(`${genesisFile}.stamp`);
342
336
  if (!stampExists) {
343
337
  let exitStatus;
@@ -367,7 +361,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
367
361
  `--keyring-dir=${keysHome}`,
368
362
  '--keyring-backend=test',
369
363
  `--chain-id=${CHAIN_ID}`,
370
- DELEGATE0_COINS,
364
+ `${DELEGATE0_COINS}`,
371
365
  ]);
372
366
  if (exitStatus) {
373
367
  return exitStatus;
@@ -388,8 +382,8 @@ export default async function startMain(progname, rawArgs, powers, opts) {
388
382
 
389
383
  // Complete the genesis file and launch the chain.
390
384
  log('read ag-chain-cosmos config');
391
- const configFile = `${serverDir}/config/config.toml`;
392
- const appFile = `${serverDir}/config/app.toml`;
385
+ const configFile = `${agServer}/config/config.toml`;
386
+ const appFile = `${agServer}/config/app.toml`;
393
387
  const [genesisJson, configToml, appToml] = await Promise.all([
394
388
  fs.readFile(genesisFile, 'utf-8'),
395
389
  fs.readFile(configFile, 'utf-8'),
@@ -452,10 +446,9 @@ export default async function startMain(progname, rawArgs, powers, opts) {
452
446
  return 1;
453
447
  }
454
448
 
455
- const serverDir = `${SERVERS_ROOT_DIR}/${profileName}-${portNum}`;
449
+ const agServer = `_agstate/agoric-servers/${profileName}-${portNum}`;
456
450
 
457
451
  const { cosmosClientBuild } = getSDKBinaries(sdkPrefixes);
458
- await null;
459
452
  if (popts.pull || popts.rebuild) {
460
453
  if (popts.dockerTag) {
461
454
  const exitStatus = await pspawn('docker', ['pull', SDK_IMAGE]);
@@ -481,7 +474,9 @@ export default async function startMain(progname, rawArgs, powers, opts) {
481
474
  }
482
475
 
483
476
  if (popts.reset) {
484
- rmVerbose(serverDir);
477
+ log(chalk.green(`removing ${agServer}`));
478
+ // rm is available on all the unix-likes, so use it for speed.
479
+ await pspawn('rm', ['-rf', agServer]);
485
480
  }
486
481
 
487
482
  let soloSpawn;
@@ -496,7 +491,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
496
491
  'run',
497
492
  `--volume=${process.cwd()}:/usr/src/dapp`,
498
493
  `--volume=${process.env.HOME}/.agoric:/root/.agoric`,
499
- `-eAG_SOLO_BASEDIR=/usr/src/dapp/${serverDir}`,
494
+ `-eAG_SOLO_BASEDIR=/usr/src/dapp/${agServer}`,
500
495
  `--rm`,
501
496
  ...terminalOnlyFlags(`-it`),
502
497
  `--entrypoint=ag-solo`,
@@ -508,7 +503,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
508
503
  );
509
504
  }
510
505
 
511
- const serverExists = await exists(serverDir);
506
+ const serverExists = await exists(agServer);
512
507
  // Initialise the solo directory and key.
513
508
  if (!serverExists) {
514
509
  const initArgs = [`--webport=${portNum}`];
@@ -516,7 +511,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
516
511
  initArgs.push(`--webhost=0.0.0.0`);
517
512
  }
518
513
  const exitStatus = await soloSpawn(
519
- ['init', serverDir, ...initArgs],
514
+ ['init', agServer, ...initArgs],
520
515
  undefined,
521
516
  [`--workdir=/usr/src/dapp`],
522
517
  );
@@ -527,15 +522,15 @@ export default async function startMain(progname, rawArgs, powers, opts) {
527
522
 
528
523
  // Create the full economy chain config.
529
524
  const agServerResolve = spec =>
530
- require.resolve(spec, { paths: [serverDir] });
525
+ require.resolve(spec, { paths: [agServer] });
531
526
  const coreConfigPath = agServerResolve(
532
- '@agoric/vm-config/decentral-core-config.json',
527
+ '@agoric/vats/decentral-core-config.json',
533
528
  );
534
529
  const economyTemplPath = agServerResolve(
535
530
  '@agoric/cosmic-swingset/economy-template.json',
536
531
  );
537
532
  const [rawSoloAddr, coreConfigJson, economyTemplJson] = await Promise.all([
538
- fs.readFile(`${serverDir}/ag-cosmos-helper-address`, 'utf-8'),
533
+ fs.readFile(`${agServer}/ag-cosmos-helper-address`, 'utf-8'),
539
534
  fs.readFile(coreConfigPath, 'utf-8'),
540
535
  fs.readFile(economyTemplPath, 'utf-8'),
541
536
  ]);
@@ -546,7 +541,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
546
541
  const economyConfig = JSON.parse(coreConfigJson);
547
542
  economyConfig.coreProposals = economyProposals;
548
543
  await fs.writeFile(
549
- `${serverDir}/decentral-economy-config.json`,
544
+ `${agServer}/decentral-economy-config.json`,
550
545
  JSON.stringify(economyConfig, null, 2),
551
546
  );
552
547
 
@@ -554,12 +549,13 @@ export default async function startMain(progname, rawArgs, powers, opts) {
554
549
  return 0;
555
550
  }
556
551
 
557
- const gciFile = `${SERVERS_ROOT_DIR}/local-chain-${CHAIN_PORT}/config/genesis.json.sha256`;
552
+ const gciFile = `_agstate/agoric-servers/local-chain-${CHAIN_PORT}/config/genesis.json.sha256`;
558
553
  process.stdout.write(`Waiting for local-chain-${CHAIN_PORT} to start...`);
559
554
  let hasGci = false;
560
555
  for await (const _ of untilTrue(() => hasGci)) {
561
556
  process.stdout.write('.');
562
557
 
558
+ // eslint-disable-next-line no-await-in-loop
563
559
  await new Promise((resolve, reject) => {
564
560
  fs.stat(gciFile).then(
565
561
  _2 => {
@@ -580,7 +576,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
580
576
 
581
577
  const spawnOpts = {};
582
578
  if (!popts.dockerTag) {
583
- spawnOpts.cwd = serverDir;
579
+ spawnOpts.cwd = agServer;
584
580
  }
585
581
 
586
582
  const rpcAddrs = [`localhost:${CHAIN_PORT}`];
@@ -594,6 +590,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
594
590
  let bestRpcAddr;
595
591
  for await (const _ of untilTrue(() => bestRpcAddr)) {
596
592
  for await (const rpcAddr of rpcAddrs) {
593
+ // eslint-disable-next-line no-await-in-loop
597
594
  exitStatus = await keysSpawn([
598
595
  'query',
599
596
  'swingset',
@@ -642,6 +639,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
642
639
  ];
643
640
  for (/* await */ const cmd of provCmds) {
644
641
  const statusOut = capture(keysSpawn, cmd, true);
642
+ // eslint-disable-next-line no-await-in-loop
645
643
  exitStatus = await statusOut[0];
646
644
  if (!exitStatus) {
647
645
  const json = statusOut[1].replace(/^gas estimate: \d+$/m, '');
@@ -666,6 +664,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
666
664
  }
667
665
  }
668
666
  if (!bestRpcAddr) {
667
+ // eslint-disable-next-line no-await-in-loop
669
668
  await delay(2000);
670
669
  }
671
670
  }
@@ -691,7 +690,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {
691
690
  }
692
691
 
693
692
  async function startTestnetDocker(profileName, startArgs, popts) {
694
- await null;
695
693
  if (popts.dockerTag && popts.pull) {
696
694
  const exitStatus = await pspawn('docker', ['pull', SOLO_IMAGE]);
697
695
  if (exitStatus) {
@@ -701,10 +699,12 @@ export default async function startMain(progname, rawArgs, powers, opts) {
701
699
 
702
700
  const port = startArgs[0] || PORT;
703
701
  const netconfig = startArgs[1] || DEFAULT_NETCONFIG;
704
- const serverDir = `${SERVERS_ROOT_DIR}/${profileName}-${port}`;
702
+ const agServer = `_agstate/agoric-servers/${profileName}-${port}`;
705
703
 
706
704
  if (popts.reset) {
707
- rmVerbose(serverDir);
705
+ log(chalk.green(`removing ${agServer}`));
706
+ // rm is available on all the unix-likes, so use it for speed.
707
+ await pspawn('rm', ['-rf', agServer]);
708
708
  }
709
709
 
710
710
  const setupRun = (...bonusArgs) =>
@@ -712,7 +712,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
712
712
  'run',
713
713
  `-p127.0.0.1:${HOST_PORT}:${port}`,
714
714
  `--volume=${process.cwd()}:/usr/src/dapp`,
715
- `-eAG_SOLO_BASEDIR=/usr/src/dapp/${serverDir}`,
715
+ `-eAG_SOLO_BASEDIR=/usr/src/dapp/${agServer}`,
716
716
  `--rm`,
717
717
  ...terminalOnlyFlags(`-it`),
718
718
  SOLO_IMAGE,
@@ -727,38 +727,44 @@ export default async function startMain(progname, rawArgs, powers, opts) {
727
727
  async function startTestnetSdk(profileName, startArgs, popts) {
728
728
  const port = startArgs[0] || PORT;
729
729
  const netconfig = startArgs[1] || DEFAULT_NETCONFIG;
730
- const serverDir = `${SERVERS_ROOT_DIR}/${profileName}-${port}`;
730
+ const agServer = `_agstate/agoric-servers/${profileName}-${port}`;
731
731
 
732
- await null;
733
732
  if (popts.reset) {
734
- rmVerbose(serverDir);
733
+ log(chalk.green(`removing ${agServer}`));
734
+ // rm is available on all the unix-likes, so use it for speed.
735
+ await pspawn('rm', ['-rf', agServer]);
735
736
  }
736
737
 
737
738
  const setupRun = (...bonusArgs) =>
738
739
  pspawn(agSolo, [`--webport=${port}`, ...bonusArgs], {
739
- env: { ...pspawnEnv, AG_SOLO_BASEDIR: serverDir },
740
+ env: { ...pspawnEnv, AG_SOLO_BASEDIR: agServer },
740
741
  });
741
742
 
742
743
  return setupRun('setup', `--netconfig=${netconfig}`);
743
744
  }
744
745
 
745
746
  const profiles = {
746
- __proto__: null,
747
747
  dev: startFakeChain,
748
748
  'local-chain': startLocalChain,
749
749
  'local-solo': startLocalSolo,
750
750
  testnet: opts.dockerTag ? startTestnetDocker : startTestnetSdk,
751
751
  };
752
752
 
753
- const [_command = 'start', profileName = 'dev', ...args] = rawArgs;
753
+ const popts = opts;
754
+
755
+ const args = rawArgs.slice(1);
756
+ const profileName = args[0] || 'dev';
754
757
  const startFn = profiles[profileName];
755
758
  if (!startFn) {
756
- const profileNames = Object.keys(profiles).join(', ');
757
759
  log.error(
758
- `unrecognized profile name ${profileName}; use one of: ${profileNames}`,
760
+ `unrecognized profile name ${profileName}; use one of: ${Object.keys(
761
+ profiles,
762
+ )
763
+ .sort()
764
+ .join(', ')}`,
759
765
  );
760
766
  return 1;
761
767
  }
762
768
 
763
- return startFn(profileName, args, opts);
769
+ return startFn(profileName, args[0] ? args.slice(1) : args, popts);
764
770
  }