agoric 0.21.2-other-dev-8f8782b.0 → 0.21.2-other-dev-fbe72e7.0.fbe72e7

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.
Files changed (44) hide show
  1. package/README.md +0 -73
  2. package/package.json +60 -43
  3. package/src/anylogger-agoric.js +31 -16
  4. package/src/bin-agops.js +8 -12
  5. package/src/chain-config.js +42 -16
  6. package/src/commands/auction.js +22 -19
  7. package/src/commands/gov.js +475 -0
  8. package/src/commands/inter.js +44 -62
  9. package/src/commands/oracle.js +144 -87
  10. package/src/commands/perf.js +20 -16
  11. package/src/commands/psm.js +29 -26
  12. package/src/commands/reserve.js +13 -6
  13. package/src/commands/test-upgrade.js +15 -8
  14. package/src/commands/vaults.js +31 -18
  15. package/src/commands/wallet.js +121 -48
  16. package/src/cosmos.js +3 -3
  17. package/src/deploy.js +10 -5
  18. package/src/entrypoint.js +2 -5
  19. package/src/follow.js +14 -10
  20. package/src/helpers.js +10 -5
  21. package/src/init.js +2 -9
  22. package/src/install.js +18 -25
  23. package/src/lib/bundles.js +102 -0
  24. package/src/lib/chain.js +71 -35
  25. package/src/lib/format.js +28 -34
  26. package/src/lib/index.js +7 -0
  27. package/src/lib/packageManager.js +24 -0
  28. package/src/lib/wallet.js +44 -144
  29. package/src/main-publish.js +2 -3
  30. package/src/main.js +95 -125
  31. package/src/open.js +8 -10
  32. package/src/publish.js +4 -9
  33. package/src/scripts.js +14 -32
  34. package/src/sdk-package-names.js +22 -9
  35. package/src/set-defaults.js +2 -1
  36. package/src/start.js +59 -68
  37. package/tools/getting-started.js +272 -0
  38. package/tools/resm-plugin/deploy.js +18 -0
  39. package/tools/resm-plugin/package.json +12 -0
  40. package/tools/resm-plugin/src/output.js +1 -0
  41. package/tools/resm-plugin/src/plugin.js +17 -0
  42. package/CHANGELOG.md +0 -1069
  43. package/src/commands/ec.js +0 -314
  44. package/src/lib/rpc.js +0 -272
@@ -1,14 +1,19 @@
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 {
5
+ fetchEnvNetworkConfig,
6
+ makeAgoricNames,
7
+ makeVstorageKit,
8
+ storageHelper,
9
+ } from '@agoric/client-utils';
7
10
  import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
11
+ import { Command } from 'commander';
8
12
  import { asPercent } from '../lib/format.js';
9
- import { makeRpcUtils, storageHelper } from '../lib/rpc.js';
10
13
  import { outputExecuteOfferAction } from '../lib/wallet.js';
11
14
 
15
+ const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
16
+
12
17
  // Adapted from https://gist.github.com/dckc/8b5b2f16395cb4d7f2ff340e0bc6b610#file-psm-tool
13
18
 
14
19
  /**
@@ -62,13 +67,14 @@ export const makePsmCommand = logger => {
62
67
  );
63
68
 
64
69
  const rpcTools = async () => {
65
- const utils = await makeRpcUtils({ fetch });
70
+ const vsk = await makeVstorageKit({ fetch }, networkConfig);
71
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
66
72
 
67
73
  const lookupPsmInstance = ([minted, anchor]) => {
68
74
  const name = `psm-${minted}-${anchor}`;
69
- const instance = utils.agoricNames.instance[name];
75
+ const instance = agoricNames.instance[name];
70
76
  if (!instance) {
71
- logger.debug('known instances:', utils.agoricNames.instance);
77
+ logger.debug('known instances:', agoricNames.instance);
72
78
  throw Error(`Unknown instance ${name}`);
73
79
  }
74
80
  return instance;
@@ -79,20 +85,19 @@ export const makePsmCommand = logger => {
79
85
  * @param {[Minted: string, Anchor: string]} pair
80
86
  */
