Skip to content
Permalink
Browse files

Merge pull request #928 from web3j/release/4.3

Post-release merge back to master: release/4.3
  • Loading branch information...
iikirilov committed Jul 8, 2019
2 parents f99ceb1 + d855fff commit 39df8f62c074d64bd88a1154719a49b06644ffb2
Showing with 2,997 additions and 122 deletions.
  1. +36 −0 .github/ISSUE_TEMPLATE/bug_report.md
  2. +14 −0 .github/ISSUE_TEMPLATE/feature_report.md
  3. +21 −0 .github/ISSUE_TEMPLATE/issue_report.md
  4. +29 −0 CONTRIBUTING.md
  5. +1 −1 console/build.gradle
  6. +3 −0 console/src/main/java/org/web3j/console/WalletSendFunds.java
  7. +21 −0 core/src/main/java/org/web3j/crypto/WalletUtils.java
  8. +11 −11 core/src/main/java/org/web3j/ens/Contracts.java
  9. +0 −1 core/src/main/java/org/web3j/ens/EnsResolver.java
  10. +5 −0 core/src/main/java/org/web3j/protocol/http/HttpService.java
  11. +2 −0 core/src/main/java/org/web3j/tx/ChainId.java
  12. +14 −0 core/src/main/java/org/web3j/tx/ChainIdLong.java
  13. +10 −0 core/src/main/java/org/web3j/tx/ClientTransactionManager.java
  14. +2 −6 core/src/main/java/org/web3j/tx/Contract.java
  15. +8 −0 core/src/main/java/org/web3j/tx/ManagedTransaction.java
  16. +16 −5 core/src/main/java/org/web3j/tx/RawTransactionManager.java
  17. +7 −0 core/src/main/java/org/web3j/tx/ReadonlyTransactionManager.java
  18. +5 −0 core/src/main/java/org/web3j/tx/TransactionManager.java
  19. +6 −4 core/src/main/java/org/web3j/tx/response/PollingTransactionReceiptProcessor.java
  20. +2 −1 core/src/main/java/org/web3j/tx/response/QueuingTransactionReceiptProcessor.java
  21. +1 −1 core/src/main/java/org/web3j/tx/response/TransactionReceiptProcessor.java
  22. +11 −0 core/src/test/java/org/web3j/crypto/WalletUtilsTest.java
  23. +3 −6 core/src/test/java/org/web3j/ens/EnsResolverTest.java
  24. +4 −2 crypto/build.gradle
  25. +1 −4 crypto/src/main/java/org/web3j/crypto/RawTransaction.java
  26. +10 −6 crypto/src/main/java/org/web3j/crypto/Sign.java
  27. +56 −0 crypto/src/main/java/org/web3j/crypto/SignatureDataOperations.java
  28. +6 −45 crypto/src/main/java/org/web3j/crypto/SignedRawTransaction.java
  29. +111 −0 crypto/src/main/java/org/web3j/crypto/StructuredData.java
  30. +448 −0 crypto/src/main/java/org/web3j/crypto/StructuredDataEncoder.java
  31. +2 −2 crypto/src/main/java/org/web3j/crypto/TransactionDecoder.java
  32. +39 −8 crypto/src/main/java/org/web3j/crypto/TransactionEncoder.java
  33. +2 −0 crypto/src/test/java/org/web3j/crypto/SampleKeys.java
  34. +409 −0 crypto/src/test/java/org/web3j/crypto/StructuredDataTest.java
  35. +1 −1 crypto/src/test/java/org/web3j/crypto/TransactionDecoderTest.java
  36. +37 −0 crypto/src/test/resources/structured_data_json_files/InvalidIdentifierStructuredData.json
  37. +46 −0 ...sources/structured_data_json_files/InvalidMessageDataNotPerfectArrayButDeclaredArrayInSchema.json
  38. +37 −0 crypto/src/test/resources/structured_data_json_files/InvalidMessageInvalidABIType.json
  39. +37 −0 ...t/resources/structured_data_json_files/InvalidMessageUnequalArrayLengthsBetweenSchemaAndData.json
  40. +37 −0 crypto/src/test/resources/structured_data_json_files/InvalidMessageValidABITypeInvalidValue.json
  41. +37 −0 crypto/src/test/resources/structured_data_json_files/InvalidMessageValueTypeMismatch.json
  42. +37 −0 crypto/src/test/resources/structured_data_json_files/InvalidTypeStructuredData.json
  43. +37 −0 crypto/src/test/resources/structured_data_json_files/ValidStructuredData.json
  44. +37 −0 crypto/src/test/resources/structured_data_json_files/ValidStructuredDataWithArrays.json
  45. +9 −0 docs/source/getting_started.rst
  46. +2 −1 docs/source/index.rst
  47. +1 −1 docs/source/modules.rst
  48. +38 −0 docs/source/nodesmith.rst
  49. +7 −0 eea/build.gradle
  50. +22 −0 eea/src/main/java/org/web3j/protocol/eea/Eea.java
  51. +47 −0 eea/src/main/java/org/web3j/protocol/eea/JsonRpc2_0Eea.java
  52. +43 −0 eea/src/main/java/org/web3j/protocol/eea/crypto/PrivateTransactionDecoder.java
  53. +93 −0 eea/src/main/java/org/web3j/protocol/eea/crypto/PrivateTransactionEncoder.java
  54. +77 −0 eea/src/main/java/org/web3j/protocol/eea/crypto/RawPrivateTransaction.java
  55. +46 −0 eea/src/main/java/org/web3j/protocol/eea/crypto/SignedRawPrivateTransaction.java
  56. +35 −0 eea/src/main/java/org/web3j/protocol/eea/response/EeaGetTransactionReceipt.java
  57. +87 −0 eea/src/main/java/org/web3j/protocol/eea/response/PrivateTransactionReceipt.java
  58. +129 −0 eea/src/main/java/org/web3j/tx/EeaTransactionManager.java
  59. +69 −0 eea/src/main/java/org/web3j/tx/PrivateTransactionManager.java
  60. +13 −0 eea/src/main/java/org/web3j/tx/gas/EeaGasProvider.java
  61. +52 −0 eea/src/main/java/org/web3j/tx/response/PollingPrivateTransactionReceiptProcessor.java
  62. +31 −0 eea/src/main/java/org/web3j/tx/response/PrivateTransactionReceiptProcessor.java
  63. +46 −0 eea/src/test/java/org/web3j/protocol/eea/RequestTest.java
  64. +95 −0 eea/src/test/java/org/web3j/protocol/eea/ResponseTest.java
  65. +122 −0 eea/src/test/java/org/web3j/protocol/eea/crypto/PrivateTransactionDecoderTest.java
  66. +42 −0 eea/src/test/java/org/web3j/protocol/eea/crypto/PrivateTransactionEncoderTest.java
  67. +1 −1 gradle.properties
  68. +6 −0 hosted-providers/build.gradle
  69. 0 {infura → hosted-providers}/src/main/java/org/web3j/protocol/infura/InfuraHttpService.java
  70. +60 −0 hosted-providers/src/main/java/org/web3j/protocol/nodesmith/NodesmithHttpService.java
  71. +68 −0 hosted-providers/src/main/java/org/web3j/protocol/nodesmith/RateLimitInfo.java
  72. 0 {infura → hosted-providers}/src/test/java/org/web3j/protocol/infura/InfuraHttpServiceTest.java
  73. +47 −0 hosted-providers/src/test/java/org/web3j/protocol/nodesmith/NodesmithHttpServiceTest.java
  74. +0 −6 infura/build.gradle
  75. +3 −3 pantheon/src/main/java/org/web3j/protocol/pantheon/JsonRpc2_0Pantheon.java
  76. +24 −3 pantheon/src/main/java/org/web3j/protocol/pantheon/Pantheon.java
  77. +4 −3 settings.gradle
  78. +19 −0 utils/src/main/java/org/web3j/crypto/Pair.java
