agoric 0.21.2-other-dev-1f26562.0 → 0.21.2-other-dev-3eb1a1d.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.
@@ -4,32 +4,20 @@
4
4
  */
5
5
 
6
6
  // @ts-check
7
- import { CommanderError, InvalidArgumentError } from 'commander';
8
- // TODO: should get M from endo https://github.com/Agoric/agoric-sdk/issues/7090
7
+ import { makeWalletUtils } from '@agoric/client-utils';
9
8
  import { makeOfferSpecShape } from '@agoric/inter-protocol/src/auction/auctionBook.js';
10
9
  import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
11
10
  import { objectMap } from '@agoric/internal';
12
- import { M, matches } from '@agoric/store';
13
-
14
- // XXX scare away ambient type zombies to fix ScheduleNotification.activeStartTime etc.
15
- // https://github.com/Agoric/agoric-sdk/issues/6512
16
- // https://github.com/Agoric/agoric-sdk/issues/6343
17
- import '@agoric/inter-protocol/src/vaultFactory/types.js';
18
-
11
+ import { M, matches } from '@endo/patterns';
12
+ import { CommanderError, InvalidArgumentError } from 'commander';
19
13
  import { normalizeAddressWithOptions, pollBlocks } from '../lib/chain.js';
14
+ import { getCurrent, outputActionAndHint, sendAction } from '../lib/wallet.js';
20
15
  import {
21
16
  asBoardRemote,
22
17
  bigintReplacer,
23
18
  makeAmountFormatter,
24
19
  } from '../lib/format.js';
25
- import { getNetworkConfig } from '../lib/rpc.js';
26
- import {
27
- getCurrent,
28
- makeParseAmount,
29
- makeWalletUtils,
30
- outputActionAndHint,
31
- sendAction,
32
- } from '../lib/wallet.js';
20
+ import { getNetworkConfig } from '../lib/network-config.js';
33
21
 
34
22
  const { values } = Object;
35
23
 
@@ -39,16 +27,16 @@ const bidInvitationShape = harden({
39
27
  callPipe: [['makeBidInvitation', M.any()]],
40
28
  });
41
29
 
42
- /** @typedef {import('@agoric/vats/tools/board-utils.js').VBankAssetDetail } AssetDescriptor */
43
- /** @typedef {import('@agoric/smart-wallet/src/smartWallet').TryExitOfferAction } TryExitOfferAction */
44
- /** @typedef {import('@agoric/inter-protocol/src/auction/auctionBook.js').OfferSpec} BidSpec */
45
- /** @typedef {import('@agoric/inter-protocol/src/auction/scheduler.js').ScheduleNotification} ScheduleNotification */
46
- /** @typedef {import('@agoric/inter-protocol/src/auction/auctionBook.js').BookDataNotification} BookDataNotification */
30
+ /** @import {VBankAssetDetail} from '@agoric/vats/tools/board-utils.js'; */
31
+ /** @import {TryExitOfferAction} from '@agoric/smart-wallet/src/smartWallet.js'; */
32
+ /** @import {OfferSpec as BidSpec} from '@agoric/inter-protocol/src/auction/auctionBook.js' */
33
+ /** @import {ScheduleNotification} from '@agoric/inter-protocol/src/auction/scheduler.js' */
34
+ /** @import {BookDataNotification} from '@agoric/inter-protocol/src/auction/auctionBook.js' */
47
35
 
48
36
  /**
49
37
  * Format amounts, prices etc. based on brand board Ids, displayInfo
50
38
  *
51
- * @param {AssetDescriptor[]} assets
39
+ * @param {VBankAssetDetail[]} assets
52
40
  */
