mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-10-02 22:22:37 +00:00
Include txHash in event sent to GQL subscribers. (#129)
This commit is contained in:
parent
61f211f2d5
commit
69c68b365f
@ -55,6 +55,7 @@ subscription SubscriptionReceipt {
|
|||||||
topic3S
|
topic3S
|
||||||
contract
|
contract
|
||||||
ethTransactionCidByTxId {
|
ethTransactionCidByTxId {
|
||||||
|
txHash
|
||||||
ethHeaderCidByHeaderId {
|
ethHeaderCidByHeaderId {
|
||||||
blockHash
|
blockHash
|
||||||
blockNumber
|
blockNumber
|
||||||
|
@ -37,12 +37,12 @@ export class EventWatcher {
|
|||||||
const contractAddress = logContracts[logIndex];
|
const contractAddress = logContracts[logIndex];
|
||||||
const uniContract = await this._indexer.isUniswapContract(contractAddress);
|
const uniContract = await this._indexer.isUniswapContract(contractAddress);
|
||||||
if (uniContract) {
|
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 events = await this._indexer.getEvents(blockHash, contractAddress, null);
|
||||||
const event = events[logIndex];
|
const event = events[logIndex];
|
||||||
|
|
||||||
// Trigger other indexer methods based on event topic.
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ export class Indexer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async publishEventToSubscribers (blockHash: string, blockNumber: number, contract: string, event: EventResult): Promise<void> {
|
async publishEventToSubscribers (blockHash: string, blockNumber: number, contract: string, txHash: string, event: EventResult): Promise<void> {
|
||||||
log(`pushing event to GQL subscribers: ${event.event.__typename}`);
|
log(`pushing event to GQL subscribers: ${event.event.__typename}`);
|
||||||
|
|
||||||
// Publishing the event here will result in pushing the payload to GQL subscribers for `onEvent`.
|
// Publishing the event here will result in pushing the payload to GQL subscribers for `onEvent`.
|
||||||
@ -113,6 +113,7 @@ export class Indexer {
|
|||||||
blockHash,
|
blockHash,
|
||||||
blockNumber,
|
blockNumber,
|
||||||
contract,
|
contract,
|
||||||
|
txHash,
|
||||||
event
|
event
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -122,12 +123,12 @@ export class Indexer {
|
|||||||
return this._db.getContract(ethers.utils.getAddress(address));
|
return this._db.getContract(ethers.utils.getAddress(address));
|
||||||
}
|
}
|
||||||
|
|
||||||
async processEvent (blockHash: string, blockNumber: number, contract: Contract, receipt: any, event: EventResult): Promise<void> {
|
async processEvent (blockHash: string, blockNumber: number, contract: Contract, txHash: string, receipt: any, event: EventResult): Promise<void> {
|
||||||
// Trigger indexing of data based on the event.
|
// Trigger indexing of data based on the event.
|
||||||
await this.triggerIndexingOnEvent(blockNumber, event);
|
await this.triggerIndexingOnEvent(blockNumber, event);
|
||||||
|
|
||||||
// Also trigger downstream event watcher subscriptions.
|
// 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<void> {
|
async _fetchAndSaveEvents ({ blockHash, contract, uniContract }: { blockHash: string, contract: string, uniContract: Contract }): Promise<void> {
|
||||||
|
@ -113,7 +113,7 @@ type CollectEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# All events emitted by the NonfungiblePositionManager contract.
|
# All events emitted by the NonfungiblePositionManager contract.
|
||||||
union NonFungiblePositionManagerEvent = IncreaseLiquidityEvent | DecreaseLiquidityEvent
|
union NonFungiblePositionManagerEvent = IncreaseLiquidityEvent | DecreaseLiquidityEvent | CollectEvent
|
||||||
|
|
||||||
|
|
||||||
# Pool Events
|
# Pool Events
|
||||||
@ -160,7 +160,7 @@ union PoolEvent = InitializeEvent | MintEvent | BurnEvent | SwapEvent
|
|||||||
|
|
||||||
|
|
||||||
# All events emitted by the watcher.
|
# 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.
|
# Result type, with proof, for event return values.
|
||||||
type ResultEvent {
|
type ResultEvent {
|
||||||
@ -175,6 +175,7 @@ type WatchedEvent {
|
|||||||
blockHash: String!
|
blockHash: String!
|
||||||
blockNumber: Int!
|
blockNumber: Int!
|
||||||
contract: String!
|
contract: String!
|
||||||
|
txHash: String!
|
||||||
|
|
||||||
event: ResultEvent!
|
event: ResultEvent!
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user