Contract events do not trigger in Status Dapp Browser #16614
Replies: 16 comments
-
@jrainville Could you see anything special in debug logs? |
Beta Was this translation helpful? Give feedback.
-
Also which provider do you use? You should hook with status EIP1102 provider |
Beta Was this translation helpful? Give feedback.
-
Just noticed you shared a URL to test.. looking at it! |
Beta Was this translation helpful? Give feedback.
-
@jeluard I'm setting up my phone to use debug logs, but in the meantime, here's the answer for your question.
We do use the EIP1102 provider. The Dapp is built using Embark and Embark takes the available provider given by the browser (in this case Status) and calls I'll try to check by logging the provider's details if I can see the url that is used to connect to the node and confirm or not that it uses RPC. |
Beta Was this translation helpful? Give feedback.
-
Just tried debugging and there is sadly nothing in the logs. |
Beta Was this translation helpful? Give feedback.
-
Is the Status offers a EIP1102 compliant provider following JSON-RPC standard. It is based on a direct protocol, neither HTTP nor WebSocket based. As AFAIK all JSON-RPC methods are supported, all web3.js sugar should work fine. AFAIK we never got any other similar feedback from other apps. It might be worth checking using something like https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#getpastevents too? |
Beta Was this translation helpful? Give feedback.
-
We had weird web3 issues too, but never the contract events not firing. Most issues I ran into had to do with BigNumbers and other such delights. We're definitely still using |
Beta Was this translation helpful? Give feedback.
-
Oops, just tested again, and while it worked when I tested last time, I might have overwritten the working version. Going to update it right away. Sorry about that. |
Beta Was this translation helpful? Give feedback.
-
Ok, I just "fixed" the Dapp. Basically, the event handler was giving an error in Status that I didn't handle.
This error tells me that web3 just doesn't support events with the current provider. We checked the status-react code and it seems you use your own Provider (https://github.com/status-im/status-react/blob/40aff1da8dc29d961ca806d2b81bcb874f7e4223/resources/js/web3_opt_in.js#L118) You might need to extend from Web3's WS provider. |
Beta Was this translation helpful? Give feedback.
-
This happens if you call write methods before the successful return and user ack of |
Beta Was this translation helpful? Give feedback.
-
Possible. It is not the case in my example though, since, as you can see here https://github.com/jrainville/events-test/blob/master/app/js/index.js#L16, I only call the event registration once For clarity, |
Beta Was this translation helpful? Give feedback.
-
So to be clear, status-react providers are NOT using websockets. In order to fix this, then we need to use them, correct? |
Beta Was this translation helpful? Give feedback.
-
That's my understanding of the problem yes. The Status-React providers are completely custom so they probably need WS support just like Web3js' Websocket provider (https://github.com/ethereum/web3.js/blob/2.x/packages/web3-providers/src/providers/WebsocketProvider.js) One way to do it would be to find a way to extend the Web3's WS provider like
Or maybe to make the Status-React use the WS provider and just "override" the send functions, a bit like we do in Embark: https://github.com/embark-framework/embark/blob/master/packages/embark-blockchain-connector/src/provider.js#L134 |
Beta Was this translation helpful? Give feedback.
-
this isn't a terribly security sensitive issue. I ask because of V1 audit scope. Events processing in dapps is pretty big though for usability and interactivity within the app. |
Beta Was this translation helpful? Give feedback.
-
More context in #10809 |
Beta Was this translation helpful? Give feedback.
-
Moving to discussion, since this requires probalby a bit more effort |
Beta Was this translation helpful? Give feedback.
-
User Story
As a developer, I want to contract events to trigger so that we can have more interactivity in the Dapp.
Description
Type: Bug
Summary: Experienced in the Status Teller Network, web3js contract events never trigger in the Status Dapp browser, but they do work in normal browsers with Metamask (probably because Status doesn't use websocket [WS] to connect to the node)
Expected behavior
Using contract events (https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#events), should call the callback when the contract interaction happens.
Actual behavior
Nothing happens, the callback is never called.
Reproduction
I created this simple Dapp that has a simple Storage contract: https://jrainville.github.io/events-test/dist/
Set
field and press "Set"-> There will be no event triggered at the bottom
If you try again in a desktop browser with Metamask (also in Rinkeby), you will see the number you set in the field appear in the Events section
Solution
I'm thinking that Status connects to the blockchain node using RPC only , but RPC doesn't not support events. It should however connect to the node using WS (see Web3js' docs for differences between the providers: https://web3js.readthedocs.io/en/1.0/web3.html#providers)
Additional Information
Beta Was this translation helpful? Give feedback.
All reactions