Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart Contract Wrapper Generation in error with functions with parameters without name #16

Closed
fraspadafora opened this issue Nov 15, 2016 · 4 comments

Comments

@fraspadafora
Copy link

fraspadafora commented Nov 15, 2016

Hi,
I was using web3j (0.5.1) to create the Smart Contract wrapper.
But I have this error:

Exception in thread "main" java.lang.IllegalArgumentException: not a valid name:
at com.squareup.javapoet.Util.checkArgument(Util.java:64)
at com.squareup.javapoet.ParameterSpec.builder(ParameterSpec.java:83)
at com.squareup.javapoet.MethodSpec$Builder.addParameter(MethodSpec.java:379)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.createFunctionDefinitions(SolidityFunctionWrapperGenerator.java:191)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.generateSolidityWrappers(SolidityFunctionWrapperGenerator.java:159)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.generate(SolidityFunctionWrapperGenerator.java:124)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.main(SolidityFunctionWrapperGenerator.java:66)
at com.nttdata.ethereum.marketplace.Test.main(Test.java:26)

I debugged the code, and I noticed that in the ABI there was a function like this:

{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"insuranceWithdraw","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"}

This function is created by Solidity because of I'm using a public map

mapping (address => unit) public insuranceWithdraw;

I think the best thing is to give a default name, with an increasing number.

@conor10
Copy link
Contributor

conor10 commented Nov 15, 2016

I'm presuming you updated to the latest release?

@fraspadafora
Copy link
Author

Yes, I was using an old version.

@RakeshSainiRk
Copy link

3.2 is the latest release ri8 ?

@tjanson
Copy link

tjanson commented Sep 30, 2018

The same problem occurs with unnamed event parameters. I’m guessing it’s the same underlying bug. @conor10
Example:

// HelloWorld.sol
pragma solidity ^0.4.24;


contract HelloWorld {
    event Foo(uint);
}
$ solc HelloWorld.sol --bin --abi -o ./
$ web3j solidity generate HelloWorld.bin HelloWorld.abi -o . -p org.web3j.sample

              _      _____ _     _
             | |    |____ (_)   (_)
__      _____| |__      / /_     _   ___
\ \ /\ / / _ \ '_ \     \ \ |   | | / _ \
 \ V  V /  __/ |_) |.___/ / | _ | || (_) |
  \_/\_/ \___|_.__/ \____/| |(_)|_| \___/
                         _/ |
                        |__/

Generating org.web3j.sample.HelloWorld ... Exception in thread "main" java.lang.IllegalArgumentException: not a valid name:
	at com.squareup.javapoet.Util.checkArgument(Util.java:64)
	at com.squareup.javapoet.FieldSpec.builder(FieldSpec.java:92)
	at com.squareup.javapoet.TypeSpec$Builder.addField(TypeSpec.java:499)
	at org.web3j.codegen.SolidityFunctionWrapper.buildEventResponseObject(SolidityFunctionWrapper.java:753)
	at org.web3j.codegen.SolidityFunctionWrapper.buildEventFunctions(SolidityFunctionWrapper.java:896)
	at org.web3j.codegen.SolidityFunctionWrapper.buildFunctionDefinitions(SolidityFunctionWrapper.java:255)
	at org.web3j.codegen.SolidityFunctionWrapper.generateJavaFiles(SolidityFunctionWrapper.java:130)
	at org.web3j.codegen.SolidityFunctionWrapper.generateJavaFiles(SolidityFunctionWrapper.java:111)
	at org.web3j.codegen.SolidityFunctionWrapperGenerator.generate(SolidityFunctionWrapperGenerator.java:123)
	at org.web3j.codegen.SolidityFunctionWrapperGenerator.main(SolidityFunctionWrapperGenerator.java:87)
	at org.web3j.codegen.SolidityFunctionWrapperGenerator.run(SolidityFunctionWrapperGenerator.java:48)
	at org.web3j.console.Runner.main(Runner.java:38)

Once a name is added, it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants