Skip to content

Commit

Permalink
chore(bootstrap-exports): implement core-eval to replace provisioning…
Browse files Browse the repository at this point in the history
…Handler

Refs: #10425
  • Loading branch information
anilhelvaci committed Nov 19, 2024
1 parent 664dbe8 commit ad90b6e
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/builders/scripts/vats/replace-provisioningHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { makeHelpers } from '@agoric/deploy-script-support';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async () =>
harden({
sourceSpec: '@agoric/vats/src/proposals/durable-provisioningHandler-proposal.js',
getManifestCall: [
'getConvertProvisioningHandlerDurable',
],
});

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('replace-provisioningHandler', defaultProposalBuilder);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { E } from '@endo/far';
import { prepareProvisionBridgeHandler } from '../lib-provisioning.js';

const convertProvisioningHandlerDurable = async ({
consume: {
provisioning: provisioningP,
provisionBridgeManager: provisionBridgeManagerP,
provisionWalletBridgeManager: provisionWalletBridgeManagerP,
powerStore: powerStoreP,
},
}) => {
const [
provisioning,
provisionBridgeManager,
provisionWalletBridgeManager,
powerStore,
] = await Promise.all([
provisioningP,
provisionBridgeManagerP,
provisionWalletBridgeManagerP,
powerStoreP,
]);
if (!provisionBridgeManager || !provisionWalletBridgeManager) {
return;
}

// Using powerStore as the durable map here
const makeProvisionBridgeHandler = prepareProvisionBridgeHandler(powerStore);
const provisioningHandler = makeProvisionBridgeHandler(
provisioning,
provisionWalletBridgeManager,
);

const handler = provisioning
? provisioningHandler
: provisionWalletBridgeManager;
await E(provisionBridgeManager).setHandler(handler);
};

export const getConvertProvisioningHandlerDurable = _powers => ({
manifest: {
[convertProvisioningHandlerDurable.name]: {
consume: {
provisioning: true,
bridgeManager: 'bridge',
provisionBridgeManager: 'bridge',
provisionWalletBridgeManager: 'bridge',
powerStore: 'bridge',
},
},
},
});

0 comments on commit ad90b6e

Please sign in to comment.