agoric 0.21.2-dev-5dc325b.0 → 0.21.2-getting-started-dev-d127d1d.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/CHANGELOG.md +1086 -0
- package/package.json +28 -39
- package/src/bin-agops.js +8 -9
- package/src/chain-config.js +10 -11
- package/src/commands/auction.js +2 -5
- package/src/commands/{gov.js → ec.js} +37 -176
- package/src/commands/inter.js +27 -10
- package/src/commands/oracle.js +3 -2
- package/src/commands/perf.js +2 -0
- package/src/commands/psm.js +11 -11
- package/src/commands/reserve.js +2 -1
- package/src/commands/test-upgrade.js +2 -7
- package/src/commands/vaults.js +5 -3
- package/src/helpers.js +0 -1
- package/src/init.js +8 -5
- package/src/install.js +1 -1
- package/src/lib/chain.js +3 -13
- package/src/lib/format.js +11 -6
- package/src/lib/rpc.js +3 -4
- package/src/lib/wallet.js +44 -2
- package/src/main-publish.js +2 -1
- package/src/main.js +2 -2
- package/src/open.js +6 -6
- package/src/publish.js +3 -1
- package/src/sdk-package-names.js +5 -6
- package/src/set-defaults.js +0 -1
- package/src/start.js +57 -51
package/src/commands/inter.js
CHANGED
|
@@ -11,6 +11,11 @@ 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
|
+
|
|
14
19
|
import { normalizeAddressWithOptions, pollBlocks } from '../lib/chain.js';
|
|
15
20
|
import {
|
|
16
21
|
asBoardRemote,
|
|
@@ -20,6 +25,7 @@ import {
|
|
|
20
25
|
import { getNetworkConfig } from '../lib/rpc.js';
|
|
21
26
|
import {
|
|
22
27
|
getCurrent,
|
|
28
|
+
makeParseAmount,
|
|
23
29
|
makeWalletUtils,
|
|
24
30
|
outputActionAndHint,
|
|
25
31
|
sendAction,
|
|
@@ -82,7 +88,7 @@ const makeFormatters = assets => {
|
|
|
82
88
|
* @param {(_: T) => string} f
|
|
83
89
|
* @returns { (x: T | null | undefined ) => string | undefined }
|
|
84
90
|
*/
|
|
85
|
-
const maybe = f => x =>
|
|
91
|
+
const maybe = f => x => x ? f(x) : undefined;
|
|
86
92
|
|
|
87
93
|
return {
|
|
88
94
|
amount,
|
|
@@ -102,7 +108,7 @@ const makeFormatters = assets => {
|
|
|
102
108
|
* Dynamic check that an OfferStatus is also a BidSpec.
|
|
103
109
|
*
|
|
104
110
|
* @param {import('@agoric/smart-wallet/src/offers.js').OfferStatus} offerStatus
|
|
105
|
-
* @param {import('../lib/
|
|
111
|
+
* @param {Awaited<ReturnType<import('../lib/rpc').makeAgoricNames>>} agoricNames
|
|
106
112
|
* @param {typeof console.warn} warn
|
|
107
113
|
* returns null if offerStatus is not a BidSpec
|
|
108
114
|
*/
|
|
@@ -200,10 +206,6 @@ export const makeInterCommand = (
|
|
|
200
206
|
const interCmd = createCommand('inter')
|
|
201
207
|
.description('Inter Protocol commands for liquidation bidding etc.')
|
|
202
208
|
.option('--home <dir>', 'agd CosmosSDK application home directory')
|
|
203
|
-
.option(
|
|
204
|
-
'--fees <amount>',
|
|
205
|
-
'set fees for transaction broadcast (e.g. 5000ubld)',
|
|
206
|
-
)
|
|
207
209
|
.option(
|
|
208
210
|
'--keyring-backend <os|file|test>',
|
|
209
211
|
`keyring's backend (os|file|test) (default "${
|
|
@@ -236,6 +238,7 @@ export const makeInterCommand = (
|
|
|
236
238
|
try {
|
|
237
239
|
// XXX pass fetch to getNetworkConfig() explicitly
|
|
238
240
|
// await null above makes this await safe
|
|
241
|
+
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
239
242
|
const networkConfig = await getNetworkConfig(env);
|
|
240
243
|
return makeWalletUtils({ fetch, execFileSync, delay }, networkConfig);
|
|
241
244
|
} catch (err) {
|
|
@@ -336,10 +339,10 @@ inter auction status
|
|
|
336
339
|
const { networkConfig, agoricNames, pollOffer } = tools;
|
|
337
340
|
const io = { ...networkConfig, execFileSync, delay, stdout };
|
|
338
341
|
|
|
339
|
-
const { home, keyringBackend: backend
|
|
342
|
+
const { home, keyringBackend: backend } = interCmd.opts();
|
|
340
343
|
const result = await sendAction(
|
|
341
344
|
{ method: 'executeOffer', offer },
|
|
342
|
-
{ keyring: { home, backend }, from,
|
|
345
|
+
{ keyring: { home, backend }, from, verbose: false, dryRun, ...io },
|
|
343
346
|
);
|
|
344
347
|
if (dryRun) {
|
|
345
348
|
return;
|
|
@@ -413,7 +416,14 @@ inter auction status
|
|
|
413
416
|
async ({ generateOnly, dryRun, ...opts }) => {
|
|
414
417
|
const tools = await tryMakeUtils();
|
|
415
418
|
|
|
416
|
-
const
|
|
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
|
+
});
|
|
417
427
|
|
|
418
428
|
if (generateOnly) {
|
|
419
429
|
outputActionAndHint(
|
|
@@ -454,7 +464,14 @@ inter auction status
|
|
|
454
464
|
async ({ generateOnly, ...opts }) => {
|
|
455
465
|
const tools = await tryMakeUtils();
|
|
456
466
|
|
|
457
|
-
const
|
|
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
|
+
});
|
|
458
475
|
if (generateOnly) {
|
|
459
476
|
outputActionAndHint(
|
|
460
477
|
{ method: 'executeOffer', offer },
|
package/src/commands/oracle.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable no-await-in-loop */
|
|
2
|
+
/* eslint-disable @jessie.js/no-nested-await */
|
|
1
3
|
// @ts-check
|
|
2
4
|
/* eslint-disable func-names */
|
|
3
5
|
/* global fetch, setTimeout, process */
|
|
@@ -7,7 +9,6 @@ import { Nat } from '@endo/nat';
|
|
|
7
9
|
import { Command } from 'commander';
|
|
8
10
|
import * as cp from 'child_process';
|
|
9
11
|
import { inspect } from 'util';
|
|
10
|
-
import { oracleBrandFeedName } from '@agoric/inter-protocol/src/proposals/utils.js';
|
|
11
12
|
import { normalizeAddressWithOptions } from '../lib/chain.js';
|
|
12
13
|
import { getNetworkConfig, makeRpcUtils, storageHelper } from '../lib/rpc.js';
|
|
13
14
|
import {
|
|
@@ -76,7 +77,7 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
76
77
|
const utils = await makeRpcUtils({ fetch });
|
|
77
78
|
|
|
78
79
|
const lookupPriceAggregatorInstance = ([brandIn, brandOut]) => {
|
|
79
|
-
const name =
|
|
80
|
+
const name = `${brandIn}-${brandOut} price feed`;
|
|
80
81
|
const instance = utils.agoricNames.instance[name];
|
|
81
82
|
if (!instance) {
|
|
82
83
|
logger.debug('known instances:', utils.agoricNames.instance);
|
package/src/commands/perf.js
CHANGED
package/src/commands/psm.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable no-await-in-loop */
|
|
2
|
+
/* eslint-disable @jessie.js/no-nested-await */
|
|
1
3
|
// @ts-check
|
|
2
4
|
/* eslint-disable func-names */
|
|
3
5
|
/* global fetch, process */
|
|
@@ -151,17 +153,15 @@ export const makePsmCommand = logger => {
|
|
|
151
153
|
.option('--giveMinted <DOLLARS>', 'amount of minted tokens to give', Number)
|
|
152
154
|
.option('--feePct [%]', 'Gas fee percentage', Number)
|
|
153
155
|
.option('--offerId <string>', 'Offer id', String, `swap-${Date.now()}`)
|
|
154
|
-
.action(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
},
|
|
164
|
-
);
|
|
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
|
+
});
|
|
165
165
|
|
|
166
166
|
psm
|
|
167
167
|
.command('proposePauseOffers')
|
package/src/commands/reserve.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @jessie.js/no-nested-await */
|
|
1
2
|
// @ts-check
|
|
2
3
|
/* eslint-disable func-names */
|
|
3
4
|
/* global fetch, process */
|
|
@@ -31,7 +32,7 @@ export const makeReserveCommand = (_logger, io = {}) => {
|
|
|
31
32
|
async ({ collateralBrand, ...opts }) => {
|
|
32
33
|
const { agoricNames } = await makeRpcUtils({ fetch });
|
|
33
34
|
|
|
34
|
-
const offer = Offers.reserve.AddCollateral(agoricNames, {
|
|
35
|
+
const offer = Offers.reserve.AddCollateral(agoricNames.brand, {
|
|
35
36
|
collateralBrandKey: collateralBrand,
|
|
36
37
|
...opts,
|
|
37
38
|
});
|
|
@@ -38,6 +38,7 @@ 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
|
|
41
42
|
const networkConfig = await getNetworkConfig(env);
|
|
42
43
|
return makeWalletUtils({ fetch, execFileSync, delay }, networkConfig);
|
|
43
44
|
} catch (err) {
|
|
@@ -82,13 +83,7 @@ export const makeTestCommand = (
|
|
|
82
83
|
publicInvitationMaker: 'makeInvitation',
|
|
83
84
|
},
|
|
84
85
|
proposal: {
|
|
85
|
-
want: {
|
|
86
|
-
Tokens: {
|
|
87
|
-
// @ts-expect-error BoardRemote not a Brand object
|
|
88
|
-
brand: agoricNames.brand.GoodStuff,
|
|
89
|
-
value: 32n,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
86
|
+
want: { Tokens: { brand: agoricNames.brand.GoodStuff, value: 32n } },
|
|
92
87
|
},
|
|
93
88
|
};
|
|
94
89
|
const result = await sendAction(
|
package/src/commands/vaults.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable no-await-in-loop */
|
|
2
|
+
/* eslint-disable @jessie.js/no-nested-await */
|
|
1
3
|
// @ts-check
|
|
2
4
|
/* eslint-disable func-names */
|
|
3
5
|
/* global fetch, process */
|
|
@@ -63,7 +65,7 @@ export const makeVaultsCommand = logger => {
|
|
|
63
65
|
logger.warn('running with options', opts);
|
|
64
66
|
const { agoricNames } = await makeRpcUtils({ fetch });
|
|
65
67
|
|
|
66
|
-
const offer = Offers.vaults.OpenVault(agoricNames, {
|
|
68
|
+
const offer = Offers.vaults.OpenVault(agoricNames.brand, {
|
|
67
69
|
giveCollateral: opts.giveCollateral,
|
|
68
70
|
wantMinted: opts.wantMinted,
|
|
69
71
|
offerId: opts.offerId,
|
|
@@ -104,7 +106,7 @@ export const makeVaultsCommand = logger => {
|
|
|
104
106
|
);
|
|
105
107
|
|
|
106
108
|
const offer = Offers.vaults.AdjustBalances(
|
|
107
|
-
agoricNames,
|
|
109
|
+
agoricNames.brand,
|
|
108
110
|
{
|
|
109
111
|
giveCollateral: opts.giveCollateral,
|
|
110
112
|
wantCollateral: opts.wantCollateral,
|
|
@@ -145,7 +147,7 @@ export const makeVaultsCommand = logger => {
|
|
|
145
147
|
);
|
|
146
148
|
|
|
147
149
|
const offer = Offers.vaults.CloseVault(
|
|
148
|
-
agoricNames,
|
|
150
|
+
agoricNames.brand,
|
|
149
151
|
{
|
|
150
152
|
giveMinted: opts.giveMinted,
|
|
151
153
|
offerId: opts.offerId,
|
package/src/helpers.js
CHANGED
|
@@ -41,7 +41,6 @@ export const makePspawn = ({
|
|
|
41
41
|
* @param {string} cmd command name to run
|
|
42
42
|
* @param {Array<string>} cargs arguments to the command
|
|
43
43
|
* @param {object} param2
|
|
44
|
-
* @param {string} [param2.cwd]
|
|
45
44
|
* @param {string | [string, string, string]} [param2.stdio] standard IO
|
|
46
45
|
* specification
|
|
47
46
|
* @param {Record<string, string | undefined>} [param2.env] environment
|
package/src/init.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { makePspawn } from './helpers.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
// Ambient types. Needed only for dev but this does a runtime import.
|
|
5
|
+
// https://github.com/Agoric/agoric-sdk/issues/6512
|
|
6
|
+
import '@endo/captp/src/types.js';
|
|
7
|
+
import '@agoric/swingset-vat/exported.js';
|
|
8
|
+
import '@agoric/swingset-vat/src/vats/network/types.js';
|
|
7
9
|
|
|
8
10
|
// Use either an absolute template URL, or find it relative to DAPP_URL_BASE.
|
|
9
11
|
const gitURL = (relativeOrAbsoluteURL, base) => {
|
|
@@ -38,10 +40,9 @@ export default async function initMain(_progname, rawArgs, priv, opts) {
|
|
|
38
40
|
dappBranch = ['-b', opts.dappBranch];
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
const shallow = ['--depth', '1', '--shallow-submodules'];
|
|
42
43
|
const exitStatus = await pspawn(
|
|
43
44
|
'git',
|
|
44
|
-
['clone', '--origin=upstream',
|
|
45
|
+
['clone', '--origin=upstream', dappURL, DIR, ...dappBranch],
|
|
45
46
|
{
|
|
46
47
|
stdio: 'inherit',
|
|
47
48
|
},
|
|
@@ -59,6 +60,7 @@ export default async function initMain(_progname, rawArgs, priv, opts) {
|
|
|
59
60
|
const path = `${DIR}/${dir}package.json`;
|
|
60
61
|
log('rewriting ', path);
|
|
61
62
|
|
|
63
|
+
// eslint-disable-next-line no-await-in-loop
|
|
62
64
|
const contents = await fs.readFile(path, 'utf-8');
|
|
63
65
|
const pkg = JSON.parse(contents.replace(/@DIR@/g, DIR));
|
|
64
66
|
if (dir === '') {
|
|
@@ -72,6 +74,7 @@ export default async function initMain(_progname, rawArgs, priv, opts) {
|
|
|
72
74
|
pkg.name = `${DIR}${pkg.name.substr(topLevelName.length)}`;
|
|
73
75
|
const json = JSON.stringify(pkg, undefined, 2);
|
|
74
76
|
|
|
77
|
+
// eslint-disable-next-line no-await-in-loop
|
|
75
78
|
await fs.writeFile(path, json);
|
|
76
79
|
}
|
|
77
80
|
|
package/src/install.js
CHANGED
|
@@ -61,6 +61,7 @@ export default async function installMain(progname, rawArgs, powers, opts) {
|
|
|
61
61
|
const yarnInstallEachWorktree = async (phase, ...flags) => {
|
|
62
62
|
for await (const workTree of workTrees) {
|
|
63
63
|
log.info(`yarn install ${phase} in ${workTree}`);
|
|
64
|
+
// eslint-disable-next-line no-await-in-loop
|
|
64
65
|
const yarnInstall = await pspawn(
|
|
65
66
|
'yarn',
|
|
66
67
|
[...linkFlags, 'install', ...flags],
|
|
@@ -287,7 +288,6 @@ export default async function installMain(progname, rawArgs, powers, opts) {
|
|
|
287
288
|
await Promise.all(
|
|
288
289
|
[...sdkPackageToPath.entries()].map(async ([pjName, dir]) => {
|
|
289
290
|
const SUBOPTIMAL = false;
|
|
290
|
-
await null;
|
|
291
291
|
if (SUBOPTIMAL) {
|
|
292
292
|
// This use of yarn is noisy and slow.
|
|
293
293
|
await pspawn('yarn', [...linkFlags, 'unlink', pjName]);
|
package/src/lib/chain.js
CHANGED
|
@@ -38,7 +38,6 @@ harden(normalizeAddressWithOptions);
|
|
|
38
38
|
* @param {ReadonlyArray<string>} swingsetArgs
|
|
39
39
|
* @param {import('./rpc').MinimalNetworkConfig & {
|
|
40
40
|
* from: string,
|
|
41
|
-
* fees?: string,
|
|
42
41
|
* dryRun?: boolean,
|
|
43
42
|
* verbose?: boolean,
|
|
44
43
|
* keyring?: {home?: string, backend: string}
|
|
@@ -49,7 +48,6 @@ harden(normalizeAddressWithOptions);
|
|
|
49
48
|
export const execSwingsetTransaction = (swingsetArgs, opts) => {
|
|
50
49
|
const {
|
|
51
50
|
from,
|
|
52
|
-
fees,
|
|
53
51
|
dryRun = false,
|
|
54
52
|
verbose = true,
|
|
55
53
|
keyring = undefined,
|
|
@@ -62,11 +60,9 @@ export const execSwingsetTransaction = (swingsetArgs, opts) => {
|
|
|
62
60
|
const backendOpt = keyring?.backend
|
|
63
61
|
? [`--keyring-backend=${keyring.backend}`]
|
|
64
62
|
: [];
|
|
65
|
-
const feeOpt = fees ? ['--fees', fees] : [];
|
|
66
63
|
const cmd = [`--node=${rpcAddrs[0]}`, `--chain-id=${chainName}`].concat(
|
|
67
64
|
homeOpt,
|
|
68
65
|
backendOpt,
|
|
69
|
-
feeOpt,
|
|
70
66
|
[`--from=${from}`, 'tx', 'swingset'],
|
|
71
67
|
swingsetArgs,
|
|
72
68
|
);
|
|
@@ -79,15 +75,7 @@ export const execSwingsetTransaction = (swingsetArgs, opts) => {
|
|
|
79
75
|
} else {
|
|
80
76
|
const yesCmd = cmd.concat(['--yes']);
|
|
81
77
|
if (verbose) console.log('Executing ', yesCmd);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// agd puts this diagnostic on stdout rather than stderr :-/
|
|
85
|
-
// "Default sign-mode 'direct' not supported by Ledger, using sign-mode 'amino-json'.
|
|
86
|
-
if (out.startsWith('Default sign-mode')) {
|
|
87
|
-
const stripDiagnostic = out.replace(/^Default[^\n]+\n/, '');
|
|
88
|
-
return stripDiagnostic;
|
|
89
|
-
}
|
|
90
|
-
return out;
|
|
78
|
+
return execFileSync(agdBinary, yesCmd, { encoding: 'utf-8' });
|
|
91
79
|
}
|
|
92
80
|
};
|
|
93
81
|
harden(execSwingsetTransaction);
|
|
@@ -134,6 +122,7 @@ export const pollBlocks = opts => async lookup => {
|
|
|
134
122
|
} = status;
|
|
135
123
|
try {
|
|
136
124
|
// see await null above
|
|
125
|
+
// eslint-disable-next-line @jessie.js/no-nested-await, no-await-in-loop
|
|
137
126
|
const result = await lookup({ time, height });
|
|
138
127
|
return result;
|
|
139
128
|
} catch (_err) {
|
|
@@ -143,6 +132,7 @@ export const pollBlocks = opts => async lookup => {
|
|
|
143
132
|
height,
|
|
144
133
|
'retrying...',
|
|
145
134
|
);
|
|
135
|
+
// eslint-disable-next-line @jessie.js/no-nested-await, no-await-in-loop
|
|
146
136
|
await delay(period);
|
|
147
137
|
}
|
|
148
138
|
}
|
package/src/lib/format.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
2
|
import { makeBoardRemote } from '@agoric/vats/tools/board-utils.js';
|
|
3
|
+
// eslint-disable-next-line no-unused-vars -- typeof below
|
|
4
|
+
import { makeAgoricNames } from './rpc.js';
|
|
5
|
+
|
|
6
|
+
// ambient types
|
|
7
|
+
import '@agoric/ertp/src/types-ambient.js';
|
|
4
8
|
|
|
5
9
|
/** @typedef {import('@agoric/vats/tools/board-utils.js').BoardRemote} BoardRemote */
|
|
6
10
|
|
|
@@ -26,15 +30,16 @@ export const Natural = str => {
|
|
|
26
30
|
*/
|
|
27
31
|
export const bigintReplacer = (k, v) => (typeof v === 'bigint' ? `${v}` : v);
|
|
28
32
|
|
|
29
|
-
/** @type {
|
|
33
|
+
/** @type {import('@agoric/vats/tools/board-utils.js').VBankAssetDetail} */
|
|
30
34
|
// eslint-disable-next-line no-unused-vars
|
|
31
35
|
const exampleAsset = {
|
|
36
|
+
// @ts-expect-error cast
|
|
32
37
|
brand: makeBoardRemote({ boardId: 'board0425', iface: 'Alleged: BLD brand' }),
|
|
33
38
|
displayInfo: { assetKind: 'nat', decimalPlaces: 6 },
|
|
39
|
+
// @ts-expect-error cast
|
|
34
40
|
issuer: makeBoardRemote({ boardId: null, iface: undefined }),
|
|
35
|
-
|
|
41
|
+
petname: 'Agoric staking token',
|
|
36
42
|
};
|
|
37
|
-
|
|
38
43
|
/** @typedef {import('@agoric/vats/tools/board-utils.js').VBankAssetDetail } AssetDescriptor */
|
|
39
44
|
|
|
40
45
|
/**
|
|
@@ -117,7 +122,7 @@ export const fmtRecordOfLines = record => {
|
|
|
117
122
|
* Summarize the offerStatuses of the state as user-facing informative tuples
|
|
118
123
|
*
|
|
119
124
|
* @param {import('@agoric/smart-wallet/src/utils.js').CoalescedWalletState} state
|
|
120
|
-
* @param {
|
|
125
|
+
* @param {Awaited<ReturnType<typeof makeAgoricNames>>} agoricNames
|
|
121
126
|
*/
|
|
122
127
|
export const offerStatusTuples = (state, agoricNames) => {
|
|
123
128
|
const { offerStatuses } = state;
|
|
@@ -174,7 +179,7 @@ export const offerStatusTuples = (state, agoricNames) => {
|
|
|
174
179
|
/**
|
|
175
180
|
* @param {import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord} current
|
|
176
181
|
* @param {ReturnType<import('@agoric/smart-wallet/src/utils.js').makeWalletStateCoalescer>['state']} coalesced
|
|
177
|
-
* @param {
|
|
182
|
+
* @param {Awaited<ReturnType<typeof makeAgoricNames>>} agoricNames
|
|
178
183
|
*/
|
|
179
184
|
export const summarize = (current, coalesced, agoricNames) => {
|
|
180
185
|
return {
|
package/src/lib/rpc.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
/* eslint-disable @jessie.js/no-nested-await */
|
|
2
3
|
/* global Buffer, fetch, process */
|
|
3
4
|
|
|
4
5
|
import { NonNullish } from '@agoric/assert';
|
|
@@ -49,8 +50,7 @@ export const getNetworkConfig = async env => {
|
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
/** @type {MinimalNetworkConfig} */
|
|
52
|
-
const networkConfig = await getNetworkConfig(process.env);
|
|
53
|
-
export { networkConfig };
|
|
53
|
+
export const networkConfig = await getNetworkConfig(process.env);
|
|
54
54
|
// console.warn('networkConfig', networkConfig);
|
|
55
55
|
|
|
56
56
|
/**
|
|
@@ -132,11 +132,11 @@ export const makeVStorage = (powers, config = networkConfig) => {
|
|
|
132
132
|
const parts = [];
|
|
133
133
|
// undefined the first iteration, to query at the highest
|
|
134
134
|
let blockHeight;
|
|
135
|
-
await null;
|
|
136
135
|
do {
|
|
137
136
|
// console.debug('READING', { blockHeight });
|
|
138
137
|
let values;
|
|
139
138
|
try {
|
|
139
|
+
// eslint-disable-next-line no-await-in-loop
|
|
140
140
|
({ blockHeight, values } = await this.readAt(
|
|
141
141
|
path,
|
|
142
142
|
blockHeight && Number(blockHeight) - 1,
|
|
@@ -242,7 +242,6 @@ export const makeAgoricNames = async (ctx, vstorage) => {
|
|
|
242
242
|
* @param {MinimalNetworkConfig} config
|
|
243
243
|
*/
|
|
244
244
|
export const makeRpcUtils = async ({ fetch }, config = networkConfig) => {
|
|
245
|
-
await null;
|
|
246
245
|
try {
|
|
247
246
|
const vstorage = makeVStorage({ fetch }, config);
|
|
248
247
|
const fromBoard = makeFromBoard();
|
package/src/lib/wallet.js
CHANGED
|
@@ -9,6 +9,7 @@ import { boardSlottingMarshaller, makeRpcUtils } from './rpc.js';
|
|
|
9
9
|
/** @typedef {import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord} CurrentWalletRecord */
|
|
10
10
|
/** @typedef {import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes} AgoricNamesRemotes */
|
|
11
11
|
|
|
12
|
+
const { values } = Object;
|
|
12
13
|
const { Fail } = assert;
|
|
13
14
|
const marshaller = boardSlottingMarshaller();
|
|
14
15
|
|
|
@@ -131,7 +132,6 @@ export const coalesceWalletState = async (follower, invitationBrand) => {
|
|
|
131
132
|
* @param {import('@agoric/smart-wallet/src/smartWallet').BridgeAction} bridgeAction
|
|
132
133
|
* @param {import('./rpc').MinimalNetworkConfig & {
|
|
133
134
|
* from: string,
|
|
134
|
-
* fees?: string,
|
|
135
135
|
* verbose?: boolean,
|
|
136
136
|
* keyring?: {home?: string, backend: string},
|
|
137
137
|
* stdout: Pick<import('stream').Writable, 'write'>,
|
|
@@ -159,7 +159,7 @@ export const sendAction = async (bridgeAction, opts) => {
|
|
|
159
159
|
assert(out); // not dry run
|
|
160
160
|
const tx = JSON.parse(out);
|
|
161
161
|
if (tx.code !== 0) {
|
|
162
|
-
const err = Error(`failed to send
|
|
162
|
+
const err = Error(`failed to send action. code: ${tx.code}`);
|
|
163
163
|
// @ts-expect-error XXX how to add properties to an error?
|
|
164
164
|
err.code = tx.code;
|
|
165
165
|
throw err;
|
|
@@ -247,6 +247,7 @@ export const makeWalletUtils = async (
|
|
|
247
247
|
untilNumWantsSatisfied = false,
|
|
248
248
|
) => {
|
|
249
249
|
const lookup = async () => {
|
|
250
|
+
// eslint-disable-next-line @jessie.js/no-nested-await, no-await-in-loop
|
|
250
251
|
const { offerStatuses } = await storedWalletState(from, minHeight);
|
|
251
252
|
const offerStatus = [...offerStatuses.values()].find(s => s.id === id);
|
|
252
253
|
if (!offerStatus) throw Error('retry');
|
|
@@ -271,3 +272,44 @@ export const makeWalletUtils = async (
|
|
|
271
272
|
pollOffer,
|
|
272
273
|
};
|
|
273
274
|
};
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @param {{
|
|
278
|
+
* brand: Record<string, Brand>,
|
|
279
|
+
* vbankAsset: Record<string, { brand: Brand, displayInfo: DisplayInfo }>,
|
|
280
|
+
* }} agoricNames
|
|
281
|
+
* @param {(msg: string) => Error} makeError error constructor
|
|
282
|
+
* @returns {(a: string) => Amount<'nat'>}
|
|
283
|
+
*/
|
|
284
|
+
export const makeParseAmount =
|
|
285
|
+
(agoricNames, makeError = msg => RangeError(msg)) =>
|
|
286
|
+
opt => {
|
|
287
|
+
assert.typeof(opt, 'string', 'parseAmount expected string');
|
|
288
|
+
const m = opt.match(/^(?<value>[\d_]+(\.[\d_]+)?)(?<brand>[A-Z]\w*?)$/);
|
|
289
|
+
if (!m || !m.groups) {
|
|
290
|
+
throw makeError(`invalid amount: ${opt}`);
|
|
291
|
+
}
|
|
292
|
+
const anyBrand = agoricNames.brand[m.groups.brand];
|
|
293
|
+
if (!anyBrand) {
|
|
294
|
+
throw makeError(`unknown brand: ${m.groups.brand}`);
|
|
295
|
+
}
|
|
296
|
+
const assetDesc = values(agoricNames.vbankAsset).find(
|
|
297
|
+
d => d.brand === anyBrand,
|
|
298
|
+
);
|
|
299
|
+
if (!assetDesc) {
|
|
300
|
+
throw makeError(`unknown brand: ${m.groups.brand}`);
|
|
301
|
+
}
|
|
302
|
+
const { displayInfo } = assetDesc;
|
|
303
|
+
if (!displayInfo.decimalPlaces || displayInfo.assetKind !== 'nat') {
|
|
304
|
+
throw makeError(`bad brand: ${displayInfo}`);
|
|
305
|
+
}
|
|
306
|
+
const value = BigInt(
|
|
307
|
+
Number(m.groups.value.replace(/_/g, '')) *
|
|
308
|
+
10 ** displayInfo.decimalPlaces,
|
|
309
|
+
);
|
|
310
|
+
/** @type {Brand<'nat'>} */
|
|
311
|
+
// @ts-expect-error dynamic cast
|
|
312
|
+
const natBrand = anyBrand;
|
|
313
|
+
const amt = { value, brand: natBrand };
|
|
314
|
+
return amt;
|
|
315
|
+
};
|
package/src/main-publish.js
CHANGED
|
@@ -31,9 +31,9 @@ const publishMain = async (progname, rawArgs, powers, opts) => {
|
|
|
31
31
|
chainID,
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
await null;
|
|
35
34
|
for (const bundlePath of rawArgs.slice(1)) {
|
|
36
35
|
// AWAIT
|
|
36
|
+
// eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
|
|
37
37
|
const bundleText = await fs.readFile(bundlePath, 'utf-8');
|
|
38
38
|
const bundle = parseLocatedJson(bundleText, bundlePath);
|
|
39
39
|
|
|
@@ -53,6 +53,7 @@ const publishMain = async (progname, rawArgs, powers, opts) => {
|
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
// AWAIT
|
|
56
|
+
// eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
|
|
56
57
|
const hashedBundle = await publishBundle(bundle, connectionSpec);
|
|
57
58
|
process.stdout.write(`${JSON.stringify(hashedBundle)}\n`);
|
|
58
59
|
}
|
package/src/main.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @jessie.js/no-nested-await */
|
|
1
2
|
/* global process */
|
|
2
3
|
import { Command } from 'commander';
|
|
3
4
|
import path from 'path';
|
|
@@ -35,7 +36,6 @@ const main = async (progname, rawArgs, powers) => {
|
|
|
35
36
|
const program = new Command();
|
|
36
37
|
|
|
37
38
|
async function isNotBasedir() {
|
|
38
|
-
await null;
|
|
39
39
|
try {
|
|
40
40
|
await fs.stat(STAMP);
|
|
41
41
|
return false;
|
|
@@ -96,7 +96,7 @@ const main = async (progname, rawArgs, powers) => {
|
|
|
96
96
|
.option(
|
|
97
97
|
'--hostport <host:port>',
|
|
98
98
|
'host and port to connect to VM',
|
|
99
|
-
'
|
|
99
|
+
'localhost:8000',
|
|
100
100
|
)
|
|
101
101
|
.option('--no-browser', `just display the URL, don't open a browser`)
|
|
102
102
|
.option(
|
package/src/open.js
CHANGED
|
@@ -5,8 +5,8 @@ import { getAccessToken } from '@agoric/access-token';
|
|
|
5
5
|
|
|
6
6
|
import { assert, details as X } from '@agoric/assert';
|
|
7
7
|
|
|
8
|
-
export default async function walletMain(
|
|
9
|
-
const { anylogger } = powers;
|
|
8
|
+
export default async function walletMain(progname, rawArgs, powers, opts) {
|
|
9
|
+
const { anylogger, fs } = powers;
|
|
10
10
|
const console = anylogger('agoric:wallet');
|
|
11
11
|
|
|
12
12
|
let suffix;
|
|
@@ -39,10 +39,10 @@ export default async function walletMain(_progname, _rawArgs, powers, opts) {
|
|
|
39
39
|
1000,
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
const walletAccessToken = await getAccessToken(opts.hostport
|
|
43
|
-
console
|
|
44
|
-
|
|
45
|
-
});
|
|
42
|
+
const walletAccessToken = await getAccessToken(opts.hostport, {
|
|
43
|
+
console,
|
|
44
|
+
fs,
|
|
45
|
+
}).catch(e => console.error(`Trying to fetch access token:`, e));
|
|
46
46
|
|
|
47
47
|
clearInterval(progressTimer);
|
|
48
48
|
process.stderr.write('\n');
|
package/src/publish.js
CHANGED
|
@@ -289,12 +289,14 @@ export const makeCosmosBundlePublisher = ({
|
|
|
289
289
|
const endpoint = urlForRpcAddress(rpcAddress);
|
|
290
290
|
|
|
291
291
|
// AWAIT
|
|
292
|
+
// eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
|
|
292
293
|
const stargateClient = await connectWithSigner(endpoint, wallet, {
|
|
293
294
|
gasPrice: Agoric.gasPrice,
|
|
294
295
|
registry,
|
|
295
296
|
});
|
|
296
297
|
|
|
297
298
|
// AWAIT
|
|
299
|
+
// eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
|
|
298
300
|
const result = await stargateClient
|
|
299
301
|
.signAndBroadcast(from.address, encodeObjects, Agoric.fee)
|
|
300
302
|
.catch(error => {
|
|
@@ -310,6 +312,7 @@ export const makeCosmosBundlePublisher = ({
|
|
|
310
312
|
}
|
|
311
313
|
|
|
312
314
|
// AWAIT
|
|
315
|
+
// eslint-disable-next-line no-await-in-loop,@jessie.js/no-nested-await
|
|
313
316
|
await E(leader).jitter('agoric CLI deploy');
|
|
314
317
|
}
|
|
315
318
|
|
|
@@ -423,7 +426,6 @@ const publishBundle = async (
|
|
|
423
426
|
)}, publishBundle supports only "endoZipBase64" with "endoZipBase64Sha512"`;
|
|
424
427
|
}
|
|
425
428
|
|
|
426
|
-
await null;
|
|
427
429
|
if (connectionSpec === undefined && getDefaultConnection !== undefined) {
|
|
428
430
|
connectionSpec = await getDefaultConnection();
|
|
429
431
|
}
|
package/src/sdk-package-names.js
CHANGED
|
@@ -4,14 +4,12 @@
|
|
|
4
4
|
export default [
|
|
5
5
|
"@agoric/access-token",
|
|
6
6
|
"@agoric/assert",
|
|
7
|
-
"@agoric/base-zone",
|
|
8
|
-
"@agoric/boot",
|
|
9
|
-
"@agoric/builders",
|
|
10
7
|
"@agoric/cache",
|
|
11
8
|
"@agoric/casting",
|
|
12
9
|
"@agoric/cosmic-proto",
|
|
13
10
|
"@agoric/cosmic-swingset",
|
|
14
11
|
"@agoric/cosmos",
|
|
12
|
+
"@agoric/create-dapp",
|
|
15
13
|
"@agoric/deploy-script-support",
|
|
16
14
|
"@agoric/deployment",
|
|
17
15
|
"@agoric/ertp",
|
|
@@ -20,11 +18,10 @@ export default [
|
|
|
20
18
|
"@agoric/import-manager",
|
|
21
19
|
"@agoric/inter-protocol",
|
|
22
20
|
"@agoric/internal",
|
|
23
|
-
"@agoric/kmarshal",
|
|
24
|
-
"@agoric/network",
|
|
25
21
|
"@agoric/notifier",
|
|
26
22
|
"@agoric/pegasus",
|
|
27
23
|
"@agoric/same-structure",
|
|
24
|
+
"@agoric/sharing-service",
|
|
28
25
|
"@agoric/smart-wallet",
|
|
29
26
|
"@agoric/solo",
|
|
30
27
|
"@agoric/sparse-ints",
|
|
@@ -38,11 +35,13 @@ export default [
|
|
|
38
35
|
"@agoric/swingset-xsnap-supervisor",
|
|
39
36
|
"@agoric/telemetry",
|
|
40
37
|
"@agoric/time",
|
|
38
|
+
"@agoric/ui-components",
|
|
41
39
|
"@agoric/vat-data",
|
|
42
40
|
"@agoric/vats",
|
|
43
|
-
"@agoric/vm-config",
|
|
44
41
|
"@agoric/wallet",
|
|
45
42
|
"@agoric/wallet-backend",
|
|
43
|
+
"@agoric/wallet-connection",
|
|
44
|
+
"@agoric/web-components",
|
|
46
45
|
"@agoric/xsnap",
|
|
47
46
|
"@agoric/xsnap-lockdown",
|
|
48
47
|
"@agoric/zoe",
|