Java Code Examples for org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32

The following examples show how to use org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32. 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: 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 2
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 3
Source Project: web3sdk   Source File: MixContract.java    License: 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 4
Source Project: web3sdk   Source File: TableTest.java    License: 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 5
Source Project: web3sdk   Source File: EvidenceVerify.java    License: Apache License 2.0 6 votes vote down vote up
public RemoteCall<TransactionReceipt> insertEvidence(
        String evi,
        String info,
        String id,
        String signAddr,
        byte[] message,
        BigInteger v,
        byte[] r,
        byte[] s) {
    final Function function =
            new Function(
                    FUNC_INSERTEVIDENCE,
                    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.Address(signAddr),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(message),
                            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 6
Source Project: web3sdk   Source File: EvidenceVerify.java    License: Apache License 2.0 6 votes vote down vote up
public void insertEvidence(
        String evi,
        String info,
        String id,
        String signAddr,
        byte[] message,
        BigInteger v,
        byte[] r,
        byte[] s,
        TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_INSERTEVIDENCE,
                    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.Address(signAddr),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(message),
                            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 7
Source Project: web3sdk   Source File: EvidenceVerify.java    License: Apache License 2.0 6 votes vote down vote up
public String insertEvidenceSeq(
        String evi,
        String info,
        String id,
        String signAddr,
        byte[] message,
        BigInteger v,
        byte[] r,
        byte[] s) {
    final Function function =
            new Function(
                    FUNC_INSERTEVIDENCE,
                    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.Address(signAddr),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(message),
                            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 8
Source Project: web3sdk   Source File: TableTest.java    License: 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 9
Source Project: web3sdk   Source File: ResultEntityTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void typeToObjectTest0() {

    assertThat(ResultEntity.typeToObject(new Uint256(2)), is(new BigInteger("2")));
    assertThat(ResultEntity.typeToObject(new Int256(-1)), is(new BigInteger("-1")));
    assertThat(ResultEntity.typeToObject(new Utf8String("adsfjkl")), is("adsfjkl"));
    assertThat(ResultEntity.typeToObject(new Bool(true)), is(true));
    assertThat(ResultEntity.typeToObject(new DynamicBytes("0x111".getBytes())), is("0x111"));
    assertThat(
            ResultEntity.typeToObject(new Address("0x111")),
            is("0x0000000000000000000000000000000000000111"));
    assertThat(
            ResultEntity.typeToObject(
                    new Bytes32("01234567890123456789012345678912".getBytes())),
            is("01234567890123456789012345678912"));
}
 
Example 10
Source Project: evidenceSample   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 11
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 12
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 13
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 14
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 15
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 16
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 17
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()
            );
}
 
Example 18
Source Project: WeBASE-Front   Source File: Evidence.java    License: Apache License 2.0 5 votes vote down vote up
public static RemoteCall<Evidence> deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider, String evi, String info, String id, BigInteger v, byte[] r, byte[] s, String addr, String sender) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(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), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(addr), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(sender)));
    return deployRemoteCall(Evidence.class, web3j, credentials, contractGasProvider, BINARY, encodedConstructor);
}
 
Example 19
Source Project: WeBASE-Front   Source File: Evidence.java    License: Apache License 2.0 5 votes vote down vote up
public static RemoteCall<Evidence> deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider, String evi, String info, String id, BigInteger v, byte[] r, byte[] s, String addr, String sender) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(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), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(addr), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(sender)));
    return deployRemoteCall(Evidence.class, web3j, transactionManager, contractGasProvider, BINARY, encodedConstructor);
}
 
Example 20
Source Project: WeBASE-Front   Source File: Evidence.java    License: Apache License 2.0 5 votes vote down vote up
@Deprecated
public static RemoteCall<Evidence> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, String evi, String info, String id, BigInteger v, byte[] r, byte[] s, String addr, String sender) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(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), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(addr), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(sender)));
    return deployRemoteCall(Evidence.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor);
}
 
Example 21
Source Project: WeBASE-Front   Source File: Evidence.java    License: Apache License 2.0 5 votes vote down vote up
@Deprecated
public static RemoteCall<Evidence> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, String evi, String info, String id, BigInteger v, byte[] r, byte[] s, String addr, String sender) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(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), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(addr), 
            new org.fisco.bcos.web3j.abi.datatypes.Address(sender)));
    return deployRemoteCall(Evidence.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor);
}
 
Example 22
Source Project: WeBASE-Collect-Bee   Source File: BytesUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static List<String> bytes32ListToStringList(List<Bytes32> list) {
    List<String> strList = new ArrayList<>();
    for (Bytes32 b : list) {
        String s = bytesTypeToString(b);
        strList.add(s);
    }
    return strList;
}
 
Example 23
Source Project: WeBASE-Collect-Bee   Source File: BytesUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static List<String> bytes32DynamicArrayToList(List<Bytes32> bytes32List) {
    List<String> stringList = new ArrayList<>();
    for (int i = 0; i < bytes32List.size(); i++) {
        stringList.add(bytesTypeToString(bytes32List.get(i)).trim());
    }
    return stringList;
}
 
