Search in sources :

Example 6 with EventValues

use of org.bcos.web3j.abi.EventValues in project web3sdk by FISCO-BCOS.

the class ConfigAction method logMessageEventObservable.

public Observable<LogMessageEventResponse> logMessageEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("LogMessage", Arrays.<TypeReference<?>>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {
    }, new TypeReference<Uint256>() {
    }, new TypeReference<Utf8String>() {
    }));
    EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
    filter.addSingleTopic(EventEncoder.encode(event));
    return web3j.ethLogObservable(filter).map(new Func1<Log, LogMessageEventResponse>() {

        @Override
        public LogMessageEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            LogMessageEventResponse typedResponse = new LogMessageEventResponse();
            typedResponse.addr = (Address) eventValues.getNonIndexedValues().get(0);
            typedResponse.code = (Uint256) eventValues.getNonIndexedValues().get(1);
            typedResponse.msg = (Utf8String) eventValues.getNonIndexedValues().get(2);
            return typedResponse;
        }
    });
}
Also used : EventValues(org.bcos.web3j.abi.EventValues) EthFilter(org.bcos.web3j.protocol.core.methods.request.EthFilter) Utf8String(org.bcos.web3j.abi.datatypes.Utf8String) Address(org.bcos.web3j.abi.datatypes.Address) Log(org.bcos.web3j.protocol.core.methods.response.Log) Event(org.bcos.web3j.abi.datatypes.Event) TypeReference(org.bcos.web3j.abi.TypeReference) Uint256(org.bcos.web3j.abi.datatypes.generated.Uint256)

Example 7 with EventValues

use of org.bcos.web3j.abi.EventValues in project web3sdk by FISCO-BCOS.

the class ContractAbiMgr method getAbiNotExistEvents.

public static List<AbiNotExistEventResponse> getAbiNotExistEvents(TransactionReceipt transactionReceipt) {
    final Event event = new Event("AbiNotExist", Arrays.<TypeReference<?>>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
    }, new TypeReference<Utf8String>() {
    }, new TypeReference<Utf8String>() {
    }));
    List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
    ArrayList<AbiNotExistEventResponse> responses = new ArrayList<AbiNotExistEventResponse>(valueList.size());
    for (EventValues eventValues : valueList) {
        AbiNotExistEventResponse typedResponse = new AbiNotExistEventResponse();
        typedResponse.cns_name = (Utf8String) eventValues.getNonIndexedValues().get(0);
        typedResponse.contractname = (Utf8String) eventValues.getNonIndexedValues().get(1);
        typedResponse.version = (Utf8String) eventValues.getNonIndexedValues().get(2);
        responses.add(typedResponse);
    }
    return responses;
}
Also used : EventValues(org.bcos.web3j.abi.EventValues) ArrayList(java.util.ArrayList) Event(org.bcos.web3j.abi.datatypes.Event) TypeReference(org.bcos.web3j.abi.TypeReference)

Example 8 with EventValues

use of org.bcos.web3j.abi.EventValues in project web3sdk by FISCO-BCOS.

the class ContractAbiMgr method updateAbiEventObservable.

public Observable<UpdateAbiEventResponse> updateAbiEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("UpdateAbi", Arrays.<TypeReference<?>>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
    }, new TypeReference<Utf8String>() {
    }, new TypeReference<Utf8String>() {
    }, new TypeReference<Utf8String>() {
    }, new TypeReference<Address>() {
    }, new TypeReference<Uint256>() {
    }, new TypeReference<Uint256>() {
    }));
    EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
    filter.addSingleTopic(EventEncoder.encode(event));
    return web3j.ethLogObservable(filter).map(new Func1<Log, UpdateAbiEventResponse>() {

        @Override
        public UpdateAbiEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            UpdateAbiEventResponse typedResponse = new UpdateAbiEventResponse();
            typedResponse.cns_name = (Utf8String) eventValues.getNonIndexedValues().get(0);
            typedResponse.contractname = (Utf8String) eventValues.getNonIndexedValues().get(1);
            typedResponse.version = (Utf8String) eventValues.getNonIndexedValues().get(2);
            typedResponse.abi = (Utf8String) eventValues.getNonIndexedValues().get(3);
            typedResponse.addr = (Address) eventValues.getNonIndexedValues().get(4);
            typedResponse.blocknumber = (Uint256) eventValues.getNonIndexedValues().get(5);
            typedResponse.timestamp = (Uint256) eventValues.getNonIndexedValues().get(6);
            return typedResponse;
        }
    });
}
Also used : EventValues(org.bcos.web3j.abi.EventValues) EthFilter(org.bcos.web3j.protocol.core.methods.request.EthFilter) Utf8String(org.bcos.web3j.abi.datatypes.Utf8String) Address(org.bcos.web3j.abi.datatypes.Address) Log(org.bcos.web3j.protocol.core.methods.response.Log) Event(org.bcos.web3j.abi.datatypes.Event) TypeReference(org.bcos.web3j.abi.TypeReference) Uint256(org.bcos.web3j.abi.datatypes.generated.Uint256)

