Skip to content
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 event logs with ethers.js #193

Merged
merged 6 commits into from
Mar 27, 2023
Merged

Conversation

bh2smith
Copy link
Contributor

As suggested in #182 (comment) (from PR #182) we introduce transaction log parsing via ethers library with appropriate Contract artifacts. Namely, we introduce dependencies on @cowprotocol/contracts which contain the abi files for GPv2Settlement and iERC20 and suffice for us to decode relevant event data from settlement transactions. For us these are Transfer, Settlement and Trade.

We construct Event types out of each which only keep the parts that matter for our purposes (namely TradeEvent having owner as the only relevant field).

Unit Tests are more-or-less the same (except we had to change test addresses to checksum addresses) and we also had to add some non-trivial data to our mock TradeEventLog since ethers expects to be able to parse even the irrelevant, to us, fields of a Trade.

Note that this also allowed us to remove a utility method that was previously used to manually decode raw transaction data.

Test Plan

Existing Tests

@bh2smith bh2smith added enhancement New feature or request slippage-v2 labels Feb 13, 2023
@bh2smith bh2smith mentioned this pull request Feb 13, 2023
@bh2smith bh2smith requested review from a team, fedgiac and fleupold February 13, 2023 22:24
@bh2smith bh2smith mentioned this pull request Feb 13, 2023
40 tasks
@bh2smith bh2smith changed the title Parse event logs with Ethers.js Parse event logs with ethers.js Feb 13, 2023
internal_transfers/actions/src/parse.ts Outdated Show resolved Hide resolved
internal_transfers/actions/src/parse.ts Outdated Show resolved Hide resolved
internal_transfers/actions/src/parse.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@fedgiac fedgiac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the changes! There are two comments I think are important before merging, otherwise it looks good.

internal_transfers/actions/src/parse.ts Outdated Show resolved Hide resolved
internal_transfers/actions/src/parse.ts Show resolved Hide resolved
Copy link
Contributor

@gentrexha gentrexha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, but take it with a grain of salt as I have no previous ts knowledge/experience.

bh2smith and others added 5 commits March 27, 2023 08:57
Co-authored-by: Leandro Boscariol <alfetopito@users.noreply.github.com>
Co-authored-by: Federico Giacon <58218759+fedgiac@users.noreply.github.com>
@socket-security
Copy link

New dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No new dependency issues detected in pull request

Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore foo@1.0.0 bar@* or ignore all packages with @SocketSecurity ignore-all

Pull request alert summary
Issue Status
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues

📊 Modified Dependency Overview:

➕ Added Package Capability Access +/- Transitive Count Publisher
@cowprotocol/contracts@1.3.2 network +7 cowprotocol_dev
ethers@6.0.3 network, filesystem +6 ricmoo

@bh2smith bh2smith merged commit f27c50d into action-models Mar 27, 2023
@bh2smith bh2smith deleted the ethers-parse-events branch March 27, 2023 12:11
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request slippage-v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants