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 19, 2024
1 parent 6a8aebc commit 7443b40
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 @@ -34,8 +34,8 @@ const { assign, keys, values } = Object;

/**
* @typedef {(
* srcLocalAccount: LocalAccountMethods,
* recipientSeat: ZCFSeat,
* localAccount: LocalAccountMethods,
* destSeat: ZCFSeat,
* amounts: AmountKeywordRecord,
* ) => Promise<void>} WithdrawToSeat
*/
Expand Down Expand Up @@ -84,7 +84,7 @@ export const makeZoeTools = (
keys(amounts).map(kw => E(userSeat).getPayout(kw)),
);
const settleDeposits = await when(
allSettled(payments.map(pmt => localAccount.deposit(pmt))),
allSettled(payments.map(pmt => E(localAccount).deposit(pmt))),
);
// if any of the deposits to localAccount failed, unwind all of the allocations
if (settleDeposits.find(x => x.status === 'rejected')) {
Expand All @@ -96,7 +96,7 @@ export const makeZoeTools = (
errors.push(x.reason);
return payments[i];
}
return localAccount.withdraw(amts[i]);
return E(localAccount).withdraw(amts[i]);
});

// return all payments to the srcSeat
Expand Down Expand Up @@ -130,12 +130,12 @@ export const makeZoeTools = (
zone,
'withdrawToSeat',
/** @type {WithdrawToSeat} */
async (srcLocalAccount, recipientSeat, amounts) => {
async (localAccount, destSeat, amounts) => {
await null;
!recipientSeat.hasExited() || Fail`The seat cannot have exited.`;
!destSeat.hasExited() || Fail`The seat cannot have exited.`;

const settledWithdrawals = await when(
allSettled(values(amounts).map(amt => srcLocalAccount.withdraw(amt))),
allSettled(values(amounts).map(amt => E(localAccount).withdraw(amt))),
);

// if any of the withdrawals were rejected, unwind the successful ones
Expand All @@ -144,7 +144,7 @@ export const makeZoeTools = (
const errors = [];
for (const result of settledWithdrawals) {
if (result.status === 'fulfilled') {
returnPaymentVs.push(srcLocalAccount.deposit(result.value));
returnPaymentVs.push(E(localAccount).deposit(result.value));
} else {
errors.push(result.reason);
}
Expand All @@ -165,7 +165,7 @@ export const makeZoeTools = (
);
const depositResponse = await depositToSeat(
zcf,
recipientSeat,
destSeat,
amounts,
paymentKwr,
);
Expand Down

0 comments on commit 7443b40

Please sign in to comment.