agoric 0.21.2-upgrade-16-dev-d492653.0 → 0.21.2-upgrade-16-dev-0549112.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 +21 -20
- package/src/commands/wallet.js +33 -15
- package/src/lib/bundles.js +102 -0
- package/src/main.js +49 -47
- package/src/sdk-package-names.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agoric",
|
|
3
|
-
"version": "0.21.2-upgrade-16-dev-
|
|
3
|
+
"version": "0.21.2-upgrade-16-dev-0549112.0+0549112",
|
|
4
4
|
"description": "Manage the Agoric Javascript smart contract platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main.js",
|
|
@@ -29,29 +29,29 @@
|
|
|
29
29
|
"lint:eslint": "eslint ."
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@agoric/cosmic-swingset": "0.41.4-upgrade-16-dev-
|
|
33
|
-
"@agoric/deploy-script-support": "0.10.4-upgrade-16-dev-
|
|
32
|
+
"@agoric/cosmic-swingset": "0.41.4-upgrade-16-dev-0549112.0+0549112",
|
|
33
|
+
"@agoric/deploy-script-support": "0.10.4-upgrade-16-dev-0549112.0+0549112",
|
|
34
34
|
"ava": "^5.3.0",
|
|
35
35
|
"c8": "^9.1.0",
|
|
36
36
|
"dd-trace": "^4.11.1"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@agoric/access-token": "0.4.22-upgrade-16-dev-
|
|
40
|
-
"@agoric/assert": "0.6.1-upgrade-16-dev-
|
|
41
|
-
"@agoric/cache": "0.3.3-upgrade-16-dev-
|
|
42
|
-
"@agoric/casting": "0.4.3-upgrade-16-dev-
|
|
43
|
-
"@agoric/cosmic-proto": "0.4.1-upgrade-16-dev-
|
|
44
|
-
"@agoric/ertp": "0.16.3-upgrade-16-dev-
|
|
45
|
-
"@agoric/governance": "0.10.4-upgrade-16-dev-
|
|
46
|
-
"@agoric/inter-protocol": "0.16.2-upgrade-16-dev-
|
|
47
|
-
"@agoric/internal": "0.3.3-upgrade-16-dev-
|
|
48
|
-
"@agoric/network": "0.1.1-upgrade-16-dev-
|
|
49
|
-
"@agoric/smart-wallet": "0.5.4-upgrade-16-dev-
|
|
50
|
-
"@agoric/store": "0.9.3-upgrade-16-dev-
|
|
51
|
-
"@agoric/swingset-vat": "0.32.3-upgrade-16-dev-
|
|
52
|
-
"@agoric/vats": "0.15.2-upgrade-16-dev-
|
|
53
|
-
"@agoric/zoe": "0.26.3-upgrade-16-dev-
|
|
54
|
-
"@agoric/zone": "0.2.3-upgrade-16-dev-
|
|
39
|
+
"@agoric/access-token": "0.4.22-upgrade-16-dev-0549112.0+0549112",
|
|
40
|
+
"@agoric/assert": "0.6.1-upgrade-16-dev-0549112.0+0549112",
|
|
41
|
+
"@agoric/cache": "0.3.3-upgrade-16-dev-0549112.0+0549112",
|
|
42
|
+
"@agoric/casting": "0.4.3-upgrade-16-dev-0549112.0+0549112",
|
|
43
|
+
"@agoric/cosmic-proto": "0.4.1-upgrade-16-dev-0549112.0+0549112",
|
|
44
|
+
"@agoric/ertp": "0.16.3-upgrade-16-dev-0549112.0+0549112",
|
|
45
|
+
"@agoric/governance": "0.10.4-upgrade-16-dev-0549112.0+0549112",
|
|
46
|
+
"@agoric/inter-protocol": "0.16.2-upgrade-16-dev-0549112.0+0549112",
|
|
47
|
+
"@agoric/internal": "0.3.3-upgrade-16-dev-0549112.0+0549112",
|
|
48
|
+
"@agoric/network": "0.1.1-upgrade-16-dev-0549112.0+0549112",
|
|
49
|
+
"@agoric/smart-wallet": "0.5.4-upgrade-16-dev-0549112.0+0549112",
|
|
50
|
+
"@agoric/store": "0.9.3-upgrade-16-dev-0549112.0+0549112",
|
|
51
|
+
"@agoric/swingset-vat": "0.32.3-upgrade-16-dev-0549112.0+0549112",
|
|
52
|
+
"@agoric/vats": "0.15.2-upgrade-16-dev-0549112.0+0549112",
|
|
53
|
+
"@agoric/zoe": "0.26.3-upgrade-16-dev-0549112.0+0549112",
|
|
54
|
+
"@agoric/zone": "0.2.3-upgrade-16-dev-0549112.0+0549112",
|
|
55
55
|
"@confio/relayer": "^0.11.3",
|
|
56
56
|
"@cosmjs/crypto": "^0.32.3",
|
|
57
57
|
"@cosmjs/encoding": "^0.32.3",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"@endo/nat": "^5.0.7",
|
|
69
69
|
"@endo/patterns": "^1.4.0",
|
|
70
70
|
"@endo/promise-kit": "^1.1.2",
|
|
71
|
+
"@endo/zip": "^1.0.5",
|
|
71
72
|
"@iarna/toml": "^2.2.3",
|
|
72
73
|
"anylogger": "^0.21.0",
|
|
73
74
|
"chalk": "^5.2.0",
|
|
@@ -100,5 +101,5 @@
|
|
|
100
101
|
"typeCoverage": {
|
|
101
102
|
"atLeast": 76.99
|
|
102
103
|
},
|
|
103
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "05491122ee61362c8310a7924ac67f033b02e38f"
|
|
104
105
|
}
|
package/src/commands/wallet.js
CHANGED
|
@@ -29,19 +29,26 @@ const SLEEP_SECONDS = 3;
|
|
|
29
29
|
* @returns {Promise<import('commander').Command>}
|
|
30
30
|
*/
|
|
31
31
|
export const makeWalletCommand = async command => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'
|
|
38
|
-
|
|
32
|
+
/**
|
|
33
|
+
* @param {import('commander').Command} baseCmd
|
|
34
|
+
*/
|
|
35
|
+
const withSharedTxOptions = baseCmd =>
|
|
36
|
+
baseCmd
|
|
37
|
+
.option('--home <dir>', 'agd application home directory')
|
|
38
|
+
.option(
|
|
39
|
+
'--keyring-backend <os|file|test>',
|
|
40
|
+
'keyring\'s backend (os|file|test) (default "os")',
|
|
41
|
+
);
|
|
42
|
+
/** @typedef {{home?: string, keyringBackend: 'os' | 'file' | 'test'}} SharedTxOptions */
|
|
43
|
+
|
|
44
|
+
const wallet = withSharedTxOptions(command('wallet')).description(
|
|
45
|
+
'wallet commands',
|
|
46
|
+
);
|
|
39
47
|
|
|
40
48
|
const normalizeAddress = literalOrName =>
|
|
41
49
|
normalizeAddressWithOptions(literalOrName, wallet.opts());
|
|
42
50
|
|
|
43
|
-
wallet
|
|
44
|
-
.command('provision')
|
|
51
|
+
withSharedTxOptions(wallet.command('provision'))
|
|
45
52
|
.description('provision a Smart Wallet')
|
|
46
53
|
.requiredOption(
|
|
47
54
|
'--account [address]',
|
|
@@ -51,8 +58,14 @@ export const makeWalletCommand = async command => {
|
|
|
51
58
|
.option('--spend', 'confirm you want to spend')
|
|
52
59
|
.option('--nickname <string>', 'nickname to use', 'my-wallet')
|
|
53
60
|
.action(function (opts) {
|
|
54
|
-
|
|
55
|
-
const {
|
|
61
|
+
/** @typedef {{account: string, spend?: boolean, nickname: 'my-wallet' | string }} Opts */
|
|
62
|
+
const {
|
|
63
|
+
account,
|
|
64
|
+
nickname,
|
|
65
|
+
spend,
|
|
66
|
+
home,
|
|
67
|
+
keyringBackend: backend,
|
|
68
|
+
} = /** @type {SharedTxOptions & Opts} */ ({ ...wallet.opts(), ...opts });
|
|
56
69
|
const tx = ['provision-one', nickname, account, 'SMART_WALLET'];
|
|
57
70
|
if (spend) {
|
|
58
71
|
execSwingsetTransaction(tx, {
|
|
@@ -110,8 +123,7 @@ export const makeWalletCommand = async command => {
|
|
|
110
123
|
console.log(offerObj.offer.id);
|
|
111
124
|
});
|
|
112
125
|
|
|
113
|
-
wallet
|
|
114
|
-
.command('send')
|
|
126
|
+
withSharedTxOptions(wallet.command('send'))
|
|
115
127
|
.description('send a prepared offer')
|
|
116
128
|
.requiredOption(
|
|
117
129
|
'--from [address]',
|
|
@@ -121,8 +133,14 @@ export const makeWalletCommand = async command => {
|
|
|
121
133
|
.requiredOption('--offer [filename]', 'path to file with prepared offer')
|
|
122
134
|
.option('--dry-run', 'spit out the command instead of running it')
|
|
123
135
|
.action(function (opts) {
|
|
124
|
-
|
|
125
|
-
const {
|
|
136
|
+
/** @typedef {{ from: string, offer: string, dryRun: boolean }} Opts */
|
|
137
|
+
const {
|
|
138
|
+
dryRun,
|
|
139
|
+
from,
|
|
140
|
+
offer,
|
|
141
|
+
home,
|
|
142
|
+
keyringBackend: backend,
|
|
143
|
+
} = /** @type {SharedTxOptions & Opts} */ ({ ...wallet.opts(), ...opts });
|
|
126
144
|
|
|
127
145
|
const offerBody = fs.readFileSync(offer).toString();
|
|
128
146
|
execSwingsetTransaction(['wallet-action', '--allow-spend', offerBody], {
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/* global Buffer */
|
|
4
|
+
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
|
|
9
|
+
import { ZipReader } from '@endo/zip';
|
|
10
|
+
|
|
11
|
+
/** @import {Bundle} from '@agoric/swingset-vat'; */
|
|
12
|
+
/** @import {CoreEvalPlan} from '@agoric/deploy-script-support/src/writeCoreEvalParts.js' */
|
|
13
|
+
|
|
14
|
+
const PACKAGE_NAME_RE = /(?<packageName>.*-v[\d.]+)\//;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {{ name: string, label: string, location: string, modules: Record<string, {compartment: string, module: string}>}} Compartment
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef CompartmentMap
|
|
22
|
+
* @property {string[]} tags
|
|
23
|
+
* @property {{compartment: string, module: string}} entry
|
|
24
|
+
* @property {Record<string, Compartment>} compartments
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** @param {Bundle} bundleObj*/
|
|
28
|
+
export const extractBundleInfo = async bundleObj => {
|
|
29
|
+
if (bundleObj.moduleFormat !== 'endoZipBase64') {
|
|
30
|
+
throw new Error('only endoZipBase64 is supported');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const contents = Buffer.from(bundleObj.endoZipBase64, 'base64');
|
|
34
|
+
|
|
35
|
+
const zipReader = new ZipReader(contents);
|
|
36
|
+
const { files } = zipReader;
|
|
37
|
+
|
|
38
|
+
const cmapEntry = files.get('compartment-map.json');
|
|
39
|
+
/** @type {CompartmentMap} */
|
|
40
|
+
const compartmentMap = JSON.parse(Buffer.from(cmapEntry.content).toString());
|
|
41
|
+
|
|
42
|
+
// XXX mapIter better but requires SES
|
|
43
|
+
const fileSizes = Object.fromEntries(
|
|
44
|
+
Array.from(files.values()).map(f => [
|
|
45
|
+
f.name,
|
|
46
|
+
// bundle contents are not compressed
|
|
47
|
+
f.content.length,
|
|
48
|
+
]),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return { compartmentMap, fileSizes };
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// UNTIL https://github.com/endojs/endo/issues/1656
|
|
55
|
+
/** @param {string} bundleFilename */
|
|
56
|
+
export const statBundle = async bundleFilename => {
|
|
57
|
+
const bundle = fs.readFileSync(bundleFilename, 'utf8');
|
|
58
|
+
/** @type {Bundle} */
|
|
59
|
+
const bundleObj = JSON.parse(bundle);
|
|
60
|
+
console.log('\nBUNDLE', bundleObj.moduleFormat, bundleFilename);
|
|
61
|
+
|
|
62
|
+
const info = await extractBundleInfo(bundleObj);
|
|
63
|
+
assert(info, 'no bundle info');
|
|
64
|
+
|
|
65
|
+
/** @type {Record<string, number>} */
|
|
66
|
+
const byPackage = {};
|
|
67
|
+
let totalSize = 0;
|
|
68
|
+
for (const [filename, size] of Object.entries(info.fileSizes)) {
|
|
69
|
+
totalSize += size;
|
|
70
|
+
if (filename === 'compartment-map.json') {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const { packageName } = filename.match(PACKAGE_NAME_RE)?.groups ?? {};
|
|
74
|
+
assert(packageName, `invalid filename ${filename}`);
|
|
75
|
+
byPackage[packageName] ||= 0;
|
|
76
|
+
byPackage[packageName] += size;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log('Sum of file sizes in each package:');
|
|
80
|
+
console.table(byPackage);
|
|
81
|
+
|
|
82
|
+
console.log('total size:', totalSize);
|
|
83
|
+
console.log('\nTo explore the contents:\n');
|
|
84
|
+
console.log(
|
|
85
|
+
` DIR=$(mktemp -d); cat ${bundleFilename} | jq -r .endoZipBase64 | base64 -d | tar xC $DIR; open $DIR`,
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** @param {string} path */
|
|
90
|
+
export const statPlans = async path => {
|
|
91
|
+
const files = await fs.promises.readdir(path);
|
|
92
|
+
const planfiles = files.filter(f => f.endsWith('plan.json'));
|
|
93
|
+
|
|
94
|
+
for (const planfile of planfiles) {
|
|
95
|
+
/** @type {CoreEvalPlan} */
|
|
96
|
+
const plan = JSON.parse(fs.readFileSync(join(path, planfile), 'utf8'));
|
|
97
|
+
console.log('\n**\nPLAN', plan.name);
|
|
98
|
+
for (const bundle of plan.bundles) {
|
|
99
|
+
await statBundle(bundle.fileName);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
package/src/main.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
/* global process */
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import url from 'url';
|
|
5
2
|
import { assert, details as X } from '@agoric/assert';
|
|
6
3
|
import {
|
|
7
|
-
DEFAULT_KEEP_POLLING_SECONDS,
|
|
8
4
|
DEFAULT_JITTER_SECONDS,
|
|
5
|
+
DEFAULT_KEEP_POLLING_SECONDS,
|
|
9
6
|
} from '@agoric/casting';
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import url from 'url';
|
|
10
|
+
import { makeWalletCommand } from './commands/wallet.js';
|
|
10
11
|
import cosmosMain from './cosmos.js';
|
|
11
12
|
import deployMain from './deploy.js';
|
|
12
|
-
import
|
|
13
|
-
import publishMain from './main-publish.js';
|
|
13
|
+
import followMain from './follow.js';
|
|
14
14
|
import initMain from './init.js';
|
|
15
15
|
import installMain from './install.js';
|
|
16
|
+
import { statPlans } from './lib/bundles.js';
|
|
17
|
+
import publishMain from './main-publish.js';
|
|
18
|
+
import walletMain from './open.js';
|
|
19
|
+
import runMain from './run.js';
|
|
16
20
|
import setDefaultsMain from './set-defaults.js';
|
|
17
21
|
import startMain from './start.js';
|
|
18
|
-
import followMain from './follow.js';
|
|
19
|
-
import walletMain from './open.js';
|
|
20
|
-
import { makeWalletCommand } from './commands/wallet.js';
|
|
21
22
|
|
|
22
23
|
const DEFAULT_DAPP_TEMPLATE = 'dapp-offer-up';
|
|
23
24
|
const DEFAULT_DAPP_URL_BASE = 'https://github.com/Agoric/';
|
|
@@ -46,6 +47,7 @@ const main = async (progname, rawArgs, powers) => {
|
|
|
46
47
|
return true;
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
// XXX exits process when fn resolves
|
|
49
51
|
function subMain(fn, args, options) {
|
|
50
52
|
return fn(progname, args, powers, options).then(
|
|
51
53
|
// This seems to be the only way to propagate the exit code.
|
|
@@ -280,29 +282,6 @@ const main = async (progname, rawArgs, powers) => {
|
|
|
280
282
|
return subMain(followMain, ['follow', ...pathSpecs], opts);
|
|
281
283
|
});
|
|
282
284
|
|
|
283
|
-
const addRunOptions = cmd =>
|
|
284
|
-
cmd
|
|
285
|
-
.option(
|
|
286
|
-
'--allow-unsafe-plugins',
|
|
287
|
-
`CAREFUL: installed Agoric VM plugins will also have all your user's privileges`,
|
|
288
|
-
false,
|
|
289
|
-
)
|
|
290
|
-
.option(
|
|
291
|
-
'--hostport <host:port>',
|
|
292
|
-
'host and port to connect to VM',
|
|
293
|
-
'127.0.0.1:8000',
|
|
294
|
-
)
|
|
295
|
-
.option(
|
|
296
|
-
'--need <subsystems>',
|
|
297
|
-
'comma-separated names of subsystems to wait for',
|
|
298
|
-
'local,agoric,wallet',
|
|
299
|
-
)
|
|
300
|
-
.option(
|
|
301
|
-
'--provide <subsystems>',
|
|
302
|
-
'comma-separated names of subsystems this script initializes',
|
|
303
|
-
'',
|
|
304
|
-
);
|
|
305
|
-
|
|
306
285
|
baseCmd('run <script> [script-args...]')
|
|
307
286
|
.description(
|
|
308
287
|
'run a script with all your user privileges and some Agoric endowments',
|
|
@@ -310,23 +289,46 @@ const main = async (progname, rawArgs, powers) => {
|
|
|
310
289
|
.passThroughOptions(true)
|
|
311
290
|
.action(async (script, scriptArgs, _options, cmd) => {
|
|
312
291
|
const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts, scriptArgs };
|
|
313
|
-
|
|
292
|
+
await runMain(progname, ['run', script], powers, opts);
|
|
293
|
+
|
|
294
|
+
if (opts.verbose) {
|
|
295
|
+
await statPlans(process.cwd());
|
|
296
|
+
}
|
|
314
297
|
});
|
|
315
298
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
299
|
+
baseCmd('deploy [script...]')
|
|
300
|
+
.option(
|
|
301
|
+
'--target <target>',
|
|
302
|
+
'One of agoric, local, cosmos, or sim',
|
|
303
|
+
'agoric',
|
|
304
|
+
)
|
|
305
|
+
.option(
|
|
306
|
+
'--allow-unsafe-plugins',
|
|
307
|
+
`CAREFUL: installed Agoric VM plugins will also have all your user's privileges`,
|
|
308
|
+
false,
|
|
309
|
+
)
|
|
310
|
+
.option(
|
|
311
|
+
'--hostport <host:port>',
|
|
312
|
+
'host and port to connect to VM',
|
|
313
|
+
'127.0.0.1:8000',
|
|
314
|
+
)
|
|
315
|
+
.option(
|
|
316
|
+
'--need <subsystems>',
|
|
317
|
+
'comma-separated names of subsystems to wait for',
|
|
318
|
+
'local,agoric,wallet',
|
|
319
|
+
)
|
|
320
|
+
.option(
|
|
321
|
+
'--provide <subsystems>',
|
|
322
|
+
'comma-separated names of subsystems this script initializes',
|
|
323
|
+
'',
|
|
324
|
+
)
|
|
325
|
+
.description(
|
|
326
|
+
'run multiple scripts with all your user privileges against the local Agoric VM',
|
|
327
|
+
)
|
|
328
|
+
.action(async (scripts, _options, cmd) => {
|
|
329
|
+
const opts = { ...program.opts(), ...cmd.opts() };
|
|
330
|
+
return subMain(deployMain, ['deploy', ...scripts], opts);
|
|
331
|
+
});
|
|
330
332
|
|
|
331
333
|
baseCmd('publish [bundle...]')
|
|
332
334
|
.option(
|
package/src/sdk-package-names.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
export default [
|
|
4
4
|
"@agoric/access-token",
|
|
5
5
|
"@agoric/assert",
|
|
6
|
-
"@agoric/async-flow",
|
|
7
6
|
"@agoric/base-zone",
|
|
8
7
|
"@agoric/benchmark",
|
|
9
8
|
"@agoric/boot",
|
|
@@ -25,7 +24,6 @@ export default [
|
|
|
25
24
|
"@agoric/kmarshal",
|
|
26
25
|
"@agoric/network",
|
|
27
26
|
"@agoric/notifier",
|
|
28
|
-
"@agoric/orchestration",
|
|
29
27
|
"@agoric/pegasus",
|
|
30
28
|
"@agoric/smart-wallet",
|
|
31
29
|
"@agoric/solo",
|