alloy-rs/core

[Bug] sol! macro does not generate enum types from JSON ABI specifications

rubydusa opened this issue · 0 comments

Component

sol! macro

What version of Alloy are you on?

0.7.0

Operating System

Linux

Describe the bug

sol! macro does not generate enum types for enums within a contract when the macro is used with a json abi.
Contract.sol:

pragma solidity ^0.8.0;

contract Contract {
    enum Enum {
        A,
        B,
        C
    }
}

main.rs:

use alloy::sol;

sol!(Contract, "src/Contract.json");

sol! {
    contract Contract2 {
        enum Enum2 {
            A2,
            B2,
            C2
        }
    }
}

// doesn't compile
fn main() {
    let a = Contract::Enum::A; // throws an error
    let a2 = Contract2::Enum2::A2; // doesn't throw an error
}

I've linked a repo so the exact json artifact I tested against is available:

https://github.com/rubydusa/alloy-json-abi-enum-bug.git