hyperledger / web3j

Lightweight Java and Android library for integration with Ethereum clients
https://www.web3labs.com/web3j-sdk
Other
5.08k stars 1.68k forks source link

Generating wrappers with a library #1724

Open abeams opened 2 years ago

abeams commented 2 years ago

When generating wrappers for a library and contracts which use that library, is it possible to specify that structs should be imported from the library wrapper? Otherwise, each contract wrapper generates its own internal class for each struct. For example,

pragma solidity ^0.8.6;
pragma experimental ABIEncoderV2;

library TestLibrary {
    struct Pair {
        uint256 a;
        uint256 b;
    }
}

contract Test {  

    function add(TestLibrary.Pair calldata pair) external pure returns (uint256){
        return pair.a + pair.b;
    }   
}

I would like to specify that Pair is defined in a different class and should be imported.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jonathan-tan-partior commented 1 year ago

I am looking at a similar issue. The library is being generated as classes inside each contract that is using the library. Should the library (in this example, Pair) be generated as another class and then imported by other Generated Java wrappers?