agoric 0.21.2-other-dev-3eb1a1d.0 → 0.21.2-other-dev-d15096d.0.d15096d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -73
- package/package.json +51 -49
- package/src/bin-agops.js +1 -5
- package/src/chain-config.js +9 -2
- package/src/commands/gov.js +29 -18
- package/src/commands/inter.js +17 -530
- package/src/commands/oracle.js +71 -43
- package/src/commands/perf.js +21 -13
- package/src/commands/psm.js +24 -15
- package/src/commands/reserve.js +17 -7
- package/src/commands/test-upgrade.js +15 -9
- package/src/commands/vaults.js +17 -7
- package/src/commands/wallet.js +38 -31
- package/src/deploy.js +7 -1
- package/src/entrypoint.js +1 -2
- package/src/follow.js +13 -8
- package/src/helpers.js +2 -1
- package/src/install.js +3 -11
- package/src/lib/casting.js +5 -1
- package/src/lib/chain.js +17 -31
- package/src/lib/format.js +7 -4
- package/src/lib/index.js +7 -0
- package/src/lib/packageManager.js +24 -0
- package/src/lib/wallet.js +25 -19
- package/src/main-publish.js +5 -1
- package/src/main.js +4 -36
- package/src/publish.js +15 -5
- package/src/scripts.js +10 -31
- package/src/sdk-package-names.js +12 -4
- package/src/start.js +2 -3
- package/tools/getting-started.js +30 -7
- package/src/commands/auction.js +0 -169
- package/src/lib/network-config.js +0 -41
package/src/commands/wallet.js
CHANGED
|
@@ -8,7 +8,11 @@ import {
|
|
|
8
8
|
makeLeader,
|
|
9
9
|
makeLeaderFromRpcAddresses,
|
|
10
10
|
} from '@agoric/casting';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
makeVstorageKit,
|
|
13
|
+
fetchEnvNetworkConfig,
|
|
14
|
+
makeAgoricNames,
|
|
15
|
+
} from '@agoric/client-utils';
|
|
12
16
|
import { execFileSync } from 'child_process';
|
|
13
17
|
import fs from 'fs';
|
|
14
18
|
import util from 'util';
|
|
@@ -19,25 +23,28 @@ import {
|
|
|
19
23
|
fetchSwingsetParams,
|
|
20
24
|
normalizeAddressWithOptions,
|
|
21
25
|
} from '../lib/chain.js';
|
|
22
|
-
import { getNetworkConfig } from '../lib/network-config.js';
|
|
23
|
-
import { coalesceWalletState, getCurrent } from '../lib/wallet.js';
|
|
24
26
|
import {
|
|
25
|
-
summarize,
|
|
26
27
|
fmtRecordOfLines,
|
|
27
28
|
parseFiniteNumber,
|
|
29
|
+
summarize,
|
|
28
30
|
} from '../lib/format.js';
|
|
31
|
+
import { coalesceWalletState, getCurrent } from '../lib/wallet.js';
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
/**
|
|
34
|
+
* @import {Command} from 'commander';
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
|
|
31
38
|
|
|
32
39
|
const SLEEP_SECONDS = 3;
|
|
33
40
|
|
|
34
41
|
/**
|
|
35
|
-
* @param {
|
|
36
|
-
* @returns {Promise<
|
|
42
|
+
* @param {Command['command']} command
|
|
43
|
+
* @returns {Promise<Command>}
|
|
37
44
|
*/
|
|
38
45
|
export const makeWalletCommand = async command => {
|
|
39
46
|
/**
|
|
40
|
-
* @param {
|
|
47
|
+
* @param {Command} baseCmd
|
|
41
48
|
*/
|
|
42
49
|
const withSharedTxOptions = baseCmd =>
|
|
43
50
|
baseCmd
|
|
@@ -52,6 +59,7 @@ export const makeWalletCommand = async command => {
|
|
|
52
59
|
'wallet commands',
|
|
53
60
|
);
|
|
54
61
|
|
|
62
|
+
/** @param {string} literalOrName */
|
|
55
63
|
const normalizeAddress = literalOrName =>
|
|
56
64
|
normalizeAddressWithOptions(literalOrName, wallet.opts());
|
|
57
65
|
|
|
@@ -64,7 +72,8 @@ export const makeWalletCommand = async command => {
|
|
|
64
72
|
)
|
|
65
73
|
.option('--spend', 'confirm you want to spend')
|
|
66
74
|
.option('--nickname <string>', 'nickname to use', 'my-wallet')
|
|
67
|
-
.action(function (opts) {
|
|
75
|
+
.action(async function (opts) {
|
|
76
|
+
await null;
|
|
68
77
|
/** @typedef {{account: string, spend?: boolean, nickname: 'my-wallet' | string }} Opts */
|
|
69
78
|
const {
|
|
70
79
|
account,
|
|
@@ -81,12 +90,12 @@ export const makeWalletCommand = async command => {
|
|
|
81
90
|
...networkConfig,
|
|
82
91
|
});
|
|
83
92
|
} else {
|
|
84
|
-
const params = fetchSwingsetParams(networkConfig);
|
|
93
|
+
const params = await fetchSwingsetParams(networkConfig);
|
|
85
94
|
assert(
|
|
86
|
-
params.
|
|
95
|
+
params.powerFlagFees.length === 1,
|
|
87
96
|
'multiple power_flag_fees not supported',
|
|
88
97
|
);
|
|
89
|
-
const { fee: fees } = params.
|
|
98
|
+
const { fee: fees } = params.powerFlagFees[0];
|
|
90
99
|
const nf = new Intl.NumberFormat('en-US');
|
|
91
100
|
const costs = fees
|
|
92
101
|
.map(f => `${nf.format(Number(f.amount))} ${f.denom}`)
|
|
@@ -109,9 +118,9 @@ export const makeWalletCommand = async command => {
|
|
|
109
118
|
.action(async function (opts) {
|
|
110
119
|
const offerStr = fs.readFileSync(opts.file).toString();
|
|
111
120
|
|
|
112
|
-
const {
|
|
121
|
+
const { marshaller } = makeVstorageKit({ fetch }, networkConfig);
|
|
113
122
|
|
|
114
|
-
const offerObj =
|
|
123
|
+
const offerObj = marshaller.fromCapData(JSON.parse(offerStr));
|
|
115
124
|
console.log(offerObj);
|
|
116
125
|
});
|
|
117
126
|
|
|
@@ -124,9 +133,9 @@ export const makeWalletCommand = async command => {
|
|
|
124
133
|
.action(async function (opts) {
|
|
125
134
|
const offerStr = fs.readFileSync(opts.offer).toString();
|
|
126
135
|
|
|
127
|
-
const {
|
|
136
|
+
const { marshaller } = makeVstorageKit({ fetch }, networkConfig);
|
|
128
137
|
|
|
129
|
-
const offerObj =
|
|
138
|
+
const offerObj = marshaller.fromCapData(JSON.parse(offerStr));
|
|
130
139
|
console.log(offerObj.offer.id);
|
|
131
140
|
});
|
|
132
141
|
|
|
@@ -201,7 +210,7 @@ export const makeWalletCommand = async command => {
|
|
|
201
210
|
.command('list')
|
|
202
211
|
.description('list all wallets in vstorage')
|
|
203
212
|
.action(async function () {
|
|
204
|
-
const { vstorage } =
|
|
213
|
+
const { vstorage } = makeVstorageKit({ fetch }, networkConfig);
|
|
205
214
|
const wallets = await vstorage.keys('published.wallet');
|
|
206
215
|
process.stdout.write(wallets.join('\n'));
|
|
207
216
|
});
|
|
@@ -215,19 +224,19 @@ export const makeWalletCommand = async command => {
|
|
|
215
224
|
normalizeAddress,
|
|
216
225
|
)
|
|
217
226
|
.action(async function (opts) {
|
|
218
|
-
const {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
);
|
|
227
|
+
const {
|
|
228
|
+
readPublished,
|
|
229
|
+
marshaller: unserializer,
|
|
230
|
+
...vsk
|
|
231
|
+
} = makeVstorageKit({ fetch }, networkConfig);
|
|
232
|
+
const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
|
|
225
233
|
|
|
226
234
|
const leader = makeLeader(networkConfig.rpcAddrs[0]);
|
|
227
235
|
const follower = await makeFollower(
|
|
228
236
|
`:published.wallet.${opts.from}`,
|
|
229
237
|
leader,
|
|
230
238
|
{
|
|
239
|
+
// @ts-expect-error xxx follower/marshaller types
|
|
231
240
|
unserializer,
|
|
232
241
|
},
|
|
233
242
|
);
|
|
@@ -274,15 +283,13 @@ export const makeWalletCommand = async command => {
|
|
|
274
283
|
.action(async function ({ from }) {
|
|
275
284
|
const spec = `:published.wallet.${from}`;
|
|
276
285
|
|
|
277
|
-
const leaderOptions = makeLeaderOptions({
|
|
278
|
-
sleep: SLEEP_SECONDS,
|
|
279
|
-
jitter: 0,
|
|
280
|
-
log: () => undefined,
|
|
281
|
-
});
|
|
282
|
-
|
|
283
286
|
const leader = makeLeaderFromRpcAddresses(
|
|
284
287
|
networkConfig.rpcAddrs,
|
|
285
|
-
|
|
288
|
+
makeLeaderOptions({
|
|
289
|
+
sleep: SLEEP_SECONDS,
|
|
290
|
+
jitter: 0,
|
|
291
|
+
log: console.warn,
|
|
292
|
+
}),
|
|
286
293
|
);
|
|
287
294
|
|
|
288
295
|
console.warn('Following', spec);
|
package/src/deploy.js
CHANGED
|
@@ -190,6 +190,12 @@ const connectAndRun = async (
|
|
|
190
190
|
return retryWebsocket().then(() => exit.promise);
|
|
191
191
|
};
|
|
192
192
|
|
|
193
|
+
/**
|
|
194
|
+
* @param {string} progname
|
|
195
|
+
* @param {string[]} rawArgs
|
|
196
|
+
* @param {{ makeWebSocket?: (...args: ConstructorParameters<typeof WebSocket>) => WebSocket; anylogger: (name: string) => Console; now?: () => number; fs?: any; }} powers
|
|
197
|
+
* @param {{ allowUnsafePlugins: any; provide: string; sdk: any; need: string; hostport: string; target: string | number | undefined; scriptArgs: any; }} opts
|
|
198
|
+
*/
|
|
193
199
|
export default async function deployMain(progname, rawArgs, powers, opts) {
|
|
194
200
|
const { anylogger, now, fs } = powers;
|
|
195
201
|
const console = anylogger('agoric:deploy');
|
|
@@ -238,7 +244,7 @@ export default async function deployMain(progname, rawArgs, powers, opts) {
|
|
|
238
244
|
|
|
239
245
|
const match = opts.hostport.match(/^(.*):(\d+)$/);
|
|
240
246
|
const host = match ? match[1] : 'localhost';
|
|
241
|
-
const port = match ? match[2] :
|
|
247
|
+
const port = match ? +match[2] : 8000;
|
|
242
248
|
|
|
243
249
|
const wsurl = opts.hostport.includes('//')
|
|
244
250
|
? new URL(opts.hostport, 'ws://localhost:8000')
|
package/src/entrypoint.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
/* eslint-env node */
|
|
3
3
|
// @jessie-check
|
|
4
4
|
|
|
5
|
-
import '@endo/init/pre.js';
|
|
6
|
-
import 'esm';
|
|
7
5
|
import '@endo/init/legacy.js';
|
|
8
6
|
|
|
9
7
|
import path from 'path';
|
|
@@ -23,6 +21,7 @@ const log = anylogger('agoric');
|
|
|
23
21
|
const progname = path.basename(process.argv[1]);
|
|
24
22
|
|
|
25
23
|
const stdout = str => process.stdout.write(str);
|
|
24
|
+
/** @type {(...args: ConstructorParameters<typeof WebSocket>) => WebSocket} */
|
|
26
25
|
const makeWebSocket = (...args) => new WebSocket(...args);
|
|
27
26
|
|
|
28
27
|
const rawArgs = process.argv.slice(2);
|
package/src/follow.js
CHANGED
|
@@ -16,6 +16,10 @@ import {
|
|
|
16
16
|
} from '@agoric/casting';
|
|
17
17
|
import { makeLeaderOptions } from './lib/casting.js';
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @import {FollowerOptions} from '@agoric/casting';
|
|
21
|
+
*/
|
|
22
|
+
|
|
19
23
|
const makeCapDataToQclass = () => {
|
|
20
24
|
const valToSlot = new WeakMap();
|
|
21
25
|
const slotToVal = new Map();
|
|
@@ -57,7 +61,7 @@ export default async function followerMain(progname, rawArgs, powers, opts) {
|
|
|
57
61
|
jitter,
|
|
58
62
|
} = opts;
|
|
59
63
|
|
|
60
|
-
/** @type {
|
|
64
|
+
/** @type {FollowerOptions} */
|
|
61
65
|
const followerOptions = {
|
|
62
66
|
proof,
|
|
63
67
|
};
|
|
@@ -126,16 +130,17 @@ export default async function followerMain(progname, rawArgs, powers, opts) {
|
|
|
126
130
|
});
|
|
127
131
|
}
|
|
128
132
|
|
|
129
|
-
const leaderOptions = makeLeaderOptions({
|
|
130
|
-
sleep,
|
|
131
|
-
jitter,
|
|
132
|
-
log: verbose ? console.warn : () => undefined,
|
|
133
|
-
});
|
|
134
|
-
|
|
135
133
|
const [_cmd, ...specs] = rawArgs;
|
|
136
134
|
|
|
137
135
|
verbose && console.warn('Creating leader for', bootstrap);
|
|
138
|
-
const leader = makeLeader(
|
|
136
|
+
const leader = makeLeader(
|
|
137
|
+
bootstrap,
|
|
138
|
+
makeLeaderOptions({
|
|
139
|
+
sleep,
|
|
140
|
+
jitter,
|
|
141
|
+
log: verbose ? console.warn : () => undefined,
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
139
144
|
const iterate = opts.lossy ? iterateLatest : iterateEach;
|
|
140
145
|
await Promise.all(
|
|
141
146
|
specs.map(async spec => {
|
package/src/helpers.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
/** @import { ChildProcess } from 'child_process' */
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// Backwards compatibility
|
|
7
|
+
export { fetchEnvNetworkConfig as getNetworkConfig } from '@agoric/client-utils';
|
|
7
8
|
|
|
8
9
|
export const getSDKBinaries = ({
|
|
9
10
|
jsPfx = '../..',
|
package/src/install.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/* eslint-env node */
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
|
+
import { execFileSync } from 'child_process';
|
|
4
5
|
import { makePspawn } from './helpers.js';
|
|
5
6
|
import DEFAULT_SDK_PACKAGE_NAMES from './sdk-package-names.js';
|
|
7
|
+
import { listWorkspaces } from './lib/packageManager.js';
|
|
6
8
|
|
|
7
9
|
const REQUIRED_AGORIC_START_PACKAGES = [
|
|
8
10
|
'@agoric/solo',
|
|
@@ -30,17 +32,7 @@ export default async function installMain(progname, rawArgs, powers, opts) {
|
|
|
30
32
|
const rimraf = file => pspawn('rm', ['-rf', file]);
|
|
31
33
|
|
|
32
34
|
async function getWorktreePackagePaths(cwd = '.', map = new Map()) {
|
|
33
|
-
|
|
34
|
-
// use, instead of a hard-coded list
|
|
35
|
-
const p = pspawn('yarn', ['workspaces', '--silent', 'info'], {
|
|
36
|
-
cwd,
|
|
37
|
-
stdio: ['inherit', 'pipe', 'inherit'],
|
|
38
|
-
});
|
|
39
|
-
const stdout = [];
|
|
40
|
-
p.childProcess.stdout?.on('data', out => stdout.push(out));
|
|
41
|
-
await p;
|
|
42
|
-
const d = JSON.parse(Buffer.concat(stdout).toString('utf-8'));
|
|
43
|
-
for (const [name, { location }] of Object.entries(d)) {
|
|
35
|
+
for (const { name, location } of listWorkspaces({ execFileSync }, cwd)) {
|
|
44
36
|
map.set(name, path.resolve(cwd, location));
|
|
45
37
|
}
|
|
46
38
|
return map;
|
package/src/lib/casting.js
CHANGED
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import { delay, exponentialBackoff, randomBackoff } from '@agoric/casting';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @import {LeaderOptions} from '@agoric/casting';
|
|
7
|
+
*/
|
|
8
|
+
|
|
5
9
|
// TODO: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
|
|
6
10
|
/**
|
|
7
11
|
* @param {{log: (...args: any) => void, sleep: number, jitter: number }} config
|
|
8
|
-
* @returns {
|
|
12
|
+
* @returns {LeaderOptions}
|
|
9
13
|
*/
|
|
10
14
|
export const makeLeaderOptions = ({ log, sleep, jitter }) => {
|
|
11
15
|
return {
|
package/src/lib/chain.js
CHANGED
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
/* eslint-env node */
|
|
3
3
|
import { normalizeBech32 } from '@cosmjs/encoding';
|
|
4
4
|
import { execFileSync as execFileSyncAmbient } from 'child_process';
|
|
5
|
+
import { makeAgoricQueryClient } from '@agoric/client-utils';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @import {MinimalNetworkConfig} from '@agoric/client-utils';
|
|
9
|
+
* @import {Params, ParamsSDKType} from '@agoric/cosmic-proto/agoric/swingset/swingset.js';
|
|
10
|
+
* @import {Writable} from 'stream';
|
|
8
11
|
*/
|
|
9
12
|
|
|
10
13
|
const agdBinary = 'agd';
|
|
@@ -77,8 +80,8 @@ const makeGasOpts = limit => {
|
|
|
77
80
|
* dryRun?: boolean,
|
|
78
81
|
* verbose?: boolean,
|
|
79
82
|
* keyring?: {home?: string, backend: string}
|
|
80
|
-
* stdout?: Pick<
|
|
81
|
-
* execFileSync?: typeof
|
|
83
|
+
* stdout?: Pick<Writable, 'write'>
|
|
84
|
+
* execFileSync?: typeof execFileSyncAmbient
|
|
82
85
|
* }} opts
|
|
83
86
|
*/
|
|
84
87
|
export const execSwingsetTransaction = (swingsetArgs, opts) => {
|
|
@@ -132,27 +135,18 @@ harden(execSwingsetTransaction);
|
|
|
132
135
|
/**
|
|
133
136
|
*
|
|
134
137
|
* @param {MinimalNetworkConfig} net
|
|
138
|
+
* @returns {Promise<Params>}
|
|
135
139
|
*/
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const {
|
|
139
|
-
|
|
140
|
-
`--node=${rpcAddrs[0]}`,
|
|
141
|
-
`--chain-id=${chainName}`,
|
|
142
|
-
'query',
|
|
143
|
-
'swingset',
|
|
144
|
-
'params',
|
|
145
|
-
'--output',
|
|
146
|
-
'json',
|
|
147
|
-
];
|
|
148
|
-
const buffer = execFileSyncAmbient(agdBinary, cmd);
|
|
149
|
-
return JSON.parse(buffer.toString());
|
|
140
|
+
export const fetchSwingsetParams = async net => {
|
|
141
|
+
const client = await makeAgoricQueryClient(net);
|
|
142
|
+
const { params } = await client.agoric.swingset.params();
|
|
143
|
+
return params;
|
|
150
144
|
};
|
|
151
145
|
harden(fetchSwingsetParams);
|
|
152
146
|
|
|
153
147
|
/**
|
|
154
148
|
* @param {MinimalNetworkConfig & {
|
|
155
|
-
* execFileSync: typeof
|
|
149
|
+
* execFileSync: typeof execFileSyncAmbient,
|
|
156
150
|
* delay: (ms: number) => Promise<void>,
|
|
157
151
|
* period?: number,
|
|
158
152
|
* retryMessage?: string,
|
|
@@ -170,9 +164,8 @@ export const pollBlocks = opts => async lookup => {
|
|
|
170
164
|
for (;;) {
|
|
171
165
|
const sTxt = execFileSync(agdBinary, ['status', ...nodeArgs]);
|
|
172
166
|
const status = JSON.parse(sTxt.toString());
|
|
173
|
-
const {
|
|
174
|
-
|
|
175
|
-
} = status;
|
|
167
|
+
const { latest_block_time: time, latest_block_height: height } =
|
|
168
|
+
status.sync_info || status.SyncInfo;
|
|
176
169
|
try {
|
|
177
170
|
// see await null above
|
|
178
171
|
const result = await lookup({ time, height });
|
|
@@ -192,13 +185,13 @@ export const pollBlocks = opts => async lookup => {
|
|
|
192
185
|
/**
|
|
193
186
|
* @param {string} txhash
|
|
194
187
|
* @param {MinimalNetworkConfig & {
|
|
195
|
-
* execFileSync: typeof
|
|
188
|
+
* execFileSync: typeof execFileSyncAmbient,
|
|
196
189
|
* delay: (ms: number) => Promise<void>,
|
|
197
190
|
* period?: number,
|
|
198
191
|
* }} opts
|
|
199
192
|
*/
|
|
200
193
|
export const pollTx = async (txhash, opts) => {
|
|
201
|
-
const { execFileSync, rpcAddrs
|
|
194
|
+
const { execFileSync, rpcAddrs } = opts;
|
|
202
195
|
|
|
203
196
|
const nodeArgs = [`--node=${rpcAddrs[0]}`];
|
|
204
197
|
const outJson = ['--output', 'json'];
|
|
@@ -206,15 +199,8 @@ export const pollTx = async (txhash, opts) => {
|
|
|
206
199
|
const lookup = async () => {
|
|
207
200
|
const out = execFileSync(
|
|
208
201
|
agdBinary,
|
|
209
|
-
[
|
|
210
|
-
|
|
211
|
-
'tx',
|
|
212
|
-
txhash,
|
|
213
|
-
`--chain-id=${chainName}`,
|
|
214
|
-
...nodeArgs,
|
|
215
|
-
...outJson,
|
|
216
|
-
],
|
|
217
|
-
{ stdio: ['ignore', 'pipe', 'ignore'] },
|
|
202
|
+
['query', 'tx', txhash, ...nodeArgs, ...outJson],
|
|
203
|
+
{ stdio: ['ignore', 'pipe', 'pipe'] },
|
|
218
204
|
);
|
|
219
205
|
// XXX this type is defined in a .proto file somewhere
|
|
220
206
|
/** @type {{ height: string, txhash: string, code: number, timestamp: string }} */
|
package/src/lib/format.js
CHANGED
|
@@ -4,6 +4,9 @@ import { makeBoardRemote } from '@agoric/vats/tools/board-utils.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* @import {Amount, Brand} from '@agoric/ertp'
|
|
6
6
|
* @import {AgoricNamesRemotes, BoardRemote, VBankAssetDetail} from '@agoric/vats/tools/board-utils.js';
|
|
7
|
+
* @import {CurrentWalletRecord} from '@agoric/smart-wallet/src/smartWallet.js';
|
|
8
|
+
* @import {CoalescedWalletState} from '@agoric/smart-wallet/src/utils.js';
|
|
9
|
+
* @import {makeWalletStateCoalescer} from '@agoric/smart-wallet/src/utils.js';
|
|
7
10
|
*/
|
|
8
11
|
|
|
9
12
|
// TODO Move to packages/internal.
|
|
@@ -87,7 +90,7 @@ export const asBoardRemote = x => {
|
|
|
87
90
|
/**
|
|
88
91
|
* Summarize the balances array as user-facing informative tuples
|
|
89
92
|
*
|
|
90
|
-
* @param {
|
|
93
|
+
* @param {CurrentWalletRecord['purses']} purses
|
|
91
94
|
* @param {VBankAssetDetail[]} assets
|
|
92
95
|
*/
|
|
93
96
|
export const purseBalanceTuples = (purses, assets) => {
|
|
@@ -115,7 +118,7 @@ export const fmtRecordOfLines = record => {
|
|
|
115
118
|
/**
|
|
116
119
|
* Summarize the offerStatuses of the state as user-facing informative tuples
|
|
117
120
|
*
|
|
118
|
-
* @param {
|
|
121
|
+
* @param {CoalescedWalletState} state
|
|
119
122
|
* @param {AgoricNamesRemotes} agoricNames
|
|
120
123
|
*/
|
|
121
124
|
export const offerStatusTuples = (state, agoricNames) => {
|
|
@@ -171,8 +174,8 @@ export const offerStatusTuples = (state, agoricNames) => {
|
|
|
171
174
|
};
|
|
172
175
|
|
|
173
176
|
/**
|
|
174
|
-
* @param {
|
|
175
|
-
* @param {ReturnType<
|
|
177
|
+
* @param {CurrentWalletRecord} current
|
|
178
|
+
* @param {ReturnType<typeof makeWalletStateCoalescer>['state']} coalesced
|
|
176
179
|
* @param {AgoricNamesRemotes} agoricNames
|
|
177
180
|
*/
|
|
178
181
|
export const summarize = (current, coalesced, agoricNames) => {
|
package/src/lib/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @import { execFileSync } from 'child_process';
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Omits the root
|
|
9
|
+
*
|
|
10
|
+
* @param {{ execFileSync: execFileSync }} io
|
|
11
|
+
* @param {string} [root]
|
|
12
|
+
* @returns {Array<{ location: string, name: string }>}
|
|
13
|
+
*/
|
|
14
|
+
export const listWorkspaces = ({ execFileSync }, root) => {
|
|
15
|
+
const out = execFileSync('npm', ['query', '.workspace'], {
|
|
16
|
+
stdio: ['ignore', 'pipe', 'inherit'],
|
|
17
|
+
shell: true,
|
|
18
|
+
encoding: 'utf-8',
|
|
19
|
+
cwd: root,
|
|
20
|
+
});
|
|
21
|
+
/** @type {Array<{ location: string, name: string, description: string }>} */
|
|
22
|
+
const result = JSON.parse(out);
|
|
23
|
+
return result.filter(({ location }) => location !== '.');
|
|
24
|
+
};
|
package/src/lib/wallet.js
CHANGED
|
@@ -11,6 +11,13 @@ import { execSwingsetTransaction, pollTx } from './chain.js';
|
|
|
11
11
|
* @import {CurrentWalletRecord} from '@agoric/smart-wallet/src/smartWallet.js';
|
|
12
12
|
* @import {AgoricNamesRemotes} from '@agoric/vats/tools/board-utils.js';
|
|
13
13
|
* @import {MinimalNetworkConfig, VstorageKit} from '@agoric/client-utils';
|
|
14
|
+
* @import {UpdateRecord} from '@agoric/smart-wallet/src/smartWallet.js';
|
|
15
|
+
* @import {BridgeAction} from '@agoric/smart-wallet/src/smartWallet.js';
|
|
16
|
+
* @import {Writable} from 'stream';
|
|
17
|
+
* @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
|
|
18
|
+
* @import {Follower} from '@agoric/casting';
|
|
19
|
+
* @import {ValueFollowerElement} from '@agoric/casting';
|
|
20
|
+
* @import {execFileSync} from 'child_process';
|
|
14
21
|
*/
|
|
15
22
|
|
|
16
23
|
const marshaller = boardSlottingMarshaller();
|
|
@@ -26,15 +33,14 @@ const emptyCurrentRecord = {
|
|
|
26
33
|
/**
|
|
27
34
|
* @param {string} addr
|
|
28
35
|
* @param {Pick<VstorageKit, 'readPublished'>} io
|
|
29
|
-
* @returns {Promise<
|
|
36
|
+
* @returns {Promise<CurrentWalletRecord>}
|
|
30
37
|
*/
|
|
31
38
|
export const getCurrent = async (addr, { readPublished }) => {
|
|
32
39
|
// Partial because older writes may not have had all properties
|
|
33
40
|
// NB: assumes changes are only additions
|
|
34
|
-
let current =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
41
|
+
let current = /** @type {Partial<CurrentWalletRecord> | undefined} */ (
|
|
42
|
+
await readPublished(`wallet.${addr}.current`)
|
|
43
|
+
);
|
|
38
44
|
if (current === undefined) {
|
|
39
45
|
throw Error(`undefined current node for ${addr}`);
|
|
40
46
|
}
|
|
@@ -61,15 +67,15 @@ export const getCurrent = async (addr, { readPublished }) => {
|
|
|
61
67
|
/**
|
|
62
68
|
* @param {string} addr
|
|
63
69
|
* @param {Pick<VstorageKit, 'readPublished'>} io
|
|
64
|
-
* @returns {Promise<
|
|
70
|
+
* @returns {Promise<UpdateRecord>}
|
|
65
71
|
*/
|
|
66
72
|
export const getLastUpdate = (addr, { readPublished }) => {
|
|
67
73
|
return readPublished(`wallet.${addr}`);
|
|
68
74
|
};
|
|
69
75
|
|
|
70
76
|
/**
|
|
71
|
-
* @param {
|
|
72
|
-
* @param {Pick<
|
|
77
|
+
* @param {BridgeAction} bridgeAction
|
|
78
|
+
* @param {Pick<Writable,'write'>} [stdout]
|
|
73
79
|
*/
|
|
74
80
|
export const outputAction = (bridgeAction, stdout = process.stdout) => {
|
|
75
81
|
const capData = marshaller.toCapData(harden(bridgeAction));
|
|
@@ -81,10 +87,10 @@ export const sendHint =
|
|
|
81
87
|
'Now use `agoric wallet send ...` to sign and broadcast the offer.\n';
|
|
82
88
|
|
|
83
89
|
/**
|
|
84
|
-
* @param {
|
|
90
|
+
* @param {BridgeAction} bridgeAction
|
|
85
91
|
* @param {{
|
|
86
|
-
* stdout: Pick<
|
|
87
|
-
* stderr: Pick<
|
|
92
|
+
* stdout: Pick<Writable,'write'>,
|
|
93
|
+
* stderr: Pick<Writable,'write'>,
|
|
88
94
|
* }} io
|
|
89
95
|
*/
|
|
90
96
|
export const outputActionAndHint = (bridgeAction, { stdout, stderr }) => {
|
|
@@ -93,16 +99,16 @@ export const outputActionAndHint = (bridgeAction, { stdout, stderr }) => {
|
|
|
93
99
|
};
|
|
94
100
|
|
|
95
101
|
/**
|
|
96
|
-
* @param {
|
|
97
|
-
* @param {Pick<
|
|
98
|
-
* @param {Pick<
|
|
102
|
+
* @param {OfferSpec} offer
|
|
103
|
+
* @param {Pick<Writable,'write'>} [stdout]
|
|
104
|
+
* @param {Pick<Writable,'write'>} [stderr]
|
|
99
105
|
*/
|
|
100
106
|
export const outputExecuteOfferAction = (
|
|
101
107
|
offer,
|
|
102
108
|
stdout = process.stdout,
|
|
103
109
|
stderr = process.stderr,
|
|
104
110
|
) => {
|
|
105
|
-
/** @type {
|
|
111
|
+
/** @type {BridgeAction} */
|
|
106
112
|
const spendAction = {
|
|
107
113
|
method: 'executeOffer',
|
|
108
114
|
offer,
|
|
@@ -113,7 +119,7 @@ export const outputExecuteOfferAction = (
|
|
|
113
119
|
|
|
114
120
|
/**
|
|
115
121
|
* @deprecated use `.current` node for current state
|
|
116
|
-
* @param {
|
|
122
|
+
* @param {Follower<ValueFollowerElement<UpdateRecord>>} follower
|
|
117
123
|
* @param {Brand<'set'>} [invitationBrand]
|
|
118
124
|
*/
|
|
119
125
|
export const coalesceWalletState = async (follower, invitationBrand) => {
|
|
@@ -143,14 +149,14 @@ export const coalesceWalletState = async (follower, invitationBrand) => {
|
|
|
143
149
|
* Sign and broadcast a wallet-action.
|
|
144
150
|
*
|
|
145
151
|
* @throws { Error & { code: number } } if transaction fails
|
|
146
|
-
* @param {
|
|
152
|
+
* @param {BridgeAction} bridgeAction
|
|
147
153
|
* @param {MinimalNetworkConfig & {
|
|
148
154
|
* from: string,
|
|
149
155
|
* fees?: string,
|
|
150
156
|
* verbose?: boolean,
|
|
151
157
|
* keyring?: {home?: string, backend: string},
|
|
152
|
-
* stdout
|
|
153
|
-
* execFileSync: typeof
|
|
158
|
+
* stdout?: Pick<Writable, 'write'>,
|
|
159
|
+
* execFileSync: typeof execFileSync,
|
|
154
160
|
* delay: (ms: number) => Promise<void>,
|
|
155
161
|
* dryRun?: boolean,
|
|
156
162
|
* }} opts
|
package/src/main-publish.js
CHANGED
|
@@ -9,6 +9,10 @@ import { parseLocatedJson } from './json.js';
|
|
|
9
9
|
|
|
10
10
|
import { makeBundlePublisher, makeCosmosBundlePublisher } from './publish.js';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* @import {CosmosConnectionSpec} from './publish.js';
|
|
14
|
+
*/
|
|
15
|
+
|
|
12
16
|
const publishMain = async (progname, rawArgs, powers, opts) => {
|
|
13
17
|
const { fs } = powers;
|
|
14
18
|
|
|
@@ -23,7 +27,7 @@ const publishMain = async (progname, rawArgs, powers, opts) => {
|
|
|
23
27
|
);
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
/** @type {
|
|
30
|
+
/** @type {CosmosConnectionSpec} */
|
|
27
31
|
const connectionSpec = {
|
|
28
32
|
type: 'chain-cosmos-sdk',
|
|
29
33
|
rpcAddresses: [rpcAddress],
|