mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-20 04:46:20 +00:00
Include block number in GQL event. (#121)
This commit is contained in:
parent
8d2a4c6b14
commit
0b6a33561b
@ -31,4 +31,4 @@
|
|||||||
deleteOnStart = false
|
deleteOnStart = false
|
||||||
|
|
||||||
[contracts]
|
[contracts]
|
||||||
factory = "0xF3eeD405056b4BB1ce100761325f82F2b6Da2D82"
|
factory = "0xECfCae19742EE4644b209d75cF15ee6D02A726Ff"
|
||||||
|
@ -39,11 +39,11 @@ export class EventWatcher {
|
|||||||
if (isWatchedContract) {
|
if (isWatchedContract) {
|
||||||
// TODO: Move processing to background task runner.
|
// TODO: Move processing to background task runner.
|
||||||
|
|
||||||
const { ethTransactionCidByTxId: { ethHeaderCidByHeaderId: { blockHash } } } = receipt;
|
const { ethTransactionCidByTxId: { ethHeaderCidByHeaderId: { blockHash, blockNumber } } } = receipt;
|
||||||
await this._indexer.getEvents(blockHash, contractAddress, null);
|
await this._indexer.getEvents(blockHash, contractAddress, null);
|
||||||
|
|
||||||
// Trigger other indexer methods based on event topic.
|
// Trigger other indexer methods based on event topic.
|
||||||
await this._indexer.processEvent(blockHash, contractAddress, receipt, logIndex);
|
await this._indexer.processEvent(blockHash, blockNumber, contractAddress, receipt, logIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ export class Indexer {
|
|||||||
}
|
}
|
||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
|
|
||||||
async publishEventToSubscribers (blockHash: string, contract: string, logIndex: number): Promise<void> {
|
async publishEventToSubscribers (blockHash: string, blockNumber: number, contract: string, logIndex: number): Promise<void> {
|
||||||
// TODO: Optimize this fetching of events.
|
// TODO: Optimize this fetching of events.
|
||||||
const events = await this.getEvents(blockHash, contract, null);
|
const events = await this.getEvents(blockHash, contract, null);
|
||||||
|
|
||||||
@ -105,6 +105,7 @@ export class Indexer {
|
|||||||
await this._pubsub.publish('event', {
|
await this._pubsub.publish('event', {
|
||||||
onEvent: {
|
onEvent: {
|
||||||
blockHash,
|
blockHash,
|
||||||
|
blockNumber,
|
||||||
contract,
|
contract,
|
||||||
event
|
event
|
||||||
}
|
}
|
||||||
@ -116,12 +117,12 @@ export class Indexer {
|
|||||||
return address != null;
|
return address != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async processEvent (blockHash: string, contract: string, receipt: any, logIndex: number): Promise<void> {
|
async processEvent (blockHash: string, blockNumber: number, contract: string, receipt: any, logIndex: number): Promise<void> {
|
||||||
// Trigger indexing of data based on the event.
|
// Trigger indexing of data based on the event.
|
||||||
await this.triggerIndexingOnEvent(blockHash, contract, receipt, logIndex);
|
await this.triggerIndexingOnEvent(blockHash, contract, receipt, logIndex);
|
||||||
|
|
||||||
// Also trigger downstream event watcher subscriptions.
|
// Also trigger downstream event watcher subscriptions.
|
||||||
await this.publishEventToSubscribers(blockHash, contract, logIndex);
|
await this.publishEventToSubscribers(blockHash, blockNumber, contract, logIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _fetchAndSaveEvents ({ blockHash, contract }: { blockHash: string, contract: string }): Promise<void> {
|
async _fetchAndSaveEvents ({ blockHash, contract }: { blockHash: string, contract: string }): Promise<void> {
|
||||||
|
@ -173,6 +173,7 @@ type ResultEvent {
|
|||||||
# Watched event, include additional context over and above the event data.
|
# Watched event, include additional context over and above the event data.
|
||||||
type WatchedEvent {
|
type WatchedEvent {
|
||||||
blockHash: String!
|
blockHash: String!
|
||||||
|
blockNumber: Int!
|
||||||
contract: String!
|
contract: String!
|
||||||
|
|
||||||
event: ResultEvent!
|
event: ResultEvent!
|
||||||
|
Loading…
Reference in New Issue
Block a user