Example 9 with EventValues

use of org.bcos.web3j.abi.EventValues in project web3sdk by FISCO-BCOS.

the class ContractAbiMgr method getUpdateAbiEvents.

public static List<UpdateAbiEventResponse> getUpdateAbiEvents(TransactionReceipt transactionReceipt) {
    final Event event = new Event("UpdateAbi", Arrays.<TypeReference<?>>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
    }, new TypeReference<Utf8String>() {
    }, new TypeReference<Utf8String>() {
    }, new TypeReference<Utf8String>() {
    }, new TypeReference<Address>() {
    }, new TypeReference<Uint256>() {
    }, new TypeReference<Uint256>() {
    }));
    List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
    ArrayList<UpdateAbiEventResponse> responses = new ArrayList<UpdateAbiEventResponse>(valueList.size());
    for (EventValues eventValues : valueList) {
        UpdateAbiEventResponse typedResponse = new UpdateAbiEventResponse();
        typedResponse.cns_name = (Utf8String) eventValues.getNonIndexedValues().get(0);
        typedResponse.contractname = (Utf8String) eventValues.getNonIndexedValues().get(1);
        typedResponse.version = (Utf8String) eventValues.getNonIndexedValues().get(2);
        typedResponse.abi = (Utf8String) eventValues.getNonIndexedValues().get(3);
        typedResponse.addr = (Address) eventValues.getNonIndexedValues().get(4);
        typedResponse.blocknumber = (Uint256) eventValues.getNonIndexedValues().get(5);
        typedResponse.timestamp = (Uint256) eventValues.getNonIndexedValues().get(6);
        responses.add(typedResponse);
    }
    return responses;
}
Also used : EventValues(org.bcos.web3j.abi.EventValues) ArrayList(java.util.ArrayList) Event(org.bcos.web3j.abi.datatypes.Event) TypeReference(org.bcos.web3j.abi.TypeReference)

Example 10 with EventValues

use of org.bcos.web3j.abi.EventValues in project web3sdk by FISCO-BCOS.

the class ContractAbiMgr method getAddOldAbiEvents.

public static List<AddOldAbiEventResponse> getAddOldAbiEvents(TransactionReceipt transactionReceipt) {
    final Event event = new Event("AddOldAbi", Arrays.<TypeReference<?>>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
    }, new TypeReference<Utf8String>() {
    }, new TypeReference<Utf8String>() {
    }, new TypeReference<Utf8String>() {
    }, new TypeReference<Address>() {
    }, new TypeReference<Uint256>() {
    }, new TypeReference<Uint256>() {
    }));
    List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
    ArrayList<AddOldAbiEventResponse> responses = new ArrayList<AddOldAbiEventResponse>(valueList.size());
    for (EventValues eventValues : valueList) {
        AddOldAbiEventResponse typedResponse = new AddOldAbiEventResponse();
        typedResponse.cns_name = (Utf8String) eventValues.getNonIndexedValues().get(0);
        typedResponse.contractname = (Utf8String) eventValues.getNonIndexedValues().get(1);
        typedResponse.version = (Utf8String) eventValues.getNonIndexedValues().get(2);
        typedResponse.abi = (Utf8String) eventValues.getNonIndexedValues().get(3);
        typedResponse.addr = (Address) eventValues.getNonIndexedValues().get(4);
        typedResponse.blocknumber = (Uint256) eventValues.getNonIndexedValues().get(5);
        typedResponse.timestamp = (Uint256) eventValues.getNonIndexedValues().get(6);
        responses.add(typedResponse);
    }
    return responses;
}
Also used : EventValues(org.bcos.web3j.abi.EventValues) ArrayList(java.util.ArrayList) Event(org.bcos.web3j.abi.datatypes.Event) TypeReference(org.bcos.web3j.abi.TypeReference)

Aggregations

EventValues (org.bcos.web3j.abi.EventValues)29 TypeReference (org.bcos.web3j.abi.TypeReference)27 Event (org.bcos.web3j.abi.datatypes.Event)26 ArrayList (java.util.ArrayList)16 Log (org.bcos.web3j.protocol.core.methods.response.Log)14 EthFilter (org.bcos.web3j.protocol.core.methods.request.EthFilter)13 Utf8String (org.bcos.web3j.abi.datatypes.Utf8String)12 Uint256 (org.bcos.web3j.abi.datatypes.generated.Uint256)11 Address (org.bcos.web3j.abi.datatypes.Address)9 Bytes32 (org.bcos.web3j.abi.datatypes.generated.Bytes32)2 Int256 (org.bcos.web3j.abi.datatypes.generated.Int256)2 MethodSpec (com.squareup.javapoet.MethodSpec)1 ParameterizedTypeName (com.squareup.javapoet.ParameterizedTypeName)1 List (java.util.List)1 StaticArray (org.bcos.web3j.abi.datatypes.StaticArray)1 Type (org.bcos.web3j.abi.datatypes.Type)1 TransactionReceipt (org.bcos.web3j.protocol.core.methods.response.TransactionReceipt)1