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

The following examples show how to use org.fisco.bcos.web3j.abi.datatypes.Function. These examples are extracted from open source projects. 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 Project: WeEvent   Source File: Topic.java    License: 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 2
Source Project: WeBASE-Front   Source File: TransService.java    License: 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 3
Source Project: WeBASE-Front   Source File: TransService.java    License: 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 4
Source Project: WeBASE-Front   Source File: TransService.java    License: 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 5
Source Project: WeBASE-Front   Source File: EvidenceSignersData.java    License: 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 6
Source Project: WeBASE-Front   Source File: Evidence.java    License: 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 7
Source Project: WeBASE-Front   Source File: Ok.java    License: 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 8
Source Project: WeEvent   Source File: TopicController.java    License: 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 9
Source Project: WeEvent   Source File: Topic.java    License: 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 10
Source Project: WeEvent   Source File: Topic.java    License: 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 11
Source Project: WeEvent   Source File: Topic.java    License: 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 12
Source Project: WeEvent   Source File: Topic.java    License: 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 13
Source Project: WeEvent   Source File: Topic.java    License: 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 14
Source Project: WeBASE-Front   Source File: TransService.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * send transaction locally
 */
public Object transHandleLocal(ReqTransHandle req) throws Exception {
    log.info("transHandle start. ReqTransHandle:[{}]", JsonUtils.toJSONString(req));

    // init contract params
    ContractOfTrans cof = new ContractOfTrans(req);
    // check param and build function
    ContractFunction contractFunction = buildContractFunction(cof);

    // address
    String address = cof.getContractAddress();

    // web3j
    Web3j web3j = web3ApiService.getWeb3j(cof.getGroupId());
    // get privateKey
    Credentials credentials = getCredentials(contractFunction.getConstant(), req.getUser());
    // contract load
    ContractGasProvider contractGasProvider =
            new StaticGasProvider(Constants.GAS_PRICE, Constants.GAS_LIMIT);
    CommonContract commonContract = CommonContract.load(address, web3j, credentials, contractGasProvider);

    // request
    Object result;
    Function function = new Function(cof.getFuncName(), contractFunction.getFinalInputs(),
            contractFunction.getFinalOutputs());
    if (contractFunction.getConstant()) {
        result = execCall(contractFunction.getOutputList(), function, commonContract);
    } else {
        result = execTransaction(function, commonContract);
    }

    log.info("transHandle end. name:{} func:{} result:{}", cof.getContractName(),
            cof.getFuncName(), JsonUtils.toJSONString(result));
    return result;
}
 
Example 15
Source Project: WeEvent   Source File: Topic.java    License: Apache License 2.0 5 votes vote down vote up
public Tuple2<String, String> getAddTopicACLInput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function = new Function(FUNC_ADDTOPICACL, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Address>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());;
    return new Tuple2<String, String>(

            (String) results.get(0).getValue(), 
            (String) results.get(1).getValue()
            );
}
 
Example 16
Source Project: WeBASE-Codegen-Monkey   Source File: HelloWorld.java    License: 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 17
Source Project: WeBASE-Front   Source File: EvidenceSignersData.java    License: 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 18
Source Project: WeBASE-Front   Source File: EvidenceSignersData.java    License: Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> newEvidence(String evi, String info, String id, BigInteger v, byte[] r, byte[] s) {
    final Function function = new Function(
            FUNC_NEWEVIDENCE, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(evi), 
            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(info), 
            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(id), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint8(v), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(r), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(s)), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example 19
Source Project: WeBASE-Front   Source File: EvidenceSignersData.java    License: Apache License 2.0 5 votes vote down vote up
public void newEvidence(String evi, String info, String id, BigInteger v, byte[] r, byte[] s, TransactionSucCallback callback) {
    final Function function = new Function(
            FUNC_NEWEVIDENCE, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(evi), 
            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(info), 
            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(id), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint8(v), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(r), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(s)), 
            Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example 20
Source Project: WeBASE-Front   Source File: EvidenceSignersData.java    License: Apache License 2.0 5 votes vote down vote up
public String newEvidenceSeq(String evi, String info, String id, BigInteger v, byte[] r, byte[] s) {
    final Function function = new Function(
            FUNC_NEWEVIDENCE, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(evi), 
            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(info), 
            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(id), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint8(v), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(r), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(s)), 
            Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example 21
Source Project: WeBASE-Front   Source File: EvidenceSignersData.java    License: Apache License 2.0 5 votes vote down vote up
public Tuple1<String> getNewEvidenceOutput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getOutput();
    final Function function = new Function(FUNC_NEWEVIDENCE, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());;
    return new Tuple1<String>(

            (String) results.get(0).getValue()
            );
}
 
Example 22
Source Project: WeEvent   Source File: FiscoBcosBroker4ProducerTest.java    License: Apache License 2.0 5 votes vote down vote up
private String buildWeEvent(WeEvent event) throws BrokerException {
    final Function function = new Function(
            Topic.FUNC_PUBLISHWEEVENT,
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(event.getTopic()),
                    new org.fisco.bcos.web3j.abi.datatypes.Utf8String(new String(event.getContent(), StandardCharsets.UTF_8)),
                    new org.fisco.bcos.web3j.abi.datatypes.Utf8String(JsonHelper.object2Json(event.getExtensions()))),
            Collections.<TypeReference<?>>emptyList());
    return FunctionEncoder.encode(function);
}
 
Example 23
Source Project: WeBASE-Front   Source File: Ok.java    License: Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> trans(BigInteger num) {
    final Function function = new Function(
            FUNC_TRANS, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(num)), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example 24
Source Project: WeBASE-Front   Source File: Ok.java    License: Apache License 2.0 5 votes vote down vote up
public void trans(BigInteger num, TransactionSucCallback callback) {
    final Function function = new Function(
            FUNC_TRANS, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(num)), 
            Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example 25
Source Project: WeEvent   Source File: Topic.java    License: Apache License 2.0 5 votes vote down vote up
public String addTopicACLSeq(String topicName, String ownerAddress) {
    final Function function = new Function(
            FUNC_ADDTOPICACL, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(topicName), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(ownerAddress)), 
            Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example 26
Source Project: WeBASE-Front   Source File: Ok.java    License: Apache License 2.0 5 votes vote down vote up
public Tuple1<BigInteger> getTransInput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function = new Function(FUNC_TRANS, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());;
    return new Tuple1<BigInteger>(

            (BigInteger) results.get(0).getValue()
            );
}
 
Example 27
Source Project: WeBASE-Front   Source File: Evidence.java    License: Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> addSignatures(BigInteger v, byte[] r, byte[] s) {
    final Function function = new Function(
            FUNC_ADDSIGNATURES, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.generated.Uint8(v), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(r), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(s)), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example 28
Source Project: WeBASE-Front   Source File: Evidence.java    License: Apache License 2.0 5 votes vote down vote up
public void addSignatures(BigInteger v, byte[] r, byte[] s, TransactionSucCallback callback) {
    final Function function = new Function(
            FUNC_ADDSIGNATURES, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.generated.Uint8(v), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(r), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(s)), 
            Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example 29
Source Project: WeBASE-Front   Source File: Evidence.java    License: Apache License 2.0 5 votes vote down vote up
public String addSignaturesSeq(BigInteger v, byte[] r, byte[] s) {
    final Function function = new Function(
            FUNC_ADDSIGNATURES, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.generated.Uint8(v), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(r), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(s)), 
            Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example 30
Source Project: WeBASE-Front   Source File: Evidence.java    License: 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()
            );
}