agoric 0.21.2-dev-fe64626.0 → 0.21.2-dev-c39bfd3.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-fe64626.0+fe64626",
3
+ "version": "0.21.2-dev-c39bfd3.0+c39bfd3",
4
4
  "description": "Manage the Agoric Javascript smart contract platform",
5
5
  "type": "module",
6
6
  "main": "src/main.js",
@@ -30,28 +30,28 @@
30
30
  "lint:eslint": "eslint ."
31
31
  },
32
32
  "devDependencies": {
33
- "@agoric/cosmic-swingset": "0.41.4-dev-fe64626.0+fe64626",
34
- "@agoric/deploy-script-support": "0.10.4-dev-fe64626.0+fe64626",
33
+ "@agoric/cosmic-swingset": "0.41.4-dev-c39bfd3.0+c39bfd3",
34
+ "@agoric/deploy-script-support": "0.10.4-dev-c39bfd3.0+c39bfd3",
35
35
  "ava": "^5.3.0",
36
36
  "c8": "^10.1.2"
37
37
  },
38
38
  "dependencies": {
39
- "@agoric/access-token": "0.4.22-dev-fe64626.0+fe64626",
40
- "@agoric/cache": "0.3.3-dev-fe64626.0+fe64626",
41
- "@agoric/casting": "0.4.3-dev-fe64626.0+fe64626",
42
- "@agoric/client-utils": "0.1.1-dev-fe64626.0+fe64626",
43
- "@agoric/cosmic-proto": "0.4.1-dev-fe64626.0+fe64626",
44
- "@agoric/ertp": "0.16.3-dev-fe64626.0+fe64626",
45
- "@agoric/governance": "0.10.4-dev-fe64626.0+fe64626",
46
- "@agoric/inter-protocol": "0.16.2-dev-fe64626.0+fe64626",
47
- "@agoric/internal": "0.3.3-dev-fe64626.0+fe64626",
48
- "@agoric/network": "0.1.1-dev-fe64626.0+fe64626",
49
- "@agoric/smart-wallet": "0.5.4-dev-fe64626.0+fe64626",
50
- "@agoric/store": "0.9.3-dev-fe64626.0+fe64626",
51
- "@agoric/swingset-vat": "0.32.3-dev-fe64626.0+fe64626",
52
- "@agoric/vats": "0.15.2-dev-fe64626.0+fe64626",
53
- "@agoric/zoe": "0.26.3-dev-fe64626.0+fe64626",
54
- "@agoric/zone": "0.2.3-dev-fe64626.0+fe64626",
39
+ "@agoric/access-token": "0.4.22-dev-c39bfd3.0+c39bfd3",
40
+ "@agoric/cache": "0.3.3-dev-c39bfd3.0+c39bfd3",
41
+ "@agoric/casting": "0.4.3-dev-c39bfd3.0+c39bfd3",
42
+ "@agoric/client-utils": "0.1.1-dev-c39bfd3.0+c39bfd3",
43
+ "@agoric/cosmic-proto": "0.4.1-dev-c39bfd3.0+c39bfd3",
44
+ "@agoric/ertp": "0.16.3-dev-c39bfd3.0+c39bfd3",
45
+ "@agoric/governance": "0.10.4-dev-c39bfd3.0+c39bfd3",
46
+ "@agoric/inter-protocol": "0.16.2-dev-c39bfd3.0+c39bfd3",
47
+ "@agoric/internal": "0.3.3-dev-c39bfd3.0+c39bfd3",
48
+ "@agoric/network": "0.1.1-dev-c39bfd3.0+c39bfd3",
49
+ "@agoric/smart-wallet": "0.5.4-dev-c39bfd3.0+c39bfd3",
50
+ "@agoric/store": "0.9.3-dev-c39bfd3.0+c39bfd3",
51
+ "@agoric/swingset-vat": "0.32.3-dev-c39bfd3.0+c39bfd3",
52
+ "@agoric/vats": "0.15.2-dev-c39bfd3.0+c39bfd3",
53
+ "@agoric/zoe": "0.26.3-dev-c39bfd3.0+c39bfd3",
54
+ "@agoric/zone": "0.2.3-dev-c39bfd3.0+c39bfd3",
55
55
  "@confio/relayer": "^0.11.3",
56
56
  "@cosmjs/crypto": "^0.32.3",
57
57
  "@cosmjs/encoding": "^0.32.3",
@@ -102,5 +102,5 @@
102
102
  "typeCoverage": {
103
103
  "atLeast": 78.73
104
104
  },
105
- "gitHead": "fe64626676ae80ae48d4beee23d2d75f71cf1031"
105
+ "gitHead": "c39bfd3c248e3b2b3f5854fdfaee25999d1702d0"
106
106
  }
package/src/bin-agops.js CHANGED
@@ -30,7 +30,6 @@ const progname = path.basename(process.argv[1]);
30
30
  const program = new Command();
31
31
  program.name(progname).version('unversioned');
32
32
 
