Search in sources :

Example 11 with Uint256

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

the class FileInfoManager method notifyEventObservable.

public Observable<NotifyEventResponse> notifyEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("Notify", Arrays.<TypeReference<?>>asList(), Arrays.<TypeReference<?>>asList(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, NotifyEventResponse>() {

        @Override
        public NotifyEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            NotifyEventResponse typedResponse = new NotifyEventResponse();
            typedResponse._errno = (Uint256) eventValues.getNonIndexedValues().get(0);
            typedResponse._info = (Utf8String) eventValues.getNonIndexedValues().get(1);
            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) Uint256(org.bcos.web3j.abi.datatypes.generated.Uint256)

Example 12 with Uint256

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

the class FileServerManager method notifyEventObservable.

public Observable<NotifyEventResponse> notifyEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("Notify", Arrays.<TypeReference<?>>asList(), Arrays.<TypeReference<?>>asList(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, NotifyEventResponse>() {

        @Override
        public NotifyEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            NotifyEventResponse typedResponse = new NotifyEventResponse();
            typedResponse._errno = (Uint256) eventValues.getNonIndexedValues().get(0);
            typedResponse._info = (Utf8String) eventValues.getNonIndexedValues().get(1);
            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) Uint256(org.bcos.web3j.abi.datatypes.generated.Uint256)

Example 13 with Uint256

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

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

the class NodeActionTools method processNodeAction.

static void processNodeAction(ApplicationContext ctx, NodeAction nodeAction, String[] args) {
    try {
        switch(args[1]) {
            case "cancelNode":
            case "registerNode":
                if (args.length < 3) {
                    System.out.println("Please input: node.json");
                    break;
                }
                System.out.println("node.json=" + args[2]);
                Resource template = ctx.getResource(args[2]);
                InputStream ksInputStream = template.getInputStream();
                ObjectMapper mapper = new ObjectMapper();
                mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
                NodeInfo nodeInfo = mapper.readValue(ksInputStream, NodeInfo.class);
                if (args[1].equals("cancelNode")) {
                    nodeAction.cancelNode(new Utf8String(nodeInfo.getId())).get();
                } else {
                    nodeAction.registerNode(new Utf8String(nodeInfo.getId()), new Utf8String(nodeInfo.getIp()), new Uint256(nodeInfo.getPort()), new Uint8(nodeInfo.getCategory()), new Utf8String(nodeInfo.getDesc()), new Utf8String(nodeInfo.getCAhash()), new Utf8String(nodeInfo.getAgencyinfo()), new Uint256(nodeInfo.getIdx())).get();
                }
            case "all":
                Uint256 len = nodeAction.getNodeIdsLength().get();
                System.out.println("NodeIdsLength= " + len.getValue().intValue());
                for (int i = 0; i < len.getValue().intValue(); i++) {
                    System.out.println("----------node " + i + "---------");
                    Utf8String id = nodeAction.getNodeId(new Uint256(i)).get();
                    System.out.println("id=" + id);
                    List<Type> node = nodeAction.getNode(id).get();
                    System.out.println("ip=" + node.get(0));
                    System.out.println("port=" + ((BigInteger) (node.get(1).getValue())).intValue());
                    System.out.println("category=" + ((BigInteger) (node.get(2).getValue())).intValue());
                    System.out.println("desc=" + node.get(3));
                    System.out.println("CAhash=" + node.get(4));
                    System.out.println("agencyinfo=" + node.get(5));
                    System.out.println("blocknumber=" + ((BigInteger) (node.get(2).getValue())).intValue());
                    System.out.println("Idx=" + ((BigInteger) (nodeAction.getNodeIdx(id).get()).getValue()).intValue());
                }
                break;
            default:
                break;
        }
    } catch (Exception e) {
        System.out.println(e);
    }
}
Also used : Utf8String(org.bcos.web3j.abi.datatypes.Utf8String) Uint8(org.bcos.web3j.abi.datatypes.generated.Uint8) Type(org.bcos.web3j.abi.datatypes.Type) InputStream(java.io.InputStream) Resource(org.springframework.core.io.Resource) BigInteger(java.math.BigInteger) Uint256(org.bcos.web3j.abi.datatypes.generated.Uint256) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 15 with Uint256

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

Uint256 (org.bcos.web3j.abi.datatypes.generated.Uint256)16 Utf8String (org.bcos.web3j.abi.datatypes.Utf8String)15 EventValues (org.bcos.web3j.abi.EventValues)11 TypeReference (org.bcos.web3j.abi.TypeReference)11 Address (org.bcos.web3j.abi.datatypes.Address)11 Event (org.bcos.web3j.abi.datatypes.Event)11 EthFilter (org.bcos.web3j.protocol.core.methods.request.EthFilter)11 Log (org.bcos.web3j.protocol.core.methods.response.Log)11 BigInteger (java.math.BigInteger)4 Type (org.bcos.web3j.abi.datatypes.Type)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 InputStream (java.io.InputStream)2 Service (org.bcos.channel.client.Service)2 Uint8 (org.bcos.web3j.abi.datatypes.generated.Uint8)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