Permalink
Browse files

merge

  • Loading branch information...
y
y committed Oct 26, 2018
2 parents 2f1df15 + 92a68f3 commit f87a564dd7ca0358ad241a5ffbc5bcf0cc162233
Showing with 2,080 additions and 987 deletions.
  1. +29 −5 .gitlab-ci.yml
  2. +11 −11 README.rst
  3. +13 −12 build.gradle
  4. +24 −22 codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java
  5. +1 −1 codegen/src/main/java/org/web3j/codegen/TruffleJsonFunctionWrapperGenerator.java
  6. +5 −5 codegen/src/test/java/org/web3j/codegen/SolidityFunctionWrapperTest.java
  7. +1 −1 codegen/src/test/resources/solidity/arrays/build/Arrays.bin
  8. +1 −1 codegen/src/test/resources/solidity/contracts/build/HumanStandardToken.bin
  9. +1 −1 codegen/src/test/resources/solidity/contracts/build/StandardToken.bin
  10. +1 −1 codegen/src/test/resources/solidity/fibonacci/build/Fibonacci.bin
  11. +1 −1 codegen/src/test/resources/solidity/greeter/build/Greeter.bin
  12. +1 −1 codegen/src/test/resources/solidity/greeter/build/Mortal.bin
  13. +1 −1 codegen/src/test/resources/solidity/shipit/build/ShipIt.bin
  14. +1 −1 codegen/src/test/resources/solidity/simplestorage/build/SimpleStorage.bin
  15. +4 −1 config/checkstyle/checkstyle.xml
  16. +1 −1 core/build.gradle
  17. +4 −3 core/src/main/java/org/web3j/contracts/token/ERC20BasicInterface.java
  18. +3 −3 core/src/main/java/org/web3j/contracts/token/ERC20Interface.java
  19. +195 −131 core/src/main/java/org/web3j/ens/contracts/generated/ENS.java
  20. +322 −219 core/src/main/java/org/web3j/ens/contracts/generated/PublicResolver.java
  21. +2 −2 core/src/main/java/org/web3j/protocol/Service.java
  22. +5 −5 core/src/main/java/org/web3j/protocol/Web3jService.java
  23. +44 −44 core/src/main/java/org/web3j/protocol/core/JsonRpc2_0Web3j.java
  24. +5 −14 core/src/main/java/org/web3j/protocol/core/RemoteCall.java
  25. +5 −4 core/src/main/java/org/web3j/protocol/core/Request.java
  26. +18 −0 core/src/main/java/org/web3j/protocol/exceptions/TransactionException.java
  27. +38 −1 core/src/main/java/org/web3j/protocol/http/HttpService.java
  28. +4 −34 core/src/main/java/org/web3j/protocol/ipc/IpcService.java
  29. +66 −66 core/src/main/java/org/web3j/protocol/rx/JsonRpc2_0Rx.java
  30. +77 −75 core/src/main/java/org/web3j/protocol/rx/Web3jRx.java
  31. +8 −7 core/src/main/java/org/web3j/protocol/websocket/WebSocketService.java
  32. +1 −1 core/src/main/java/org/web3j/protocol/websocket/WebSocketSubscription.java
  33. +1 −1 core/src/main/java/org/web3j/tx/response/PollingTransactionReceiptProcessor.java
  34. +1 −1 core/src/main/java/org/web3j/tx/response/QueuingTransactionReceiptProcessor.java
  35. +18 −17 core/src/main/java/org/web3j/utils/{Observables.java → Flowables.java}
  36. 0 core/src/main/resources/solidity/build.sh
  37. +1 −1 core/src/main/resources/solidity/ens/build/ENS.bin
  38. +1 −1 core/src/main/resources/solidity/ens/build/PublicResolver.bin
  39. +1 −1 core/src/test/java/org/web3j/protocol/core/JsonRpc2_0Web3jTest.java
  40. +1 −1 core/src/test/java/org/web3j/protocol/core/filters/BlockFilterTest.java
  41. +6 −6 core/src/test/java/org/web3j/protocol/core/filters/FilterTester.java
  42. +1 −1 core/src/test/java/org/web3j/protocol/core/filters/LogFilterTest.java
  43. +1 −1 core/src/test/java/org/web3j/protocol/core/filters/PendingTransactionFilterTest.java
  44. +0 −7 core/src/test/java/org/web3j/protocol/ipc/IpcServiceTest.java
  45. +157 −18 core/src/test/java/org/web3j/protocol/rx/JsonRpc2_0RxTest.java
  46. +33 −35 core/src/test/java/org/web3j/protocol/websocket/WebSocketServiceTest.java
  47. +4 −1 core/src/test/java/org/web3j/tx/response/PollingTransactionReceiptProcessorTest.java
  48. +17 −17 core/src/test/java/org/web3j/utils/{ObservablesTests.java → FlowablesTests.java}
  49. +173 −0 crypto/src/main/java/org/web3j/crypto/Bip32ECKeyPair.java
  50. +78 −0 crypto/src/main/java/org/web3j/crypto/Bip44WalletUtils.java
  51. +39 −49 crypto/src/main/java/org/web3j/crypto/MnemonicUtils.java
  52. +15 −1 crypto/src/main/java/org/web3j/crypto/Sign.java
  53. +75 −0 crypto/src/test/java/org/web3j/crypto/Base58.java
  54. +159 −0 crypto/src/test/java/org/web3j/crypto/Bip32Test.java
  55. +97 −0 crypto/src/test/java/org/web3j/crypto/Bip44WalletUtilsTest.java
  56. +8 −0 crypto/src/test/java/org/web3j/crypto/SignTest.java
  57. +85 −0 crypto/src/test/java/org/web3j/crypto/StaticMnemonicUtilsTest.java
  58. +1 −1 crypto/src/test/java/org/web3j/crypto/WalletUtilsTest.java
  59. +2 −2 docs/source/conf.py
  60. +2 −2 docs/source/development.rst
  61. +20 −20 docs/source/filters.rst
  62. +10 −10 docs/source/getting_started.rst
  63. +3 −3 docs/source/smart_contracts.rst
  64. +10 −9 geth/src/main/java/org/web3j/protocol/geth/Geth.java
  65. +3 −3 geth/src/main/java/org/web3j/protocol/geth/JsonRpc2_0Geth.java
  66. +1 −1 gradle.properties
  67. +2 −1 gradle/wrapper/gradle-wrapper.properties
  68. +2 −2 integration-tests/src/test/java/org/web3j/generated/Arrays.java
  69. +8 −9 integration-tests/src/test/java/org/web3j/generated/Fibonacci.java
  70. +2 −2 integration-tests/src/test/java/org/web3j/generated/Greeter.java
  71. +13 −14 integration-tests/src/test/java/org/web3j/generated/HumanStandardToken.java
  72. +76 −43 integration-tests/src/test/java/org/web3j/generated/MetaCoin.java
  73. +2 −2 integration-tests/src/test/java/org/web3j/generated/ShipIt.java
  74. +2 −2 integration-tests/src/test/java/org/web3j/generated/SimpleStorage.java
  75. +27 −20 integration-tests/src/test/java/org/web3j/protocol/core/{ObservableIT.java → FlowableIT.java}
  76. +7 −7 integration-tests/src/test/java/org/web3j/protocol/scenarios/HumanStandardTokenGeneratedIT.java
  77. +22 −0 utils/src/main/java/org/web3j/crypto/Hash.java
