agoric 0.21.2-u12.0 → 0.21.2-upgrade-16-fi-dev-8879538.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 +50 -37
- package/src/anylogger-agoric.js +28 -14
- package/src/bin-agops.js +8 -8
- package/src/chain-config.js +11 -11
- package/src/commands/auction.js +6 -5
- package/src/commands/{ec.js → gov.js} +181 -39
- package/src/commands/inter.js +20 -37
- package/src/commands/oracle.js +34 -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 +6 -3
- package/src/cosmos.js +2 -2
- package/src/follow.js +6 -3
- package/src/helpers.js +2 -1
- package/src/init.js +3 -8
- package/src/install.js +9 -11
- package/src/lib/chain.js +24 -10
- package/src/lib/format.js +14 -18
- package/src/lib/rpc.js +18 -5
- package/src/lib/wallet.js +29 -58
- package/src/main-publish.js +1 -2
- package/src/main.js +43 -45
- package/src/open.js +6 -6
- package/src/publish.js +3 -6
- package/src/sdk-package-names.js +11 -6
- package/src/set-defaults.js +1 -0
- package/src/start.js +52 -60
- package/tools/getting-started.js +170 -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
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;
|
package/src/commands/reserve.js
CHANGED
|
@@ -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 fetch, process */
|
|
@@ -32,7 +31,7 @@ export const makeReserveCommand = (_logger, io = {}) => {
|
|
|
32
31
|
async ({ collateralBrand, ...opts }) => {
|
|
33
32
|
const { agoricNames } = await makeRpcUtils({ fetch });
|
|
34
33
|
|
|
35
|
-
const offer = Offers.reserve.AddCollateral(agoricNames
|
|
34
|
+
const offer = Offers.reserve.AddCollateral(agoricNames, {
|
|
36
35
|
collateralBrandKey: collateralBrand,
|
|
37
36
|
...opts,
|
|
38
37
|
});
|
|
@@ -38,7 +38,6 @@ 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
41
|
const networkConfig = await getNetworkConfig(env);
|
|
43
42
|
return makeWalletUtils({ fetch, execFileSync, delay }, networkConfig);
|
|
44
43
|
} catch (err) {
|
|
@@ -83,7 +82,13 @@ export const makeTestCommand = (
|
|
|
83
82
|
publicInvitationMaker: 'makeInvitation',
|
|
84
83
|
},
|
|
85
84
|
proposal: {
|
|
86
|
-
want: {
|
|
85
|
+
want: {
|
|
86
|
+
Tokens: {
|
|
87
|
+
// @ts-expect-error BoardRemote not a Brand object
|
|
88
|
+
brand: agoricNames.brand.GoodStuff,
|
|
89
|
+
value: 32n,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
87
92
|
},
|
|
88
93
|
};
|
|
89
94
|
const result = await sendAction(
|
package/src/commands/vaults.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 */
|
|
@@ -56,7 +54,7 @@ export const makeVaultsCommand = logger => {
|
|
|
56
54
|
|
|
57
55
|
vaults
|
|
58
56
|
.command('open')
|
|
59
|
-
.description('open a new vault')
|
|
57
|
+
.description('Prepare an offer to open a new vault')
|
|
60
58
|
.requiredOption('--giveCollateral <number>', 'Collateral to give', Number)
|
|
61
59
|
.requiredOption('--wantMinted <number>', 'Minted wants', Number)
|
|
62
60
|
.option('--offerId <string>', 'Offer id', String, `openVault-${Date.now()}`)
|
|
@@ -65,7 +63,7 @@ export const makeVaultsCommand = logger => {
|
|
|
65
63
|
logger.warn('running with options', opts);
|
|
66
64
|
const { agoricNames } = await makeRpcUtils({ fetch });
|
|
67
65
|
|
|
68
|
-
const offer = Offers.vaults.OpenVault(agoricNames
|
|
66
|
+
const offer = Offers.vaults.OpenVault(agoricNames, {
|
|
69
67
|
giveCollateral: opts.giveCollateral,
|
|
70
68
|
wantMinted: opts.wantMinted,
|
|
71
69
|
offerId: opts.offerId,
|
|
@@ -78,7 +76,7 @@ export const makeVaultsCommand = logger => {
|
|
|
78
76
|
|
|
79
77
|
vaults
|
|
80
78
|
.command('adjust')
|
|
81
|
-
.description('adjust an existing vault')
|
|
79
|
+
.description('Prepare an offer to adjust an existing vault')
|
|
82
80
|
.requiredOption(
|
|
83
81
|
'--from <address>',
|
|
84
82
|
'wallet address literal or name',
|
|
@@ -106,7 +104,7 @@ export const makeVaultsCommand = logger => {
|
|
|
106
104
|
);
|
|
107
105
|
|
|
108
106
|
const offer = Offers.vaults.AdjustBalances(
|
|
109
|
-
agoricNames
|
|
107
|
+
agoricNames,
|
|
110
108
|
{
|
|
111
109
|
giveCollateral: opts.giveCollateral,
|
|
112
110
|
wantCollateral: opts.wantCollateral,
|
|
@@ -123,7 +121,7 @@ export const makeVaultsCommand = logger => {
|
|
|
123
121
|
|
|
124
122
|
vaults
|
|
125
123
|
.command('close')
|
|
126
|
-
.description('close an existing vault')
|
|
124
|
+
.description('Prepare an offer to close an existing vault')
|
|
127
125
|
.requiredOption(
|
|
128
126
|
'--from <address>',
|
|
129
127
|
'wallet address literal or name',
|
|
@@ -147,7 +145,7 @@ export const makeVaultsCommand = logger => {
|
|
|
147
145
|
);
|
|
148
146
|
|
|
149
147
|
const offer = Offers.vaults.CloseVault(
|
|
150
|
-
agoricNames
|
|
148
|
+
agoricNames,
|
|
151
149
|
{
|
|
152
150
|
giveMinted: opts.giveMinted,
|
|
153
151
|
offerId: opts.offerId,
|
package/src/commands/wallet.js
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
makeLeader,
|
|
9
9
|
makeLeaderFromRpcAddresses,
|
|
10
10
|
} from '@agoric/casting';
|
|
11
|
-
import { Command } from 'commander';
|
|
12
11
|
import fs from 'fs';
|
|
13
12
|
import util from 'util';
|
|
14
13
|
import { execFileSync } from 'child_process';
|
|
@@ -25,8 +24,12 @@ import { coalesceWalletState, getCurrent } from '../lib/wallet.js';
|
|
|
25
24
|
|
|
26
25
|
const SLEEP_SECONDS = 3;
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @param {import('commander').Command['command']} command
|
|
29
|
+
* @returns {Promise<import('commander').Command>}
|
|
30
|
+
*/
|
|
31
|
+
export const makeWalletCommand = async command => {
|
|
32
|
+
const wallet = command('wallet')
|
|
30
33
|
.description('wallet commands')
|
|
31
34
|
.option('--home <dir>', 'agd application home directory')
|
|
32
35
|
.option(
|
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 });
|
package/src/follow.js
CHANGED
|
@@ -142,9 +142,12 @@ export default async function followerMain(progname, rawArgs, powers, opts) {
|
|
|
142
142
|
verbose && console.warn('Following', spec);
|
|
143
143
|
const castingSpec = makeCastingSpec(spec);
|
|
144
144
|
const follower = makeFollower(castingSpec, leader, followerOptions);
|
|
145
|
-
for await (const
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
for await (const obj of iterate(follower)) {
|
|
146
|
+
if ('error' in obj) {
|
|
147
|
+
console.error('Error following:', obj.error);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const { value, blockHeight, currentBlockHeight } = obj;
|
|
148
151
|
const blockHeightPrefix = opts.blockHeight ? `${blockHeight}:` : '';
|
|
149
152
|
const currentBlockHeightPrefix = opts.currentBlockHeight
|
|
150
153
|
? `${currentBlockHeight}:`
|
package/src/helpers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* global process */
|
|
2
2
|
// @ts-check
|
|
3
3
|
|
|
4
|
-
/** @
|
|
4
|
+
/** @import { ChildProcess } from 'child_process' */
|
|
5
5
|
|
|
6
6
|
export const getSDKBinaries = ({
|
|
7
7
|
jsPfx = '../..',
|
|
@@ -41,6 +41,7 @@ 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]
|
|
44
45
|
* @param {string | [string, string, string]} [param2.stdio] standard IO
|
|
45
46
|
* specification
|
|
46
47
|
* @param {Record<string, string | undefined>} [param2.env] environment
|
package/src/init.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { makePspawn } from './helpers.js';
|
|
3
3
|
|
|
4
|
-
|
|
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';
|
|
4
|
+
/// <reference types="@endo/captp/src/types.js" />
|
|
9
5
|
|
|
10
6
|
// Use either an absolute template URL, or find it relative to DAPP_URL_BASE.
|
|
11
7
|
const gitURL = (relativeOrAbsoluteURL, base) => {
|
|
@@ -40,9 +36,10 @@ export default async function initMain(_progname, rawArgs, priv, opts) {
|
|
|
40
36
|
dappBranch = ['-b', opts.dappBranch];
|
|
41
37
|
}
|
|
42
38
|
|
|
39
|
+
const shallow = ['--depth', '1', '--shallow-submodules'];
|
|
43
40
|
const exitStatus = await pspawn(
|
|
44
41
|
'git',
|
|
45
|
-
['clone', '--origin=upstream', dappURL, DIR, ...dappBranch],
|
|
42
|
+
['clone', '--origin=upstream', ...shallow, dappURL, DIR, ...dappBranch],
|
|
46
43
|
{
|
|
47
44
|
stdio: 'inherit',
|
|
48
45
|
},
|
|
@@ -60,7 +57,6 @@ export default async function initMain(_progname, rawArgs, priv, opts) {
|
|
|
60
57
|
const path = `${DIR}/${dir}package.json`;
|
|
61
58
|
log('rewriting ', path);
|
|
62
59
|
|
|
63
|
-
// eslint-disable-next-line no-await-in-loop
|
|
64
60
|
const contents = await fs.readFile(path, 'utf-8');
|
|
65
61
|
const pkg = JSON.parse(contents.replace(/@DIR@/g, DIR));
|
|
66
62
|
if (dir === '') {
|
|
@@ -74,7 +70,6 @@ export default async function initMain(_progname, rawArgs, priv, opts) {
|
|
|
74
70
|
pkg.name = `${DIR}${pkg.name.substr(topLevelName.length)}`;
|
|
75
71
|
const json = JSON.stringify(pkg, undefined, 2);
|
|
76
72
|
|
|
77
|
-
// eslint-disable-next-line no-await-in-loop
|
|
78
73
|
await fs.writeFile(path, json);
|
|
79
74
|
}
|
|
80
75
|
|
package/src/install.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* global process
|
|
1
|
+
/* global process Buffer */
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { makePspawn } from './helpers.js';
|
|
@@ -9,8 +9,7 @@ const REQUIRED_AGORIC_START_PACKAGES = [
|
|
|
9
9
|
'@agoric/cosmic-swingset',
|
|
10
10
|
];
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
const dirname = path.dirname(filename);
|
|
12
|
+
const dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
14
13
|
|
|
15
14
|
export default async function installMain(progname, rawArgs, powers, opts) {
|
|
16
15
|
const { anylogger, fs, spawn } = powers;
|
|
@@ -41,9 +40,9 @@ export default async function installMain(progname, rawArgs, powers, opts) {
|
|
|
41
40
|
p.childProcess.stdout.on('data', out => stdout.push(out));
|
|
42
41
|
await p;
|
|
43
42
|
const d = JSON.parse(Buffer.concat(stdout).toString('utf-8'));
|
|
44
|
-
|
|
45
|
-
map.set(name, path.resolve(cwd, location))
|
|
46
|
-
|
|
43
|
+
for (const [name, { location }] of Object.entries(d)) {
|
|
44
|
+
map.set(name, path.resolve(cwd, location));
|
|
45
|
+
}
|
|
47
46
|
return map;
|
|
48
47
|
}
|
|
49
48
|
|
|
@@ -61,7 +60,6 @@ export default async function installMain(progname, rawArgs, powers, opts) {
|
|
|
61
60
|
const yarnInstallEachWorktree = async (phase, ...flags) => {
|
|
62
61
|
for await (const workTree of workTrees) {
|
|
63
62
|
log.info(`yarn install ${phase} in ${workTree}`);
|
|
64
|
-
// eslint-disable-next-line no-await-in-loop
|
|
65
63
|
const yarnInstall = await pspawn(
|
|
66
64
|
'yarn',
|
|
67
65
|
[...linkFlags, 'install', ...flags],
|
|
@@ -175,9 +173,6 @@ export default async function installMain(progname, rawArgs, powers, opts) {
|
|
|
175
173
|
({ status }) => status !== 'fulfilled',
|
|
176
174
|
);
|
|
177
175
|
if (failures.length) {
|
|
178
|
-
if (typeof AggregateError !== 'function') {
|
|
179
|
-
throw failures[0].reason;
|
|
180
|
-
}
|
|
181
176
|
throw AggregateError(
|
|
182
177
|
failures.map(({ reason }) => reason),
|
|
183
178
|
'Failed to prune',
|
|
@@ -269,7 +264,9 @@ export default async function installMain(progname, rawArgs, powers, opts) {
|
|
|
269
264
|
};
|
|
270
265
|
await Promise.all(subdirs.map(removeNodeModulesSymlinks));
|
|
271
266
|
} else {
|
|
272
|
-
|
|
267
|
+
for (const name of DEFAULT_SDK_PACKAGE_NAMES) {
|
|
268
|
+
sdkPackageToPath.set(name, null);
|
|
269
|
+
}
|
|
273
270
|
}
|
|
274
271
|
|
|
275
272
|
if (forceSdkVersion !== undefined) {
|
|
@@ -288,6 +285,7 @@ export default async function installMain(progname, rawArgs, powers, opts) {
|
|
|
288
285
|
await Promise.all(
|
|
289
286
|
[...sdkPackageToPath.entries()].map(async ([pjName, dir]) => {
|
|
290
287
|
const SUBOPTIMAL = false;
|
|
288
|
+
await null;
|
|
291
289
|
if (SUBOPTIMAL) {
|
|
292
290
|
// This use of yarn is noisy and slow.
|
|
293
291
|
await pspawn('yarn', [...linkFlags, 'unlink', pjName]);
|
package/src/lib/chain.js
CHANGED
|
@@ -36,8 +36,9 @@ harden(normalizeAddressWithOptions);
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* @param {ReadonlyArray<string>} swingsetArgs
|
|
39
|
-
* @param {import('./rpc').MinimalNetworkConfig & {
|
|
39
|
+
* @param {import('./rpc.js').MinimalNetworkConfig & {
|
|
40
40
|
* from: string,
|
|
41
|
+
* fees?: string,
|
|
41
42
|
* dryRun?: boolean,
|
|
42
43
|
* verbose?: boolean,
|
|
43
44
|
* keyring?: {home?: string, backend: string}
|
|
@@ -48,6 +49,7 @@ harden(normalizeAddressWithOptions);
|
|
|
48
49
|
export const execSwingsetTransaction = (swingsetArgs, opts) => {
|
|
49
50
|
const {
|
|
50
51
|
from,
|
|
52
|
+
fees,
|
|
51
53
|
dryRun = false,
|
|
52
54
|
verbose = true,
|
|
53
55
|
keyring = undefined,
|
|
@@ -60,9 +62,11 @@ export const execSwingsetTransaction = (swingsetArgs, opts) => {
|
|
|
60
62
|
const backendOpt = keyring?.backend
|
|
61
63
|
? [`--keyring-backend=${keyring.backend}`]
|
|
62
64
|
: [];
|
|
65
|
+
const feeOpt = fees ? ['--fees', fees] : [];
|
|
63
66
|
const cmd = [`--node=${rpcAddrs[0]}`, `--chain-id=${chainName}`].concat(
|
|
64
67
|
homeOpt,
|
|
65
68
|
backendOpt,
|
|
69
|
+
feeOpt,
|
|
66
70
|
[`--from=${from}`, 'tx', 'swingset'],
|
|
67
71
|
swingsetArgs,
|
|
68
72
|
);
|
|
@@ -75,14 +79,26 @@ export const execSwingsetTransaction = (swingsetArgs, opts) => {
|
|
|
75
79
|
} else {
|
|
76
80
|
const yesCmd = cmd.concat(['--yes']);
|
|
77
81
|
if (verbose) console.log('Executing ', yesCmd);
|
|
78
|
-
|
|
82
|
+
const out = execFileSync(agdBinary, yesCmd, { encoding: 'utf-8' });
|
|
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;
|
|
79
91
|
}
|
|
80
92
|
};
|
|
81
93
|
harden(execSwingsetTransaction);
|
|
82
94
|
|
|
83
|
-
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* @param {import('./rpc.js').MinimalNetworkConfig} net
|
|
98
|
+
*/
|
|
99
|
+
// TODO fetch by HTTP instead of shelling out https://github.com/Agoric/agoric-sdk/issues/9200
|
|
84
100
|
export const fetchSwingsetParams = net => {
|
|
85
|
-
const { chainName, rpcAddrs
|
|
101
|
+
const { chainName, rpcAddrs } = net;
|
|
86
102
|
const cmd = [
|
|
87
103
|
`--node=${rpcAddrs[0]}`,
|
|
88
104
|
`--chain-id=${chainName}`,
|
|
@@ -90,15 +106,15 @@ export const fetchSwingsetParams = net => {
|
|
|
90
106
|
'swingset',
|
|
91
107
|
'params',
|
|
92
108
|
'--output',
|
|
93
|
-
'
|
|
109
|
+
'json',
|
|
94
110
|
];
|
|
95
|
-
const buffer =
|
|
111
|
+
const buffer = execFileSyncAmbient(agdBinary, cmd);
|
|
96
112
|
return JSON.parse(buffer.toString());
|
|
97
113
|
};
|
|
98
114
|
harden(fetchSwingsetParams);
|
|
99
115
|
|
|
100
116
|
/**
|
|
101
|
-
* @param {import('./rpc').MinimalNetworkConfig & {
|
|
117
|
+
* @param {import('./rpc.js').MinimalNetworkConfig & {
|
|
102
118
|
* execFileSync: typeof import('child_process').execFileSync,
|
|
103
119
|
* delay: (ms: number) => Promise<void>,
|
|
104
120
|
* period?: number,
|
|
@@ -122,7 +138,6 @@ export const pollBlocks = opts => async lookup => {
|
|
|
122
138
|
} = status;
|
|
123
139
|
try {
|
|
124
140
|
// see await null above
|
|
125
|
-
// eslint-disable-next-line @jessie.js/no-nested-await, no-await-in-loop
|
|
126
141
|
const result = await lookup({ time, height });
|
|
127
142
|
return result;
|
|
128
143
|
} catch (_err) {
|
|
@@ -132,7 +147,6 @@ export const pollBlocks = opts => async lookup => {
|
|
|
132
147
|
height,
|
|
133
148
|
'retrying...',
|
|
134
149
|
);
|
|
135
|
-
// eslint-disable-next-line @jessie.js/no-nested-await, no-await-in-loop
|
|
136
150
|
await delay(period);
|
|
137
151
|
}
|
|
138
152
|
}
|
|
@@ -140,7 +154,7 @@ export const pollBlocks = opts => async lookup => {
|
|
|
140
154
|
|
|
141
155
|
/**
|
|
142
156
|
* @param {string} txhash
|
|
143
|
-
* @param {import('./rpc').MinimalNetworkConfig & {
|
|
157
|
+
* @param {import('./rpc.js').MinimalNetworkConfig & {
|
|
144
158
|
* execFileSync: typeof import('child_process').execFileSync,
|
|
145
159
|
* delay: (ms: number) => Promise<void>,
|
|
146
160
|
* period?: number,
|
package/src/lib/format.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
// @ts-check
|
|
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
2
|
|
|
6
|
-
|
|
7
|
-
import '@agoric/ertp/src/types-ambient.js';
|
|
3
|
+
import { makeBoardRemote } from '@agoric/vats/tools/board-utils.js';
|
|
8
4
|
|
|
9
|
-
/** @
|
|
5
|
+
/** @import {BoardRemote} from '@agoric/vats/tools/board-utils.js' */
|
|
6
|
+
/** @import {VBankAssetDetail} from '@agoric/vats/tools/board-utils.js'; */
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* Like @endo/nat but coerces
|
|
@@ -30,21 +27,18 @@ export const Natural = str => {
|
|
|
30
27
|
*/
|
|
31
28
|
export const bigintReplacer = (k, v) => (typeof v === 'bigint' ? `${v}` : v);
|
|
32
29
|
|
|
33
|
-
/** @type {
|
|
30
|
+
/** @type {Partial<VBankAssetDetail>} */
|
|
34
31
|
// eslint-disable-next-line no-unused-vars
|
|
35
32
|
const exampleAsset = {
|
|
36
|
-
// @ts-expect-error cast
|
|
37
33
|
brand: makeBoardRemote({ boardId: 'board0425', iface: 'Alleged: BLD brand' }),
|
|
38
34
|
displayInfo: { assetKind: 'nat', decimalPlaces: 6 },
|
|
39
|
-
// @ts-expect-error cast
|
|
40
35
|
issuer: makeBoardRemote({ boardId: null, iface: undefined }),
|
|
41
|
-
|
|
36
|
+
proposedName: 'Agoric staking token',
|
|
42
37
|
};
|
|
43
|
-
/** @typedef {import('@agoric/vats/tools/board-utils.js').VBankAssetDetail } AssetDescriptor */
|
|
44
38
|
|
|
45
39
|
/**
|
|
46
|
-
* @param {
|
|
47
|
-
* @returns {(a: Amount & { brand: BoardRemote }) => [string, number | any[]]}
|
|
40
|
+
* @param {VBankAssetDetail[]} assets
|
|
41
|
+
* @returns {(a: Amount & { brand: BoardRemote }) => [string | null, number | any[]]}
|
|
48
42
|
*/
|
|
49
43
|
export const makeAmountFormatter = assets => amt => {
|
|
50
44
|
const { brand, value } = amt;
|
|
@@ -60,7 +54,9 @@ export const makeAmountFormatter = assets => amt => {
|
|
|
60
54
|
return [issuerName, Number(value) / 10 ** decimalPlaces];
|
|
61
55
|
case 'set':
|
|
62
56
|
assert(Array.isArray(value));
|
|
57
|
+
// @ts-expect-error narrowed
|
|
63
58
|
if (value[0]?.handle?.iface?.includes('InvitationHandle')) {
|
|
59
|
+
// @ts-expect-error narrowed
|
|
64
60
|
return [issuerName, value.map(v => v.description)];
|
|
65
61
|
}
|
|
66
62
|
return [issuerName, value];
|
|
@@ -94,8 +90,8 @@ export const asBoardRemote = x => {
|
|
|
94
90
|
/**
|
|
95
91
|
* Summarize the balances array as user-facing informative tuples
|
|
96
92
|
*
|
|
97
|
-
* @param {import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord['purses']} purses
|
|
98
|
-
* @param {
|
|
93
|
+
* @param {import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord['purses']} purses
|
|
94
|
+
* @param {VBankAssetDetail[]} assets
|
|
99
95
|
*/
|
|
100
96
|
export const purseBalanceTuples = (purses, assets) => {
|
|
101
97
|
const fmt = makeAmountFormatter(assets);
|
|
@@ -122,7 +118,7 @@ export const fmtRecordOfLines = record => {
|
|
|
122
118
|
* Summarize the offerStatuses of the state as user-facing informative tuples
|
|
123
119
|
*
|
|
124
120
|
* @param {import('@agoric/smart-wallet/src/utils.js').CoalescedWalletState} state
|
|
125
|
-
* @param {
|
|
121
|
+
* @param {import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes} agoricNames
|
|
126
122
|
*/
|
|
127
123
|
export const offerStatusTuples = (state, agoricNames) => {
|
|
128
124
|
const { offerStatuses } = state;
|
|
@@ -177,9 +173,9 @@ export const offerStatusTuples = (state, agoricNames) => {
|
|
|
177
173
|
};
|
|
178
174
|
|
|
179
175
|
/**
|
|
180
|
-
* @param {import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord} current
|
|
176
|
+
* @param {import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord} current
|
|
181
177
|
* @param {ReturnType<import('@agoric/smart-wallet/src/utils.js').makeWalletStateCoalescer>['state']} coalesced
|
|
182
|
-
* @param {
|
|
178
|
+
* @param {import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes} agoricNames
|
|
183
179
|
*/
|
|
184
180
|
export const summarize = (current, coalesced, agoricNames) => {
|
|
185
181
|
return {
|
package/src/lib/rpc.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
/* eslint-disable @jessie.js/no-nested-await */
|
|
3
2
|
/* global Buffer, fetch, process */
|
|
4
3
|
|
|
5
4
|
import { NonNullish } from '@agoric/assert';
|
|
@@ -50,7 +49,8 @@ export const getNetworkConfig = async env => {
|
|
|
50
49
|
};
|
|
51
50
|
|
|
52
51
|
/** @type {MinimalNetworkConfig} */
|
|
53
|
-
|
|
52
|
+
const networkConfig = await getNetworkConfig(process.env);
|
|
53
|
+
export { networkConfig };
|
|
54
54
|
// console.warn('networkConfig', networkConfig);
|
|
55
55
|
|
|
56
56
|
/**
|
|
@@ -79,9 +79,13 @@ export const makeVStorage = (powers, config = networkConfig) => {
|
|
|
79
79
|
result: { response },
|
|
80
80
|
} = data;
|
|
81
81
|
if (response?.code !== 0) {
|
|
82
|
-
|
|
82
|
+
/** @type {any} */
|
|
83
|
+
const err = Error(
|
|
83
84
|
`error code ${response?.code} reading ${kind} of ${path}: ${response.log}`,
|
|
84
85
|
);
|
|
86
|
+
err.code = response?.code;
|
|
87
|
+
err.codespace = response?.codespace;
|
|
88
|
+
throw err;
|
|
85
89
|
}
|
|
86
90
|
return data;
|
|
87
91
|
});
|
|
@@ -132,18 +136,26 @@ export const makeVStorage = (powers, config = networkConfig) => {
|
|
|
132
136
|
const parts = [];
|
|
133
137
|
// undefined the first iteration, to query at the highest
|
|
134
138
|
let blockHeight;
|
|
139
|
+
await null;
|
|
135
140
|
do {
|
|
136
141
|
// console.debug('READING', { blockHeight });
|
|
137
142
|
let values;
|
|
138
143
|
try {
|
|
139
|
-
// eslint-disable-next-line no-await-in-loop
|
|
140
144
|
({ blockHeight, values } = await this.readAt(
|
|
141
145
|
path,
|
|
142
146
|
blockHeight && Number(blockHeight) - 1,
|
|
143
147
|
));
|
|
144
148
|
// console.debug('readAt returned', { blockHeight });
|
|
145
149
|
} catch (err) {
|
|
146
|
-
if (
|
|
150
|
+
if (
|
|
151
|
+
// CosmosSDK ErrInvalidRequest with particular message text;
|
|
152
|
+
// misrepresentation of pruned data
|
|
153
|
+
// TODO replace after incorporating a fix to
|
|
154
|
+
// https://github.com/cosmos/cosmos-sdk/issues/19992
|
|
155
|
+
err.codespace === 'sdk' &&
|
|
156
|
+
err.code === 18 &&
|
|
157
|
+
err.message.match(/pruned/)
|
|
158
|
+
) {
|
|
147
159
|
// console.error(err);
|
|
148
160
|
break;
|
|
149
161
|
}
|
|
@@ -242,6 +254,7 @@ export const makeAgoricNames = async (ctx, vstorage) => {
|
|
|
242
254
|
* @param {MinimalNetworkConfig} config
|
|
243
255
|
*/
|
|
244
256
|
export const makeRpcUtils = async ({ fetch }, config = networkConfig) => {
|
|
257
|
+
await null;
|
|
245
258
|
try {
|
|
246
259
|
const vstorage = makeVStorage({ fetch }, config);
|
|
247
260
|
const fromBoard = makeFromBoard();
|