53
41
  const makeFormatters = assets => {
54
42
  const r4 = x => Math.round(x * 10_000) / 10_000;
@@ -71,12 +59,12 @@ const makeFormatters = assets => {
71
59
  r4(100 - (Number(r.numerator.value) / Number(r.denominator.value)) * 100);
72
60
 
73
61
  // XXX real TimeMath.absValue requires real Remotable timerBrand
74
- /** @param {import('@agoric/time/src/types.js').Timestamp} ts */
62
+ /** @param {import('@agoric/time').Timestamp} ts */
75
63
  const absValue = ts => (typeof ts === 'bigint' ? ts : ts.absValue);
76
64
 
77
- /** @param {import('@agoric/time/src/types.js').Timestamp} tr */
65
+ /** @param {import('@agoric/time').Timestamp} tr */
78
66
  const absTime = tr => new Date(Number(absValue(tr)) * 1000).toISOString();
79
- /** @param {import('@agoric/time/src/types.js').RelativeTimeRecord} tr */
67
+ /** @param {import('@agoric/time').RelativeTimeRecord} tr */
80
68
  const relTime = tr =>
81
69
  new Date(Number(tr.relValue) * 1000).toISOString().slice(11, 19);
82
70
 
@@ -88,7 +76,7 @@ const makeFormatters = assets => {
88
76
  * @param {(_: T) => string} f
89
77
  * @returns { (x: T | null | undefined ) => string | undefined }
90
78
  */
91
- const maybe = f => x => x ? f(x) : undefined;
79
+ const maybe = f => x => (x ? f(x) : undefined);
92
80
 
93
81
  return {
94
82
  amount,
@@ -108,7 +96,7 @@ const makeFormatters = assets => {
108
96
  * Dynamic check that an OfferStatus is also a BidSpec.
109
97
  *
110
98
  * @param {import('@agoric/smart-wallet/src/offers.js').OfferStatus} offerStatus
111
- * @param {Awaited<ReturnType<import('../lib/rpc').makeAgoricNames>>} agoricNames
99
+ * @param {import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes} agoricNames
112
100
  * @param {typeof console.warn} warn
113
101
  * returns null if offerStatus is not a BidSpec
114
102
  */
@@ -144,7 +132,7 @@ const coerceBid = (offerStatus, agoricNames, warn) => {
144
132
  *
145
133
  * @param {import('@agoric/smart-wallet/src/offers.js').OfferStatus &
146
134
  * { offerArgs: BidSpec}} bid
147
- * @param {import('agoric/src/lib/format.js').AssetDescriptor[]} assets
135
+ * @param {VBankAssetDetail[]} assets
148
136
  */
149
137
  export const fmtBid = (bid, assets) => {
150
138
  const fmt = makeFormatters(assets);
@@ -206,6 +194,10 @@ export const makeInterCommand = (
206
194
  const interCmd = createCommand('inter')
207
195
  .description('Inter Protocol commands for liquidation bidding etc.')
208
196
  .option('--home <dir>', 'agd CosmosSDK application home directory')
197
+ .option(
198
+ '--fees <amount>',
199
+ 'set fees for transaction broadcast (e.g. 5000ubld)',
200
+ )
209
201
  .option(
210
202
  '--keyring-backend <os|file|test>',
211
203
  `keyring's backend (os|file|test) (default "${
@@ -220,6 +212,8 @@ export const makeInterCommand = (
220
212
  try {
221
213
  return rawExec(file, args, ...opts);
222
214
  } catch (err) {
215
+ // InvalidArgumentError is a class constructor, and so
216
+ // must be invoked with `new`.
223
217
  throw new InvalidArgumentError(
224
218
  `${err.message}: is ${file} in your $PATH?`,
225
219
  );
@@ -238,10 +232,11 @@ export const makeInterCommand = (
238
232
  try {
239
233
  // XXX pass fetch to getNetworkConfig() explicitly
240
234
  // await null above makes this await safe
241
- // eslint-disable-next-line @jessie.js/no-nested-await
242
- const networkConfig = await getNetworkConfig(env);
243
- return makeWalletUtils({ fetch, execFileSync, delay }, networkConfig);
235
+ const networkConfig = await getNetworkConfig({ env, fetch });
236
+ return makeWalletUtils({ fetch, delay }, networkConfig);
244
237
  } catch (err) {
238
+ // CommanderError is a class constructor, and so
239
+ // must be invoked with `new`.
245
240
  throw new CommanderError(1, 'RPC_FAIL', err.message);
246
241
  }
247
242
  };
@@ -286,14 +281,12 @@ inter auction status
286
281
  * }}
287
282
  */ opts,
288
283
  ) => {
289
- const { agoricNames, readLatestHead } = await tryMakeUtils();
284
+ const { agoricNames, readPublished } = await tryMakeUtils();
290
285
 
291
- /** @type { [ScheduleNotification, BookDataNotification, *] } */
292
- // @ts-expect-error dynamic cast
293
286
  const [schedule, book, { current: params }] = await Promise.all([
294
- readLatestHead(`published.auction.schedule`),
295
- readLatestHead(`published.auction.book${opts.book}`),
296
- readLatestHead(`published.auction.governance`),
287
+ readPublished('auction.schedule'),
288
+ readPublished(`auction.book${opts.book}`),
289
+ readPublished('auction.governance'),
297
290
  ]);
298
291
 
299
292
  const fmt = makeFormatters(Object.values(agoricNames.vbankAsset));
@@ -333,16 +326,16 @@ inter auction status
333
326
  * @param {string} from
334
327
  * @param {import('@agoric/smart-wallet/src/offers.js').OfferSpec} offer
335
328
  * @param {Awaited<ReturnType<tryMakeUtils>>} tools
336
- * @param {boolean?} dryRun
329
+ * @param {boolean | undefined} dryRun
337
330
  */
338
331
  const placeBid = async (from, offer, tools, dryRun = false) => {
339
332
  const { networkConfig, agoricNames, pollOffer } = tools;
340
333
  const io = { ...networkConfig, execFileSync, delay, stdout };
341
334
 
342
- const { home, keyringBackend: backend } = interCmd.opts();
335
+ const { home, keyringBackend: backend, fees } = interCmd.opts();
343
336
  const result = await sendAction(
344
337
  { method: 'executeOffer', offer },
345
- { keyring: { home, backend }, from, verbose: false, dryRun, ...io },
338
+ { keyring: { home, backend }, from, fees, verbose: false, dryRun, ...io },
346
339
  );
347
340
  if (dryRun) {
348
341
  return;
@@ -416,14 +409,7 @@ inter auction status
416
409
  async ({ generateOnly, dryRun, ...opts }) => {
417
410
  const tools = await tryMakeUtils();
418
411
 
419
- const parseAmount = makeParseAmount(
420
- tools.agoricNames,
421
- msg => new InvalidArgumentError(msg),
422
- );
423
- const offer = Offers.auction.Bid(tools.agoricNames.brand, {
424
- ...opts,
425
- parseAmount,
426
- });
412
+ const offer = Offers.auction.Bid(tools.agoricNames, opts);
427
413
 
428
414
  if (generateOnly) {
429
415
  outputActionAndHint(
@@ -441,6 +427,8 @@ inter auction status
441
427
  const parsePercent = v => {
442
428
  const p = Number(v);
443
429
  if (!(p >= -100 && p <= 100)) {
430
+ // InvalidArgumentError is a class constructor, and so
431
+ // must be invoked with `new`.
444
432
  throw new InvalidArgumentError('must be between -100 and 100');
445
433
  }
446
434
  return p / 100;
@@ -464,14 +452,7 @@ inter auction status
464
452
  async ({ generateOnly, ...opts }) => {
465
453
  const tools = await tryMakeUtils();
466
454
 
467
- const parseAmount = makeParseAmount(
468
- tools.agoricNames,
469
- msg => new InvalidArgumentError(msg),
470
- );
471
- const offer = Offers.auction.Bid(tools.agoricNames.brand, {
472
- ...opts,
473
- parseAmount,
474
- });
455
+ const offer = Offers.auction.Bid(tools.agoricNames, opts);
475
456
  if (generateOnly) {
476
457
  outputActionAndHint(
477
458
  { method: 'executeOffer', offer },
@@ -510,11 +491,13 @@ inter auction status
510
491
  return;
511
492
  }
512
493
 
513
- const { networkConfig, readLatestHead } = await tryMakeUtils();
494
+ const { networkConfig, readPublished } = await tryMakeUtils();
514
495
 
515
- const current = await getCurrent(from, { readLatestHead });
496
+ const current = await getCurrent(from, { readPublished });
516
497
  const liveIds = current.liveOffers.map(([i, _s]) => i);
517
498
  if (!liveIds.includes(id)) {
499
+ // InvalidArgumentError is a class constructor, and so
500
+ // must be invoked with `new`.
518
501
  throw new InvalidArgumentError(
519
502
  `${id} not in live offer ids: ${liveIds}`,
520
503
  );
@@ -535,7 +518,7 @@ inter auction status
535
518
  show({ timestamp, height, offerId: id, txhash });
536
519
 
537
520
  const checkGone = async blockInfo => {
538
- const pollResult = await getCurrent(from, { readLatestHead });
521
+ const pollResult = await getCurrent(from, { readPublished });
539
522
  const found = pollResult.liveOffers.find(([i, _]) => i === id);
540
523
  if (found) throw Error('retry');
541
524
  return blockInfo;
@@ -577,11 +560,11 @@ $ inter bid list --from my-acct
577
560
  * }} opts
578
561
  */
579
562
  async opts => {
580
- const { agoricNames, readLatestHead, storedWalletState } =
563
+ const { agoricNames, readPublished, storedWalletState } =
581
564
  await tryMakeUtils();
582
565
 
583
566
  const [current, state] = await Promise.all([
584
- getCurrent(opts.from, { readLatestHead }),
567
+ getCurrent(opts.from, { readPublished }),
585
568
  storedWalletState(opts.from),
586
569
  ]);
587
570
  const entries = opts.all
@@ -1,29 +1,37 @@
1
- /* eslint-disable no-await-in-loop */
2
- /* eslint-disable @jessie.js/no-nested-await */
3
1
  // @ts-check
4
2
  /* eslint-disable func-names */
5
- /* global fetch, setTimeout, process */
6
- import { Fail } from '@agoric/assert';
3
+ /* eslint-env node */
4
+ import {
5
+ makeVstorageKit,
6
+ makeWalletUtils,
7
+ storageHelper,
8
+ } from '@agoric/client-utils';
7
9
  import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
10
+ import { oracleBrandFeedName } from '@agoric/inter-protocol/src/proposals/utils.js';
11
+ import { Fail } from '@endo/errors';
8
12
  import { Nat } from '@endo/nat';
9
- import { Command } from 'commander';
10
13
  import * as cp from 'child_process';
14
+ import { Command } from 'commander';
11
15
  import { inspect } from 'util';
12
16
  import { normalizeAddressWithOptions } from '../lib/chain.js';
13
- import { getNetworkConfig, makeRpcUtils, storageHelper } from '../lib/rpc.js';
17
+ import { getNetworkConfig } from '../lib/network-config.js';
14
18
  import {
15
19
  getCurrent,
16
- makeWalletUtils,
17
20
  outputAction,
18
21
  sendAction,
22
+ sendHint,
19
23
  } from '../lib/wallet.js';
20
24
  import { bigintReplacer } from '../lib/format.js';
21
25
 
26
+ /** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */
27
+
22
28
  // XXX support other decimal places
23
29
  const COSMOS_UNIT = 1_000_000n;
24
30
  const scaleDecimals = num => BigInt(num * Number(COSMOS_UNIT));
25
31
 
26
32
  /**
33
+ * Prints JSON output to stdout and diagnostic info (like logs) to stderr
34
+ *
27
35
  * @param {import('anylogger').Logger} logger
28
36
  * @param {{
29
37
  * delay?: (ms: number) => Promise<void>,
@@ -71,13 +79,18 @@ export const makeOracleCommand = (logger, io = {}) => {
71
79
  env.AGORIC_KEYRING_BACKEND,
72
80
  );
73
81
 
82
+ const normalizeAddress = literalOrName =>
83
+ normalizeAddressWithOptions(literalOrName, oracle.opts(), {
84
+ execFileSync,
85
+ });
86
+
74
87
  const rpcTools = async () => {
75
88
  // XXX pass fetch to getNetworkConfig() explicitly
76
- const networkConfig = await getNetworkConfig(env);
77
- const utils = await makeRpcUtils({ fetch });
89
+ const networkConfig = await getNetworkConfig({ env: process.env, fetch });
90
+ const utils = await makeVstorageKit({ fetch }, networkConfig);
78
91
 
79
92
  const lookupPriceAggregatorInstance = ([brandIn, brandOut]) => {
80
- const name = `${brandIn}-${brandOut} price feed`;
93
+ const name = oracleBrandFeedName(brandIn, brandOut);
81
94
  const instance = utils.agoricNames.instance[name];
82
95
  if (!instance) {
83
96
  logger.debug('known instances:', utils.agoricNames.instance);
@@ -124,7 +137,7 @@ export const makeOracleCommand = (logger, io = {}) => {
124
137
  offer,
125
138
  });
126
139
 
127
- console.warn('Now execute the prepared offer');
140
+ console.warn(sendHint);
128
141
  });
129
142
 
130
143
  oracle
@@ -159,19 +172,19 @@ export const makeOracleCommand = (logger, io = {}) => {
159
172
  offer,
160
173
  });
161
174
 
162
- console.warn('Now execute the prepared offer');
175
+ console.warn(sendHint);
163
176
  });
164
177
 
165
- const findOracleCap = async (from, readLatestHead) => {
166
- const current = await getCurrent(from, { readLatestHead });
178
+ const findOracleCap = async (instance, from, readPublished) => {
179
+ const current = await getCurrent(from, { readPublished });
167
180
 
168
181
  const { offerToUsedInvitation: entries } = /** @type {any} */ (current);
169
182
  Array.isArray(entries) || Fail`entries must be an array: ${entries}`;
170
183
 
171
184
  for (const [offerId, { value }] of entries) {
172
185
  /** @type {{ description: string, instance: unknown }[]} */
173
- const [{ description }] = value;
174
- if (description === 'oracle invitation') {
186
+ const [{ description, instance: candidate }] = value;
187
+ if (description === 'oracle invitation' && candidate === instance) {
175
188
  return offerId;
176
189
  }
177
190
  }
@@ -180,11 +193,22 @@ export const makeOracleCommand = (logger, io = {}) => {
180
193
  oracle
181
194
  .command('find-continuing-id')
182
195
  .description('print id of specified oracle continuing invitation')
183
- .requiredOption('--from <address>', 'from address', String)
196
+ .requiredOption(
197
+ '--from <address>',
198
+ 'wallet address literal or name',
199
+ normalizeAddress,
200
+ )
201
+ .requiredOption(
202
+ '--pair [brandIn.brandOut]',
203
+ 'token pair (brandIn.brandOut)',
204
+ s => s.split('.'),
205
+ )
184
206
  .action(async opts => {
185
- const { readLatestHead } = await makeRpcUtils({ fetch });
207
+ const { readLatestHead, lookupPriceAggregatorInstance } =
208
+ await rpcTools();
209
+ const instance = lookupPriceAggregatorInstance(opts.pair);
186
210
 
187
- const offerId = await findOracleCap(opts.from, readLatestHead);
211
+ const offerId = await findOracleCap(instance, opts.from, readLatestHead);
188
212
  if (!offerId) {
189
213
  console.error('No continuing ids found');
190
214
  }
@@ -212,11 +236,6 @@ export const makeOracleCommand = (logger, io = {}) => {
212
236
  console.log(inspect(capDatas[0], { depth: 10, colors: true }));
213
237
  });
214
238
 
215
- /** @param {string} literalOrName */
216
- const normalizeAddress = literalOrName =>
217
- normalizeAddressWithOptions(literalOrName, oracle.opts(), {
218
- execFileSync,
219
- });
220
239
  const show = (info, indent = false) =>
221
240
  stdout.write(
222
241
  `${JSON.stringify(info, bigintReplacer, indent ? 2 : undefined)}\n`,
@@ -250,21 +269,18 @@ export const makeOracleCommand = (logger, io = {}) => {
250
269
  * }}
251
270
  */ { pair, keys, price },
252
271
  ) => {
253
- const { readLatestHead, networkConfig } = await rpcTools();
254
- const wutil = await makeWalletUtils(
255
- { fetch, execFileSync, delay },
256
- networkConfig,
257
- );
272
+ const { readLatestHead, networkConfig, lookupPriceAggregatorInstance } =
273
+ await rpcTools();
274
+ const wutil = await makeWalletUtils({ fetch, delay }, networkConfig);
258
275
  const unitPrice = scaleDecimals(price);
259
276
 
260
- console.error(`${pair[0]}-${pair[1]}_price_feed: before setPrice`);
277
+ const feedPath = `published.priceFeed.${pair[0]}-${pair[1]}_price_feed`;
261
278
 
262
279
  const readPrice = () =>
263
280
  /** @type {Promise<PriceDescription>} */ (
264
- readLatestHead(
265
- `published.priceFeed.${pair[0]}-${pair[1]}_price_feed`,
266
- ).catch(err => {
267
- console.warn(`cannot get ${pair[0]}-${pair[1]}_price_feed`, err);
281
+ readLatestHead(feedPath).catch(() => {
282
+ const viewer = `https://vstorage.agoric.net/#${networkConfig.rpcAddrs[0]}|published,published.priceFeed|${feedPath}`;
283
+ console.warn(`no existing price data; see ${viewer}`);
268
284
  return undefined;
269
285
  })
270
286
  );
@@ -283,40 +299,61 @@ export const makeOracleCommand = (logger, io = {}) => {
283
299
  show(fmtFeed(before));
284
300
  }
285
301
 
286
- console.error(
287
- 'Choose lead oracle operator order based on latestRound...',
288
- );
289
302
  const keyOrder = keys.map(normalizeAddress);
290
- const latestRoundP = readLatestHead(
291
- `published.priceFeed.${pair[0]}-${pair[1]}_price_feed.latestRound`,
292
- );
293
- await Promise.race([
294
- delay(5000),
295
- latestRoundP.then(round => {
296
- // @ts-expect-error XXX get type from contract
297
- const { roundId, startedAt, startedBy } = round;
298
- show({
299
- startedAt: fmtSecs(startedAt.absValue),
300
- roundId,
301
- startedBy,
302
- });
303
- if (startedBy === keyOrder[0]) {
304
- keyOrder.reverse();
305
- }
306
- }),
307
- ]).catch(err => {
308
- console.warn(err);
309
- });
303
+ if (before) {
304
+ console.error(
305
+ 'Choose lead oracle operator order based on latestRound...',
306
+ );
310
307
 
311
- console.error('pushPrice from each:', keyOrder);
308
+ const latestRoundP =
309
+ /** @type {Promise<{roundId: number, startedAt: import('@agoric/time').TimestampRecord, startedBy: string}>} */ (
310
+ readLatestHead(
311
+ `published.priceFeed.${pair[0]}-${pair[1]}_price_feed.latestRound`,
312
+ )
313
+ );
314
+ await Promise.race([
315
+ delay(5000),
316
+ latestRoundP.then(round => {
317
+ const { roundId, startedAt, startedBy } = round;
318
+ show({
319
+ startedAt: fmtSecs(startedAt.absValue),
320
+ roundId,
321
+ startedBy,
322
+ });
323
+ if (startedBy === keyOrder[0]) {
324
+ keyOrder.reverse();
325
+ }
326
+ }),
327
+ ]).catch(err => {
328
+ console.warn(err);
329
+ });
330
+ }
331
+
332
+ const instance = lookupPriceAggregatorInstance(pair);
333
+ const adminOfferIds = {};
312
334
  for await (const from of keyOrder) {
313
- const oracleAdminAcceptOfferId = await findOracleCap(
335
+ adminOfferIds[from] = await findOracleCap(
336
+ instance,
314
337
  from,
315
338
  readLatestHead,
316
339
  );
317
- if (!oracleAdminAcceptOfferId) {
318
- throw Error(`no oracle invitation found: ${from}`);
340
+ if (!adminOfferIds[from]) {
341
+ console.error(
342
+ `Failed to find an offer accepting oracle invitation for ${from}. Accept and try again:`,
343
+ );
344
+ console.error(
345
+ ` agops oracle accept > accept.json; agoric wallet send --from ${from} --offer accept.json`,
346
+ );
319
347
  }
348
+ }
349
+ assert(
350
+ Object.values(adminOfferIds).every(x => x),
351
+ 'Missing oracle admin offer ids',
352
+ );
353
+
354
+ console.error('pushPrice from each:', keyOrder);
355
+ for await (const from of keyOrder) {
356
+ const oracleAdminAcceptOfferId = adminOfferIds[from];
320
357
  show({ from, oracleAdminAcceptOfferId });
321
358
  const offerId = `pushPrice-${Date.now()}`;
322
359
  const offer = Offers.fluxAggregator.PushPrice(
@@ -1,29 +1,29 @@
1
- /* eslint-disable no-await-in-loop */
2
- /* eslint-disable @jessie.js/no-nested-await */
3
1
  // @ts-check
4
2
  /* eslint-disable func-names */
5
- /* global process */
3
+ /* eslint-env node */
6
4
  import {
7
5
  iterateEach,
8
6
  makeCastingSpec,
9
7
  makeFollower,
10
8
  makeLeaderFromRpcAddresses,
11
9
  } from '@agoric/casting';
10
+ import { slotToRemotable } from '@agoric/internal/src/storage-test-utils.js';
11
+ import { boardSlottingMarshaller } from '@agoric/vats/tools/board-utils.js';
12
12
  import { Command } from 'commander';
13
13
  import fs from 'fs';
14
14
  import { exit } from 'process';
15
- import { slotToRemotable } from '@agoric/internal/src/storage-test-utils.js';
16
- import { boardSlottingMarshaller } from '@agoric/vats/tools/board-utils.js';
17
15
  import { makeLeaderOptions } from '../lib/casting.js';
18
16
  import {
19
17
  execSwingsetTransaction,
20
18
  normalizeAddressWithOptions,
21
19
  } from '../lib/chain.js';
22
- import { networkConfig } from '../lib/rpc.js';
20
+ import { getNetworkConfig } from '../lib/network-config.js';
23
21
 
24
22
  // tight for perf testing but less than this tends to hang.
25
23
  const SLEEP_SECONDS = 0.1;
26
24
 
25
+ const networkConfig = await getNetworkConfig({ env: process.env, fetch });
26
+
27
27
  /**
28
28
  * @param {import('anylogger').Logger} logger
29
29
  */
@@ -1,13 +1,14 @@
1
- /* eslint-disable no-await-in-loop */
2
- /* eslint-disable @jessie.js/no-nested-await */
3
1
  // @ts-check
4
2
  /* eslint-disable func-names */
5
- /* global fetch, process */
6
- import { Command } from 'commander';
3
+ /* eslint-env node */
4
+ import { makeVstorageKit, storageHelper } from '@agoric/client-utils';
7
5
  import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
8
- import { asPercent } from '../lib/format.js';
9
- import { makeRpcUtils, storageHelper } from '../lib/rpc.js';
6
+ import { Command } from 'commander';
7
+ import { getNetworkConfig } from '../lib/network-config.js';
10
8
  import { outputExecuteOfferAction } from '../lib/wallet.js';
9
+ import { asPercent } from '../lib/format.js';
10
+
11
+ const networkConfig = await getNetworkConfig({ env: process.env, fetch });
11
12
 
12
13
  // Adapted from https://gist.github.com/dckc/8b5b2f16395cb4d7f2ff340e0bc6b610#file-psm-tool
13
14
 
@@ -62,7 +63,7 @@ export const makePsmCommand = logger => {
62
63
  );
63
64
 
64
65
  const rpcTools = async () => {
65
- const utils = await makeRpcUtils({ fetch });
66
+ const utils = await makeVstorageKit({ fetch }, networkConfig);
66
67
 
67
68
  const lookupPsmInstance = ([minted, anchor]) => {
68
69
  const name = `psm-${minted}-${anchor}`;
@@ -153,15 +154,17 @@ export const makePsmCommand = logger => {
153
154
  .option('--giveMinted <DOLLARS>', 'amount of minted tokens to give', Number)
154
155
  .option('--feePct [%]', 'Gas fee percentage', Number)
155
156
  .option('--offerId <string>', 'Offer id', String, `swap-${Date.now()}`)
156
- .action(async function (
157
- /** @type {Parameters<typeof Offers.psm.swap>[2]} */ opts,
158
- ) {
159
- console.warn('running with options', opts);
160
- const { agoricNames, lookupPsmInstance } = await rpcTools();
161
- const instance = await lookupPsmInstance(opts.pair);
162
- const offer = Offers.psm.swap(instance, agoricNames.brand, opts);
163
- outputExecuteOfferAction(offer);
164
- });
157
+ .action(
158
+ async function (
159
+ /** @type {Parameters<typeof Offers.psm.swap>[2]} */ opts,
160
+ ) {
161
+ console.warn('running with options', opts);
162
+ const { agoricNames, lookupPsmInstance } = await rpcTools();
163
+ const instance = await lookupPsmInstance(opts.pair);
164
+ const offer = Offers.psm.swap(agoricNames, instance, opts);
165
+ outputExecuteOfferAction(offer);
166
+ },
167
+ );
165
168
 
166
169
  psm
167
170
  .command('proposePauseOffers')
@@ -216,8 +219,6 @@ export const makePsmCommand = logger => {
216
219
  };
217
220
 
218
221
  outputExecuteOfferAction(offer);
219
-
220
- console.warn('Now execute the prepared offer');
221
222
  });
222
223
 
223
224
  psm
@@ -272,8 +273,6 @@ export const makePsmCommand = logger => {
272
273
  };
273
274
 
274
275
  outputExecuteOfferAction(offer);
275
-
276
- console.warn('Now execute the prepared offer');
277
276
  });
278
277
 
279
278
  return psm;
@@ -1,12 +1,14 @@
1
- /* eslint-disable @jessie.js/no-nested-await */
2
1
  // @ts-check
3
2
  /* eslint-disable func-names */
4
- /* global fetch, process */
3
+ /* eslint-env node */
4
+ import { makeVstorageKit } from '@agoric/client-utils';
5
5
  import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
6
6
  import { Command } from 'commander';
7
- import { makeRpcUtils } from '../lib/rpc.js';
7
+ import { getNetworkConfig } from '../lib/network-config.js';
8
8
  import { outputActionAndHint } from '../lib/wallet.js';
9
9
 
10
+ const networkConfig = await getNetworkConfig({ env: process.env, fetch });
11
+
10
12
  /**
11
13
  * @param {import('anylogger').Logger} _logger
12
14
  * @param {*} io
@@ -30,9 +32,9 @@ export const makeReserveCommand = (_logger, io = {}) => {
30
32
  * }} opts
31
33
  */
32
34
  async ({ collateralBrand, ...opts }) => {
33
- const { agoricNames } = await makeRpcUtils({ fetch });
35
+ const { agoricNames } = await makeVstorageKit({ fetch }, networkConfig);
34
36
 
35
- const offer = Offers.reserve.AddCollateral(agoricNames.brand, {
37
+ const offer = Offers.reserve.AddCollateral(agoricNames, {
36
38
  collateralBrandKey: collateralBrand,
37
39
  ...opts,
38
40
  });
@@ -64,7 +66,7 @@ export const makeReserveCommand = (_logger, io = {}) => {
64
66
  1,
65
67
  )
66
68
  .action(async function (opts) {
67
- const { agoricNames } = await makeRpcUtils({ fetch });
69
+ const { agoricNames } = await makeVstorageKit({ fetch }, networkConfig);
68
70
 
69
71
  const reserveInstance = agoricNames.instance.reserve;
70
72
  assert(reserveInstance, 'missing reserve in names');