@agoric/deploy-script-support 0.10.4-dev-3dacdc3.0.3dacdc3 → 0.10.4-dev-3189429.0.3189429

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/deploy-script-support",
3
- "version": "0.10.4-dev-3dacdc3.0.3dacdc3",
3
+ "version": "0.10.4-dev-3189429.0.3189429",
4
4
  "description": "Helpers and other support for writing deploy scripts",
5
5
  "type": "module",
6
6
  "main": "src/helpers.js",
@@ -34,19 +34,19 @@
34
34
  },
35
35
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
36
36
  "dependencies": {
37
- "@agoric/client-utils": "0.1.1-dev-3dacdc3.0.3dacdc3",
38
- "@agoric/ertp": "0.16.3-dev-3dacdc3.0.3dacdc3",
39
- "@agoric/import-manager": "0.3.12-dev-3dacdc3.0.3dacdc3",
40
- "@agoric/internal": "0.3.3-dev-3dacdc3.0.3dacdc3",
41
- "@agoric/notifier": "0.6.3-dev-3dacdc3.0.3dacdc3",
42
- "@agoric/orchestration": "0.1.1-dev-3dacdc3.0.3dacdc3",
43
- "@agoric/pola-io": "0.1.1-dev-3dacdc3.0.3dacdc3",
44
- "@agoric/portfolio-api": "0.1.1-dev-3dacdc3.0.3dacdc3",
45
- "@agoric/smart-wallet": "0.5.4-dev-3dacdc3.0.3dacdc3",
46
- "@agoric/store": "0.9.3-dev-3dacdc3.0.3dacdc3",
47
- "@agoric/time": "0.3.3-dev-3dacdc3.0.3dacdc3",
48
- "@agoric/zoe": "0.26.3-dev-3dacdc3.0.3dacdc3",
49
- "@agoric/zone": "0.2.3-dev-3dacdc3.0.3dacdc3",
37
+ "@agoric/client-utils": "0.1.1-dev-3189429.0.3189429",
38
+ "@agoric/ertp": "0.16.3-dev-3189429.0.3189429",
39
+ "@agoric/import-manager": "0.3.12-dev-3189429.0.3189429",
40
+ "@agoric/internal": "0.3.3-dev-3189429.0.3189429",
41
+ "@agoric/notifier": "0.6.3-dev-3189429.0.3189429",
42
+ "@agoric/orchestration": "0.1.1-dev-3189429.0.3189429",
43
+ "@agoric/pola-io": "0.1.1-dev-3189429.0.3189429",
44
+ "@agoric/portfolio-api": "0.1.1-dev-3189429.0.3189429",
45
+ "@agoric/smart-wallet": "0.5.4-dev-3189429.0.3189429",
46
+ "@agoric/store": "0.9.3-dev-3189429.0.3189429",
47
+ "@agoric/time": "0.3.3-dev-3189429.0.3189429",
48
+ "@agoric/zoe": "0.26.3-dev-3189429.0.3189429",
49
+ "@agoric/zone": "0.2.3-dev-3189429.0.3189429",
50
50
  "@endo/base64": "^1.0.12",
51
51
  "@endo/bundle-source": "^4.1.2",
52
52
  "@endo/errors": "^1.2.13",
@@ -60,7 +60,7 @@
60
60
  "@endo/zip": "^1.0.11"
61
61
  },
62
62
  "devDependencies": {
63
- "@agoric/vats": "0.15.2-dev-3dacdc3.0.3dacdc3",
63
+ "@agoric/vats": "0.15.2-dev-3189429.0.3189429",
64
64
  "@endo/init": "^1.1.12",
65
65
  "ava": "^6.4.1",
66
66
  "import-meta-resolve": "^4.1.0"
@@ -83,5 +83,5 @@
83
83
  "typeCoverage": {
84
84
  "atLeast": 84.46
85
85
  },
86
- "gitHead": "3dacdc33b578ee52258e5771192bf8e57beb603b"
86
+ "gitHead": "3189429dea5ba7004a95cf73d8b6203b48f0b2e9"
87
87
  }
