polkadot-js / api

Promise and RxJS APIs around Polkadot and Substrate based chains via RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata.
Apache License 2.0
1.07k stars 354 forks source link

Events emitted from subcontract in contract->subcontract calls are decoded as events from the caller contract #3330

Open vminkov opened 3 years ago

vminkov commented 3 years ago

I will add in the comments later a repo with a simple example, but the title should be enough to get the idea - all emitted events currently are treated as events emitted from the top caller smart contract, so events from subcontract calls are wrongly decoded or fail to decode because the framework looks them up in the top caller contract ABI event index

jacogr commented 3 years ago

A reproduction with wasm/json/contract files would be great. However, can see how that happens, hence the request for compiled play-samples, to see if it is properly solvable.

vminkov commented 3 years ago

Here is a complete example, please note that contractEvents will be undefined unless fixed ( https://github.com/polkadot-js/api/pull/3324 )

The breaking code is in the Mocha files test/test.js

https://github.com/vminkov/polkadotjs-events-issue

jacogr commented 3 years ago

Yes, looking at the code quickly - there is absolutely no link between the contract and the sub ABI. So possibly need to explicitly pass all sub-ABIs through to a specific instance.

PS: Thanks for the great testcase here.