agoric 0.22.0-upgrade-14-dev-c8f9e7b.0 → 0.22.0-upgrade-16-dev-07b0130.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/main.js CHANGED
@@ -1,24 +1,24 @@
1
- /* eslint-disable @jessie.js/no-nested-await */
2
1
  /* global process */
3
- import { Command } from 'commander';
4
- import path from 'path';
5
- import url from 'url';
6
2
  import { assert, details as X } from '@agoric/assert';
7
3
  import {
8
- DEFAULT_KEEP_POLLING_SECONDS,
9
4
  DEFAULT_JITTER_SECONDS,
5
+ DEFAULT_KEEP_POLLING_SECONDS,
10
6
  } from '@agoric/casting';
7
+ import { Command } from 'commander';
8
+ import path from 'path';
9
+ import url from 'url';
10
+ import { makeWalletCommand } from './commands/wallet.js';
11
11
  import cosmosMain from './cosmos.js';
12
12
  import deployMain from './deploy.js';
13
- import runMain from './run.js';
14
- import publishMain from './main-publish.js';
13
+ import followMain from './follow.js';
15
14
  import initMain from './init.js';
16
15
  import installMain from './install.js';
16
+ import { statPlans } from './lib/bundles.js';
17
+ import publishMain from './main-publish.js';
18
+ import walletMain from './open.js';
19
+ import runMain from './run.js';
17
20
  import setDefaultsMain from './set-defaults.js';
18
21
  import startMain from './start.js';
19
- import followMain from './follow.js';
20
- import walletMain from './open.js';
21
- import { makeWalletCommand } from './commands/wallet.js';
22
22
 
23
23
  const DEFAULT_DAPP_TEMPLATE = 'dapp-offer-up';
24
24
  const DEFAULT_DAPP_URL_BASE = 'https://github.com/Agoric/';
