diff --git a/packages/web3-core/src/web3_request_manager.ts b/packages/web3-core/src/web3_request_manager.ts index 35242c5e620..2ccbaca1e27 100644 --- a/packages/web3-core/src/web3_request_manager.ts +++ b/packages/web3-core/src/web3_request_manager.ts @@ -186,7 +186,6 @@ export class Web3RequestManager< // Check if the provider throw an error instead of reject with error response = error as JsonRpcResponse; } - return this._processJsonRpcResponse(payload, response, { legacy: false, error: false }); } diff --git a/packages/web3-eth-contract/src/contract.ts b/packages/web3-eth-contract/src/contract.ts index c7081683107..1e6ab83b382 100644 --- a/packages/web3-eth-contract/src/contract.ts +++ b/packages/web3-eth-contract/src/contract.ts @@ -721,7 +721,6 @@ export class Contract this.options, abi, filter ?? {}, - returnFormat, ); const logs = await getLogs(this, { fromBlock, toBlock, topics, address }, returnFormat); diff --git a/packages/web3-eth-contract/src/encoding.ts b/packages/web3-eth-contract/src/encoding.ts index df8a370f132..5b9bc1b6a60 100644 --- a/packages/web3-eth-contract/src/encoding.ts +++ b/packages/web3-eth-contract/src/encoding.ts @@ -15,7 +15,14 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DataFormat, DEFAULT_RETURN_FORMAT, format, isNullish } from 'web3-utils'; +import { + DataFormat, + DEFAULT_RETURN_FORMAT, + FMT_BYTES, + FMT_NUMBER, + format, + isNullish, +} from 'web3-utils'; import { AbiConstructorFragment, @@ -59,7 +66,6 @@ export const encodeEventABI = ( // eslint-disable-next-line @typescript-eslint/ban-types topics?: (null | Topic | Topic[])[]; }, - returnFormat: DataFormat = DEFAULT_RETURN_FORMAT, ) => { const opts: { filter: Filter; @@ -72,11 +78,16 @@ export const encodeEventABI = ( }; if (!isNullish(options?.fromBlock)) { - opts.fromBlock = format(blockSchema.properties.number, options?.fromBlock, returnFormat); + opts.fromBlock = format(blockSchema.properties.number, options?.fromBlock, { + number: FMT_NUMBER.HEX, + bytes: FMT_BYTES.HEX, + }); } - if (!isNullish(options?.toBlock)) { - opts.toBlock = format(blockSchema.properties.number, options?.toBlock, returnFormat); + opts.toBlock = format(blockSchema.properties.number, options?.toBlock, { + number: FMT_NUMBER.HEX, + bytes: FMT_BYTES.HEX, + }); } if (options?.topics && Array.isArray(options.topics)) { diff --git a/packages/web3-eth-contract/test/integration/contract_events.test.ts b/packages/web3-eth-contract/test/integration/contract_events.test.ts index 2d83e0f0834..209a918c05f 100644 --- a/packages/web3-eth-contract/test/integration/contract_events.test.ts +++ b/packages/web3-eth-contract/test/integration/contract_events.test.ts @@ -186,7 +186,7 @@ describe('contract', () => { describeIf(isWs)('getPastEvents', () => { // TODO: Debug why this tests is hanging the websocket - it('should return all past events', async () => { + it('should return all past events using earliest and latest options', async () => { await contractDeployed.methods .firesMultiValueEvent('New Greeting 1', 11, true) .send(sendOptions); @@ -201,5 +201,50 @@ describe('contract', () => { }), ).toHaveLength(2); }); + it('should return all past events using number options', async () => { + await contractDeployed.methods + .firesMultiValueEvent('New Greeting 1', 11, true) + .send(sendOptions); + await contractDeployed.methods + .firesMultiValueEvent('New Greeting 2', 12, true) + .send(sendOptions); + + expect( + await contractDeployed.getPastEvents('MultiValueEvent', { + fromBlock: 0, + toBlock: 1000, + }), + ).toHaveLength(2); + }); + it('should return all past events using string options', async () => { + await contractDeployed.methods + .firesMultiValueEvent('New Greeting 1', 11, true) + .send(sendOptions); + await contractDeployed.methods + .firesMultiValueEvent('New Greeting 2', 12, true) + .send(sendOptions); + + expect( + await contractDeployed.getPastEvents('MultiValueEvent', { + fromBlock: '0', + toBlock: '1000', + }), + ).toHaveLength(2); + }); + it('should return all past events using bigint options', async () => { + await contractDeployed.methods + .firesMultiValueEvent('New Greeting 1', 11, true) + .send(sendOptions); + await contractDeployed.methods + .firesMultiValueEvent('New Greeting 2', 12, true) + .send(sendOptions); + + expect( + await contractDeployed.getPastEvents('MultiValueEvent', { + fromBlock: BigInt(0), + toBlock: BigInt(1000), + }), + ).toHaveLength(2); + }); }); });