agoric 0.22.0-u18.5 → 0.22.0-u18.6
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 +38 -36
- package/src/anylogger-agoric.js +2 -2
- package/src/chain-config.js +22 -3
- package/src/commands/auction.js +15 -14
- package/src/commands/gov.js +41 -28
- package/src/commands/inter.js +16 -25
- package/src/commands/oracle.js +27 -18
- package/src/commands/perf.js +5 -3
- package/src/commands/psm.js +17 -10
- package/src/commands/reserve.js +11 -3
- package/src/commands/test-upgrade.js +4 -4
- package/src/commands/vaults.js +24 -9
- package/src/commands/wallet.js +68 -18
- package/src/cosmos.js +1 -1
- package/src/helpers.js +8 -5
- package/src/install.js +8 -5
- package/src/lib/chain.js +42 -5
- package/src/lib/format.js +18 -19
- package/src/lib/index.js +7 -0
- package/src/lib/wallet.js +16 -87
- package/src/main.js +3 -1
- package/src/scripts.js +1 -1
- package/src/sdk-package-names.js +3 -2
- package/src/start.js +7 -7
- package/tools/getting-started.js +7 -0
- package/src/lib/rpc.js +0 -285
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agoric",
|
|
3
|
-
"version": "0.22.0-u18.
|
|
3
|
+
"version": "0.22.0-u18.6",
|
|
4
4
|
"description": "Manage the Agoric Javascript smart contract platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main.js",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
"./src/entrypoint.js": "./src/entrypoint.js",
|
|
13
|
-
"./src/helpers.js": "./src/helpers.js"
|
|
13
|
+
"./src/helpers.js": "./src/helpers.js",
|
|
14
|
+
"./src/lib/index.js": "./src/lib/index.js"
|
|
14
15
|
},
|
|
15
16
|
"files": [
|
|
16
17
|
"src",
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
"scripts": {
|
|
21
22
|
"build": "node ./scripts/get-sdk-package-names.js > src/sdk-package-names.js",
|
|
22
23
|
"test": "ava",
|
|
23
|
-
"test:c8": "c8 $C8_OPTIONS ava
|
|
24
|
+
"test:c8": "c8 --all $C8_OPTIONS ava",
|
|
24
25
|
"test:xs": "exit 0",
|
|
25
26
|
"integration-test": "ava --config .ava-integration-test.config.js",
|
|
26
27
|
"lint-fix": "yarn lint:eslint --fix",
|
|
@@ -29,50 +30,51 @@
|
|
|
29
30
|
"lint:eslint": "eslint ."
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@agoric/cosmic-swingset": "^0.42.0-u18.
|
|
33
|
-
"@agoric/deploy-script-support": "^0.10.4-u18.
|
|
33
|
+
"@agoric/cosmic-swingset": "^0.42.0-u18.6",
|
|
34
|
+
"@agoric/deploy-script-support": "^0.10.4-u18.5",
|
|
34
35
|
"ava": "^5.3.0",
|
|
35
|
-
"c8": "^
|
|
36
|
+
"c8": "^10.1.2",
|
|
36
37
|
"dd-trace": "^4.11.1"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@agoric/access-token": "^0.4.22-u18.
|
|
40
|
-
"@agoric/cache": "^0.3.3-u18.
|
|
41
|
-
"@agoric/casting": "^0.4.3-u18.
|
|
42
|
-
"@agoric/
|
|
43
|
-
"@agoric/
|
|
44
|
-
"@agoric/
|
|
45
|
-
"@agoric/
|
|
46
|
-
"@agoric/
|
|
47
|
-
"@agoric/
|
|
48
|
-
"@agoric/
|
|
49
|
-
"@agoric/
|
|
50
|
-
"@agoric/
|
|
51
|
-
"@agoric/
|
|
52
|
-
"@agoric/
|
|
53
|
-
"@agoric/
|
|
40
|
+
"@agoric/access-token": "^0.4.22-u18.1",
|
|
41
|
+
"@agoric/cache": "^0.3.3-u18.1",
|
|
42
|
+
"@agoric/casting": "^0.4.3-u18.5",
|
|
43
|
+
"@agoric/client-utils": "^0.2.0-u18.0",
|
|
44
|
+
"@agoric/cosmic-proto": "^0.5.0-u18.5",
|
|
45
|
+
"@agoric/ertp": "^0.16.3-u18.1",
|
|
46
|
+
"@agoric/governance": "^0.10.4-u18.1",
|
|
47
|
+
"@agoric/inter-protocol": "^0.17.0-u18.6",
|
|
48
|
+
"@agoric/internal": "^0.4.0-u18.1",
|
|
49
|
+
"@agoric/network": "^0.2.0-u18.1",
|
|
50
|
+
"@agoric/smart-wallet": "^0.5.4-u18.5",
|
|
51
|
+
"@agoric/store": "^0.9.3-u18.1",
|
|
52
|
+
"@agoric/swingset-vat": "^0.33.0-u18.1",
|
|
53
|
+
"@agoric/vats": "^0.16.0-u18.5",
|
|
54
|
+
"@agoric/zoe": "^0.26.3-u18.1",
|
|
55
|
+
"@agoric/zone": "^0.3.0-u18.1",
|
|
54
56
|
"@confio/relayer": "^0.11.3",
|
|
55
57
|
"@cosmjs/crypto": "^0.32.3",
|
|
56
58
|
"@cosmjs/encoding": "^0.32.3",
|
|
57
59
|
"@cosmjs/math": "^0.32.3",
|
|
58
60
|
"@cosmjs/proto-signing": "^0.32.3",
|
|
59
61
|
"@cosmjs/stargate": "^0.32.3",
|
|
60
|
-
"@endo/bundle-source": "^3.
|
|
61
|
-
"@endo/captp": "^4.4.
|
|
62
|
-
"@endo/compartment-mapper": "^1.
|
|
63
|
-
"@endo/env-options": "^1.1.
|
|
64
|
-
"@endo/errors": "^1.2.
|
|
65
|
-
"@endo/far": "^1.1.
|
|
66
|
-
"@endo/init": "^1.1.
|
|
67
|
-
"@endo/marshal": "^1.6.
|
|
68
|
-
"@endo/nat": "^5.0.
|
|
69
|
-
"@endo/patterns": "^1.4.
|
|
70
|
-
"@endo/promise-kit": "^1.1.
|
|
71
|
-
"@endo/zip": "^1.0.
|
|
62
|
+
"@endo/bundle-source": "^3.5.0",
|
|
63
|
+
"@endo/captp": "^4.4.3",
|
|
64
|
+
"@endo/compartment-mapper": "^1.4.0",
|
|
65
|
+
"@endo/env-options": "^1.1.8",
|
|
66
|
+
"@endo/errors": "^1.2.8",
|
|
67
|
+
"@endo/far": "^1.1.9",
|
|
68
|
+
"@endo/init": "^1.1.7",
|
|
69
|
+
"@endo/marshal": "^1.6.2",
|
|
70
|
+
"@endo/nat": "^5.0.13",
|
|
71
|
+
"@endo/patterns": "^1.4.7",
|
|
72
|
+
"@endo/promise-kit": "^1.1.8",
|
|
73
|
+
"@endo/zip": "^1.0.9",
|
|
72
74
|
"@iarna/toml": "^2.2.3",
|
|
73
75
|
"anylogger": "^0.21.0",
|
|
74
76
|
"chalk": "^5.2.0",
|
|
75
|
-
"commander": "^
|
|
77
|
+
"commander": "^12.1.0",
|
|
76
78
|
"deterministic-json": "^1.0.5",
|
|
77
79
|
"esm": "agoric-labs/esm#Agoric-built",
|
|
78
80
|
"inquirer": "^8.2.2",
|
|
@@ -99,7 +101,7 @@
|
|
|
99
101
|
"workerThreads": false
|
|
100
102
|
},
|
|
101
103
|
"typeCoverage": {
|
|
102
|
-
"atLeast":
|
|
104
|
+
"atLeast": 78.19
|
|
103
105
|
},
|
|
104
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "f8c45b8a2e29a51522a81a6692af25b2d7f6b50f"
|
|
105
107
|
}
|
package/src/anylogger-agoric.js
CHANGED
|
@@ -28,8 +28,8 @@ const selectedCode = anylogger.levels[selectedLevel];
|
|
|
28
28
|
const globalCode = selectedCode === undefined ? -Infinity : selectedCode;
|
|
29
29
|
|
|
30
30
|
const oldExt = anylogger.ext;
|
|
31
|
-
anylogger.ext = (l,
|
|
32
|
-
l = oldExt(l,
|
|
31
|
+
anylogger.ext = (l, ...rest) => {
|
|
32
|
+
l = oldExt(l, ...rest);
|
|
33
33
|
l.enabledFor = lvl => globalCode >= anylogger.levels[lvl];
|
|
34
34
|
|
|
35
35
|
const prefix = l.name.replace(/:/g, ': ');
|
package/src/chain-config.js
CHANGED
|
@@ -81,7 +81,12 @@ export const DEFAULT_RPC_PORT = 26657;
|
|
|
81
81
|
export const DEFAULT_PROM_PORT = 26660;
|
|
82
82
|
export const DEFAULT_API_PORT = 1317;
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Rewrite the app.toml.
|
|
86
|
+
*
|
|
87
|
+
* @param {{ appToml: string, enableCors?: boolean, exportMetrics?: boolean, portNum?: string, chainId?: string, enableRosetta?: boolean, rosettaPort?: string }} input
|
|
88
|
+
* @returns {string} toml
|
|
89
|
+
*/
|
|
85
90
|
export function finishCosmosApp({
|
|
86
91
|
appToml,
|
|
87
92
|
enableCors,
|
|
@@ -92,6 +97,8 @@ export function finishCosmosApp({
|
|
|
92
97
|
rosettaPort = `${DEFAULT_ROSETTA_PORT}`,
|
|
93
98
|
}) {
|
|
94
99
|
const rpcPort = Number(portNum);
|
|
100
|
+
// TODO: Use an accurate narrow type.
|
|
101
|
+
/** @type {Record<string, any>} */
|
|
95
102
|
const app = TOML.parse(appToml);
|
|
96
103
|
|
|
97
104
|
if (enableCors) {
|
|
@@ -138,7 +145,12 @@ export function finishCosmosApp({
|
|
|
138
145
|
return TOML.stringify(app);
|
|
139
146
|
}
|
|
140
147
|
|
|
141
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Rewrite the config.toml.
|
|
150
|
+
*
|
|
151
|
+
* @param {{ configToml: string, enableCors?: boolean, exportMetrics?: boolean, portNum?: string, persistentPeers?: string, seeds?: string, unconditionalPeerIds?: string }} input
|
|
152
|
+
* @returns {string} toml
|
|
153
|
+
*/
|
|
142
154
|
export function finishTendermintConfig({
|
|
143
155
|
configToml,
|
|
144
156
|
enableCors,
|
|
@@ -151,6 +163,8 @@ export function finishTendermintConfig({
|
|
|
151
163
|
const rpcPort = Number(portNum);
|
|
152
164
|
|
|
153
165
|
// Adjust the config.toml.
|
|
166
|
+
// TODO: Use an accurate narrow type.
|
|
167
|
+
/** @type {Record<string, any>} */
|
|
154
168
|
const config = TOML.parse(configToml);
|
|
155
169
|
|
|
156
170
|
config.proxy_app = 'kvstore';
|
|
@@ -189,7 +203,12 @@ export function finishTendermintConfig({
|
|
|
189
203
|
return TOML.stringify(config);
|
|
190
204
|
}
|
|
191
205
|
|
|
192
|
-
|
|
206
|
+
/**
|
|
207
|
+
* Rewrite/import the genesis.json.
|
|
208
|
+
*
|
|
209
|
+
* @param {{ genesisJson: string, exportedGenesisJson?: string }} input
|
|
210
|
+
* @returns {string} json
|
|
211
|
+
*/
|
|
193
212
|
export function finishCosmosGenesis({ genesisJson, exportedGenesisJson }) {
|
|
194
213
|
const genesis = JSON.parse(genesisJson);
|
|
195
214
|
const exported = exportedGenesisJson ? JSON.parse(exportedGenesisJson) : {};
|
package/src/commands/auction.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
/* eslint-env node */
|
|
3
|
+
import {
|
|
4
|
+
fetchEnvNetworkConfig,
|
|
5
|
+
makeAgoricNames,
|
|
6
|
+
makeVstorageKit,
|
|
7
|
+
} from '@agoric/client-utils';
|
|
4
8
|
import { Fail } from '@endo/errors';
|
|
5
|
-
import {
|
|
9
|
+
import { InvalidArgumentError } from 'commander';
|
|
6
10
|
import { outputActionAndHint } from '../lib/wallet.js';
|
|
7
11
|
|
|
8
12
|
/**
|
|
@@ -10,6 +14,8 @@ import { outputActionAndHint } from '../lib/wallet.js';
|
|
|
10
14
|
* @import {ParamValueForType} from '@agoric/governance/src/types.js'
|
|
11
15
|
*/
|
|
12
16
|
|
|
17
|
+
const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
|
|
18
|
+
|
|
13
19
|
/**
|
|
14
20
|
* @template {ParamTypesMap} M
|
|
15
21
|
* @typedef {{
|
|
@@ -59,11 +65,6 @@ export const makeAuctionCommand = (
|
|
|
59
65
|
'descending clock step size',
|
|
60
66
|
BigInt,
|
|
61
67
|
)
|
|
62
|
-
.option(
|
|
63
|
-
'--discount-step <integer>',
|
|
64
|
-
'proposed value (basis points)',
|
|
65
|
-
BigInt,
|
|
66
|
-
)
|
|
67
68
|
.requiredOption(
|
|
68
69
|
'--charterAcceptOfferId <string>',
|
|
69
70
|
'offer that had continuing invitation result',
|
|
@@ -91,13 +92,13 @@ export const makeAuctionCommand = (
|
|
|
91
92
|
* }} opts
|
|
92
93
|
*/
|
|
93
94
|
async opts => {
|
|
94
|
-
const {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// @ts-expect-error XXX should runtime check?
|
|
98
|
-
const { current } = await readLatestHead(
|
|
99
|
-
`published.auction.governance`,
|
|
95
|
+
const { readPublished, ...vsk } = makeVstorageKit(
|
|
96
|
+
{ fetch },
|
|
97
|
+
networkConfig,
|
|
100
98
|
);
|
|
99
|
+
const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
|
|
100
|
+
|
|
101
|
+
const { current } = await readPublished(`auction.governance`);
|
|
101
102
|
|
|
102
103
|
const {
|
|
103
104
|
AuctionStartDelay: {
|
package/src/commands/gov.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
/* eslint-disable func-names */
|
|
3
|
-
/*
|
|
3
|
+
/* eslint-env node */
|
|
4
|
+
import {
|
|
5
|
+
fetchEnvNetworkConfig,
|
|
6
|
+
makeAgoricNames,
|
|
7
|
+
makeVstorageKit,
|
|
8
|
+
} from '@agoric/client-utils';
|
|
4
9
|
import { execFileSync as execFileSyncAmbient } from 'child_process';
|
|
5
10
|
import { Command, CommanderError } from 'commander';
|
|
6
11
|
import { normalizeAddressWithOptions, pollBlocks } from '../lib/chain.js';
|
|
7
|
-
import { getNetworkConfig, makeRpcUtils } from '../lib/rpc.js';
|
|
8
12
|
import {
|
|
9
13
|
findContinuingIds,
|
|
10
14
|
getCurrent,
|
|
@@ -14,8 +18,10 @@ import {
|
|
|
14
18
|
} from '../lib/wallet.js';
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
|
-
* @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js'
|
|
18
|
-
* @import {
|
|
21
|
+
* @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
|
|
22
|
+
* @import {AgoricNamesRemotes} from '@agoric/vats/tools/board-utils.js';
|
|
23
|
+
* @import {CurrentWalletRecord} from '@agoric/smart-wallet/src/smartWallet.js';
|
|
24
|
+
* @import {VstorageKit} from '@agoric/client-utils';
|
|
19
25
|
*/
|
|
20
26
|
|
|
21
27
|
const collectValues = (val, memo) => {
|
|
@@ -25,6 +31,8 @@ const collectValues = (val, memo) => {
|
|
|
25
31
|
|
|
26
32
|
const defaultKeyring = process.env.AGORIC_KEYRING_BACKEND || 'test';
|
|
27
33
|
|
|
34
|
+
const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
|
|
35
|
+
|
|
28
36
|
/**
|
|
29
37
|
* @param {import('anylogger').Logger} _logger
|
|
30
38
|
* @param {{
|
|
@@ -40,10 +48,9 @@ export const makeGovCommand = (_logger, io = {}) => {
|
|
|
40
48
|
const {
|
|
41
49
|
// Allow caller to provide access explicitly, but
|
|
42
50
|
// default to conventional ambient IO facilities.
|
|
43
|
-
env = process.env,
|
|
44
51
|
stdout = process.stdout,
|
|
45
52
|
stderr = process.stderr,
|
|
46
|
-
fetch =
|
|
53
|
+
fetch = global.fetch,
|
|
47
54
|
execFileSync = execFileSyncAmbient,
|
|
48
55
|
delay = ms => new Promise(resolve => setTimeout(resolve, ms)),
|
|
49
56
|
} = io;
|
|
@@ -84,26 +91,27 @@ export const makeGovCommand = (_logger, io = {}) => {
|
|
|
84
91
|
* given a sendFrom address; else print it.
|
|
85
92
|
*
|
|
86
93
|
* @param {{
|
|
87
|
-
* toOffer: (agoricNames:
|
|
94
|
+
* toOffer: (agoricNames: AgoricNamesRemotes, current: CurrentWalletRecord | undefined) => OfferSpec,
|
|
88
95
|
* sendFrom?: string | undefined,
|
|
89
96
|
* keyringBackend: string,
|
|
90
97
|
* instanceName?: string,
|
|
91
98
|
* }} detail
|
|
92
|
-
* @param {
|
|
99
|
+
* @param {VstorageKit} [vsk]
|
|
93
100
|
*/
|
|
94
101
|
const processOffer = async function (
|
|
95
102
|
{ toOffer, sendFrom, keyringBackend },
|
|
96
|
-
|
|
103
|
+
vsk,
|
|
97
104
|
) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const {
|
|
105
|
+
await null;
|
|
106
|
+
vsk ||= makeVstorageKit({ fetch }, networkConfig);
|
|
107
|
+
const { readPublished } = vsk;
|
|
108
|
+
const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
|
|
101
109
|
|
|
102
110
|
assert(keyringBackend, 'missing keyring-backend option');
|
|
103
111
|
|
|
104
112
|
let current;
|
|
105
113
|
if (sendFrom) {
|
|
106
|
-
current = await getCurrent(sendFrom, {
|
|
114
|
+
current = await getCurrent(sendFrom, { readPublished });
|
|
107
115
|
}
|
|
108
116
|
|
|
109
117
|
const offer = toOffer(agoricNames, current);
|
|
@@ -133,9 +141,9 @@ export const makeGovCommand = (_logger, io = {}) => {
|
|
|
133
141
|
show({ timestamp, height, offerId: offer.id, txhash });
|
|
134
142
|
const checkInWallet = async blockInfo => {
|
|
135
143
|
const [state, update] = await Promise.all([
|
|
136
|
-
getCurrent(sendFrom, {
|
|
137
|
-
getLastUpdate(sendFrom, {
|
|
138
|
-
|
|
144
|
+
getCurrent(sendFrom, { readPublished }),
|
|
145
|
+
getLastUpdate(sendFrom, { readPublished }),
|
|
146
|
+
readPublished(`wallet.${sendFrom}`),
|
|
139
147
|
]);
|
|
140
148
|
if (update.updated === 'offerStatus' && update.status.id === offer.id) {
|
|
141
149
|
return blockInfo;
|
|
@@ -264,8 +272,12 @@ export const makeGovCommand = (_logger, io = {}) => {
|
|
|
264
272
|
)
|
|
265
273
|
.requiredOption('--for <string>', 'description of the invitation')
|
|
266
274
|
.action(async opts => {
|
|
267
|
-
const {
|
|
268
|
-
|
|
275
|
+
const { readPublished, ...vsk } = makeVstorageKit(
|
|
276
|
+
{ fetch },
|
|
277
|
+
networkConfig,
|
|
278
|
+
);
|
|
279
|
+
const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
|
|
280
|
+
const current = await getCurrent(opts.from, { readPublished });
|
|
269
281
|
|
|
270
282
|
const known = findContinuingIds(current, agoricNames);
|
|
271
283
|
if (!known) {
|
|
@@ -290,8 +302,12 @@ export const makeGovCommand = (_logger, io = {}) => {
|
|
|
290
302
|
normalizeAddress,
|
|
291
303
|
)
|
|
292
304
|
.action(async opts => {
|
|
293
|
-
const {
|
|
294
|
-
|
|
305
|
+
const { readPublished, ...vsk } = makeVstorageKit(
|
|
306
|
+
{ fetch },
|
|
307
|
+
networkConfig,
|
|
308
|
+
);
|
|
309
|
+
const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
|
|
310
|
+
const current = await getCurrent(opts.from, { readPublished });
|
|
295
311
|
|
|
296
312
|
const found = findContinuingIds(current, agoricNames);
|
|
297
313
|
for (const it of found) {
|
|
@@ -326,20 +342,17 @@ export const makeGovCommand = (_logger, io = {}) => {
|
|
|
326
342
|
normalizeAddress,
|
|
327
343
|
)
|
|
328
344
|
.action(async function (opts, options) {
|
|
329
|
-
const
|
|
330
|
-
const {
|
|
345
|
+
const vsk = makeVstorageKit({ fetch }, networkConfig);
|
|
346
|
+
const { readPublished } = vsk;
|
|
331
347
|
|
|
332
|
-
const
|
|
333
|
-
`
|
|
348
|
+
const questionDesc = await readPublished(
|
|
349
|
+
`committees.${opts.pathname}.latestQuestion`,
|
|
334
350
|
).catch(err => {
|
|
335
351
|
// CommanderError is a class constructor, and so
|
|
336
352
|
// must be invoked with `new`.
|
|
337
353
|
throw new CommanderError(1, 'VSTORAGE_FAILURE', err.message);
|
|
338
354
|
});
|
|
339
355
|
|
|
340
|
-
// XXX runtime shape-check
|
|
341
|
-
const questionDesc = /** @type {QuestionDetails} */ (info);
|
|
342
|
-
|
|
343
356
|
// TODO support multiple position arguments
|
|
344
357
|
const chosenPositions = [questionDesc.positions[opts.forPosition]];
|
|
345
358
|
assert(chosenPositions, `undefined position index ${opts.forPosition}`);
|
|
@@ -380,7 +393,7 @@ export const makeGovCommand = (_logger, io = {}) => {
|
|
|
380
393
|
sendFrom: opts.sendFrom,
|
|
381
394
|
keyringBackend: options.optsWithGlobals().keyringBackend,
|
|
382
395
|
},
|
|
383
|
-
|
|
396
|
+
vsk,
|
|
384
397
|
);
|
|
385
398
|
});
|
|
386
399
|
|
package/src/commands/inter.js
CHANGED
|
@@ -4,26 +4,19 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// @ts-check
|
|
7
|
-
import {
|
|
8
|
-
// TODO: should get M from endo https://github.com/Agoric/agoric-sdk/issues/7090
|
|
7
|
+
import { fetchEnvNetworkConfig, makeWalletUtils } from '@agoric/client-utils';
|
|
9
8
|
import { makeOfferSpecShape } from '@agoric/inter-protocol/src/auction/auctionBook.js';
|
|
10
9
|
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
|
|
11
10
|
import { objectMap } from '@agoric/internal';
|
|
12
|
-
import { M, matches } from '@
|
|
13
|
-
|
|
11
|
+
import { M, matches } from '@endo/patterns';
|
|
12
|
+
import { CommanderError, InvalidArgumentError } from 'commander';
|
|
14
13
|
import { normalizeAddressWithOptions, pollBlocks } from '../lib/chain.js';
|
|
15
14
|
import {
|
|
16
15
|
asBoardRemote,
|
|
17
16
|
bigintReplacer,
|
|
18
17
|
makeAmountFormatter,
|
|
19
18
|
} from '../lib/format.js';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
getCurrent,
|
|
23
|
-
makeWalletUtils,
|
|
24
|
-
outputActionAndHint,
|
|
25
|
-
sendAction,
|
|
26
|
-
} from '../lib/wallet.js';
|
|
19
|
+
import { getCurrent, outputActionAndHint, sendAction } from '../lib/wallet.js';
|
|
27
20
|
|
|
28
21
|
const { values } = Object;
|
|
29
22
|
|
|
@@ -238,8 +231,8 @@ export const makeInterCommand = (
|
|
|
238
231
|
try {
|
|
239
232
|
// XXX pass fetch to getNetworkConfig() explicitly
|
|
240
233
|
// await null above makes this await safe
|
|
241
|
-
const networkConfig = await
|
|
242
|
-
return makeWalletUtils({ fetch,
|
|
234
|
+
const networkConfig = await fetchEnvNetworkConfig({ env, fetch });
|
|
235
|
+
return makeWalletUtils({ fetch, delay }, networkConfig);
|
|
243
236
|
} catch (err) {
|
|
244
237
|
// CommanderError is a class constructor, and so
|
|
245
238
|
// must be invoked with `new`.
|
|
@@ -287,14 +280,12 @@ inter auction status
|
|
|
287
280
|
* }}
|
|
288
281
|
*/ opts,
|
|
289
282
|
) => {
|
|
290
|
-
const { agoricNames,
|
|
283
|
+
const { agoricNames, readPublished } = await tryMakeUtils();
|
|
291
284
|
|
|
292
|
-
/** @type { [ScheduleNotification, BookDataNotification, *] } */
|
|
293
|
-
// @ts-expect-error dynamic cast
|
|
294
285
|
const [schedule, book, { current: params }] = await Promise.all([
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
286
|
+
readPublished('auction.schedule'),
|
|
287
|
+
readPublished(`auction.book${opts.book}`),
|
|
288
|
+
readPublished('auction.governance'),
|
|
298
289
|
]);
|
|
299
290
|
|
|
300
291
|
const fmt = makeFormatters(Object.values(agoricNames.vbankAsset));
|
|
@@ -334,7 +325,7 @@ inter auction status
|
|
|
334
325
|
* @param {string} from
|
|
335
326
|
* @param {import('@agoric/smart-wallet/src/offers.js').OfferSpec} offer
|
|
336
327
|
* @param {Awaited<ReturnType<tryMakeUtils>>} tools
|
|
337
|
-
* @param {boolean
|
|
328
|
+
* @param {boolean | undefined} dryRun
|
|
338
329
|
*/
|
|
339
330
|
const placeBid = async (from, offer, tools, dryRun = false) => {
|
|
340
331
|
const { networkConfig, agoricNames, pollOffer } = tools;
|
|
@@ -499,9 +490,9 @@ inter auction status
|
|
|
499
490
|
return;
|
|
500
491
|
}
|
|
501
492
|
|
|
502
|
-
const { networkConfig,
|
|
493
|
+
const { networkConfig, readPublished } = await tryMakeUtils();
|
|
503
494
|
|
|
504
|
-
const current = await getCurrent(from, {
|
|
495
|
+
const current = await getCurrent(from, { readPublished });
|
|
505
496
|
const liveIds = current.liveOffers.map(([i, _s]) => i);
|
|
506
497
|
if (!liveIds.includes(id)) {
|
|
507
498
|
// InvalidArgumentError is a class constructor, and so
|
|
@@ -526,7 +517,7 @@ inter auction status
|
|
|
526
517
|
show({ timestamp, height, offerId: id, txhash });
|
|
527
518
|
|
|
528
519
|
const checkGone = async blockInfo => {
|
|
529
|
-
const pollResult = await getCurrent(from, {
|
|
520
|
+
const pollResult = await getCurrent(from, { readPublished });
|
|
530
521
|
const found = pollResult.liveOffers.find(([i, _]) => i === id);
|
|
531
522
|
if (found) throw Error('retry');
|
|
532
523
|
return blockInfo;
|
|
@@ -568,11 +559,11 @@ $ inter bid list --from my-acct
|
|
|
568
559
|
* }} opts
|
|
569
560
|
*/
|
|
570
561
|
async opts => {
|
|
571
|
-
const { agoricNames,
|
|
562
|
+
const { agoricNames, readPublished, storedWalletState } =
|
|
572
563
|
await tryMakeUtils();
|
|
573
564
|
|
|
574
565
|
const [current, state] = await Promise.all([
|
|
575
|
-
getCurrent(opts.from, {
|
|
566
|
+
getCurrent(opts.from, { readPublished }),
|
|
576
567
|
storedWalletState(opts.from),
|
|
577
568
|
]);
|
|
578
569
|
const entries = opts.all
|
package/src/commands/oracle.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
/* eslint-disable func-names */
|
|
3
3
|
/* eslint-env node */
|
|
4
|
+
import {
|
|
5
|
+
fetchEnvNetworkConfig,
|
|
6
|
+
makeAgoricNames,
|
|
7
|
+
makeVstorageKit,
|
|
8
|
+
makeWalletUtils,
|
|
9
|
+
storageHelper,
|
|
10
|
+
} from '@agoric/client-utils';
|
|
4
11
|
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
|
|
5
12
|
import { oracleBrandFeedName } from '@agoric/inter-protocol/src/proposals/utils.js';
|
|
6
13
|
import { Fail } from '@endo/errors';
|
|
@@ -10,10 +17,8 @@ import { Command } from 'commander';
|
|
|
10
17
|
import { inspect } from 'util';
|
|
11
18
|
import { normalizeAddressWithOptions } from '../lib/chain.js';
|
|
12
19
|
import { bigintReplacer } from '../lib/format.js';
|
|
13
|
-
import { getNetworkConfig, makeRpcUtils, storageHelper } from '../lib/rpc.js';
|
|
14
20
|
import {
|
|
15
21
|
getCurrent,
|
|
16
|
-
makeWalletUtils,
|
|
17
22
|
outputAction,
|
|
18
23
|
sendAction,
|
|
19
24
|
sendHint,
|
|
@@ -82,20 +87,24 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
82
87
|
|
|
83
88
|
const rpcTools = async () => {
|
|
84
89
|
// XXX pass fetch to getNetworkConfig() explicitly
|
|
85
|
-
const networkConfig = await
|
|
86
|
-
|
|
90
|
+
const networkConfig = await fetchEnvNetworkConfig({
|
|
91
|
+
env: process.env,
|
|
92
|
+
fetch,
|
|
93
|
+
});
|
|
94
|
+
const vsk = makeVstorageKit({ fetch }, networkConfig);
|
|
95
|
+
const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
|
|
87
96
|
|
|
88
97
|
const lookupPriceAggregatorInstance = ([brandIn, brandOut]) => {
|
|
89
98
|
const name = oracleBrandFeedName(brandIn, brandOut);
|
|
90
|
-
const instance =
|
|
99
|
+
const instance = agoricNames.instance[name];
|
|
91
100
|
if (!instance) {
|
|
92
|
-
logger.debug('known instances:',
|
|
101
|
+
logger.debug('known instances:', agoricNames.instance);
|
|
93
102
|
throw Error(`Unknown instance ${name}`);
|
|
94
103
|
}
|
|
95
104
|
return instance;
|
|
96
105
|
};
|
|
97
106
|
|
|
98
|
-
return { ...
|
|
107
|
+
return { ...vsk, networkConfig, lookupPriceAggregatorInstance };
|
|
99
108
|
};
|
|
100
109
|
|
|
101
110
|
oracle
|
|
@@ -171,8 +180,8 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
171
180
|
console.warn(sendHint);
|
|
172
181
|
});
|
|
173
182
|
|
|
174
|
-
const findOracleCap = async (instance, from,
|
|
175
|
-
const current = await getCurrent(from, {
|
|
183
|
+
const findOracleCap = async (instance, from, readPublished) => {
|
|
184
|
+
const current = await getCurrent(from, { readPublished });
|
|
176
185
|
|
|
177
186
|
const { offerToUsedInvitation: entries } = /** @type {any} */ (current);
|
|
178
187
|
Array.isArray(entries) || Fail`entries must be an array: ${entries}`;
|
|
@@ -200,11 +209,10 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
200
209
|
s => s.split('.'),
|
|
201
210
|
)
|
|
202
211
|
.action(async opts => {
|
|
203
|
-
const {
|
|
204
|
-
await rpcTools();
|
|
212
|
+
const { readPublished, lookupPriceAggregatorInstance } = await rpcTools();
|
|
205
213
|
const instance = lookupPriceAggregatorInstance(opts.pair);
|
|
206
214
|
|
|
207
|
-
const offerId = await findOracleCap(instance, opts.from,
|
|
215
|
+
const offerId = await findOracleCap(instance, opts.from, readPublished);
|
|
208
216
|
if (!offerId) {
|
|
209
217
|
console.error('No continuing ids found');
|
|
210
218
|
}
|
|
@@ -265,12 +273,13 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
265
273
|
* }}
|
|
266
274
|
*/ { pair, keys, price },
|
|
267
275
|
) => {
|
|
268
|
-
const {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
{ fetch, execFileSync, delay },
|
|
276
|
+
const {
|
|
277
|
+
readLatestHead,
|
|
278
|
+
readPublished,
|
|
272
279
|
networkConfig,
|
|
273
|
-
|
|
280
|
+
lookupPriceAggregatorInstance,
|
|
281
|
+
} = await rpcTools();
|
|
282
|
+
const wutil = await makeWalletUtils({ fetch, delay }, networkConfig);
|
|
274
283
|
const unitPrice = scaleDecimals(price);
|
|
275
284
|
|
|
276
285
|
const feedPath = `published.priceFeed.${pair[0]}-${pair[1]}_price_feed`;
|
|
@@ -334,7 +343,7 @@ export const makeOracleCommand = (logger, io = {}) => {
|
|
|
334
343
|
adminOfferIds[from] = await findOracleCap(
|
|
335
344
|
instance,
|
|
336
345
|
from,
|
|
337
|
-
|
|
346
|
+
readPublished,
|
|
338
347
|
);
|
|
339
348
|
if (!adminOfferIds[from]) {
|
|
340
349
|
console.error(
|
package/src/commands/perf.js
CHANGED
|
@@ -7,21 +7,23 @@ import {
|
|
|
7
7
|
makeFollower,
|
|
8
8
|
makeLeaderFromRpcAddresses,
|
|
9
9
|
} from '@agoric/casting';
|
|
10
|
+
import { fetchEnvNetworkConfig } from '@agoric/client-utils';
|
|
11
|
+
import { slotToRemotable } from '@agoric/internal/src/storage-test-utils.js';
|
|
12
|
+
import { boardSlottingMarshaller } from '@agoric/vats/tools/board-utils.js';
|
|
10
13
|
import { Command } from 'commander';
|
|
11
14
|
import fs from 'fs';
|
|
12
15
|
import { exit } from 'process';
|
|
13
|
-
import { slotToRemotable } from '@agoric/internal/src/storage-test-utils.js';
|
|
14
|
-
import { boardSlottingMarshaller } from '@agoric/vats/tools/board-utils.js';
|
|
15
16
|
import { makeLeaderOptions } from '../lib/casting.js';
|
|
16
17
|
import {
|
|
17
18
|
execSwingsetTransaction,
|
|
18
19
|
normalizeAddressWithOptions,
|
|
19
20
|
} from '../lib/chain.js';
|
|
20
|
-
import { networkConfig } from '../lib/rpc.js';
|
|
21
21
|
|
|
22
22
|
// tight for perf testing but less than this tends to hang.
|
|
23
23
|
const SLEEP_SECONDS = 0.1;
|
|
24
24
|
|
|
25
|
+
const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
|
|
26
|
+
|
|
25
27
|
/**
|
|
26
28
|
* @param {import('anylogger').Logger} logger
|
|
27
29
|
*/
|