org.fisco.bcos.web3j.abi.datatypes.Function Java Examples

The following examples show how to use org.fisco.bcos.web3j.abi.datatypes.Function. 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: 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 #2
Source File: TransService.java    From WeBASE-Front with Apache License 2.0 6 votes vote down vote up
/**
 * execCall through common contract
 *
 * @param funOutputTypes list
 * @param function function
 * @param commonContract contract
 */
public static Object execCall(List<String> funOutputTypes, Function function,
        CommonContract commonContract) throws FrontException {
    try {
        List<Type> typeList = commonContract.execCall(function);
        Object result = null;
        if (typeList.size() > 0) {
            result = AbiUtil.callResultParse(funOutputTypes, typeList);
        }
        return result;
    } catch (IOException | ContractCallException e) {
        log.error("execCall failed.", e);
        throw new FrontException(ConstantCode.TRANSACTION_QUERY_FAILED.getCode(),
                e.getMessage());
    }
}
 
Example #3
Source File: TransService.java    From WeBASE-Front with Apache License 2.0 6 votes vote down vote up
/**
 * execTransaction through common contract
 *
 * @param function function
 * @param commonContract contract
 */
public static TransactionReceipt execTransaction(Function function,
        CommonContract commonContract) throws FrontException {
    TransactionReceipt transactionReceipt = null;
    Instant startTime = Instant.now();
    log.info("execTransaction start startTime:{}", startTime.toEpochMilli());
    try {
        transactionReceipt = commonContract.execTransaction(function);
    } catch (IOException | TransactionException | ContractCallException e) {
        log.error("execTransaction failed.", e);
        throw new FrontException(ConstantCode.TRANSACTION_SEND_FAILED.getCode(),
                e.getMessage());
    }
    log.info("execTransaction end  useTime:{}",
            Duration.between(startTime, Instant.now()).toMillis());
    return transactionReceipt;
}
 
Example #4
Source File: Topic.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple4<BigInteger, BigInteger, BigInteger, String>> getSnapshot(String topicName) {
    final Function function = new Function(FUNC_GETSNAPSHOT, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(topicName)), 
            Arrays.<TypeReference<?>>asList(
                new TypeReference<Uint256>() {},
                new TypeReference<Uint256>() {},
                new TypeReference<Uint256>() {},
                new TypeReference<Address>() {}));
    return new RemoteCall<Tuple4<BigInteger, BigInteger, BigInteger, String>>(
            new Callable<Tuple4<BigInteger, BigInteger, BigInteger, String>>() {
                @Override
                public Tuple4<BigInteger, BigInteger, BigInteger, String> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple4<BigInteger, BigInteger, BigInteger, String>(
                            (BigInteger) results.get(0).getValue(), 
                            (BigInteger) results.get(1).getValue(), 
                            (BigInteger) results.get(2).getValue(), 
                            (String) results.get(3).getValue());
                }
            });
}
 
Example #5
Source File: TransService.java    From WeBASE-Front with Apache License 2.0 6 votes vote down vote up
/**
 * send tx with sign for precomnpiled contract
 * 
 * @param precompiledType enum of precompiled contract
 * @param funcName precompiled contract function name
 */
public Object transHandleWithSignForPrecompile(int groupId, String signUserId,
        PrecompiledTypes precompiledType, String funcName, List<Object> funcParams)
        throws Exception {
    // check groupId
    Web3j web3j = web3ApiService.getWeb3j(groupId);
    // get address and abi of precompiled contract
    String contractAddress = PrecompiledCommonInfo.getAddress(precompiledType);
    String abiStr = PrecompiledCommonInfo.getAbi(precompiledType);
    List<Object> contractAbi = JsonUtils.toJavaObjectList(abiStr, Object.class);
    // check function param and get function param from abi
    ContractFunction contractFunction =
            buildContractFunctionWithAbi(contractAbi, funcName, funcParams);
    // encode function
    Function function = new Function(funcName, contractFunction.getFinalInputs(),
            contractFunction.getFinalOutputs());
    // trans handle
    return handleTransByFunction(groupId, web3j, signUserId, contractAddress, function,
            contractFunction);
}
 