@@ -0,0 +1,36 @@
---
name: Bug report
about: Create a report to help us improve
title: ""
labels: bug
assignees: ''

---

# _Bug_title_
_A clear and concise description of what the issue is._

## Steps To Reproduce
_Describe the exact steps or scenario to reproduce the issue._

### Expected behavior
_A clear and concise description of what you expected to happen._

### Actual behavior
_A description of the actual behavior occurring._

## Environment
_Describe the environment in which the issue occurs_
- Web3j version
- Java or Android version
- Operating System


## Additional context
_Add any other context about the problem here._
- Logs
- Sample code and/or code snippets
- Unit/integration tests to highlight the issue
- [etherscan](https://etherscan.io/) references


@@ -0,0 +1,14 @@
---
name: Feature report
about: Create a report to help us improve
title: ""
labels: enhancement
assignees: ''

---


## Feature description_
_A clear and concise description of what the feature would be._


@@ -0,0 +1,21 @@
---
name: Issue report
about: Create a report to help us improve
title: ""
labels: needs-review
assignees: ''

---


# _Issue_title_
_A clear and concise description of what the issue is._


## _Issue_description_
_Please describe what are you trying to do and why it doesn't work_


## _Issue_context_
_Please provide additional information that might be helpful_

@@ -0,0 +1,29 @@
## How to contribute to web3j

Thank you for reading this! If you'd like to report a bug or join in the buidl-ing of web3j, then here are some notes on how to do that.

#### **Did you find a bug?**

* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/web3j/web3j/issues). If there is then please add any more information that you have, or give it a :+1:. This will help us prioritize work.

* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/web3j/web3j/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or event better an **executable test case** demonstrating the expected behavior that is not occurring.

#### **Did you write a patch that fixes a bug?**

* Open a new pull request with the patch.

* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.

#### **Do you intend to add a new feature or change an existing one?**

* Suggest your change in the [gitter channel](https://gitter.im/web3j/web3j) then start writing code.

* Do not open an issue on GitHub until you have collected positive feedback about the change. GitHub issues are primarily intended for bug reports and fixes.

#### **Do you have questions about the source code?**

* Ask any question about how to use web3j should be directed to the [gitter channel](https://gitter.im/web3j/web3j)

## :heart: BUIDL :heart:

team web3j
@@ -7,7 +7,7 @@ description 'web3j command line tools'

dependencies {
compile project(':codegen'),
project(':infura'),
project(':hosted-providers'),
project(':contracts')
runtime "org.slf4j:slf4j-nop:$slf4jVersion" // prevent logging of the library to the console
testCompile project(path: ':crypto', configuration: 'testArtifacts'),
@@ -15,6 +15,7 @@
import org.web3j.protocol.exceptions.TransactionException;
import org.web3j.protocol.http.HttpService;
import org.web3j.protocol.infura.InfuraHttpService;
import org.web3j.protocol.nodesmith.NodesmithHttpService;
import org.web3j.tx.Transfer;
import org.web3j.utils.Convert;

@@ -137,6 +138,8 @@ private Web3j getEthereumClient() {
web3j = Web3j.build(new HttpService());
} else if (clientAddress.contains("infura.io")) {
web3j = Web3j.build(new InfuraHttpService(clientAddress));
} else if (clientAddress.contains("nodesmith.io")) {
web3j = Web3j.build(new NodesmithHttpService(clientAddress));
} else {
web3j = Web3j.build(new HttpService(clientAddress));
}
@@ -108,6 +108,27 @@ public static Bip39Wallet generateBip39Wallet(String password, File destinationD
return new Bip39Wallet(walletFile, mnemonic);
}

/**
* Generates a BIP-39 compatible Ethereum wallet using a mnemonic passed as argument.
*
* @param password Will be used for both wallet encryption and passphrase for BIP-39 seed
* @param mnemonic The mnemonic that will be used to generate the seed
* @param destinationDirectory The directory containing the wallet
* @return A BIP-39 compatible Ethereum wallet
* @throws CipherException if the underlying cipher is not available
* @throws IOException if the destination cannot be written to
*/
public static Bip39Wallet generateBip39WalletFromMnemonic(
String password, String mnemonic, File destinationDirectory)
throws CipherException, IOException {
byte[] seed = MnemonicUtils.generateSeed(mnemonic, password);
ECKeyPair privateKey = ECKeyPair.create(sha256(seed));

String walletFile = generateWalletFile(password, privateKey, destinationDirectory, false);

return new Bip39Wallet(walletFile, mnemonic);
}

public static Credentials loadCredentials(String password, String source)
throws IOException, CipherException {
return loadCredentials(password, new File(source));
@@ -1,6 +1,6 @@
package org.web3j.ens;

import org.web3j.tx.ChainId;
import org.web3j.tx.ChainIdLong;

/**
* ENS registry contract addresses.
@@ -12,16 +12,16 @@
public static final String RINKEBY = "0xe7410170f87102df0055eb195163a03b7f2bff4a";

public static String resolveRegistryContract(String chainId) {
switch (Byte.valueOf(chainId)) {
case ChainId.MAINNET:
return MAINNET;
case ChainId.ROPSTEN:
return ROPSTEN;
case ChainId.RINKEBY:
return RINKEBY;
default:
throw new EnsResolutionException(
"Unable to resolve ENS registry contract for network id: " + chainId);
final Long chainIdLong = Long.parseLong(chainId);
if (chainIdLong.equals(ChainIdLong.MAINNET)) {
return MAINNET;
} else if (chainIdLong.equals(ChainIdLong.ROPSTEN)) {
return ROPSTEN;
} else if (chainIdLong.equals(ChainIdLong.RINKEBY)) {
return RINKEBY;
} else {
throw new EnsResolutionException(
"Unable to resolve ENS registry contract for network id: " + chainId);
}
}
}
@@ -9,7 +9,6 @@
import org.web3j.protocol.core.methods.response.EthSyncing;
import org.web3j.protocol.core.methods.response.NetVersion;
import org.web3j.tx.ClientTransactionManager;
import org.web3j.tx.ManagedTransaction;
import org.web3j.tx.TransactionManager;
import org.web3j.tx.gas.DefaultGasProvider;
import org.web3j.utils.Numeric;
@@ -149,6 +149,7 @@ protected InputStream performIO(String request) throws IOException {
.build();

okhttp3.Response response = httpClient.newCall(httpRequest).execute();
processHeaders(response.headers());
ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
if (responseBody != null) {
@@ -164,6 +165,10 @@ protected InputStream performIO(String request) throws IOException {
}
}

protected void processHeaders(Headers headers) {
// Default implementation is empty
}

private InputStream buildInputStream(ResponseBody responseBody) throws IOException {
InputStream inputStream = responseBody.byteStream();

@@ -4,6 +4,7 @@
* Ethereum chain ids as per
* <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md">EIP-155</a>.
*/
@Deprecated
public class ChainId {
public static final byte NONE = -1;
public static final byte MAINNET = 1;
@@ -16,3 +17,4 @@
public static final byte ETHEREUM_CLASSIC_MAINNET = 61;
public static final byte ETHEREUM_CLASSIC_TESTNET = 62;
}

@@ -0,0 +1,14 @@
package org.web3j.tx;

public class ChainIdLong {
public static final long NONE = -1;
public static final long MAINNET = 1;
public static final long EXPANSE_MAINNET = 2;
public static final long ROPSTEN = 3;
public static final long RINKEBY = 4;
public static final long ROOTSTOCK_MAINNET = 30;
public static final long ROOTSTOCK_TESTNET = 31;
public static final long KOVAN = 42;
public static final long ETHEREUM_CLASSIC_MAINNET = 61;
public static final long ETHEREUM_CLASSIC_TESTNET = 62;
}
@@ -4,6 +4,7 @@
import java.math.BigInteger;

import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameter;
import org.web3j.protocol.core.methods.request.Transaction;
import org.web3j.protocol.core.methods.response.EthSendTransaction;
import org.web3j.tx.response.TransactionReceiptProcessor;
@@ -48,4 +49,13 @@ public EthSendTransaction sendTransaction(
return web3j.ethSendTransaction(transaction)
.send();
}

@Override
public String sendCall(String to, String data, DefaultBlockParameter defaultBlockParameter)
throws IOException {
return web3j.ethCall(
Transaction.createEthCallTransaction(getFromAddress(), to, data),
defaultBlockParameter)
.send().getValue();
}
}
@@ -221,13 +221,9 @@ public void setDefaultBlockParameter(DefaultBlockParameter defaultBlockParameter
private List<Type> executeCall(
Function function) throws IOException {
String encodedFunction = FunctionEncoder.encode(function);
org.web3j.protocol.core.methods.response.EthCall ethCall = web3j.ethCall(
Transaction.createEthCallTransaction(
transactionManager.getFromAddress(), contractAddress, encodedFunction),
defaultBlockParameter)
.send();

String value = ethCall.getValue();
String value = call(contractAddress, encodedFunction, defaultBlockParameter);

return FunctionReturnDecoder.decode(value, function.getOutputParameters());
}

@@ -5,6 +5,7 @@

import org.web3j.ens.EnsResolver;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameter;
import org.web3j.protocol.core.methods.response.EthGasPrice;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.protocol.exceptions.TransactionException;
@@ -87,4 +88,11 @@ protected TransactionReceipt send(
return transactionManager.executeTransaction(
gasPrice, gasLimit, to, data, value);
}

protected String call(
String to, String data, DefaultBlockParameter defaultBlockParameter)
throws IOException {

return transactionManager.sendCall(to, data, defaultBlockParameter);
}
}
@@ -8,7 +8,9 @@
import org.web3j.crypto.RawTransaction;
import org.web3j.crypto.TransactionEncoder;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameter;
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.core.methods.request.Transaction;
import org.web3j.protocol.core.methods.response.EthGetTransactionCount;
import org.web3j.protocol.core.methods.response.EthSendTransaction;
import org.web3j.tx.exceptions.TxHashMismatchException;
@@ -29,11 +31,11 @@
private final Web3j web3j;
final Credentials credentials;

private final byte chainId;
private final long chainId;

protected TxHashVerifier txHashVerifier = new TxHashVerifier();

public RawTransactionManager(Web3j web3j, Credentials credentials, byte chainId) {
public RawTransactionManager(Web3j web3j, Credentials credentials, long chainId) {
super(web3j, credentials.getAddress());

this.web3j = web3j;
@@ -43,7 +45,7 @@ public RawTransactionManager(Web3j web3j, Credentials credentials, byte chainId)
}

public RawTransactionManager(
Web3j web3j, Credentials credentials, byte chainId,
Web3j web3j, Credentials credentials, long chainId,
TransactionReceiptProcessor transactionReceiptProcessor) {
super(transactionReceiptProcessor, credentials.getAddress());

@@ -54,7 +56,7 @@ public RawTransactionManager(
}

public RawTransactionManager(
Web3j web3j, Credentials credentials, byte chainId, int attempts, long sleepDuration) {
Web3j web3j, Credentials credentials, long chainId, int attempts, long sleepDuration) {
super(web3j, attempts, sleepDuration, credentials.getAddress());

this.web3j = web3j;
@@ -104,7 +106,16 @@ public EthSendTransaction sendTransaction(

return signAndSend(rawTransaction);
}


@Override
public String sendCall(String to, String data, DefaultBlockParameter defaultBlockParameter)
throws IOException {
return web3j.ethCall(
Transaction.createEthCallTransaction(getFromAddress(), to, data),
defaultBlockParameter)
.send().getValue();
}

/*
* @param rawTransaction a RawTransaction istance to be signed
* @return The transaction signed and encoded without ever broadcasting it
@@ -4,6 +4,7 @@
import java.math.BigInteger;

import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameter;
import org.web3j.protocol.core.methods.response.EthSendTransaction;

/**
@@ -22,4 +23,10 @@ public EthSendTransaction sendTransaction(
throw new UnsupportedOperationException(
"Only read operations are supported by this transaction manager");
}

@Override
public String sendCall(String to, String data, DefaultBlockParameter defaultBlockParameter)
throws IOException {
throw new UnsupportedOperationException("Not implemented");
}
}

0 comments on commit 39df8f6

Please sign in to comment.
You can’t perform that action at this time.