agoric 0.22.0-u13.0 → 0.22.0-upgrade-14-dev-0a0580c.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 +19 -18
- package/src/init.js +2 -1
- package/src/main.js +2 -2
- package/src/sdk-package-names.js +1 -0
- package/tools/getting-started.js +269 -0
- package/tools/resm-plugin/deploy.js +19 -0
- package/tools/resm-plugin/package.json +5 -0
- package/tools/resm-plugin/src/output.js +1 -0
- package/tools/resm-plugin/src/plugin.js +18 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agoric",
|
|
3
|
-
"version": "0.22.0-
|
|
3
|
+
"version": "0.22.0-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
4
4
|
"description": "Manage the Agoric Javascript smart contract platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main.js",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"src",
|
|
17
|
+
"tools",
|
|
17
18
|
"exported.js"
|
|
18
19
|
],
|
|
19
20
|
"scripts": {
|
|
@@ -28,26 +29,26 @@
|
|
|
28
29
|
"lint:eslint": "eslint ."
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@agoric/deploy-script-support": "
|
|
32
|
+
"@agoric/deploy-script-support": "0.10.4-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
32
33
|
"ava": "^5.2.0",
|
|
33
34
|
"c8": "^7.13.0",
|
|
34
35
|
"dd-trace": "^3.3.0"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@agoric/access-token": "
|
|
38
|
-
"@agoric/assert": "
|
|
39
|
-
"@agoric/cache": "
|
|
40
|
-
"@agoric/casting": "
|
|
41
|
-
"@agoric/cosmic-proto": "
|
|
42
|
-
"@agoric/ertp": "
|
|
43
|
-
"@agoric/inter-protocol": "
|
|
44
|
-
"@agoric/internal": "
|
|
45
|
-
"@agoric/smart-wallet": "
|
|
46
|
-
"@agoric/store": "
|
|
47
|
-
"@agoric/swingset-vat": "
|
|
48
|
-
"@agoric/vats": "
|
|
49
|
-
"@agoric/zoe": "
|
|
50
|
-
"@agoric/zone": "
|
|
38
|
+
"@agoric/access-token": "0.4.22-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
39
|
+
"@agoric/assert": "0.6.1-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
40
|
+
"@agoric/cache": "0.3.3-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
41
|
+
"@agoric/casting": "0.4.3-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
42
|
+
"@agoric/cosmic-proto": "0.3.1-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
43
|
+
"@agoric/ertp": "0.16.3-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
44
|
+
"@agoric/inter-protocol": "0.16.2-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
45
|
+
"@agoric/internal": "0.4.0-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
46
|
+
"@agoric/smart-wallet": "0.5.4-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
47
|
+
"@agoric/store": "0.9.3-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
48
|
+
"@agoric/swingset-vat": "0.32.3-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
49
|
+
"@agoric/vats": "0.15.2-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
50
|
+
"@agoric/zoe": "0.26.3-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
51
|
+
"@agoric/zone": "0.2.3-upgrade-14-dev-0a0580c.0+0a0580c",
|
|
51
52
|
"@confio/relayer": "^0.9.0",
|
|
52
53
|
"@cosmjs/crypto": "^0.30.1",
|
|
53
54
|
"@cosmjs/encoding": "^0.30.1",
|
|
@@ -65,7 +66,7 @@
|
|
|
65
66
|
"@iarna/toml": "^2.2.3",
|
|
66
67
|
"anylogger": "^0.21.0",
|
|
67
68
|
"chalk": "^5.2.0",
|
|
68
|
-
"commander": "^
|
|
69
|
+
"commander": "^11.1.0",
|
|
69
70
|
"deterministic-json": "^1.0.5",
|
|
70
71
|
"esm": "agoric-labs/esm#Agoric-built",
|
|
71
72
|
"inquirer": "^8.2.2",
|
|
@@ -91,5 +92,5 @@
|
|
|
91
92
|
"timeout": "2m",
|
|
92
93
|
"workerThreads": false
|
|
93
94
|
},
|
|
94
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "0a0580cba9f4b41a1dc748cdd267dbcf0feed362"
|
|
95
96
|
}
|
package/src/init.js
CHANGED
|
@@ -40,9 +40,10 @@ export default async function initMain(_progname, rawArgs, priv, opts) {
|
|
|
40
40
|
dappBranch = ['-b', opts.dappBranch];
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
const shallow = ['--depth', '1', '--shallow-submodules'];
|
|
43
44
|
const exitStatus = await pspawn(
|
|
44
45
|
'git',
|
|
45
|
-
['clone', '--origin=upstream', dappURL, DIR, ...dappBranch],
|
|
46
|
+
['clone', '--origin=upstream', ...shallow, dappURL, DIR, ...dappBranch],
|
|
46
47
|
{
|
|
47
48
|
stdio: 'inherit',
|
|
48
49
|
},
|
package/src/main.js
CHANGED
|
@@ -20,7 +20,7 @@ import followMain from './follow.js';
|
|
|
20
20
|
import walletMain from './open.js';
|
|
21
21
|
import { makeWalletCommand } from './commands/wallet.js';
|
|
22
22
|
|
|
23
|
-
const DEFAULT_DAPP_TEMPLATE = 'dapp-
|
|
23
|
+
const DEFAULT_DAPP_TEMPLATE = 'dapp-offer-up';
|
|
24
24
|
const DEFAULT_DAPP_URL_BASE = 'https://github.com/Agoric/';
|
|
25
25
|
const DEFAULT_DAPP_BRANCH = undefined;
|
|
26
26
|
|
|
@@ -96,7 +96,7 @@ const main = async (progname, rawArgs, powers) => {
|
|
|
96
96
|
.option(
|
|
97
97
|
'--hostport <host:port>',
|
|
98
98
|
'host and port to connect to VM',
|
|
99
|
-
'
|
|
99
|
+
'localhost:8000',
|
|
100
100
|
)
|
|
101
101
|
.option('--no-browser', `just display the URL, don't open a browser`)
|
|
102
102
|
.option(
|
package/src/sdk-package-names.js
CHANGED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/* global process setTimeout clearTimeout setInterval clearInterval */
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
6
|
+
import tmp from 'tmp';
|
|
7
|
+
import { makePromiseKit } from '@endo/promise-kit';
|
|
8
|
+
import { request } from 'http';
|
|
9
|
+
|
|
10
|
+
import { spawn } from 'child_process';
|
|
11
|
+
|
|
12
|
+
import { makePspawn } from '../src/helpers.js';
|
|
13
|
+
|
|
14
|
+
const TIMEOUT_SECONDS = 20 * 60;
|
|
15
|
+
|
|
16
|
+
const dirname = new URL('./', import.meta.url).pathname;
|
|
17
|
+
|
|
18
|
+
// To keep in sync with https://agoric.com/documentation/getting-started/
|
|
19
|
+
|
|
20
|
+
// Note that we currently only test:
|
|
21
|
+
// agoric init dapp-foo
|
|
22
|
+
// agoric install
|
|
23
|
+
// agoric start --reset
|
|
24
|
+
// agoric deploy ./contract/deploy.js ./api/deploy.js
|
|
25
|
+
// (For simple-exchange and autoswap, the above also makes and accepts offers)
|
|
26
|
+
// cd ui && yarn install
|
|
27
|
+
// cd ui && yarn start
|
|
28
|
+
|
|
29
|
+
export const gettingStartedWorkflowTest = async (t, options = {}) => {
|
|
30
|
+
const {
|
|
31
|
+
init: initOptions = [],
|
|
32
|
+
install: installOptions = [],
|
|
33
|
+
start: startOptions = [],
|
|
34
|
+
testUnsafePlugins = false,
|
|
35
|
+
} = options;
|
|
36
|
+
// FIXME: Do a search for an unused port or allow specification.
|
|
37
|
+
const PORT = '7999';
|
|
38
|
+
process.env.PORT = PORT;
|
|
39
|
+
|
|
40
|
+
const pspawn = makePspawn({ spawn });
|
|
41
|
+
|
|
42
|
+
// Kill an entire process group.
|
|
43
|
+
const pkill = (cp, signal = 'SIGINT') => process.kill(-cp.pid, signal);
|
|
44
|
+
|
|
45
|
+
function pspawnStdout(...args) {
|
|
46
|
+
const ps = pspawn(...args);
|
|
47
|
+
ps.childProcess.stdout.on('data', chunk => {
|
|
48
|
+
process.stdout.write(chunk);
|
|
49
|
+
});
|
|
50
|
+
// ps.childProcess.unref();
|
|
51
|
+
return ps;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const defaultAgoricCmd = () => {
|
|
55
|
+
// Run all main programs with the '--sdk' flag if we are in agoric-sdk.
|
|
56
|
+
const extraArgs = fs.existsSync(`${dirname}/../../cosmic-swingset`)
|
|
57
|
+
? ['--sdk']
|
|
58
|
+
: [];
|
|
59
|
+
const localCli = path.join(dirname, '..', 'bin', 'agoric');
|
|
60
|
+
return [localCli, ...extraArgs];
|
|
61
|
+
};
|
|
62
|
+
const { AGORIC_CMD = JSON.stringify(defaultAgoricCmd()) } = process.env;
|
|
63
|
+
const agoricCmd = JSON.parse(AGORIC_CMD);
|
|
64
|
+
function myMain(args, opts = {}) {
|
|
65
|
+
// console.error('running agoric-cli', ...extraArgs, ...args);
|
|
66
|
+
return pspawnStdout(agoricCmd[0], [...agoricCmd.slice(1), ...args], {
|
|
67
|
+
stdio: ['ignore', 'pipe', 'inherit'],
|
|
68
|
+
env: { ...process.env, DEBUG: 'agoric' },
|
|
69
|
+
detached: true,
|
|
70
|
+
...opts,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const olddir = process.cwd();
|
|
75
|
+
const { name } = tmp.dirSync({
|
|
76
|
+
unsafeCleanup: true,
|
|
77
|
+
prefix: 'agoric-cli-test-',
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const finalizers = [];
|
|
81
|
+
const runFinalizers = sig => {
|
|
82
|
+
while (finalizers.length) {
|
|
83
|
+
const f = finalizers.shift();
|
|
84
|
+
try {
|
|
85
|
+
f();
|
|
86
|
+
} catch (e) {
|
|
87
|
+
// console.log(e);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (sig) {
|
|
91
|
+
// We're dying due to signal.
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
process.on('SIGINT', runFinalizers);
|
|
98
|
+
process.on('exit', runFinalizers);
|
|
99
|
+
process.chdir(name);
|
|
100
|
+
|
|
101
|
+
// ==============
|
|
102
|
+
// agoric init dapp-foo
|
|
103
|
+
if (process.env.AGORIC_INIT_OPTIONS) {
|
|
104
|
+
const opts = JSON.parse(process.env.AGORIC_INIT_OPTIONS);
|
|
105
|
+
initOptions.push(...opts);
|
|
106
|
+
}
|
|
107
|
+
t.is(
|
|
108
|
+
await myMain([
|
|
109
|
+
'init',
|
|
110
|
+
'--dapp-template',
|
|
111
|
+
'dapp-fungible-faucet',
|
|
112
|
+
...initOptions,
|
|
113
|
+
'dapp-foo',
|
|
114
|
+
]),
|
|
115
|
+
0,
|
|
116
|
+
'init dapp-foo works',
|
|
117
|
+
);
|
|
118
|
+
process.chdir('dapp-foo');
|
|
119
|
+
|
|
120
|
+
// ==============
|
|
121
|
+
// agoric install
|
|
122
|
+
if (process.env.AGORIC_INSTALL_OPTIONS) {
|
|
123
|
+
const opts = JSON.parse(process.env.AGORIC_INSTALL_OPTIONS);
|
|
124
|
+
installOptions.push(...opts);
|
|
125
|
+
}
|
|
126
|
+
t.is(await myMain(['install', ...installOptions]), 0, 'install works');
|
|
127
|
+
|
|
128
|
+
// ==============
|
|
129
|
+
// agoric start --reset
|
|
130
|
+
const startResult = makePromiseKit();
|
|
131
|
+
|
|
132
|
+
if (process.env.AGORIC_START_OPTIONS) {
|
|
133
|
+
const opts = JSON.parse(process.env.AGORIC_START_OPTIONS);
|
|
134
|
+
startOptions.push(...opts);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// TODO: Allow this to work even if the port is already used.
|
|
138
|
+
const startP = myMain(['start', '--reset', ...startOptions]);
|
|
139
|
+
finalizers.push(() => pkill(startP.childProcess, 'SIGINT'));
|
|
140
|
+
|
|
141
|
+
let stdoutStr = '';
|
|
142
|
+
if (startP.childProcess.stdout) {
|
|
143
|
+
startP.childProcess.stdout.on('data', chunk => {
|
|
144
|
+
// console.log('stdout:', chunk.toString());
|
|
145
|
+
stdoutStr += chunk.toString();
|
|
146
|
+
if (stdoutStr.match(/(^|:\s+)swingset running$/m)) {
|
|
147
|
+
startResult.resolve(true);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
startP.childProcess.on('close', code =>
|
|
152
|
+
startResult.reject(Error(`early termination: ${code}`)),
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
const timeout = setTimeout(
|
|
156
|
+
startResult.reject,
|
|
157
|
+
TIMEOUT_SECONDS * 1000,
|
|
158
|
+
'timeout',
|
|
159
|
+
);
|
|
160
|
+
t.is(await startResult.promise, true, `swingset running before timeout`);
|
|
161
|
+
clearTimeout(timeout);
|
|
162
|
+
|
|
163
|
+
const testDeploy = async (deployCmd, opts = {}) => {
|
|
164
|
+
const deployResult = makePromiseKit();
|
|
165
|
+
const deployP = myMain(
|
|
166
|
+
['deploy', `--hostport=127.0.0.1:${PORT}`, ...deployCmd],
|
|
167
|
+
{
|
|
168
|
+
stdio: [opts.stdin ? 'pipe' : 'ignore', 'pipe', 'inherit'],
|
|
169
|
+
},
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
if (opts.stdin) {
|
|
173
|
+
// Write the input to stdin.
|
|
174
|
+
deployP.childProcess.stdin.write(opts.stdin);
|
|
175
|
+
deployP.childProcess.stdin.end();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
finalizers.push(() => pkill(deployP.childProcess, 'SIGINT'));
|
|
179
|
+
const to = setTimeout(
|
|
180
|
+
deployResult.resolve,
|
|
181
|
+
TIMEOUT_SECONDS * 1000,
|
|
182
|
+
'timeout',
|
|
183
|
+
);
|
|
184
|
+
const done = await Promise.race([deployResult.promise, deployP]);
|
|
185
|
+
t.is(done, 0, `deploy ${deployCmd.join(' ')} successful before timeout`);
|
|
186
|
+
clearTimeout(to);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// ==============
|
|
190
|
+
// agoric deploy ./contract/deploy.js ./api/deploy.js
|
|
191
|
+
await testDeploy(['./contract/deploy.js', './api/deploy.js']);
|
|
192
|
+
|
|
193
|
+
for (const [suffix, code] of [
|
|
194
|
+
['/notthere', 404],
|
|
195
|
+
['', 200],
|
|
196
|
+
]) {
|
|
197
|
+
let urlResolve;
|
|
198
|
+
const url = `http://127.0.0.1:${PORT}${suffix}`;
|
|
199
|
+
const urlP = new Promise(resolve => (urlResolve = resolve));
|
|
200
|
+
const urlReq = request(url, res => urlResolve(res.statusCode));
|
|
201
|
+
urlReq.setTimeout(2000);
|
|
202
|
+
urlReq.on('error', err => urlResolve(`Cannot connect to ${url}: ${err}`));
|
|
203
|
+
urlReq.end();
|
|
204
|
+
const urlTimeout = setTimeout(urlResolve, 3000, 'timeout');
|
|
205
|
+
// eslint-disable-next-line no-await-in-loop
|
|
206
|
+
const urlDone = await urlP;
|
|
207
|
+
clearTimeout(urlTimeout);
|
|
208
|
+
t.is(urlDone, code, `${url} gave status ${code}`);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// ==============
|
|
212
|
+
// cd ui && yarn start
|
|
213
|
+
const uiStartP = pspawn(`yarn`, ['start'], {
|
|
214
|
+
stdio: ['ignore', 'inherit', 'inherit'],
|
|
215
|
+
cwd: 'ui',
|
|
216
|
+
env: { ...process.env, PORT: '3000' },
|
|
217
|
+
detached: true,
|
|
218
|
+
});
|
|
219
|
+
finalizers.push(() => pkill(uiStartP.childProcess, 'SIGINT'));
|
|
220
|
+
const uiListening = makePromiseKit();
|
|
221
|
+
let retries = 0;
|
|
222
|
+
const ival = setInterval(() => {
|
|
223
|
+
try {
|
|
224
|
+
const resolve = status => {
|
|
225
|
+
clearInterval(ival);
|
|
226
|
+
uiListening.resolve(status);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
retries += 1;
|
|
230
|
+
if (retries > 8) {
|
|
231
|
+
resolve('too many retries');
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const req = request('http://localhost:3000/', _res => {
|
|
236
|
+
resolve('listening');
|
|
237
|
+
});
|
|
238
|
+
req.setTimeout(2000);
|
|
239
|
+
req.on('error', err => {
|
|
240
|
+
if (err.code !== 'ECONNREFUSED') {
|
|
241
|
+
resolve(`Cannot connect to UI server: ${err}`);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
req.end();
|
|
245
|
+
} catch (e) {
|
|
246
|
+
console.error('cannot make request', e);
|
|
247
|
+
}
|
|
248
|
+
}, 3000);
|
|
249
|
+
t.is(
|
|
250
|
+
await Promise.race([uiStartP, uiListening.promise]),
|
|
251
|
+
'listening',
|
|
252
|
+
`cd ui && yarn start succeeded`,
|
|
253
|
+
);
|
|
254
|
+
clearInterval(ival);
|
|
255
|
+
|
|
256
|
+
// Test that the Node.js `-r esm`-dependent plugin works.
|
|
257
|
+
await (testUnsafePlugins &&
|
|
258
|
+
testDeploy(
|
|
259
|
+
['--allow-unsafe-plugins', `${dirname}/resm-plugin/deploy.js`],
|
|
260
|
+
{ stdin: 'yes\n' },
|
|
261
|
+
));
|
|
262
|
+
|
|
263
|
+
// TODO: When it exists, Test that the Node.js native ESM plugin works.
|
|
264
|
+
} finally {
|
|
265
|
+
runFinalizers();
|
|
266
|
+
process.off('SIGINT', runFinalizers);
|
|
267
|
+
process.chdir(olddir);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* globals setTimeout */
|
|
2
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
|
+
import { E } from '@endo/eventual-send';
|
|
4
|
+
|
|
5
|
+
const PONG_TIMEOUT = 10_000;
|
|
6
|
+
|
|
7
|
+
export default async function deployPlugin(
|
|
8
|
+
homePromise,
|
|
9
|
+
{ installUnsafePlugin },
|
|
10
|
+
) {
|
|
11
|
+
const plugin = await installUnsafePlugin('./src/plugin.js', {});
|
|
12
|
+
const result = await Promise.race([
|
|
13
|
+
E(plugin).ping(),
|
|
14
|
+
new Promise(resolve => setTimeout(resolve, PONG_TIMEOUT, 'timeout')),
|
|
15
|
+
]);
|
|
16
|
+
if (result !== 'pong') {
|
|
17
|
+
throw Error(`ping failed ${result}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const start = 'Started plugin';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @jessie-check
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
4
|
+
import { Far } from '@endo/marshal';
|
|
5
|
+
import { start } from './output.js';
|
|
6
|
+
|
|
7
|
+
export const bootPlugin = () => {
|
|
8
|
+
return Far('plugin', {
|
|
9
|
+
start(_opts) {
|
|
10
|
+
console.log(start);
|
|
11
|
+
return Far('plugin start', {
|
|
12
|
+
async ping() {
|
|
13
|
+
return 'pong';
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
};
|