agoric 0.21.2-dev-ddf71d7.0 → 0.21.2-dev-af5e7ab.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 -19
- package/src/helpers.js +1 -0
- package/tools/getting-started.js +92 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agoric",
|
|
3
|
-
"version": "0.21.2-dev-
|
|
3
|
+
"version": "0.21.2-dev-af5e7ab.0+af5e7ab",
|
|
4
4
|
"description": "Manage the Agoric Javascript smart contract platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main.js",
|
|
@@ -29,28 +29,28 @@
|
|
|
29
29
|
"lint:eslint": "eslint ."
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@agoric/cosmic-swingset": "0.41.4-dev-
|
|
33
|
-
"@agoric/deploy-script-support": "0.10.4-dev-
|
|
32
|
+
"@agoric/cosmic-swingset": "0.41.4-dev-af5e7ab.0+af5e7ab",
|
|
33
|
+
"@agoric/deploy-script-support": "0.10.4-dev-af5e7ab.0+af5e7ab",
|
|
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-dev-
|
|
40
|
-
"@agoric/cache": "0.3.3-dev-
|
|
41
|
-
"@agoric/casting": "0.4.3-dev-
|
|
42
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
43
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
44
|
-
"@agoric/governance": "0.10.4-dev-
|
|
45
|
-
"@agoric/inter-protocol": "0.16.2-dev-
|
|
46
|
-
"@agoric/internal": "0.3.3-dev-
|
|
47
|
-
"@agoric/network": "0.1.1-dev-
|
|
48
|
-
"@agoric/smart-wallet": "0.5.4-dev-
|
|
49
|
-
"@agoric/store": "0.9.3-dev-
|
|
50
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
51
|
-
"@agoric/vats": "0.15.2-dev-
|
|
52
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
53
|
-
"@agoric/zone": "0.2.3-dev-
|
|
39
|
+
"@agoric/access-token": "0.4.22-dev-af5e7ab.0+af5e7ab",
|
|
40
|
+
"@agoric/cache": "0.3.3-dev-af5e7ab.0+af5e7ab",
|
|
41
|
+
"@agoric/casting": "0.4.3-dev-af5e7ab.0+af5e7ab",
|
|
42
|
+
"@agoric/cosmic-proto": "0.4.1-dev-af5e7ab.0+af5e7ab",
|
|
43
|
+
"@agoric/ertp": "0.16.3-dev-af5e7ab.0+af5e7ab",
|
|
44
|
+
"@agoric/governance": "0.10.4-dev-af5e7ab.0+af5e7ab",
|
|
45
|
+
"@agoric/inter-protocol": "0.16.2-dev-af5e7ab.0+af5e7ab",
|
|
46
|
+
"@agoric/internal": "0.3.3-dev-af5e7ab.0+af5e7ab",
|
|
47
|
+
"@agoric/network": "0.1.1-dev-af5e7ab.0+af5e7ab",
|
|
48
|
+
"@agoric/smart-wallet": "0.5.4-dev-af5e7ab.0+af5e7ab",
|
|
49
|
+
"@agoric/store": "0.9.3-dev-af5e7ab.0+af5e7ab",
|
|
50
|
+
"@agoric/swingset-vat": "0.32.3-dev-af5e7ab.0+af5e7ab",
|
|
51
|
+
"@agoric/vats": "0.15.2-dev-af5e7ab.0+af5e7ab",
|
|
52
|
+
"@agoric/zoe": "0.26.3-dev-af5e7ab.0+af5e7ab",
|
|
53
|
+
"@agoric/zone": "0.2.3-dev-af5e7ab.0+af5e7ab",
|
|
54
54
|
"@confio/relayer": "^0.11.3",
|
|
55
55
|
"@cosmjs/crypto": "^0.32.3",
|
|
56
56
|
"@cosmjs/encoding": "^0.32.3",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"typeCoverage": {
|
|
102
102
|
"atLeast": 77.36
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "af5e7ab6b8ddc32de3923995ad2647077abba5b2"
|
|
105
105
|
}
|
package/src/helpers.js
CHANGED
|
@@ -45,6 +45,7 @@ export const makePspawn = ({
|
|
|
45
45
|
* @param {string | [string, string, string]} [param2.stdio] standard IO
|
|
46
46
|
* specification
|
|
47
47
|
* @param {Record<string, string | undefined>} [param2.env] environment
|
|
48
|
+
* @param {boolean} [param2.detached] whether the child process should be detached
|
|
48
49
|
* @returns {Promise<number> & { childProcess: ChildProcess }}} promise for
|
|
49
50
|
* exit status. The return result has a `childProcess` property to obtain
|
|
50
51
|
* control over the running process
|
package/tools/getting-started.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
/* global process setTimeout setInterval clearInterval Buffer */
|
|
2
3
|
|
|
3
4
|
import fs from 'fs';
|
|
4
5
|
import path from 'path';
|
|
@@ -10,7 +11,13 @@ import { spawn } from 'child_process';
|
|
|
10
11
|
|
|
11
12
|
import { makePspawn } from '../src/helpers.js';
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
+
const RETRY_BLOCKHEIGHT_SECONDS = 3;
|
|
15
|
+
const SOCKET_TIMEOUT_SECONDS = 2;
|
|
16
|
+
|
|
17
|
+
// TODO: Set this to `true` when `agoric install $DISTTAG` properly updates the
|
|
18
|
+
// getting-started workflow's dependencies to current `@endo/*` and Agoric SDK
|
|
19
|
+
// from the local registry.
|
|
20
|
+
const AGORIC_INSTALL_DISTTAG = false;
|
|
14
21
|
|
|
15
22
|
const dirname = new URL('./', import.meta.url).pathname;
|
|
16
23
|
|
|
@@ -18,23 +25,59 @@ const dirname = new URL('./', import.meta.url).pathname;
|
|
|
18
25
|
|
|
19
26
|
// Note that we currently only test:
|
|
20
27
|
// agoric init dapp-foo
|
|
21
|
-
// yarn install
|
|
28
|
+
// yarn install (or agoric install $DISTTAG)
|
|
22
29
|
// yarn start:docker
|
|
23
30
|
// yarn start:contract
|
|
24
31
|
// yarn start:ui
|
|
25
32
|
|
|
33
|
+
/**
|
|
34
|
+
* @param {string} url
|
|
35
|
+
* @returns {Promise<bigint>}
|
|
36
|
+
*/
|
|
37
|
+
const getLatestBlockHeight = url =>
|
|
38
|
+
new Promise((resolve, reject) => {
|
|
39
|
+
const req = request(url, res => {
|
|
40
|
+
if (!res) {
|
|
41
|
+
reject(Error('no result'));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const bodyChunks = [];
|
|
45
|
+
res
|
|
46
|
+
.on('data', chunk => bodyChunks.push(chunk))
|
|
47
|
+
.on('end', () => {
|
|
48
|
+
const body = Buffer.concat(bodyChunks).toString('utf8');
|
|
49
|
+
const { statusCode = 0 } = res;
|
|
50
|
+
if (statusCode >= 200 && statusCode < 300) {
|
|
51
|
+
const { result: { sync_info: sync = {} } = {} } = JSON.parse(body);
|
|
52
|
+
if (sync.catching_up === false) {
|
|
53
|
+
resolve(BigInt(sync.latest_block_height));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
reject(Error(`Cannot get block height: ${statusCode} ${body}`));
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
req.setTimeout(SOCKET_TIMEOUT_SECONDS * 1_000);
|
|
61
|
+
req.on('error', reject);
|
|
62
|
+
req.end();
|
|
63
|
+
});
|
|
64
|
+
|
|
26
65
|
export const gettingStartedWorkflowTest = async (t, options = {}) => {
|
|
27
|
-
const { init: initOptions = [] } = options;
|
|
66
|
+
const { init: initOptions = [], install: installOptions = [] } = options;
|
|
28
67
|
const pspawn = makePspawn({ spawn });
|
|
29
68
|
|
|
30
69
|
// Kill an entire process group.
|
|
31
70
|
const pkill = (cp, signal = 'SIGINT') => process.kill(-cp.pid, signal);
|
|
32
71
|
|
|
72
|
+
/** @param {Parameters<typeof pspawn>} args */
|
|
33
73
|
function pspawnStdout(...args) {
|
|
34
74
|
const ps = pspawn(...args);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
75
|
+
const { stdout } = ps.childProcess;
|
|
76
|
+
if (stdout) {
|
|
77
|
+
stdout.on('data', chunk => {
|
|
78
|
+
process.stdout.write(chunk);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
38
81
|
// ps.childProcess.unref();
|
|
39
82
|
return ps;
|
|
40
83
|
}
|
|
@@ -107,17 +150,51 @@ export const gettingStartedWorkflowTest = async (t, options = {}) => {
|
|
|
107
150
|
);
|
|
108
151
|
process.chdir('dapp-foo');
|
|
109
152
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
153
|
+
if (AGORIC_INSTALL_DISTTAG && process.env.AGORIC_INSTALL_OPTIONS) {
|
|
154
|
+
// ==============
|
|
155
|
+
// agoric install $DISTTAG
|
|
156
|
+
const opts = JSON.parse(process.env.AGORIC_INSTALL_OPTIONS);
|
|
157
|
+
installOptions.push(...opts);
|
|
158
|
+
t.is(
|
|
159
|
+
await myMain(['install', ...installOptions]),
|
|
160
|
+
0,
|
|
161
|
+
'agoric install works',
|
|
162
|
+
);
|
|
163
|
+
} else {
|
|
164
|
+
// ==============
|
|
165
|
+
// yarn install
|
|
166
|
+
t.is(await yarn(['install', ...installOptions]), 0, 'yarn install works');
|
|
167
|
+
}
|
|
113
168
|
|
|
114
169
|
// ==============
|
|
115
170
|
// yarn start:docker
|
|
116
171
|
t.is(await yarn(['start:docker']), 0, 'yarn start:docker works');
|
|
117
172
|
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
|
|
173
|
+
// ==============
|
|
174
|
+
// wait for the chain to start
|
|
175
|
+
let lastKnownBlockHeight = 0n;
|
|
176
|
+
for (;;) {
|
|
177
|
+
try {
|
|
178
|
+
const currentHeight = await getLatestBlockHeight(
|
|
179
|
+
'http://localhost:26657/status',
|
|
180
|
+
);
|
|
181
|
+
if (currentHeight > lastKnownBlockHeight) {
|
|
182
|
+
const earlierHeight = lastKnownBlockHeight;
|
|
183
|
+
lastKnownBlockHeight = currentHeight;
|
|
184
|
+
if (earlierHeight > 0n && currentHeight > earlierHeight) {
|
|
185
|
+
// We've had at least one block produced.
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
} catch (e) {
|
|
190
|
+
console.error((e && e.message) || e);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Wait a bit and try again.
|
|
194
|
+
await new Promise(resolve =>
|
|
195
|
+
setTimeout(resolve, RETRY_BLOCKHEIGHT_SECONDS * 1_000),
|
|
196
|
+
);
|
|
197
|
+
}
|
|
121
198
|
|
|
122
199
|
// ==============
|
|
123
200
|
// yarn start:contract
|
|
@@ -145,9 +222,9 @@ export const gettingStartedWorkflowTest = async (t, options = {}) => {
|
|
|
145
222
|
const req = request('http://localhost:5173/', _res => {
|
|
146
223
|
resolve('listening');
|
|
147
224
|
});
|
|
148
|
-
req.setTimeout(
|
|
225
|
+
req.setTimeout(SOCKET_TIMEOUT_SECONDS * 1_000);
|
|
149
226
|
req.on('error', err => {
|
|
150
|
-
if (err.code !== 'ECONNREFUSED') {
|
|
227
|
+
if (!('code' in err) || err.code !== 'ECONNREFUSED') {
|
|
151
228
|
resolve(`Cannot connect to UI server: ${err}`);
|
|
152
229
|
}
|
|
153
230
|
});
|