org.fisco.bcos.web3j.tuples.generated.Tuple3 Java Examples

The following examples show how to use org.fisco.bcos.web3j.tuples.generated.Tuple3. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TopicController.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple3<BigInteger, BigInteger, List<String>>> listTopicName(BigInteger pageIndex, BigInteger pageSize) {
    final Function function = new Function(FUNC_LISTTOPICNAME, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(pageIndex), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(pageSize)), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<DynamicArray<Utf8String>>() {}));
    return new RemoteCall<Tuple3<BigInteger, BigInteger, List<String>>>(
            new Callable<Tuple3<BigInteger, BigInteger, List<String>>>() {
                @Override
                public Tuple3<BigInteger, BigInteger, List<String>> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple3<BigInteger, BigInteger, List<String>>(
                            (BigInteger) results.get(0).getValue(), 
                            (BigInteger) results.get(1).getValue(), 
                            convertToNative((List<Utf8String>) results.get(2).getValue()));
                }
            });
}
 
Example #2
Source File: Topic.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
public Tuple3<String, String, String> getPublishWeEventInput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function = new Function(FUNC_PUBLISHWEEVENT, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(
                new TypeReference<Utf8String>() {},
                new TypeReference<Utf8String>() {},
                new TypeReference<Utf8String>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());;
    return new Tuple3<String, String, String>(

            (String) results.get(0).getValue(), 
            (String) results.get(1).getValue(), 
            (String) results.get(2).getValue()
            );
}
 
Example #3
Source File: TestRingSig.java    From group-signature-client with GNU General Public License v3.0 6 votes vote down vote up
public Tuple3<String, String, String> getUpdate_ring_sig_dataInput(
        TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function =
            new Function(
                    FUNC_UPDATE_RING_SIG_DATA,
                    Arrays.<Type>asList(),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Utf8String>() {},
                            new TypeReference<Utf8String>() {},
                            new TypeReference<Utf8String>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
    ;
    return new Tuple3<String, String, String>(
            (String) results.get(0).getValue(),
            (String) results.get(1).getValue(),
            (String) results.get(2).getValue());
}
 
Example #4
Source File: MixContract.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>> read(String name) {
    final Function function =
            new Function(
                    FUNC_READ,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name)),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<DynamicArray<Bytes32>>() {},
                            new TypeReference<DynamicArray<Int256>>() {},
                            new TypeReference<DynamicArray<Bytes32>>() {}));
    return new RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>(
            new Callable<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>() {
                @Override
                public Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>> call()
                        throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>(
                            convertToNative((List<Bytes32>) results.get(0).getValue()),
                            convertToNative((List<Int256>) results.get(1).getValue()),
                            convertToNative((List<Bytes32>) results.get(2).getValue()));
                }
            });
}
 
Example #5
Source File: TableTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>> select(String name) {
    final Function function =
            new Function(
                    FUNC_SELECT,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name)),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<DynamicArray<Bytes32>>() {},
                            new TypeReference<DynamicArray<Int256>>() {},
                            new TypeReference<DynamicArray<Bytes32>>() {}));
    return new RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>(
            new Callable<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>() {
                @Override
                public Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>> call()
                        throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>(
                            convertToNative((List<Bytes32>) results.get(0).getValue()),
                            convertToNative((List<Int256>) results.get(1).getValue()),
                            convertToNative((List<Bytes32>) results.get(2).getValue()));
                }
            });
}
 
Example #6
Source File: TableTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>> select(String name) {
    final Function function =
            new Function(
                    FUNC_SELECT,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name)),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<DynamicArray<Bytes32>>() {},
                            new TypeReference<DynamicArray<Int256>>() {},
                            new TypeReference<DynamicArray<Bytes32>>() {}));
    return new RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>(
            new Callable<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>() {
                @Override
                public Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>> call()
                        throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>(
                            convertToNative((List<Bytes32>) results.get(0).getValue()),
                            convertToNative((List<Int256>) results.get(1).getValue()),
                            convertToNative((List<Bytes32>) results.get(2).getValue()));
                }
            });
}
 
