web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

Methods that require to use .request in batch calls fail typescript

Open Nilotaviano opened this issue 3 years ago • 11 comments

Same issue as: https://github.com/ChainSafe/web3.js/issues/3144

Description

To perform batch requests and add to batches we need to append .request on methods i.e

 batch.add(web3.eth.getBlock.request(blockNumber));

I believe type definitions don't have this .request option specified as it fails.

Expected behavior

Appending .request in batches should not throw type errors.

Actual behavior

Description

To perform batch requests and add to batches we need to append .request on methods i.e

 batch.add(web3.eth.getBlock.request(blockNumber));

I believe type definitions don't have this .request option specified as it fails.

Expected behavior

Appending .request in batches should not throw type errors.

Actual behavior

Screenshot 2019-10-18 at 16 55 46

Versions

  • web3.js: 2.0.0-alpha.1
  • nodejs: 10.16.3
  • browser: Chrome latest
  • ethereum node: Metamask

Nilotaviano avatar Dec 21 '21 17:12 Nilotaviano

same issue here cannot batch.add sendSignedTransaction:

batch.add(web3.eth.sendSignedTransaction.request(signedtxObjectApproval.rawTransaction .... gives ERROR: the property "request" does not exist on type PromiEvent

FreetzBB avatar Jan 05 '22 23:01 FreetzBB

@Nilotaviano Thanks for sharing this issue.

I tried the following code with 1.5.2 version and was able to reproduce the error.

import Web3 from "web3";
const web3 = new Web3(Web3.givenProvider || "http://localhost:8545");

const batch = new web3.BatchRequest();
batch.add(web3.eth.getBlock.request(1));

The detail error is:

error TS2339: Property 'request' does not exist on type '{ (blockHashOrBlockNumber: BlockNumber): Promise<BlockTransactionString>; (blockHashOrBlockNumber: BlockNumber, returnTransactionObjects: boolean): Promise<...>; (blockHashOrBlockNumber: BlockNumber, callback?: (error: Error, block: BlockTransactionString) => void): Promise<...>; (blockHashOrBlockNumber: BlockNumber...'.

We will look into this further.

nazarhussain avatar Jan 06 '22 16:01 nazarhussain

Thank you for looking into it, @nazarhussain!

Nilotaviano avatar Jan 06 '22 17:01 Nilotaviano

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Mar 08 '22 00:03 github-actions[bot]

Just chiming in to say that this is still a problem 👍

Ezzahhh avatar Mar 11 '22 05:03 Ezzahhh

same issue here cannot batch.add sendSignedTransaction:

batch.add(web3.eth.sendSignedTransaction.request(signedtxObjectApproval.rawTransaction .... gives ERROR: the property "request" does not exist on type PromiEvent

same issue when i using web3.eth.call.request(trans, callback). @nazarhussain when will there be a new update for this issue?

dattp avatar Apr 12 '22 08:04 dattp

Also running into this

alexleventer avatar May 01 '22 04:05 alexleventer

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Jul 01 '22 00:07 github-actions[bot]

According to the workload we will plan this in some future sprints. FYI @jdevcs

nazarhussain avatar Jul 01 '22 10:07 nazarhussain

While waiting for the issue to be resolved, here’s a workaround :

var batch = new web3.BatchRequest();

var getBlock: any = web3.eth.getBlock;

batch.add(getBlock.request("latest"));

aymantaybi avatar Jul 14 '22 23:07 aymantaybi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Sep 13 '22 00:09 github-actions[bot]