-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: recover auto-deploy.template.js from run log
We negledted to check this in. Fortunately, we logged it and captured the log in a comment. #48 (comment)
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// @ts-check | ||
import { allValues } from './objectTools.js'; | ||
import { | ||
AmountMath, | ||
installContract, | ||
startContract, | ||
} from './platform-goals/start-contract.js'; | ||
|
||
const { Fail } = assert; | ||
|
||
const contractName = '_CONTRACT_NAME_'; // for pattern match | ||
const IST_UNIT = 1_000_000n; | ||
|
||
/** | ||
* Core eval script to start contract | ||
* | ||
* @param {BootstrapPowers } permittedPowers | ||
* @param {*} config | ||
* | ||
*/ | ||
export const deployContract = async (permittedPowers, config) => { | ||
console.log('core eval for', contractName); | ||
const { | ||
// must be supplied by caller or template-replaced | ||
bundleID = Fail`no bundleID`, | ||
} = config?.options?.[contractName] ?? {}; | ||
|
||
const installation = await installContract(permittedPowers, { | ||
name: contractName, | ||
bundleID, | ||
}); | ||
|
||
await startContract(permittedPowers, { | ||
name: contractName, | ||
startArgs: { | ||
installation, | ||
}, | ||
}); | ||
|
||
console.log(contractName, '(re)started'); | ||
}; | ||
|
||
/** @type { import("@agoric/vats/src/core/lib-boot.js").BootstrapManifestPermit } */ | ||
export const permit = harden({ | ||
consume: { | ||
startUpgradable: true, // to start contract and save adminFacet | ||
}, | ||
installation: { | ||
consume: { [contractName]: true }, | ||
produce: { [contractName]: true }, | ||
}, | ||
instance: { produce: { [contractName]: true } }, | ||
// generate issuer/brand | ||
}); | ||
|
||
export const main = deployContract; |