agoric 0.21.2-upgrade-18-dev-6ddbef0.0 → 0.21.2-upgrade-19-dev-ae3bcff.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.
@@ -1,19 +1,23 @@
1
1
  // @ts-check
2
2
  /* eslint-disable func-names */
3
3
  /* eslint-env node */
4
+ import {
5
+ fetchEnvNetworkConfig,
6
+ makeAgoricNames,
7
+ makeVstorageKit,
8
+ makeWalletUtils,
9
+ storageHelper,
10
+ } from '@agoric/client-utils';
4
11
  import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
5
12
  import { oracleBrandFeedName } from '@agoric/inter-protocol/src/proposals/utils.js';
6
13
  import { Fail } from '@endo/errors';
7
14
  import { Nat } from '@endo/nat';
8
- import * as cp from 'child_process';
9
15
  import { Command } from 'commander';
10
16
  import { inspect } from 'util';
11
17
  import { normalizeAddressWithOptions } from '../lib/chain.js';
12
18
  import { bigintReplacer } from '../lib/format.js';
13
- import { getNetworkConfig, makeRpcUtils, storageHelper } from '../lib/rpc.js';
14
19
  import {
15
20
  getCurrent,
16
- makeWalletUtils,
17
21
  outputAction,
18
22
  sendAction,
19
23
  sendHint,
@@ -23,26 +27,33 @@ import {
23
27
 
24
28
  // XXX support other decimal places
25
29
  const COSMOS_UNIT = 1_000_000n;
26
- const scaleDecimals = num => BigInt(num * Number(COSMOS_UNIT));
30
+ /** @param {number} num */
31
+ const scaleDecimals = num => BigInt(Math.round(num * Number(COSMOS_UNIT)));
27
32
 
28
33
  /**
29
34
  * Prints JSON output to stdout and diagnostic info (like logs) to stderr
30
35
  *
31
- * @param {import('anylogger').Logger} logger
32
36
  * @param {{
33
- * delay?: (ms: number) => Promise<void>,
34
- * execFileSync?: typeof import('child_process').execFileSync,
35
- * env?: Record<string, string | undefined>,
36
- * stdout?: Pick<import('stream').Writable,'write'>,
37
- * }} [io]
37
+ * createCommand: typeof import('commander').createCommand,
38
+ * env: Partial<Record<string, string>>,
39
+ * execFileSync: typeof import('child_process').execFileSync,
40
+ * now: () => number,
41
+ * setTimeout: typeof setTimeout,
42
+ * stderr: Pick<import('stream').Writable,'write'>,
43
+ * stdout: Pick<import('stream').Writable,'write'>,
44
+ * }} process
45
+ * @param {import('anylogger').Logger} [logger]
38
46
  */
39
- export const makeOracleCommand = (logger, io = {}) => {
40
- const {
41
- delay = ms => new Promise(resolve => setTimeout(resolve, ms)),
42
- execFileSync = cp.execFileSync,
43
- env = process.env,
44
- stdout = process.stdout,
45
- } = io;
47
+ export const makeOracleCommand = (
48
+ { env, execFileSync, setTimeout, stderr, stdout },
49
+ logger,
50
+ ) => {
51
+ /**
52
+ * @param {number} ms
53
+ * @returns {Promise<void>}
54
+ */
55
+ const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
56
+
46
57
  const oracle = new Command('oracle')
47
58
  .description('Oracle commands')
48
59
  .usage(
@@ -82,20 +93,24 @@ export const makeOracleCommand = (logger, io = {}) => {
82
93
 
83
94
  const rpcTools = async () => {
84
95
  // XXX pass fetch to getNetworkConfig() explicitly
85
- const networkConfig = await getNetworkConfig(env);
86
- const utils = await makeRpcUtils({ fetch });
96
+ const networkConfig = await fetchEnvNetworkConfig({
97
+ env: process.env,
98
+ fetch,
99
+ });
100
+ const vsk = makeVstorageKit({ fetch }, networkConfig);
101
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
87
102
 
88
103
  const lookupPriceAggregatorInstance = ([brandIn, brandOut]) => {
89
104
  const name = oracleBrandFeedName(brandIn, brandOut);
90
- const instance = utils.agoricNames.instance[name];
105
+ const instance = agoricNames.instance[name];
91
106
  if (!instance) {
92
- logger.debug('known instances:', utils.agoricNames.instance);
107
+ logger && logger.debug('known instances:', agoricNames.instance);
93
108
  throw Error(`Unknown instance ${name}`);
94
109
  }
95
110
  return instance;
96
111
  };
97
112
 
98
- return { ...utils, networkConfig, lookupPriceAggregatorInstance };
113
+ return { ...vsk, networkConfig, lookupPriceAggregatorInstance };
99
114
  };
100
115
 
101
116
  oracle
@@ -128,12 +143,15 @@ export const makeOracleCommand = (logger, io = {}) => {
128
143
  proposal: {},
129
144
  };
130
145
 
131
- outputAction({
132
- method: 'executeOffer',
133
- offer,
134
- });
146
+ outputAction(
147
+ {
148
+ method: 'executeOffer',
149
+ offer,
150
+ },
151
+ stdout,
152
+ );
135
153
 
136
- console.warn(sendHint);
154
+ stderr.write(sendHint);
137
155
  });
138
156
 
139
157
  oracle
@@ -163,16 +181,19 @@ export const makeOracleCommand = (logger, io = {}) => {
163
181
  opts.oracleAdminAcceptOfferId,
164
182
  );
165
183
 
166
- outputAction({
167
- method: 'executeOffer',
168
- offer,
169
- });
184
+ outputAction(
185
+ {
186
+ method: 'executeOffer',
187
+ offer,
188
+ },
189
+ stdout,
190
+ );
170
191
 
171
- console.warn(sendHint);
192
+ stderr.write(sendHint);
172
193
  });
173
194
 
174
- const findOracleCap = async (instance, from, readLatestHead) => {
175
- const current = await getCurrent(from, { readLatestHead });
195
+ const findOracleCap = async (instance, from, readPublished) => {
196
+ const current = await getCurrent(from, { readPublished });
176
197
 
177
198
  const { offerToUsedInvitation: entries } = /** @type {any} */ (current);
178
199
  Array.isArray(entries) || Fail`entries must be an array: ${entries}`;
@@ -200,11 +221,10 @@ export const makeOracleCommand = (logger, io = {}) => {
200
221
  s => s.split('.'),
201
222
  )
202
223
  .action(async opts => {
203
- const { readLatestHead, lookupPriceAggregatorInstance } =
204
- await rpcTools();
224
+ const { readPublished, lookupPriceAggregatorInstance } = await rpcTools();
205
225
  const instance = lookupPriceAggregatorInstance(opts.pair);
206
226
 
207
- const offerId = await findOracleCap(instance, opts.from, readLatestHead);
227
+ const offerId = await findOracleCap(instance, opts.from, readPublished);
208
228
  if (!offerId) {
209
229
  console.error('No continuing ids found');
210
230
  }
@@ -265,12 +285,13 @@ export const makeOracleCommand = (logger, io = {}) => {
265
285
  * }}
266
286
  */ { pair, keys, price },
267
287
  ) => {
268
- const { readLatestHead, networkConfig, lookupPriceAggregatorInstance } =
269
- await rpcTools();
270
- const wutil = await makeWalletUtils(
271
- { fetch, execFileSync, delay },
288
+ const {
289
+ readLatestHead,
290
+ readPublished,
272
291
  networkConfig,
273
- );
292
+ lookupPriceAggregatorInstance,
293
+ } = await rpcTools();
294
+ const wutil = await makeWalletUtils({ fetch, delay }, networkConfig);
274
295
  const unitPrice = scaleDecimals(price);
275
296
 
276
297
  const feedPath = `published.priceFeed.${pair[0]}-${pair[1]}_price_feed`;
@@ -279,7 +300,7 @@ export const makeOracleCommand = (logger, io = {}) => {
279
300
  /** @type {Promise<PriceDescription>} */ (
280
301
  readLatestHead(feedPath).catch(() => {
281
302
  const viewer = `https://vstorage.agoric.net/#${networkConfig.rpcAddrs[0]}|published,published.priceFeed|${feedPath}`;
282
- console.warn(`no existing price data; see ${viewer}`);
303
+ stderr.write(`no existing price data; see ${viewer}`);
283
304
  return undefined;
284
305
  })
285
306
  );
@@ -324,7 +345,7 @@ export const makeOracleCommand = (logger, io = {}) => {
324
345
  }
325
346
  }),
326
347
  ]).catch(err => {
327
- console.warn(err);
348
+ stderr.write(err);
328
349
  });
329
350
  }
330
351
 
@@ -334,7 +355,7 @@ export const makeOracleCommand = (logger, io = {}) => {
334
355
  adminOfferIds[from] = await findOracleCap(
335
356
  instance,
336
357
  from,
337
- readLatestHead,
358
+ readPublished,
338
359
  );
339
360
  if (!adminOfferIds[from]) {
340
361
  console.error(
@@ -7,21 +7,23 @@ import {
7
7
  makeFollower,
8
8
  makeLeaderFromRpcAddresses,
9
9
  } from '@agoric/casting';
10
+ import { fetchEnvNetworkConfig } from '@agoric/client-utils';
11
+ import { slotToRemotable } from '@agoric/internal/src/storage-test-utils.js';
12
+ import { boardSlottingMarshaller } from '@agoric/vats/tools/board-utils.js';
10
13
  import { Command } from 'commander';
11
14
  import fs from 'fs';
12
15
  import { exit } from 'process';
13
- import { slotToRemotable } from '@agoric/internal/src/storage-test-utils.js';
14
- import { boardSlottingMarshaller } from '@agoric/vats/tools/board-utils.js';
15
16
  import { makeLeaderOptions } from '../lib/casting.js';
16
17
  import {
17
18
  execSwingsetTransaction,
18
19
  normalizeAddressWithOptions,
19
20
  } from '../lib/chain.js';
20
- import { networkConfig } from '../lib/rpc.js';
21
21
 
22
22
  // tight for perf testing but less than this tends to hang.
23
23
  const SLEEP_SECONDS = 0.1;
24
24
 
25
+ const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
26
+
25
27
  /**
26
28
  * @param {import('anylogger').Logger} logger
27
29
  */
@@ -1,12 +1,19 @@
1
1
  // @ts-check
2
2
  /* eslint-disable func-names */
3
3
  /* eslint-env node */
4
- import { Command } from 'commander';
4
+ import {
5
+ fetchEnvNetworkConfig,
6
+ makeAgoricNames,
7
+ makeVstorageKit,
8
+ storageHelper,
9
+ } from '@agoric/client-utils';
5
10
  import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
11
+ import { Command } from 'commander';
6
12
  import { asPercent } from '../lib/format.js';
7
- import { makeRpcUtils, storageHelper } from '../lib/rpc.js';
8
13
  import { outputExecuteOfferAction } from '../lib/wallet.js';
9
14
 
15
+ const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
16
+
10
17
  // Adapted from https://gist.github.com/dckc/8b5b2f16395cb4d7f2ff340e0bc6b610#file-psm-tool
11
18
 
12
19
  /**
@@ -60,13 +67,14 @@ export const makePsmCommand = logger => {
60
67
  );
61
68
 
62
69
  const rpcTools = async () => {
63
- const utils = await makeRpcUtils({ fetch });
70
+ const vsk = await makeVstorageKit({ fetch }, networkConfig);
71
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
64
72
 
65
73
  const lookupPsmInstance = ([minted, anchor]) => {
66
74
  const name = `psm-${minted}-${anchor}`;
67
- const instance = utils.agoricNames.instance[name];
75
+ const instance = agoricNames.instance[name];
68
76
  if (!instance) {
69
- logger.debug('known instances:', utils.agoricNames.instance);
77
+ logger.debug('known instances:', agoricNames.instance);
70
78
  throw Error(`Unknown instance ${name}`);
71
79
  }
72
80
  return instance;
@@ -77,20 +85,19 @@ export const makePsmCommand = logger => {
77
85
  * @param {[Minted: string, Anchor: string]} pair
78
86
  */
79
87
  const getGovernanceState = async ([Minted, Anchor]) => {
80
- const govContent = await utils.vstorage.readLatest(
88
+ const govContent = await vsk.vstorage.readLatest(
81
89
  `published.psm.${Minted}.${Anchor}.governance`,
82
90
  );
83
91
  assert(govContent, 'no gov content');
84
92
  const { current: governance } = last(
85
- storageHelper.unserializeTxt(govContent, utils.fromBoard),
93
+ storageHelper.unserializeTxt(govContent, vsk.fromBoard),
86
94
  );
87
- const { [`psm.${Minted}.${Anchor}`]: instance } =
88
- utils.agoricNames.instance;
95
+ const { [`psm.${Minted}.${Anchor}`]: instance } = agoricNames.instance;
89
96
 
90
97
  return { instance, governance };
91
98
  };
92
99
 
93
- return { ...utils, lookupPsmInstance, getGovernanceState };
100
+ return { ...vsk, agoricNames, lookupPsmInstance, getGovernanceState };
94
101
  };
95
102
 
96
103
  psm
@@ -1,11 +1,17 @@
1
1
  // @ts-check
2
2
  /* eslint-disable func-names */
3
3
  /* eslint-env node */
4
+ import {
5
+ fetchEnvNetworkConfig,
6
+ makeAgoricNames,
7
+ makeVstorageKit,
8
+ } from '@agoric/client-utils';
4
9
  import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
5
10
  import { Command } from 'commander';
6
- import { makeRpcUtils } from '../lib/rpc.js';
7
11
  import { outputActionAndHint } from '../lib/wallet.js';
8
12
 
13
+ const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
14
+
9
15
  /**
10
16
  * @param {import('anylogger').Logger} _logger
11
17
  * @param {*} io
@@ -29,7 +35,8 @@ export const makeReserveCommand = (_logger, io = {}) => {
29
35
  * }} opts
30
36
  */
31
37
  async ({ collateralBrand, ...opts }) => {
32
- const { agoricNames } = await makeRpcUtils({ fetch });
38
+ const vsk = makeVstorageKit({ fetch }, networkConfig);
39
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
33
40
 
34
41
  const offer = Offers.reserve.AddCollateral(agoricNames, {
35
42
  collateralBrandKey: collateralBrand,
@@ -63,7 +70,8 @@ export const makeReserveCommand = (_logger, io = {}) => {
63
70
  1,
64
71
  )
65
72
  .action(async function (opts) {
66
- const { agoricNames } = await makeRpcUtils({ fetch });
73
+ const vsk = makeVstorageKit({ fetch }, networkConfig);
74
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
67
75
 
68
76
  const reserveInstance = agoricNames.instance.reserve;
69
77
  assert(reserveInstance, 'missing reserve in names');
@@ -1,11 +1,11 @@
1
1
  // @ts-check
2
2
  /* eslint-env node */
3
+ import { fetchEnvNetworkConfig, makeWalletUtils } from '@agoric/client-utils';
3
4
  import { Fail } from '@endo/errors';
4
5
  import { CommanderError } from 'commander';
5
6
  import { normalizeAddressWithOptions } from '../lib/chain.js';
6
7
  import { bigintReplacer } from '../lib/format.js';
7
- import { getNetworkConfig } from '../lib/rpc.js';
8
- import { makeWalletUtils, sendAction } from '../lib/wallet.js';
8
+ import { sendAction } from '../lib/wallet.js';
9
9
 
10
10
  /**
11
11
  * Make commands for testing.
@@ -38,8 +38,8 @@ export const makeTestCommand = (
38
38
  try {
39
39
  // XXX pass fetch to getNetworkConfig() explicitly
40
40
  // await null above makes this await safe
41
- const networkConfig = await getNetworkConfig(env);
42
- return makeWalletUtils({ fetch, execFileSync, delay }, networkConfig);
41
+ const networkConfig = await fetchEnvNetworkConfig({ env, fetch });
42
+ return makeWalletUtils({ fetch, delay }, networkConfig);
43
43
  } catch (err) {
44
44
  // CommanderError is a class constructor, and so
45
45
  // must be invoked with `new`.
@@ -1,15 +1,21 @@
1
1
  // @ts-check
2
2
  /* eslint-disable func-names */
3
3
  /* eslint-env node */
4
- import { Command } from 'commander';
4
+ import {
5
+ fetchEnvNetworkConfig,
6
+ makeAgoricNames,
7
+ makeVstorageKit,
8
+ } from '@agoric/client-utils';
5
9
  import {
6
10
  lookupOfferIdForVault,
7
11
  Offers,
8
12
  } from '@agoric/inter-protocol/src/clientSupport.js';
13
+ import { Command } from 'commander';
9
14
  import { normalizeAddressWithOptions } from '../lib/chain.js';
10
- import { makeRpcUtils } from '../lib/rpc.js';
11
15
  import { getCurrent, outputExecuteOfferAction } from '../lib/wallet.js';
12
16
 
17
+ const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
18
+
13
19
  /**
14
20
  * @param {import('anylogger').Logger} logger
15
21
  */
@@ -36,10 +42,10 @@ export const makeVaultsCommand = logger => {
36
42
  normalizeAddress,
37
43
  )
38
44
  .action(async function (opts) {
39
- const { readLatestHead } = await makeRpcUtils({ fetch });
45
+ const { readPublished } = await makeVstorageKit({ fetch }, networkConfig);
40
46
 
41
47
  const current = await getCurrent(opts.from, {
42
- readLatestHead,
48
+ readPublished,
43
49
  });
44
50
 
45
51
  const vaultStoragePaths = current.offerToPublicSubscriberPaths.map(
@@ -61,7 +67,8 @@ export const makeVaultsCommand = logger => {
61
67
  .option('--collateralBrand <string>', 'Collateral brand key', 'ATOM')
62
68
  .action(async function (opts) {
63
69
  logger.warn('running with options', opts);
64
- const { agoricNames } = await makeRpcUtils({ fetch });
70
+ const vsk = makeVstorageKit({ fetch }, networkConfig);
71
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
65
72
 
66
73
  const offer = Offers.vaults.OpenVault(agoricNames, {
67
74
  giveCollateral: opts.giveCollateral,
@@ -96,11 +103,15 @@ export const makeVaultsCommand = logger => {
96
103
  .requiredOption('--vaultId <string>', 'Key of vault (e.g. vault1)')
97
104
  .action(async function (opts) {
98
105
  logger.warn('running with options', opts);
99
- const { agoricNames, readLatestHead } = await makeRpcUtils({ fetch });
106
+ const { readPublished, ...vsk } = makeVstorageKit(
107
+ { fetch },
108
+ networkConfig,
109
+ );
110
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
100
111
 
101
112
  const previousOfferId = await lookupOfferIdForVault(
102
113
  opts.vaultId,
103
- getCurrent(opts.from, { readLatestHead }),
114
+ getCurrent(opts.from, { readPublished }),
104
115
  );
105
116
 
106
117
  const offer = Offers.vaults.AdjustBalances(
@@ -137,11 +148,15 @@ export const makeVaultsCommand = logger => {
137
148
  )
138
149
  .action(async function (opts) {
139
150
  logger.warn('running with options', opts);
140
- const { agoricNames, readLatestHead } = await makeRpcUtils({ fetch });
151
+ const { readPublished, ...vsk } = makeVstorageKit(
152
+ { fetch },
153
+ networkConfig,
154
+ );
155
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
141
156
 
142
157
  const previousOfferId = await lookupOfferIdForVault(
143
158
  opts.vaultId,
144
- getCurrent(opts.from, { readLatestHead }),
159
+ getCurrent(opts.from, { readPublished }),
145
160
  );
146
161
 
147
162
  const offer = Offers.vaults.CloseVault(
@@ -8,11 +8,14 @@ import {
8
8
  makeLeader,
9
9
  makeLeaderFromRpcAddresses,
10
10
  } from '@agoric/casting';
11
+ import {
12
+ makeVstorageKit,
13
+ fetchEnvNetworkConfig,
14
+ makeAgoricNames,
15
+ } from '@agoric/client-utils';
16
+ import { execFileSync } from 'child_process';
11
17
  import fs from 'fs';
12
18
  import util from 'util';
13
- import { execFileSync } from 'child_process';
14
- import { fmtRecordOfLines, summarize } from '../lib/format.js';
15
- import { makeRpcUtils, networkConfig } from '../lib/rpc.js';
16
19
 
17
20
  import { makeLeaderOptions } from '../lib/casting.js';
18
21
  import {
@@ -20,8 +23,15 @@ import {
20
23
  fetchSwingsetParams,
21
24
  normalizeAddressWithOptions,
22
25
  } from '../lib/chain.js';
26
+ import {
27
+ fmtRecordOfLines,
28
+ parseFiniteNumber,
29
+ summarize,
30
+ } from '../lib/format.js';
23
31
  import { coalesceWalletState, getCurrent } from '../lib/wallet.js';
24
32
 
33
+ const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
34
+
25
35
  const SLEEP_SECONDS = 3;
26
36
 
27
37
  /**
@@ -45,6 +55,7 @@ export const makeWalletCommand = async command => {
45
55
  'wallet commands',
46
56
  );
47
57
 
58
+ /** @param {string} literalOrName */
48
59
  const normalizeAddress = literalOrName =>
49
60
  normalizeAddressWithOptions(literalOrName, wallet.opts());
50
61
 
@@ -102,9 +113,9 @@ export const makeWalletCommand = async command => {
102
113
  .action(async function (opts) {
103
114
  const offerStr = fs.readFileSync(opts.file).toString();
104
115
 
105
- const { unserializer } = await makeRpcUtils({ fetch });
116
+ const { marshaller } = makeVstorageKit({ fetch }, networkConfig);
106
117
 
107
- const offerObj = unserializer.fromCapData(JSON.parse(offerStr));
118
+ const offerObj = marshaller.fromCapData(JSON.parse(offerStr));
108
119
  console.log(offerObj);
109
120
  });
110
121
 
@@ -117,9 +128,9 @@ export const makeWalletCommand = async command => {
117
128
  .action(async function (opts) {
118
129
  const offerStr = fs.readFileSync(opts.offer).toString();
119
130
 
120
- const { unserializer } = await makeRpcUtils({ fetch });
131
+ const { marshaller } = makeVstorageKit({ fetch }, networkConfig);
121
132
 
122
- const offerObj = unserializer.fromCapData(JSON.parse(offerStr));
133
+ const offerObj = marshaller.fromCapData(JSON.parse(offerStr));
123
134
  console.log(offerObj.offer.id);
124
135
  });
125
136
 
@@ -132,30 +143,69 @@ export const makeWalletCommand = async command => {
132
143
  )
133
144
  .requiredOption('--offer [filename]', 'path to file with prepared offer')
134
145
  .option('--dry-run', 'spit out the command instead of running it')
146
+ .option('--gas', 'gas limit; "auto" [default] to calculate automatically')
147
+ .option(
148
+ '--gas-adjustment',
149
+ 'factor by which to multiply the --gas=auto calculation result [default 1.2]',
150
+ )
151
+ .option('--verbose', 'print command output')
135
152
  .action(function (opts) {
136
- /** @typedef {{ from: string, offer: string, dryRun: boolean }} Opts */
153
+ /**
154
+ * @typedef {{
155
+ * from: string,
156
+ * offer: string,
157
+ * dryRun: boolean,
158
+ * gas: string,
159
+ * gasAdjustment: string,
160
+ * verbose: boolean,
161
+ * }} Opts
162
+ */
137
163
  const {
138
164
  dryRun,
139
165
  from,
166
+ gas = 'auto',
167
+ gasAdjustment = '1.2',
140
168
  offer,
141
169
  home,
170
+ verbose,
142
171
  keyringBackend: backend,
143
172
  } = /** @type {SharedTxOptions & Opts} */ ({ ...wallet.opts(), ...opts });
144
173
 
145
174
  const offerBody = fs.readFileSync(offer).toString();
146
- execSwingsetTransaction(['wallet-action', '--allow-spend', offerBody], {
147
- from,
148
- dryRun,
149
- keyring: { home, backend },
150
- ...networkConfig,
151
- });
175
+ const out = execSwingsetTransaction(
176
+ ['wallet-action', '--allow-spend', offerBody, '-ojson', '-bblock'],
177
+ {
178
+ ...networkConfig,
179
+ keyring: { home, backend },
180
+ from,
181
+ gas:
182
+ gas === 'auto'
183
+ ? ['auto', parseFiniteNumber(gasAdjustment)]
184
+ : parseFiniteNumber(gas),
185
+ dryRun,
186
+ verbose,
187
+ },
188
+ );
189
+
190
+ // see sendAction in {@link ../lib/wallet.js}
191
+ if (dryRun || !verbose) return;
192
+ try {
193
+ const tx = JSON.parse(/** @type {string} */ (out));
194
+ if (tx.code !== 0) {
195
+ console.error('failed to send tx', tx);
196
+ }
197
+ console.log(tx);
198
+ } catch (err) {
199
+ console.error('unexpected output', JSON.stringify(out));
200
+ throw err;
201
+ }
152
202
  });
153
203
 
154
204
  wallet
155
205
  .command('list')
156
206
  .description('list all wallets in vstorage')
157
207
  .action(async function () {
158
- const { vstorage } = await makeRpcUtils({ fetch });
208
+ const { vstorage } = makeVstorageKit({ fetch }, networkConfig);
159
209
  const wallets = await vstorage.keys('published.wallet');
160
210
  process.stdout.write(wallets.join('\n'));
161
211
  });
@@ -169,23 +219,26 @@ export const makeWalletCommand = async command => {
169
219
  normalizeAddress,
170
220
  )
171
221
  .action(async function (opts) {
172
- const { agoricNames, unserializer, readLatestHead } = await makeRpcUtils({
173
- fetch,
174
- });
222
+ const {
223
+ readPublished,
224
+ marshaller: unserializer,
225
+ ...vsk
226
+ } = makeVstorageKit({ fetch }, networkConfig);
227
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
175
228
 
176
229
  const leader = makeLeader(networkConfig.rpcAddrs[0]);
177
230
  const follower = await makeFollower(
178
231
  `:published.wallet.${opts.from}`,
179
232
  leader,
180
233
  {
181
- // @ts-expect-error xxx
234
+ // @ts-expect-error xxx follower/marshaller types
182
235
  unserializer,
183
236
  },
184
237
  );
185
238
 
186
239
  const coalesced = await coalesceWalletState(follower);
187
240
 
188
- const current = await getCurrent(opts.from, { readLatestHead });
241
+ const current = await getCurrent(opts.from, { readPublished });
189
242
 
190
243
  console.warn(
191
244
  'got coalesced',
package/src/cosmos.js CHANGED
@@ -50,7 +50,7 @@ export default async function cosmosMain(progname, rawArgs, powers, opts) {
50
50
  },
51
51
  );
52
52
  // Ensure the build doesn't mess up stdout.
53
- ps.childProcess.stdout.pipe(process.stderr);
53
+ ps.childProcess.stdout?.pipe(process.stderr);
54
54
  return ps;
55
55
  }
56
56
  throw e;
package/src/helpers.js CHANGED
@@ -3,6 +3,9 @@
3
3
 
4
4
  /** @import { ChildProcess } from 'child_process' */
5
5
 
6
+ // Backwards compatibility
7
+ export { fetchEnvNetworkConfig as getNetworkConfig } from '@agoric/client-utils';
8
+
6
9
  export const getSDKBinaries = ({
7
10
  jsPfx = '../..',
8
11
  goPfx = `${jsPfx}/../golang`,
@@ -40,12 +43,12 @@ export const makePspawn = ({
40
43
  *
41
44
  * @param {string} cmd command name to run
42
45
  * @param {Array<string>} cargs arguments to the command
43
- * @param {object} param2
44
- * @param {string} [param2.cwd]
45
- * @param {string | [string, string, string]} [param2.stdio] standard IO
46
+ * @param {object} [opts]
47
+ * @param {string} [opts.cwd]
48
+ * @param {string | [string, string, string]} [opts.stdio] standard IO
46
49
  * specification
47
- * @param {Record<string, string | undefined>} [param2.env] environment
48
- * @param {boolean} [param2.detached] whether the child process should be detached
50
+ * @param {Record<string, string | undefined>} [opts.env] environment
51
+ * @param {boolean} [opts.detached] whether the child process should be detached
49
52
  * @returns {Promise<number> & { childProcess: ChildProcess }}} promise for
50
53
  * exit status. The return result has a `childProcess` property to obtain
51
54
  * control over the running process