-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse: Tenderly Simulation Response #228
Conversation
0231a52
to
e10c0e9
Compare
e6de2ec
to
812c1e8
Compare
cc3e804
to
5eb431b
Compare
72422bd
to
53fa626
Compare
* Converts simulation result into `SimulationData` containing only the relevant fields. | ||
* @param simulation - return value from simulate method. | ||
*/ | ||
abstract parseSimulation(simulation: any): SimulationData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be great if the param is not of type any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this method belong to the abstract class.
It should be a static util, used by Tenderly implementation of the interface I suggested in #227
Instead, the method simulate
should return Promise if this is the only data you care about. So you can start with simpler closed interfaces, and add data to them based on need.
If in the future you need more data in SimulationData
you just add it, and then the static function i suggested above will require to implement the extraction of the data from the Tenderly result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, parse is usually applied if you are dividing some string, bytes and extracting some logical parts from it.
Here you are technically converging one object into another one. So i don't think you are parsing anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Parse" is to resolve something into its parts. I would say that this is exactly what we are doing here. Pruning irrelevant pieces and interpreting the response.
blockNumber: number; | ||
// Event Logs emitted within the transaction's simulation. | ||
logs: EventLog[]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im a bit confused about the structure of the project. I see a pythion project with a nodejs project inside a folder (internal_tranfer/actions
). And then there's models in the src
but also in src/simulate
For me, SimulationData
should be part of the interface of the method parseSimulation
so it should be in the same file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea. I just don't understand how to put function signatures into an interface.. until now I have only seen interfaces used to define data structures (without functionality).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im a bit confused about the structure of the project. I see a pythion project with a nodejs project inside a folder (internal_tranfer/actions).
Yes, what you are seeing is what it is.
And then there's models in the src but also in src/simulate
models inside of simulate are related only to the simulation abstraction (I thought this would keep simulation self contained). I can also easily move SimulationData
into the same file (no problem).
Merging into base because they belong together cc @anxolin |
Part of #177
In #227 we introduced a transaction simulation interface and implementation via Tenderly. This PR extends on the functionality by parsing only the relevant fields of the simulation results. In essence,
TxSimulator
interface (parseSimulation
). This functionality is separated so that we can unit test parsing without requiring an API call.parseSimulation
and test that it works as intended.