@@ -1,6 +1,13 @@
image: gradle:alpine
variables:
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
cache:
paths:
@@ -10,19 +17,36 @@ cache:
stages:
- build
- test
- deploy
build:
stage: build
script:
- gradle clean build
- gradle clean build -x test
unit tests:
stage: test
script:
- gradle test
# integration tests:
publish_snapshot:
stage: deploy
script:
- gradle uploadArchives
environment:
name: publish_snapshot
when: manual
only:
- /release/.*$/
publish_release:
stage: deploy
script:
- gradle uploadArchives
# stage: test
# script:
# - $ ./gradlew -Pintegration-tests=true :integration-tests:test
environment:
name: publish_release
when: manual
only:
- master
@@ -124,7 +124,7 @@ Java 8:
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>3.5.0</version>
<version>4.0.0</version>
</dependency>
Android:
@@ -145,7 +145,7 @@ Java 8:
.. code-block:: groovy
compile ('org.web3j:core:3.5.0')
compile ('org.web3j:core:4.0.0')
Android:
@@ -203,12 +203,12 @@ To send asynchronous requests using a CompletableFuture (Future on Android):
Web3ClientVersion web3ClientVersion = web3.web3ClientVersion().sendAsync().get();
String clientVersion = web3ClientVersion.getWeb3ClientVersion();
To use an RxJava Observable:
To use an RxJava Flowable:
.. code-block:: java
Web3j web3 = Web3j.build(new HttpService()); // defaults to http://localhost:8545/
web3.web3ClientVersion().observable().subscribe(x -> {
web3.web3ClientVersion().flowable().subscribe(x -> {
String clientVersion = x.getWeb3ClientVersion();
...
});
@@ -330,15 +330,15 @@ To receive all new blocks as they are added to the blockchain:
.. code-block:: java
Subscription subscription = web3j.blockObservable(false).subscribe(block -> {
Subscription subscription = web3j.blockFlowable(false).subscribe(block -> {
...
});
To receive all new transactions as they are added to the blockchain:
.. code-block:: java
Subscription subscription = web3j.transactionObservable().subscribe(tx -> {
Subscription subscription = web3j.transactionFlowable().subscribe(tx -> {
...
});
@@ -347,21 +347,21 @@ been grouped into a block together):
.. code-block:: java
Subscription subscription = web3j.pendingTransactionObservable().subscribe(tx -> {
Subscription subscription = web3j.pendingTransactionFlowable().subscribe(tx -> {
...
});
Or, if you'd rather replay all blocks to the most current, and be notified of new subsequent
blocks being created:
.. code-block:: java
Subscription subscription = catchUpToLatestAndSubscribeToNewBlocksObservable(
Subscription subscription = replayPastAndFutureBlocksFlowable(
<startBlockNumber>, <fullTxObjects>)
.subscribe(block -> {
...
});
There are a number of other transaction and block replay Observables described in the
There are a number of other transaction and block replay Flowables described in the
`docs <http://docs.web3j.io/filters.html>`_.
Topic filters are also supported:
@@ -371,7 +371,7 @@ Topic filters are also supported:
EthFilter filter = new EthFilter(DefaultBlockParameterName.EARLIEST,
DefaultBlockParameterName.LATEST, <contract-address>)
.addSingleTopic(...)|.addOptionalTopics(..., ...)|...;
web3j.ethLogObservable(filter).subscribe(log -> {
web3j.ethLogFlowable(filter).subscribe(log -> {
...
});
@@ -576,7 +576,7 @@ To run the integration tests:
Snapshot Dependencies
---------------------
Snapshot versions of web3j follow the ``<major>.<minor>.<build>-SNAPSHOT`` convention, for example: 3.6.0-SNAPSHOT.
Snapshot versions of web3j follow the ``<major>.<minor>.<build>-SNAPSHOT`` convention, for example: 4.0.0-SNAPSHOT.
| If you would like to use snapshots instead please add a new maven repository pointing to:
@@ -4,7 +4,7 @@ buildscript {
ext.javapoetVersion = '1.7.0'
ext.jnr_unixsocketVersion = '0.15'
ext.okhttpVersion = '3.8.1'
ext.rxjavaVersion = '1.2.4'
ext.rxjavaVersion = '2.2.2'
ext.slf4jVersion = '1.7.25'
ext.javaWebSocketVersion = '1.3.8'
ext.picocliVersion = '3.0.0'
@@ -28,7 +28,9 @@ buildscript {
plugins {
id "com.jfrog.bintray" version "1.7.3"
id "net.researchgate.release" version "2.7.0"
id "org.ajoberstar.grgit" version "3.0.0-rc.2"
// TODO: sort out the tagging
// id "net.researchgate.release" version "2.7.0"
}
apply plugin: 'java'
@@ -123,8 +125,9 @@ configure(subprojects.findAll { it.name != 'integration-tests' }) {
}
ext {
ossrhUsername = project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : ''
ossrhPassword = project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : ''
ossrhUsername = project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : System.getenv('OSSRH_USERNAME')
ossrhPassword = project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : System.getenv('OSSRH_PASSWORD')
ossrhRepoUrl = project.hasProperty('ossrhRepoUrl') ? project.property('ossrhRepoUrl') : System.getenv('OSSRH_REPO_URL')
bintrayUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
bintrayKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
isSnapshotVersion = project.version.endsWith("-SNAPSHOT")
@@ -152,11 +155,10 @@ configure(subprojects.findAll { it.name != 'integration-tests' }) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
onlyIf {
ossrhUsername != '' && ossrhPassword != ''
ossrhUsername != '' && ossrhPassword != '' && ossrhRepoUrl != ''
}
String repoUrl = isSnapshotVersion ? "http://oss.sonatype.org/content/repositories/snapshots/" : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
repository(url: repoUrl) {
repository(url: ossrhRepoUrl) {
authentication(
userName: ossrhUsername,
password: ossrhPassword
@@ -229,11 +231,10 @@ configure(subprojects.findAll { it.name != 'integration-tests' }) {
}
}
release {
tagTemplate = 'v${version}'
failOnCommitNeeded = true
}
//release {
// tagTemplate = 'v${version}'
// failOnCommitNeeded = true
//}
task jacocoRootTestReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
dependsOn = subprojects.test
@@ -27,9 +27,9 @@
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import com.squareup.javapoet.TypeVariableName;
import io.reactivex.Flowable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rx.functions.Func1;
import org.web3j.abi.EventEncoder;
import org.web3j.abi.FunctionEncoder;
@@ -849,30 +849,31 @@ TypeSpec buildEventResponseObject(
return builder.build();
}
MethodSpec buildEventObservableFunction(
MethodSpec buildEventFlowableFunction(
String responseClassName,
String functionName,
List<org.web3j.codegen.SolidityFunctionWrapper.NamedTypeName> indexedParameters,
List<org.web3j.codegen.SolidityFunctionWrapper.NamedTypeName> nonIndexedParameters)
throws ClassNotFoundException {
String generatedFunctionName =
Strings.lowercaseFirstLetter(functionName) + "EventObservable";
ParameterizedTypeName parameterizedTypeName = ParameterizedTypeName.get(ClassName.get(rx
.Observable.class), ClassName.get("", responseClassName));
Strings.lowercaseFirstLetter(functionName) + "EventFlowable";
ParameterizedTypeName parameterizedTypeName =
ParameterizedTypeName.get(ClassName.get(Flowable.class),
ClassName.get("", responseClassName));
MethodSpec.Builder observableMethodBuilder =
MethodSpec.Builder flowableMethodBuilder =
MethodSpec.methodBuilder(generatedFunctionName)
.addModifiers(Modifier.PUBLIC)
.addParameter(EthFilter.class, FILTER)
.returns(parameterizedTypeName);
TypeSpec converter = TypeSpec.anonymousClassBuilder("")
.addSuperinterface(ParameterizedTypeName.get(
ClassName.get(Func1.class),
ClassName.get(io.reactivex.functions.Function.class),
ClassName.get(Log.class),
ClassName.get("", responseClassName)))
.addMethod(MethodSpec.methodBuilder("call")
.addMethod(MethodSpec.methodBuilder("apply")
.addAnnotation(Override.class)
.addModifiers(Modifier.PUBLIC)
.addParameter(Log.class, "log")
@@ -888,36 +889,37 @@ MethodSpec buildEventObservableFunction(
.build())
.build();
observableMethodBuilder
.addStatement("return web3j.ethLogObservable(filter).map($L)", converter);
flowableMethodBuilder
.addStatement("return web3j.ethLogFlowable(filter).map($L)", converter);
return observableMethodBuilder
return flowableMethodBuilder
.build();
}
MethodSpec buildDefaultEventObservableFunction(
MethodSpec buildDefaultEventFlowableFunction(
String responseClassName,
String functionName) {
String generatedFunctionName =
Strings.lowercaseFirstLetter(functionName) + "EventObservable";
ParameterizedTypeName parameterizedTypeName = ParameterizedTypeName.get(ClassName.get(rx
.Observable.class), ClassName.get("", responseClassName));
Strings.lowercaseFirstLetter(functionName) + "EventFlowable";
ParameterizedTypeName parameterizedTypeName =
ParameterizedTypeName.get(ClassName.get(Flowable.class),
ClassName.get("", responseClassName));
MethodSpec.Builder observableMethodBuilder =
MethodSpec.Builder flowableMethodBuilder =
MethodSpec.methodBuilder(generatedFunctionName)
.addModifiers(Modifier.PUBLIC)
.addParameter(DefaultBlockParameter.class, START_BLOCK)
.addParameter(DefaultBlockParameter.class, END_BLOCK)
.returns(parameterizedTypeName);
observableMethodBuilder.addStatement("$1T filter = new $1T($2L, $3L, "
flowableMethodBuilder.addStatement("$1T filter = new $1T($2L, $3L, "
+ "getContractAddress())", EthFilter.class, START_BLOCK, END_BLOCK)
.addStatement("filter.addSingleTopic($T.encode("
+ buildEventDefinitionName(functionName) + "))", EventEncoder.class)
.addStatement("return " + generatedFunctionName + "(filter)");
return observableMethodBuilder
return flowableMethodBuilder
.build();
}
@@ -993,9 +995,9 @@ MethodSpec buildEventTransactionReceiptFunction(
methods.add(buildEventTransactionReceiptFunction(responseClassName,
functionName, indexedParameters, nonIndexedParameters));
methods.add(buildEventObservableFunction(responseClassName, functionName,
methods.add(buildEventFlowableFunction(responseClassName, functionName,
indexedParameters, nonIndexedParameters));
methods.add(buildDefaultEventObservableFunction(responseClassName,
methods.add(buildDefaultEventFlowableFunction(responseClassName,
functionName));
return methods;
}
@@ -1004,7 +1006,7 @@ CodeBlock buildTypedResponse(
String objectName,
List<org.web3j.codegen.SolidityFunctionWrapper.NamedTypeName> indexedParameters,
List<org.web3j.codegen.SolidityFunctionWrapper.NamedTypeName> nonIndexedParameters,
boolean observable) {
boolean flowable) {
String nativeConversion;
if (useNativeJavaTypes) {
@@ -1014,7 +1016,7 @@ CodeBlock buildTypedResponse(
}
CodeBlock.Builder builder = CodeBlock.builder();
if (observable) {
if (flowable) {
builder.addStatement("$L.log = log", objectName);
} else {
builder.addStatement(
@@ -40,7 +40,7 @@
+ "[--javaTypes|--solidityTypes] "
+ "<input truffle json file>.json "
+ "-p|--package <base package name> "
+ "-o|--output <destination base directory>";
+ "-o|--outputDir <destination base directory>";
private String jsonFileLocation;
@@ -390,10 +390,10 @@ public void testBuildEventConstantMultipleValueReturn() throws Exception {
+ " return responses;\n"
+ " }\n"
+ "\n"
+ " public rx.Observable<TransferEventResponse> transferEventObservable(org.web3j.protocol.core.methods.request.EthFilter filter) {\n"
+ " return web3j.ethLogObservable(filter).map(new rx.functions.Func1<org.web3j.protocol.core.methods.response.Log, TransferEventResponse>() {\n"
+ " public io.reactivex.Flowable<TransferEventResponse> transferEventFlowable(org.web3j.protocol.core.methods.request.EthFilter filter) {\n"
+ " return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<org.web3j.protocol.core.methods.response.Log, TransferEventResponse>() {\n"
+ " @java.lang.Override\n"
+ " public TransferEventResponse call(org.web3j.protocol.core.methods.response.Log log) {\n"
+ " public TransferEventResponse apply(org.web3j.protocol.core.methods.response.Log log) {\n"
+ " org.web3j.tx.Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(TRANSFER_EVENT, log);\n"
+ " TransferEventResponse typedResponse = new TransferEventResponse();\n"
+ " typedResponse.log = log;\n"
@@ -407,10 +407,10 @@ public void testBuildEventConstantMultipleValueReturn() throws Exception {
+ " });\n"
+ " }\n"
+ "\n"
+ " public rx.Observable<TransferEventResponse> transferEventObservable(org.web3j.protocol.core.DefaultBlockParameter startBlock, org.web3j.protocol.core.DefaultBlockParameter endBlock) {\n"
+ " public io.reactivex.Flowable<TransferEventResponse> transferEventFlowable(org.web3j.protocol.core.DefaultBlockParameter startBlock, org.web3j.protocol.core.DefaultBlockParameter endBlock) {\n"
+ " org.web3j.protocol.core.methods.request.EthFilter filter = new org.web3j.protocol.core.methods.request.EthFilter(startBlock, endBlock, getContractAddress());\n"
+ " filter.addSingleTopic(org.web3j.abi.EventEncoder.encode(TRANSFER_EVENT));\n"
+ " return transferEventObservable(filter);\n"
+ " return transferEventFlowable(filter);\n"
+ " }\n"
+ "\n"
+ " public static class TransferEventResponse {\n"
Oops, something went wrong.

0 comments on commit f87a564

Please sign in to comment.