Search in sources :

Example 6 with Address

use of org.bcos.web3j.abi.datatypes.Address 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 7 with Address

use of org.bcos.web3j.abi.datatypes.Address 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)

Example 8 with Address

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

the class ContractAbiMgr method addAbiEventObservable.

public Observable<AddAbiEventResponse> addAbiEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("AddAbi", 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, AddAbiEventResponse>() {

        @Override
        public AddAbiEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            AddAbiEventResponse typedResponse = new AddAbiEventResponse();
            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 Address

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

the class NodeAction 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 10 with Address

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

the class SystemProxyTools method processSystemProxy.

static void processSystemProxy(SystemProxy systemProxy, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
    try {
        System.out.println("-----------------系统路由表----------------------");
        Uint256 routelength = systemProxy.getRouteSize().get();
        for (int i = 0; i < routelength.getValue().intValue(); i++) {
            Utf8String key = systemProxy.getRouteNameByIndex(new Uint256(i)).get();
            List<Type> route = systemProxy.getRoute(key).get();
            System.out.println(" " + i + ")" + key + "=>" + (route.get(0)) + "," + route.get(1).getValue() + "," + ((BigInteger) (route.get(2).getValue())).intValue());
            if (key.getValue().equals("TransactionFilterChain")) {
                TransactionFilterChain transactionFilterChain1 = TransactionFilterChain.load(route.get(0).toString(), web3j, credentials, gasPrice, gasLimit);
                Uint256 filterlength = transactionFilterChain1.getFiltersLength().get();
                for (int j = 0; j < filterlength.getValue().intValue(); j++) {
                    Address filter = transactionFilterChain1.getFilter(new Uint256(j)).get();
                    TransactionFilterBase transactionFilterBase = TransactionFilterBase.load(filter.toString(), web3j, credentials, gasPrice, gasLimit);
                    Utf8String name = transactionFilterBase._name().get();
                    Utf8String version = transactionFilterBase._version().get();
                    System.out.println("       " + name + "=>" + version + "," + filter);
                }
            }
        }
    } catch (Exception e) {
        System.out.println(e);
    }
}
Also used : Utf8String(org.bcos.web3j.abi.datatypes.Utf8String) Type(org.bcos.web3j.abi.datatypes.Type) Address(org.bcos.web3j.abi.datatypes.Address) TransactionFilterChain(org.bcos.contract.source.TransactionFilterChain) BigInteger(java.math.BigInteger) TransactionFilterBase(org.bcos.contract.source.TransactionFilterBase) Uint256(org.bcos.web3j.abi.datatypes.generated.Uint256)

Aggregations

Address (org.bcos.web3j.abi.datatypes.Address)12 Utf8String (org.bcos.web3j.abi.datatypes.Utf8String)12 Uint256 (org.bcos.web3j.abi.datatypes.generated.Uint256)11 EventValues (org.bcos.web3j.abi.EventValues)9 TypeReference (org.bcos.web3j.abi.TypeReference)9 Event (org.bcos.web3j.abi.datatypes.Event)9 EthFilter (org.bcos.web3j.protocol.core.methods.request.EthFilter)9 Log (org.bcos.web3j.protocol.core.methods.response.Log)9 BigInteger (java.math.BigInteger)3 Type (org.bcos.web3j.abi.datatypes.Type)3 Service (org.bcos.channel.client.Service)2 Credentials (org.bcos.web3j.crypto.Credentials)2 ECKeyPair (org.bcos.web3j.crypto.ECKeyPair)2 Web3j (org.bcos.web3j.protocol.Web3j)2 ChannelEthereumService (org.bcos.web3j.protocol.channel.ChannelEthereumService)2 ApplicationContext (org.springframework.context.ApplicationContext)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 ChannelRequest (org.bcos.channel.dto.ChannelRequest)1 ChannelResponse (org.bcos.channel.dto.ChannelResponse)1 TransactionFilterBase (org.bcos.contract.source.TransactionFilterBase)1