agoric 0.21.2-mainnet1B-dev-26244e8.0 → 0.21.2-orchestration-dev-096c4e8.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 +48 -35
- package/src/anylogger-agoric.js +28 -14
- package/src/bin-agops.js +9 -8
- package/src/chain-config.js +11 -11
- package/src/commands/auction.js +6 -3
- package/src/commands/{ec.js → gov.js} +177 -38
- package/src/commands/inter.js +14 -31
- package/src/commands/oracle.js +32 -17
- package/src/commands/perf.js +0 -2
- package/src/commands/psm.js +11 -15
- package/src/commands/reserve.js +1 -2
- package/src/commands/test-upgrade.js +7 -2
- package/src/commands/vaults.js +6 -8
- package/src/commands/wallet.js +12 -8
- package/src/cosmos.js +2 -2
- package/src/follow.js +6 -3
- package/src/helpers.js +1 -0
- package/src/init.js +5 -8
- package/src/install.js +8 -6
- package/src/lib/chain.js +30 -20
- package/src/lib/format.js +9 -14
- package/src/lib/rpc.js +17 -5
- package/src/lib/wallet.js +26 -55
- package/src/main-publish.js +1 -2
- package/src/main.js +43 -45
- package/src/open.js +6 -6
- package/src/publish.js +4 -13
- package/src/sdk-package-names.js +9 -5
- package/src/set-defaults.js +1 -0
- package/src/start.js +53 -59
- package/tools/getting-started.js +273 -0
- package/tools/resm-plugin/deploy.js +18 -0
- package/tools/resm-plugin/package.json +12 -0
- package/tools/resm-plugin/src/output.js +1 -0
- package/tools/resm-plugin/src/plugin.js +17 -0
- package/CHANGELOG.md +0 -1086
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @jessie.js/no-nested-await */
|
|
2
1
|
// @ts-check
|
|
3
2
|
/* eslint-disable func-names */
|
|
4
3
|
/* global globalThis, process, setTimeout */
|
|
@@ -16,6 +15,13 @@ import {
|
|
|
16
15
|
|
|
17
16
|
/** @typedef {import('@agoric/smart-wallet/src/offers.js').OfferSpec} OfferSpec */
|
|
18
17
|
|
|
18
|
+
const collectValues = (val, memo) => {
|
|
19
|
+
memo.push(val);
|
|
20
|
+
return memo;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const defaultKeyring = process.env.AGORIC_KEYRING_BACKEND || 'test';
|
|
24
|
+
|
|
19
25
|
/**
|
|
20
26
|
* @param {import('anylogger').Logger} _logger
|
|
21
27
|
* @param {{
|
|
@@ -27,7 +33,7 @@ import {
|
|
|
27
33
|
* delay?: (ms: number) => Promise<void>,
|
|
28
34
|
* }} [io]
|
|
29
35
|
*/
|
|
30
|
-
export const
|
|
36
|
+
export const makeGovCommand = (_logger, io = {}) => {
|
|
31
37
|
const {
|
|
32
38
|
// Allow caller to provide access explicitly, but
|
|
33
39
|
// default to conventional ambient IO facilities.
|
|
@@ -39,11 +45,22 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
|
|
|
39
45
|
delay = ms => new Promise(resolve => setTimeout(resolve, ms)),
|
|
40
46
|
} = io;
|
|
41
47
|
|
|
42
|
-
const
|
|
48
|
+
const cmd = new Command('gov').description('Electoral governance commands');
|
|
49
|
+
// backwards compatibility with less general "ec" command. To make this work
|
|
50
|
+
// the new CLI options default to the values used for Economic Committee
|
|
51
|
+
cmd.alias('ec');
|
|
52
|
+
cmd.option(
|
|
53
|
+
'--keyring-backend <os|file|test>',
|
|
54
|
+
`keyring's backend (os|file|test) (default "${defaultKeyring}")`,
|
|
55
|
+
defaultKeyring,
|
|
56
|
+
);
|
|
43
57
|
|
|
44
58
|
/** @param {string} literalOrName */
|
|
45
59
|
const normalizeAddress = literalOrName =>
|
|
46
|
-
normalizeAddressWithOptions(literalOrName, {
|
|
60
|
+
normalizeAddressWithOptions(literalOrName, {
|
|
61
|
+
// FIXME does not observe keyring-backend option, which isn't available during arg parsing
|
|
62
|
+
keyringBackend: defaultKeyring,
|
|
63
|
+
});
|
|
47
64
|
|
|
48
65
|
/** @type {(info: unknown, indent?: unknown) => boolean } */
|
|
49
66
|
const show = (info, indent) =>
|
|
@@ -62,17 +79,23 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
|
|
|
62
79
|
* given a sendFrom address; else print it.
|
|
63
80
|
*
|
|
64
81
|
* @param {{
|
|
65
|
-
* toOffer: (agoricNames: *, current: import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord | undefined) => OfferSpec,
|
|
82
|
+
* toOffer: (agoricNames: *, current: import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord | undefined) => OfferSpec,
|
|
66
83
|
* sendFrom?: string | undefined,
|
|
84
|
+
* keyringBackend: string,
|
|
67
85
|
* instanceName?: string,
|
|
68
86
|
* }} detail
|
|
69
87
|
* @param {Awaited<ReturnType<makeRpcUtils>>} [optUtils]
|
|
70
88
|
*/
|
|
71
|
-
const processOffer = async function (
|
|
89
|
+
const processOffer = async function (
|
|
90
|
+
{ toOffer, sendFrom, keyringBackend },
|
|
91
|
+
optUtils,
|
|
92
|
+
) {
|
|
72
93
|
const networkConfig = await getNetworkConfig(env);
|
|
73
94
|
const utils = await (optUtils || makeRpcUtils({ fetch }));
|
|
74
95
|
const { agoricNames, readLatestHead } = utils;
|
|
75
96
|
|
|
97
|
+
assert(keyringBackend, 'missing keyring-backend option');
|
|
98
|
+
|
|
76
99
|
let current;
|
|
77
100
|
if (sendFrom) {
|
|
78
101
|
current = await getCurrent(sendFrom, { readLatestHead });
|
|
@@ -90,7 +113,7 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
|
|
|
90
113
|
const result = await sendAction(
|
|
91
114
|
{ method: 'executeOffer', offer },
|
|
92
115
|
{
|
|
93
|
-
keyring: { backend:
|
|
116
|
+
keyring: { backend: keyringBackend },
|
|
94
117
|
from: sendFrom,
|
|
95
118
|
verbose: false,
|
|
96
119
|
...networkConfig,
|
|
@@ -127,29 +150,38 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
|
|
|
127
150
|
show(blockInfo);
|
|
128
151
|
};
|
|
129
152
|
|
|
130
|
-
|
|
131
|
-
.
|
|
153
|
+
cmd
|
|
154
|
+
.command('committee')
|
|
155
|
+
.description('accept invitation to join a committee')
|
|
156
|
+
.requiredOption(
|
|
157
|
+
'--name <string>',
|
|
158
|
+
'Committee instance name',
|
|
159
|
+
String,
|
|
160
|
+
'economicCommittee',
|
|
161
|
+
)
|
|
132
162
|
.option('--voter <number>', 'Voter number', Number, 0)
|
|
133
163
|
.option(
|
|
134
164
|
'--offerId <string>',
|
|
135
165
|
'Offer id',
|
|
136
166
|
String,
|
|
137
|
-
`
|
|
167
|
+
`gov-committee-${Date.now()}`,
|
|
138
168
|
)
|
|
139
169
|
.option(
|
|
140
170
|
'--send-from <name-or-address>',
|
|
141
171
|
'Send from address',
|
|
142
172
|
normalizeAddress,
|
|
143
173
|
)
|
|
144
|
-
.action(async function (opts) {
|
|
174
|
+
.action(async function (opts, options) {
|
|
175
|
+
const { name: instanceName } = opts;
|
|
176
|
+
|
|
145
177
|
/** @type {Parameters<typeof processOffer>[0]['toOffer']} */
|
|
146
178
|
const toOffer = (agoricNames, current) => {
|
|
147
|
-
const instance = agoricNames.instance
|
|
148
|
-
assert(instance, `missing
|
|
179
|
+
const instance = agoricNames.instance[instanceName];
|
|
180
|
+
assert(instance, `missing ${instanceName}`);
|
|
149
181
|
|
|
150
182
|
if (current) {
|
|
151
183
|
const found = findContinuingIds(current, agoricNames);
|
|
152
|
-
abortIfSeen(
|
|
184
|
+
abortIfSeen(instanceName, found);
|
|
153
185
|
}
|
|
154
186
|
|
|
155
187
|
return {
|
|
@@ -165,28 +197,37 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
|
|
|
165
197
|
|
|
166
198
|
await processOffer({
|
|
167
199
|
toOffer,
|
|
168
|
-
instanceName
|
|
169
|
-
|
|
200
|
+
instanceName,
|
|
201
|
+
sendFrom: opts.sendFrom,
|
|
202
|
+
keyringBackend: options.optsWithGlobals().keyringBackend,
|
|
170
203
|
});
|
|
171
204
|
});
|
|
172
205
|
|
|
173
|
-
|
|
206
|
+
cmd
|
|
207
|
+
.command('charter')
|
|
174
208
|
.description('accept the charter invitation')
|
|
175
|
-
.
|
|
209
|
+
.requiredOption(
|
|
210
|
+
'--name <string>',
|
|
211
|
+
'Charter instance name',
|
|
212
|
+
'economicCommitteeCharter',
|
|
213
|
+
)
|
|
214
|
+
.option('--offerId <string>', 'Offer id', String, `charter-${Date.now()}`)
|
|
176
215
|
.option(
|
|
177
216
|
'--send-from <name-or-address>',
|
|
178
217
|
'Send from address',
|
|
179
218
|
normalizeAddress,
|
|
180
219
|
)
|
|
181
|
-
.action(async function (opts) {
|
|
220
|
+
.action(async function (opts, options) {
|
|
221
|
+
const { name: instanceName } = opts;
|
|
222
|
+
|
|
182
223
|
/** @type {Parameters<typeof processOffer>[0]['toOffer']} */
|
|
183
224
|
const toOffer = (agoricNames, current) => {
|
|
184
|
-
const instance = agoricNames.instance
|
|
185
|
-
assert(instance, `missing
|
|
225
|
+
const instance = agoricNames.instance[instanceName];
|
|
226
|
+
assert(instance, `missing ${instanceName}`);
|
|
186
227
|
|
|
187
228
|
if (current) {
|
|
188
229
|
const found = findContinuingIds(current, agoricNames);
|
|
189
|
-
abortIfSeen(
|
|
230
|
+
abortIfSeen(instanceName, found);
|
|
190
231
|
}
|
|
191
232
|
|
|
192
233
|
return {
|
|
@@ -202,12 +243,14 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
|
|
|
202
243
|
|
|
203
244
|
await processOffer({
|
|
204
245
|
toOffer,
|
|
205
|
-
instanceName
|
|
206
|
-
|
|
246
|
+
instanceName,
|
|
247
|
+
sendFrom: opts.sendFrom,
|
|
248
|
+
keyringBackend: options.optsWithGlobals().keyringBackend,
|
|
207
249
|
});
|
|
208
250
|
});
|
|
209
251
|
|
|
210
|
-
|
|
252
|
+
cmd
|
|
253
|
+
.command('find-continuing-id')
|
|
211
254
|
.description('print id of specified voting continuing invitation')
|
|
212
255
|
.requiredOption(
|
|
213
256
|
'--from <name-or-address>',
|
|
@@ -233,7 +276,8 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
|
|
|
233
276
|
console.log(match.offerId);
|
|
234
277
|
});
|
|
235
278
|
|
|
236
|
-
|
|
279
|
+
cmd
|
|
280
|
+
.command('find-continuing-ids')
|
|
237
281
|
.description('print records of voting continuing invitations')
|
|
238
282
|
.requiredOption(
|
|
239
283
|
'--from <name-or-address>',
|
|
@@ -245,12 +289,27 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
|
|
|
245
289
|
const current = await getCurrent(opts.from, { readLatestHead });
|
|
246
290
|
|
|
247
291
|
const found = findContinuingIds(current, agoricNames);
|
|
248
|
-
|
|
292
|
+
for (const it of found) {
|
|
293
|
+
show({ ...it, address: opts.from });
|
|
294
|
+
}
|
|
249
295
|
});
|
|
250
296
|
|
|
251
|
-
|
|
252
|
-
.
|
|
253
|
-
.
|
|
297
|
+
cmd
|
|
298
|
+
.command('vote')
|
|
299
|
+
.description('vote on latest question')
|
|
300
|
+
.requiredOption(
|
|
301
|
+
'--instance <string>',
|
|
302
|
+
'Committee name under agoricNames.instances',
|
|
303
|
+
String,
|
|
304
|
+
'economicCommittee',
|
|
305
|
+
)
|
|
306
|
+
.requiredOption(
|
|
307
|
+
'--pathname <string>',
|
|
308
|
+
'Committee name under published.committees',
|
|
309
|
+
String,
|
|
310
|
+
'Economic_Committee',
|
|
311
|
+
)
|
|
312
|
+
.option('--offerId <number>', 'Offer id', String, `gov-vote-${Date.now()}`)
|
|
254
313
|
.requiredOption(
|
|
255
314
|
'--forPosition <number>',
|
|
256
315
|
'index of one position to vote for (within the question description.positions); ',
|
|
@@ -261,17 +320,18 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
|
|
|
261
320
|
'Send from address',
|
|
262
321
|
normalizeAddress,
|
|
263
322
|
)
|
|
264
|
-
.action(async function (opts) {
|
|
323
|
+
.action(async function (opts, options) {
|
|
265
324
|
const utils = await makeRpcUtils({ fetch });
|
|
266
325
|
const { readLatestHead } = utils;
|
|
267
326
|
|
|
268
327
|
const info = await readLatestHead(
|
|
269
|
-
|
|
328
|
+
`published.committees.${opts.pathname}.latestQuestion`,
|
|
270
329
|
).catch(err => {
|
|
271
330
|
throw new CommanderError(1, 'VSTORAGE_FAILURE', err.message);
|
|
272
331
|
});
|
|
332
|
+
|
|
273
333
|
// XXX runtime shape-check
|
|
274
|
-
const questionDesc = /** @type {
|
|
334
|
+
const questionDesc = /** @type {QuestionDetails} */ (info);
|
|
275
335
|
|
|
276
336
|
// TODO support multiple position arguments
|
|
277
337
|
const chosenPositions = [questionDesc.positions[opts.forPosition]];
|
|
@@ -280,9 +340,7 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
|
|
|
280
340
|
/** @type {Parameters<typeof processOffer>[0]['toOffer']} */
|
|
281
341
|
const toOffer = (agoricNames, current) => {
|
|
282
342
|
const cont = current ? findContinuingIds(current, agoricNames) : [];
|
|
283
|
-
const votingRight = cont.find(
|
|
284
|
-
it => it.instance === agoricNames.instance.economicCommittee,
|
|
285
|
-
);
|
|
343
|
+
const votingRight = cont.find(it => it.instanceName === opts.instance);
|
|
286
344
|
if (!votingRight) {
|
|
287
345
|
console.debug('continuing ids', cont, 'for', current);
|
|
288
346
|
throw new CommanderError(
|
|
@@ -307,8 +365,89 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {
|
|
|
307
365
|
};
|
|
308
366
|
};
|
|
309
367
|
|
|
310
|
-
await processOffer(
|
|
368
|
+
await processOffer(
|
|
369
|
+
{
|
|
370
|
+
toOffer,
|
|
371
|
+
sendFrom: opts.sendFrom,
|
|
372
|
+
keyringBackend: options.optsWithGlobals().keyringBackend,
|
|
373
|
+
},
|
|
374
|
+
utils,
|
|
375
|
+
);
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
cmd
|
|
379
|
+
.command('proposePauseOffers')
|
|
380
|
+
.description('propose a vote to pause offers')
|
|
381
|
+
.option(
|
|
382
|
+
'--send-from <name-or-address>',
|
|
383
|
+
'Send from address',
|
|
384
|
+
normalizeAddress,
|
|
385
|
+
)
|
|
386
|
+
.option(
|
|
387
|
+
'--offerId <string>',
|
|
388
|
+
'Offer id',
|
|
389
|
+
String,
|
|
390
|
+
`proposePauseOffers-${Date.now()}`,
|
|
391
|
+
)
|
|
392
|
+
.requiredOption(
|
|
393
|
+
'--instance <string>',
|
|
394
|
+
'name of governed instance in agoricNames',
|
|
395
|
+
)
|
|
396
|
+
.requiredOption(
|
|
397
|
+
'--substring <string>',
|
|
398
|
+
'an offer string to pause (can be repeated)',
|
|
399
|
+
collectValues,
|
|
400
|
+
[],
|
|
401
|
+
)
|
|
402
|
+
.option(
|
|
403
|
+
'--deadline <minutes>',
|
|
404
|
+
'minutes from now to close the vote',
|
|
405
|
+
Number,
|
|
406
|
+
1,
|
|
407
|
+
)
|
|
408
|
+
.action(async function (opts, options) {
|
|
409
|
+
const { instance: instanceName } = opts;
|
|
410
|
+
|
|
411
|
+
/** @type {Parameters<typeof processOffer>[0]['toOffer']} */
|
|
412
|
+
const toOffer = (agoricNames, current) => {
|
|
413
|
+
const instance = agoricNames.instance[instanceName];
|
|
414
|
+
assert(instance, `missing ${instanceName}`);
|
|
415
|
+
assert(current, 'missing current wallet');
|
|
416
|
+
|
|
417
|
+
const known = findContinuingIds(current, agoricNames);
|
|
418
|
+
|
|
419
|
+
assert(known, 'could not find committee acceptance offer id');
|
|
420
|
+
|
|
421
|
+
// TODO magic string
|
|
422
|
+
const match = known.find(
|
|
423
|
+
r => r.description === 'charter member invitation',
|
|
424
|
+
);
|
|
425
|
+
assert(match, 'no offer found for charter member invitation');
|
|
426
|
+
|
|
427
|
+
return {
|
|
428
|
+
id: opts.offerId,
|
|
429
|
+
invitationSpec: {
|
|
430
|
+
source: 'continuing',
|
|
431
|
+
previousOffer: match.offerId,
|
|
432
|
+
invitationMakerName: 'VoteOnPauseOffers',
|
|
433
|
+
// ( instance, strings list, timer deadline seconds )
|
|
434
|
+
invitationArgs: harden([
|
|
435
|
+
instance,
|
|
436
|
+
opts.substring,
|
|
437
|
+
BigInt(opts.deadline * 60 + Math.round(Date.now() / 1000)),
|
|
438
|
+
]),
|
|
439
|
+
},
|
|
440
|
+
proposal: {},
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
await processOffer({
|
|
445
|
+
toOffer,
|
|
446
|
+
instanceName,
|
|
447
|
+
sendFrom: opts.sendFrom,
|
|
448
|
+
keyringBackend: options.optsWithGlobals().keyringBackend,
|
|
449
|
+
});
|
|
311
450
|
});
|
|
312
451
|
|
|
313
|
-
return
|
|
452
|
+
return cmd;
|
|
314
453
|
};
|
package/src/commands/inter.js
CHANGED
|
@@ -11,11 +11,6 @@ import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
|
|
|
11
11
|
import { objectMap } from '@agoric/internal';
|
|
12
12
|
import { M, matches } from '@agoric/store';
|
|
13
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
|
-
|
|
19
14
|
import { normalizeAddressWithOptions, pollBlocks } from '../lib/chain.js';
|
|
20
15
|
import {
|
|
21
16
|
asBoardRemote,
|
|
@@ -25,7 +20,6 @@ import {
|
|
|
25
20
|
import { getNetworkConfig } from '../lib/rpc.js';
|
|
26
21
|
import {
|
|
27
22
|
getCurrent,
|
|
28
|
-
makeParseAmount,
|
|
29
23
|
makeWalletUtils,
|
|
30
24
|
outputActionAndHint,
|
|
31
25
|
sendAction,
|
|
@@ -40,7 +34,7 @@ const bidInvitationShape = harden({
|
|
|
40
34
|
});
|
|
41
35
|
|
|
42
36
|
/** @typedef {import('@agoric/vats/tools/board-utils.js').VBankAssetDetail } AssetDescriptor */
|
|
43
|
-
/** @typedef {import('@agoric/smart-wallet/src/smartWallet').TryExitOfferAction } TryExitOfferAction */
|
|
37
|
+
/** @typedef {import('@agoric/smart-wallet/src/smartWallet.js').TryExitOfferAction } TryExitOfferAction */
|
|
44
38
|
/** @typedef {import('@agoric/inter-protocol/src/auction/auctionBook.js').OfferSpec} BidSpec */
|
|
45
39
|
/** @typedef {import('@agoric/inter-protocol/src/auction/scheduler.js').ScheduleNotification} ScheduleNotification */
|
|
46
40
|
/** @typedef {import('@agoric/inter-protocol/src/auction/auctionBook.js').BookDataNotification} BookDataNotification */
|
|
@@ -71,12 +65,12 @@ const makeFormatters = assets => {
|
|
|
71
65
|
r4(100 - (Number(r.numerator.value) / Number(r.denominator.value)) * 100);
|
|
72
66
|
|
|
73
67
|
// XXX real TimeMath.absValue requires real Remotable timerBrand
|
|
74
|
-
/** @param {import('@agoric/time
|
|
68
|
+
/** @param {import('@agoric/time').Timestamp} ts */
|
|
75
69
|
const absValue = ts => (typeof ts === 'bigint' ? ts : ts.absValue);
|
|
76
70
|
|
|
77
|
-
/** @param {import('@agoric/time
|
|
71
|
+
/** @param {import('@agoric/time').Timestamp} tr */
|
|
78
72
|
const absTime = tr => new Date(Number(absValue(tr)) * 1000).toISOString();
|
|
79
|
-
/** @param {import('@agoric/time
|
|
73
|
+
/** @param {import('@agoric/time').RelativeTimeRecord} tr */
|
|
80
74
|
const relTime = tr =>
|
|
81
75
|
new Date(Number(tr.relValue) * 1000).toISOString().slice(11, 19);
|
|
82
76
|
|
|
@@ -88,7 +82,7 @@ const makeFormatters = assets => {
|
|
|
88
82
|
* @param {(_: T) => string} f
|
|
89
83
|
* @returns { (x: T | null | undefined ) => string | undefined }
|
|
90
84
|
*/
|
|
91
|
-
const maybe = f => x => x ? f(x) : undefined;
|
|
85
|
+
const maybe = f => x => (x ? f(x) : undefined);
|
|
92
86
|
|
|
93
87
|
return {
|
|
94
88
|
amount,
|
|
@@ -108,7 +102,7 @@ const makeFormatters = assets => {
|
|
|
108
102
|
* Dynamic check that an OfferStatus is also a BidSpec.
|
|
109
103
|
*
|
|
110
104
|
* @param {import('@agoric/smart-wallet/src/offers.js').OfferStatus} offerStatus
|
|
111
|
-
* @param {
|
|
105
|
+
* @param {import('../lib/wallet.js').AgoricNamesRemotes} agoricNames
|
|
112
106
|
* @param {typeof console.warn} warn
|
|
113
107
|
* returns null if offerStatus is not a BidSpec
|
|
114
108
|
*/
|
|
@@ -206,6 +200,10 @@ export const makeInterCommand = (
|
|
|
206
200
|
const interCmd = createCommand('inter')
|
|
207
201
|
.description('Inter Protocol commands for liquidation bidding etc.')
|
|
208
202
|
.option('--home <dir>', 'agd CosmosSDK application home directory')
|
|
203
|
+
.option(
|
|
204
|
+
'--fees <amount>',
|
|
205
|
+
'set fees for transaction broadcast (e.g. 5000ubld)',
|
|
206
|
+
)
|
|
209
207
|
.option(
|
|
210
208
|
'--keyring-backend <os|file|test>',
|
|
211
209
|
`keyring's backend (os|file|test) (default "${
|
|
@@ -238,7 +236,6 @@ export const makeInterCommand = (
|
|
|
238
236
|
try {
|
|
239
237
|
// XXX pass fetch to getNetworkConfig() explicitly
|
|
240
238
|
// await null above makes this await safe
|
|
241
|
-
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
242
239
|
const networkConfig = await getNetworkConfig(env);
|
|
243
240
|
return makeWalletUtils({ fetch, execFileSync, delay }, networkConfig);
|
|
244
241
|
} catch (err) {
|
|
@@ -339,10 +336,10 @@ inter auction status
|
|
|
339
336
|
const { networkConfig, agoricNames, pollOffer } = tools;
|
|
340
337
|
const io = { ...networkConfig, execFileSync, delay, stdout };
|
|
341
338
|
|
|
342
|
-
const { home, keyringBackend: backend } = interCmd.opts();
|
|
339
|
+
const { home, keyringBackend: backend, fees } = interCmd.opts();
|
|
343
340
|
const result = await sendAction(
|
|
344
341
|
{ method: 'executeOffer', offer },
|
|
345
|
-
{ keyring: { home, backend }, from, verbose: false, dryRun, ...io },
|
|
342
|
+
{ keyring: { home, backend }, from, fees, verbose: false, dryRun, ...io },
|
|
346
343
|
);
|
|
347
344
|
if (dryRun) {
|
|
348
345
|
return;
|
|
@@ -416,14 +413,7 @@ inter auction status
|
|
|
416
413
|
async ({ generateOnly, dryRun, ...opts }) => {
|
|
417
414
|
const tools = await tryMakeUtils();
|
|
418
415
|
|
|
419
|
-
const
|
|
420
|
-
tools.agoricNames,
|
|
421
|
-
msg => new InvalidArgumentError(msg),
|
|
422
|
-
);
|
|
423
|
-
const offer = Offers.auction.Bid(tools.agoricNames.brand, {
|
|
424
|
-
...opts,
|
|
425
|
-
parseAmount,
|
|
426
|
-
});
|
|
416
|
+
const offer = Offers.auction.Bid(tools.agoricNames, opts);
|
|
427
417
|
|
|
428
418
|
if (generateOnly) {
|
|
429
419
|
outputActionAndHint(
|
|
@@ -464,14 +454,7 @@ inter auction status
|
|
|
464
454
|
async ({ generateOnly, ...opts }) => {
|
|
465
455
|
const tools = await tryMakeUtils();
|
|
466
456
|
|
|
467
|
-
const
|
|
468
|
-
tools.agoricNames,
|
|
469
|
-
msg => new InvalidArgumentError(msg),
|
|
470
|
-
);
|
|
471
|
-
const offer = Offers.auction.Bid(tools.agoricNames.brand, {
|
|
472
|
-
...opts,
|
|
473
|
-
parseAmount,
|
|
474
|
-
});
|
|
457
|
+
const offer = Offers.auction.Bid(tools.agoricNames, opts);
|
|
475
458
|
if (generateOnly) {
|
|
476
459
|
outputActionAndHint(
|
|
477
460
|
{ method: 'executeOffer', offer },
|
package/src/commands/oracle.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
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
3
|
/* global fetch, setTimeout, process */
|
|
@@ -9,6 +7,7 @@ import { Nat } from '@endo/nat';
|
|
|
9
7
|
import { Command } from 'commander';
|
|
10
8
|
import * as cp from 'child_process';
|
|
11
9
|
import { inspect } from 'util';
|
|
10
|
+
import { oracleBrandFeedName } from '@agoric/inter-protocol/src/proposals/utils.js';
|
|
12
11
|
import { normalizeAddressWithOptions } from '../lib/chain.js';
|
|
13
12
|
import { getNetworkConfig, makeRpcUtils, storageHelper } from '../lib/rpc.js';
|
|
14
13
|
import {
|
|
@@ -16,6 +15,7 @@ import {
|
|
|
16
15
|
makeWalletUtils,
|
|
17
16
|
outputAction,
|
|
18
17
|
sendAction,
|
|
18
|
+
sendHint,
|
|
19
19
|
} from '../lib/wallet.js';
|
|
20
20
|
import { bigintReplacer } from '../lib/format.js';
|
|
21
21
|
|
|
@@ -71,13 +71,18 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
71
71
|
env.AGORIC_KEYRING_BACKEND,
|
|
72
72
|
);
|
|
73
73
|
|
|
74
|
+
const normalizeAddress = literalOrName =>
|
|
75
|
+
normalizeAddressWithOptions(literalOrName, oracle.opts(), {
|
|
76
|
+
execFileSync,
|
|
77
|
+
});
|
|
78
|
+
|
|
74
79
|
const rpcTools = async () => {
|
|
75
80
|
// XXX pass fetch to getNetworkConfig() explicitly
|
|
76
81
|
const networkConfig = await getNetworkConfig(env);
|
|
77
82
|
const utils = await makeRpcUtils({ fetch });
|
|
78
83
|
|
|
79
84
|
const lookupPriceAggregatorInstance = ([brandIn, brandOut]) => {
|
|
80
|
-
const name =
|
|
85
|
+
const name = oracleBrandFeedName(brandIn, brandOut);
|
|
81
86
|
const instance = utils.agoricNames.instance[name];
|
|
82
87
|
if (!instance) {
|
|
83
88
|
logger.debug('known instances:', utils.agoricNames.instance);
|
|
@@ -124,7 +129,7 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
124
129
|
offer,
|
|
125
130
|
});
|
|
126
131
|
|
|
127
|
-
console.warn(
|
|
132
|
+
console.warn(sendHint);
|
|
128
133
|
});
|
|
129
134
|
|
|
130
135
|
oracle
|
|
@@ -159,10 +164,10 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
159
164
|
offer,
|
|
160
165
|
});
|
|
161
166
|
|
|
162
|
-
console.warn(
|
|
167
|
+
console.warn(sendHint);
|
|
163
168
|
});
|
|
164
169
|
|
|
165
|
-
const findOracleCap = async (from, readLatestHead) => {
|
|
170
|
+
const findOracleCap = async (instance, from, readLatestHead) => {
|
|
166
171
|
const current = await getCurrent(from, { readLatestHead });
|
|
167
172
|
|
|
168
173
|
const { offerToUsedInvitation: entries } = /** @type {any} */ (current);
|
|
@@ -170,8 +175,8 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
170
175
|
|
|
171
176
|
for (const [offerId, { value }] of entries) {
|
|
172
177
|
/** @type {{ description: string, instance: unknown }[]} */
|
|
173
|
-
const [{ description }] = value;
|
|
174
|
-
if (description === 'oracle invitation') {
|
|
178
|
+
const [{ description, instance: candidate }] = value;
|
|
179
|
+
if (description === 'oracle invitation' && candidate === instance) {
|
|
175
180
|
return offerId;
|
|
176
181
|
}
|
|
177
182
|
}
|
|
@@ -180,11 +185,22 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
180
185
|
oracle
|
|
181
186
|
.command('find-continuing-id')
|
|
182
187
|
.description('print id of specified oracle continuing invitation')
|
|
183
|
-
.requiredOption(
|
|
188
|
+
.requiredOption(
|
|
189
|
+
'--from <address>',
|
|
190
|
+
'wallet address literal or name',
|
|
191
|
+
normalizeAddress,
|
|
192
|
+
)
|
|
193
|
+
.requiredOption(
|
|
194
|
+
'--pair [brandIn.brandOut]',
|
|
195
|
+
'token pair (brandIn.brandOut)',
|
|
196
|
+
s => s.split('.'),
|
|
197
|
+
)
|
|
184
198
|
.action(async opts => {
|
|
185
|
-
const { readLatestHead } =
|
|
199
|
+
const { readLatestHead, lookupPriceAggregatorInstance } =
|
|
200
|
+
await rpcTools();
|
|
201
|
+
const instance = lookupPriceAggregatorInstance(opts.pair);
|
|
186
202
|
|
|
187
|
-
const offerId = await findOracleCap(opts.from, readLatestHead);
|
|
203
|
+
const offerId = await findOracleCap(instance, opts.from, readLatestHead);
|
|
188
204
|
if (!offerId) {
|
|
189
205
|
console.error('No continuing ids found');
|
|
190
206
|
}
|
|
@@ -212,11 +228,6 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
212
228
|
console.log(inspect(capDatas[0], { depth: 10, colors: true }));
|
|
213
229
|
});
|
|
214
230
|
|
|
215
|
-
/** @param {string} literalOrName */
|
|
216
|
-
const normalizeAddress = literalOrName =>
|
|
217
|
-
normalizeAddressWithOptions(literalOrName, oracle.opts(), {
|
|
218
|
-
execFileSync,
|
|
219
|
-
});
|
|
220
231
|
const show = (info, indent = false) =>
|
|
221
232
|
stdout.write(
|
|
222
233
|
`${JSON.stringify(info, bigintReplacer, indent ? 2 : undefined)}\n`,
|
|
@@ -250,7 +261,8 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
250
261
|
* }}
|
|
251
262
|
*/ { pair, keys, price },
|
|
252
263
|
) => {
|
|
253
|
-
const { readLatestHead, networkConfig } =
|
|
264
|
+
const { readLatestHead, networkConfig, lookupPriceAggregatorInstance } =
|
|
265
|
+
await rpcTools();
|
|
254
266
|
const wutil = await makeWalletUtils(
|
|
255
267
|
{ fetch, execFileSync, delay },
|
|
256
268
|
networkConfig,
|
|
@@ -308,9 +320,12 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
308
320
|
console.warn(err);
|
|
309
321
|
});
|
|
310
322
|
|
|
323
|
+
const instance = lookupPriceAggregatorInstance(pair);
|
|
324
|
+
|
|
311
325
|
console.error('pushPrice from each:', keyOrder);
|
|
312
326
|
for await (const from of keyOrder) {
|
|
313
327
|
const oracleAdminAcceptOfferId = await findOracleCap(
|
|
328
|
+
instance,
|
|
314
329
|
from,
|
|
315
330
|
readLatestHead,
|
|
316
331
|
);
|
package/src/commands/perf.js
CHANGED
package/src/commands/psm.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
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
3
|
/* global fetch, process */
|
|
@@ -153,15 +151,17 @@ export const makePsmCommand = logger => {
|
|
|
153
151
|
.option('--giveMinted <DOLLARS>', 'amount of minted tokens to give', Number)
|
|
154
152
|
.option('--feePct [%]', 'Gas fee percentage', Number)
|
|
155
153
|
.option('--offerId <string>', 'Offer id', String, `swap-${Date.now()}`)
|
|
156
|
-
.action(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
154
|
+
.action(
|
|
155
|
+
async function (
|
|
156
|
+
/** @type {Parameters<typeof Offers.psm.swap>[2]} */ opts,
|
|
157
|
+
) {
|
|
158
|
+
console.warn('running with options', opts);
|
|
159
|
+
const { agoricNames, lookupPsmInstance } = await rpcTools();
|
|
160
|
+
const instance = await lookupPsmInstance(opts.pair);
|
|
161
|
+
const offer = Offers.psm.swap(agoricNames, instance, opts);
|
|
162
|
+
outputExecuteOfferAction(offer);
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
165
|
|
|
166
166
|
psm
|
|
167
167
|
.command('proposePauseOffers')
|
|
@@ -216,8 +216,6 @@ export const makePsmCommand = logger => {
|
|
|
216
216
|
};
|
|
217
217
|
|
|
218
218
|
outputExecuteOfferAction(offer);
|
|
219
|
-
|
|
220
|
-
console.warn('Now execute the prepared offer');
|
|
221
219
|
});
|
|
222
220
|
|
|
223
221
|
psm
|
|
@@ -272,8 +270,6 @@ export const makePsmCommand = logger => {
|
|
|
272
270
|
};
|
|
273
271
|
|
|
274
272
|
outputExecuteOfferAction(offer);
|
|
275
|
-
|
|
276
|
-
console.warn('Now execute the prepared offer');
|
|
277
273
|
});
|
|
278
274
|
|
|
279
275
|
return psm;
|