diff --git a/packages/orchestration/src/utils/start-helper.js b/packages/orchestration/src/utils/start-helper.js index f11da8db32c..e86cb6e6b0a 100644 --- a/packages/orchestration/src/utils/start-helper.js +++ b/packages/orchestration/src/utils/start-helper.js @@ -63,8 +63,6 @@ export const provideOrchestration = ( orchestration: zone.subZone('orchestration'), /** system names for vows */ vows: zone.subZone('vows'), - /** system names for zoe */ - zoe: zone.subZone('zoe'), /** contract-provided names, and subzones */ contract: zone.subZone('contract'), }; @@ -76,7 +74,7 @@ export const provideOrchestration = ( const chainHub = makeChainHub(agoricNames, vowTools); - const zoeTools = makeZoeTools(zones.zoe, { zcf, vowTools }); + const zoeTools = makeZoeTools(zcf, vowTools); const { makeRecorderKit } = prepareRecorderKitMakers(baggage, marshaller); const makeLocalOrchestrationAccountKit = prepareLocalOrchestrationAccountKit( diff --git a/packages/orchestration/src/utils/zoe-tools.js b/packages/orchestration/src/utils/zoe-tools.js index 59306435247..97dbd6e8124 100644 --- a/packages/orchestration/src/utils/zoe-tools.js +++ b/packages/orchestration/src/utils/zoe-tools.js @@ -5,10 +5,10 @@ import { E } from '@endo/far'; const { assign, keys, values } = Object; /** + * @import {HostOf, GuestInterface} from '@agoric/async-flow'; * @import {InvitationMakers} from '@agoric/smart-wallet/src/types.js'; * @import {ResolvedPublicTopic} from '@agoric/zoe/src/contractSupport/topics.js'; * @import {VowTools} from '@agoric/vow'; - * @import {Zone} from '@agoric/zone'; * @import {LocalAccountMethods} from '../types.js'; */ @@ -38,25 +38,26 @@ const { assign, keys, values } = Object; */ /** - * @param {Zone} zone - * @param {{ zcf: ZCF; vowTools: VowTools }} io + * @param {ZCF} zcf + * @param {VowTools} vowTools */ -export const makeZoeTools = ( - zone, - { zcf, vowTools: { retriable, when, allVows, allSettled } }, -) => { +export const makeZoeTools = (zcf, vowTools) => { + const { when, allVows, allSettled, asVow } = vowTools; /** * Transfer the `amounts` from `srcSeat` to `localAccount`. If any of the * deposits fail, everything will be rolled back to the `srcSeat`. Supports * multiple items in the `amounts` {@link AmountKeywordRecord}. + * + * @type {HostOf} */ - const localTransfer = retriable( - zone, - 'localTransfer', + const localTransfer = (srcSeat, localAccount, amounts) => /** - * @type {LocalTransfer} + * There are no interchain actions - everything happens on the local chain - + * so we can expect this to settle promptly. As such, it's safe to use + * `asVow` instead of `watch`. In the future, when async-flow supports E and + * promises, we might consider making this an async-flow function. */ - async (srcSeat, localAccount, amounts) => { + asVow(async () => { !srcSeat.hasExited() || Fail`The seat cannot have exited.`; const { zcfSeat: tempSeat, userSeat: userSeatP } = zcf.makeEmptySeatKit(); const userSeat = await userSeatP; @@ -114,21 +115,24 @@ export const makeZoeTools = ( throw makeError(`One or more deposits failed ${q(errors)}`); } // TODO #9541 remove userSeat from baggage - }, - ); + }); /** * Transfer the `amounts` from a `localAccount` to the `recipientSeat`. If any * of the withdrawals fail, everything will be rolled back to the * `srcLocalAccount`. Supports multiple items in the `amounts` - * {@link PaymentKeywordRecord}. + * {@link PaymentKeywordRecord} + * + * @type {HostOf} */ - const withdrawToSeat = retriable( - zone, - 'withdrawToSeat', - /** @type {WithdrawToSeat} */ - async (localAccount, destSeat, amounts) => { - await null; + const withdrawToSeat = (localAccount, destSeat, amounts) => + /* + * There are no interchain actions - everything happens on the local chain - + * so we can expect this to settle promptly. As such, it's safe to use + * `asVow` instead of `watch`. In the future, when async-flow supports E and + * promises, we might consider making this an async-flow function. + */ + asVow(async () => { !destSeat.hasExited() || Fail`The seat cannot have exited.`; const settledWithdrawals = await when( @@ -167,12 +171,13 @@ export const makeZoeTools = ( paymentKwr, ); console.debug(depositResponse); - }, - ); + }); return harden({ localTransfer, withdrawToSeat, }); }; -/** @typedef {ReturnType} ZoeTools */ + +/** @typedef {ReturnType} ZoeToolsHost */ +/** @typedef {GuestInterface} ZoeTools */ diff --git a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md index a835e96a709..11710ddf60d 100644 --- a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md +++ b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md @@ -68,5 +68,4 @@ Generated by [AVA](https://avajs.dev). VowInternalsKit_kindHandle: 'Alleged: kind', WatchUtils_kindHandle: 'Alleged: kind', }, - zoe: {}, } diff --git a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap index fc84d7f6361..bbf9e53542d 100644 Binary files a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap and b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap differ diff --git a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md index 5b0b7e27271..926a50924a3 100644 --- a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md +++ b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md @@ -139,5 +139,4 @@ Generated by [AVA](https://avajs.dev). VowInternalsKit_kindHandle: 'Alleged: kind', WatchUtils_kindHandle: 'Alleged: kind', }, - zoe: {}, } diff --git a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap index baa5d7049ab..7a30cfbebf4 100644 Binary files a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap and b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap differ diff --git a/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.md b/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.md index 82a7b2f488e..1a7163c5994 100644 --- a/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.md +++ b/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.md @@ -57,5 +57,4 @@ Generated by [AVA](https://avajs.dev). VowInternalsKit_kindHandle: 'Alleged: kind', WatchUtils_kindHandle: 'Alleged: kind', }, - zoe: {}, } diff --git a/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.snap b/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.snap index 90478398c1d..fbf713b1764 100644 Binary files a/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.snap and b/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.snap differ