Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions packages/web3-eth/src/web3_eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,15 @@ export class Web3Eth extends Web3Context<Web3EthExecutionAPI, RegisteredSubscrip
transactionHash: Bytes,
returnFormat: ReturnFormat = DEFAULT_RETURN_FORMAT as ReturnFormat,
) {
return rpcMethodsWrappers.getTransaction(this, transactionHash, returnFormat);
const response = await rpcMethodsWrappers.getTransaction(
this,
transactionHash,
returnFormat,
);

if (!response) throw new Error('Transaction not found!');

return response;
}

public async getPendingTransactions<
Expand All @@ -227,7 +235,15 @@ export class Web3Eth extends Web3Context<Web3EthExecutionAPI, RegisteredSubscrip
public async getTransactionReceipt<
ReturnFormat extends DataFormat = typeof DEFAULT_RETURN_FORMAT,
>(transactionHash: Bytes, returnFormat: ReturnFormat = DEFAULT_RETURN_FORMAT as ReturnFormat) {
return rpcMethodsWrappers.getTransactionReceipt(this, transactionHash, returnFormat);
const response = await rpcMethodsWrappers.getTransactionReceipt(
this,
transactionHash,
returnFormat,
);

if (!response) throw new Error('Transaction not found!');

return response;
}

public async getTransactionCount<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
Uint256,
} from 'web3-utils';
import { transactionWithSender } from './rpc_methods_wrappers';
import { ReceiptInfo } from '../../src/types';

/**
* Array consists of:
Expand Down Expand Up @@ -1835,3 +1836,39 @@ export const getProofValidData: [
],
],
];

export const tx = {
blockHash: '0xb3a667f84f58c90ab87476073e06c5d1186a0f0b0b69aa3033bfe0e4df264350',
blockNumber: '123',
from: '0x01ada9d3470eb9eb3875d9e7948c674804ca43ae',
gas: '21000',
gasPrice: '10000',
hash: '0x84f44dffc3cd90a1b66ad0219a97680308e5e7a77299fbf1e2ebb572cf02cc2d',
input: '0x',
nonce: '61',
to: '0x0000000000000000000000000000000000000000',
transactionIndex: '0',
value: '1',
type: '0x01',
v: '2710',
r: '0xbefb00433ef79b2609dc560c28963c2e954370792671f71ab99665b8807b7feb',
s: '0x6bebe5e2c9f839d3ce0264dc5c7cc521f902e86705c69f5fddffaa3de5aac6d3',
};

export const txReceipt: ReceiptInfo = {
blockHash: '0xb3a667f84f58c90ab87476073e06c5d1186a0f0b0b69aa3033bfe0e4df264350',
blockNumber: BigInt(123),
cumulativeGasUsed: BigInt(21000),
effectiveGasPrice: BigInt(10000),
from: '0x01ada9d3470eb9eb3875d9e7948c674804ca43ae',
gasUsed: BigInt(21000),
logs: [],
logsBloom:
'0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
status: BigInt(1),
to: '0x0000000000000000000000000000000000000000',
transactionHash: '0x84f44dffc3cd90a1b66ad0219a97680308e5e7a77299fbf1e2ebb572cf02cc2d',
transactionIndex: BigInt(0),
type: BigInt(0),
root: '',
};
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ import {
sendSignedTransactionValidData,
signValidData,
submitWorkValidData,
tx,
txReceipt,
} from '../fixtures/web3_eth_methods_with_parameters';

jest.mock('../../src/rpc_methods');
jest.mock('../../src/rpc_method_wrappers');
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
jest.spyOn(rpcMethodWrappers, 'getTransaction').mockResolvedValue(tx);
jest.spyOn(rpcMethodWrappers, 'getTransactionReceipt').mockResolvedValue(txReceipt);

describe('web3_eth_methods_with_parameters', () => {
let web3Eth: Web3Eth;
Expand Down