agoric 0.21.2-other-dev-3eb1a1d.0 → 0.21.2-other-dev-d15096d.0.d15096d

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.
@@ -2,6 +2,8 @@
2
2
  /* eslint-disable func-names */
3
3
  /* eslint-env node */
4
4
  import {
5
+ fetchEnvNetworkConfig,
6
+ makeAgoricNames,
5
7
  makeVstorageKit,
6
8
  makeWalletUtils,
7
9
  storageHelper,
@@ -10,43 +12,56 @@ import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
10
12
  import { oracleBrandFeedName } from '@agoric/inter-protocol/src/proposals/utils.js';
11
13
  import { Fail } from '@endo/errors';
12
14
  import { Nat } from '@endo/nat';
13
- import * as cp from 'child_process';
14
15
  import { Command } from 'commander';
15
16
  import { inspect } from 'util';
16
17
  import { normalizeAddressWithOptions } from '../lib/chain.js';
17
- import { getNetworkConfig } from '../lib/network-config.js';
18
+ import { bigintReplacer } from '../lib/format.js';
18
19
  import {
19
20
  getCurrent,
20
21
  outputAction,
21
22
  sendAction,
22
23
  sendHint,
23
24
  } from '../lib/wallet.js';
24
- import { bigintReplacer } from '../lib/format.js';
25
25
 
26
- /** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */
26
+ /**
27
+ * @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
28
+ * @import {createCommand} from 'commander';
29
+ * @import {execFileSync} from 'child_process';
30
+ * @import {Writable} from 'stream';
31
+ * @import {Logger} from 'anylogger';
32
+ * @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
33
+ * @import {TimestampRecord} from '@agoric/time';
34
+ */
27
35
 
28
36
  // XXX support other decimal places
29
37
  const COSMOS_UNIT = 1_000_000n;
30
- const scaleDecimals = num => BigInt(num * Number(COSMOS_UNIT));
38
+ /** @param {number} num */
39
+ const scaleDecimals = num => BigInt(Math.round(num * Number(COSMOS_UNIT)));
31
40
 
32
41
  /**
33
42
  * Prints JSON output to stdout and diagnostic info (like logs) to stderr
34
43
  *
35
- * @param {import('anylogger').Logger} logger
36
44
  * @param {{
37
- * delay?: (ms: number) => Promise<void>,
38
- * execFileSync?: typeof import('child_process').execFileSync,
39
- * env?: Record<string, string | undefined>,
40
- * stdout?: Pick<import('stream').Writable,'write'>,
41
- * }} [io]
45
+ * createCommand: typeof createCommand,
46
+ * env: Partial<Record<string, string>>,
47
+ * execFileSync: typeof execFileSync,
48
+ * now: () => number,
49
+ * setTimeout: typeof setTimeout,
50
+ * stderr: Pick<Writable,'write'>,
51
+ * stdout: Pick<Writable,'write'>,
52
+ * }} process
53
+ * @param {Logger} [logger]
42
54
  */
43
- export const makeOracleCommand = (logger, io = {}) => {
44
- const {
45
- delay = ms => new Promise(resolve => setTimeout(resolve, ms)),
46
- execFileSync = cp.execFileSync,
47
- env = process.env,
48
- stdout = process.stdout,
49
- } = io;
55
+ export const makeOracleCommand = (
56
+ { env, execFileSync, setTimeout, stderr, stdout },
57
+ logger,
58
+ ) => {
59
+ /**
60
+ * @param {number} ms
61
+ * @returns {Promise<void>}
62
+ */
63
+ const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
64
+
50
65
  const oracle = new Command('oracle')
51
66
  .description('Oracle commands')
52
67
  .usage(
@@ -86,20 +101,24 @@ export const makeOracleCommand = (logger, io = {}) => {
86
101
 
87
102
  const rpcTools = async () => {
88
103
  // XXX pass fetch to getNetworkConfig() explicitly
89
- const networkConfig = await getNetworkConfig({ env: process.env, fetch });
90
- const utils = await makeVstorageKit({ fetch }, networkConfig);
104
+ const networkConfig = await fetchEnvNetworkConfig({
105
+ env: process.env,
106
+ fetch,
107
+ });
108
+ const vsk = makeVstorageKit({ fetch }, networkConfig);
109
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
91
110
 
92
111
  const lookupPriceAggregatorInstance = ([brandIn, brandOut]) => {
93
112
  const name = oracleBrandFeedName(brandIn, brandOut);
94
- const instance = utils.agoricNames.instance[name];
113
+ const instance = agoricNames.instance[name];
95
114
  if (!instance) {
96
- logger.debug('known instances:', utils.agoricNames.instance);
115
+ logger && logger.debug('known instances:', agoricNames.instance);
97
116
  throw Error(`Unknown instance ${name}`);
98
117
  }
99
118
  return instance;
100
119
  };
101
120
 
102
- return { ...utils, networkConfig, lookupPriceAggregatorInstance };
121
+ return { ...vsk, networkConfig, lookupPriceAggregatorInstance };
103
122
  };
104
123
 
105
124
  oracle
@@ -121,7 +140,7 @@ export const makeOracleCommand = (logger, io = {}) => {
121
140
  const { lookupPriceAggregatorInstance } = await rpcTools();
122
141
  const instance = lookupPriceAggregatorInstance(opts.pair);
123
142
 
124
- /** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */
143
+ /** @type {OfferSpec} */
125
144
  const offer = {
126
145
  id: opts.offerId,
127
146
  invitationSpec: {
@@ -132,12 +151,15 @@ export const makeOracleCommand = (logger, io = {}) => {
132
151
  proposal: {},
133
152
  };
134
153
 
135
- outputAction({
136
- method: 'executeOffer',
137
- offer,
138
- });
154
+ outputAction(
155
+ {
156
+ method: 'executeOffer',
157
+ offer,
158
+ },
159
+ stdout,
160
+ );
139
161
 
140
- console.warn(sendHint);
162
+ stderr.write(sendHint);
141
163
  });
142
164
 
143
165
  oracle
@@ -167,12 +189,15 @@ export const makeOracleCommand = (logger, io = {}) => {
167
189
  opts.oracleAdminAcceptOfferId,
168
190
  );
169
191
 
170
- outputAction({
171
- method: 'executeOffer',
172
- offer,
173
- });
192
+ outputAction(
193
+ {
194
+ method: 'executeOffer',
195
+ offer,
196
+ },
197
+ stdout,
198
+ );
174
199
 
175
- console.warn(sendHint);
200
+ stderr.write(sendHint);
176
201
  });
177
202
 
178
203
  const findOracleCap = async (instance, from, readPublished) => {
@@ -204,11 +229,10 @@ export const makeOracleCommand = (logger, io = {}) => {
204
229
  s => s.split('.'),
205
230
  )
206
231
  .action(async opts => {
207
- const { readLatestHead, lookupPriceAggregatorInstance } =
208
- await rpcTools();
232
+ const { readPublished, lookupPriceAggregatorInstance } = await rpcTools();
209
233
  const instance = lookupPriceAggregatorInstance(opts.pair);
210
234
 
211
- const offerId = await findOracleCap(instance, opts.from, readLatestHead);
235
+ const offerId = await findOracleCap(instance, opts.from, readPublished);
212
236
  if (!offerId) {
213
237
  console.error('No continuing ids found');
214
238
  }
@@ -269,8 +293,12 @@ export const makeOracleCommand = (logger, io = {}) => {
269
293
  * }}
270
294
  */ { pair, keys, price },
271
295
  ) => {
272
- const { readLatestHead, networkConfig, lookupPriceAggregatorInstance } =
273
- await rpcTools();
296
+ const {
297
+ readLatestHead,
298
+ readPublished,
299
+ networkConfig,
300
+ lookupPriceAggregatorInstance,
301
+ } = await rpcTools();
274
302
  const wutil = await makeWalletUtils({ fetch, delay }, networkConfig);
275
303
  const unitPrice = scaleDecimals(price);
276
304
 
@@ -280,7 +308,7 @@ export const makeOracleCommand = (logger, io = {}) => {
280
308
  /** @type {Promise<PriceDescription>} */ (
281
309
  readLatestHead(feedPath).catch(() => {
282
310
  const viewer = `https://vstorage.agoric.net/#${networkConfig.rpcAddrs[0]}|published,published.priceFeed|${feedPath}`;
283
- console.warn(`no existing price data; see ${viewer}`);
311
+ stderr.write(`no existing price data; see ${viewer}`);
284
312
  return undefined;
285
313
  })
286
314
  );
@@ -306,7 +334,7 @@ export const makeOracleCommand = (logger, io = {}) => {
306
334
  );
307
335
 
308
336
  const latestRoundP =
309
- /** @type {Promise<{roundId: number, startedAt: import('@agoric/time').TimestampRecord, startedBy: string}>} */ (
337
+ /** @type {Promise<{roundId: number, startedAt: TimestampRecord, startedBy: string}>} */ (
310
338
  readLatestHead(
311
339
  `published.priceFeed.${pair[0]}-${pair[1]}_price_feed.latestRound`,
312
340
  )
@@ -325,7 +353,7 @@ export const makeOracleCommand = (logger, io = {}) => {
325
353
  }
326
354
  }),
327
355
  ]).catch(err => {
328
- console.warn(err);
356
+ stderr.write(err);
329
357
  });
330
358
  }
331
359
 
@@ -335,7 +363,7 @@ export const makeOracleCommand = (logger, io = {}) => {
335
363
  adminOfferIds[from] = await findOracleCap(
336
364
  instance,
337
365
  from,
338
- readLatestHead,
366
+ readPublished,
339
367
  );
340
368
  if (!adminOfferIds[from]) {
341
369
  console.error(
@@ -7,6 +7,7 @@ import {
7
7
  makeFollower,
8
8
  makeLeaderFromRpcAddresses,
9
9
  } from '@agoric/casting';
10
+ import { fetchEnvNetworkConfig } from '@agoric/client-utils';
10
11
  import { slotToRemotable } from '@agoric/internal/src/storage-test-utils.js';
11
12
  import { boardSlottingMarshaller } from '@agoric/vats/tools/board-utils.js';
12
13
  import { Command } from 'commander';
@@ -17,15 +18,18 @@ import {
17
18
  execSwingsetTransaction,
18
19
  normalizeAddressWithOptions,
19
20
  } from '../lib/chain.js';
20
- import { getNetworkConfig } from '../lib/network-config.js';
21
+
22
+ /**
23
+ * @import {Logger} from 'anylogger';
24
+ */
21
25
 
22
26
  // tight for perf testing but less than this tends to hang.
23
27
  const SLEEP_SECONDS = 0.1;
24
28
 
25
- const networkConfig = await getNetworkConfig({ env: process.env, fetch });
29
+ const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
26
30
 
27
31
  /**
28
- * @param {import('anylogger').Logger} logger
32
+ * @param {Logger} logger
29
33
  */
30
34
  export const makePerfCommand = logger => {
31
35
  const perf = new Command('perf')
@@ -51,6 +55,7 @@ export const makePerfCommand = logger => {
51
55
  'address literal or name',
52
56
  normalizeAddress,
53
57
  )
58
+ .option('--verbose')
54
59
  .action(async function (opts) {
55
60
  const sharedOpts = perf.opts();
56
61
  logger.warn({ sharedOpts, opts });
@@ -63,15 +68,13 @@ export const makePerfCommand = logger => {
63
68
 
64
69
  const spec = `:published.wallet.${opts.from}`;
65
70
 
66
- const leaderOptions = makeLeaderOptions({
67
- sleep: SLEEP_SECONDS,
68
- jitter: 0,
69
- log: () => undefined,
70
- });
71
-
72
71
  const leader = makeLeaderFromRpcAddresses(
73
72
  networkConfig.rpcAddrs,
74
- leaderOptions,
73
+ makeLeaderOptions({
74
+ sleep: SLEEP_SECONDS,
75
+ jitter: 0,
76
+ log: console.warn,
77
+ }),
75
78
  );
76
79
 
77
80
  logger.warn('Following', spec);
@@ -86,9 +89,10 @@ export const makePerfCommand = logger => {
86
89
  if (status.error) {
87
90
  console.error(status.error);
88
91
  exit(1);
89
- } else if (status.numWantsSatisfied)
92
+ } else if (status.numWantsSatisfied) {
90
93
  process.stdout.write(`satisfied: ${status.numWantsSatisfied}\n`);
91
- exit(0);
94
+ exit(0);
95
+ }
92
96
  }
93
97
  }
94
98
  };
@@ -102,7 +106,11 @@ export const makePerfCommand = logger => {
102
106
  if (sharedOpts.home) {
103
107
  cmd.push(`--home=${sharedOpts.home}`);
104
108
  }
105
- execSwingsetTransaction(cmd, { from: opts.from, ...networkConfig });
109
+ execSwingsetTransaction(cmd, {
110
+ from: opts.from,
111
+ verbose: opts.verbose,
112
+ ...networkConfig,
113
+ });
106
114
  });
107
115
 
108
116
  return perf;
@@ -1,14 +1,23 @@
1
1
  // @ts-check
2
2
  /* eslint-disable func-names */
3
3
  /* eslint-env node */
4
- import { makeVstorageKit, storageHelper } from '@agoric/client-utils';
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';
6
11
  import { Command } from 'commander';
7
- import { getNetworkConfig } from '../lib/network-config.js';
8
- import { outputExecuteOfferAction } from '../lib/wallet.js';
9
12
  import { asPercent } from '../lib/format.js';
13
+ import { outputExecuteOfferAction } from '../lib/wallet.js';
14
+
15
+ /**
16
+ * @import {Logger} from 'anylogger';
17
+ * @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
18
+ */
10
19
 
11
- const networkConfig = await getNetworkConfig({ env: process.env, fetch });
20
+ const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
12
21
 
13
22
  // Adapted from https://gist.github.com/dckc/8b5b2f16395cb4d7f2ff340e0bc6b610#file-psm-tool
14
23
 
@@ -32,7 +41,7 @@ function collectValues(val, memo) {
32
41
  }
33
42
 
34
43
  /**
35
- * @param {import('anylogger').Logger} logger
44
+ * @param {Logger} logger
36
45
  */
37
46
  export const makePsmCommand = logger => {
38
47
  const psm = new Command('psm').description('PSM commands').usage(
@@ -63,13 +72,14 @@ export const makePsmCommand = logger => {
63
72
  );
64
73
 
65
74
  const rpcTools = async () => {
66
- const utils = await makeVstorageKit({ fetch }, networkConfig);
75
+ const vsk = await makeVstorageKit({ fetch }, networkConfig);
76
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
67
77
 
68
78
  const lookupPsmInstance = ([minted, anchor]) => {
69
79
  const name = `psm-${minted}-${anchor}`;
70
- const instance = utils.agoricNames.instance[name];
80
+ const instance = agoricNames.instance[name];
71
81
  if (!instance) {
72
- logger.debug('known instances:', utils.agoricNames.instance);
82
+ logger.debug('known instances:', agoricNames.instance);
73
83
  throw Error(`Unknown instance ${name}`);
74
84
  }
75
85
  return instance;
@@ -80,20 +90,19 @@ export const makePsmCommand = logger => {
80
90
  * @param {[Minted: string, Anchor: string]} pair
81
91
  */
82
92
  const getGovernanceState = async ([Minted, Anchor]) => {
83
- const govContent = await utils.vstorage.readLatest(
93
+ const govContent = await vsk.vstorage.readLatest(
84
94
  `published.psm.${Minted}.${Anchor}.governance`,
85
95
  );
86
96
  assert(govContent, 'no gov content');
87
97
  const { current: governance } = last(
88
- storageHelper.unserializeTxt(govContent, utils.fromBoard),
98
+ storageHelper.unserializeTxt(govContent, vsk.fromBoard),
89
99
  );
90
- const { [`psm.${Minted}.${Anchor}`]: instance } =
91
- utils.agoricNames.instance;
100
+ const { [`psm.${Minted}.${Anchor}`]: instance } = agoricNames.instance;
92
101
 
93
102
  return { instance, governance };
94
103
  };
95
104
 
96
- return { ...utils, lookupPsmInstance, getGovernanceState };
105
+ return { ...vsk, agoricNames, lookupPsmInstance, getGovernanceState };
97
106
  };
98
107
 
99
108
  psm
@@ -201,7 +210,7 @@ export const makePsmCommand = logger => {
201
210
  const { lookupPsmInstance } = await rpcTools();
202
211
  const psmInstance = lookupPsmInstance(opts.pair);
203
212
 
204
- /** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */
213
+ /** @type {OfferSpec} */
205
214
  const offer = {
206
215
  id: opts.offerId,
207
216
  invitationSpec: {
@@ -256,7 +265,7 @@ export const makePsmCommand = logger => {
256
265
  brand: istBrand,
257
266
  value: BigInt(opts.limit * 1_000_000),
258
267
  });
259
- /** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */
268
+ /** @type {OfferSpec} */
260
269
  const offer = {
261
270
  id: opts.offerId,
262
271
  invitationSpec: {
@@ -1,16 +1,24 @@
1
1
  // @ts-check
2
2
  /* eslint-disable func-names */
3
3
  /* eslint-env node */
4
- import { makeVstorageKit } from '@agoric/client-utils';
4
+ import {
5
+ fetchEnvNetworkConfig,
6
+ makeAgoricNames,
7
+ makeVstorageKit,
8
+ } from '@agoric/client-utils';
5
9
  import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
6
10
  import { Command } from 'commander';
7
- import { getNetworkConfig } from '../lib/network-config.js';
8
11
  import { outputActionAndHint } from '../lib/wallet.js';
9
12
 
10
- const networkConfig = await getNetworkConfig({ env: process.env, fetch });
13
+ /**
14
+ * @import {Logger} from 'anylogger';
15
+ * @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
16
+ */
17
+
18
+ const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
11
19
 
12
20
  /**
13
- * @param {import('anylogger').Logger} _logger
21
+ * @param {Logger} _logger
14
22
  * @param {*} io
15
23
  */
16
24
  export const makeReserveCommand = (_logger, io = {}) => {
@@ -32,7 +40,8 @@ export const makeReserveCommand = (_logger, io = {}) => {
32
40
  * }} opts
33
41
  */
34
42
  async ({ collateralBrand, ...opts }) => {
35
- const { agoricNames } = await makeVstorageKit({ fetch }, networkConfig);
43
+ const vsk = makeVstorageKit({ fetch }, networkConfig);
44
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
36
45
 
37
46
  const offer = Offers.reserve.AddCollateral(agoricNames, {
38
47
  collateralBrandKey: collateralBrand,
@@ -66,14 +75,15 @@ export const makeReserveCommand = (_logger, io = {}) => {
66
75
  1,
67
76
  )
68
77
  .action(async function (opts) {
69
- const { agoricNames } = await makeVstorageKit({ fetch }, networkConfig);
78
+ const vsk = makeVstorageKit({ fetch }, networkConfig);
79
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
70
80
 
71
81
  const reserveInstance = agoricNames.instance.reserve;
72
82
  assert(reserveInstance, 'missing reserve in names');
73
83
 
74
84
  const feesToBurn = { brand: agoricNames.brand.IST, value: opts.value };
75
85
 
76
- /** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */
86
+ /** @type {OfferSpec} */
77
87
  const offer = {
78
88
  id: opts.offerId,
79
89
  invitationSpec: {
@@ -1,24 +1,30 @@
1
1
  // @ts-check
2
2
  /* eslint-env node */
3
- import { makeWalletUtils } from '@agoric/client-utils';
3
+ import { fetchEnvNetworkConfig, makeWalletUtils } from '@agoric/client-utils';
4
4
  import { Fail } from '@endo/errors';
5
5
  import { CommanderError } from 'commander';
6
6
  import { normalizeAddressWithOptions } from '../lib/chain.js';
7
- import { getNetworkConfig } from '../lib/network-config.js';
8
- import { sendAction } from '../lib/wallet.js';
9
7
  import { bigintReplacer } from '../lib/format.js';
8
+ import { sendAction } from '../lib/wallet.js';
9
+
10
+ /**
11
+ * @import {Writable} from 'stream';
12
+ * @import {createCommand} from 'commander';
13
+ * @import {execFileSync} from 'child_process';
14
+ * @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
15
+ */
10
16
 
11
17
  /**
12
18
  * Make commands for testing.
13
19
  *
14
20
  * @param {{
15
21
  * env: Partial<Record<string, string>>,
16
- * stdout: Pick<import('stream').Writable,'write'>,
17
- * stderr: Pick<import('stream').Writable,'write'>,
22
+ * stdout: Pick<Writable,'write'>,
23
+ * stderr: Pick<Writable,'write'>,
18
24
  * now: () => number,
19
25
  * createCommand: // Note: includes access to process.stdout, .stderr, .exit
20
- * typeof import('commander').createCommand,
21
- * execFileSync: typeof import('child_process').execFileSync,
26
+ * typeof createCommand,
27
+ * execFileSync: typeof execFileSync,
22
28
  * setTimeout: typeof setTimeout,
23
29
  * }} process
24
30
  * @param {{ fetch: typeof window.fetch }} net
@@ -39,7 +45,7 @@ export const makeTestCommand = (
39
45
  try {
40
46
  // XXX pass fetch to getNetworkConfig() explicitly
41
47
  // await null above makes this await safe
42
- const networkConfig = await getNetworkConfig({ env, fetch });
48
+ const networkConfig = await fetchEnvNetworkConfig({ env, fetch });
43
49
  return makeWalletUtils({ fetch, delay }, networkConfig);
44
50
  } catch (err) {
45
51
  // CommanderError is a class constructor, and so
@@ -76,7 +82,7 @@ export const makeTestCommand = (
76
82
  const { home, keyringBackend: backend } = testCmd.opts();
77
83
 
78
84
  const io = { ...networkConfig, execFileSync, delay, stdout };
79
- /** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */
85
+ /** @type {OfferSpec} */
80
86
  const offer = {
81
87
  id: opts.offerId,
82
88
  invitationSpec: {
@@ -1,7 +1,11 @@
1
1
  // @ts-check
2
2
  /* eslint-disable func-names */
3
3
  /* eslint-env node */
4
- import { makeVstorageKit } from '@agoric/client-utils';
4
+ import {
5
+ fetchEnvNetworkConfig,
6
+ makeAgoricNames,
7
+ makeVstorageKit,
8
+ } from '@agoric/client-utils';
5
9
  import {
6
10
  lookupOfferIdForVault,
7
11
  Offers,
@@ -9,12 +13,15 @@ import {
9
13
  import { Command } from 'commander';
10
14
  import { normalizeAddressWithOptions } from '../lib/chain.js';
11
15
  import { getCurrent, outputExecuteOfferAction } from '../lib/wallet.js';
12
- import { getNetworkConfig } from '../lib/network-config.js';
13
16
 
14
- const networkConfig = await getNetworkConfig({ env: process.env, fetch });
17
+ /**
18
+ * @import {Logger} from 'anylogger';
19
+ */
20
+
21
+ const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
15
22
 
16
23
  /**
17
- * @param {import('anylogger').Logger} logger
24
+ * @param {Logger} logger
18
25
  */
19
26
  export const makeVaultsCommand = logger => {
20
27
  const vaults = new Command('vaults')
@@ -64,7 +71,8 @@ export const makeVaultsCommand = logger => {
64
71
  .option('--collateralBrand <string>', 'Collateral brand key', 'ATOM')
65
72
  .action(async function (opts) {
66
73
  logger.warn('running with options', opts);
67
- const { agoricNames } = await makeVstorageKit({ fetch }, networkConfig);
74
+ const vsk = makeVstorageKit({ fetch }, networkConfig);
75
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
68
76
 
69
77
  const offer = Offers.vaults.OpenVault(agoricNames, {
70
78
  giveCollateral: opts.giveCollateral,
@@ -99,10 +107,11 @@ export const makeVaultsCommand = logger => {
99
107
  .requiredOption('--vaultId <string>', 'Key of vault (e.g. vault1)')
100
108
  .action(async function (opts) {
101
109
  logger.warn('running with options', opts);
102
- const { agoricNames, readPublished } = await makeVstorageKit(
110
+ const { readPublished, ...vsk } = makeVstorageKit(
103
111
  { fetch },
104
112
  networkConfig,
105
113
  );
114
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
106
115
 
107
116
  const previousOfferId = await lookupOfferIdForVault(
108
117
  opts.vaultId,
@@ -143,10 +152,11 @@ export const makeVaultsCommand = logger => {
143
152
  )
144
153
  .action(async function (opts) {
145
154
  logger.warn('running with options', opts);
146
- const { agoricNames, readPublished } = await makeVstorageKit(
155
+ const { readPublished, ...vsk } = makeVstorageKit(
147
156
  { fetch },
148
157
  networkConfig,
149
158
  );
159
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
150
160
 
151
161
  const previousOfferId = await lookupOfferIdForVault(
152
162
  opts.vaultId,