33
- program.addCommand(makeOracleCommand(logger));
34
33
  program.addCommand(makeGovCommand(logger));
35
34
  program.addCommand(makePerfCommand(logger));
36
35
  program.addCommand(makePsmCommand(logger));
@@ -69,6 +68,7 @@ const procIO = {
69
68
  setTimeout,
70
69
  };
71
70
 
71
+ program.addCommand(makeOracleCommand(procIO, logger));
72
72
  program.addCommand(makeReserveCommand(logger, procIO));
73
73
  program.addCommand(makeAuctionCommand(logger, { ...procIO, fetch }));
74
74
  program.addCommand(makeInterCommand(procIO, { fetch }));
@@ -12,7 +12,6 @@ import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
12
12
  import { oracleBrandFeedName } from '@agoric/inter-protocol/src/proposals/utils.js';
13
13
  import { Fail } from '@endo/errors';
14
14
  import { Nat } from '@endo/nat';
15
- import * as cp from 'child_process';
16
15
  import { Command } from 'commander';
17
16
  import { inspect } from 'util';
18
17
  import { normalizeAddressWithOptions } from '../lib/chain.js';
@@ -28,26 +27,33 @@ import {
28
27
 
29
28
  // XXX support other decimal places
30
29
  const COSMOS_UNIT = 1_000_000n;
31
- const scaleDecimals = num => BigInt(num * Number(COSMOS_UNIT));
30
+ /** @param {number} num */
31
+ const scaleDecimals = num => BigInt(Math.round(num * Number(COSMOS_UNIT)));
32
32
 
33
33
  /**
34
34
  * Prints JSON output to stdout and diagnostic info (like logs) to stderr
35
35
  *
36
- * @param {import('anylogger').Logger} logger
37
36
  * @param {{
38
- * delay?: (ms: number) => Promise<void>,
39
- * execFileSync?: typeof import('child_process').execFileSync,
40
- * env?: Record<string, string | undefined>,
41
- * stdout?: Pick<import('stream').Writable,'write'>,
42
- * }} [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]
43
46
  */
44
- export const makeOracleCommand = (logger, io = {}) => {
45
- const {
46
- delay = ms => new Promise(resolve => setTimeout(resolve, ms)),
47
- execFileSync = cp.execFileSync,
48
- env = process.env,
49
- stdout = process.stdout,
50
- } = 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
+
51
57
  const oracle = new Command('oracle')
52
58
  .description('Oracle commands')
53
59
  .usage(
@@ -98,7 +104,7 @@ export const makeOracleCommand = (logger, io = {}) => {
98
104
  const name = oracleBrandFeedName(brandIn, brandOut);
99
105
  const instance = agoricNames.instance[name];
100
106
  if (!instance) {
101
- logger.debug('known instances:', agoricNames.instance);
107
+ logger && logger.debug('known instances:', agoricNames.instance);
102
108
  throw Error(`Unknown instance ${name}`);
103
109
  }
104
110
  return instance;
@@ -137,12 +143,15 @@ export const makeOracleCommand = (logger, io = {}) => {
137
143
  proposal: {},
138
144
  };
139
145
 
140
- outputAction({
141
- method: 'executeOffer',
142
- offer,
143
- });
146
+ outputAction(
147
+ {
148
+ method: 'executeOffer',
149
+ offer,
150
+ },
151
+ stdout,
152
+ );
144
153
 
145
- console.warn(sendHint);
154
+ stderr.write(sendHint);
146
155
  });
147
156
 
148
157
  oracle
@@ -172,12 +181,15 @@ export const makeOracleCommand = (logger, io = {}) => {
172
181
  opts.oracleAdminAcceptOfferId,
173
182
  );
174
183
 
175
- outputAction({
176
- method: 'executeOffer',
177
- offer,
178
- });
184
+ outputAction(
185
+ {
186
+ method: 'executeOffer',
187
+ offer,
188
+ },
189
+ stdout,
190
+ );
179
191
 
180
- console.warn(sendHint);
192
+ stderr.write(sendHint);
181
193
  });
182
194
 
183
195
  const findOracleCap = async (instance, from, readPublished) => {
@@ -288,7 +300,7 @@ export const makeOracleCommand = (logger, io = {}) => {
288
300
  /** @type {Promise<PriceDescription>} */ (
289
301
  readLatestHead(feedPath).catch(() => {
290
302
  const viewer = `https://vstorage.agoric.net/#${networkConfig.rpcAddrs[0]}|published,published.priceFeed|${feedPath}`;
291
- console.warn(`no existing price data; see ${viewer}`);
303
+ stderr.write(`no existing price data; see ${viewer}`);
292
304
  return undefined;
293
305
  })
294
306
  );
@@ -333,7 +345,7 @@ export const makeOracleCommand = (logger, io = {}) => {
333
345
  }
334
346
  }),
335
347
  ]).catch(err => {
336
- console.warn(err);
348
+ stderr.write(err);
337
349
  });
338
350
  }
339
351