@agoric/solo 0.10.4-other-dev-d15096d.0.d15096d → 0.10.4-pre.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/ava.config.js +10 -0
- package/package.json +31 -44
- package/public/main.js +1 -0
- package/solo-config.json +3 -0
- package/src/add-chain.js +4 -4
- package/src/chain-cosmos-sdk.js +30 -36
- package/src/entrypoint.js +2 -2
- package/src/init-basedir.js +5 -6
- package/src/main.js +83 -24
- package/src/outbound.js +2 -2
- package/src/pipe-entrypoint.js +0 -1
- package/src/pipe.js +2 -2
- package/src/reset-state.js +2 -2
- package/src/set-fake-chain.js +3 -2
- package/src/set-gci-ingress.js +3 -2
- package/src/start.js +23 -32
- package/src/vat-http.js +3 -1
- package/src/vat-spawner.js +5 -1
- package/src/vat-uploads.js +2 -0
- package/src/web.js +7 -6
- package/test/captp-fixture.js +2 -2
- package/test/home.test.js +2 -2
- package/tsconfig.json +3 -6
package/ava.config.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This file configures AVA for this package. A config file next to each
|
|
2
|
+
// package.json avoids AVA's warning about using a config file from an
|
|
3
|
+
// ancestor directory:
|
|
4
|
+
// https://github.com/avajs/ava/blob/main/lib/cli.js
|
|
5
|
+
import base from '../../ava.config.js';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
...base,
|
|
9
|
+
timeout: '20m',
|
|
10
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/solo",
|
|
3
|
-
"version": "0.10.4-
|
|
3
|
+
"version": "0.10.4-pre.0",
|
|
4
4
|
"description": "Agoric's Solo vat runner",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,70 +15,57 @@
|
|
|
15
15
|
"test:xs": "exit 0",
|
|
16
16
|
"lint-fix": "yarn lint:eslint --fix",
|
|
17
17
|
"lint": "yarn run -T run-s --continue-on-error 'lint:*'",
|
|
18
|
-
"lint:types": "yarn run -T
|
|
19
|
-
"lint:eslint": "
|
|
18
|
+
"lint:types": "yarn run -T tsgo --tsBuildInfoFile tsconfig.tsgo.tsbuildinfo",
|
|
19
|
+
"lint:eslint": "node ../../scripts/eslint-repo.mjs ."
|
|
20
20
|
},
|
|
21
21
|
"keywords": [],
|
|
22
22
|
"author": "Agoric",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@agoric/access-token": "0.4.22-
|
|
26
|
-
"@agoric/cache": "0.3.3-
|
|
27
|
-
"@agoric/cosmic-proto": "0.4.1-
|
|
28
|
-
"@agoric/cosmic-swingset": "0.41.4-
|
|
29
|
-
"@agoric/internal": "0.3.3-
|
|
30
|
-
"@agoric/notifier": "0.6.3-
|
|
31
|
-
"@agoric/spawner": "0.6.9-
|
|
32
|
-
"@agoric/store": "0.9.3-
|
|
33
|
-
"@agoric/swing-store": "0.9.2-
|
|
34
|
-
"@agoric/swingset-vat": "0.32.3-
|
|
35
|
-
"@agoric/telemetry": "0.6.3-
|
|
36
|
-
"@agoric/time": "0.3.3-
|
|
37
|
-
"@agoric/vats": "0.15.2-
|
|
38
|
-
"@agoric/wallet": "0.18.4-
|
|
39
|
-
"@endo/base64": "^1.
|
|
40
|
-
"@endo/captp": "^4.
|
|
41
|
-
"@endo/errors": "^1.
|
|
42
|
-
"@endo/eventual-send": "^1.
|
|
43
|
-
"@endo/import-bundle": "^1.
|
|
44
|
-
"@endo/init": "^1.1.
|
|
45
|
-
"@endo/marshal": "^1.
|
|
46
|
-
"@endo/promise-kit": "^1.1
|
|
47
|
-
"anylogger": "^0.21.0",
|
|
25
|
+
"@agoric/access-token": "0.4.22-pre.0",
|
|
26
|
+
"@agoric/cache": "0.3.3-pre.0",
|
|
27
|
+
"@agoric/cosmic-proto": "0.4.1-pre.0",
|
|
28
|
+
"@agoric/cosmic-swingset": "0.41.4-pre.0",
|
|
29
|
+
"@agoric/internal": "0.3.3-pre.0",
|
|
30
|
+
"@agoric/notifier": "0.6.3-pre.0",
|
|
31
|
+
"@agoric/spawner": "0.6.9-pre.0",
|
|
32
|
+
"@agoric/store": "0.9.3-pre.0",
|
|
33
|
+
"@agoric/swing-store": "0.9.2-pre.0",
|
|
34
|
+
"@agoric/swingset-vat": "0.32.3-pre.0",
|
|
35
|
+
"@agoric/telemetry": "0.6.3-pre.0",
|
|
36
|
+
"@agoric/time": "0.3.3-pre.0",
|
|
37
|
+
"@agoric/vats": "0.15.2-pre.0",
|
|
38
|
+
"@agoric/wallet": "0.18.4-pre.0",
|
|
39
|
+
"@endo/base64": "^1.1.1",
|
|
40
|
+
"@endo/captp": "^4.5.1",
|
|
41
|
+
"@endo/errors": "^1.3.1",
|
|
42
|
+
"@endo/eventual-send": "^1.5.0",
|
|
43
|
+
"@endo/import-bundle": "^1.7.0",
|
|
44
|
+
"@endo/init": "^1.1.13",
|
|
45
|
+
"@endo/marshal": "^1.10.0",
|
|
46
|
+
"@endo/promise-kit": "^1.2.1",
|
|
48
47
|
"deterministic-json": "^1.0.5",
|
|
49
48
|
"express": "^5.0.1",
|
|
50
49
|
"http-proxy-middleware": "^2.0.6",
|
|
51
50
|
"import-meta-resolve": "^4.1.0",
|
|
52
|
-
"minimist": "^1.2.0",
|
|
53
51
|
"morgan": "^1.10.0",
|
|
54
|
-
"temp": "^0.9.1",
|
|
55
52
|
"tmp": "^0.2.1",
|
|
56
53
|
"ws": "^7.2.0"
|
|
57
54
|
},
|
|
58
55
|
"devDependencies": {
|
|
59
|
-
"@agoric/ertp": "0.16.3-
|
|
60
|
-
"@endo/bundle-source": "^4.
|
|
61
|
-
"ava": "^
|
|
56
|
+
"@agoric/ertp": "0.16.3-pre.0",
|
|
57
|
+
"@endo/bundle-source": "^4.3.2",
|
|
58
|
+
"ava": "^8.0.1",
|
|
62
59
|
"c8": "^10.1.3"
|
|
63
60
|
},
|
|
64
61
|
"publishConfig": {
|
|
65
62
|
"access": "public"
|
|
66
63
|
},
|
|
67
64
|
"engines": {
|
|
68
|
-
"node": "^
|
|
69
|
-
},
|
|
70
|
-
"ava": {
|
|
71
|
-
"files": [
|
|
72
|
-
"test/**/*.test.*"
|
|
73
|
-
],
|
|
74
|
-
"require": [
|
|
75
|
-
"@endo/init/debug.js"
|
|
76
|
-
],
|
|
77
|
-
"timeout": "20m",
|
|
78
|
-
"workerThreads": false
|
|
65
|
+
"node": "^22.11 || ^24.14"
|
|
79
66
|
},
|
|
80
67
|
"typeCoverage": {
|
|
81
|
-
"atLeast":
|
|
68
|
+
"atLeast": 75.18
|
|
82
69
|
},
|
|
83
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "5efbc7b59d32124089475afa58db059908a4df0a"
|
|
84
71
|
}
|
package/public/main.js
CHANGED
package/solo-config.json
CHANGED
package/src/add-chain.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import crypto from 'crypto';
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import crypto from 'node:crypto';
|
|
3
3
|
import djson from 'deterministic-json';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import fs from 'fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
6
|
|
|
7
7
|
import { Fail } from '@endo/errors';
|
|
8
8
|
import setGCIIngress from './set-gci-ingress.js';
|
package/src/chain-cosmos-sdk.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/* global clearTimeout setTimeout */
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import { mkdtemp, writeFile, unlink } from 'node:fs/promises';
|
|
6
|
+
import { tmpdir } from 'node:os';
|
|
7
|
+
import url from 'node:url';
|
|
8
|
+
import { execFile } from 'node:child_process';
|
|
7
9
|
|
|
8
10
|
import WebSocket from 'ws';
|
|
9
11
|
|
|
10
|
-
import anylogger from 'anylogger';
|
|
12
|
+
import anylogger from '@agoric/internal/vendor/anylogger.js';
|
|
11
13
|
import { decodeBase64, encodeBase64 } from '@endo/base64';
|
|
12
14
|
import { Fail, makeError } from '@endo/errors';
|
|
13
15
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
@@ -70,35 +72,28 @@ const randomizeDelay = delay =>
|
|
|
70
72
|
Math.ceil(delay + delay * RANDOM_SCALE * Math.random());
|
|
71
73
|
|
|
72
74
|
const makeTempFile = async (prefix, contents) => {
|
|
73
|
-
|
|
74
|
-
tempOpen({ prefix }, (err, info) => {
|
|
75
|
-
if (err) {
|
|
76
|
-
return reject(err);
|
|
77
|
-
}
|
|
78
|
-
return resolve(info);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
75
|
+
await null;
|
|
81
76
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
77
|
+
// Create temporary directory with Node native fs.mkdtemp
|
|
78
|
+
const tempDir = await mkdtemp(path.join(tmpdir(), prefix));
|
|
79
|
+
const tempPath = path.join(tempDir, 'tempfile');
|
|
80
|
+
|
|
81
|
+
// Write contents to file
|
|
82
|
+
await writeFile(tempPath, contents);
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
path: tempPath,
|
|
86
|
+
async cleanup() {
|
|
87
|
+
await null;
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
await unlink(tempPath);
|
|
91
|
+
await fs.promises.rmdir(tempDir);
|
|
92
|
+
} catch (err) {
|
|
93
|
+
// Ignore cleanup errors
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
};
|
|
102
97
|
};
|
|
103
98
|
|
|
104
99
|
export async function connectToChain(
|
|
@@ -446,7 +441,6 @@ export async function connectToChain(
|
|
|
446
441
|
|
|
447
442
|
// Find only the latest value in the events.
|
|
448
443
|
let storageValue;
|
|
449
|
-
// eslint-disable-next-line github/array-foreach
|
|
450
444
|
paths.forEach((key, i) => {
|
|
451
445
|
if (key === storagePath) {
|
|
452
446
|
storageValue = values[i];
|
|
@@ -717,7 +711,7 @@ ${chainID} chain does not yet know of address ${clientAddr}${adviseEgress(
|
|
|
717
711
|
}
|
|
718
712
|
};
|
|
719
713
|
|
|
720
|
-
await tryBody().finally(() => tmpInfo &&
|
|
714
|
+
await tryBody().finally(() => tmpInfo && tmpInfo.cleanup());
|
|
721
715
|
};
|
|
722
716
|
|
|
723
717
|
/**
|
package/src/entrypoint.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// (dep chain: temp->glob->minimatch->brace-expansion)
|
|
5
5
|
import '@endo/init/legacy.js';
|
|
6
6
|
|
|
7
|
-
import process from 'process';
|
|
8
|
-
import path from 'path';
|
|
7
|
+
import process from 'node:process';
|
|
8
|
+
import path from 'node:path';
|
|
9
9
|
|
|
10
10
|
// Configure logs.
|
|
11
11
|
import '@agoric/cosmic-swingset/src/anylogger-agoric.js';
|
package/src/init-basedir.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { execFileSync } from 'child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
6
5
|
|
|
7
6
|
import { assert, X } from '@endo/errors';
|
|
8
|
-
import anylogger from 'anylogger';
|
|
7
|
+
import anylogger from '@agoric/internal/vendor/anylogger.js';
|
|
9
8
|
import { HELPER } from './chain-cosmos-sdk.js';
|
|
10
9
|
|
|
11
10
|
const console = anylogger('ag-solo:init');
|
|
@@ -16,7 +15,7 @@ const dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* @param {string} basedir
|
|
19
|
-
* @param {string} webport
|
|
18
|
+
* @param {number | string} webport
|
|
20
19
|
* @param {string} webhost
|
|
21
20
|
* @param {string} _subdir
|
|
22
21
|
* @param {string[]} egresses
|
package/src/main.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import parseArgs from '
|
|
4
|
-
import process from 'process';
|
|
5
|
-
import { spawnSync } from 'child_process';
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { parseArgs } from 'node:util';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
import { spawnSync } from 'node:child_process';
|
|
6
6
|
import { assert } from '@endo/errors';
|
|
7
7
|
|
|
8
|
-
import anylogger from 'anylogger';
|
|
8
|
+
import anylogger from '@agoric/internal/vendor/anylogger.js';
|
|
9
9
|
|
|
10
10
|
// Start a network service
|
|
11
11
|
import addChain from './add-chain.js';
|
|
@@ -23,6 +23,41 @@ const DEFAULT_EGRESSES = 'cosmos';
|
|
|
23
23
|
const AG_SOLO_BASEDIR =
|
|
24
24
|
process.env.AG_SOLO_BASEDIR && path.resolve(process.env.AG_SOLO_BASEDIR);
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @param {string | boolean | (string | boolean)[] | undefined} value
|
|
28
|
+
* @param {string} defaultValue
|
|
29
|
+
*/
|
|
30
|
+
const stringOption = (value, defaultValue) =>
|
|
31
|
+
typeof value === 'string' ? value : defaultValue;
|
|
32
|
+
|
|
33
|
+
/** @param {string | boolean | (string | boolean)[] | undefined} value */
|
|
34
|
+
const optionalStringOption = value =>
|
|
35
|
+
typeof value === 'string' ? value : undefined;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param {string | boolean | (string | boolean)[] | undefined} value
|
|
39
|
+
* @param {boolean} defaultValue
|
|
40
|
+
*/
|
|
41
|
+
const booleanOption = (value, defaultValue) =>
|
|
42
|
+
typeof value === 'boolean' ? value : defaultValue;
|
|
43
|
+
|
|
44
|
+
const parseTopLevelArgs = rawArgv => {
|
|
45
|
+
const commandIndex = rawArgv.findIndex(arg => !arg.startsWith('-'));
|
|
46
|
+
const optionArgs =
|
|
47
|
+
commandIndex < 0 ? rawArgv : rawArgv.slice(0, commandIndex);
|
|
48
|
+
const commandArgs = commandIndex < 0 ? [] : rawArgv.slice(commandIndex);
|
|
49
|
+
const { values: opts } = parseArgs({
|
|
50
|
+
args: optionArgs,
|
|
51
|
+
options: {
|
|
52
|
+
help: { type: 'boolean' },
|
|
53
|
+
version: { type: 'boolean' },
|
|
54
|
+
},
|
|
55
|
+
allowPositionals: false,
|
|
56
|
+
strict: false,
|
|
57
|
+
});
|
|
58
|
+
return { opts, argv: commandArgs };
|
|
59
|
+
};
|
|
60
|
+
|
|
26
61
|
function insistIsBasedir() {
|
|
27
62
|
if (AG_SOLO_BASEDIR) {
|
|
28
63
|
process.chdir(AG_SOLO_BASEDIR);
|
|
@@ -39,10 +74,7 @@ function insistIsBasedir() {
|
|
|
39
74
|
|
|
40
75
|
export default async function solo(progname, rawArgv) {
|
|
41
76
|
log.debug('solo', rawArgv);
|
|
42
|
-
const {
|
|
43
|
-
stopEarly: true,
|
|
44
|
-
boolean: ['help', 'version'],
|
|
45
|
-
});
|
|
77
|
+
const { opts, argv } = parseTopLevelArgs(rawArgv);
|
|
46
78
|
|
|
47
79
|
if (opts.help) {
|
|
48
80
|
process.stdout.write(`\
|
|
@@ -57,7 +89,15 @@ start
|
|
|
57
89
|
await null;
|
|
58
90
|
switch (argv[0]) {
|
|
59
91
|
case 'setup': {
|
|
60
|
-
const {
|
|
92
|
+
const { values: setupOpts } = parseArgs({
|
|
93
|
+
args: argv.slice(1),
|
|
94
|
+
options: {
|
|
95
|
+
netconfig: { type: 'string' },
|
|
96
|
+
},
|
|
97
|
+
allowPositionals: true,
|
|
98
|
+
strict: false,
|
|
99
|
+
});
|
|
100
|
+
const netconfig = optionalStringOption(setupOpts.netconfig);
|
|
61
101
|
if (!AG_SOLO_BASEDIR) {
|
|
62
102
|
console.error(`setup: you must set $AG_SOLO_BASEDIR`);
|
|
63
103
|
return 1;
|
|
@@ -71,16 +111,23 @@ start
|
|
|
71
111
|
break;
|
|
72
112
|
}
|
|
73
113
|
case 'init': {
|
|
74
|
-
const {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
114
|
+
const { values: subOpts, positionals: subArgs } = parseArgs({
|
|
115
|
+
args: argv.slice(1),
|
|
116
|
+
options: {
|
|
117
|
+
webport: { type: 'string', default: '8000' },
|
|
118
|
+
webhost: { type: 'string', default: '127.0.0.1' },
|
|
119
|
+
egresses: { type: 'string', default: DEFAULT_EGRESSES },
|
|
120
|
+
defaultManagerType: {
|
|
121
|
+
type: 'string',
|
|
122
|
+
default: process.env.SWINGSET_WORKER_TYPE || 'xs-worker',
|
|
123
|
+
},
|
|
80
124
|
},
|
|
125
|
+
allowPositionals: true,
|
|
126
|
+
strict: false,
|
|
81
127
|
});
|
|
82
|
-
const webport = Number(subOpts.webport);
|
|
83
|
-
const
|
|
128
|
+
const webport = Number(stringOption(subOpts.webport, '8000'));
|
|
129
|
+
const webhost = stringOption(subOpts.webhost, '127.0.0.1');
|
|
130
|
+
const egresses = stringOption(subOpts.egresses, DEFAULT_EGRESSES);
|
|
84
131
|
const basedir = subArgs[0] || AG_SOLO_BASEDIR;
|
|
85
132
|
const subdir = subArgs[1];
|
|
86
133
|
assert(basedir !== undefined, 'you must provide a BASEDIR');
|
|
@@ -103,18 +150,30 @@ start
|
|
|
103
150
|
}
|
|
104
151
|
case 'add-chain': {
|
|
105
152
|
const basedir = insistIsBasedir();
|
|
106
|
-
const {
|
|
107
|
-
|
|
153
|
+
const { values: subOpts, positionals: subArgs } = parseArgs({
|
|
154
|
+
args: argv.slice(1),
|
|
155
|
+
options: {
|
|
156
|
+
reset: { type: 'boolean' },
|
|
157
|
+
},
|
|
158
|
+
allowPositionals: true,
|
|
159
|
+
strict: false,
|
|
108
160
|
});
|
|
109
161
|
const [chainConfig] = subArgs;
|
|
110
|
-
await addChain(basedir, chainConfig, subOpts.reset);
|
|
162
|
+
await addChain(basedir, chainConfig, booleanOption(subOpts.reset, false));
|
|
111
163
|
break;
|
|
112
164
|
}
|
|
113
165
|
case 'set-gci-ingress': {
|
|
114
166
|
const basedir = insistIsBasedir();
|
|
115
|
-
const {
|
|
167
|
+
const { values: subOpts, positionals: subArgs } = parseArgs({
|
|
168
|
+
args: argv.slice(1),
|
|
169
|
+
options: {
|
|
170
|
+
chainID: { type: 'string' },
|
|
171
|
+
},
|
|
172
|
+
allowPositionals: true,
|
|
173
|
+
strict: false,
|
|
174
|
+
});
|
|
116
175
|
const GCI = subArgs[0];
|
|
117
|
-
const chainID = subOpts.chainID
|
|
176
|
+
const chainID = stringOption(subOpts.chainID, 'agoric');
|
|
118
177
|
const rpcAddresses = subArgs.slice(1);
|
|
119
178
|
setGCIIngress(basedir, GCI, rpcAddresses, chainID);
|
|
120
179
|
break;
|
package/src/outbound.js
CHANGED
package/src/pipe-entrypoint.js
CHANGED
package/src/pipe.js
CHANGED
package/src/reset-state.js
CHANGED
package/src/set-fake-chain.js
CHANGED
package/src/set-gci-ingress.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
3
4
|
|
|
4
5
|
export default function setGCIIngress(basedir, GCI, rpcAddresses, chainID) {
|
|
5
6
|
const myAddrFn = path.join(basedir, 'ag-cosmos-helper-address');
|
package/src/start.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import { promisify } from 'util';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import url from 'node:url';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { mkdtemp, writeFile, unlink } from 'node:fs/promises';
|
|
6
|
+
import { fork } from 'node:child_process';
|
|
7
|
+
import { promisify } from 'node:util';
|
|
9
8
|
import { resolve as importMetaResolve } from 'import-meta-resolve';
|
|
10
9
|
// import { createHash } from 'crypto';
|
|
11
10
|
|
|
12
|
-
import anylogger from 'anylogger';
|
|
11
|
+
import anylogger from '@agoric/internal/vendor/anylogger.js';
|
|
13
12
|
|
|
14
13
|
// import connect from 'lotion-connect';
|
|
15
14
|
// import djson from 'deterministic-json';
|
|
@@ -53,41 +52,33 @@ const log = anylogger('start');
|
|
|
53
52
|
|
|
54
53
|
let swingSetRunning = false;
|
|
55
54
|
|
|
56
|
-
const fsWrite = promisify(fs.write);
|
|
57
|
-
const fsClose = promisify(fs.close);
|
|
58
55
|
const rename = promisify(fs.rename);
|
|
59
|
-
const unlink = promisify(fs.unlink);
|
|
60
56
|
|
|
61
57
|
const atomicReplaceFile = async (filename, contents) => {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
(err, inf) => {
|
|
69
|
-
if (err) {
|
|
70
|
-
reject(err);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
resolve(inf);
|
|
74
|
-
},
|
|
75
|
-
);
|
|
76
|
-
});
|
|
58
|
+
const basename = path.basename(filename);
|
|
59
|
+
const tempDir = await mkdtemp(
|
|
60
|
+
path.join(path.dirname(filename), `${basename}.`),
|
|
61
|
+
);
|
|
62
|
+
const tempPath = path.join(tempDir, basename);
|
|
63
|
+
|
|
77
64
|
try {
|
|
78
|
-
|
|
79
|
-
await
|
|
80
|
-
await fsClose(info.fd);
|
|
81
|
-
await rename(info.path, filename);
|
|
65
|
+
await writeFile(tempPath, contents);
|
|
66
|
+
await rename(tempPath, filename);
|
|
82
67
|
} catch (e) {
|
|
83
|
-
// Unlink on error.
|
|
84
68
|
try {
|
|
85
|
-
await unlink(
|
|
69
|
+
await unlink(tempPath);
|
|
70
|
+
await fs.promises.rmdir(tempDir);
|
|
86
71
|
} catch (e2) {
|
|
87
72
|
// do nothing, we're already failing
|
|
88
73
|
}
|
|
89
74
|
throw e;
|
|
90
75
|
}
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
await fs.promises.rmdir(tempDir);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
// Ignore cleanup errors
|
|
81
|
+
}
|
|
91
82
|
};
|
|
92
83
|
|
|
93
84
|
const neverStop = () => {
|
package/src/vat-http.js
CHANGED
|
@@ -143,7 +143,7 @@ export function buildRootObject(vatPowers) {
|
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* @param {object} [privateObjects]
|
|
146
|
-
* @param {
|
|
146
|
+
* @param {Record<string, any>} [decentralObjects]
|
|
147
147
|
* @param {object} [deprecatedObjects]
|
|
148
148
|
*/
|
|
149
149
|
setPresences(
|
|
@@ -241,3 +241,5 @@ export function buildRootObject(vatPowers) {
|
|
|
241
241
|
},
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
|
+
|
|
245
|
+
/** @typedef {ReturnType<typeof buildRootObject>} HttpVat */
|
package/src/vat-spawner.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// Copyright (C) 2018 Agoric, under Apache License 2.0
|
|
2
|
+
import { E } from '@endo/eventual-send';
|
|
2
3
|
import { Far } from '@endo/marshal';
|
|
3
4
|
import { makeSpawner } from '@agoric/spawner';
|
|
4
5
|
|
|
5
6
|
function buildRootObject() {
|
|
6
7
|
return Far('root', {
|
|
7
8
|
buildSpawner(vatAdminSvc) {
|
|
8
|
-
|
|
9
|
+
const spawnBundleCapP = E(vatAdminSvc).getNamedBundleCap('spawn');
|
|
10
|
+
return makeSpawner(vatAdminSvc, spawnBundleCapP);
|
|
9
11
|
},
|
|
10
12
|
});
|
|
11
13
|
}
|
|
12
14
|
harden(buildRootObject);
|
|
13
15
|
export { buildRootObject };
|
|
16
|
+
|
|
17
|
+
/** @typedef {ReturnType<typeof buildRootObject>} SpawnerVat */
|
package/src/vat-uploads.js
CHANGED
package/src/web.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/* global setTimeout clearTimeout setInterval clearInterval process */
|
|
2
3
|
// Start a network service
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import http from 'http';
|
|
5
|
-
import { createConnection } from 'net';
|
|
6
|
-
import { existsSync as existsSyncAmbient } from 'fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import http from 'node:http';
|
|
6
|
+
import { createConnection } from 'node:net';
|
|
7
|
+
import { existsSync as existsSyncAmbient } from 'node:fs';
|
|
7
8
|
import express from 'express';
|
|
8
9
|
import { createProxyMiddleware } from 'http-proxy-middleware';
|
|
9
10
|
import WebSocket from 'ws';
|
|
10
|
-
import anylogger from 'anylogger';
|
|
11
|
+
import anylogger from '@agoric/internal/vendor/anylogger.js';
|
|
11
12
|
import morgan from 'morgan';
|
|
12
|
-
import { format as urlFormat } from 'url';
|
|
13
|
+
import { format as urlFormat } from 'node:url';
|
|
13
14
|
|
|
14
15
|
import { getAccessToken } from '@agoric/access-token';
|
|
15
16
|
|
package/test/captp-fixture.js
CHANGED
package/test/home.test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-nocheck
|
|
2
2
|
|
|
3
3
|
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
|
|
4
4
|
|
|
@@ -198,6 +198,6 @@ test.serial('home.localTimerService makeRepeater', async t => {
|
|
|
198
198
|
// This runs after all the tests.
|
|
199
199
|
test.after.always('teardown', async t => {
|
|
200
200
|
const { teardown } = t.context;
|
|
201
|
-
await teardown();
|
|
201
|
+
await teardown?.();
|
|
202
202
|
t.truthy('shutdown');
|
|
203
203
|
});
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
// This file can contain .js-specific Typescript compiler config.
|
|
2
2
|
{
|
|
3
3
|
"extends": "../../tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"checkJs": false,
|
|
6
|
-
},
|
|
7
4
|
"include": [
|
|
8
|
-
"public
|
|
9
|
-
"src
|
|
10
|
-
"test
|
|
5
|
+
"public",
|
|
6
|
+
"src",
|
|
7
|
+
"test",
|
|
11
8
|
],
|
|
12
9
|
}
|