Skip to content

Commit

Permalink
fix(feeByEvent): handle tip for partialFee (#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul committed Aug 2, 2022
1 parent 0545454 commit 6e60aa9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/services/blocks/BlocksService.spec.ts
Expand Up @@ -592,7 +592,7 @@ describe('BlocksService', () => {
});

it('Should retrieve the correct fee for balances:withdraw events with a tip', () => {
const expectedResponse = { partialFee: '1681144907847007' };
const expectedResponse = { partialFee: '1675415080573007' };
const fee = polkadotRegistry.createType('Balance', '1675415067070856');
const tip = new Compact(polkadotRegistry, 'u64', 5729827274000);
const response = blocksService['getPartialFeeByEvents'](
Expand Down
12 changes: 9 additions & 3 deletions src/services/blocks/BlocksService.ts
Expand Up @@ -541,7 +541,9 @@ export class BlocksService extends AbstractService {
// The difference between values is 00.00001% or less so they are alike.
if (this.areFeesSimilar(new BN(fee), adjustedPartialFee)) {
return {
partialFee: fee.toString(),
partialFee: tip
? new BN(fee).sub(tip.toBn()).toString()
: fee.toString(),
};
}
}
Expand All @@ -559,7 +561,9 @@ export class BlocksService extends AbstractService {
// The difference between values is 00.00001% or less so they are alike.
if (this.areFeesSimilar(new BN(fee), adjustedPartialFee)) {
return {
partialFee: fee.toString(),
partialFee: tip
? new BN(fee).sub(tip.toBn()).toString()
: fee.toString(),
};
}
}
Expand All @@ -579,7 +583,9 @@ export class BlocksService extends AbstractService {
// The difference between values is 00.00001% or less so they are alike.
if (this.areFeesSimilar(sumOfFees, adjustedPartialFee)) {
return {
partialFee: sumOfFees.toString(),
partialFee: tip
? new BN(sumOfFees).sub(tip.toBn()).toString()
: sumOfFees.toString(),
};
}
}
Expand Down

0 comments on commit 6e60aa9

Please sign in to comment.