@@ -36,6 +36,7 @@ const main = async (progname, rawArgs, powers) => {
36
36
  const program = new Command();
37
37
 
38
38
  async function isNotBasedir() {
39
+ await null;
39
40
  try {
40
41
  await fs.stat(STAMP);
41
42
  return false;
@@ -46,6 +47,7 @@ const main = async (progname, rawArgs, powers) => {
46
47
  return true;
47
48
  }
48
49
 
50
+ // XXX exits process when fn resolves
49
51
  function subMain(fn, args, options) {
50
52
  return fn(progname, args, powers, options).then(
51
53
  // This seems to be the only way to propagate the exit code.
@@ -57,23 +59,29 @@ const main = async (progname, rawArgs, powers) => {
57
59
  const pkg = JSON.parse(pj);
58
60
  program.name(pkg.name).version(pkg.version);
59
61
 
60
- program
61
- .option('--sdk', 'use the Agoric SDK containing this program')
62
- .option('--no-sdk', 'do not use the Agoric SDK containing this program')
63
- .option('--docker-tag <tag>', 'image tag to use for Docker containers')
64
- .option(
62
+ const cmdOpts = { verbose: 0 };
63
+ const addCmdOpts = baseCmd =>
64
+ baseCmd.option(
65
65
  '-v, --verbose',
66
66
  'verbosity that can be increased',
67
- (_value, previous) => previous + 1,
68
- 0,
67
+ (_value, _previous) => (cmdOpts.verbose += 1),
69
68
  );
69
+ const baseCmd = (...args) => addCmdOpts(program.command(...args));
70
+
71
+ addCmdOpts(
72
+ program
73
+ .enablePositionalOptions()
74
+ .option('--sdk', 'use the Agoric SDK containing this program')
75
+ .option('--no-sdk', 'do not use the Agoric SDK containing this program'),
76
+ );
70
77
 
71
78
  // Add each of the commands.
72
- program
73
- .command('cosmos <command...>')
79
+ baseCmd('cosmos <command...>')
80
+ .passThroughOptions(true)
81
+ .option('--docker-tag <tag>', 'image tag to use for Docker containers')
74
82
  .description('client for an Agoric Cosmos chain')
75
83
  .action(async (command, _options, cmd) => {
76
- const opts = { ...program.opts(), ...cmd.opts() };
84
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
77
85
  return subMain(cosmosMain, ['cosmos', ...command], opts);
78
86
  });
79
87
 
@@ -90,8 +98,7 @@ const main = async (progname, rawArgs, powers) => {
90
98
  { executableFile: ibcSetup },
91
99
  );
92
100
 
93
- program
94
- .command('open')
101
+ baseCmd('open')
95
102
  .description('launch the Agoric UI')
96
103
  .option(
97
104
  '--hostport <host:port>',
@@ -112,12 +119,11 @@ const main = async (progname, rawArgs, powers) => {
112
119
  },
113
120
  )
114
121
  .action(async (_options, cmd) => {
115
- const opts = { ...program.opts(), ...cmd.opts() };
122
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
116
123
  return subMain(walletMain, ['wallet'], opts);
117
124
  });
118
125
 
119
- program
120
- .command('init <project>')
126
+ baseCmd('init <project>')
121
127
  .description('create a new Dapp directory named <project>')
122
128
  .option(
123
129
  '--dapp-template <name>',
@@ -134,13 +140,17 @@ const main = async (progname, rawArgs, powers) => {
134
140
  'use this branch instead of the repository HEAD',
135
141
  DEFAULT_DAPP_BRANCH,
136
142
  )
143
+ // Tolerate @agoric/create-dapp's `agoric init --version` invocation.
144
+ .option('-V, --version', 'output the version number', () => {
145
+ console.log(pkg.version);
146
+ process.exit(0);
147
+ })
137
148
  .action(async (project, _options, cmd) => {
138
- const opts = { ...program.opts(), ...cmd.opts() };
149
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
139
150
  return subMain(initMain, ['init', project], opts);
140
151
  });
141
152
 
142
- program
143
- .command('set-defaults <program> <config-dir>')
153
+ baseCmd('set-defaults <program> <config-dir>')
144
154
  .description('update the configuration files for <program> in <config-dir>')
145
155
  .option(
146
156
  '--enable-cors',
@@ -168,7 +178,7 @@ const main = async (progname, rawArgs, powers) => {
168
178
  '',
169
179
  )
170
180
  .action(async (prog, configDir, _options, cmd) => {
171
- const opts = { ...program.opts(), ...cmd.opts() };
181
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
172
182
  return subMain(setDefaultsMain, ['set-defaults', prog, configDir], opts);
173
183
  });
174
184
 
@@ -187,17 +197,15 @@ const main = async (progname, rawArgs, powers) => {
187
197
  },
188
198
  );
189
199
 
190
- program
191
- .command('install [force-sdk-version]')
200
+ baseCmd('install [force-sdk-version]')
192
201
  .description('install Dapp dependencies')
193
202
  .action(async (forceSdkVersion, _options, cmd) => {
194
203
  await isNotBasedir();
195
- const opts = { ...program.opts(), ...cmd.opts() };
204
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
196
205
  return subMain(installMain, ['install', forceSdkVersion], opts);
197
206
  });
198
207
 
199
- program
200
- .command('follow <path-spec...>')
208
+ baseCmd('follow <path-spec...>')
201
209
  .description('follow an Agoric Casting leader')
202
210
  .option(
203
211
  '--proof <strict | optimistic | none>',
@@ -270,61 +278,59 @@ const main = async (progname, rawArgs, powers) => {
270
278
  )
271
279
  .option('-B, --bootstrap <config>', 'network bootstrap configuration')
272
280
  .action(async (pathSpecs, _options, cmd) => {
273
- const opts = { ...program.opts(), ...cmd.opts() };
281
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
274
282
  return subMain(followMain, ['follow', ...pathSpecs], opts);
275
283
  });
276
284
 
277
- const addRunOptions = cmd =>
278
- cmd
279
- .option(
280
- '--allow-unsafe-plugins',
281
- `CAREFUL: installed Agoric VM plugins will also have all your user's privileges`,
282
- false,
283
- )
284
- .option(
285
- '--hostport <host:port>',
286
- 'host and port to connect to VM',
287
- '127.0.0.1:8000',
288
- )
289
- .option(
290
- '--need <subsystems>',
291
- 'comma-separated names of subsystems to wait for',
292
- 'local,agoric,wallet',
293
- )
294
- .option(
295
- '--provide <subsystems>',
296
- 'comma-separated names of subsystems this script initializes',
297
- '',
298
- );
299
-
300
- program
301
- .command('run <script> [script-args...]')
285
+ baseCmd('run <script> [script-args...]')
302
286
  .description(
303
287
  'run a script with all your user privileges and some Agoric endowments',
304
288
  )
289
+ .passThroughOptions(true)
305
290
  .action(async (script, scriptArgs, _options, cmd) => {
306
- const opts = { ...program.opts(), ...cmd.opts(), scriptArgs };
307
- return subMain(runMain, ['run', script], opts);
291
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts, scriptArgs };
292
+ await runMain(progname, ['run', script], powers, opts);
293
+
294
+ if (opts.verbose) {
295
+ await statPlans(process.cwd());
296
+ }
308
297
  });
309
298
 
310
- addRunOptions(
311
- program
312
- .command('deploy [script...]')
313
- .option(
314
- '--target <target>',
315
- 'One of agoric, local, cosmos, or sim',
316
- 'agoric',
317
- )
318
- .description(
319
- 'run multiple scripts with all your user privileges against the local Agoric VM',
320
- ),
321
- ).action(async (scripts, _options, cmd) => {
322
- const opts = { ...program.opts(), ...cmd.opts() };
323
- return subMain(deployMain, ['deploy', ...scripts], opts);
324
- });
299
+ baseCmd('deploy [script...]')
300
+ .option(
301
+ '--target <target>',
302
+ 'One of agoric, local, cosmos, or sim',
303
+ 'agoric',
304
+ )
305
+ .option(
306
+ '--allow-unsafe-plugins',
307
+ `CAREFUL: installed Agoric VM plugins will also have all your user's privileges`,
308
+ false,
309
+ )
310
+ .option(
311
+ '--hostport <host:port>',
312
+ 'host and port to connect to VM',
313
+ '127.0.0.1:8000',
314
+ )
315
+ .option(
316
+ '--need <subsystems>',
317
+ 'comma-separated names of subsystems to wait for',
318
+ 'local,agoric,wallet',
319
+ )
320
+ .option(
321
+ '--provide <subsystems>',
322
+ 'comma-separated names of subsystems this script initializes',
323
+ '',
324
+ )
325
+ .description(
326
+ 'run multiple scripts with all your user privileges against the local Agoric VM',
327
+ )
328
+ .action(async (scripts, _options, cmd) => {
329
+ const opts = { ...program.opts(), ...cmd.opts() };
330
+ return subMain(deployMain, ['deploy', ...scripts], opts);
331
+ });
325
332
 
326
- program
327
- .command('publish [bundle...]')
333
+ baseCmd('publish [bundle...]')
328
334
  .option(
329
335
  '-c, --chain-id <chainID>',
330
336
  'The ID of the destination chain',
@@ -345,10 +351,9 @@ const main = async (progname, rawArgs, powers) => {
345
351
  return subMain(publishMain, ['publish', ...bundles], opts);
346
352
  });
347
353
 
348
- program.addCommand(await makeWalletCommand());
354
+ await makeWalletCommand(baseCmd);
349
355
 
350
- program
351
- .command('start [profile] [args...]')
356
+ baseCmd('start [profile] [args...]')
352
357
  .description(
353
358
  `\
354
359
  start an Agoric VM
@@ -360,6 +365,7 @@ agoric start local-solo [portNum] [provisionPowers] - local solo VM
360
365
  `,
361
366
  )
362
367
  .option('-d, --debug', 'run in JS debugger mode')
368
+ .option('--docker-tag <tag>', 'image tag to use for Docker containers')
363
369
  .option('--reset', 'clear all VM state before starting')
364
370
  .option('--no-restart', 'do not actually start the VM')
365
371
  .option('--pull', 'for Docker-based VM, pull the image before running')
@@ -383,19 +389,13 @@ agoric start local-solo [portNum] [provisionPowers] - local solo VM
383
389
  )
384
390
  .action(async (profile, args, _options, cmd) => {
385
391
  await isNotBasedir();
386
- const opts = { ...program.opts(), ...cmd.opts() };
392
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
387
393
  return subMain(startMain, ['start', profile, ...args], opts);
388
394
  });
389
395
 
390
396
  // Throw an error instead of exiting directly.
391
397
  program.exitOverride();
392
398
 
393
- // Hack: cosmos arguments are always unparsed.
394
- const cosmosIndex = rawArgs.indexOf('cosmos');
395
- if (cosmosIndex >= 0) {
396
- rawArgs.splice(cosmosIndex + 1, 0, '--');
397
- }
398
-
399
399
  try {
400
400
  await program.parseAsync(rawArgs, { from: 'user' });
401
401
  } catch (e) {
package/src/open.js CHANGED
@@ -5,8 +5,8 @@ import { getAccessToken } from '@agoric/access-token';
5
5
 
6
6
  import { assert, details as X } from '@agoric/assert';
7
7
 
8
- export default async function walletMain(progname, rawArgs, powers, opts) {
9
- const { anylogger, fs } = powers;
8
+ export default async function walletMain(_progname, _rawArgs, powers, opts) {
9
+ const { anylogger } = powers;
10
10
  const console = anylogger('agoric:wallet');
11
11
 
12
12
  let suffix;
@@ -39,10 +39,10 @@ export default async function walletMain(progname, rawArgs, powers, opts) {
39
39
  1000,
40
40
  );
41
41
 
42
- const walletAccessToken = await getAccessToken(opts.hostport, {
43
- console,
44
- fs,
45
- }).catch(e => console.error(`Trying to fetch access token:`, e));
42
+ const walletAccessToken = await getAccessToken(opts.hostport).catch(e => {
43
+ console.error(`Trying to fetch access token:`, e);
44
+ throw e;
45
+ });
46
46
 
47
47
  clearInterval(progressTimer);
48
48
  process.stderr.write('\n');
package/src/publish.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- /// <reference types="ses"/>
2
+ /// <reference types="ses" />
3
3
 
4
4
  import { E } from '@endo/far';
5
5
 
@@ -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],
@@ -96,7 +97,6 @@ const choose = (array, randomNumber) => {
96
97
  return array[index];
97
98
  };
98
99
 
99
- // eslint-disable-next-line jsdoc/require-returns-check
100
100
  /**
101
101
  * @param {unknown} connectionSpec
102
102
  * @returns {asserts connectionSpec is HttpConnectionSpec}
@@ -124,7 +124,6 @@ const assertHttpConnectionSpec = connectionSpec => {
124
124
  Fail`Expected integer "port" on "http" type connectionSpec, ${connectionSpec}`;
125
125
  };
126
126
 
127
- // eslint-disable-next-line jsdoc/require-returns-check
128
127
  /**
129
128
  * @param {unknown} connectionSpec
130
129
  * @returns {asserts connectionSpec is CosmosConnectionSpec}
@@ -289,14 +288,12 @@ export const makeCosmosBundlePublisher = ({
289
288
  const endpoint = urlForRpcAddress(rpcAddress);
290
289
 
291
290
  // AWAIT
292
- // eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
293
291
  const stargateClient = await connectWithSigner(endpoint, wallet, {
294
292
  gasPrice: Agoric.gasPrice,
295
293
  registry,
296
294
  });
297
295
 
298
296
  // AWAIT
299
- // eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
300
297
  const result = await stargateClient
301
298
  .signAndBroadcast(from.address, encodeObjects, Agoric.fee)
302
299
  .catch(error => {
@@ -312,7 +309,6 @@ export const makeCosmosBundlePublisher = ({
312
309
  }
313
310
 
314
311
  // AWAIT
315
- // eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
316
312
  await E(leader).jitter('agoric CLI deploy');
317
313
  }
318
314
 
@@ -426,6 +422,7 @@ const publishBundle = async (
426
422
  )}, publishBundle supports only "endoZipBase64" with "endoZipBase64Sha512"`;
427
423
  }
428
424
 
425
+ await null;
429
426
  if (connectionSpec === undefined && getDefaultConnection !== undefined) {
430
427
  connectionSpec = await getDefaultConnection();
431
428
  }
@@ -1,9 +1,12 @@
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 [
5
4
  "@agoric/access-token",
6
5
  "@agoric/assert",
6
+ "@agoric/base-zone",
7
+ "@agoric/benchmark",
8
+ "@agoric/boot",
9
+ "@agoric/builders",
7
10
  "@agoric/cache",
8
11
  "@agoric/casting",
9
12
  "@agoric/cosmic-proto",
@@ -18,10 +21,10 @@ export default [
18
21
  "@agoric/import-manager",
19
22
  "@agoric/inter-protocol",
20
23
  "@agoric/internal",
24
+ "@agoric/kmarshal",
25
+ "@agoric/network",
21
26
  "@agoric/notifier",
22
27
  "@agoric/pegasus",
23
- "@agoric/same-structure",
24
- "@agoric/sharing-service",
25
28
  "@agoric/smart-wallet",
26
29
  "@agoric/solo",
27
30
  "@agoric/sparse-ints",
@@ -35,13 +38,12 @@ export default [
35
38
  "@agoric/swingset-xsnap-supervisor",
36
39
  "@agoric/telemetry",
37
40
  "@agoric/time",
38
- "@agoric/ui-components",
39
41
  "@agoric/vat-data",
40
42
  "@agoric/vats",
43
+ "@agoric/vm-config",
44
+ "@agoric/vow",
41
45
  "@agoric/wallet",
42
46
  "@agoric/wallet-backend",
43
- "@agoric/wallet-connection",
44
- "@agoric/web-components",
45
47
  "@agoric/xsnap",
46
48
  "@agoric/xsnap-lockdown",
47
49
  "@agoric/zoe",
@@ -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');