0

I've got a contract here which works fine for the most part, but there's a problem with the whitelisting of addresses in that it doesn't fill the mapping, or the test array I added (wls) when whitelistAddresses is called. Here's the whitelist functionality, as simple as it gets:

// List of addresses who can purchase in pre-sale
mapping(address => bool) public wl;
address[] public wls;

// ...

function whitelistAddresses(address[] users) onlyOwner external {
    for (uint i = 0; i < users.length; i++) {
        wl[users[i]] = true;
        wls.push(users[i]);
        Whitelisted(users[i], true);
    }
}

If you have a test network set up, you can try deploying it locally (use the flattened IcoFlat.sol file) and seeing for yourself. Function can be called without a problem, but it refuses to do any sort of state change.

I'd like to know what the best way to debug this is. Truffle has been buggy of late (i.e. weird error messages like DocstringParsingError: Doc tag @deprecated not valid for contracts. on deployment) and Remix has been very uncooperative with Metamask with infinitely long connection attemtps and a lot of crashes on all browsers, so I'm looking for help in either solving the problem or finding a tool to use for anaylzing it more thoroughly.

1

I cannot reproduce your issue. How are you calling the function? This is the smart contract that I used to attempt reproducing your issue (gist here):

pragma solidity ^0.4.18;

contract test{
    // List of addresses who can purchase in pre-sale
    mapping(address => bool) public wl;
    address[] public wls;

    function whitelistAddresses(address[] users) external {
        for (uint i = 0; i < users.length; i++) {
            wl[users[i]] = true;
            wls.push(users[i]);
        }
    }
}

I use Remix and managed to successfully call the function passing 1 and 2 addresses which get added to the mapping and to the array.

weird error messages like DocstringParsingError: Doc tag @deprecated not valid for contracts

That sounds like you attempt to pass an unknown doc tag (the description starting with @ in the comment block before the contract that your doc parser does now know - I suggest simply removing it.

  • Re @deprecated, there was a runaway tag in another contract that is getting compiled for some reason even though it's not used. Thank you, that's been removed. I'm calling the function from Mist. I'll do some more testing and report back, thanks. – Swader Feb 9 '18 at 10:07
  • I have found the problem - the placeholder text in Mist is invalid. It is ['0x4729874r...] - it uses a single quite. Single quotes or unquoted addresses won't work. They MUST be double quoted. – Swader Feb 9 '18 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.