diff --git a/src.ts/providers/format.ts b/src.ts/providers/format.ts index 40720d1ef8..d1dbe9a100 100644 --- a/src.ts/providers/format.ts +++ b/src.ts/providers/format.ts @@ -101,6 +101,7 @@ const _formatLog = object({ topics: arrayOf(formatHash), transactionHash: formatHash, transactionIndex: getNumber, + timestamp: allowNull(getNumber), }, { index: [ "logIndex" ] }); @@ -156,6 +157,7 @@ const _formatReceiptLog = object({ data: formatData, index: getNumber, blockHash: formatHash, + timestamp: allowNull(getNumber), }, { index: [ "logIndex" ] }); diff --git a/src.ts/providers/formatting.ts b/src.ts/providers/formatting.ts index d5bd09da69..1a0ed9b288 100644 --- a/src.ts/providers/formatting.ts +++ b/src.ts/providers/formatting.ts @@ -173,6 +173,13 @@ export interface LogParams { * The transaction index of this log. */ transactionIndex: number; + + /** + * The timestamp of the block that included this log (optional). + * This is supported by newer versions of Geth as per updated + * eth_getLogs specification. + */ + timestamp?: number; } diff --git a/src.ts/providers/provider.ts b/src.ts/providers/provider.ts index 1e1e64bba4..5dc5e6f902 100644 --- a/src.ts/providers/provider.ts +++ b/src.ts/providers/provider.ts @@ -857,6 +857,13 @@ export class Log implements LogParams { */ readonly transactionIndex!: number; + /** + * The timestamp of the block that included this log (optional). + * This is supported by newer versions of Geth as per updated + * eth_getLogs specification. + */ + readonly timestamp?: number; + /** * @_ignore: */ @@ -878,6 +885,7 @@ export class Log implements LogParams { index: log.index, transactionIndex: log.transactionIndex, + timestamp: log.timestamp, }); } @@ -887,13 +895,13 @@ export class Log implements LogParams { toJSON(): any { const { address, blockHash, blockNumber, data, index, - removed, topics, transactionHash, transactionIndex + removed, topics, transactionHash, transactionIndex, timestamp } = this; return { _type: "log", address, blockHash, blockNumber, data, index, - removed, topics, transactionHash, transactionIndex + removed, topics, transactionHash, transactionIndex, timestamp }; }