diff --git a/packages/codegen/src/templates/indexer-template.handlebars b/packages/codegen/src/templates/indexer-template.handlebars index f1f13e8b4..351c63ca1 100644 --- a/packages/codegen/src/templates/indexer-template.handlebars +++ b/packages/codegen/src/templates/indexer-template.handlebars @@ -44,7 +44,10 @@ import { Clients, EthClient, UpstreamConfig, - ResultMeta + ResultMeta, + EthFullBlock, + EthFullTransaction, + ExtraEventData } from '@cerc-io/util'; {{#if (subgraphPath)}} import { GraphWatcher } from '@cerc-io/graph-node'; @@ -464,13 +467,13 @@ export class Indexer implements IndexerInterface { } {{/if}} - async triggerIndexingOnEvent (event: Event): Promise { + async triggerIndexingOnEvent (event: Event, extraData: ExtraEventData): Promise { const resultEvent = this.getResultEvent(event); {{#if (subgraphPath)}} console.time('time:indexer#processEvent-mapping_code'); // Call subgraph handler for event. - await this._graphWatcher.handleEvent(resultEvent); + await this._graphWatcher.handleEvent(resultEvent, extraData); console.timeEnd('time:indexer#processEvent-mapping_code'); {{/if}} @@ -478,9 +481,9 @@ export class Indexer implements IndexerInterface { await handleEvent(this, resultEvent); } - async processEvent (event: Event): Promise { + async processEvent (event: Event, extraData: ExtraEventData): Promise { // Trigger indexing of data based on the event. - await this.triggerIndexingOnEvent(event); + await this.triggerIndexingOnEvent(event, extraData); } async processBlock (blockProgress: BlockProgress): Promise { @@ -689,7 +692,12 @@ export class Indexer implements IndexerInterface { return this._baseIndexer.fetchEventsAndSaveBlocks(blocks, this._eventSignaturesMap, this.parseEventNameAndArgs.bind(this)); } - async fetchAndSaveFilteredEventsAndBlocks (startBlock: number, endBlock: number): Promise<{ blockProgress: BlockProgress, events: DeepPartial[] }[]> { + async fetchAndSaveFilteredEventsAndBlocks (startBlock: number, endBlock: number): Promise<{ + blockProgress: BlockProgress, + events: DeepPartial[], + ethFullBlock: EthFullBlock; + ethFullTransactions: EthFullTransaction[]; + }[]> { return this._baseIndexer.fetchAndSaveFilteredEventsAndBlocks(startBlock, endBlock, this._eventSignaturesMap, this.parseEventNameAndArgs.bind(this)); } @@ -697,7 +705,11 @@ export class Indexer implements IndexerInterface { return this._baseIndexer.fetchEventsForContracts(blockHash, blockNumber, addresses, this._eventSignaturesMap, this.parseEventNameAndArgs.bind(this)); } - async saveBlockAndFetchEvents (block: DeepPartial): Promise<[BlockProgress, DeepPartial[]]> { + async saveBlockAndFetchEvents (block: DeepPartial): Promise<[ + BlockProgress, + DeepPartial[], + EthFullTransaction[] + ]> { return this._saveBlockAndFetchEvents(block); } @@ -810,11 +822,15 @@ export class Indexer implements IndexerInterface { blockNumber, blockTimestamp, parentHash - }: DeepPartial): Promise<[BlockProgress, DeepPartial[]]> { + }: DeepPartial): Promise<[ + BlockProgress, + DeepPartial[], + EthFullTransaction[] + ]> { assert(blockHash); assert(blockNumber); - const dbEvents = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this._eventSignaturesMap, this.parseEventNameAndArgs.bind(this)); + const { events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this._eventSignaturesMap, this.parseEventNameAndArgs.bind(this)); const dbTx = await this._db.createTransactionRunner(); try { @@ -831,7 +847,7 @@ export class Indexer implements IndexerInterface { await dbTx.commitTransaction(); console.timeEnd(`time:indexer#_saveBlockAndFetchEvents-db-save-${blockNumber}`); - return [blockProgress, []]; + return [blockProgress, [], transactions]; } catch (error) { await dbTx.rollbackTransaction(); throw error; diff --git a/packages/graph-node/src/loader.ts b/packages/graph-node/src/loader.ts index 82e78e125..e4fc9e7f8 100644 --- a/packages/graph-node/src/loader.ts +++ b/packages/graph-node/src/loader.ts @@ -158,8 +158,7 @@ export const instantiate = async ( const functionParamsPtr = await smartContractCall.functionParams; let functionParams = __getArray(functionParamsPtr); - console.log('ethereum.call params'); - console.log('functionSignature:', functionSignature); + console.log('ethereum.call functionSignature:', functionSignature); const abi = abis[contractName]; const contractAddressStringPtr = await contractAddress.toHexString(); @@ -284,7 +283,7 @@ export const instantiate = async ( conversion: { 'typeConversion.stringToH160': async (s: number) => { const string = __getString(s); - const address = utils.getAddress(string); + const address = utils.getAddress(string.trim()); const byteArray = utils.arrayify(address); const uint8ArrayId = await getIdOfType(TypeId.Uint8Array);