Example #7
Source File: TableTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple3<List<String>, List<BigInteger>, List<String>>> select(String name) {
    final Function function =
            new Function(
                    FUNC_SELECT,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name)),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<DynamicArray<Utf8String>>() {},
                            new TypeReference<DynamicArray<Int256>>() {},
                            new TypeReference<DynamicArray<Utf8String>>() {}));
    return new RemoteCall<Tuple3<List<String>, List<BigInteger>, List<String>>>(
            new Callable<Tuple3<List<String>, List<BigInteger>, List<String>>>() {
                @Override
                public Tuple3<List<String>, List<BigInteger>, List<String>> call()
                        throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple3<List<String>, List<BigInteger>, List<String>>(
                            convertToNative((List<Utf8String>) results.get(0).getValue()),
                            convertToNative((List<Int256>) results.get(1).getValue()),
                            convertToNative((List<Utf8String>) results.get(2).getValue()));
                }
            });
}
 
Example #8
Source File: Evidence.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
public Tuple3<BigInteger, byte[], byte[]> getAddSignaturesInput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function = new Function(FUNC_ADDSIGNATURES, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint8>() {}, new TypeReference<Bytes32>() {}, new TypeReference<Bytes32>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());;
    return new Tuple3<BigInteger, byte[], byte[]>(

            (BigInteger) results.get(0).getValue(), 
            (byte[]) results.get(1).getValue(), 
            (byte[]) results.get(2).getValue()
            );
}
 
Example #9
Source File: SupportedVersion.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public static WeEvent decodeWeEvent(BigInteger timestamp, TransactionReceipt receipt, int version, Map<String, Contract> historyTopic) {
    try {
        // support version list
        switch (version) {
            case 10:
                // v10 is com.webank.weevent.broker.fisco.web3sdk.v2.solc10.Topic
                Topic topic = (Topic) historyTopic.get(receipt.getTo());
                Tuple3<String, String, String> input = topic.getPublishWeEventInput(receipt);
                Tuple1<BigInteger> output = topic.getPublishWeEventOutput(receipt);
                long seq = output.getValue1().longValue();
                if (seq <= 0) {
                    log.warn("skip data for invalid sequence: {}", seq);
                    return null;
                }

                String topicName = input.getValue1();
                Map<String, String> extensions = JsonHelper.json2Object(input.getValue3(), new TypeReference<Map<String, String>>() {
                });
                if (extensions == null) {
                    extensions = new HashMap<>();
                }
                WeEventPlus weEventPlus = new WeEventPlus(timestamp.longValue(), receipt.getBlockNumber().longValue(), receipt.getTransactionHash(), receipt.getFrom());
                extensions.put(WeEvent.WeEvent_PLUS, JsonHelper.object2Json(weEventPlus));

                WeEvent event = new WeEvent(topicName, input.getValue2().getBytes(StandardCharsets.UTF_8), extensions);
                event.setEventId(DataTypeUtils.encodeEventId(topicName, receipt.getBlockNumber().intValue(), seq));
                return event;

            default:
                log.error("unknown solidity version: {}", version);
                return null;
        }
    } catch (Exception e) {
        log.warn("decode WeEvent failed, TransactionReceipt: {} {}", receipt.getTransactionHash(), e.getMessage());
        return null;
    }
}
 
Example #10
Source File: TableTestClient.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
private static void select(String[] args, TableTest tabletest) {
    if (args.length == 2) {
        try {
            String keyName = args[1];
            Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>> lists =
                    tabletest.select(keyName).send();
            List<byte[]> value1 = lists.getValue1();
            List<BigInteger> value2 = lists.getValue2();
            List<byte[]> value3 = lists.getValue3();
            logger.info("record numbers = " + value1.size());
            System.out.println("record numbers = " + value1.size());
            for (int i = 0; i < value1.size(); i++) {
                String name = new String(value1.get(i));
                logger.info("name = " + name);
                System.out.println("name = " + name);
                int item_id = value2.get(i).intValue();
                logger.info("item_id = " + item_id);
                System.out.println("item_id = " + item_id);
                String item_name = new String(value3.get(i));
                logger.info("item_name = " + item_name);
                System.out.println("item_name = " + item_name);
            }
        } catch (Exception e) {
            logger.info("record numbers = 0");
            System.out.println("record numbers = 0");
        }
    } else {
        System.out.println("\nPlease enter as follow example:\n 1 1 select fruit");
    }
}
 
