Skip to content

Commit

Permalink
fix: upgrade for breaking changes in @endo/bundle-source
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig authored and mhofman committed Jan 13, 2024
1 parent e6a7d87 commit 88009cc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
19 changes: 15 additions & 4 deletions packages/SwingSet/tools/bundleTool.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { makeNodeBundleCache as wrappedMaker } from '@endo/bundle-source/cache.js';
import { randomInt } from 'crypto';
import styles from 'ansi-styles'; // less authority than 'chalk'

export const makeNodeBundleCache = async (dest, options, loadModule) => {
const getUniquishNumber = () => {
return randomInt(2 ** 32);
};

/** @type {typeof wrappedMaker} */
export const makeNodeBundleCache = async (dest, options, loadModule, pid) => {
const log = (...args) => {
const flattened = args.map(arg =>
// Don't print stack traces.
Expand All @@ -15,7 +21,7 @@ export const makeNodeBundleCache = async (dest, options, loadModule) => {
styles.dim.close,
);
};
return wrappedMaker(dest, { log, ...options }, loadModule);
return wrappedMaker(dest, { log, ...options }, loadModule, pid);
};

/** @type {Map<string, ReturnType<typeof makeNodeBundleCache>>} */
Expand All @@ -33,12 +39,17 @@ export const provideBundleCache = (dest, options, loadModule) => {
const uniqueDest = [dest, options.format, options.dev].join('-');
let bundleCache = providedCaches.get(uniqueDest);
if (!bundleCache) {
bundleCache = makeNodeBundleCache(dest, options, loadModule);
bundleCache = makeNodeBundleCache(
dest,
options,
loadModule,
getUniquishNumber(),
);
providedCaches.set(uniqueDest, bundleCache);
}
return bundleCache;
};
harden(provideBundleCache);

export const unsafeMakeBundleCache = dest =>
makeNodeBundleCache(dest, {}, s => import(s));
makeNodeBundleCache(dest, {}, s => import(s), getUniquishNumber());
2 changes: 0 additions & 2 deletions packages/deploy-script-support/exported.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import '@endo/bundle-source/exported.js';

import './src/externalTypes.js';
11 changes: 1 addition & 10 deletions packages/deploy-script-support/src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,9 @@ import { E } from '@endo/far';

/** @typedef {import('@agoric/deploy-script-support/src/externalTypes').Petname} Petname */

/**
* @callback BundleSource
* @param {string} startFilename - the filepath to start the bundling from
* @param {ModuleFormat | BundleOptions} [moduleFormat]
* @param {object} [powers]
* @param {ReadFn} [powers.read]
* @param {CanonicalFn} [powers.canonical]
*/

// XXX board is Board but specifying that leads to type errors with imports which aren't worth fixing right now
/**
* @param {BundleSource} bundleSource
* @param {typeof import('@endo/bundle-source')['default']} bundleSource
* @param {ERef<ZoeService>} zoe
* @param {ERef<import('./startInstance.js').InstallationManager>} installationManager
* @param {ERef<any>} board
Expand Down
6 changes: 4 additions & 2 deletions packages/smart-wallet/test/test-addAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,11 @@ test.serial('trading in non-vbank asset: game real-estate NFTs', async t => {
const { consume, simpleProvideWallet, sendToBridge } = t.context;

const bundles = {
game: await importSpec('./gameAssetContract.js').then(bundleSource),
game: await importSpec('./gameAssetContract.js').then(spec =>
bundleSource(spec),
),
centralSupply: await importSpec('@agoric/vats/src/centralSupply.js').then(
bundleSource,
spec => bundleSource(spec),
),
};

Expand Down

0 comments on commit 88009cc

Please sign in to comment.