-
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.
feat: smart wallet can upgrade to use promiseWatcher
upgrade-wallet-factory-proposal upgrades to the new walletFactory in agoric-3-proposals.
- Loading branch information
1 parent
c378c3e
commit 9c8ec51
Showing
5 changed files
with
96 additions
and
149 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
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
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
128 changes: 0 additions & 128 deletions
128
packages/smart-wallet/src/proposals/upgrade-walletFactory-proposal.js
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
packages/vats/src/proposals/upgrade-wallet-factory-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,63 @@ | ||
import { E } from '@endo/far'; | ||
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js'; | ||
|
||
/** | ||
* @param {BootstrapPowers & { | ||
* consume: { | ||
* walletFactoryStartResult: WalletFactoryStartResult; | ||
* provisionPoolStartResult: any; // startPSM has a TODO for this | ||
* chainStorage: ChainStorage; | ||
* walletBridgeManager: WalletBridgeManager; | ||
* }; | ||
* }} powers | ||
* @param {object} options | ||
* @param {{ zoeRef: VatSourceRef; zcfRef: VatSourceRef }} options.options | ||
*/ | ||
export const upgradeWalletFactory = async ( | ||
{ | ||
consume: { | ||
walletFactoryStartResult, | ||
provisionPoolStartResult, | ||
chainStorage, | ||
walletBridgeManager: walletBridgeManagerP, | ||
}, | ||
}, | ||
options, | ||
) => { | ||
const WALLET_STORAGE_PATH_SEGMENT = 'wallet'; | ||
|
||
const { walletRef } = options.options; | ||
|
||
const [walletBridgeManager, walletStorageNode, ppFacets] = await Promise.all([ | ||
walletBridgeManagerP, | ||
makeStorageNodeChild(chainStorage, WALLET_STORAGE_PATH_SEGMENT), | ||
provisionPoolStartResult, | ||
]); | ||
|
||
const privateArgs = { | ||
storageNode: walletStorageNode, | ||
walletBridgeManager, | ||
walletReviver: E(ppFacets.creatorFacet).getWalletReviver(), | ||
}; | ||
|
||
const { adminFacet } = await walletFactoryStartResult; | ||
|
||
await E(adminFacet).upgradeContract(walletRef.bundleID, privateArgs); | ||
|
||
// XXX this console.log doesn't print. Any added above will. Seems strange. | ||
// console.log(`upgrade WF AFTER`); | ||
}; | ||
|
||
export const getManifestForUpgradeWallet = (_powers, { walletRef }) => ({ | ||
manifest: { | ||
[upgradeWalletFactory.name]: { | ||
consume: { | ||
walletFactoryStartResult: 'walletFactoryStartResult', | ||
provisionPoolStartResult: 'provisionPoolStartResult', | ||
chainStorage: 'chainStorage', | ||
walletBridgeManager: 'walletBridgeManager', | ||
}, | ||
}, | ||
}, | ||
options: { walletRef }, | ||
}); |