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

Issues generating proxies from external Truffle proj #82

Open
walshe opened this issue Oct 12, 2021 · 1 comment
Open

Issues generating proxies from external Truffle proj #82

walshe opened this issue Oct 12, 2021 · 1 comment

Comments

@walshe
Copy link

walshe commented Oct 12, 2021

Issue_title

Generate Java proxies from external Truffle project

Issue_description

I have a truffle project that has a contract that extends OpenZeppelin's ERC1155. (Which I deploy to Ganache)

        pragma solidity ^0.8.0;
        
        import "../node_modules/@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
        import "../node_modules/@openzeppelin/contracts/access/Ownable.sol";
        
        contract Items is ERC1155, Ownable {
        
            mapping(uint256 => bool) tokenIdMinted;
            
            constructor() ERC1155("http://localhost:8080/api/token-metadata/{id}") {
                
            }
        
            function mintCoupon(address owner, uint256 tokenId, uint256 amount)
                public onlyOwner
            {
                require(!tokenIdMinted[tokenId], "This token id was already minted");
                tokenIdMinted[tokenId] = true;
                _mint(owner, tokenId, amount, "");
                
            }
        }

Meanwhile I have a Java maven project where I want to interact with Ganache and the smart contract. So far I have connected to Ganache using web3j and am able to read account balances etc.

Next I need to lookup the contract on the Java side with web3j and call my custom mintCoupon function. To so this I believe I need to generate Java proxies from the .sol files. I was hoping I could do this by referencing them in the web3j plugin (unless I can point them to json abi files instead?):

<plugin>
                <groupId>org.web3j</groupId>
                <artifactId>web3j-maven-plugin</artifactId>
                <version>4.8.7</version>
                <configuration>
                    <soliditySourceFiles>
                        <directory>/Users/Emmett/dev/walsingh/seol/blockchain/ethereum/learn/</directory>
                        <includes>

                            <include>contracts/Items.sol</include>

                        </includes>
                    </soliditySourceFiles>
                    <outputFormat>java</outputFormat>
                </configuration>
            </plugin>

Anyway, when I run the maven plugin I get the following issues:

