You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We already have some codegen in place, but it goes one way: protobuf -> rust; abi -> rust
If you want to pass ABI events among substream modules, you need a protobuf definition for them. The way we've been doing it so far is by manually creating the protobuf message for the events we want to pass around. This works just fine if you only need to work with a handful events, but as soon as you want to start tracking everything it gets out of hand.
We should be able to generate protobuf messages for each ABI event types, and all the converting code pb<>abi.
Proposal
Generate one protobuf message for each event in the ABIs. It is possible for multiple ABIs to have the same event names, but with potentially different fields. So each message should have prepended the ABI name:
At the same time, it is possible for multiple contracts to implement the exact same events (think ERC20 standard). In this case we don't need to prepend the ABI name, but we need a way to tell if a given ABI is from an interface or from a custom contract. We could determine this from the way they are organized in the project:
NOTE: It could even be smart enough to detect which events in the contract ABIs are already in the common ABIs, so we don't need to generate them every time.
It should also generate all the rust abi to rust pb types and back
The ABI events only contain the fields included in the event, but it is common to also need additional metadata with them (block num, block hash, transaction hash, log index, etc). We could optionally enrich our pb events including all those fields . For example:
Event Transfer { from: Vec<u8>, to: Vec<u8>, amount: BigInt } (this is the rust type generated from the ABI)
You might also want to pass around event types without necessarily knowing which event is beforehand. So, for each ABI, we should also generate a oneof message with all the events from that ABI:
Related to the previous point, you might also want to decode a log into an event, only knowing that it will be one of many but without knowing exactly which.
Summary
We already have some codegen in place, but it goes one way:
protobuf -> rust; abi -> rust
If you want to pass ABI events among substream modules, you need a protobuf definition for them. The way we've been doing it so far is by manually creating the protobuf message for the events we want to pass around. This works just fine if you only need to work with a handful events, but as soon as you want to start tracking everything it gets out of hand.
We should be able to generate protobuf messages for each ABI event types, and all the converting code pb<>abi.
Proposal
Generate one protobuf message for each event in the ABIs. It is possible for multiple ABIs to have the same event names, but with potentially different fields. So each message should have prepended the ABI name:
message ATokenBurn, message StableDebtTokenBurn, message VariableDebtTokenBurn
At the same time, it is possible for multiple contracts to implement the exact same events (think ERC20 standard). In this case we don't need to prepend the ABI name, but we need a way to tell if a given ABI is from an interface or from a custom contract. We could determine this from the way they are organized in the project:
Transfer { from: Vec<u8>, to: Vec<u8>, amount: BigInt }
(this is the rust type generated from the ABI)The text was updated successfully, but these errors were encountered: