agoric 0.21.2-other-dev-fbe72e7.0.fbe72e7 → 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/package.json +21 -21
- package/src/bin-agops.js +0 -2
- package/src/commands/gov.js +5 -3
- package/src/commands/inter.js +15 -527
- package/src/commands/oracle.js +16 -8
- package/src/commands/perf.js +5 -1
- package/src/commands/psm.js +8 -3
- package/src/commands/reserve.js +7 -2
- package/src/commands/test-upgrade.js +12 -5
- package/src/commands/vaults.js +5 -1
- package/src/commands/wallet.js +7 -3
- package/src/follow.js +5 -1
- package/src/lib/casting.js +5 -1
- package/src/lib/chain.js +5 -4
- package/src/lib/format.js +7 -4
- package/src/lib/wallet.js +25 -19
- package/src/main-publish.js +5 -1
- package/src/publish.js +15 -5
- package/src/scripts.js +9 -3
- package/src/sdk-package-names.js +1 -0
- package/src/start.js +2 -2
- package/tools/getting-started.js +8 -3
- package/src/commands/auction.js +0 -173
package/src/commands/oracle.js
CHANGED
|
@@ -23,7 +23,15 @@ import {
|
|
|
23
23
|
sendHint,
|
|
24
24
|
} from '../lib/wallet.js';
|
|
25
25
|
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
|
|
28
|
+
* @import {createCommand} from 'commander';
|
|
29
|
+
* @import {execFileSync} from 'child_process';
|
|
30
|
+
* @import {Writable} from 'stream';
|
|
31
|
+
* @import {Logger} from 'anylogger';
|
|
32
|
+
* @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
|
|
33
|
+
* @import {TimestampRecord} from '@agoric/time';
|
|
34
|
+
*/
|
|
27
35
|
|
|
28
36
|
// XXX support other decimal places
|
|
29
37
|
const COSMOS_UNIT = 1_000_000n;
|
|
@@ -34,15 +42,15 @@ const scaleDecimals = num => BigInt(Math.round(num * Number(COSMOS_UNIT)));
|
|
|
34
42
|
* Prints JSON output to stdout and diagnostic info (like logs) to stderr
|
|
35
43
|
*
|
|
36
44
|
* @param {{
|
|
37
|
-
* createCommand: typeof
|
|
45
|
+
* createCommand: typeof createCommand,
|
|
38
46
|
* env: Partial<Record<string, string>>,
|
|
39
|
-
* execFileSync: typeof
|
|
47
|
+
* execFileSync: typeof execFileSync,
|
|
40
48
|
* now: () => number,
|
|
41
49
|
* setTimeout: typeof setTimeout,
|
|
42
|
-
* stderr: Pick<
|
|
43
|
-
* stdout: Pick<
|
|
50
|
+
* stderr: Pick<Writable,'write'>,
|
|
51
|
+
* stdout: Pick<Writable,'write'>,
|
|
44
52
|
* }} process
|
|
45
|
-
* @param {
|
|
53
|
+
* @param {Logger} [logger]
|
|
46
54
|
*/
|
|
47
55
|
export const makeOracleCommand = (
|
|
48
56
|
{ env, execFileSync, setTimeout, stderr, stdout },
|
|
@@ -132,7 +140,7 @@ export const makeOracleCommand = (
|
|
|
132
140
|
const { lookupPriceAggregatorInstance } = await rpcTools();
|
|
133
141
|
const instance = lookupPriceAggregatorInstance(opts.pair);
|
|
134
142
|
|
|
135
|
-
/** @type {
|
|
143
|
+
/** @type {OfferSpec} */
|
|
136
144
|
const offer = {
|
|
137
145
|
id: opts.offerId,
|
|
138
146
|
invitationSpec: {
|
|
@@ -326,7 +334,7 @@ export const makeOracleCommand = (
|
|
|
326
334
|
);
|
|
327
335
|
|
|
328
336
|
const latestRoundP =
|
|
329
|
-
/** @type {Promise<{roundId: number, startedAt:
|
|
337
|
+
/** @type {Promise<{roundId: number, startedAt: TimestampRecord, startedBy: string}>} */ (
|
|
330
338
|
readLatestHead(
|
|
331
339
|
`published.priceFeed.${pair[0]}-${pair[1]}_price_feed.latestRound`,
|
|
332
340
|
)
|
package/src/commands/perf.js
CHANGED
|
@@ -19,13 +19,17 @@ import {
|
|
|
19
19
|
normalizeAddressWithOptions,
|
|
20
20
|
} from '../lib/chain.js';
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @import {Logger} from 'anylogger';
|
|
24
|
+
*/
|
|
25
|
+
|
|
22
26
|
// tight for perf testing but less than this tends to hang.
|
|
23
27
|
const SLEEP_SECONDS = 0.1;
|
|
24
28
|
|
|
25
29
|
const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
|
-
* @param {
|
|
32
|
+
* @param {Logger} logger
|
|
29
33
|
*/
|
|
30
34
|
export const makePerfCommand = logger => {
|
|
31
35
|
const perf = new Command('perf')
|
package/src/commands/psm.js
CHANGED
|
@@ -12,6 +12,11 @@ import { Command } from 'commander';
|
|
|
12
12
|
import { asPercent } from '../lib/format.js';
|
|
13
13
|
import { outputExecuteOfferAction } from '../lib/wallet.js';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* @import {Logger} from 'anylogger';
|
|
17
|
+
* @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
|
|
18
|
+
*/
|
|
19
|
+
|
|
15
20
|
const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
|
|
16
21
|
|
|
17
22
|
// Adapted from https://gist.github.com/dckc/8b5b2f16395cb4d7f2ff340e0bc6b610#file-psm-tool
|
|
@@ -36,7 +41,7 @@ function collectValues(val, memo) {
|
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
/**
|
|
39
|
-
* @param {
|
|
44
|
+
* @param {Logger} logger
|
|
40
45
|
*/
|
|
41
46
|
export const makePsmCommand = logger => {
|
|
42
47
|
const psm = new Command('psm').description('PSM commands').usage(
|
|
@@ -205,7 +210,7 @@ export const makePsmCommand = logger => {
|
|
|
205
210
|
const { lookupPsmInstance } = await rpcTools();
|
|
206
211
|
const psmInstance = lookupPsmInstance(opts.pair);
|
|
207
212
|
|
|
208
|
-
/** @type {
|
|
213
|
+
/** @type {OfferSpec} */
|
|
209
214
|
const offer = {
|
|
210
215
|
id: opts.offerId,
|
|
211
216
|
invitationSpec: {
|
|
@@ -260,7 +265,7 @@ export const makePsmCommand = logger => {
|
|
|
260
265
|
brand: istBrand,
|
|
261
266
|
value: BigInt(opts.limit * 1_000_000),
|
|
262
267
|
});
|
|
263
|
-
/** @type {
|
|
268
|
+
/** @type {OfferSpec} */
|
|
264
269
|
const offer = {
|
|
265
270
|
id: opts.offerId,
|
|
266
271
|
invitationSpec: {
|
package/src/commands/reserve.js
CHANGED
|
@@ -10,10 +10,15 @@ import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
|
|
|
10
10
|
import { Command } from 'commander';
|
|
11
11
|
import { outputActionAndHint } from '../lib/wallet.js';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @import {Logger} from 'anylogger';
|
|
15
|
+
* @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
|
|
16
|
+
*/
|
|
17
|
+
|
|
13
18
|
const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
|
|
14
19
|
|
|
15
20
|
/**
|
|
16
|
-
* @param {
|
|
21
|
+
* @param {Logger} _logger
|
|
17
22
|
* @param {*} io
|
|
18
23
|
*/
|
|
19
24
|
export const makeReserveCommand = (_logger, io = {}) => {
|
|
@@ -78,7 +83,7 @@ export const makeReserveCommand = (_logger, io = {}) => {
|
|
|
78
83
|
|
|
79
84
|
const feesToBurn = { brand: agoricNames.brand.IST, value: opts.value };
|
|
80
85
|
|
|
81
|
-
/** @type {
|
|
86
|
+
/** @type {OfferSpec} */
|
|
82
87
|
const offer = {
|
|
83
88
|
id: opts.offerId,
|
|
84
89
|
invitationSpec: {
|
|
@@ -7,17 +7,24 @@ import { normalizeAddressWithOptions } from '../lib/chain.js';
|
|
|
7
7
|
import { bigintReplacer } from '../lib/format.js';
|
|
8
8
|
import { sendAction } from '../lib/wallet.js';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @import {Writable} from 'stream';
|
|
12
|
+
* @import {createCommand} from 'commander';
|
|
13
|
+
* @import {execFileSync} from 'child_process';
|
|
14
|
+
* @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
|
|
15
|
+
*/
|
|
16
|
+
|
|
10
17
|
/**
|
|
11
18
|
* Make commands for testing.
|
|
12
19
|
*
|
|
13
20
|
* @param {{
|
|
14
21
|
* env: Partial<Record<string, string>>,
|
|
15
|
-
* stdout: Pick<
|
|
16
|
-
* stderr: Pick<
|
|
22
|
+
* stdout: Pick<Writable,'write'>,
|
|
23
|
+
* stderr: Pick<Writable,'write'>,
|
|
17
24
|
* now: () => number,
|
|
18
25
|
* createCommand: // Note: includes access to process.stdout, .stderr, .exit
|
|
19
|
-
* typeof
|
|
20
|
-
* execFileSync: typeof
|
|
26
|
+
* typeof createCommand,
|
|
27
|
+
* execFileSync: typeof execFileSync,
|
|
21
28
|
* setTimeout: typeof setTimeout,
|
|
22
29
|
* }} process
|
|
23
30
|
* @param {{ fetch: typeof window.fetch }} net
|
|
@@ -75,7 +82,7 @@ export const makeTestCommand = (
|
|
|
75
82
|
const { home, keyringBackend: backend } = testCmd.opts();
|
|
76
83
|
|
|
77
84
|
const io = { ...networkConfig, execFileSync, delay, stdout };
|
|
78
|
-
/** @type {
|
|
85
|
+
/** @type {OfferSpec} */
|
|
79
86
|
const offer = {
|
|
80
87
|
id: opts.offerId,
|
|
81
88
|
invitationSpec: {
|
package/src/commands/vaults.js
CHANGED
|
@@ -14,10 +14,14 @@ import { Command } from 'commander';
|
|
|
14
14
|
import { normalizeAddressWithOptions } from '../lib/chain.js';
|
|
15
15
|
import { getCurrent, outputExecuteOfferAction } from '../lib/wallet.js';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* @import {Logger} from 'anylogger';
|
|
19
|
+
*/
|
|
20
|
+
|
|
17
21
|
const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
|
-
* @param {
|
|
24
|
+
* @param {Logger} logger
|
|
21
25
|
*/
|
|
22
26
|
export const makeVaultsCommand = logger => {
|
|
23
27
|
const vaults = new Command('vaults')
|
package/src/commands/wallet.js
CHANGED
|
@@ -30,17 +30,21 @@ import {
|
|
|
30
30
|
} from '../lib/format.js';
|
|
31
31
|
import { coalesceWalletState, getCurrent } from '../lib/wallet.js';
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* @import {Command} from 'commander';
|
|
35
|
+
*/
|
|
36
|
+
|
|
33
37
|
const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
|
|
34
38
|
|
|
35
39
|
const SLEEP_SECONDS = 3;
|
|
36
40
|
|
|
37
41
|
/**
|
|
38
|
-
* @param {
|
|
39
|
-
* @returns {Promise<
|
|
42
|
+
* @param {Command['command']} command
|
|
43
|
+
* @returns {Promise<Command>}
|
|
40
44
|
*/
|
|
41
45
|
export const makeWalletCommand = async command => {
|
|
42
46
|
/**
|
|
43
|
-
* @param {
|
|
47
|
+
* @param {Command} baseCmd
|
|
44
48
|
*/
|
|
45
49
|
const withSharedTxOptions = baseCmd =>
|
|
46
50
|
baseCmd
|
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
|
};
|
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
|
@@ -7,6 +7,7 @@ import { makeAgoricQueryClient } from '@agoric/client-utils';
|
|
|
7
7
|
/**
|
|
8
8
|
* @import {MinimalNetworkConfig} from '@agoric/client-utils';
|
|
9
9
|
* @import {Params, ParamsSDKType} from '@agoric/cosmic-proto/agoric/swingset/swingset.js';
|
|
10
|
+
* @import {Writable} from 'stream';
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
const agdBinary = 'agd';
|
|
@@ -79,8 +80,8 @@ const makeGasOpts = limit => {
|
|
|
79
80
|
* dryRun?: boolean,
|
|
80
81
|
* verbose?: boolean,
|
|
81
82
|
* keyring?: {home?: string, backend: string}
|
|
82
|
-
* stdout?: Pick<
|
|
83
|
-
* execFileSync?: typeof
|
|
83
|
+
* stdout?: Pick<Writable, 'write'>
|
|
84
|
+
* execFileSync?: typeof execFileSyncAmbient
|
|
84
85
|
* }} opts
|
|
85
86
|
*/
|
|
86
87
|
export const execSwingsetTransaction = (swingsetArgs, opts) => {
|
|
@@ -145,7 +146,7 @@ harden(fetchSwingsetParams);
|
|
|
145
146
|
|
|
146
147
|
/**
|
|
147
148
|
* @param {MinimalNetworkConfig & {
|
|
148
|
-
* execFileSync: typeof
|
|
149
|
+
* execFileSync: typeof execFileSyncAmbient,
|
|
149
150
|
* delay: (ms: number) => Promise<void>,
|
|
150
151
|
* period?: number,
|
|
151
152
|
* retryMessage?: string,
|
|
@@ -184,7 +185,7 @@ export const pollBlocks = opts => async lookup => {
|
|
|
184
185
|
/**
|
|
185
186
|
* @param {string} txhash
|
|
186
187
|
* @param {MinimalNetworkConfig & {
|
|
187
|
-
* execFileSync: typeof
|
|
188
|
+
* execFileSync: typeof execFileSyncAmbient,
|
|
188
189
|
* delay: (ms: number) => Promise<void>,
|
|
189
190
|
* period?: number,
|
|
190
191
|
* }} opts
|
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/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?: Pick<
|
|
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],
|
package/src/publish.js
CHANGED
|
@@ -15,7 +15,17 @@ import { defaultRegistryTypes } from '@cosmjs/stargate';
|
|
|
15
15
|
import { stringToPath } from '@cosmjs/crypto';
|
|
16
16
|
import { Decimal } from '@cosmjs/math';
|
|
17
17
|
import { fromBech32 } from '@cosmjs/encoding';
|
|
18
|
-
import {
|
|
18
|
+
import { CodecHelper } from '@agoric/cosmic-proto';
|
|
19
|
+
import { MsgInstallBundle as MsgInstallBundleType } from '@agoric/cosmic-proto/swingset/msgs.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @import {resolve} from 'path';
|
|
23
|
+
* @import {promises} from 'fs';
|
|
24
|
+
* @import {SigningStargateClient} from '@cosmjs/stargate';
|
|
25
|
+
* @import {EncodeObject} from '@cosmjs/proto-signing';
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const MsgInstallBundle = CodecHelper(MsgInstallBundleType);
|
|
19
29
|
|
|
20
30
|
// https://github.com/Agoric/agoric-sdk/blob/master/golang/cosmos/daemon/main.go
|
|
21
31
|
const Agoric = {
|
|
@@ -226,9 +236,9 @@ const urlForRpcAddress = address => {
|
|
|
226
236
|
|
|
227
237
|
/**
|
|
228
238
|
* @param {object} args
|
|
229
|
-
* @param {typeof
|
|
230
|
-
* @param {typeof
|
|
231
|
-
* @param {typeof
|
|
239
|
+
* @param {typeof resolve} args.pathResolve
|
|
240
|
+
* @param {typeof promises.readFile} args.readFile
|
|
241
|
+
* @param {typeof SigningStargateClient.connectWithSigner} args.connectWithSigner
|
|
232
242
|
* @param {() => number} args.random - a random number in the interval [0, 1)
|
|
233
243
|
*/
|
|
234
244
|
export const makeCosmosBundlePublisher = ({
|
|
@@ -269,7 +279,7 @@ export const makeCosmosBundlePublisher = ({
|
|
|
269
279
|
submitter: fromBech32(from.address).data,
|
|
270
280
|
};
|
|
271
281
|
|
|
272
|
-
/** @type {Array<
|
|
282
|
+
/** @type {Array<EncodeObject>} */
|
|
273
283
|
const encodeObjects = [
|
|
274
284
|
{
|
|
275
285
|
typeUrl: Agoric.proto.swingset.InstallBundle.typeUrl,
|
package/src/scripts.js
CHANGED
|
@@ -6,6 +6,12 @@ import { E } from '@endo/captp';
|
|
|
6
6
|
import { createRequire } from 'module';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @import {ModuleFormat} from '@endo/bundle-source';
|
|
11
|
+
* @import {BundleOptions} from '@endo/bundle-source';
|
|
12
|
+
* @import {BundleSourceResult} from '@endo/bundle-source';
|
|
13
|
+
*/
|
|
14
|
+
|
|
9
15
|
const require = createRequire(import.meta.url);
|
|
10
16
|
|
|
11
17
|
const PATH_SEP_RE = new RegExp(`${path.sep.replace(/\\/g, '\\\\')}`, 'g');
|
|
@@ -135,10 +141,10 @@ export { bootPlugin } from ${JSON.stringify(absPath)};
|
|
|
135
141
|
const allEndowments = harden({
|
|
136
142
|
home: bootP,
|
|
137
143
|
/**
|
|
138
|
-
* @template {
|
|
144
|
+
* @template {ModuleFormat} ModuleFormat
|
|
139
145
|
* @param {string} file
|
|
140
|
-
* @param {
|
|
141
|
-
* @returns {Promise<
|
|
146
|
+
* @param {BundleOptions<ModuleFormat>} options
|
|
147
|
+
* @returns {Promise<BundleSourceResult<ModuleFormat>>}
|
|
142
148
|
*/
|
|
143
149
|
bundleSource: (file, options = {}) =>
|
|
144
150
|
bundleSource(pathResolve(file), {
|
package/src/sdk-package-names.js
CHANGED
package/src/start.js
CHANGED
|
@@ -276,7 +276,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
276
276
|
await rmVerbose(serverDir);
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
/** @type {(args: string[], spawnOpts?: Parameters<typeof pspawn>[2], dockerArgs?: string[]) => ReturnType<pspawn>} */
|
|
279
|
+
/** @type {(args: string[], spawnOpts?: Parameters<typeof pspawn>[2], dockerArgs?: string[]) => ReturnType<typeof pspawn>} */
|
|
280
280
|
let chainSpawn;
|
|
281
281
|
if (!popts.dockerTag) {
|
|
282
282
|
chainSpawn = (args, spawnOpts) =>
|
|
@@ -482,7 +482,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
|
|
|
482
482
|
await rmVerbose(serverDir);
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
-
/** @type {(args: string[], spawnOpts?: Parameters<typeof pspawn>[2], dockerArgs?: string[]) => ReturnType<pspawn>} */
|
|
485
|
+
/** @type {(args: string[], spawnOpts?: Parameters<typeof pspawn>[2], dockerArgs?: string[]) => ReturnType<typeof pspawn>} */
|
|
486
486
|
let soloSpawn;
|
|
487
487
|
if (!popts.dockerTag) {
|
|
488
488
|
soloSpawn = (args, spawnOpts) => pspawn(agSolo, args, spawnOpts);
|
package/tools/getting-started.js
CHANGED
|
@@ -11,6 +11,11 @@ import { spawn } from 'child_process';
|
|
|
11
11
|
|
|
12
12
|
import { makePspawn } from '../src/helpers.js';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @import {ExecutionContext} from 'ava';
|
|
16
|
+
* @import {ChildProcess} from 'child_process';
|
|
17
|
+
*/
|
|
18
|
+
|
|
14
19
|
const RETRY_BLOCKHEIGHT_SECONDS = 3;
|
|
15
20
|
const SOCKET_TIMEOUT_SECONDS = 2;
|
|
16
21
|
|
|
@@ -66,7 +71,7 @@ const getLatestBlockHeight = url =>
|
|
|
66
71
|
* Test the "getting started" workflow. Note that this function may be imported
|
|
67
72
|
* by external repositories.
|
|
68
73
|
*
|
|
69
|
-
* @param {
|
|
74
|
+
* @param {ExecutionContext} t
|
|
70
75
|
* @param {{ init?: string[], install?: string[] }} [options]
|
|
71
76
|
*/
|
|
72
77
|
export const gettingStartedWorkflowTest = async (t, options = {}) => {
|
|
@@ -110,7 +115,7 @@ export const gettingStartedWorkflowTest = async (t, options = {}) => {
|
|
|
110
115
|
|
|
111
116
|
/**
|
|
112
117
|
* @param {string[]} args
|
|
113
|
-
* @returns {{childProcess?:
|
|
118
|
+
* @returns {{childProcess?: ChildProcess} & Promise<void>}
|
|
114
119
|
*/
|
|
115
120
|
function yarn(...args) {
|
|
116
121
|
const ps = pspawnStdout('yarn', args, {
|
|
@@ -118,7 +123,7 @@ export const gettingStartedWorkflowTest = async (t, options = {}) => {
|
|
|
118
123
|
env: { ...process.env },
|
|
119
124
|
detached: true,
|
|
120
125
|
});
|
|
121
|
-
/** @type {{childProcess?:
|
|
126
|
+
/** @type {{childProcess?: ChildProcess} & Promise<void>} */
|
|
122
127
|
const p = new Promise((resolve, reject) => {
|
|
123
128
|
ps.then(code => {
|
|
124
129
|
if (code !== 0) {
|