Example #6
Source File: EvidenceSignersData.java    From WeBASE-Front with Apache License 2.0 6 votes vote down vote up
public Tuple6<String, String, String, BigInteger, byte[], byte[]> getNewEvidenceInput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function = new Function(FUNC_NEWEVIDENCE, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint8>() {}, new TypeReference<Bytes32>() {}, new TypeReference<Bytes32>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());;
    return new Tuple6<String, String, String, BigInteger, byte[], byte[]>(

            (String) results.get(0).getValue(), 
            (String) results.get(1).getValue(), 
            (String) results.get(2).getValue(), 
            (BigInteger) results.get(3).getValue(), 
            (byte[]) results.get(4).getValue(), 
            (byte[]) results.get(5).getValue()
            );
}
 
Example #7
Source File: Evidence.java    From WeBASE-Front with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple7<String, String, String, List<BigInteger>, List<byte[]>, List<byte[]>, List<String>>> getEvidence() {
    final Function function = new Function(FUNC_GETEVIDENCE, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<DynamicArray<Uint8>>() {}, new TypeReference<DynamicArray<Bytes32>>() {}, new TypeReference<DynamicArray<Bytes32>>() {}, new TypeReference<DynamicArray<Address>>() {}));
    return new RemoteCall<Tuple7<String, String, String, List<BigInteger>, List<byte[]>, List<byte[]>, List<String>>>(
            new Callable<Tuple7<String, String, String, List<BigInteger>, List<byte[]>, List<byte[]>, List<String>>>() {
                @Override
                public Tuple7<String, String, String, List<BigInteger>, List<byte[]>, List<byte[]>, List<String>> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple7<String, String, String, List<BigInteger>, List<byte[]>, List<byte[]>, List<String>>(
                            (String) results.get(0).getValue(), 
                            (String) results.get(1).getValue(), 
                            (String) results.get(2).getValue(), 
                            convertToNative((List<Uint8>) results.get(3).getValue()), 
                            convertToNative((List<Bytes32>) results.get(4).getValue()), 
                            convertToNative((List<Bytes32>) results.get(5).getValue()), 
                            convertToNative((List<Address>) results.get(6).getValue()));
                }
            });
}
 
