Search in sources :

Example 6 with Log

use of org.bcos.web3j.protocol.core.methods.response.Log in project web3sdk by FISCO-BCOS.

the class LogFilter method process.

@Override
void process(List<EthLog.LogResult> logResults) {
    for (EthLog.LogResult logResult : logResults) {
        if (logResult instanceof EthLog.LogObject) {
            Log log = ((EthLog.LogObject) logResult).get();
            callback.onEvent(log);
        } else {
            throw new FilterException("Unexpected result type: " + logResult.get() + " required LogObject");
        }
    }
}
Also used : EthLog(org.bcos.web3j.protocol.core.methods.response.EthLog) Log(org.bcos.web3j.protocol.core.methods.response.Log) EthLog(org.bcos.web3j.protocol.core.methods.response.EthLog)

Example 7 with Log

use of org.bcos.web3j.protocol.core.methods.response.Log in project web3sdk by FISCO-BCOS.

the class Base 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 8 with Log

use of org.bcos.web3j.protocol.core.methods.response.Log in project web3sdk by FISCO-BCOS.

the class ContractAbiMgr method abiNotExistEventObservable.

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

        @Override
        public AbiNotExistEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            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);
            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) Log(org.bcos.web3j.protocol.core.methods.response.Log) Event(org.bcos.web3j.abi.datatypes.Event) TypeReference(org.bcos.web3j.abi.TypeReference)

Example 9 with Log

use of org.bcos.web3j.protocol.core.methods.response.Log in project web3sdk by FISCO-BCOS.

the class ContractAbiMgr method addOldAbiEventObservable.

public Observable<AddOldAbiEventResponse> addOldAbiEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    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>() {
    }));
    EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
    filter.addSingleTopic(EventEncoder.encode(event));
    return web3j.ethLogObservable(filter).map(new Func1<Log, AddOldAbiEventResponse>() {

        @Override
        public AddOldAbiEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            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);
            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 10 with Log

use of org.bcos.web3j.protocol.core.methods.response.Log in project web3sdk by FISCO-BCOS.

the class ContractAbiMgr method abiExistEventObservable.

public Observable<AbiExistEventResponse> abiExistEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("AbiExist", 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, AbiExistEventResponse>() {

        @Override
        public AbiExistEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            AbiExistEventResponse typedResponse = new AbiExistEventResponse();
            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.bn = (Uint256) eventValues.getNonIndexedValues().get(5);
            typedResponse.t = (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)

Aggregations

Log (org.bcos.web3j.protocol.core.methods.response.Log)16 EventValues (org.bcos.web3j.abi.EventValues)14 TypeReference (org.bcos.web3j.abi.TypeReference)13 Event (org.bcos.web3j.abi.datatypes.Event)13 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 ArrayList (java.util.ArrayList)1 StaticArray (org.bcos.web3j.abi.datatypes.StaticArray)1 Bytes32 (org.bcos.web3j.abi.datatypes.generated.Bytes32)1 Int256 (org.bcos.web3j.abi.datatypes.generated.Int256)1 LogFilter (org.bcos.web3j.protocol.core.filters.LogFilter)1 EthLog (org.bcos.web3j.protocol.core.methods.response.EthLog)1 Subscriber (rx.Subscriber)1