Skip to content

Commit

Permalink
fix: ProjectToken.RevenueSplitLeft mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
zeeshanakram3 committed Mar 29, 2024
1 parent 729fe65 commit 12bbbe2
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/mappings/token/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -757,21 +757,21 @@ export async function processRevenueSplitLeftEvent({
}: EventHandlerContext<'ProjectToken.RevenueSplitLeft'>) {
const account = await getTokenAccountByMemberByTokenOrFail(overlay, memberId, tokenId)
account.stakedAmount -= unstakedAmount
const token = await overlay.getRepository(CreatorToken).getByIdOrFail(tokenId.toString())
if (token.currentRevenueShareId) {
// TODO: refactor this as should be true all the times, might be a good idea to panic

const revenueShareParticipation = (
await overlay
.getRepository(RevenueShareParticipation)
.getManyByRelation('accountId', account.id)
).find((participation) => participation.recovered === false)

if (revenueShareParticipation) {
revenueShareParticipation.recovered = true

const revenueShare = await overlay
.getRepository(RevenueShare)
.getByIdOrFail(token.currentRevenueShareId)
.getByIdOrFail(revenueShareParticipation.revenueShareId || '')

revenueShare.participantsNum -= 1
const qRevenueShareParticipation = (
await overlay
.getRepository(RevenueShareParticipation)
.getManyByRelation('accountId', account.id)
).find((participation) => participation.recovered === false)
if (qRevenueShareParticipation) {
qRevenueShareParticipation.recovered = true
}
}
}

Expand Down

0 comments on commit 12bbbe2

Please sign in to comment.