Skip to content

Commit

Permalink
fix: remove awaita from depositMultiple
Browse files Browse the repository at this point in the history
  • Loading branch information
dtribble authored and michaelfig committed May 4, 2021
1 parent b16ae45 commit a7da714
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/vats/src/distributeFees.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function buildDistributor(treasury, bank, epochTimer, timer, params) {
const accounts = queuedAccounts.splice(0, depositsPerUpdate);
const payments = queuedPayments.splice(0, depositsPerUpdate);
E(bank)
.depositMultiple(accounts, payments)
.depositMultiple(runBrand, accounts, payments)
.then(settledResults => {
const rejectedPayments = payments.filter(
(_pmt, i) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/vats/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
/**
* @typedef {Object} BankDepositFacet
*
* @property {(accounts: string[], payments: Payment[]) => Promise<PromiseSettledResult<Amount>[]>} depositMultiple
* @property {(brand: Brand, accounts: string[], payments: Payment[]) => Promise<PromiseSettledResult<Amount>[]>} depositMultiple
* @property {() => Notifier<string[]>} getAccountsNotifier
*/

Expand Down
13 changes: 7 additions & 6 deletions packages/vats/src/vat-bank.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export function buildRootObject(_vatPowers) {
const assetRecord = brandToAssetRecord.get(brand);
if (!bankCall) {
// Just emulate with a real purse.
const purse = await E(assetRecord.issuer).makeEmptyPurse();
const purse = E(assetRecord.issuer).makeEmptyPurse();
brandToVPurse.init(brand, purse);
return purse;
}
Expand Down Expand Up @@ -266,22 +266,23 @@ export function buildRootObject(_vatPowers) {
return accountsNotifier;
},
/**
* Send many independent deposits. If any of them fail, then you should
* reclaim the corresponding payments since they didn't get deposited.
* Send many independent deposits, all of the same brand. If any of them
* fail, then you should reclaim the corresponding payments since they
* didn't get deposited.
*
* @param {Brand} brand
* @param {Array<string>} accounts
* @param {Array<Payment>} payments
* @returns {Promise<PromiseSettledResult<Amount>[]>}
*/
depositMultiple(accounts, payments) {
depositMultiple(brand, accounts, payments) {
/**
* @param {string} account
* @param {Payment} payment
*/
const doDeposit = async (account, payment) => {
const doDeposit = (account, payment) => {
// We can get the alleged brand, because the purse we send it to
// will do the proper verification as part of deposit.
const brand = await E(payment).getAllegedBrand();
const bank = getBankForAddress(account);
const purse = bank.getPurse(brand);
return E(purse).deposit(payment);
Expand Down

0 comments on commit a7da714

Please sign in to comment.