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

Generate the ABI elements #27

Closed
flefevre opened this issue Jul 5, 2018 · 9 comments
Closed

Generate the ABI elements #27

flefevre opened this issue Jul 5, 2018 · 9 comments

Comments

@flefevre
Copy link
Contributor

flefevre commented Jul 5, 2018

Will it be possible to generate also the ABI files in the generated folder?
It will be usefull to provide a tooling able to parse the transaction.input parameter directly?
Any idea on how to do it?

Several projects in javascritp are doint it 1

@flefevre
Copy link
Contributor Author

flefevre commented Jul 5, 2018

In fact it seems to have code to generate the ABI element, but I am not able to see any abi.json files generated in my target folder.
any idea?

@flefevre
Copy link
Contributor Author

flefevre commented Aug 7, 2018

I have added in my configuration the abi parameter, but no file has been generated...
does i miss something

			<groupId>org.web3j</groupId>
			<artifactId>web3j-maven-plugin</artifactId>
			<executions>
				<execution>
					<goals>
						<goal>generate-sources</goal>
					</goals>
					<phase>generate-sources</phase>
					<configuration>
						<packageName>com.cea.digitalworld.dwsmartcontracts</packageName>
						<sourceDestination>${project.basedir}/target/main/java</sourceDestination>
						<soliditySourceFiles>
							<directory>${project.basedir}/src/main/resources/solidity/</directory>
							<includes>
								<include>**/*.sol</include>
							</includes>
						</soliditySourceFiles>
						<abi>true</abi>
					</configuration>
				</execution>
			</executions>
		</plugin>

@flefevre
Copy link
Contributor Author

flefevre commented Aug 7, 2018

I have got the code, and replace abi default value to true, it does not generate the abi coresponding json files.
Any idea?

@flefevre
Copy link
Contributor Author

Ok, I have found at least one problem in the code.

in
Files.write(Paths.get(sourceDestination, packageName, contractName + ".json"), abiJson.getBytes());

will result in error due to the fact that the packageName directory has not been previously created.

ERROR] Could not build abi file for contract 'BCThing'
java.nio.file.NoSuchFileException: /volatile/home/fl218080/gits/fildariane/digitalworld/dwethereum/dwsmartcontracts/target/main/java/com.cea.digitalworld.dwsmartcontracts/BCThing.json
at sun.nio.fs.UnixException.translateToIOException (UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException (UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException (UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel (UnixFileSystemProvider.java:214)
at java.nio.file.spi.FileSystemProvider.newOutputStream (FileSystemProvider.java:434)
at java.nio.file.Files.newOutputStream (Files.java:216)
at java.nio.file.Files.write (Files.java:3292)
at org.web3j.mavenplugin.JavaClassGeneratorMojo.generatedAbi (JavaClassGeneratorMojo.java:169)
at org.web3j.mavenplugin.JavaClassGeneratorMojo.processResult (JavaClassGeneratorMojo.java:211)
at org.web3j.mavenplugin.JavaClassGeneratorMojo.processContractFile (JavaClassGeneratorMojo.java:159)
at org.web3j.mavenplugin.JavaClassGeneratorMojo.execute (JavaClassGeneratorMojo.java:76)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[INFO] Built Class for contract 'BCThing'

so we can update the code with

Files.write(Paths.get(sourceDestination, packageName.replace(".", "/"), contractName + ".json"), abiJson.getBytes());

so the json abi files will be located at the same place as the java source files

But I am not sure it is the right place. Because if we follow this pattern for the "binary" option generation, the solidity binaries will be located at the same place as the java source files.

moreover I think it is pertinent also to add the ABI generated files directly in the maven jar provided.
so i would like to propose to create a abi resource folder to put them

@h2mch
Copy link
Contributor

h2mch commented Aug 23, 2018

Apologizes for my absence. Holiday, "Money"work, I will check the issue and PullRequest tomorrow. But thank you already for your work!

@flefevre
Copy link
Contributor Author

flefevre commented Aug 23, 2018 via email

flefevre added a commit to flefevre/web3j-maven-plugin that referenced this issue Aug 24, 2018
@h2mch
Copy link
Contributor

h2mch commented Aug 24, 2018

With the newest version (0.3.5) it should be possible to generate abi or bin files. see the readme file

<outputFormat>java,bin</outputFormat>

@flefevre
Copy link
Contributor Author

flefevre commented Aug 24, 2018 via email

@flefevre
Copy link
Contributor Author

I close since the new version is able to generate the ABI files. An upgrade could be possible to put it a separate configurable folder.

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

2 participants