Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import { makeDefaultExo } from '@metamask/kernel-utils/exo';
/**
* Build function for testing subcluster functionality.
*
* @param _vatPowers - Special powers granted to this vat.
* @param parameters - Initialization parameters from the vat's config object.
* @param parameters.name - The name of the vat.
* @param parameters.subcluster - The subcluster for the vat.
* @param _baggage - Root of vat's persistent state (not used here).
* @returns The root object for the new vat.
*/
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export function buildRootObject(
_vatPowers: unknown,
parameters: { name?: string; subcluster?: string } = {},
_baggage: unknown = null,
) {
const name = parameters?.name ?? 'anonymous';
const subcluster = parameters?.subcluster ?? 'default';
/**
* Print a message to the log.
*
* @param message - The message to print.
*/
function log(message: string): void {
// eslint-disable-next-line no-console
console.log(`${name}: ${message}`);
}
log(`buildRootObject`);
log(`configuration parameters: ${JSON.stringify(parameters)}`);
return makeDefaultExo('root', {
async bootstrap() {
log(`bootstrap() in ${subcluster}`);
return 'bootstrap complete';
},
});
}
|