agoric 0.21.2-dev-7ffae88.0 → 0.21.2-dev-32c4d68.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agoric",
3
- "version": "0.21.2-dev-7ffae88.0+7ffae88",
3
+ "version": "0.21.2-dev-32c4d68.0+32c4d68",
4
4
  "description": "Manage the Agoric Javascript smart contract platform",
5
5
  "type": "module",
6
6
  "main": "src/main.js",
@@ -29,45 +29,45 @@
29
29
  "lint:eslint": "eslint ."
30
30
  },
31
31
  "devDependencies": {
32
- "@agoric/cosmic-swingset": "0.41.4-dev-7ffae88.0+7ffae88",
33
- "@agoric/deploy-script-support": "0.10.4-dev-7ffae88.0+7ffae88",
32
+ "@agoric/cosmic-swingset": "0.41.4-dev-32c4d68.0+32c4d68",
33
+ "@agoric/deploy-script-support": "0.10.4-dev-32c4d68.0+32c4d68",
34
34
  "ava": "^5.3.0",
35
35
  "c8": "^7.13.0",
36
36
  "dd-trace": "^4.11.1"
37
37
  },
38
38
  "dependencies": {
39
- "@agoric/access-token": "0.4.22-dev-7ffae88.0+7ffae88",
40
- "@agoric/assert": "0.6.1-dev-7ffae88.0+7ffae88",
41
- "@agoric/cache": "0.3.3-dev-7ffae88.0+7ffae88",
42
- "@agoric/casting": "0.4.3-dev-7ffae88.0+7ffae88",
43
- "@agoric/cosmic-proto": "0.3.1-dev-7ffae88.0+7ffae88",
44
- "@agoric/ertp": "0.16.3-dev-7ffae88.0+7ffae88",
45
- "@agoric/governance": "0.10.4-dev-7ffae88.0+7ffae88",
46
- "@agoric/inter-protocol": "0.16.2-dev-7ffae88.0+7ffae88",
47
- "@agoric/internal": "0.3.3-dev-7ffae88.0+7ffae88",
48
- "@agoric/network": "0.1.1-dev-7ffae88.0+7ffae88",
49
- "@agoric/smart-wallet": "0.5.4-dev-7ffae88.0+7ffae88",
50
- "@agoric/store": "0.9.3-dev-7ffae88.0+7ffae88",
51
- "@agoric/swingset-vat": "0.32.3-dev-7ffae88.0+7ffae88",
52
- "@agoric/vats": "0.15.2-dev-7ffae88.0+7ffae88",
53
- "@agoric/zoe": "0.26.3-dev-7ffae88.0+7ffae88",
54
- "@agoric/zone": "0.2.3-dev-7ffae88.0+7ffae88",
55
- "@confio/relayer": "^0.9.0",
56
- "@cosmjs/crypto": "^0.30.1",
57
- "@cosmjs/encoding": "^0.30.1",
58
- "@cosmjs/math": "^0.30.1",
59
- "@cosmjs/proto-signing": "^0.30.1",
60
- "@cosmjs/stargate": "^0.30.1",
61
- "@endo/bundle-source": "^3.0.2",
62
- "@endo/captp": "^4.0.2",
63
- "@endo/compartment-mapper": "^1.1.0",
64
- "@endo/env-options": "^1.1.0",
65
- "@endo/far": "^1.0.2",
66
- "@endo/init": "^1.0.2",
67
- "@endo/marshal": "^1.1.0",
68
- "@endo/nat": "^5.0.2",
69
- "@endo/patterns": "^1.1.0",
70
- "@endo/promise-kit": "^1.0.2",
39
+ "@agoric/access-token": "0.4.22-dev-32c4d68.0+32c4d68",
40
+ "@agoric/assert": "0.6.1-dev-32c4d68.0+32c4d68",
41
+ "@agoric/cache": "0.3.3-dev-32c4d68.0+32c4d68",
42
+ "@agoric/casting": "0.4.3-dev-32c4d68.0+32c4d68",
43
+ "@agoric/cosmic-proto": "0.4.1-dev-32c4d68.0+32c4d68",
44
+ "@agoric/ertp": "0.16.3-dev-32c4d68.0+32c4d68",
45
+ "@agoric/governance": "0.10.4-dev-32c4d68.0+32c4d68",
46
+ "@agoric/inter-protocol": "0.16.2-dev-32c4d68.0+32c4d68",
47
+ "@agoric/internal": "0.3.3-dev-32c4d68.0+32c4d68",
48
+ "@agoric/network": "0.1.1-dev-32c4d68.0+32c4d68",
49
+ "@agoric/smart-wallet": "0.5.4-dev-32c4d68.0+32c4d68",
50
+ "@agoric/store": "0.9.3-dev-32c4d68.0+32c4d68",
51
+ "@agoric/swingset-vat": "0.32.3-dev-32c4d68.0+32c4d68",
52
+ "@agoric/vats": "0.15.2-dev-32c4d68.0+32c4d68",
53
+ "@agoric/zoe": "0.26.3-dev-32c4d68.0+32c4d68",
54
+ "@agoric/zone": "0.2.3-dev-32c4d68.0+32c4d68",
55
+ "@confio/relayer": "^0.11.3",
56
+ "@cosmjs/crypto": "^0.32.2",
57
+ "@cosmjs/encoding": "^0.32.2",
58
+ "@cosmjs/math": "^0.32.2",
59
+ "@cosmjs/proto-signing": "^0.32.2",
60
+ "@cosmjs/stargate": "^0.32.2",
61
+ "@endo/bundle-source": "^3.1.0",
62
+ "@endo/captp": "^4.0.4",
63
+ "@endo/compartment-mapper": "^1.1.2",
64
+ "@endo/env-options": "^1.1.1",
65
+ "@endo/far": "^1.0.4",
66
+ "@endo/init": "^1.0.4",
67
+ "@endo/marshal": "^1.3.0",
68
+ "@endo/nat": "^5.0.4",
69
+ "@endo/patterns": "^1.2.0",
70
+ "@endo/promise-kit": "^1.0.4",
71
71
  "@iarna/toml": "^2.2.3",
72
72
  "anylogger": "^0.21.0",
73
73
  "chalk": "^5.2.0",
@@ -98,7 +98,7 @@
98
98
  "workerThreads": false
99
99
  },
