trufflesuite / drizzle-react-components-legacy

A set of useful components for common dapp UI elements.
96 stars 70 forks source link

Pass array as paramter to ContractForm #113

Closed Intoit82 closed 5 years ago

Intoit82 commented 5 years ago

Hi,

I am trying to pass an array of uint[] to a ContractFrom using Drizzle.

I have a simple test contract:

contract MyContract{
    uint[] myNums;

    function setNums(uint[] memory _myNums)
    public
    {
        myNums = _myNums;
    }
}

Inside my render function I have:

<ContractForm contract="MyContract" method="setNums" sendArgs ={{ from: accounts[0], gas: 3000000 }} labels={["Need an Array in here"]} />

However, as far as I understand the input cannot be an array - only numbers and texts - Is there any solution for it?

Thanks,

AndriianChestnykh commented 5 years ago

Hi @Intoit82 , I ran into the same problem a few days ago. The only solution which I figure out is to add something like case /^uint256[]/.test(type): return "text"; somewhere in this function. This will allow you to put something like [1,2,3] into as into you field of text type. That worked with no exceptions from my side.