juanfranblanco / vscode-solidity

Visual Studio Code language support extension for Solidity smart contracts in Ethereum https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity
MIT License
903 stars 192 forks source link

USDT - Tether contract #435

Open TesoraFinancial opened 11 months ago

TesoraFinancial commented 11 months ago

Trying to generate the interface files for USDT - Tether on the Ethereum Network in order to interact with the contract, sending and receiving USDT.

Steps:

Solidity Download contract: ethereum, contract address: 0xdac17f958d2ee523a2206206994597c13d831ec7

creates the sol and abi files, then compile and generate CSharp

in the abi, you have: contract ERC20Basic { uint public _totalSupply; function totalSupply() public constant returns (uint); function balanceOf(address who) public constant returns (uint); function transfer(address to, uint value) public; event Transfer(address indexed from, address indexed to, uint value); }

Problem: the variable has an underscore with the same name as the function. The code generated removes the underscore and generates a duplicate function names.

Generated code (4 functions, 2 sets are duplicated)

    public Task<BigInteger> TotalSupplyQueryAsync(TotalSupplyFunction totalSupplyFunction, BlockParameter blockParameter = null)
    {
        return ContractHandler.QueryAsync<TotalSupplyFunction, BigInteger>(totalSupplyFunction, blockParameter);
    }

    public Task<BigInteger> TotalSupplyQueryAsync(BlockParameter blockParameter = null)
    {
        return ContractHandler.QueryAsync<TotalSupplyFunction, BigInteger>(null, blockParameter);
    }

    public Task<BigInteger> TotalSupplyQueryAsync(TotalSupplyFunction totalSupplyFunction, BlockParameter blockParameter = null)
    {
        return ContractHandler.QueryAsync<TotalSupplyFunction, BigInteger>(totalSupplyFunction, blockParameter);
    }

    public Task<BigInteger> TotalSupplyQueryAsync(BlockParameter blockParameter = null)
    {
        return ContractHandler.QueryAsync<TotalSupplyFunction, BigInteger>(null, blockParameter);
    }
juanfranblanco commented 11 months ago

Thanks, yes, that is a general issue with anti patterns on public fields. I will need to modify the code generator (brainstorming here) in this scenario to include the suffix when there is a duplicate.