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
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(
|
|
@@ -47,10 +50,11 @@ export const makeWalletCommand = async () => {
|
|
|
47
50
|
)
|
|
48
51
|
.option('--spend', 'confirm you want to spend')
|
|
49
52
|
.option('--nickname <string>', 'nickname to use', 'my-wallet')
|
|
50
|
-
.action(function (opts) {
|
|
53
|
+
.action(async function (opts) {
|
|
51
54
|
const { account, nickname, spend } = opts;
|
|
52
55
|
const { home, keyringBackend: backend } = wallet.opts();
|
|
53
56
|
const tx = ['provision-one', nickname, account, 'SMART_WALLET'];
|
|
57
|
+
await null;
|
|
54
58
|
if (spend) {
|
|
55
59
|
execSwingsetTransaction(tx, {
|
|
56
60
|
from: account,
|
|
@@ -58,12 +62,12 @@ export const makeWalletCommand = async () => {
|
|
|
58
62
|
...networkConfig,
|
|
59
63
|
});
|
|
60
64
|
} else {
|
|
61
|
-
const params = fetchSwingsetParams(networkConfig);
|
|
65
|
+
const params = await fetchSwingsetParams(networkConfig);
|
|
62
66
|
assert(
|
|
63
|
-
params.
|
|
64
|
-
'multiple
|
|
67
|
+
params.powerFlagFees.length === 1,
|
|
68
|
+
'multiple powerFlagFees not supported',
|
|
65
69
|
);
|
|
66
|
-
const { fee: fees } = params.
|
|
70
|
+
const { fee: fees } = params.powerFlagFees[0];
|
|
67
71
|
const nf = new Intl.NumberFormat('en-US');
|
|
68
72
|
const costs = fees
|
|
69
73
|
.map(f => `${nf.format(Number(f.amount))} ${f.denom}`)
|
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
|
@@ -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,9 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { makePspawn } from './helpers.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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" />
|
|
5
|
+
/// <reference types="@agoric/swingset-vat/exported.js" />
|
|
6
|
+
/// <reference types="@agoric/network/exported.js" />
|
|
9
7
|
|
|
10
8
|
// Use either an absolute template URL, or find it relative to DAPP_URL_BASE.
|
|
11
9
|
const gitURL = (relativeOrAbsoluteURL, base) => {
|
|
@@ -40,9 +38,10 @@ export default async function initMain(_progname, rawArgs, priv, opts) {
|
|
|
40
38
|
dappBranch = ['-b', opts.dappBranch];
|
|
41
39
|
}
|
|
42
40
|
|
|
41
|
+
const shallow = ['--depth', '1', '--shallow-submodules'];
|
|
43
42
|
const exitStatus = await pspawn(
|
|
44
43
|
'git',
|
|
45
|
-
['clone', '--origin=upstream', dappURL, DIR, ...dappBranch],
|
|
44
|
+
['clone', '--origin=upstream', ...shallow, dappURL, DIR, ...dappBranch],
|
|
46
45
|
{
|
|
47
46
|
stdio: 'inherit',
|
|
48
47
|
},
|
|
@@ -60,7 +59,6 @@ export default async function initMain(_progname, rawArgs, priv, opts) {
|
|
|
60
59
|
const path = `${DIR}/${dir}package.json`;
|
|
61
60
|
log('rewriting ', path);
|
|
62
61
|
|
|
63
|
-
// eslint-disable-next-line no-await-in-loop
|
|
64
62
|
const contents = await fs.readFile(path, 'utf-8');
|
|
65
63
|
const pkg = JSON.parse(contents.replace(/@DIR@/g, DIR));
|
|
66
64
|
if (dir === '') {
|
|
@@ -74,7 +72,6 @@ export default async function initMain(_progname, rawArgs, priv, opts) {
|
|
|
74
72
|
pkg.name = `${DIR}${pkg.name.substr(topLevelName.length)}`;
|
|
75
73
|
const json = JSON.stringify(pkg, undefined, 2);
|
|
76
74
|
|
|
77
|
-
// eslint-disable-next-line no-await-in-loop
|
|
78
75
|
await fs.writeFile(path, json);
|
|
79
76
|
}
|
|
80
77
|
|
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';
|
|
@@ -41,9 +41,9 @@ export default async function installMain(progname, rawArgs, powers, opts) {
|
|
|
41
41
|
p.childProcess.stdout.on('data', out => stdout.push(out));
|
|
42
42
|
await p;
|
|
43
43
|
const d = JSON.parse(Buffer.concat(stdout).toString('utf-8'));
|
|
44
|
-
|
|
45
|
-
map.set(name, path.resolve(cwd, location))
|
|
46
|
-
|
|
44
|
+
for (const [name, { location }] of Object.entries(d)) {
|
|
45
|
+
map.set(name, path.resolve(cwd, location));
|
|
46
|
+
}
|
|
47
47
|
return map;
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -61,7 +61,6 @@ 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
|
|
65
64
|
const yarnInstall = await pspawn(
|
|
66
65
|
'yarn',
|
|
67
66
|
[...linkFlags, 'install', ...flags],
|
|
@@ -269,7 +268,9 @@ export default async function installMain(progname, rawArgs, powers, opts) {
|
|
|
269
268
|
};
|
|
270
269
|
await Promise.all(subdirs.map(removeNodeModulesSymlinks));
|
|
271
270
|
} else {
|
|
272
|
-
|
|
271
|
+
for (const name of DEFAULT_SDK_PACKAGE_NAMES) {
|
|
272
|
+
sdkPackageToPath.set(name, null);
|
|
273
|
+
}
|
|
273
274
|
}
|
|
274
275
|
|
|
275
276
|
if (forceSdkVersion !== undefined) {
|
|
@@ -288,6 +289,7 @@ export default async function installMain(progname, rawArgs, powers, opts) {
|
|
|
288
289
|
await Promise.all(
|
|
289
290
|
[...sdkPackageToPath.entries()].map(async ([pjName, dir]) => {
|
|
290
291
|
const SUBOPTIMAL = false;
|
|
292
|
+
await null;
|
|
291
293
|
if (SUBOPTIMAL) {
|
|
292
294
|
// This use of yarn is noisy and slow.
|
|
293
295
|
await pspawn('yarn', [...linkFlags, 'unlink', pjName]);
|
package/src/lib/chain.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
/* global process */
|
|
3
|
+
import { agoric } from '@agoric/cosmic-proto';
|
|
3
4
|
import { normalizeBech32 } from '@cosmjs/encoding';
|
|
4
5
|
import { execFileSync as execFileSyncAmbient } from 'child_process';
|
|
5
6
|
|
|
@@ -36,8 +37,9 @@ harden(normalizeAddressWithOptions);
|
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* @param {ReadonlyArray<string>} swingsetArgs
|
|
39
|
-
* @param {import('./rpc').MinimalNetworkConfig & {
|
|
40
|
+
* @param {import('./rpc.js').MinimalNetworkConfig & {
|
|
40
41
|
* from: string,
|
|
42
|
+
* fees?: string,
|
|
41
43
|
* dryRun?: boolean,
|
|
42
44
|
* verbose?: boolean,
|
|
43
45
|
* keyring?: {home?: string, backend: string}
|
|
@@ -48,6 +50,7 @@ harden(normalizeAddressWithOptions);
|
|
|
48
50
|
export const execSwingsetTransaction = (swingsetArgs, opts) => {
|
|
49
51
|
const {
|
|
50
52
|
from,
|
|
53
|
+
fees,
|
|
51
54
|
dryRun = false,
|
|
52
55
|
verbose = true,
|
|
53
56
|
keyring = undefined,
|
|
@@ -60,9 +63,11 @@ export const execSwingsetTransaction = (swingsetArgs, opts) => {
|
|
|
60
63
|
const backendOpt = keyring?.backend
|
|
61
64
|
? [`--keyring-backend=${keyring.backend}`]
|
|
62
65
|
: [];
|
|
66
|
+
const feeOpt = fees ? ['--fees', fees] : [];
|
|
63
67
|
const cmd = [`--node=${rpcAddrs[0]}`, `--chain-id=${chainName}`].concat(
|
|
64
68
|
homeOpt,
|
|
65
69
|
backendOpt,
|
|
70
|
+
feeOpt,
|
|
66
71
|
[`--from=${from}`, 'tx', 'swingset'],
|
|
67
72
|
swingsetArgs,
|
|
68
73
|
);
|
|
@@ -75,30 +80,37 @@ export const execSwingsetTransaction = (swingsetArgs, opts) => {
|
|
|
75
80
|
} else {
|
|
76
81
|
const yesCmd = cmd.concat(['--yes']);
|
|
77
82
|
if (verbose) console.log('Executing ', yesCmd);
|
|
78
|
-
|
|
83
|
+
const out = execFileSync(agdBinary, yesCmd, { encoding: 'utf-8' });
|
|
84
|
+
|
|
85
|
+
// agd puts this diagnostic on stdout rather than stderr :-/
|
|
86
|
+
// "Default sign-mode 'direct' not supported by Ledger, using sign-mode 'amino-json'.
|
|
87
|
+
if (out.startsWith('Default sign-mode')) {
|
|
88
|
+
const stripDiagnostic = out.replace(/^Default[^\n]+\n/, '');
|
|
89
|
+
return stripDiagnostic;
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
79
92
|
}
|
|
80
93
|
};
|
|
81
94
|
harden(execSwingsetTransaction);
|
|
82
95
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return JSON.parse(buffer.toString());
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
* @param {import('./rpc.js').MinimalNetworkConfig} net
|
|
99
|
+
* @returns {Promise<import('@agoric/cosmic-proto/dist/codegen/agoric/swingset/swingset').Params>}
|
|
100
|
+
*/
|
|
101
|
+
export const fetchSwingsetParams = async net => {
|
|
102
|
+
const { rpcAddrs } = net;
|
|
103
|
+
const rpcEndpoint = rpcAddrs[0];
|
|
104
|
+
const client = await agoric.ClientFactory.createRPCQueryClient({
|
|
105
|
+
rpcEndpoint,
|
|
106
|
+
});
|
|
107
|
+
const { params } = await client.agoric.swingset.params();
|
|
108
|
+
return params;
|
|
97
109
|
};
|
|
98
110
|
harden(fetchSwingsetParams);
|
|
99
111
|
|
|
100
112
|
/**
|
|
101
|
-
* @param {import('./rpc').MinimalNetworkConfig & {
|
|
113
|
+
* @param {import('./rpc.js').MinimalNetworkConfig & {
|
|
102
114
|
* execFileSync: typeof import('child_process').execFileSync,
|
|
103
115
|
* delay: (ms: number) => Promise<void>,
|
|
104
116
|
* period?: number,
|
|
@@ -122,7 +134,6 @@ export const pollBlocks = opts => async lookup => {
|
|
|
122
134
|
} = status;
|
|
123
135
|
try {
|
|
124
136
|
// see await null above
|
|
125
|
-
// eslint-disable-next-line @jessie.js/no-nested-await, no-await-in-loop
|
|
126
137
|
const result = await lookup({ time, height });
|
|
127
138
|
return result;
|
|
128
139
|
} catch (_err) {
|
|
@@ -132,7 +143,6 @@ export const pollBlocks = opts => async lookup => {
|
|
|
132
143
|
height,
|
|
133
144
|
'retrying...',
|
|
134
145
|
);
|
|
135
|
-
// eslint-disable-next-line @jessie.js/no-nested-await, no-await-in-loop
|
|
136
146
|
await delay(period);
|
|
137
147
|
}
|
|
138
148
|
}
|
|
@@ -140,7 +150,7 @@ export const pollBlocks = opts => async lookup => {
|
|
|
140
150
|
|
|
141
151
|
/**
|
|
142
152
|
* @param {string} txhash
|
|
143
|
-
* @param {import('./rpc').MinimalNetworkConfig & {
|
|
153
|
+
* @param {import('./rpc.js').MinimalNetworkConfig & {
|
|
144
154
|
* execFileSync: typeof import('child_process').execFileSync,
|
|
145
155
|
* delay: (ms: number) => Promise<void>,
|
|
146
156
|
* period?: number,
|
package/src/lib/format.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
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
|
/** @typedef {import('@agoric/vats/tools/board-utils.js').BoardRemote} BoardRemote */
|
|
10
6
|
|
|
@@ -30,21 +26,20 @@ export const Natural = str => {
|
|
|
30
26
|
*/
|
|
31
27
|
export const bigintReplacer = (k, v) => (typeof v === 'bigint' ? `${v}` : v);
|
|
32
28
|
|
|
33
|
-
/** @type {import('@agoric/vats/tools/board-utils.js').VBankAssetDetail} */
|
|
29
|
+
/** @type {Partial<import('@agoric/vats/tools/board-utils.js').VBankAssetDetail>} */
|
|
34
30
|
// eslint-disable-next-line no-unused-vars
|
|
35
31
|
const exampleAsset = {
|
|
36
|
-
// @ts-expect-error cast
|
|
37
32
|
brand: makeBoardRemote({ boardId: 'board0425', iface: 'Alleged: BLD brand' }),
|
|
38
33
|
displayInfo: { assetKind: 'nat', decimalPlaces: 6 },
|
|
39
|
-
// @ts-expect-error cast
|
|
40
34
|
issuer: makeBoardRemote({ boardId: null, iface: undefined }),
|
|
41
|
-
|
|
35
|
+
proposedName: 'Agoric staking token',
|
|
42
36
|
};
|
|
37
|
+
|
|
43
38
|
/** @typedef {import('@agoric/vats/tools/board-utils.js').VBankAssetDetail } AssetDescriptor */
|
|
44
39
|
|
|
45
40
|
/**
|
|
46
41
|
* @param {AssetDescriptor[]} assets
|
|
47
|
-
* @returns {(a: Amount & { brand: BoardRemote }) => [string, number | any[]]}
|
|
42
|
+
* @returns {(a: Amount & { brand: BoardRemote }) => [string | null, number | any[]]}
|
|
48
43
|
*/
|
|
49
44
|
export const makeAmountFormatter = assets => amt => {
|
|
50
45
|
const { brand, value } = amt;
|
|
@@ -94,7 +89,7 @@ export const asBoardRemote = x => {
|
|
|
94
89
|
/**
|
|
95
90
|
* Summarize the balances array as user-facing informative tuples
|
|
96
91
|
*
|
|
97
|
-
* @param {import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord['purses']} purses
|
|
92
|
+
* @param {import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord['purses']} purses
|
|
98
93
|
* @param {AssetDescriptor[]} assets
|
|
99
94
|
*/
|
|
100
95
|
export const purseBalanceTuples = (purses, assets) => {
|
|
@@ -122,7 +117,7 @@ export const fmtRecordOfLines = record => {
|
|
|
122
117
|
* Summarize the offerStatuses of the state as user-facing informative tuples
|
|
123
118
|
*
|
|
124
119
|
* @param {import('@agoric/smart-wallet/src/utils.js').CoalescedWalletState} state
|
|
125
|
-
* @param {
|
|
120
|
+
* @param {import('./wallet.js').AgoricNamesRemotes} agoricNames
|
|
126
121
|
*/
|
|
127
122
|
export const offerStatusTuples = (state, agoricNames) => {
|
|
128
123
|
const { offerStatuses } = state;
|
|
@@ -177,9 +172,9 @@ export const offerStatusTuples = (state, agoricNames) => {
|
|
|
177
172
|
};
|
|
178
173
|
|
|
179
174
|
/**
|
|
180
|
-
* @param {import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord} current
|
|
175
|
+
* @param {import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord} current
|
|
181
176
|
* @param {ReturnType<import('@agoric/smart-wallet/src/utils.js').makeWalletStateCoalescer>['state']} coalesced
|
|
182
|
-
* @param {
|
|
177
|
+
* @param {import('./wallet.js').AgoricNamesRemotes} agoricNames
|
|
183
178
|
*/
|
|
184
179
|
export const summarize = (current, coalesced, agoricNames) => {
|
|
185
180
|
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,25 @@ 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 ErrNotFound; there is no data at the path
|
|
152
|
+
(err.codespace === 'sdk' && err.code === 38) ||
|
|
153
|
+
// CosmosSDK ErrUnknownRequest; misrepresentation of the same until
|
|
154
|
+
// https://github.com/Agoric/agoric-sdk/commit/dafc7c1708977aaa55e245dc09a73859cf1df192
|
|
155
|
+
// TODO remove after upgrade-12
|
|
156
|
+
err.message.match(/unknown request/)
|
|
157
|
+
) {
|
|
147
158
|
// console.error(err);
|
|
148
159
|
break;
|
|
149
160
|
}
|
|
@@ -242,6 +253,7 @@ export const makeAgoricNames = async (ctx, vstorage) => {
|
|
|
242
253
|
* @param {MinimalNetworkConfig} config
|
|
243
254
|
*/
|
|
244
255
|
export const makeRpcUtils = async ({ fetch }, config = networkConfig) => {
|
|
256
|
+
await null;
|
|
245
257
|
try {
|
|
246
258
|
const vstorage = makeVStorage({ fetch }, config);
|
|
247
259
|
const fromBoard = makeFromBoard();
|