Skip to content
This repository has been archived by the owner on Aug 20, 2019. It is now read-only.

Fix overload function a bit #109

Merged
merged 2 commits into from
Mar 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/main/java/org/adridadou/ethereum/SmartContract.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -55,7 +54,7 @@ public CompletableFuture<Object[]> callFunction(String functionName, EthValue va
}

public CompletableFuture<Object[]> callFunction(EthValue value, String functionName, Object... args) {
return Optional.ofNullable(contract.getByName(functionName)).map((func) -> {
return Arrays.stream(contract.functions).filter(f-> f.name.equals(functionName) && f.inputs.length == args.length).findFirst().map((func) -> {
EthData functionCallBytes = EthData.of(func.encode(args));
return proxy.sendTx(value, functionCallBytes, account, address)
.thenApply(receipt -> contract.getByName(functionName).decodeResult(receipt.getResult().data));
Expand Down