use of org.fisco.bcos.web3j.abi.TypeReference in project web3sdk by FISCO-BCOS.
the class ContractAbiUtil method decodeEvent.
/**
* @param log
* @param abiDefinition
* @return
* @throws BaseException
*/
public static EventValues decodeEvent(Log log, AbiDefinition abiDefinition) throws BaseException {
List<TypeReference<?>> finalOutputs = paramFormat(abiDefinition.getInputs());
Event event = new Event(abiDefinition.getName(), finalOutputs);
EventValues eventValues = Contract.staticExtractEventParameters(event, log);
return eventValues;
}
use of org.fisco.bcos.web3j.abi.TypeReference in project web3sdk by FISCO-BCOS.
the class CallContractTest method testAsyncCallContract.
private static void testAsyncCallContract(CallContract callContract, String address) {
TransactionCallback callback = new TransactionCallback();
TransactionReceipt receipt;
callContract.asyncSendTransaction(callback, gasPrice, gasLimit, address, "setAndget", new Utf8String("hello world"), new Int256(10086));
try {
callback.semaphore.acquire(1);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.out.println(e.getLocalizedMessage());
}
receipt = callback.receipt;
List<TypeReference<?>> referencesList = Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
}, new TypeReference<Int256>() {
});
List<Type> returnList1 = FunctionReturnDecoder.decode(receipt.getOutput(), Utils.convert(referencesList));
System.out.println("async call setAndget: " + (String) returnList1.get(0).getValue() + ", " + (BigInteger) returnList1.get(1).getValue());
callContract.asyncSendTransaction(callback, address, "setAndget", new Utf8String("hello world"), new Int256(10086));
try {
callback.semaphore.acquire(1);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.out.println(e.getLocalizedMessage());
}
receipt = callback.receipt;
referencesList = Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
}, new TypeReference<Int256>() {
});
List<Type> returnList2 = FunctionReturnDecoder.decode(receipt.getOutput(), Utils.convert(referencesList));
System.out.println("default async call setAndget: " + (String) returnList2.get(0).getValue() + ", " + (BigInteger) returnList2.get(1).getValue());
}
Aggregations