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

feat: add support for multiple contract definitions in abigen macro #498

Merged
merged 5 commits into from
Oct 11, 2021

Conversation

mattsse
Copy link
Collaborator

@mattsse mattsse commented Oct 10, 2021

Motivation

This allows to use same ABIEncoderV2 structs for multiple structs.

Solution

Make abigen! parse 1+ Contract definition and then adjust for type conflicts by extracting them into a separate __shared_types module from where the contract mods then import.
contract definitions within abigen are now separated by ;, this is a non-breaking change so that abigen!(single contract) still works the same.

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog

impl Parse for Contracts {
fn parse(input: ParseStream) -> ParseResult<Self> {
let inner = input
.parse_terminated::<_, Token![;]>(ContractArgs::spanned_parse)?
Copy link
Owner

Choose a reason for hiding this comment

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

Token![;] what an insane type

@gakonst gakonst merged commit ea8551d into gakonst:master Oct 11, 2021
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.

2 participants