Skip to content

Commit

Permalink
WIP flow call flow?
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Sep 3, 2024
1 parent b11e6b8 commit b931fa6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import * as flows from './continuing-invitation.flows.js';
* @param {OrchestrationTools} tools
*/
const contract = async (zcf, privateArgs, zone, { orchestrateAll }) => {
const { makeAccount } = orchestrateAll(flows, { zcf });
const { makeAccount } = orchestrateAll(flows, { flows, zcf });

const publicFacet = zone.exo('publicFacet', undefined, {
makeAccount() {
Expand Down
27 changes: 25 additions & 2 deletions packages/orchestration/src/examples/continuing-invitation.flows.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @import {Orchestrator, OrchestrationFlow} from '../types.js'
* @import {Orchestrator, OrchestrationFlow, OrchestrationAccount, OrchestrationAccountI, StakingAccountActions} from '../types.js'
* @import {ContinuingOfferResult, InvitationMakers} from '@agoric/smart-wallet/src/types.js';
* @import {NameHub} from '@agoric/vats';
*/
Expand All @@ -9,16 +9,39 @@
* @param {Orchestrator} orch
* @param {object} ctx
* @param {ZCF} ctx.zcf

Check failure on line 11 in packages/orchestration/src/examples/continuing-invitation.flows.js

View workflow job for this annotation

GitHub Actions / lint-rest

@param "ctx.zcf" does not exist on ctx
* @param {any} ctx.flows
* @param {ZCFSeat} _seat
* @param {{ chainName: string }} offerArgs
* @returns {Promise<ContinuingOfferResult>}
*/
export const makeAccount = async (orch, ctx, _seat, { chainName }) => {
export const makeAccount = async (orch, { flows }, _seat, { chainName }) => {
const chain = await orch.getChain(chainName);
const account = await chain.makeAccount();

/** @type {ContinuingOfferResult} */
const result = await account.asContinuingOffer();

// TODO merge in another invitationMaker that uses flow.undelegateAndTransfer

// XXX can we call another flow?
await flows.undelegateAndTransfer(orch, {}, undefined, { account });

return result;
};
harden(makeAccount);

// FIXME 'account' not Passable?
/**
* @satisfies {OrchestrationFlow}
* @param {Orchestrator} orch
* @param {object} ctx
* @param {ZCFSeat | undefined} _seat
* @param {{ account: OrchestrationAccountI & StakingAccountActions }} args
* @returns {Promise<void>}
*/
export const undelegateAndTransfer = async (orch, ctx, _seat, { account }) => {
// FIXME undelegate something
await account.undelegate([]);
// FIXME then transfer something
};
harden(undelegateAndTransfer);

0 comments on commit b931fa6

Please sign in to comment.