I did not use require, since that would revert transaction. In most cases when withdraw is called, at least for some party amount is zero, and imposing that check would render withdraw useless
I considered just putting lines 735 - 740 in if conditional that would execute only if amount > 0 (this is what was proposed). That would result in vouchersStatus[_tokenIdVoucher].depositReleased.status still being updated. Although this is not wrong per se, this would result in different states depending on whether withdraw is called or if withdrawSingle is callled for each entity.
In withdraw, it would seem as if deposit was released to all three entities, while withdrawSingle would revert if there was nothing to be withdrawn and therefore vouchersStatus[_tokenIdVoucher].depositReleased.status would not be updated. I decided to do it in a way, that calling withdraw or withdrawSIngle three times result in same state.
I could impose the check _amount > 0 at very begining of setDepositsReleased and just return if amount ==0, but I decided to actually put that check into Cashier to avoid a call to VoucherKernel contract at all. I added a comment in setDepositsReleased so if at any point onlyFromCashier is removed that amount tcheck should be put in place.
FIx #332
Three things to note:
withdraw
is called, at least for some party amount is zero, and imposing that check would renderwithdraw
uselessvouchersStatus[_tokenIdVoucher].depositReleased.status
still being updated. Although this is not wrong per se, this would result in different states depending on whetherwithdraw
is called or ifwithdrawSingle
is callled for each entity. Inwithdraw
, it would seem as if deposit was released to all three entities, whilewithdrawSingle
would revert if there was nothing to be withdrawn and thereforevouchersStatus[_tokenIdVoucher].depositReleased.status
would not be updated. I decided to do it in a way, that calling withdraw or withdrawSIngle three times result in same state._amount > 0
at very begining ofsetDepositsReleased
and just return ifamount ==0
, but I decided to actually put that check intoCashier
to avoid a call to VoucherKernel contract at all. I added a comment insetDepositsReleased
so if at any pointonlyFromCashier
is removed that amount tcheck should be put in place.