[INFO] --- web3j-maven-plugin:4.8.7:generate-sources (default-cli) @ seol ---
[INFO] Solidity: adding to process 'contracts/Items.sol'
[INFO] 	Compile Warning:
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> /Users/Emmett/dev/walsingh/seol/blockchain/ethereum/learn/contracts/Items.sol

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.629 s
[INFO] Finished at: 2021-10-12T19:49:51+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.web3j:web3j-maven-plugin:4.8.7:generate-sources (default-cli) on project seol: A type incompatibility occurred while executing org.web3j:web3j-maven-plugin:4.8.7:generate-sources: class org.json.simple.JSONArray cannot be cast to class java.lang.String (org.json.simple.JSONArray is in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @1640c151; java.lang.String is in module java.base of loader 'bootstrap')
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.web3j:web3j-maven-plugin:4.8.7
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/Emmett/.m2/repository/org/web3j/web3j-maven-plugin/4.8.7/web3j-maven-plugin-4.8.7.jar
[ERROR] urls[1] = file:/Users/Emmett/.m2/repository/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar
[ERROR] urls[2] = file:/Users/Emmett/.m2/repository/org/codehaus/plexus/plexus-utils/3.2.0/plexus-utils-3.2.0.jar
[ERROR] urls[3] = file:/Users/Emmett/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.25/plexus-interpolation-1.25.jar
[ERROR] urls[4] = file:/Users/Emmett/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[5] = file:/Users/Emmett/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[6] = file:/Users/Emmett/.m2/repository/org/apache/maven/maven-builder-support/3.6.1/maven-builder-support-3.6.1.jar
[ERROR] urls[7] = file:/Users/Emmett/.m2/repository/org/apache/maven/resolver/maven-resolver-util/1.3.3/maven-resolver-util-1.3.3.jar
[ERROR] urls[8] = file:/Users/Emmett/.m2/repository/org/apache/maven/shared/maven-shared-utils/3.2.1/maven-shared-utils-3.2.1.jar
[ERROR] urls[9] = file:/Users/Emmett/.m2/repository/commons-io/commons-io/2.5/commons-io-2.5.jar
[ERROR] urls[10] = file:/Users/Emmett/.m2/repository/org/eclipse/sisu/org.eclipse.sisu.inject/0.3.3/org.eclipse.sisu.inject-0.3.3.jar
[ERROR] urls[11] = file:/Users/Emmett/.m2/repository/com/google/inject/guice/4.2.1/guice-4.2.1-no_aop.jar
[ERROR] urls[12] = file:/Users/Emmett/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
[ERROR] urls[13] = file:/Users/Emmett/.m2/repository/com/google/guava/guava/25.1-android/guava-25.1-android.jar
[ERROR] urls[14] = file:/Users/Emmett/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar
[ERROR] urls[15] = file:/Users/Emmett/.m2/repository/org/checkerframework/checker-compat-qual/2.0.0/checker-compat-qual-2.0.0.jar
[ERROR] urls[16] = file:/Users/Emmett/.m2/repository/com/google/errorprone/error_prone_annotations/2.1.3/error_prone_annotations-2.1.3.jar
[ERROR] urls[17] = file:/Users/Emmett/.m2/repository/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar
[ERROR] urls[18] = file:/Users/Emmett/.m2/repository/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar
[ERROR] urls[19] = file:/Users/Emmett/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.7.1/plexus-component-annotations-1.7.1.jar
[ERROR] urls[20] = file:/Users/Emmett/.m2/repository/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar
[ERROR] urls[21] = file:/Users/Emmett/.m2/repository/org/apache/maven/shared/file-management/3.0.0/file-management-3.0.0.jar
[ERROR] urls[22] = file:/Users/Emmett/.m2/repository/org/apache/maven/shared/maven-shared-io/3.0.0/maven-shared-io-3.0.0.jar
[ERROR] urls[23] = file:/Users/Emmett/.m2/repository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar
[ERROR] urls[24] = file:/Users/Emmett/.m2/repository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar
[ERROR] urls[25] = file:/Users/Emmett/.m2/repository/org/web3j/codegen/4.8.7/codegen-4.8.7.jar
[ERROR] urls[26] = file:/Users/Emmett/.m2/repository/com/squareup/kotlinpoet/1.5.0/kotlinpoet-1.5.0.jar
[ERROR] urls[27] = file:/Users/Emmett/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.3.61/kotlin-reflect-1.3.61.jar
[ERROR] urls[28] = file:/Users/Emmett/.m2/repository/com/squareup/javapoet/1.7.0/javapoet-1.7.0.jar
[ERROR] urls[29] = file:/Users/Emmett/.m2/repository/info/picocli/picocli/3.0.0/picocli-3.0.0.jar
[ERROR] urls[30] = file:/Users/Emmett/.m2/repository/org/junit/platform/junit-platform-launcher/1.5.2/junit-platform-launcher-1.5.2.jar
[ERROR] urls[31] = file:/Users/Emmett/.m2/repository/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar
[ERROR] urls[32] = file:/Users/Emmett/.m2/repository/org/junit/platform/junit-platform-engine/1.5.2/junit-platform-engine-1.5.2.jar
[ERROR] urls[33] = file:/Users/Emmett/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar
[ERROR] urls[34] = file:/Users/Emmett/.m2/repository/org/junit/platform/junit-platform-commons/1.5.2/junit-platform-commons-1.5.2.jar
[ERROR] urls[35] = file:/Users/Emmett/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.5.2/junit-jupiter-engine-5.5.2.jar
[ERROR] urls[36] = file:/Users/Emmett/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.5.2/junit-jupiter-api-5.5.2.jar
[ERROR] urls[37] = file:/Users/Emmett/.m2/repository/org/junit/vintage/junit-vintage-engine/5.5.2/junit-vintage-engine-5.5.2.jar
[ERROR] urls[38] = file:/Users/Emmett/.m2/repository/org/web3j/core/4.8.7/core-4.8.7.jar
[ERROR] urls[39] = file:/Users/Emmett/.m2/repository/org/web3j/abi/4.8.7/abi-4.8.7.jar
[ERROR] urls[40] = file:/Users/Emmett/.m2/repository/org/web3j/utils/4.8.7/utils-4.8.7.jar
[ERROR] urls[41] = file:/Users/Emmett/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.68/bcprov-jdk15on-1.68.jar
[ERROR] urls[42] = file:/Users/Emmett/.m2/repository/org/web3j/crypto/4.8.7/crypto-4.8.7.jar
[ERROR] urls[43] = file:/Users/Emmett/.m2/repository/org/web3j/rlp/4.8.7/rlp-4.8.7.jar
[ERROR] urls[44] = file:/Users/Emmett/.m2/repository/org/web3j/tuples/4.8.7/tuples-4.8.7.jar
[ERROR] urls[45] = file:/Users/Emmett/.m2/repository/com/github/jnr/jnr-unixsocket/0.21/jnr-unixsocket-0.21.jar
[ERROR] urls[46] = file:/Users/Emmett/.m2/repository/com/github/jnr/jnr-ffi/2.1.9/jnr-ffi-2.1.9.jar
[ERROR] urls[47] = file:/Users/Emmett/.m2/repository/com/github/jnr/jffi/1.2.17/jffi-1.2.17.jar
[ERROR] urls[48] = file:/Users/Emmett/.m2/repository/com/github/jnr/jffi/1.2.16/jffi-1.2.16-native.jar
[ERROR] urls[49] = file:/Users/Emmett/.m2/repository/org/ow2/asm/asm/5.0.3/asm-5.0.3.jar
[ERROR] urls[50] = file:/Users/Emmett/.m2/repository/org/ow2/asm/asm-commons/5.0.3/asm-commons-5.0.3.jar
[ERROR] urls[51] = file:/Users/Emmett/.m2/repository/org/ow2/asm/asm-analysis/5.0.3/asm-analysis-5.0.3.jar
[ERROR] urls[52] = file:/Users/Emmett/.m2/repository/org/ow2/asm/asm-tree/5.0.3/asm-tree-5.0.3.jar
[ERROR] urls[53] = file:/Users/Emmett/.m2/repository/org/ow2/asm/asm-util/5.0.3/asm-util-5.0.3.jar
[ERROR] urls[54] = file:/Users/Emmett/.m2/repository/com/github/jnr/jnr-a64asm/1.0.0/jnr-a64asm-1.0.0.jar
[ERROR] urls[55] = file:/Users/Emmett/.m2/repository/com/github/jnr/jnr-x86asm/1.0.2/jnr-x86asm-1.0.2.jar
[ERROR] urls[56] = file:/Users/Emmett/.m2/repository/com/github/jnr/jnr-constants/0.9.11/jnr-constants-0.9.11.jar
[ERROR] urls[57] = file:/Users/Emmett/.m2/repository/com/github/jnr/jnr-enxio/0.19/jnr-enxio-0.19.jar
[ERROR] urls[58] = file:/Users/Emmett/.m2/repository/com/github/jnr/jnr-posix/3.0.47/jnr-posix-3.0.47.jar
[ERROR] urls[59] = file:/Users/Emmett/.m2/repository/com/squareup/okhttp3/okhttp/4.9.0/okhttp-4.9.0.jar
[ERROR] urls[60] = file:/Users/Emmett/.m2/repository/com/squareup/okio/okio/2.8.0/okio-2.8.0.jar
[ERROR] urls[61] = file:/Users/Emmett/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.4.10/kotlin-stdlib-1.4.10.jar
[ERROR] urls[62] = file:/Users/Emmett/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar
[ERROR] urls[63] = file:/Users/Emmett/.m2/repository/com/squareup/okhttp3/logging-interceptor/4.9.0/logging-interceptor-4.9.0.jar
[ERROR] urls[64] = file:/Users/Emmett/.m2/repository/io/reactivex/rxjava2/rxjava/2.2.2/rxjava-2.2.2.jar
[ERROR] urls[65] = file:/Users/Emmett/.m2/repository/org/reactivestreams/reactive-streams/1.0.2/reactive-streams-1.0.2.jar
[ERROR] urls[66] = file:/Users/Emmett/.m2/repository/org/java-websocket/Java-WebSocket/1.3.8/Java-WebSocket-1.3.8.jar
[ERROR] urls[67] = file:/Users/Emmett/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.10.0/jackson-databind-2.10.0.jar
[ERROR] urls[68] = file:/Users/Emmett/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.10.0/jackson-annotations-2.10.0.jar
[ERROR] urls[69] = file:/Users/Emmett/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.10.0/jackson-core-2.10.0.jar
[ERROR] urls[70] = file:/Users/Emmett/.m2/repository/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar
[ERROR] urls[71] = file:/Users/Emmett/.m2/repository/junit/junit/4.10/junit-4.10.jar
[ERROR] urls[72] = file:/Users/Emmett/.m2/repository/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar
[ERROR] urls[73] = file:/Users/Emmett/.m2/repository/org/web3j/web3j-sokt/0.2.1/web3j-sokt-0.2.1.jar
[ERROR] urls[74] = file:/Users/Emmett/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.61/kotlin-stdlib-jdk8-1.3.61.jar
[ERROR] urls[75] = file:/Users/Emmett/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.3.61/kotlin-stdlib-jdk7-1.3.61.jar
[ERROR] urls[76] = file:/Users/Emmett/.m2/repository/com/github/zafarkhaja/java-semver/0.9.0/java-semver-0.9.0.jar
[ERROR] urls[77] = file:/Users/Emmett/.m2/repository/org/jetbrains/kotlinx/kotlinx-serialization-runtime/0.14.0/kotlinx-serialization-runtime-0.14.0.jar
[ERROR] urls[78] = file:/Users/Emmett/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.60/kotlin-stdlib-common-1.3.60.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Process finished with exit code 1

Can anyone advise ?

Issue_context

Please provide additional information that might be helpful

@csplrj
Copy link

csplrj commented Mar 29, 2022

I also faced the same issue and found the issue. Issue is from 0.8.0 . I mean if you try this using say 0.7.6 then it will work. I guess the community has fixed the issue in web3j maven plugin snapshot version 4.8.8.SNAPSHOT version but since it is not released.

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