Skip to content

Commit

Permalink
Adds transaction receipt interface
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
  • Loading branch information
konstantinabl committed Apr 26, 2024
1 parent 1e4b619 commit 8cbb200
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/relay/src/lib/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { IDebugService } from './services/debugService/IDebugService';
import { DebugService } from './services/debugService';
import { isValidEthereumAddress } from '../formatters';
import { IFeeHistory } from './types/IFeeHistory';
import { ITransactionReceipt } from './types/ITransactionReceipt';

const _ = require('lodash');
const createHash = require('keccak');
Expand Down Expand Up @@ -93,7 +94,7 @@ export class EthImpl implements Eth {
oldestBlock: EthImpl.zeroHex,
baseFeePerGas: undefined,
};
static feeHistoryEmptyResponse: IFeeHistory = {
static readonly feeHistoryEmptyResponse: IFeeHistory = {
baseFeePerGas: [],
gasUsedRatio: [],
reward: [],
Expand Down Expand Up @@ -1905,7 +1906,7 @@ export class EthImpl implements Eth {
*
* @param hash
*/
async getTransactionReceipt(hash: string, requestIdPrefix?: string): Promise<Log | any | null> {
async getTransactionReceipt(hash: string, requestIdPrefix?: string): Promise<any> {
this.logger.trace(`${requestIdPrefix} getTransactionReceipt(${hash})`);

const cacheKey = `${constants.CACHE_KEY.ETH_GET_TRANSACTION_RECEIPT}_${hash}`;
Expand All @@ -1926,7 +1927,7 @@ export class EthImpl implements Eth {

if (cachedLog) {
const gasPriceForTimestamp = await this.getCurrentGasPriceForBlock(cachedLog.blockHash);
const receipt: any = {
const receipt: ITransactionReceipt = {
blockHash: cachedLog.blockHash,
blockNumber: cachedLog.blockNumber,
contractAddress: cachedLog.address,
Expand Down Expand Up @@ -1982,7 +1983,7 @@ export class EthImpl implements Eth {
});
});

const receipt: any = {
const receipt: ITransactionReceipt = {
blockHash: toHash32(receiptResponse.block_hash),
blockNumber: numberTo0x(receiptResponse.block_number),
from: await this.resolveEvmAddress(receiptResponse.from, requestIdPrefix),
Expand Down
20 changes: 20 additions & 0 deletions packages/relay/src/lib/types/ITransactionReceipt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Log } from '../model';

export interface ITransactionReceipt {
blockHash: string;
blockNumber: string;
contractAddress: string;
cumulativeGasUsed: string;
effectiveGasPrice: string;
from: string;
gasUsed: string;
logs: Log[];
logsBloom: string;
root: string;
status: string;
to: string;
transactionHash: string;
transactionIndex: string | null;
type: string | null;
revertReason?: string;
}

0 comments on commit 8cbb200

Please sign in to comment.