mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
hardened event listening
This commit is contained in:
parent
8ab5f7408b
commit
7b0d34a420
@ -1,6 +1,7 @@
|
||||
import GenericContract from "./contracts/GenericContract"
|
||||
import EventListener from "./EventListener"
|
||||
import Web3Provider from "./Web3Provider"
|
||||
// import Logger from "../utils/Logger"
|
||||
|
||||
export default class Event {
|
||||
|
||||
@ -39,15 +40,19 @@ export default class Event {
|
||||
private async handler(callback: any) {
|
||||
const contract = await GenericContract.getInstance(this.contractName)
|
||||
|
||||
const events = await contract.getEventData(this.eventName, {
|
||||
filter: this.filter,
|
||||
fromBlock: this.lastBlock,
|
||||
toBlock: "latest",
|
||||
})
|
||||
try {
|
||||
const events = await contract.getEventData(this.eventName, {
|
||||
filter: this.filter,
|
||||
fromBlock: this.lastBlock,
|
||||
toBlock: "latest",
|
||||
})
|
||||
|
||||
if (events.length > 0) {
|
||||
this.lastBlock = events[events.length - 1].blockNumber + 1
|
||||
callback(events)
|
||||
if (events.length > 0) {
|
||||
this.lastBlock = events[events.length - 1].blockNumber + 1
|
||||
callback(events)
|
||||
}
|
||||
} catch (err) {
|
||||
// Logger.log("err")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user