@@ -1,4 +1,5 @@
1
1
  import { Fail } from '@endo/errors';
2
+ import { writeFileAtomic } from '@agoric/internal/src/build-cache.js';
2
3
 
3
4
  /**
4
5
  * @import {promises} from 'fs';
@@ -30,11 +31,13 @@ export const makeCacheAndGetBundleSpec =
30
31
  if (e.code !== 'ENOENT') {
31
32
  throw e;
32
33
  }
33
- const tmpFile = `${cacheFile}.${pid}.${now()}.${Math.random().toString(16).slice(2)}.tmp`;
34
- await fs.writeFile(tmpFile, JSON.stringify(bundle, null, 2), {
35
- flag: 'wx',
34
+ await writeFileAtomic({
35
+ fs,
36
+ filePath: cacheFile,
37
+ data: JSON.stringify(bundle, null, 2),
38
+ now,
39
+ pid,
36
40
  });
37
- await fs.rename(tmpFile, cacheFile);
38
41
  }
39
42
  return harden({ bundleID, fileName: cacheFile });
40
43
  };
@@ -5,8 +5,10 @@ export {};
5
5
  * @import {NameHub} from '@agoric/vats';
6
6
  * @import {ZoeService} from '@agoric/zoe';
7
7
  * @import {BundleSource} from '@endo/bundle-source';
8
+ * @import {writeFile as WriteFile} from 'node:fs/promises';
8
9
  * @import {ERef} from '@agoric/vow';
9
10
  * @import {ScratchPad} from '@agoric/internal/src/scratch.js';
11
+ * @import {CoreEvalMaterialRecord} from './writeCoreEvalParts.js';
10
12
  * @import {Bank} from '@agoric/vats/src/vat-bank.js';
11
13
  * @import {Board} from '@agoric/vats';
12
14
  * @import {NameAdmin} from '@agoric/vats';
@@ -64,10 +66,13 @@ export {};
64
66
  * bundleSource: BundleSource,
65
67
  * cacheDir: string,
66
68
  * lookup: (...path: string[]) => unknown,
69
+ * log?: typeof console.log,
67
70
  * now: () => number,
71
+ * onWriteCoreEval?: (record: CoreEvalMaterialRecord) => void | Promise<void>,
68
72
  * pathResolve: (...path: string[]) => string,
69
73
  * publishBundle: PublishBundleRef,
70
74
  * scriptArgs?: string[],
75
+ * writeFile?: WriteFile,
71
76
  * }} DeployScriptEndownments
72
77
  */
73
78
 
package/src/helpers.js CHANGED
@@ -70,6 +70,9 @@ export const makeHelpers = async (homePromise, endowments) => {
70
70
  publishBundle,
71
71
  pathResolve,
72
72
  cacheDir = pathResolve(os.homedir(), '.agoric/cache'),
73
+ onWriteCoreEval,
74
+ writeFile,
75
+ log,
73
76
  } = endowments;
74
77
 
75
78
  // Internal-to-this-function lazy dependencies.
@@ -156,6 +159,9 @@ export const makeHelpers = async (homePromise, endowments) => {
156
159
  return makeWriteCoreEval(homePromise, endowments, {
157
160
  getBundleSpec: deps.cacheAndGetBundleSpec,
158
161
  getBundlerMaker: helpers.getBundlerMaker,
162
+ ...(onWriteCoreEval && { onWriteCoreEval }),
163
+ ...(log && { log }),
164
+ ...(writeFile && { writeFile }),
159
165
  });
160
166
  },
161
167
  /** @deprecated use writeCoreEval */
