diff --git a/CHANGELOG.md b/CHANGELOG.md index e1714a8f56b..b61e7c6b019 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2225,4 +2225,9 @@ If there are any bugs, improvements, optimizations or any new feature proposal f - Dependencies updated -## [Unreleased] \ No newline at end of file +## [Unreleased] +### Added + +#### web3-types + +- `gasPrice` was added to `Transaction1559UnsignedAPI` type. (#6539) diff --git a/packages/web3-eth/src/rpc_method_wrappers.ts b/packages/web3-eth/src/rpc_method_wrappers.ts index 9a36f2dc405..7aad8d33a81 100644 --- a/packages/web3-eth/src/rpc_method_wrappers.ts +++ b/packages/web3-eth/src/rpc_method_wrappers.ts @@ -627,9 +627,8 @@ export function sendSignedTransaction< }; try { - const { v , r , s, - ...txWithoutSigParams} = unSerializedTransactionWithFrom; - + const { v, r, s, ...txWithoutSigParams } = unSerializedTransactionWithFrom; + await sendTxHelper.checkRevertBeforeSending( txWithoutSigParams as TransactionCall, ); diff --git a/packages/web3-eth/test/fixtures/validation.ts b/packages/web3-eth/test/fixtures/validation.ts index 6644167f25a..115e198ae1f 100644 --- a/packages/web3-eth/test/fixtures/validation.ts +++ b/packages/web3-eth/test/fixtures/validation.ts @@ -91,6 +91,7 @@ export const isTransaction1559UnsignedValidData = (): [Transaction1559UnsignedAP { ...transaction[0], maxFeePerGas: '0x1', + gasPrice: '0x1', maxPriorityFeePerGas: '0x1', accessList: [], }, diff --git a/packages/web3-eth/test/integration/rpc.test.ts b/packages/web3-eth/test/integration/rpc.test.ts index 7cc88dab2d7..c8d8d68d34a 100644 --- a/packages/web3-eth/test/integration/rpc.test.ts +++ b/packages/web3-eth/test/integration/rpc.test.ts @@ -264,6 +264,89 @@ describe('rpc', () => { validateTransaction(res as TransactionInfo); expect(res?.hash).toBe(receipt.transactionHash); }); + it('check get transaction fields', async () => { + const receipt0 = await web3Eth.sendTransaction({ + from: tempAcc.address, + value: '0x1', + to: tempAcc2.address, + type: BigInt(0), + }); + const res0 = await web3Eth.getTransaction(receipt0.transactionHash); + + expect(res0.type).toBeDefined(); + expect(res0.hash).toBeDefined(); + expect(res0.nonce).toBeDefined(); + expect(res0.blockHash).toBeDefined(); + expect(res0.blockNumber).toBeDefined(); + expect(res0.transactionIndex).toBeDefined(); + expect(res0.from).toBeDefined(); + expect(res0.to).toBeDefined(); + expect(res0.value).toBeDefined(); + expect(res0.gas).toBeDefined(); + expect(res0.input).toBeDefined(); + expect(res0.r).toBeDefined(); + expect(res0.s).toBeDefined(); + expect(res0.v).toBeDefined(); + expect(res0.data).toBeDefined(); + expect(res0?.hash).toBe(receipt0.transactionHash); + + expect(res0.gasPrice).toBeDefined(); + + const receipt1 = await web3Eth.sendTransaction({ + from: tempAcc.address, + value: '0x1', + maxPriorityFeePerGas: BigInt(500000000), + maxFeePerGas: BigInt(500000000), + to: tempAcc2.address, + type: BigInt(1), + }); + const res1 = await web3Eth.getTransaction(receipt1.transactionHash); + expect(res1.type).toBeDefined(); + expect(res1.hash).toBeDefined(); + expect(res1.nonce).toBeDefined(); + expect(res1.blockHash).toBeDefined(); + expect(res1.blockNumber).toBeDefined(); + expect(res1.transactionIndex).toBeDefined(); + expect(res1.from).toBeDefined(); + expect(res1.to).toBeDefined(); + expect(res1.value).toBeDefined(); + expect(res1.gas).toBeDefined(); + expect(res1.input).toBeDefined(); + expect(res1.r).toBeDefined(); + expect(res1.s).toBeDefined(); + expect(res1.data).toBeDefined(); + expect(res1?.hash).toBe(receipt1.transactionHash); + expect(res1.gasPrice).toBeDefined(); + expect(res1.accessList).toBeDefined(); + + const receipt2 = await web3Eth.sendTransaction({ + from: tempAcc.address, + value: '0x1', + to: tempAcc2.address, + type: BigInt(2), + }); + const res2 = await web3Eth.getTransaction(receipt2.transactionHash); + + expect(res2.type).toBeDefined(); + expect(res2.hash).toBeDefined(); + expect(res2.nonce).toBeDefined(); + expect(res2.blockHash).toBeDefined(); + expect(res2.blockNumber).toBeDefined(); + expect(res2.transactionIndex).toBeDefined(); + expect(res2.from).toBeDefined(); + expect(res2.to).toBeDefined(); + expect(res2.value).toBeDefined(); + expect(res2.gas).toBeDefined(); + expect(res2.input).toBeDefined(); + expect(res2.r).toBeDefined(); + expect(res2.s).toBeDefined(); + expect(res2.data).toBeDefined(); + expect(res2?.hash).toBe(receipt2.transactionHash); + expect(res2.maxFeePerGas).toBeDefined(); + expect(res2.maxPriorityFeePerGas).toBeDefined(); + expect(res2.accessList).toBeDefined(); + expect(res2.gasPrice).toBeDefined(); + }); itIf(getSystemTestBackend() !== 'ganache')('getPendingTransactions', async () => { const tx = web3Eth.sendTransaction({ diff --git a/packages/web3-eth/test/unit/web3_eth_methods_with_parameters.test.ts b/packages/web3-eth/test/unit/web3_eth_methods_with_parameters.test.ts index ace9df829cd..c2f017b24cf 100644 --- a/packages/web3-eth/test/unit/web3_eth_methods_with_parameters.test.ts +++ b/packages/web3-eth/test/unit/web3_eth_methods_with_parameters.test.ts @@ -16,6 +16,7 @@ along with web3.js. If not, see . */ import { ethRpcMethods } from 'web3-rpc-methods'; +import { TransactionInfoAPI } from 'web3-types'; import Web3Eth from '../../src/index'; import * as rpcMethodWrappers from '../../src/rpc_method_wrappers'; import { @@ -52,7 +53,7 @@ import { testData as createAccessListTestData } from './rpc_method_wrappers/fixt jest.mock('web3-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, 'getTransaction').mockResolvedValue(tx as TransactionInfoAPI); jest.spyOn(rpcMethodWrappers, 'getTransactionReceipt').mockResolvedValue(txReceipt); describe('web3_eth_methods_with_parameters', () => { diff --git a/packages/web3-types/CHANGELOG.md b/packages/web3-types/CHANGELOG.md index a526d15b3a0..97b01da0d31 100644 --- a/packages/web3-types/CHANGELOG.md +++ b/packages/web3-types/CHANGELOG.md @@ -170,4 +170,7 @@ Documentation: - Interface `EventLog` was added. (#6410) -## [Unreleased] \ No newline at end of file +## [Unreleased] + +### Added +- `gasPrice` was added to `Transaction1559UnsignedAPI` type. (#6539) diff --git a/packages/web3-types/src/apis/eth_execution_api.ts b/packages/web3-types/src/apis/eth_execution_api.ts index 9bdefe3dd43..e015e6b9ed3 100644 --- a/packages/web3-types/src/apis/eth_execution_api.ts +++ b/packages/web3-types/src/apis/eth_execution_api.ts @@ -68,27 +68,35 @@ export interface Transaction1559UnsignedAPI extends BaseTransactionAPI { readonly maxFeePerGas: Uint; readonly maxPriorityFeePerGas: Uint; readonly accessList: AccessList; + readonly gasPrice: Uint; } export interface Transaction1559SignedAPI extends Transaction1559UnsignedAPI { readonly yParity: Uint; readonly r: Uint; readonly s: Uint; + readonly v?: never; } export interface Transaction2930UnsignedAPI extends BaseTransactionAPI { readonly gasPrice: Uint; readonly accessList: AccessList; + readonly maxFeePerGas?: never; + readonly maxPriorityFeePerGas?: never; } export interface Transaction2930SignedAPI extends Transaction2930UnsignedAPI { readonly yParity: Uint; readonly r: Uint; readonly s: Uint; + readonly v?: never; } export interface TransactionLegacyUnsignedAPI extends BaseTransactionAPI { readonly gasPrice: Uint; + readonly accessList?: never; + readonly maxFeePerGas?: never; + readonly maxPriorityFeePerGas?: never; } export interface TransactionLegacySignedAPI extends TransactionLegacyUnsignedAPI {