Skip to content

Commit

Permalink
chore: address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
katelynsills committed Sep 10, 2020
1 parent 630fd24 commit 1b1dac1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/zoe/src/contractSupport/zoeHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ export const assertUsesNatMath = (zcf, brand) => {
);
};

export const depositToSeatSuccessMsg = `Deposit and reallocation successful.`;

/**
* Deposit payments such that their amounts are reallocated to a seat.
* The `amounts` and `payments` records must have corresponding
Expand All @@ -267,8 +269,9 @@ export const assertUsesNatMath = (zcf, brand) => {
* @param {PaymentKeywordRecord} payments
* @returns {Promise<string>} `Deposit and reallocation successful.`
*/

export async function depositToSeat(zcf, recipientSeat, amounts, payments) {
assert(!recipientSeat.hasExited(), 'The recipientSeat was exited.');
assert(!recipientSeat.hasExited(), 'The recipientSeat cannot not be exited.');

// We will create a temporary offer to be able to escrow our payments
// with Zoe.
Expand All @@ -283,7 +286,7 @@ export async function depositToSeat(zcf, recipientSeat, amounts, payments) {
{ seat: recipientSeat, gains: amounts },
);
tempSeat.exit();
return `Deposit and reallocation successful.`;
return depositToSeatSuccessMsg;
}
const invitation = zcf.makeInvitation(
reallocateAfterDeposit,
Expand All @@ -303,7 +306,7 @@ export async function depositToSeat(zcf, recipientSeat, amounts, payments) {

/**
* Withdraw payments from a seat. Note that withdrawing the amounts of
* the payments must not violate offer safety for the seat. The
* the payments must not and cannot violate offer safety for the seat. The
* `amounts` and `payments` records must have corresponding keywords.
*
* @param {ContractFacet} zcf
Expand All @@ -312,7 +315,7 @@ export async function depositToSeat(zcf, recipientSeat, amounts, payments) {
* @returns {Promise<PaymentPKeywordRecord>}
*/
export async function withdrawFromSeat(zcf, seat, amounts) {
assert(!seat.hasExited(), 'The seat was exited.');
assert(!seat.hasExited(), 'The seat cannot be exited.');
const { zcfSeat: tempSeat, userSeat: tempUserSeatP } = zcf.makeEmptySeatKit();
trade(zcf, { seat: tempSeat, gains: amounts }, { seat, gains: {} });
tempSeat.exit();
Expand Down

0 comments on commit 1b1dac1

Please sign in to comment.