Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
fix: poolFee transactions for CHARGE and PAID not registered (#215)
Browse files Browse the repository at this point in the history
Fixes #213
  • Loading branch information
filo87 authored Mar 7, 2024
1 parent e32604c commit e5181d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ enum PoolFeeTransactionType {
}

type PoolFeeTransaction @entity {
id: ID! # extrinsicHash - epochNumber - transaction type
id: ID! # extrinsicHash - epochNumber - transaction type
poolFee: PoolFee! @index
type: PoolFeeTransactionType!

Expand Down
17 changes: 10 additions & 7 deletions src/mappings/services/poolFeeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ export class PoolFeeService extends PoolFee {
const _type = PoolFeeType[type]
const _status = PoolFeeStatus[status]

Object.getOwnPropertyNames(this)
.filter((prop) => typeof this[prop] === 'bigint')
.forEach((prop) => {
logger.info(`-> initialising ${prop} to 0`)
this[prop] = BigInt(0)
})
const poolFee = new this(`${poolId}-${feeId}`, feeId, _type, _status, false, poolId)

return new this(`${poolId}-${feeId}`, feeId, _type, _status, false, poolId)
poolFee.sumChargedAmount = BigInt(0)
poolFee.sumAccruedAmount = BigInt(0)
poolFee.sumPaidAmount = BigInt(0)
poolFee.pendingAmount = BigInt(0)
poolFee.sumChargedAmountByPeriod = BigInt(0)
poolFee.sumAccruedAmountByPeriod = BigInt(0)
poolFee.sumPaidAmountByPeriod = BigInt(0)

return poolFee
}

static async getOrInit(data: PoolFeeData, type: keyof typeof PoolFeeType, status: keyof typeof PoolFeeStatus) {
Expand Down
2 changes: 1 addition & 1 deletion src/mappings/services/poolFeeTransactionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class PoolFeeTransactionService extends PoolFeeTransaction {
const _type = PoolFeeTransactionType[type]
const _epochNumber = epochNumber ?? 0
return new this(
`${hash}-${_epochNumber}`,
`${hash}-${_epochNumber}-${type}`,
`${poolId}-${feeId}`,
_type,
timestamp,
Expand Down

0 comments on commit e5181d2

Please sign in to comment.