-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(bootstrap-exports): implement core-eval to replace provisioning…
…Handler Refs: #10425
- Loading branch information
1 parent
664dbe8
commit ad90b6e
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
packages/builders/scripts/vats/replace-provisioningHandler.js
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,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); | ||
}; |
52 changes: 52 additions & 0 deletions
52
packages/vats/src/proposals/durable-provisioningHandler-proposal.js
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,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', | ||
}, | ||
}, | ||
}, | ||
}); |