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

Event logs does not support types for indexed properties

Open nazarhussain opened this issue 3 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

Currently if we access the event properties via, property name it detects valid type.

(await myContract.events.MyEvent()).on('data', log => {
   console.log(log.returnValues.eventProp1) // will detect valid type 
   console.log(log.returnValues[0]) // will not detect valid type 
});

Expected Behavior

It should detect the type for indexed properties as well.

Steps to Reproduce

Explained above.

Web3.js Version

4.x

Environment

  • Operating System:
  • Browser:
  • Node.js Version:
  • NPM Version:

Anything Else?

I am not sure if this can be done with existing types. But can be looked into further.

nazarhussain avatar Jul 05 '22 13:07 nazarhussain

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 04 '22 00:09 github-actions[bot]

Estimated as 1. Will need to investigate and update estimate later.

mconnelly8 avatar Oct 18 '22 17:10 mconnelly8

who can resolve this issue

ViktorMachine avatar Oct 28 '22 08:10 ViktorMachine

I tested https://github.com/web3/web3.js/blob/9b15fb1fd84d92cdd503e1324b7f58614d095192/fixtures/contracts/Basic.sol#L70 and I am getting:

log.returnValues :

{
  '0': 'value',
  '1': 12n,
  '2': true,
  __length__: 3,
  str: 'value',
  val: 12n,
  flag: true
}

for tx with: firesMultiValueEvent('value', 12, true)

both for index (log.returnValues[0]) and by event prop title (log.returnValues.str) I am getting same value.

jdevcs avatar Nov 08 '22 12:11 jdevcs

Same as well, i am getting the correct types but they are both detected as unknown, will be creating an issue for adding the feature of supporting event log types from abi

luu-alex avatar Nov 08 '22 20:11 luu-alex