100
100
  "typeCoverage": {
101
- "atLeast": 77.5
101
+ "atLeast": 76.93
102
102
  },
103
- "gitHead": "7ffae88ae37df782d5ffe3cf92261a498b0f636c"
103
+ "gitHead": "32c4d68c5f675f1e8fea1a8bc08621816e7b491e"
104
104
  }
package/src/bin-agops.js CHANGED
@@ -77,7 +77,7 @@ program.addCommand(makeAuctionCommand(logger, { ...procIO, fetch }));
77
77
  program.addCommand(makeInterCommand(procIO, { fetch }));
78
78
  program.addCommand(makeTestCommand(procIO, { fetch }));
79
79
 
80
- E.when(program.parseAsync(process.argv), undefined, err => {
80
+ void E.when(program.parseAsync(process.argv), undefined, err => {
81
81
  if (err instanceof CommanderError) {
82
82
  console.error(err.message);
83
83
  } else {
@@ -8,7 +8,6 @@ import {
8
8
  makeLeader,
9
9
  makeLeaderFromRpcAddresses,
10
10
  } from '@agoric/casting';
11
- import { Command } from 'commander';
12
11
  import fs from 'fs';
13
12
  import util from 'util';
14
13
  import { execFileSync } from 'child_process';
@@ -25,8 +24,12 @@ import { coalesceWalletState, getCurrent } from '../lib/wallet.js';
25
24
 
26
25
  const SLEEP_SECONDS = 3;
27
26
 
28
- export const makeWalletCommand = async () => {
29
- const wallet = new Command('wallet')
27
+ /**
28
+ * @param {import('commander').Command['command']} command
29
+ * @returns {Promise<import('commander').Command>}
30
+ */
31
+ export const makeWalletCommand = async command => {
32
+ const wallet = command('wallet')
30
33
  .description('wallet commands')
31
34
  .option('--home <dir>', 'agd application home directory')
32
35
  .option(
@@ -47,10 +50,11 @@ export const makeWalletCommand = async () => {
47
50
  )
48
51
  .option('--spend', 'confirm you want to spend')
49
52
  .option('--nickname <string>', 'nickname to use', 'my-wallet')
50
- .action(function (opts) {
53
+ .action(async function (opts) {
51
54
  const { account, nickname, spend } = opts;
52
55
  const { home, keyringBackend: backend } = wallet.opts();
53
56
  const tx = ['provision-one', nickname, account, 'SMART_WALLET'];
57
+ await null;
54
58
  if (spend) {
55
59
  execSwingsetTransaction(tx, {
56
60
  from: account,
@@ -58,12 +62,12 @@ export const makeWalletCommand = async () => {
58
62
  ...networkConfig,
59
63
  });
60
64
  } else {
61
- const params = fetchSwingsetParams(networkConfig);
65
+ const params = await fetchSwingsetParams(networkConfig);
62
66
  assert(
63
- params.power_flag_fees.length === 1,
64
- 'multiple power_flag_fees not supported',
67
+ params.powerFlagFees.length === 1,
68
+ 'multiple powerFlagFees not supported',
65
69
  );
66
- const { fee: fees } = params.power_flag_fees[0];
70
+ const { fee: fees } = params.powerFlagFees[0];
67
71
  const nf = new Intl.NumberFormat('en-US');
68
72
  const costs = fees
69
73
  .map(f => `${nf.format(Number(f.amount))} ${f.denom}`)
package/src/install.js CHANGED
@@ -1,4 +1,4 @@
1
- /* global process AggregateError Buffer */
1
+ /* global process Buffer */
2
2
  import path from 'path';
3
3
  import chalk from 'chalk';
4
4
  import { makePspawn } from './helpers.js';
@@ -41,9 +41,9 @@ export default async function installMain(progname, rawArgs, powers, opts) {
41
41
  p.childProcess.stdout.on('data', out => stdout.push(out));
42
42
  await p;
43
43
  const d = JSON.parse(Buffer.concat(stdout).toString('utf-8'));
44
- Object.entries(d).forEach(([name, { location }]) =>
45
- map.set(name, path.resolve(cwd, location)),
46
- );
44
+ for (const [name, { location }] of Object.entries(d)) {
45
+ map.set(name, path.resolve(cwd, location));
46
+ }
47
47
  return map;
48
48
  }
49
49
 
@@ -268,7 +268,9 @@ export default async function installMain(progname, rawArgs, powers, opts) {
268
268
  };
269
269
  await Promise.all(subdirs.map(removeNodeModulesSymlinks));
270
270
  } else {
271
- DEFAULT_SDK_PACKAGE_NAMES.forEach(name => sdkPackageToPath.set(name, null));
271
+ for (const name of DEFAULT_SDK_PACKAGE_NAMES) {
272
+ sdkPackageToPath.set(name, null);
273
+ }
272
274
  }
273
275
 
274
276
  if (forceSdkVersion !== undefined) {
package/src/lib/chain.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // @ts-check
2
2
  /* global process */
3
+ import { agoric } from '@agoric/cosmic-proto';
3
4
  import { normalizeBech32 } from '@cosmjs/encoding';
4
5
  import { execFileSync as execFileSyncAmbient } from 'child_process';
5
6
 
@@ -92,20 +93,19 @@ export const execSwingsetTransaction = (swingsetArgs, opts) => {
92
93
  };
93
94
  harden(execSwingsetTransaction);
94
95
 
95
- // xxx rpc should be able to query this by HTTP without shelling out
96
- export const fetchSwingsetParams = net => {
97
- const { chainName, rpcAddrs, execFileSync = execFileSyncAmbient } = net;
98
- const cmd = [
99
- `--node=${rpcAddrs[0]}`,
100
- `--chain-id=${chainName}`,
101
- 'query',
102
- 'swingset',
103
- 'params',
104
- '--output',
105
- '--json',
106
- ];
107
- const buffer = execFileSync(agdBinary, cmd);
108
- return JSON.parse(buffer.toString());
96
+ /**
97
+ *
98
+ * @param {import('./rpc.js').MinimalNetworkConfig} net
99
+ * @returns {Promise<import('@agoric/cosmic-proto/dist/codegen/agoric/swingset/swingset').Params>}
100
+ */
101
+ export const fetchSwingsetParams = async net => {
102
+ const { rpcAddrs } = net;
103
+ const rpcEndpoint = rpcAddrs[0];
104
+ const client = await agoric.ClientFactory.createRPCQueryClient({
105
+ rpcEndpoint,
106
+ });
107
+ const { params } = await client.agoric.swingset.params();
108
+ return params;
109
109
  };
110
110
  harden(fetchSwingsetParams);
111
111
 
package/src/lib/format.js CHANGED
@@ -39,7 +39,7 @@ const exampleAsset = {
39
39
 
40
40
  /**
41
41
  * @param {AssetDescriptor[]} assets
42
- * @returns {(a: Amount & { brand: BoardRemote }) => [string, number | any[]]}
42
+ * @returns {(a: Amount & { brand: BoardRemote }) => [string | null, number | any[]]}
43
43
  */
44
44
  export const makeAmountFormatter = assets => amt => {
45
45
  const { brand, value } = amt;
package/src/main.js CHANGED
@@ -57,23 +57,29 @@ const main = async (progname, rawArgs, powers) => {
57
57
  const pkg = JSON.parse(pj);
58
58
  program.name(pkg.name).version(pkg.version);
59
59
 
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(
60
+ const cmdOpts = { verbose: 0 };
61
+ const addCmdOpts = baseCmd =>
62
+ baseCmd.option(
65
63
  '-v, --verbose',
66
64
  'verbosity that can be increased',
67
- (_value, previous) => previous + 1,
68
- 0,
65
+ (_value, _previous) => (cmdOpts.verbose += 1),
69
66
  );
67
+ const baseCmd = (...args) => addCmdOpts(program.command(...args));
68
+
69
+ addCmdOpts(
70
+ program
71
+ .enablePositionalOptions()
72
+ .option('--sdk', 'use the Agoric SDK containing this program')
73
+ .option('--no-sdk', 'do not use the Agoric SDK containing this program'),
74
+ );
70
75
 
71
76
  // Add each of the commands.
72
- program
73
- .command('cosmos <command...>')
77
+ baseCmd('cosmos <command...>')
78
+ .passThroughOptions(true)
79
+ .option('--docker-tag <tag>', 'image tag to use for Docker containers')
74
80
  .description('client for an Agoric Cosmos chain')
75
81
  .action(async (command, _options, cmd) => {
76
- const opts = { ...program.opts(), ...cmd.opts() };
82
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
77
83
  return subMain(cosmosMain, ['cosmos', ...command], opts);
78
84
  });
79
85
 
@@ -90,8 +96,7 @@ const main = async (progname, rawArgs, powers) => {
90
96
  { executableFile: ibcSetup },
91
97
  );
92
98
 
93
- program
94
- .command('open')
99
+ baseCmd('open')
95
100
  .description('launch the Agoric UI')
96
101
  .option(
97
102
  '--hostport <host:port>',
@@ -112,12 +117,11 @@ const main = async (progname, rawArgs, powers) => {
112
117
  },
113
118
  )
114
119
  .action(async (_options, cmd) => {
115
- const opts = { ...program.opts(), ...cmd.opts() };
120
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
116
121
  return subMain(walletMain, ['wallet'], opts);
117
122
  });
118
123
 
119
- program
120
- .command('init <project>')
124
+ baseCmd('init <project>')
121
125
  .description('create a new Dapp directory named <project>')
122
126
  .option(
123
127
  '--dapp-template <name>',
@@ -134,13 +138,17 @@ const main = async (progname, rawArgs, powers) => {
134
138
  'use this branch instead of the repository HEAD',
135
139
  DEFAULT_DAPP_BRANCH,
136
140
  )
141
+ // Tolerate @agoric/create-dapp's `agoric init --version` invocation.
142
+ .option('-V, --version', 'output the version number', () => {
143
+ console.log(pkg.version);
144
+ process.exit(0);
145
+ })
137
146
  .action(async (project, _options, cmd) => {
138
- const opts = { ...program.opts(), ...cmd.opts() };
147
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
139
148
  return subMain(initMain, ['init', project], opts);
140
149
  });
141
150
 
142
- program
143
- .command('set-defaults <program> <config-dir>')
151
+ baseCmd('set-defaults <program> <config-dir>')
144
152
  .description('update the configuration files for <program> in <config-dir>')
145
153
  .option(
146
154
  '--enable-cors',
@@ -168,7 +176,7 @@ const main = async (progname, rawArgs, powers) => {
168
176
  '',
169
177
  )
170
178
  .action(async (prog, configDir, _options, cmd) => {
171
- const opts = { ...program.opts(), ...cmd.opts() };
179
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
172
180
  return subMain(setDefaultsMain, ['set-defaults', prog, configDir], opts);
173
181
  });
174
182
 
@@ -187,17 +195,15 @@ const main = async (progname, rawArgs, powers) => {
187
195
  },
188
196
  );
189
197
 
190
- program
191
- .command('install [force-sdk-version]')
198
+ baseCmd('install [force-sdk-version]')
192
199
  .description('install Dapp dependencies')
193
200
  .action(async (forceSdkVersion, _options, cmd) => {
194
201
  await isNotBasedir();
195
- const opts = { ...program.opts(), ...cmd.opts() };
202
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
196
203
  return subMain(installMain, ['install', forceSdkVersion], opts);
197
204
  });
198
205
 
199
- program
200
- .command('follow <path-spec...>')
206
+ baseCmd('follow <path-spec...>')
201
207
  .description('follow an Agoric Casting leader')
202
208
  .option(
203
209
  '--proof <strict | optimistic | none>',
@@ -270,7 +276,7 @@ const main = async (progname, rawArgs, powers) => {
270
276
  )
271
277
  .option('-B, --bootstrap <config>', 'network bootstrap configuration')
272
278
  .action(async (pathSpecs, _options, cmd) => {
273
- const opts = { ...program.opts(), ...cmd.opts() };
279
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
274
280
  return subMain(followMain, ['follow', ...pathSpecs], opts);
275
281
  });
276
282
 
@@ -297,19 +303,18 @@ const main = async (progname, rawArgs, powers) => {
297
303
  '',
298
304
  );
299
305
 
300
- program
301
- .command('run <script> [script-args...]')
306
+ baseCmd('run <script> [script-args...]')
302
307
  .description(
303
308
  'run a script with all your user privileges and some Agoric endowments',
304
309
  )
310
+ .passThroughOptions(true)
305
311
  .action(async (script, scriptArgs, _options, cmd) => {
306
- const opts = { ...program.opts(), ...cmd.opts(), scriptArgs };
312
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts, scriptArgs };
307
313
  return subMain(runMain, ['run', script], opts);
308
314
  });
309
315
 
310
316
  addRunOptions(
311
- program
312
- .command('deploy [script...]')
317
+ baseCmd('deploy [script...]')
313
318
  .option(
314
319
  '--target <target>',
315
320
  'One of agoric, local, cosmos, or sim',
@@ -323,8 +328,7 @@ const main = async (progname, rawArgs, powers) => {
323
328
  return subMain(deployMain, ['deploy', ...scripts], opts);
324
329
  });
325
330
 
326
- program
327
- .command('publish [bundle...]')
331
+ baseCmd('publish [bundle...]')
328
332
  .option(
329
333
  '-c, --chain-id <chainID>',
330
334
  'The ID of the destination chain',
@@ -345,10 +349,9 @@ const main = async (progname, rawArgs, powers) => {
345
349
  return subMain(publishMain, ['publish', ...bundles], opts);
346
350
  });
347
351
 
348
- program.addCommand(await makeWalletCommand());
352
+ await makeWalletCommand(baseCmd);
349
353
 
350
- program
351
- .command('start [profile] [args...]')
354
+ baseCmd('start [profile] [args...]')
352
355
  .description(
353
356
  `\
354
357
  start an Agoric VM
@@ -360,6 +363,7 @@ agoric start local-solo [portNum] [provisionPowers] - local solo VM
360
363
  `,
361
364
  )
362
365
  .option('-d, --debug', 'run in JS debugger mode')
366
+ .option('--docker-tag <tag>', 'image tag to use for Docker containers')
363
367
  .option('--reset', 'clear all VM state before starting')
364
368
  .option('--no-restart', 'do not actually start the VM')
365
369
  .option('--pull', 'for Docker-based VM, pull the image before running')
@@ -383,19 +387,13 @@ agoric start local-solo [portNum] [provisionPowers] - local solo VM
383
387
  )
384
388
  .action(async (profile, args, _options, cmd) => {
385
389
  await isNotBasedir();
386
- const opts = { ...program.opts(), ...cmd.opts() };
390
+ const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts };
387
391
  return subMain(startMain, ['start', profile, ...args], opts);
388
392
  });
389
393
 
390
394
  // Throw an error instead of exiting directly.
391
395
  program.exitOverride();
392
396
 
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
397
  try {
400
398
  await program.parseAsync(rawArgs, { from: 'user' });
401
399
  } catch (e) {
package/src/publish.js CHANGED
@@ -9,14 +9,12 @@ import {
9
9
  makeLeaderFromRpcAddresses,
10
10
  makeCastingSpec,
11
11
  } from '@agoric/casting';
12
- import { DirectSecp256k1HdWallet, Registry } from '@cosmjs/proto-signing';
13
- import { defaultRegistryTypes } from '@cosmjs/stargate';
12
+ import { getSigningAgoricClientOptions } from '@agoric/cosmic-proto';
13
+ import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
14
14
  import { stringToPath } from '@cosmjs/crypto';
15
15
  import { Decimal } from '@cosmjs/math';
16
16
  import { fromBech32 } from '@cosmjs/encoding';
17
17
 
18
- import { MsgInstallBundle } from '@agoric/cosmic-proto/swingset/msgs.js';
19
-
20
18
  // https://github.com/Agoric/agoric-sdk/blob/master/golang/cosmos/daemon/main.go
21
19
  const Agoric = {
22
20
  Bech32MainPrefix: 'agoric',
@@ -38,11 +36,6 @@ const Agoric = {
38
36
  const hdPath = (coinType = 118, account = 0) =>
39
37
  stringToPath(`m/44'/${coinType}'/${account}'/0/0`);
40
38
 
41
- const registry = new Registry([
42
- ...defaultRegistryTypes,
43
- [Agoric.proto.swingset.InstallBundle.typeUrl, MsgInstallBundle],
44
- ]);
45
-
46
39
  /**
47
40
  * @typedef {object} JsonHttpRequest
48
41
  * @property {string} hostname
@@ -290,8 +283,8 @@ export const makeCosmosBundlePublisher = ({
290
283
 
291
284
  // AWAIT
292
285
  const stargateClient = await connectWithSigner(endpoint, wallet, {
286
+ ...getSigningAgoricClientOptions(),
293
287
  gasPrice: Agoric.gasPrice,
294
- registry,
295
288
  });
296
289
 
297
290
  // AWAIT
@@ -42,6 +42,7 @@ export default [
42
42
  "@agoric/vat-data",
43
43
  "@agoric/vats",
44
44
  "@agoric/vm-config",
45
+ "@agoric/vow",
45
46
  "@agoric/wallet",
46
47
  "@agoric/wallet-backend",
47
48
  "@agoric/xsnap",