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.
- package/README.md +0 -73
- package/package.json +51 -49
- package/src/bin-agops.js +1 -5
- package/src/chain-config.js +9 -2
- package/src/commands/gov.js +29 -18
- package/src/commands/inter.js +17 -530
- package/src/commands/oracle.js +71 -43
- package/src/commands/perf.js +21 -13
- package/src/commands/psm.js +24 -15
- package/src/commands/reserve.js +17 -7
- package/src/commands/test-upgrade.js +15 -9
- package/src/commands/vaults.js +17 -7
- package/src/commands/wallet.js +38 -31
- package/src/deploy.js +7 -1
- package/src/entrypoint.js +1 -2
- package/src/follow.js +13 -8
- package/src/helpers.js +2 -1
- package/src/install.js +3 -11
- package/src/lib/casting.js +5 -1
- package/src/lib/chain.js +17 -31
- package/src/lib/format.js +7 -4
- package/src/lib/index.js +7 -0
- package/src/lib/packageManager.js +24 -0
- package/src/lib/wallet.js +25 -19
- package/src/main-publish.js +5 -1
- package/src/main.js +4 -36
- package/src/publish.js +15 -5
- package/src/scripts.js +10 -31
- package/src/sdk-package-names.js +12 -4
- package/src/start.js +2 -3
- package/tools/getting-started.js +30 -7
- package/src/commands/auction.js +0 -169
- package/src/lib/network-config.js +0 -41
package/src/commands/oracle.js
CHANGED
|
@@ -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 {
|
|
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
|
-
/**
|
|
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
|
-
|
|
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
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
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 = (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
90
|
-
|
|
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 =
|
|
113
|
+
const instance = agoricNames.instance[name];
|
|
95
114
|
if (!instance) {
|
|
96
|
-
logger.debug('known instances:',
|
|
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 { ...
|
|
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 {
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
154
|
+
outputAction(
|
|
155
|
+
{
|
|
156
|
+
method: 'executeOffer',
|
|
157
|
+
offer,
|
|
158
|
+
},
|
|
159
|
+
stdout,
|
|
160
|
+
);
|
|
139
161
|
|
|
140
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
192
|
+
outputAction(
|
|
193
|
+
{
|
|
194
|
+
method: 'executeOffer',
|
|
195
|
+
offer,
|
|
196
|
+
},
|
|
197
|
+
stdout,
|
|
198
|
+
);
|
|
174
199
|
|
|
175
|
-
|
|
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 {
|
|
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,
|
|
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 {
|
|
273
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
366
|
+
readPublished,
|
|
339
367
|
);
|
|
340
368
|
if (!adminOfferIds[from]) {
|
|
341
369
|
console.error(
|
package/src/commands/perf.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
29
|
+
const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
|
-
* @param {
|
|
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
|
-
|
|
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
|
-
|
|
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, {
|
|
109
|
+
execSwingsetTransaction(cmd, {
|
|
110
|
+
from: opts.from,
|
|
111
|
+
verbose: opts.verbose,
|
|
112
|
+
...networkConfig,
|
|
113
|
+
});
|
|
106
114
|
});
|
|
107
115
|
|
|
108
116
|
return perf;
|
package/src/commands/psm.js
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
/* eslint-disable func-names */
|
|
3
3
|
/* eslint-env node */
|
|
4
|
-
import {
|
|
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
|
|
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 {
|
|
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
|
|
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 =
|
|
80
|
+
const instance = agoricNames.instance[name];
|
|
71
81
|
if (!instance) {
|
|
72
|
-
logger.debug('known instances:',
|
|
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
|
|
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,
|
|
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 { ...
|
|
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 {
|
|
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 {
|
|
268
|
+
/** @type {OfferSpec} */
|
|
260
269
|
const offer = {
|
|
261
270
|
id: opts.offerId,
|
|
262
271
|
invitationSpec: {
|
package/src/commands/reserve.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
/* eslint-disable func-names */
|
|
3
3
|
/* eslint-env node */
|
|
4
|
-
import {
|
|
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
|
-
|
|
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 {
|
|
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
|
|
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
|
|
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 {
|
|
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<
|
|
17
|
-
* stderr: Pick<
|
|
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
|
|
21
|
-
* execFileSync: typeof
|
|
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
|
|
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 {
|
|
85
|
+
/** @type {OfferSpec} */
|
|
80
86
|
const offer = {
|
|
81
87
|
id: opts.offerId,
|
|
82
88
|
invitationSpec: {
|
package/src/commands/vaults.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
/* eslint-disable func-names */
|
|
3
3
|
/* eslint-env node */
|
|
4
|
-
import {
|
|
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
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @import {Logger} from 'anylogger';
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
|
|
15
22
|
|
|
16
23
|
/**
|
|
17
|
-
* @param {
|
|
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
|
|
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 {
|
|
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 {
|
|
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,
|