Search in sources :

Example 1 with Bytes32

use of org.bcos.web3j.abi.datatypes.generated.Bytes32 in project web3sdk by FISCO-BCOS.

the class Ok method getEventOrderLogEvents.

public List<EventOrderLogEventResponse> getEventOrderLogEvents(TransactionReceipt transactionReceipt) {
    final Event event = new Event("eventOrderLog", Arrays.<TypeReference<?>>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<StaticArray<Bytes32>>() {
    }, new TypeReference<StaticArray<Int256>>() {
    }, new TypeReference<Int256>() {
    }));
    List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
    ArrayList<EventOrderLogEventResponse> responses = new ArrayList<EventOrderLogEventResponse>(valueList.size());
    for (EventValues eventValues : valueList) {
        EventOrderLogEventResponse typedResponse = new EventOrderLogEventResponse();
        typedResponse.msg = (StaticArray<Bytes32>) eventValues.getNonIndexedValues().get(0);
        typedResponse.msg2 = (StaticArray<Int256>) eventValues.getNonIndexedValues().get(1);
        typedResponse.hello = (Int256) eventValues.getNonIndexedValues().get(2);
        responses.add(typedResponse);
    }
    return responses;
}
Also used : EventValues(org.bcos.web3j.abi.EventValues) Int256(org.bcos.web3j.abi.datatypes.generated.Int256) ArrayList(java.util.ArrayList) Event(org.bcos.web3j.abi.datatypes.Event) TypeReference(org.bcos.web3j.abi.TypeReference) Bytes32(org.bcos.web3j.abi.datatypes.generated.Bytes32)

Example 2 with Bytes32

use of org.bcos.web3j.abi.datatypes.generated.Bytes32 in project web3sdk by FISCO-BCOS.

the class Ok method eventOrderLogEventObservable.

public Observable<EventOrderLogEventResponse> eventOrderLogEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("eventOrderLog", Arrays.<TypeReference<?>>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<StaticArray<Bytes32>>() {
    }, new TypeReference<StaticArray<Int256>>() {
    }, new TypeReference<Int256>() {
    }));
    EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
    filter.addSingleTopic(EventEncoder.encode(event));
    return web3j.ethLogObservable(filter).map(new Func1<Log, EventOrderLogEventResponse>() {

        @Override
        public EventOrderLogEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            EventOrderLogEventResponse typedResponse = new EventOrderLogEventResponse();
            typedResponse.msg = (StaticArray<Bytes32>) eventValues.getNonIndexedValues().get(0);
            typedResponse.msg2 = (StaticArray<Int256>) eventValues.getNonIndexedValues().get(1);
            typedResponse.hello = (Int256) eventValues.getNonIndexedValues().get(2);
            return typedResponse;
        }
    });
}
Also used : EventValues(org.bcos.web3j.abi.EventValues) StaticArray(org.bcos.web3j.abi.datatypes.StaticArray) Int256(org.bcos.web3j.abi.datatypes.generated.Int256) EthFilter(org.bcos.web3j.protocol.core.methods.request.EthFilter) Log(org.bcos.web3j.protocol.core.methods.response.Log) Event(org.bcos.web3j.abi.datatypes.Event) TypeReference(org.bcos.web3j.abi.TypeReference) Bytes32(org.bcos.web3j.abi.datatypes.generated.Bytes32)

Aggregations

EventValues (org.bcos.web3j.abi.EventValues)2 TypeReference (org.bcos.web3j.abi.TypeReference)2 Event (org.bcos.web3j.abi.datatypes.Event)2 Bytes32 (org.bcos.web3j.abi.datatypes.generated.Bytes32)2 Int256 (org.bcos.web3j.abi.datatypes.generated.Int256)2 ArrayList (java.util.ArrayList)1 StaticArray (org.bcos.web3j.abi.datatypes.StaticArray)1 EthFilter (org.bcos.web3j.protocol.core.methods.request.EthFilter)1 Log (org.bcos.web3j.protocol.core.methods.response.Log)1