Skip to content

Commit

Permalink
Merge pull request #772 from Agoric/mfig/wait-for-payments
Browse files Browse the repository at this point in the history
Wait for payments at opportune moments
  • Loading branch information
michaelfig authored Mar 26, 2020
2 parents fb9c8a0 + 53f359d commit 105fc16
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 105fc16

Please sign in to comment.