Example #11
Source File: GMTableTestClient.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
private static void select(String[] args, TableTest tabletest) {
    if (args.length == 2) {
        try {
            String keyName = args[1];
            Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>> lists =
                    tabletest.select(keyName).send();
            List<byte[]> value1 = lists.getValue1();
            List<BigInteger> value2 = lists.getValue2();
            List<byte[]> value3 = lists.getValue3();
            logger.info("record numbers = " + value1.size());
            System.out.println("record numbers = " + value1.size());
            for (int i = 0; i < value1.size(); i++) {
                String name = new String(value1.get(i));
                logger.info("name = " + name);
                System.out.println("name = " + name);
                int item_id = value2.get(i).intValue();
                logger.info("item_id = " + item_id);
                System.out.println("item_id = " + item_id);
                String item_name = new String(value3.get(i));
                logger.info("item_name = " + item_name);
                System.out.println("item_name = " + item_name);
            }
        } catch (Exception e) {
            logger.info("record numbers = 0");
            System.out.println("record numbers = 0");
        }
    } else {
        System.out.println("\nPlease enter as follow example:\n 1 1 select fruit");
    }
}
 
Example #12
Source File: SupportedVersion.java    From WeEvent with Apache License 2.0 4 votes vote down vote up
private static List<List<TopicInfo>> loadTopicData(Web3j web3j, Credentials credentials, String address, Long version, int timeout) throws BrokerException {
    List<List<TopicInfo>> topicInfos = new ArrayList<>();
    int total;
    switch (version.intValue()) {
        case 10:
            TopicController lowControl = (TopicController) Web3SDK2Wrapper.loadContract(address, web3j, credentials, TopicController.class);
            final int pageSize = 100;
            for (int i = 0; true; i++) {
                try {
                    Tuple3<BigInteger, BigInteger, List<String>> tuple3 = lowControl.listTopicName(BigInteger.valueOf(i), BigInteger.valueOf(pageSize))
                            .sendAsync().get(timeout, TimeUnit.MILLISECONDS);

                    total = tuple3.getValue1().intValue();
                    List<TopicInfo> onePage = new ArrayList<>();
                    if (tuple3.getValue2().intValue() > 0) {
                        for (String topicName : tuple3.getValue3()) {
                            TopicInfo topicInfo = new TopicInfo();
                            Tuple8<Boolean, String, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, String> result =
                                    lowControl.getTopicInfo(topicName).sendAsync().get(timeout, TimeUnit.MILLISECONDS);
                            if (result.getValue1()) {
                                //topic
                                topicInfo.setTopicName(topicName);
                                topicInfo.setSenderAddress(result.getValue2());
                                topicInfo.setCreatedTimestamp(result.getValue3().longValue());
                                topicInfo.setBlockNumber(result.getValue4().longValue());

                                // last event
                                topicInfo.setSequenceNumber(result.getValue5().longValue());
                                topicInfo.setLastBlock(result.getValue6().longValue());
                                topicInfo.setLastTimestamp(result.getValue7().longValue());
                                topicInfo.setLastSender(result.getValue8());

                                onePage.add(topicInfo);
                            }
                        }

                        topicInfos.add(onePage);
                    }

                    if (tuple3.getValue2().intValue() < pageSize) {
                        break;
                    }
                } catch (TimeoutException | ExecutionException | InterruptedException e) {
                    log.error("loop block failed due to ExecutionException|NullPointerException|InterruptedException", e);
                    throw new BrokerException(ErrorCode.TRANSACTION_EXECUTE_ERROR);
                }
            }
            break;

        default:
            log.error("unknown solidity version: {}", version);
            throw new BrokerException(ErrorCode.UNKNOWN_SOLIDITY_VERSION);
    }

    log.info("topic size: {} in version: {}", total, version);
    return topicInfos;
}