diff --git a/packages/deploy-script-support/src/helpers.js b/packages/deploy-script-support/src/helpers.js index 3581ba88d7e8..375afe22bffe 100644 --- a/packages/deploy-script-support/src/helpers.js +++ b/packages/deploy-script-support/src/helpers.js @@ -23,7 +23,7 @@ const ZOE_INVITE_PURSE_PETNAME = 'Default Zoe invite purse'; export const makeHelpers = async (homePromise, endowments) => { const { zoe, wallet, scratch, board } = E.get(homePromise); - const { lookup } = endowments; + const { lookup, publishBundle, pathResolve } = endowments; const walletAdmin = E(wallet).getAdminFacet(); const installationManager = E(walletAdmin).getInstallationManager(); @@ -36,7 +36,14 @@ export const makeHelpers = async (homePromise, endowments) => { // Create the methods - const install = makeInstall(bundleSource, zoe, installationManager, board); + const install = makeInstall( + bundleSource, + zoe, + installationManager, + board, + publishBundle, + pathResolve, + ); const startInstance = makeStartInstance( issuerManager, diff --git a/packages/deploy-script-support/src/install.js b/packages/deploy-script-support/src/install.js index 38cafeaaa17e..81ddd9536e3a 100644 --- a/packages/deploy-script-support/src/install.js +++ b/packages/deploy-script-support/src/install.js @@ -10,22 +10,49 @@ import { E } from '@endo/far'; * @param {ERef} zoe * @param {ERef} installationManager * @param {ERef} board + * @param {(bundle: any) => any} [publishBundle] + * @param {(path: string) => string} [pathResolve] * @returns {InstallSaveAndPublish} */ -export const makeInstall = (bundleSource, zoe, installationManager, board) => { +export const makeInstall = ( + bundleSource, + zoe, + installationManager, + board, + publishBundle, + pathResolve, +) => { /** @type {InstallSaveAndPublish} */ - const install = async (resolvedPath, contractPetname) => { - console.log(`- Installing Contract Name: ${contractPetname}`); - + const install = async (contractPath, contractPetname) => { + const resolvedPath = pathResolve ? pathResolve(contractPath) : contractPath; const bundle = await bundleSource(resolvedPath); - const installation = await E(zoe).install(bundle); - + console.log(`- Publishing Contract Name: ${contractPetname}`); + const hashedBundle = await (publishBundle ? publishBundle(bundle) : bundle); + console.log(`- Installing Contract Name: ${contractPetname}`); + const installation = await E(zoe).install(hashedBundle); + console.log( + `- Adding contract to installation manager: ${contractPetname}`, + ); await E(installationManager).add(contractPetname, installation); - console.log(`- Installed Contract Name: ${contractPetname}`); - + // Let's share this installation with other people, so that + // they can run our contract code by making a contract + // instance (see the api deploy script in this repo to see an + // example of how to use the installation to make a new contract + // instance.) + // To share the installation, we're going to put it in the + // board. The board is a shared, on-chain object that maps + // strings to objects. const id = await E(board).getId(installation); - return { installation, id }; + + console.log('- SUCCESS! contract code installed on Zoe'); + console.log(`-- Contract Name: ${contractPetname}`); + console.log(`-- Installation Board Id: ${id}`); + + return { + installation, + id, + }; }; return install; };