Example #8
Source File: Ok.java    From WeBASE-Front with Apache License 2.0 6 votes vote down vote up
public Flowable<TransEventEventResponse> transEventEventFlowable(BcosFilter filter) {
  return web3j
      .logFlowable(filter)
      .map(
          new io.reactivex.functions.Function<Log, TransEventEventResponse>() {
            @Override
            public TransEventEventResponse apply(Log log) {
              Contract.EventValuesWithLog eventValues =
                  extractEventParametersWithLog(TRANSEVENT_EVENT, log);
              TransEventEventResponse typedResponse = new TransEventEventResponse();
              typedResponse.log = log;
              typedResponse.num =
                  (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
              return typedResponse;
            }
          });
}
 
Example #9
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 #10
Source File: Topic.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
public RemoteCall<TransactionReceipt> flushSnapshot(List<String> topicName, List<BigInteger> lastSequence,
                                                    List<BigInteger> lastBlock, List<BigInteger> lastTimestamp,
                                                    List<String> lastSender) {
    final Function function = new Function(
            FUNC_FLUSHSNAPSHOT, 
            Arrays.<Type>asList(topicName.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("string[]"):
                    new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Utf8String>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(topicName, org.fisco.bcos.web3j.abi.datatypes.Utf8String.class)), 
            lastSequence.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastSequence, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastBlock.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastBlock, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastTimestamp.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastTimestamp, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastSender.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("address[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Address>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastSender, org.fisco.bcos.web3j.abi.datatypes.Address.class))), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #11
Source File: Topic.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
public void flushSnapshot(List<String> topicName, List<BigInteger> lastSequence, List<BigInteger> lastBlock,
                          List<BigInteger> lastTimestamp, List<String> lastSender, TransactionSucCallback callback) {
    final Function function = new Function(
            FUNC_FLUSHSNAPSHOT, 
            Arrays.<Type>asList(topicName.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("string[]"):
                    new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Utf8String>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(topicName, org.fisco.bcos.web3j.abi.datatypes.Utf8String.class)), 
            lastSequence.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastSequence, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastBlock.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastBlock, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastTimestamp.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastTimestamp, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastSender.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("address[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Address>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastSender, org.fisco.bcos.web3j.abi.datatypes.Address.class))), 
            Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #12
Source File: Topic.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
public String flushSnapshotSeq(List<String> topicName, List<BigInteger> lastSequence, List<BigInteger> lastBlock, List<BigInteger> lastTimestamp, List<String> lastSender) {
    final Function function = new Function(
            FUNC_FLUSHSNAPSHOT, 
            Arrays.<Type>asList(topicName.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("string[]"):
                    new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Utf8String>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(topicName, org.fisco.bcos.web3j.abi.datatypes.Utf8String.class)), 
            lastSequence.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastSequence, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastBlock.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastBlock, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastTimestamp.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastTimestamp, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastSender.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("address[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Address>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastSender, org.fisco.bcos.web3j.abi.datatypes.Address.class))), 
            Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #13
Source File: Topic.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
public Tuple5<List<String>, List<BigInteger>, List<BigInteger>, List<BigInteger>, List<String>> getFlushSnapshotInput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function = new Function(FUNC_FLUSHSNAPSHOT, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(
                new TypeReference<DynamicArray<Utf8String>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Address>>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());;
    return new Tuple5<List<String>, List<BigInteger>, List<BigInteger>, List<BigInteger>, List<String>>(

            convertToNative((List<Utf8String>) results.get(0).getValue()), 
            convertToNative((List<Uint256>) results.get(1).getValue()), 
            convertToNative((List<Uint256>) results.get(2).getValue()), 
            convertToNative((List<Uint256>) results.get(3).getValue()), 
            convertToNative((List<Address>) results.get(4).getValue())
            );
}
 
Example #14
Source File: Topic.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public void publishWeEvent(String topicName, String eventContent, String extensions, TransactionSucCallback callback) {
    final Function function = new Function(
            FUNC_PUBLISHWEEVENT, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(topicName), 
            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(eventContent), 
            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(extensions)), 
            Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #15
Source File: TopicController.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public String addTopicInfoSeq(String topicName) {
    final Function function = new Function(
            FUNC_ADDTOPICINFO, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(topicName)), 
            Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #16
Source File: HelloWorld.java    From WeBASE-Codegen-Monkey with Apache License 2.0 5 votes vote down vote up
public void set(String n, TransactionSucCallback callback) {
    final Function function = new Function(
            FUNC_SET, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(n)), 
            Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #17
Source File: TopicController.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> addTopicInfo(String topicName) {
    final Function function = new Function(
            FUNC_ADDTOPICINFO, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(topicName)), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #18
Source File: Topic.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public String publishWeEventSeq(String topicName, String eventContent, String extensions) {
    final Function function = new Function(
            FUNC_PUBLISHWEEVENT, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(topicName), 
            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(eventContent), 
            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(extensions)), 
            Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #19
Source File: TopicController.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public RemoteCall<Tuple8<Boolean, String, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, String>> getTopicInfo(String topicName) {
    final Function function = new Function(FUNC_GETTOPICINFO, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(topicName)), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {},
                new TypeReference<Address>() {},
                new TypeReference<Uint256>() {},
                new TypeReference<Uint256>() {},
                new TypeReference<Uint256>() {},
                new TypeReference<Uint256>() {},
                new TypeReference<Uint256>() {},
                new TypeReference<Address>() {}));
    return new RemoteCall<Tuple8<Boolean, String, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, String>>(
            new Callable<Tuple8<Boolean, String, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, String>>() {
                @Override
                public Tuple8<Boolean, String, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, String> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple8<Boolean, String, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, String>(
                            (Boolean) results.get(0).getValue(), 
                            (String) results.get(1).getValue(), 
                            (BigInteger) results.get(2).getValue(), 
                            (BigInteger) results.get(3).getValue(), 
                            (BigInteger) results.get(4).getValue(), 
                            (BigInteger) results.get(5).getValue(), 
                            (BigInteger) results.get(6).getValue(), 
                            (String) results.get(7).getValue());
                }
            });
}
 
Example #20
Source File: TopicController.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public Tuple8<List<String>, List<String>, List<BigInteger>, List<BigInteger>, List<BigInteger>, List<BigInteger>, List<BigInteger>, List<String>> getFlushTopicInfoInput(
    TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function = new Function(FUNC_FLUSHTOPICINFO, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(
                new TypeReference<DynamicArray<Utf8String>>() {},
                new TypeReference<DynamicArray<Address>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Address>>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());;
    return new Tuple8<List<String>, List<String>, List<BigInteger>, List<BigInteger>, List<BigInteger>, List<BigInteger>, List<BigInteger>, List<String>>(

            convertToNative((List<Utf8String>) results.get(0).getValue()), 
            convertToNative((List<Address>) results.get(1).getValue()), 
            convertToNative((List<Uint256>) results.get(2).getValue()), 
            convertToNative((List<Uint256>) results.get(3).getValue()), 
            convertToNative((List<Uint256>) results.get(4).getValue()), 
            convertToNative((List<Uint256>) results.get(5).getValue()), 
            convertToNative((List<Uint256>) results.get(6).getValue()), 
            convertToNative((List<Address>) results.get(7).getValue())
            );
}
 
Example #21
Source File: HelloWorld.java    From WeBASE-Codegen-Monkey with Apache License 2.0 5 votes vote down vote up
public void set(String n, TransactionSucCallback callback) {
    final Function function = new Function(
            FUNC_SET, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(n)), 
            Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #22
Source File: TopicController.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public void flushTopicInfo(List<String> topicName, List<String> topicSender, List<BigInteger> topicTimestamp,
                           List<BigInteger> topicBlock, List<BigInteger> lastSequence, List<BigInteger> lastBlock,
                           List<BigInteger> lastTimestamp, List<String> lastSender, TransactionSucCallback callback) {
    final Function function = new Function(
            FUNC_FLUSHTOPICINFO, 
            Arrays.<Type>asList(topicName.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("string[]"):
                    new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Utf8String>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(topicName, org.fisco.bcos.web3j.abi.datatypes.Utf8String.class)), 
            topicSender.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("address[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Address>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(topicSender, org.fisco.bcos.web3j.abi.datatypes.Address.class)), 
            topicTimestamp.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(topicTimestamp, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            topicBlock.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(topicBlock, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastSequence.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastSequence, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastBlock.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastBlock, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastTimestamp.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastTimestamp, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastSender.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("address[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Address>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastSender, org.fisco.bcos.web3j.abi.datatypes.Address.class))), 
            Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #23
Source File: TopicController.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> flushTopicInfo(List<String> topicName, List<String> topicSender,
                                                     List<BigInteger> topicTimestamp, List<BigInteger> topicBlock,
                                                     List<BigInteger> lastSequence, List<BigInteger> lastBlock,
                                                     List<BigInteger> lastTimestamp, List<String> lastSender) {
    final Function function = new Function(
            FUNC_FLUSHTOPICINFO, 
            Arrays.<Type>asList(topicName.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("string[]"):
                    new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Utf8String>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(topicName, org.fisco.bcos.web3j.abi.datatypes.Utf8String.class)), 
            topicSender.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("address[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Address>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(topicSender, org.fisco.bcos.web3j.abi.datatypes.Address.class)), 
            topicTimestamp.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(topicTimestamp, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            topicBlock.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(topicBlock, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastSequence.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastSequence, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastBlock.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastBlock, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastTimestamp.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastTimestamp, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastSender.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("address[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Address>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastSender, org.fisco.bcos.web3j.abi.datatypes.Address.class))), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #24
Source File: TransService.java    From WeBASE-Transaction with Apache License 2.0 5 votes vote down vote up
/**
 * get transaction output.
 * 
 * @param groupId groupId
 * @param uuidStateless uuid
 * @return
 */
public ResponseEntity getOutput(int groupId, String uuidStateless) throws BaseException {
    ResponseEntity response = new ResponseEntity(ConstantCode.RET_SUCCEED);
    TransInfoDto transInfo = transMapper.selectTransInfo(groupId, uuidStateless);
    if (transInfo == null) {
        log.warn("getOutput fail. trans is not exist uuidStateless:{}.", uuidStateless);
        throw new BaseException(ConstantCode.TRANS_NOT_EXIST);
    }
    String transOutput = transInfo.getTransOutput();
    // check if trans has been sent
    if (StringUtils.isBlank(transOutput)) {
        log.warn("getOutput fail. trans output is empty uuidStateless:{}.", uuidStateless);
        throw new BaseException(ConstantCode.TRANS_OUTPUT_EMPTY);
    }
    String contractAbi = transInfo.getContractAbi();
    if (StringUtils.isBlank(contractAbi)) {
        log.warn("getOutput fail. uuidStateless:{} abi is not exists", uuidStateless);
        throw new BaseException(ConstantCode.CONTRACT_ABI_EMPTY);
    }
    // get AbiDefinition
    AbiDefinition abiDefinition =
            ContractAbiUtil.getAbiDefinition(transInfo.getFuncName(), contractAbi);
    // check output format
    List<String> funOutputTypes = ContractAbiUtil.getFuncOutputType(abiDefinition);
    List<TypeReference<?>> finalOutputs = ContractAbiUtil.outputFormat(funOutputTypes);
    // encode function
    Function function = new Function(transInfo.getFuncName(), null, finalOutputs);
    List<Type> typeList = FunctionReturnDecoder.decode(transInfo.getTransOutput(),
            function.getOutputParameters());
    if (typeList.size() > 0) {
        response.setData(ContractAbiUtil.callResultParse(funOutputTypes, typeList));
    } else {
        response.setData(typeList);
    }
    return response;
}
 
Example #25
Source File: HelloWorld.java    From WeBASE-Codegen-Monkey with Apache License 2.0 5 votes vote down vote up
public String setSeq(String n) {
    final Function function = new Function(
            FUNC_SET, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(n)), 
            Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #26
Source File: EvidenceSignersData.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
public RemoteCall<List> getSigners() {
    final Function function = new Function(FUNC_GETSIGNERS, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Address>>() {}));
    return new RemoteCall<List>(
            new Callable<List>() {
                @Override
                @SuppressWarnings("unchecked")
                public List call() throws Exception {
                    List<Type> result = (List<Type>) executeCallSingleValueReturn(function, List.class);
                    return convertToNative(result);
                }
            });
}
 
Example #27
Source File: HelloWorldGM.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
public String setSeq(String n) {
    final Function function = new Function(
            FUNC_SET,
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(n)),
            Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #28
Source File: HelloWorldGM.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
public void set(String n, TransactionSucCallback callback) {
    final Function function = new Function(
            FUNC_SET,
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(n)),
            Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #29
Source File: HelloWorldGM.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> set(String n) {
    final Function function = new Function(
            FUNC_SET,
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(n)),
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #30
Source File: TopicController.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public Tuple1<Boolean> getAddTopicInfoOutput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getOutput();
    final Function function = new Function(FUNC_ADDTOPICINFO, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());;
    return new Tuple1<Boolean>(

            (Boolean) results.get(0).getValue()
            );
}