diff --git a/packages/ipld-eth-client/src/eth-queries.ts b/packages/ipld-eth-client/src/eth-queries.ts index 2ef471c3..8ca7c81f 100644 --- a/packages/ipld-eth-client/src/eth-queries.ts +++ b/packages/ipld-eth-client/src/eth-queries.ts @@ -55,6 +55,7 @@ subscription SubscriptionReceipt { topic3S contract ethTransactionCidByTxId { + txHash ethHeaderCidByHeaderId { blockHash blockNumber diff --git a/packages/uni-watcher/src/events.ts b/packages/uni-watcher/src/events.ts index 9b88bc96..01476c62 100644 --- a/packages/uni-watcher/src/events.ts +++ b/packages/uni-watcher/src/events.ts @@ -37,12 +37,12 @@ export class EventWatcher { const contractAddress = logContracts[logIndex]; const uniContract = await this._indexer.isUniswapContract(contractAddress); if (uniContract) { - const { ethTransactionCidByTxId: { ethHeaderCidByHeaderId: { blockHash, blockNumber } } } = receipt; + const { ethTransactionCidByTxId: { txHash, ethHeaderCidByHeaderId: { blockHash, blockNumber } } } = receipt; const events = await this._indexer.getEvents(blockHash, contractAddress, null); const event = events[logIndex]; // Trigger other indexer methods based on event topic. - await this._indexer.processEvent(blockHash, blockNumber, uniContract, receipt, event); + await this._indexer.processEvent(blockHash, blockNumber, uniContract, txHash, receipt, event); } } } diff --git a/packages/uni-watcher/src/indexer.ts b/packages/uni-watcher/src/indexer.ts index d9f0263d..4786b8d0 100644 --- a/packages/uni-watcher/src/indexer.ts +++ b/packages/uni-watcher/src/indexer.ts @@ -104,7 +104,7 @@ export class Indexer { } } - async publishEventToSubscribers (blockHash: string, blockNumber: number, contract: string, event: EventResult): Promise { + async publishEventToSubscribers (blockHash: string, blockNumber: number, contract: string, txHash: string, event: EventResult): Promise { log(`pushing event to GQL subscribers: ${event.event.__typename}`); // Publishing the event here will result in pushing the payload to GQL subscribers for `onEvent`. @@ -113,6 +113,7 @@ export class Indexer { blockHash, blockNumber, contract, + txHash, event } }); @@ -122,12 +123,12 @@ export class Indexer { return this._db.getContract(ethers.utils.getAddress(address)); } - async processEvent (blockHash: string, blockNumber: number, contract: Contract, receipt: any, event: EventResult): Promise { + async processEvent (blockHash: string, blockNumber: number, contract: Contract, txHash: string, receipt: any, event: EventResult): Promise { // Trigger indexing of data based on the event. await this.triggerIndexingOnEvent(blockNumber, event); // Also trigger downstream event watcher subscriptions. - await this.publishEventToSubscribers(blockHash, blockNumber, contract.address, event); + await this.publishEventToSubscribers(blockHash, blockNumber, contract.address, txHash, event); } async _fetchAndSaveEvents ({ blockHash, contract, uniContract }: { blockHash: string, contract: string, uniContract: Contract }): Promise { diff --git a/packages/uni-watcher/src/schema.ts b/packages/uni-watcher/src/schema.ts index 45b1597b..4f9cfdc5 100644 --- a/packages/uni-watcher/src/schema.ts +++ b/packages/uni-watcher/src/schema.ts @@ -113,7 +113,7 @@ type CollectEvent { } # All events emitted by the NonfungiblePositionManager contract. -union NonFungiblePositionManagerEvent = IncreaseLiquidityEvent | DecreaseLiquidityEvent +union NonFungiblePositionManagerEvent = IncreaseLiquidityEvent | DecreaseLiquidityEvent | CollectEvent # Pool Events @@ -160,7 +160,7 @@ union PoolEvent = InitializeEvent | MintEvent | BurnEvent | SwapEvent # All events emitted by the watcher. -union Event = TransferEvent | PoolCreatedEvent | IncreaseLiquidityEvent | DecreaseLiquidityEvent | InitializeEvent | MintEvent | BurnEvent | SwapEvent +union Event = TransferEvent | PoolCreatedEvent | IncreaseLiquidityEvent | DecreaseLiquidityEvent | CollectEvent | InitializeEvent | MintEvent | BurnEvent | SwapEvent # Result type, with proof, for event return values. type ResultEvent { @@ -175,6 +175,7 @@ type WatchedEvent { blockHash: String! blockNumber: Int! contract: String! + txHash: String! event: ResultEvent! }