Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Event aliasing for contract bindings #425

Merged
merged 6 commits into from
Sep 3, 2021
Merged

Conversation

WilfredTA
Copy link
Contributor

Motivation

Smart contracts written in Solidity can include methods and events with the same name, so long as their signatures are different.

The contract crate provides utilities for generating bindings to a contract's ABI. Because Rust does not support function overloading, these utilities enable the user to add method_aliases, which changes the function's name in the generated contract bindings.

The crate did not provide aliasing capabilities for event definitions.

Solution

The associated function add_event_alias was added to the Abigen struct within ethers-contract::ethers-contract-abigen.

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog

@WilfredTA
Copy link
Contributor Author

Note: Linter check fails because rustfmt adds a trailing comma to one of the tests which causes the test to fail.

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

Some suggestions and nits.
Tes cases look good!

Also since the self.event_aliases.get is used quite often, consider creating a function for it, fn get_event_alias or something

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

@gakonst gakonst merged commit 32ad5a6 into gakonst:master Sep 3, 2021
meetmangukiya pushed a commit to meetmangukiya/ethers-rs that referenced this pull request Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants