Search in sources :

Example 1 with EthFilter

use of org.bcos.web3j.protocol.core.methods.request.EthFilter 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)

Example 2 with EthFilter

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

the class CAAction 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 3 with EthFilter

use of org.bcos.web3j.protocol.core.methods.request.EthFilter 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 4 with EthFilter

use of org.bcos.web3j.protocol.core.methods.request.EthFilter 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 5 with EthFilter

use of org.bcos.web3j.protocol.core.methods.request.EthFilter 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)

Aggregations

EventValues (org.bcos.web3j.abi.EventValues)13 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 Log (org.bcos.web3j.protocol.core.methods.response.Log)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 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