81
87
  const getGovernanceState = async ([Minted, Anchor]) => {
82
- const govContent = await utils.vstorage.readLatest(
88
+ const govContent = await vsk.vstorage.readLatest(
83
89
  `published.psm.${Minted}.${Anchor}.governance`,
84
90
  );
85
91
  assert(govContent, 'no gov content');
86
92
  const { current: governance } = last(
87
- storageHelper.unserializeTxt(govContent, utils.fromBoard),
93
+ storageHelper.unserializeTxt(govContent, vsk.fromBoard),
88
94
  );
89
- const { [`psm.${Minted}.${Anchor}`]: instance } =
90
- utils.agoricNames.instance;
95
+ const { [`psm.${Minted}.${Anchor}`]: instance } = agoricNames.instance;
91
96
 
92
97
  return { instance, governance };
93
98
  };
94
99
 
95
- return { ...utils, lookupPsmInstance, getGovernanceState };
100
+ return { ...vsk, agoricNames, lookupPsmInstance, getGovernanceState };
96
101
  };
97
102
 
98
103
  psm
@@ -153,15 +158,17 @@ export const makePsmCommand = logger => {
153
158
  .option('--giveMinted <DOLLARS>', 'amount of minted tokens to give', Number)
154
159
  .option('--feePct [%]', 'Gas fee percentage', Number)
155
160
  .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
- });
161
+ .action(
162
+ async function (
163
+ /** @type {Parameters<typeof Offers.psm.swap>[2]} */ opts,
164
+ ) {
165
+ console.warn('running with options', opts);
166
+ const { agoricNames, lookupPsmInstance } = await rpcTools();
167
+ const instance = await lookupPsmInstance(opts.pair);
168
+ const offer = Offers.psm.swap(agoricNames, instance, opts);
169
+ outputExecuteOfferAction(offer);
170
+ },
171
+ );
165
172
 
166
173
  psm
167
174
  .command('proposePauseOffers')
@@ -216,8 +223,6 @@ export const makePsmCommand = logger => {
216
223
  };
217
224
 
218
225
  outputExecuteOfferAction(offer);
219
-
220
- console.warn('Now execute the prepared offer');
221
226
  });
222
227
 
223
228
  psm
@@ -272,8 +277,6 @@ export const makePsmCommand = logger => {
272
277
  };
273
278
 
274
279
  outputExecuteOfferAction(offer);
275
-
276
- console.warn('Now execute the prepared offer');
277
280
  });
278
281
 
279
282
  return psm;
