-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Support codegen directly from Truffle json contract files #228
Conversation
Changes were made to master after this fork and before the commit of the Truffle import functionality.
Codecov Report
@@ Coverage Diff @@
## master #228 +/- ##
============================================
- Coverage 77.32% 76.82% -0.51%
- Complexity 1534 1558 +24
============================================
Files 209 211 +2
Lines 5580 5731 +151
Branches 895 908 +13
============================================
+ Hits 4315 4403 +88
- Misses 1066 1119 +53
- Partials 199 209 +10
Continue to review full report at Codecov.
|
Seems unfair: My pull request is getting penalized because it picked up (and merged in) changes made by Conor, notably additions to the code that didn't include tests to cover that new code. |
assertThat(toCsv(Collections.singletonList("a")), is("a")); | ||
assertThat(toCsv(Arrays.asList("a", "b", "c")), is("a, b, c")); | ||
} | ||
|
||
@Test | ||
public void testJoin() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come you removed this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That test was removed because I removed the Strings.join method since Java has a static String.join() method https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#join-java.lang.CharSequence-java.lang.CharSequence...- but again, if this is targetting JDK 1.6, then... whoops, undo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@conor10 : do I need to put back in the hand-rolled Strings.join() utility method to support JDK 1.6 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave the test in.
You can update the join util to be:
public static String join(List<String> src, String delimiter) {
return src == null ? null : String.join(delimiter, src.toArray(new String[0]));
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
When I checked usages, the only place the code referenced that method is in the Strings
utility class itself. The toCsv()
method was calling it.
@@ -19,16 +21,11 @@ | |||
|
|||
@Test | |||
public void testToCsv() { | |||
assertThat(toCsv(Collections.<String>emptyList()), is("")); | |||
assertThat(toCsv(Collections.emptyList()), is("")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameterized value is so that this function works with Java 1.6 in the Android branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android. Ah-ha. Maybe it's better then to change the gradle file to require Java v 1.6 ? (Unless I missed it, I may have only checked the top-level config and not the module's config.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to change these lines in the root build.gradle file:
sourceCompatibility = 1.8
targetCompatibility = 1.8
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consciously make these changes, or is your local gradle wrapper once downloaded different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry about that. I thought I'd excluded the gradle wrapper folder entirely. Accident on my side if so.
Side note (and why I missed it): I always include it in my .ignore file since i view keeping the build tool in the repo as ... weird, rather I just have a gradle wrapper command to run when first pulling. Of course that means I've installed gradle, but then, most envs require you install the build tool. If some user is developing java they've already downloaded the JDK - and not just the JRE - and so they're 90% there.
* Subclasses should implement this method to return pre-existing addresses for deployed | ||
* contracts. | ||
* | ||
* @param networkId the network id, for example "1" for the main-net, "3" for ropsten, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could put a link to the org.web3j.tx.ChainId class in this Javadoc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually searched the code base for ropsten, but I think I forgot to make it a case insensitive search. Hadn't seen ChainId. Curious why not just make that an enum?
Also, ChainId values are bytes, but the max value of a byte is 255 (unsigned). And the doc referenced actually shows 1337 as one of the recommended ids.
Shall we change ChainId to an enum and make the values int or, better, long ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for using a byte, is to support EIP-155, where you place a byte value in the raw transaction object - see here.
That being said further down the discussion in the original EIP it is mentioned that the v value when the transaction is RLP encoded shouldn't be limited to a single byte. So web3j could be enhanced to accomodate this. I've created a separate issue for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool.
A few comments inline.
Please could you also update the docs with details too?
Specifically:
https://github.com/web3j/web3j#features
https://github.com/web3j/web3j#working-with-smart-contracts-with-java-smart-contract-wrappers
https://github.com/web3j/web3j/blob/master/docs/source/smart_contracts.rst#solidity-smart-contract-wrappers
updating. i don't have the tools installed to build the docs, so here's hoping my edits are good |
atching up with changes since this fork was made.
A fair point - however, as the Java 6 version of toCsv is lengthier, I'd
rather keep the two underlying functions.
…On 10 November 2017 at 17:45, Ezra Epstein ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In utils/src/test/java/org/web3j/utils/StringsTest.java
<#228 (comment)>:
> assertThat(toCsv(Collections.singletonList("a")), is("a"));
assertThat(toCsv(Arrays.asList("a", "b", "c")), is("a, b, c"));
}
-
- @test
- public void testJoin() {
Will do.
When I checked usages, the only place the code referenced that method is
in the Strings utility class itself. The toCsv() method was calling it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#228 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACDHqiQox3pwEu1_LyVTSSQYPUU1HYuVks5s1IvDgaJpZM4QXc1D>
.
--
Web: http://conorsvensson.com
Phone: +44 7497 376 365
Skype: conor_svensson
|
Thanks again @eepstein, this is a great enhancement. |
Support codegen directly from Truffle json contract files
See #226 .
This allows tighter integration of web3j tools with the Truffle suite so that there's more assurance code will work across both libraries.