Skip to content

Commit

Permalink
1. Updated block/transaction replay Observables to use DefaultBlockPa…
Browse files Browse the repository at this point in the history
…rameters instead of BigInteger values.

2. Added additional catchup replay Observables
3. Changed Ether value parameter to Wei value in contract wrappers.
4. Regenerated Solidity wrapper classes.
  • Loading branch information
conor10 committed May 16, 2017
1 parent cca8c8e commit 7f4a5ce
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 84 deletions.
10 changes: 5 additions & 5 deletions src/integration-test/java/org/web3j/generated/Arrays.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.web3j.tx.TransactionManager;

/**
* <p>Auto generated code.<br>
* Auto generated code.<br>
* <strong>Do not modify!</strong><br>
* Please use {@link org.web3j.codegen.SolidityFunctionWrapperGenerator} to update.
*
Expand All @@ -43,12 +43,12 @@ public Future<TransactionReceipt> dynamicReverse(DynamicArray<Uint256> input) {
return executeTransactionAsync(function);
}

public static Future<Arrays> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialEtherValue) {
return deployAsync(Arrays.class, web3j, credentials, gasPrice, gasLimit, BINARY, "", initialEtherValue);
public static Future<Arrays> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue) {
return deployAsync(Arrays.class, web3j, credentials, gasPrice, gasLimit, BINARY, "", initialWeiValue);
}

public static Future<Arrays> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialEtherValue) {
return deployAsync(Arrays.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "", initialEtherValue);
public static Future<Arrays> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue) {
return deployAsync(Arrays.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "", initialWeiValue);
}

public static Arrays load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
Expand Down
8 changes: 4 additions & 4 deletions src/integration-test/java/org/web3j/generated/Fibonacci.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ public Future<Uint256> fibonacci(Uint256 number) {
return executeCallSingleValueReturnAsync(function);
}

public static Future<Fibonacci> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialEtherValue) {
return deployAsync(Fibonacci.class, web3j, credentials, gasPrice, gasLimit, BINARY, "", initialEtherValue);
public static Future<Fibonacci> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue) {
return deployAsync(Fibonacci.class, web3j, credentials, gasPrice, gasLimit, BINARY, "", initialWeiValue);
}

public static Future<Fibonacci> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialEtherValue) {
return deployAsync(Fibonacci.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "", initialEtherValue);
public static Future<Fibonacci> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue) {
return deployAsync(Fibonacci.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "", initialWeiValue);
}

public static Fibonacci load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
Expand Down
10 changes: 5 additions & 5 deletions src/integration-test/java/org/web3j/generated/Greeter.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.web3j.tx.TransactionManager;

/**
* <p>Auto generated code.<br>
* Auto generated code.<br>
* <strong>Do not modify!</strong><br>
* Please use {@link org.web3j.codegen.SolidityFunctionWrapperGenerator} to update.
*
Expand Down Expand Up @@ -45,14 +45,14 @@ public Future<Utf8String> greet() {
return executeCallSingleValueReturnAsync(function);
}

public static Future<Greeter> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialEtherValue, Utf8String _greeting) {
public static Future<Greeter> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue, Utf8String _greeting) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(_greeting));
return deployAsync(Greeter.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor, initialEtherValue);
return deployAsync(Greeter.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor, initialWeiValue);
}

public static Future<Greeter> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialEtherValue, Utf8String _greeting) {
public static Future<Greeter> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue, Utf8String _greeting) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(_greeting));
return deployAsync(Greeter.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor, initialEtherValue);
return deployAsync(Greeter.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor, initialWeiValue);
}

public static Greeter load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import rx.functions.Func1;

/**
* <p>Auto generated code.<br>
* Auto generated code.<br>
* <strong>Do not modify!</strong><br>
* Please use {@link org.web3j.codegen.SolidityFunctionWrapperGenerator} to update.
*
Expand All @@ -51,9 +51,9 @@ public List<TransferEventResponse> getTransferEvents(TransactionReceipt transact
final Event event = new Event("Transfer",
Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Address>() {}),
Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
List<EventValues> valueList = extractEventParameters(event,transactionReceipt);
List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
ArrayList<TransferEventResponse> responses = new ArrayList<TransferEventResponse>(valueList.size());
for(EventValues eventValues : valueList) {
for (EventValues eventValues : valueList) {
TransferEventResponse typedResponse = new TransferEventResponse();
typedResponse._from = (Address) eventValues.getIndexedValues().get(0);
typedResponse._to = (Address) eventValues.getIndexedValues().get(1);
Expand Down Expand Up @@ -86,9 +86,9 @@ public List<ApprovalEventResponse> getApprovalEvents(TransactionReceipt transact
final Event event = new Event("Approval",
Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Address>() {}),
Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
List<EventValues> valueList = extractEventParameters(event,transactionReceipt);
List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
ArrayList<ApprovalEventResponse> responses = new ArrayList<ApprovalEventResponse>(valueList.size());
for(EventValues eventValues : valueList) {
for (EventValues eventValues : valueList) {
ApprovalEventResponse typedResponse = new ApprovalEventResponse();
typedResponse._owner = (Address) eventValues.getIndexedValues().get(0);
typedResponse._spender = (Address) eventValues.getIndexedValues().get(1);
Expand Down Expand Up @@ -186,14 +186,14 @@ public Future<Uint256> allowance(Address _owner, Address _spender) {
return executeCallSingleValueReturnAsync(function);
}

public static Future<HumanStandardToken> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialEtherValue, Uint256 _initialAmount, Utf8String _tokenName, Uint8 _decimalUnits, Utf8String _tokenSymbol) {
public static Future<HumanStandardToken> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue, Uint256 _initialAmount, Utf8String _tokenName, Uint8 _decimalUnits, Utf8String _tokenSymbol) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol));
return deployAsync(HumanStandardToken.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor, initialEtherValue);
return deployAsync(HumanStandardToken.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor, initialWeiValue);
}

public static Future<HumanStandardToken> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialEtherValue, Uint256 _initialAmount, Utf8String _tokenName, Uint8 _decimalUnits, Utf8String _tokenSymbol) {
public static Future<HumanStandardToken> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue, Uint256 _initialAmount, Utf8String _tokenName, Uint8 _decimalUnits, Utf8String _tokenSymbol) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol));
return deployAsync(HumanStandardToken.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor, initialEtherValue);
return deployAsync(HumanStandardToken.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor, initialWeiValue);
}

public static HumanStandardToken load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
Expand Down
10 changes: 5 additions & 5 deletions src/integration-test/java/org/web3j/generated/ShipIt.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.web3j.tx.TransactionManager;

/**
* <p>Auto generated code.<br>
* Auto generated code.<br>
* <strong>Do not modify!</strong><br>
* Please use {@link org.web3j.codegen.SolidityFunctionWrapperGenerator} to update.
*
Expand All @@ -42,12 +42,12 @@ public Future<List<Type>> shipments(Address param0) {
return executeCallMultipleValueReturnAsync(function);
}

public static Future<ShipIt> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialEtherValue) {
return deployAsync(ShipIt.class, web3j, credentials, gasPrice, gasLimit, BINARY, "", initialEtherValue);
public static Future<ShipIt> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue) {
return deployAsync(ShipIt.class, web3j, credentials, gasPrice, gasLimit, BINARY, "", initialWeiValue);
}

public static Future<ShipIt> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialEtherValue) {
return deployAsync(ShipIt.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "", initialEtherValue);
public static Future<ShipIt> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue) {
return deployAsync(ShipIt.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "", initialWeiValue);
}

public static ShipIt load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public void testLogObservable() throws Exception {

@Test
public void testReplayObservable() throws Exception {
run(web3j.replayBlocksObservable(BigInteger.ZERO, BigInteger.valueOf(EVENT_COUNT), true));
run(web3j.replayBlocksObservable(
new DefaultBlockParameterNumber(0),
new DefaultBlockParameterNumber(EVENT_COUNT), true));
}

@Test
Expand All @@ -67,7 +69,8 @@ public void testCatchUpToLatestAndSubscribeToNewBlocksObservable() throws Except
.send();
BigInteger latestBlockNumber = ethBlock.getBlock().getNumber();
run(web3j.catchUpToLatestAndSubscribeToNewBlocksObservable(
latestBlockNumber.subtract(BigInteger.ONE), false));
new DefaultBlockParameterNumber(latestBlockNumber.subtract(BigInteger.ONE)),
false));
}

private <T> void run(Observable<T> observable) throws Exception {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public class SolidityFunctionWrapper {
private static final String WEB3J = "web3j";
private static final String CREDENTIALS = "credentials";
private static final String TRANSACTION_MANAGER = "transactionManager";
private static final String INITIAL_VALUE = "initialEtherValue";
private static final String INITIAL_VALUE = "initialWeiValue";
private static final String CONTRACT_ADDRESS = "contractAddress";
private static final String GAS_PRICE = "gasPrice";
private static final String GAS_LIMIT = "gasLimit";
private static final String START_BLOCK = "startBlock";
private static final String END_BLOCK = "endBlock";

private static final String CODEGEN_WARNING = "<p>Auto generated code.<br>\n" +
private static final String CODEGEN_WARNING = "Auto generated code.<br>\n" +
"<strong>Do not modify!</strong><br>\n" +
"Please use {@link " + SolidityFunctionWrapperGenerator.class.getName() +
"} to update.\n";
Expand Down Expand Up @@ -449,12 +449,12 @@ static MethodSpec buildEventTransactionReceiptFunction(String responseClassName,
buildVariableLengthEventConstructor(
transactionMethodBuilder, functionName, indexedParameters, nonIndexedParameters);

transactionMethodBuilder.addStatement("$T valueList = extractEventParameters(event," +
transactionMethodBuilder.addStatement("$T valueList = extractEventParameters(event, " +
"transactionReceipt)", ParameterizedTypeName.get(List.class, EventValues.class))
.addStatement("$1T responses = new $1T(valueList.size())",
ParameterizedTypeName.get(ClassName.get(ArrayList.class),
ClassName.get("", responseClassName)))
.beginControlFlow("for($T eventValues : valueList)", EventValues.class)
.beginControlFlow("for ($T eventValues : valueList)", EventValues.class)
.addStatement("$1T typedResponse = new $1T()",
ClassName.get("", responseClassName))
.addCode(buildTypedResponse("typedResponse", indexedParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ public DefaultBlockParameterNumber(long blockNumber) {
public String getValue() {
return Numeric.encodeQuantity(blockNumber);
}

public BigInteger getBlockNumber() {
return blockNumber;
}
}
33 changes: 23 additions & 10 deletions src/main/java/org/web3j/protocol/core/JsonRpc2_0Web3j.java
Original file line number Diff line number Diff line change
Expand Up @@ -780,37 +780,50 @@ public Observable<EthBlock> blockObservable(boolean fullTransactionObjects) {

@Override
public Observable<EthBlock> replayBlocksObservable(
BigInteger startBlockNumber, BigInteger endBlockNumber, boolean fullTransactionObjects) {
return web3jRx.replayBlocksObservable(startBlockNumber, endBlockNumber, fullTransactionObjects);
DefaultBlockParameter startBlock, DefaultBlockParameter endBlock,
boolean fullTransactionObjects) {
return web3jRx.replayBlocksObservable(startBlock, endBlock, fullTransactionObjects);
}

@Override
public Observable<org.web3j.protocol.core.methods.response.Transaction>
replayTransactionsObservable(
BigInteger startBlockNumber, BigInteger endBlockNumber) {
return web3jRx.replayTransactionsObservable(startBlockNumber, endBlockNumber);
DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
return web3jRx.replayTransactionsObservable(startBlock, endBlock);
}

@Override
public Observable<EthBlock> catchUpToLatestBlockObservable(
BigInteger startBlockNumber, boolean fullTransactionObjects,
DefaultBlockParameter startBlock, boolean fullTransactionObjects,
Observable<EthBlock> onCompleteObservable) {
return web3jRx.catchUpToLatestBlockObservable(
startBlockNumber, fullTransactionObjects, onCompleteObservable);
startBlock, fullTransactionObjects, onCompleteObservable);
}

@Override
public Observable<EthBlock> catchUpToLatestBlockObservable(
DefaultBlockParameter startBlock, boolean fullTransactionObjects) {
return web3jRx.catchUpToLatestBlockObservable(startBlock, fullTransactionObjects);
}

@Override
public Observable<org.web3j.protocol.core.methods.response.Transaction>
catchUpToLatestTransactionObservable(DefaultBlockParameter startBlock) {
return web3jRx.catchUpToLatestTransactionObservable(startBlock);
}

@Override
public Observable<EthBlock> catchUpToLatestAndSubscribeToNewBlocksObservable(
BigInteger startBlockNumber, boolean fullTransactionObjects) {
DefaultBlockParameter startBlock, boolean fullTransactionObjects) {
return web3jRx.catchUpToLatestAndSubscribeToNewBlocksObservable(
startBlockNumber, fullTransactionObjects, blockTime);
startBlock, fullTransactionObjects, blockTime);
}

@Override
public Observable<org.web3j.protocol.core.methods.response.Transaction>
catchUpToLatestAndSubscribeToNewTransactionsObservable(
BigInteger startBlockNumber) {
DefaultBlockParameter startBlock) {
return web3jRx.catchUpToLatestAndSubscribeToNewTransactionsObservable(
startBlockNumber, blockTime);
startBlock, blockTime);
}
}
Loading

0 comments on commit 7f4a5ce

Please sign in to comment.