@@ -1,12 +1,17 @@
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 {
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 { makeRpcUtils } from '../lib/rpc.js';
8
11
  import { outputActionAndHint } from '../lib/wallet.js';
9
12
 
13
+ const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
14
+
10
15
  /**
11
16
  * @param {import('anylogger').Logger} _logger
12
17
  * @param {*} io
@@ -30,9 +35,10 @@ export const makeReserveCommand = (_logger, io = {}) => {
30
35
  * }} opts
31
36
  */
32
37
  async ({ collateralBrand, ...opts }) => {
33
- const { agoricNames } = await makeRpcUtils({ fetch });
38
+ const vsk = makeVstorageKit({ fetch }, networkConfig);
39
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
34
40
 
35
- const offer = Offers.reserve.AddCollateral(agoricNames.brand, {
41
+ const offer = Offers.reserve.AddCollateral(agoricNames, {
36
42
  collateralBrandKey: collateralBrand,
37
43
  ...opts,
38
44
  });
@@ -64,7 +70,8 @@ export const makeReserveCommand = (_logger, io = {}) => {
64
70
  1,
65
71
  )
66
72
  .action(async function (opts) {
67
- const { agoricNames } = await makeRpcUtils({ fetch });
73
+ const vsk = makeVstorageKit({ fetch }, networkConfig);
74
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
68
75
 
69
76
  const reserveInstance = agoricNames.instance.reserve;
70
77
  assert(reserveInstance, 'missing reserve in names');
@@ -1,11 +1,11 @@
1
1
  // @ts-check
2
- /* global process */
3
- import { Fail } from '@agoric/assert';
2
+ /* eslint-env node */
3
+ import { fetchEnvNetworkConfig, makeWalletUtils } from '@agoric/client-utils';
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,10 +38,11 @@ export const makeTestCommand = (
38
38
  try {
39
39
  // XXX pass fetch to getNetworkConfig() explicitly
40
40
  // await null above makes this await safe
41
- // eslint-disable-next-line @jessie.js/no-nested-await
42
- const networkConfig = await getNetworkConfig(env);
43
- return makeWalletUtils({ fetch, execFileSync, delay }, networkConfig);
41
+ const networkConfig = await fetchEnvNetworkConfig({ env, fetch });
42
+ return makeWalletUtils({ fetch, delay }, networkConfig);
44
43
  } catch (err) {
44
+ // CommanderError is a class constructor, and so
45
+ // must be invoked with `new`.
45
46
  throw new CommanderError(1, 'RPC_FAIL', err.message);
46
47
  }
47
48
  };
@@ -83,7 +84,13 @@ export const makeTestCommand = (
83
84
  publicInvitationMaker: 'makeInvitation',
84
85
  },
85
86
  proposal: {
86
- want: { Tokens: { brand: agoricNames.brand.GoodStuff, value: 32n } },
87
+ want: {
88
+ Tokens: {
89
+ // @ts-expect-error BoardRemote not a Brand object
90
+ brand: agoricNames.brand.GoodStuff,
91
+ value: 32n,
92
+ },
93
+ },
87
94
  },
88
95
  };
89
96
  const result = await sendAction(
@@ -1,17 +1,21 @@
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 {
5
+ fetchEnvNetworkConfig,
6
+ makeAgoricNames,
7
+ makeVstorageKit,
8
+ } from '@agoric/client-utils';
7
9
  import {
8
10
  lookupOfferIdForVault,
9
11
  Offers,
10
12
  } from '@agoric/inter-protocol/src/clientSupport.js';
13
+ import { Command } from 'commander';
11
14
  import { normalizeAddressWithOptions } from '../lib/chain.js';
12
- import { makeRpcUtils } from '../lib/rpc.js';
13
15
  import { getCurrent, outputExecuteOfferAction } from '../lib/wallet.js';
14
16
 
17
+ const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
18
+
15
19
  /**
16
20
  * @param {import('anylogger').Logger} logger
17
21
  */
@@ -38,10 +42,10 @@ export const makeVaultsCommand = logger => {
38
42
  normalizeAddress,
39
43
  )
40
44
  .action(async function (opts) {
41
- const { readLatestHead } = await makeRpcUtils({ fetch });
45
+ const { readPublished } = await makeVstorageKit({ fetch }, networkConfig);
42
46
 
43
47
  const current = await getCurrent(opts.from, {
44
- readLatestHead,
48
+ readPublished,
45
49
  });
46
50
 
47
51
  const vaultStoragePaths = current.offerToPublicSubscriberPaths.map(
@@ -56,16 +60,17 @@ export const makeVaultsCommand = logger => {
56
60
 
57
61
  vaults
58
62
  .command('open')
59
- .description('open a new vault')
63
+ .description('Prepare an offer to open a new vault')
60
64
  .requiredOption('--giveCollateral <number>', 'Collateral to give', Number)
61
65
  .requiredOption('--wantMinted <number>', 'Minted wants', Number)
62
66
  .option('--offerId <string>', 'Offer id', String, `openVault-${Date.now()}`)
63
67
  .option('--collateralBrand <string>', 'Collateral brand key', 'ATOM')
64
68
  .action(async function (opts) {
65
69
  logger.warn('running with options', opts);
66
- const { agoricNames } = await makeRpcUtils({ fetch });
70
+ const vsk = makeVstorageKit({ fetch }, networkConfig);
71
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
67
72
 
68
- const offer = Offers.vaults.OpenVault(agoricNames.brand, {
73
+ const offer = Offers.vaults.OpenVault(agoricNames, {
69
74
  giveCollateral: opts.giveCollateral,
70
75
  wantMinted: opts.wantMinted,
71
76
  offerId: opts.offerId,
@@ -78,7 +83,7 @@ export const makeVaultsCommand = logger => {
78
83
 
79
84
  vaults
80
85
  .command('adjust')
81
- .description('adjust an existing vault')
86
+ .description('Prepare an offer to adjust an existing vault')
82
87
  .requiredOption(
83
88
  '--from <address>',
84
89
  'wallet address literal or name',
@@ -98,15 +103,19 @@ export const makeVaultsCommand = logger => {
98
103
  .requiredOption('--vaultId <string>', 'Key of vault (e.g. vault1)')
99
104
  .action(async function (opts) {
100
105
  logger.warn('running with options', opts);
101
- 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);
102
111
 
103
112
  const previousOfferId = await lookupOfferIdForVault(
104
113
  opts.vaultId,
105
- getCurrent(opts.from, { readLatestHead }),
114
+ getCurrent(opts.from, { readPublished }),
106
115
  );
107
116
 
108
117
  const offer = Offers.vaults.AdjustBalances(
109
- agoricNames.brand,
118
+ agoricNames,
110
119
  {
111
120
  giveCollateral: opts.giveCollateral,
112
121
  wantCollateral: opts.wantCollateral,
@@ -123,7 +132,7 @@ export const makeVaultsCommand = logger => {
123
132
 
124
133
  vaults
125
134
  .command('close')
126
- .description('close an existing vault')
135
+ .description('Prepare an offer to close an existing vault')
127
136
  .requiredOption(
128
137
  '--from <address>',
129
138
  'wallet address literal or name',
@@ -139,15 +148,19 @@ export const makeVaultsCommand = logger => {
139
148
  )
140
149
  .action(async function (opts) {
141
150
  logger.warn('running with options', opts);
142
- 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);
143
156
 
144
157
  const previousOfferId = await lookupOfferIdForVault(
145
158
  opts.vaultId,
146
- getCurrent(opts.from, { readLatestHead }),
159
+ getCurrent(opts.from, { readPublished }),
147
160
  );
148
161
 
149
162
  const offer = Offers.vaults.CloseVault(
150
- agoricNames.brand,
163
+ agoricNames,
151
164
  {
152
165
  giveMinted: opts.giveMinted,
153
166
  offerId: opts.offerId,
@@ -1,6 +1,6 @@
1
1
  // @ts-check
2
2
  /* eslint-disable func-names */
3
- /* global fetch, process */
3
+ /* eslint-env node */
4
4
  import {
5
5
  iterateLatest,
6
6
  makeCastingSpec,
@@ -8,12 +8,14 @@ import {
8
8
  makeLeader,
9
9
  makeLeaderFromRpcAddresses,
10
10
  } from '@agoric/casting';
11
- import { Command } from 'commander';
11
+ import {
12
+ makeVstorageKit,
13
+ fetchEnvNetworkConfig,
14
+ makeAgoricNames,
15
+ } from '@agoric/client-utils';
16
+ import { execFileSync } from 'child_process';
12
17
  import fs from 'fs';
13
18
  import util from 'util';
14
- import { execFileSync } from 'child_process';
15
- import { fmtRecordOfLines, summarize } from '../lib/format.js';
16
- import { makeRpcUtils, networkConfig } from '../lib/rpc.js';
17
19
 
18
20
  import { makeLeaderOptions } from '../lib/casting.js';
19
21
  import {
@@ -21,24 +23,43 @@ import {
21
23
  fetchSwingsetParams,
22
24
  normalizeAddressWithOptions,
23
25
  } from '../lib/chain.js';
26
+ import {
27
+ fmtRecordOfLines,
28
+ parseFiniteNumber,
29
+ summarize,
30
+ } from '../lib/format.js';
24
31
  import { coalesceWalletState, getCurrent } from '../lib/wallet.js';
25
32
 
33
+ const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
34
+
26
35
  const SLEEP_SECONDS = 3;
27
36
 
28
- export const makeWalletCommand = async () => {
29
- const wallet = new Command('wallet')
30
- .description('wallet commands')
31
- .option('--home <dir>', 'agd application home directory')
32
- .option(
33
- '--keyring-backend <os|file|test>',
34
- 'keyring\'s backend (os|file|test) (default "os")',
35
- );
37
+ /**
38
+ * @param {import('commander').Command['command']} command
39
+ * @returns {Promise<import('commander').Command>}
40
+ */
41
+ export const makeWalletCommand = async command => {
42
+ /**
43
+ * @param {import('commander').Command} baseCmd
44
+ */
45
+ const withSharedTxOptions = baseCmd =>
46
+ baseCmd
47
+ .option('--home <dir>', 'agd application home directory')
48
+ .option(
49
+ '--keyring-backend <os|file|test>',
50
+ 'keyring\'s backend (os|file|test) (default "os")',
51
+ );
52
+ /** @typedef {{home?: string, keyringBackend: 'os' | 'file' | 'test'}} SharedTxOptions */
36
53
 
54
+ const wallet = withSharedTxOptions(command('wallet')).description(
55
+ 'wallet commands',
56
+ );
57
+
58
+ /** @param {string} literalOrName */
37
59
  const normalizeAddress = literalOrName =>
38
60
  normalizeAddressWithOptions(literalOrName, wallet.opts());
39
61
 
40
- wallet
41
- .command('provision')
62
+ withSharedTxOptions(wallet.command('provision'))
42
63
  .description('provision a Smart Wallet')
43
64
  .requiredOption(
44
65
  '--account [address]',
@@ -47,9 +68,16 @@ export const makeWalletCommand = async () => {
47
68
  )
48
69
  .option('--spend', 'confirm you want to spend')
49
70
  .option('--nickname <string>', 'nickname to use', 'my-wallet')
50
- .action(function (opts) {
51
- const { account, nickname, spend } = opts;
52
- const { home, keyringBackend: backend } = wallet.opts();
71
+ .action(async function (opts) {
72
+ await null;
73
+ /** @typedef {{account: string, spend?: boolean, nickname: 'my-wallet' | string }} Opts */
74
+ const {
75
+ account,
76
+ nickname,
77
+ spend,
78
+ home,
79
+ keyringBackend: backend,
80
+ } = /** @type {SharedTxOptions & Opts} */ ({ ...wallet.opts(), ...opts });
53
81
  const tx = ['provision-one', nickname, account, 'SMART_WALLET'];
54
82
  if (spend) {
55
83
  execSwingsetTransaction(tx, {
@@ -58,12 +86,12 @@ export const makeWalletCommand = async () => {
58
86
  ...networkConfig,
59
87
  });
60
88
  } else {
61
- const params = fetchSwingsetParams(networkConfig);
89
+ const params = await fetchSwingsetParams(networkConfig);
62
90
  assert(
63
- params.power_flag_fees.length === 1,
91
+ params.powerFlagFees.length === 1,
64
92
  'multiple power_flag_fees not supported',
65
93
  );
66
- const { fee: fees } = params.power_flag_fees[0];
94
+ const { fee: fees } = params.powerFlagFees[0];
67
95
  const nf = new Intl.NumberFormat('en-US');
68
96
  const costs = fees
69
97
  .map(f => `${nf.format(Number(f.amount))} ${f.denom}`)
@@ -86,9 +114,9 @@ export const makeWalletCommand = async () => {
86
114
  .action(async function (opts) {
87
115
  const offerStr = fs.readFileSync(opts.file).toString();
88
116
 
89
- const { unserializer } = await makeRpcUtils({ fetch });
117
+ const { marshaller } = makeVstorageKit({ fetch }, networkConfig);
90
118
 
91
- const offerObj = unserializer.fromCapData(JSON.parse(offerStr));
119
+ const offerObj = marshaller.fromCapData(JSON.parse(offerStr));
92
120
  console.log(offerObj);
93
121
  });
94
122
 
@@ -101,14 +129,13 @@ export const makeWalletCommand = async () => {
101
129
  .action(async function (opts) {
102
130
  const offerStr = fs.readFileSync(opts.offer).toString();
103
131
 
104
- const { unserializer } = await makeRpcUtils({ fetch });
132
+ const { marshaller } = makeVstorageKit({ fetch }, networkConfig);
105
133
 
106
- const offerObj = unserializer.fromCapData(JSON.parse(offerStr));
134
+ const offerObj = marshaller.fromCapData(JSON.parse(offerStr));
107
135
  console.log(offerObj.offer.id);
108
136
  });
109
137
 
110
- wallet
111
- .command('send')
138
+ withSharedTxOptions(wallet.command('send'))
112
139
  .description('send a prepared offer')
113
140
  .requiredOption(
114
141
  '--from [address]',
@@ -117,24 +144,69 @@ export const makeWalletCommand = async () => {
117
144
  )
118
145
  .requiredOption('--offer [filename]', 'path to file with prepared offer')
119
146
  .option('--dry-run', 'spit out the command instead of running it')
147
+ .option('--gas', 'gas limit; "auto" [default] to calculate automatically')
148
+ .option(
149
+ '--gas-adjustment',
150
+ 'factor by which to multiply the --gas=auto calculation result [default 1.2]',
151
+ )
152
+ .option('--verbose', 'print command output')
120
153
  .action(function (opts) {
121
- const { dryRun, from, offer } = opts;
122
- const { home, keyringBackend: backend } = wallet.opts();
154
+ /**
155
+ * @typedef {{
156
+ * from: string,
157
+ * offer: string,
158
+ * dryRun: boolean,
159
+ * gas: string,
160
+ * gasAdjustment: string,
161
+ * verbose: boolean,
162
+ * }} Opts
163
+ */
164
+ const {
165
+ dryRun,
166
+ from,
167
+ gas = 'auto',
168
+ gasAdjustment = '1.2',
169
+ offer,
170
+ home,
171
+ verbose,
172
+ keyringBackend: backend,
173
+ } = /** @type {SharedTxOptions & Opts} */ ({ ...wallet.opts(), ...opts });
123
174
 
124
175
  const offerBody = fs.readFileSync(offer).toString();
125
- execSwingsetTransaction(['wallet-action', '--allow-spend', offerBody], {
126
- from,
127
- dryRun,
128
- keyring: { home, backend },
129
- ...networkConfig,
130
- });
176
+ const out = execSwingsetTransaction(
177
+ ['wallet-action', '--allow-spend', offerBody, '-ojson', '-bblock'],
178
+ {
179
+ ...networkConfig,
180
+ keyring: { home, backend },
181
+ from,
182
+ gas:
183
+ gas === 'auto'
184
+ ? ['auto', parseFiniteNumber(gasAdjustment)]
185
+ : parseFiniteNumber(gas),
186
+ dryRun,
187
+ verbose,
188
+ },
189
+ );
190
+
191
+ // see sendAction in {@link ../lib/wallet.js}
192
+ if (dryRun || !verbose) return;
193
+ try {
194
+ const tx = JSON.parse(/** @type {string} */ (out));
195
+ if (tx.code !== 0) {
196
+ console.error('failed to send tx', tx);
197
+ }
198
+ console.log(tx);
199
+ } catch (err) {
200
+ console.error('unexpected output', JSON.stringify(out));
201
+ throw err;
202
+ }
131
203
  });
132
204
 
133
205
  wallet
134
206
  .command('list')
135
207
  .description('list all wallets in vstorage')
136
208
  .action(async function () {
137
- const { vstorage } = await makeRpcUtils({ fetch });
209
+ const { vstorage } = makeVstorageKit({ fetch }, networkConfig);
138
210
  const wallets = await vstorage.keys('published.wallet');
139
211
  process.stdout.write(wallets.join('\n'));
140
212
  });
@@ -148,23 +220,26 @@ export const makeWalletCommand = async () => {
148
220
  normalizeAddress,
149
221
  )
150
222
  .action(async function (opts) {
151
- const { agoricNames, unserializer, readLatestHead } = await makeRpcUtils({
152
- fetch,
153
- });
223
+ const {
224
+ readPublished,
225
+ marshaller: unserializer,
226
+ ...vsk
227
+ } = makeVstorageKit({ fetch }, networkConfig);
228
+ const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
154
229
 
155
230
  const leader = makeLeader(networkConfig.rpcAddrs[0]);
156
231
  const follower = await makeFollower(
157
232
  `:published.wallet.${opts.from}`,
158
233
  leader,
159
234
  {
160
- // @ts-expect-error xxx
235
+ // @ts-expect-error xxx follower/marshaller types
161
236
  unserializer,
162
237
  },
163
238
  );
164
239
 
165
240
  const coalesced = await coalesceWalletState(follower);
166
241
 
167
- const current = await getCurrent(opts.from, { readLatestHead });
242
+ const current = await getCurrent(opts.from, { readPublished });
168
243
 
169
244
  console.warn(
170
245
  'got coalesced',
@@ -204,15 +279,13 @@ export const makeWalletCommand = async () => {
204
279
  .action(async function ({ from }) {
205
280
  const spec = `:published.wallet.${from}`;
206
281
 
207
- const leaderOptions = makeLeaderOptions({
208
- sleep: SLEEP_SECONDS,
209
- jitter: 0,
210
- log: () => undefined,
211
- });
212
-
213
282
  const leader = makeLeaderFromRpcAddresses(
214
283
  networkConfig.rpcAddrs,
215
- leaderOptions,
284
+ makeLeaderOptions({
285
+ sleep: SLEEP_SECONDS,
286
+ jitter: 0,
287
+ log: console.warn,
288
+ }),
216
289
  );
217
290
 
218
291
  console.warn('Following', spec);
package/src/cosmos.js CHANGED
@@ -14,10 +14,10 @@ export default async function cosmosMain(progname, rawArgs, powers, opts) {
14
14
  const pspawnEnv = { ...process.env };
15
15
  if (popts.verbose > 1) {
16
16
  // Enable verbose logs.
17
- pspawnEnv.DEBUG = 'agoric';
17
+ pspawnEnv.DEBUG = 'agoric:info';
18
18
  } else if (!popts.verbose) {
19
19
  // Disable more logs.
20
- pspawnEnv.DEBUG = '';
20
+ pspawnEnv.DEBUG = 'agoric:none';
21
21
  }
22
22
 
23
23
  const pspawn = makePspawn({ env: pspawnEnv, log, spawn, chalk });
@@ -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/deploy.js CHANGED
@@ -1,8 +1,9 @@
1
1
  // @ts-check
2
- /* global process setTimeout setInterval clearInterval */
2
+ /* eslint-env node */
3
3
 
4
- import { E, makeCapTP } from '@endo/captp';
4
+ import { X } from '@endo/errors';
5
5
  import { makePromiseKit } from '@endo/promise-kit';
6
+ import { E, makeCapTP } from '@endo/captp';
6
7
  import { makeLeaderFromRpcAddresses } from '@agoric/casting';
7
8
  import path from 'path';
8
9
  import http from 'http';
@@ -20,8 +21,6 @@ import {
20
21
  import { makeJsonHttpClient } from './json-http-client-node.js';
21
22
  import { makeScriptLoader } from './scripts.js';
22
23
 
23
- const { details: X } = assert;
24
-
25
24
  // note: CapTP has its own HandledPromise instantiation, and the contract
26
25
  // must use the same one that CapTP uses. We achieve this by not bundling
27
26
  // captp, and doing a (non-isolated) dynamic import of the deploy script
@@ -191,6 +190,12 @@ const connectAndRun = async (
191
190
  return retryWebsocket().then(() => exit.promise);
192
191
  };
193
192
 
193
+ /**
194
+ * @param {string} progname
195
+ * @param {string[]} rawArgs
196
+ * @param {{ makeWebSocket?: (...args: ConstructorParameters<typeof WebSocket>) => WebSocket; anylogger: (name: string) => Console; now?: () => number; fs?: any; }} powers
197
+ * @param {{ allowUnsafePlugins: any; provide: string; sdk: any; need: string; hostport: string; target: string | number | undefined; scriptArgs: any; }} opts
198
+ */
194
199
  export default async function deployMain(progname, rawArgs, powers, opts) {
195
200
  const { anylogger, now, fs } = powers;
196
201
  const console = anylogger('agoric:deploy');
@@ -239,7 +244,7 @@ export default async function deployMain(progname, rawArgs, powers, opts) {
239
244
 
240
245
  const match = opts.hostport.match(/^(.*):(\d+)$/);
241
246
  const host = match ? match[1] : 'localhost';
242
- const port = match ? match[2] : '8000';
247
+ const port = match ? +match[2] : 8000;
243
248
 
244
249
  const wsurl = opts.hostport.includes('//')
245
250
  ? new URL(opts.hostport, 'ws://localhost:8000')