Skip to content

Commit

Permalink
fix: throw exception if event does not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
dancespiele committed Apr 25, 2023
1 parent 12ee8ad commit 5a270ae
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/shared/nevermined/nvm.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common'
import { ForbiddenException, Injectable } from '@nestjs/common'
import {
generateId,
generateIntantiableConfigFromConfig,
Expand Down Expand Up @@ -476,10 +476,16 @@ export class NeverminedService {
eventOptions,
)

if (event?.blockNumber) {
if (!event) {
throw new ForbiddenException(
`No purchase found for subscription ${subscriptionDid} from user ${userAddress}`,
)
}

if (event.blockNumber) {
return event.blockNumber
} else if (event?.id) {
const [transactionHash] = event.id.split('-') as string[]
} else if (event.id) {
const [transactionHash] = event.id.split('-')
const transactionReceipt = await this.nevermined.utils.web3.getTransaction(transactionHash)
return transactionReceipt.blockNumber
}
Expand Down

0 comments on commit 5a270ae

Please sign in to comment.