@@ -163,6 +169,9 @@ export const makeHelpers = async (homePromise, endowments) => {
163
169
  return makeWriteCoreEval(homePromise, endowments, {
164
170
  getBundleSpec: deps.cacheAndGetBundleSpec,
165
171
  getBundlerMaker: helpers.getBundlerMaker,
172
+ ...(onWriteCoreEval && { onWriteCoreEval }),
173
+ ...(log && { log }),
174
+ ...(writeFile && { writeFile }),
166
175
  });
167
176
  },
168
177
  });
@@ -22,7 +22,14 @@ import {
22
22
  * @property {string} name
23
23
  * @property {string} permit
24
24
  * @property {string} script
25
- * @property {{entrypoint: string, bundleID: string, fileName: string}[]} bundles
25
+ * @property {{entrypoint: string, bundleID?: string, bundleName?: string, fileName?: string}[]} bundles
26
+ */
27
+ /**
28
+ * @typedef {{
29
+ * plan: CoreEvalPlan,
30
+ * eval: { json_permits: string, js_code: string },
31
+ * bundles: { entrypoint: string, bundleID?: string, bundleName?: string, fileName?: string, bundle: BundleSourceResult<'endoZipBase64'> }[],
32
+ * }} CoreEvalMaterialRecord
26
33
  */
27
34
 
28
35
  /**
@@ -45,6 +52,7 @@ import {
45
52
  * getBundlerMaker: () => Promise<BundleMaker>,
46
53
  * getBundleSpec: (bundle: Promise<BundleSourceResult<'endoZipBase64'>>, getBundle: () => Bundler, opts?: any) => Promise<ManifestBundleRef>,
47
54
  * log?: typeof console.log,
55
+ * onWriteCoreEval?: (record: CoreEvalMaterialRecord) => void | Promise<void>,
48
56
  * writeFile?: typeof fs.promises.writeFile
49
57
  * }} io
50
58
  * @returns {WriteCoreEval}
@@ -56,6 +64,7 @@ export const makeWriteCoreEval = (
56
64
  getBundlerMaker,
57
65
  getBundleSpec,
58
66
  log = console.log,
67
+ onWriteCoreEval = () => {},
59
68
  writeFile = fs.promises.writeFile,
60
69
  },
61
70
  ) => {
@@ -120,7 +129,8 @@ export const makeWriteCoreEval = (
120
129
  return ns.default;
121
130
  };
122
131
 
123
- const bundles = [];
132
+ /** @type {CoreEvalMaterialRecord['bundles']} */
133
+ const bundleRecords = [];
124
134
 
125
135
  /**
126
136
  * Install an entrypoint.
@@ -136,9 +146,13 @@ export const makeWriteCoreEval = (
136
146
  // Serialise the installations.
137
147
  mutex = E.when(mutex, async () => {
138
148
  // console.log('installing', { filePrefix, entrypoint, bundlePath });
139
- const spec = await getBundleSpec(bundle, getBundler, opts);
140
- bundles.push({
149
+ const [spec, builtBundle] = await Promise.all([
150
+ getBundleSpec(bundle, getBundler, opts),
151
+ bundle,
152
+ ]);
153
+ bundleRecords.push({
141
154
  entrypoint,
155
+ bundle: builtBundle,
142
156
  ...spec,
143
157
  });
144
158
  return spec;
@@ -205,13 +219,21 @@ behavior;
205
219
  name: filePrefix,
206
220
  script: codeFile,
207
221
  permit: permitFile,
208
- bundles,
222
+ bundles: bundleRecords.map(({ bundle: _bundle, ...spec }) => spec),
209
223
  };
210
224
 
211
225
  await writeFile(
212
226
  `${filePrefix}-plan.json`,
213
227
  `${JSON.stringify(plan, null, 2)}\n`,
214
228
  );
229
+ await onWriteCoreEval({
230
+ plan,
231
+ eval: {
232
+ json_permits: JSON.stringify(evalPermits, null, 2),
233
+ js_code: trimmed,
234
+ },
235
+ bundles: bundleRecords,
236
+ });
215
237
 
216
238
  log(`\
217
239
  You can now run a governance submission command like: