-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(orchestration): add init-stakeOsmo.js to support .query tests
- a better approach seems to be refactoring start-stakeAtom.js to start-stakeIca.js with parameters. buildProposal doesn't seem to accept options so punted for now - TODO: register OSMO in bank
- Loading branch information
1 parent
b83745f
commit b6df6c2
Showing
11 changed files
with
196 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */ | ||
export const defaultProposalBuilder = async ({ publishRef, install }) => { | ||
return harden({ | ||
sourceSpec: '@agoric/orchestration/src/proposals/start-stakeOsmo.js', | ||
getManifestCall: [ | ||
'getManifestForStakeOsmo', | ||
{ | ||
installKeys: { | ||
stakeIca: publishRef( | ||
install('@agoric/orchestration/src/examples/stakeIca.contract.js'), | ||
), | ||
}, | ||
}, | ||
], | ||
}); | ||
}; | ||
|
||
export default async (homeP, endowments) => { | ||
const { writeCoreEval } = await makeHelpers(homeP, endowments); | ||
await writeCoreEval('start-stakeOsmo', defaultProposalBuilder); | ||
}; |
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
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
109 changes: 109 additions & 0 deletions
109
packages/orchestration/src/proposals/start-stakeOsmo.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,109 @@ | ||
import { makeTracer } from '@agoric/internal'; | ||
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js'; | ||
import { E } from '@endo/far'; | ||
import { makeChainHub } from '../utils/chainHub.js'; | ||
|
||
/** | ||
* @import {IBCConnectionID} from '@agoric/vats'; | ||
* @import {StakeIcaSF} from '../examples/stakeIca.contract'; | ||
*/ | ||
|
||
const trace = makeTracer('StartStakeOsmo', true); | ||
|
||
/** | ||
* @param {BootstrapPowers & { | ||
* installation: { | ||
* consume: { | ||
* stakeIca: Installation< | ||
* import('../examples/stakeIca.contract.js').start | ||
* >; | ||
* }; | ||
* }; | ||
* }} powers | ||
*/ | ||
export const startStakeOsmo = async ({ | ||
consume: { | ||
agoricNames, | ||
board, | ||
chainStorage, | ||
chainTimerService, | ||
orchestration, | ||
startUpgradable, | ||
}, | ||
installation: { | ||
consume: { stakeIca }, | ||
}, | ||
instance: { | ||
// @ts-expect-error stakeOsmo not typed | ||
produce: { stakeOsmo: produceInstance }, | ||
}, | ||
}) => { | ||
const VSTORAGE_PATH = 'stakeOsmo'; | ||
trace('startStakeOsmo'); | ||
await null; | ||
|
||
const storageNode = await makeStorageNodeChild(chainStorage, VSTORAGE_PATH); | ||
const marshaller = await E(board).getPublishingMarshaller(); | ||
|
||
const chainHub = makeChainHub(await agoricNames); | ||
|
||
const agoric = await chainHub.getChainInfo('agoric'); | ||
const osmosis = await chainHub.getChainInfo('osmosis'); | ||
const connectionInfo = await chainHub.getConnectionInfo( | ||
agoric.chainId, | ||
osmosis.chainId, | ||
); | ||
|
||
/** @type {StartUpgradableOpts<StakeIcaSF>} */ | ||
const startOpts = { | ||
label: 'stakeOsmo', | ||
installation: stakeIca, | ||
terms: { | ||
chainId: osmosis.chainId, | ||
hostConnectionId: connectionInfo.id, | ||
controllerConnectionId: connectionInfo.counterparty.connection_id, | ||
bondDenom: osmosis.stakingTokens[0].denom, | ||
icqEnabled: osmosis.icqEnabled, | ||
}, | ||
privateArgs: { | ||
orchestration: await orchestration, | ||
storageNode, | ||
marshaller, | ||
timer: await chainTimerService, | ||
}, | ||
}; | ||
|
||
const { instance } = await E(startUpgradable)(startOpts); | ||
produceInstance.resolve(instance); | ||
}; | ||
harden(startStakeOsmo); | ||
|
||
export const getManifestForStakeOsmo = ( | ||
{ restoreRef }, | ||
{ installKeys, ...options }, | ||
) => { | ||
return { | ||
manifest: { | ||
[startStakeOsmo.name]: { | ||
consume: { | ||
agoricNames: true, | ||
board: true, | ||
chainStorage: true, | ||
chainTimerService: true, | ||
orchestration: true, | ||
startUpgradable: true, | ||
}, | ||
installation: { | ||
consume: { stakeIca: true }, | ||
}, | ||
instance: { | ||
produce: { stakeOsmo: true }, | ||
}, | ||
}, | ||
}, | ||
installations: { | ||
stakeIca: restoreRef(installKeys.stakeIca), | ||
}, | ||
options, | ||
}; | ||
}; |
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
Oops, something went wrong.