Skip to content

Commit

Permalink
fix: wait for payments at opportune moments
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Mar 25, 2020
1 parent fb9c8a0 commit 53f359d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default function setup(syscall, state, helpers) {
);

// deposit payments
const [moolaPayment, simoleanPayment] = payments;
const [moolaPayment, simoleanPayment] = await Promise.all(payments);

await E(wallet).deposit(pursePetnames.moola, moolaPayment);
await E(wallet).deposit(pursePetnames.simolean, simoleanPayment);
Expand Down
5 changes: 3 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/lib-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,11 @@ export async function makeWallet(
}),
).then(payoutArray =>
Promise.all(
payoutArray.map((payout, payoutIndex) => {
payoutArray.map(async (payoutP, payoutIndex) => {
const keyword = payoutIndexToKeyword[payoutIndex];
const purse = purses[keyword];
if (purse && payout) {
if (purse && payoutP) {
const payout = await payoutP;
return E(purse).deposit(payout);
}
return undefined;
Expand Down
6 changes: 4 additions & 2 deletions packages/zoe/src/zoe.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,10 @@ const makeZoe = (additionalEndowments = {}) => {
if (giveKeywords.includes(keyword)) {
// We cannot trust these amounts since they come directly
// from the remote issuer and so we must coerce them.
return E(purse)
.deposit(paymentKeywordRecord[keyword], proposal.give[keyword])
return Promise.resolve(paymentKeywordRecord[keyword])
.then(payment =>
E(purse).deposit(payment, proposal.give[keyword]),
)
.then(_ => amountMath.coerce(proposal.give[keyword]));
}
// If any other payments are included, they are ignored.
Expand Down

0 comments on commit 53f359d

Please sign in to comment.