Example 24
Source Project: web3sdk   Source File: EvidenceVerify.java    License: Apache License 2.0 5 votes vote down vote up
public Tuple8<String, String, String, String, byte[], BigInteger, byte[], byte[]>
        getInsertEvidenceInput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function =
            new Function(
                    FUNC_INSERTEVIDENCE,
                    Arrays.<Type>asList(),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Utf8String>() {},
                            new TypeReference<Utf8String>() {},
                            new TypeReference<Utf8String>() {},
                            new TypeReference<Address>() {},
                            new TypeReference<Bytes32>() {},
                            new TypeReference<Uint8>() {},
                            new TypeReference<Bytes32>() {},
                            new TypeReference<Bytes32>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
    ;
    return new Tuple8<String, String, String, String, byte[], BigInteger, byte[], byte[]>(
            (String) results.get(0).getValue(),
            (String) results.get(1).getValue(),
            (String) results.get(2).getValue(),
            (String) results.get(3).getValue(),
            (byte[]) results.get(4).getValue(),
            (BigInteger) results.get(5).getValue(),
            (byte[]) results.get(6).getValue(),
            (byte[]) results.get(7).getValue());
}
 
Example 25
Source Project: web3sdk   Source File: ContractTypeUtilTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void getTypeTest() throws BaseException {
    assertThat(ContractTypeUtil.getType("bytes").getName(), is(DynamicBytes.class.getName()));
    assertThat(ContractTypeUtil.getType("address").getName(), is(Address.class.getName()));
    assertThat(ContractTypeUtil.getType("string").getName(), is(Utf8String.class.getName()));
    assertThat(ContractTypeUtil.getType("int").getName(), is(Int256.class.getName()));
    assertThat(ContractTypeUtil.getType("uint").getName(), is(Uint256.class.getName()));
    assertThat(ContractTypeUtil.getType("int256").getName(), is(Int256.class.getName()));
    assertThat(ContractTypeUtil.getType("uint256").getName(), is(Uint256.class.getName()));
    assertThat(ContractTypeUtil.getType("int8").getName(), is(Int8.class.getName()));
    assertThat(ContractTypeUtil.getType("uint8").getName(), is(Uint8.class.getName()));
    assertThat(ContractTypeUtil.getType("bool").getName(), is(Bool.class.getName()));
    assertThat(ContractTypeUtil.getType("bytes1").getName(), is(Bytes1.class.getName()));
    assertThat(ContractTypeUtil.getType("bytes32").getName(), is(Bytes32.class.getName()));
}
 
Example 26
Source Project: web3sdk   Source File: FunctionReturnDecoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testDecodeIndexedStringValue() {
    Utf8String string = new Utf8String("some text");
    String encoded = TypeEncoder.encodeString(string);
    String hash = Hash.sha3(encoded);

    assertThat(
            FunctionReturnDecoder.decodeIndexedValue(hash, new TypeReference<Utf8String>() {}),
            equalTo(new Bytes32(Numeric.hexStringToByteArray(hash))));
}
 
Example 27
Source Project: web3sdk   Source File: FunctionReturnDecoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testDecodeIndexedBytes32Value() {
    String rawInput = "0x1234567890123456789012345678901234567890123456789012345678901234";
    byte[] rawInputBytes = Numeric.hexStringToByteArray(rawInput);

    assertThat(
            FunctionReturnDecoder.decodeIndexedValue(rawInput, new TypeReference<Bytes32>() {}),
            equalTo(new Bytes32(rawInputBytes)));
}
 
Example 28
Source Project: web3sdk   Source File: FunctionReturnDecoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testDecodeIndexedDynamicBytesValue() {
    DynamicBytes bytes = new DynamicBytes(new byte[] {1, 2, 3, 4, 5});
    String encoded = TypeEncoder.encodeDynamicBytes(bytes);
    String hash = Hash.sha3(encoded);

    assertThat(
            FunctionReturnDecoder.decodeIndexedValue(
                    hash, new TypeReference<DynamicBytes>() {}),
            equalTo(new Bytes32(Numeric.hexStringToByteArray(hash))));
}
 
Example 29
Source Project: web3sdk   Source File: FunctionReturnDecoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testDecodeIndexedDynamicArrayValue() {
    DynamicArray<Uint256> array = new DynamicArray<>(new Uint256(BigInteger.TEN));
    String encoded = TypeEncoder.encodeDynamicArray(array);
    String hash = Hash.sha3(encoded);

    assertThat(
            FunctionReturnDecoder.decodeIndexedValue(
                    hash, new TypeReference<DynamicArray>() {}),
            equalTo(new Bytes32(Numeric.hexStringToByteArray(hash))));
}
 
Example 30
Source Project: evidenceSample   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);
}