Skip to content

Commit

Permalink
fixup! feat: zoeTools.withdrawToSeat
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Sep 17, 2024
1 parent 92821e9 commit 30a3f27
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/orchestration/src/utils/zoe-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const { assign, keys, values } = Object;
* @typedef {(
* srcSeat: ZCFSeat,
* localAccount: LocalAccountMethods,
* give: AmountKeywordRecord,
* amounts: AmountKeywordRecord,
* ) => Promise<void>} LocalTransfer
*/

Expand All @@ -49,9 +49,9 @@ export const makeZoeTools = (
{ zcf, vowTools: { retriable, when, allVows, allSettled } },
) => {
/**
* Transfer the `give` of a seat to a local account. If any of the deposits
* fail, everything will be rolled back to the `srcSeat`. Supports multiple
* items in the `give` {@link PaymentKeywordRecord}.
* 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}.
*/
const localTransfer = retriable(
zone,
Expand All @@ -73,20 +73,20 @@ export const makeZoeTools = (
// zcf.makeEmptySeatKit();
// const uSeat = await userSeatP;
// // TODO how do I store in the place for this retriable?
// atomicTransfer(zcf, srcSeat, tempSeat, give);
// atomicTransfer(zcf, srcSeat, tempSeat, amounts);
// tempSeat.exit();
// return uSeat;
// },
// );

// Now all the `give` are accessible, so we can move them to the localAccount`
// Now all the `amounts` are accessible, so we can move them to the localAccount
const payments = await Promise.all(
keys(amounts).map(kw => E(userSeat).getPayout(kw)),
);
const settleDeposits = await when(
allSettled(payments.map(pmt => localAccount.deposit(pmt))),
);
// if any of the deposits to LCA failed, unwind all the allocations
// if any of the deposits to localAccount failed, unwind all of the allocations
if (settleDeposits.find(x => x.status === 'rejected')) {
const amts = values(amounts);
const errors = [];
Expand Down Expand Up @@ -118,12 +118,12 @@ export const makeZoeTools = (
errors,
});
}
// TODO remove userSeat from baggage
// TODO #9541 remove userSeat from baggage
},
);

/**
* Transfer the `amounts` from a local account to the `recipientSeat`. If any
* 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}.
Expand Down

0 comments on commit 30a3f27

Please sign in to comment.