Skip to content

Commit

Permalink
feat(orchestration): orchestrator is resumable
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Jun 27, 2024
1 parent 27c9395 commit b09aaf9
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions packages/orchestration/src/exos/orchestrator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @file ChainAccount exo */
import { AmountShape } from '@agoric/ertp';
import { makeTracer } from '@agoric/internal';
import { Shape as NetworkShape } from '@agoric/network';
import { E } from '@endo/far';
import { M } from '@endo/patterns';
import {
Expand All @@ -25,16 +26,16 @@ import {
* @import {MakeLocalOrchestrationAccountKit} from './local-orchestration-account.js';
* @import {MakeLocalChainFacade} from './local-chain-facade.js';
* @import {MakeRemoteChainFacade} from './remote-chain-facade.js';
* @import {Chain, ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, Orchestrator} from '../types.js';
* @import {Chain, ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, Orchestrator, PromiseToVow} from '../types.js';
*/

const { Fail } = assert;
const trace = makeTracer('Orchestrator');

/** @see {Orchestrator} */
export const OrchestratorI = M.interface('Orchestrator', {
getChain: M.callWhen(M.string()).returns(ChainInfoShape),
makeLocalAccount: M.callWhen().returns(LocalChainAccountShape),
getChain: M.call(M.string()).returns(NetworkShape.Vow$(ChainInfoShape)),
makeLocalAccount: M.call().returns(NetworkShape.Vow$(LocalChainAccountShape)),
getBrandInfo: M.call(DenomShape).returns(BrandInfoShape),
asAmount: M.call(DenomAmountShape).returns(AmountShape),
});
Expand Down Expand Up @@ -62,7 +63,7 @@ export const prepareOrchestratorKit = (
localchain,
makeLocalChainFacade,
makeRemoteChainFacade,
vowTools: { watch, when },
vowTools: { watch },
},
) =>
zone.exoClassKit(
Expand Down Expand Up @@ -111,27 +112,23 @@ export const prepareOrchestratorKit = (
},
},
orchestrator: {
/** @type {Orchestrator['getChain']} */
/** @type {PromiseToVow<Orchestrator['getChain']>} */
getChain(name) {
if (name === 'agoric') {
// XXX when() until membrane
return when(
watch(
chainHub.getChainInfo('agoric'),
this.facets.makeLocalChainFacadeWatcher,
),
// @ts-expect-error Type 'Vow<Voidless>' is not assignable to type 'Vow<Chain<any>>'.
return watch(
chainHub.getChainInfo('agoric'),
this.facets.makeLocalChainFacadeWatcher,
);
}
// XXX when() until membrane
return when(
watch(
chainHub.getChainsAndConnection('agoric', name),
this.facets.makeRemoteChainFacadeWatcher,
),
// @ts-expect-error Type 'Vow<Voidless>' is not assignable to type 'Vow<Chain<any>>'.
return watch(
chainHub.getChainsAndConnection('agoric', name),
this.facets.makeRemoteChainFacadeWatcher,
);
},
makeLocalAccount() {
return when(watch(E(localchain).makeAccount()));
return watch(E(localchain).makeAccount());
},
getBrandInfo: () => Fail`not yet implemented`,
asAmount: () => Fail`not yet implemented`,
Expand Down

0 comments on commit b09aaf9

Please sign in to comment.