joshstevens19 / ethereum-abi-types-generator

Generate typings based on your ABIs, with provider wrappers exposed.
MIT License
163 stars 22 forks source link

"tuple is not valid solidty type" error for structure in arguments #21

Closed happyswap closed 3 years ago

happyswap commented 3 years ago

Hello!

Thank you for your great tool!

I get an issue with follow contract:

// SPDX-License-Identifier: MIT

pragma solidity 0.8;

struct Market {
    uint256 share;
    uint256 price;
}

struct TokenForMarket {
    Market market;
    uint256 tokenId;
}

contract Test  {

    function createMarkets(
        TokenForMarket[] memory _pool
    ) public  returns (uint) {
        return 1;
    }

}

this contract's abi return 'tuple is not valid solidty type' it happens because the argument of the function "createMarkets" is struct which contains struct.

TokenForMarket[] memory _pool it not happens when the argument is just structure Market[] memory _pool

the abi is generated by truffle.

{

  "abi": [
    {
      "inputs": [
        {
          "components": [
            {
              "components": [
                {
                  "internalType": "uint256",
                  "name": "share",
                  "type": "uint256"
                },
                {
                  "internalType": "uint256",
                  "name": "price",
                  "type": "uint256"
                }
              ],
              "internalType": "struct Market",
              "name": "market",
              "type": "tuple"
            },
            {
              "internalType": "uint256",
              "name": "tokenId",
              "type": "uint256"
            }
          ],
          "internalType": "struct TokenForMarket[]",
          "name": "_pool",
          "type": "tuple[]"
        }
      ],
      "name": "createMarkets",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "nonpayable",
      "type": "function"
    }
  ]

}
joshstevens19 commented 3 years ago

Hey thanks for raising this will look into this for you as soon as possible!

joshstevens19 commented 3 years ago

fixed in version 1.3.0