Skip to content
Snippets Groups Projects

Fees should use the right units

Closed Carles Barrobés requested to merge transfer-fee-bug into develop
3 unresolved threads
Files
3
@@ -479,9 +479,8 @@ export class AccountsService extends RxStartableService<AccountsState> {
throw new Error('ERROR.AMOUNT_NEGATIVE');
}
// Remove decimals, in amount and fee
// Convert amount to right unit ("cents")
amount = amount * powBase;
if (fee) fee = fee * powBase;
    • I dont understand why we need to remove this line ? The fee argument (see function jsdoc) are in decimals. So we need to convert in cents, before using it.

      • Interesting... although while it is true that the docstring mentions decimals, your comment contradicts my observations, which are:

        So for the time being I would even remove the fee parameter and always use the network values (in cents) to prevent tripping others up.

        But I see your point, this is not really a bug (it only converts the undefined argument to align the units) but it makes the code confusing and unit mismatch is a potential source of bugs and the variable names aren't helping make out the difference.

        Edited by Carles Barrobés
      • Please register or sign in to reply
Please register or sign in to reply
// Check fee validity
fee = fee || currency.fees?.tx || 0;
Loading