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

The following examples show how to use org.fisco.bcos.web3j.abi.datatypes.generated.Uint256. 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: 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 2
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 3
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 4
Source Project: web3sdk   Source File: EventEncoderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testEventbuildMethodSignature2() {
    Event event =
            new Event(
                    "f",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<DynamicBytes>() {},
                            new TypeReference<Bool>() {},
                            new TypeReference<DynamicArray<Uint256>>() {}));

    assertThat(
            EventEncoder.buildMethodSignature(event.getName(), event.getParameters()),
            is("f(bytes,bool,uint256[])"));

    assertThat(
            EventEncoder.encode(event),
            is("0xa83b3f0112fa8ecc02937d734929bbaa30731fe27b20195418852fb64ac2837d"));

    assertThat(
            EventEncoder.buildEventSignature("f(bytes,bool,uint256[])"),
            is("0xa83b3f0112fa8ecc02937d734929bbaa30731fe27b20195418852fb64ac2837d"));
}
 
Example 5
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 6
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 7
Source Project: web3sdk   Source File: DagTransfer.java    License: Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple2<BigInteger, BigInteger>> userBalance(String user) {
    final Function function =
            new Function(
                    FUNC_USERBALANCE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(user)),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}));
    return new RemoteCall<Tuple2<BigInteger, BigInteger>>(
            new Callable<Tuple2<BigInteger, BigInteger>>() {
                @Override
                public Tuple2<BigInteger, BigInteger> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple2<BigInteger, BigInteger>(
                            (BigInteger) results.get(0).getValue(),
                            (BigInteger) results.get(1).getValue());
                }
            });
}
 
Example 8
Source Project: web3sdk   Source File: FunctionEncoderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testMixTypeEncode4() {

    // function  set0(string,address,uint256,int256)
    Function function =
            new Function(
                    "set0",
                    Arrays.asList(
                            new Utf8String("aaafadsfsfadsfdasf"),
                            new Address("0x35ef07393b57464e93deb59175ff72e6499450cf"),
                            new Uint256(11111),
                            new Int256(-11111)),
                    Collections.singletonList(
                            new TypeReference<DynamicArray<Utf8String>>() {}));

    assertThat(
            FunctionEncoder.encodeParameters(
                    function.getInputParameters(), new StringBuilder()),
            is(
                    "00000000000000000000000000000000000000000000000000000000000000800000000"
                            + "0000000000000000035ef07393b57464e93deb59175ff72e6499450cf000000000000000000000000"
                            + "0000000000000000000000000000000000002b67fffffffffffffffffffffffffffffffffffffffff"
                            + "fffffffffffffffffffd4990000000000000000000000000000000000000000000000000000000000"
                            + "0000126161616661647366736661647366646173660000000000000000000000000000"));
}
 
Example 9
Source Project: web3sdk   Source File: EventEncoderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testEventbuildMethodSignature6() {
    Event event =
            new Event(
                    "test6",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Uint256>() {},
                            new TypeReference<Int256>() {},
                            new TypeReference<Utf8String>() {},
                            new TypeReference<DynamicArray<Utf8String>>() {},
                            new TypeReference<StaticArray3<Utf8String>>() {}));

    assertThat(
            EventEncoder.buildMethodSignature(event.getName(), event.getParameters()),
            is("test6(uint256,int256,string,string[],string[3])"));

    assertThat(
            EventEncoder.encode(event),
            is("0x5199068657caa55d23ad866ba738a7f21e567e6f50aa8173ac108efdd5d3bb79"));

    assertThat(
            EventEncoder.buildEventSignature("test6(uint256,int256,string,string[],string[3])"),
            is("0x5199068657caa55d23ad866ba738a7f21e567e6f50aa8173ac108efdd5d3bb79"));
}
 
Example 10
Source Project: web3sdk   Source File: EventEncoderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testEventbuildMethodSignature0() {
    Event event =
            new Event(
                    "g",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<DynamicArray<DynamicArray<Uint256>>>() {},
                            new TypeReference<DynamicArray<Utf8String>>() {}));

    assertThat(
            EventEncoder.buildMethodSignature(event.getName(), event.getParameters()),
            is("g(uint256[][],string[])"));

    assertThat(
            EventEncoder.encode(event),
            is("0x2289b18cd8c6e198648b35d3bcf2ff8668984543f01927711c161bcf7b5e1bba"));

    assertThat(
            EventEncoder.buildEventSignature("g(uint256[][],string[])"),
            is("0x2289b18cd8c6e198648b35d3bcf2ff8668984543f01927711c161bcf7b5e1bba"));
}
 
Example 11
Source Project: web3sdk   Source File: FunctionReturnDecoderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void testDecodeStaticArrayValue() {
    List<TypeReference<Type>> outputParameters = new ArrayList<>(1);
    outputParameters.add((TypeReference) new TypeReference<StaticArray2<Uint256>>() {});
    outputParameters.add((TypeReference) new TypeReference<Uint256>() {});

    List<Type> decoded =
            FunctionReturnDecoder.decode(
                    "0x0000000000000000000000000000000000000000000000000000000000000037"
                            + "0000000000000000000000000000000000000000000000000000000000000001"
                            + "000000000000000000000000000000000000000000000000000000000000000a",
                    outputParameters);

    List<Type> expected =
            Arrays.asList(
                    new StaticArray2<Uint256>(
                            new Uint256(BigInteger.valueOf(55)), new Uint256(BigInteger.ONE)),
                    new Uint256(BigInteger.TEN));
    assertThat(decoded, equalTo(expected));
}
 
Example 12
Source Project: web3sdk   Source File: EventEncoderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testEventbuildMethodSignature9() {
    Event event =
            new Event(
                    "test9",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Utf8String>() {},
                            new TypeReference<Uint256>() {},
                            new TypeReference<StaticArray6<Uint256>>() {},
                            new TypeReference<DynamicArray<Uint256>>() {},
                            new TypeReference<Bool>() {},
                            new TypeReference<Address>() {}));

    assertThat(
            EventEncoder.buildMethodSignature(event.getName(), event.getParameters()),
            is("test9(string,uint256,uint256[6],uint256[],bool,address)"));

    assertThat(
            EventEncoder.encode(event),
            is("0xa37d8a63087cf5837e0b9ff13d07d756479f8afdfe4b05ea3dfdc98154ef58ed"));

    assertThat(
            EventEncoder.buildEventSignature(
                    "test9(string,uint256,uint256[6],uint256[],bool,address)"),
            is("0xa37d8a63087cf5837e0b9ff13d07d756479f8afdfe4b05ea3dfdc98154ef58ed"));
}
 
Example 13
Source Project: web3sdk   Source File: EventEncoderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testEventbuildMethodSignature8() {
    Event event =
            new Event(
                    "test8",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Utf8String>() {},
                            new TypeReference<Address>() {},
                            new TypeReference<Uint256>() {},
                            new TypeReference<Int256>() {}));

    assertThat(
            EventEncoder.buildMethodSignature(event.getName(), event.getParameters()),
            is("test8(string,address,uint256,int256)"));

    assertThat(
            EventEncoder.encode(event),
            is("0xfa3d7a982eb00eec003de55d3e9266fa4b9ccd6a3a067b75b24ef6b4cb9b12c4"));
    assertThat(
            EventEncoder.buildEventSignature("test8(string,address,uint256,int256)"),
            is("0xfa3d7a982eb00eec003de55d3e9266fa4b9ccd6a3a067b75b24ef6b4cb9b12c4"));
}
 
Example 14
Source Project: web3sdk   Source File: FunctionEncoderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testEncodeInt() {
    assertThat(
            FunctionEncoder.encodeParameters(Arrays.asList(new Int256(0)), new StringBuilder()),
            is("0000000000000000000000000000000000000000000000000000000000000000"));
    assertThat(
            FunctionEncoder.encodeParameters(
                    Arrays.asList(new Int256(1111)), new StringBuilder()),
            is("0000000000000000000000000000000000000000000000000000000000000457"));
    assertThat(
            FunctionEncoder.encodeParameters(
                    Arrays.asList(new Int256(new BigInteger("-1"))), new StringBuilder()),
            is("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
    assertThat(
            FunctionEncoder.encodeParameters(
                    Arrays.asList(new Uint256(Long.MAX_VALUE)), new StringBuilder()),
            is("0000000000000000000000000000000000000000000000007fffffffffffffff"));
}
 
Example 15
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 16
Source Project: web3sdk   Source File: FunctionReturnDecoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMixTypeDecode4() {

    // function function(string,address,uint256,int256) constant
    // returns(string,address,uint256,int256)
    Function function =
            new Function(
                    "function",
                    Collections.<Type>emptyList(),
                    Arrays.asList(
                            new TypeReference<Utf8String>() {},
                            new TypeReference<Address>() {},
                            new TypeReference<Uint256>() {},
                            new TypeReference<Int256>() {}));

    assertThat(
            FunctionReturnDecoder.decode(
                    "00000000000000000000000000000000000000000000000000000000000000800000000"
                            + "0000000000000000035ef07393b57464e93deb59175ff72e6499450cf000000000000000000000000"
                            + "0000000000000000000000000000000000002b67fffffffffffffffffffffffffffffffffffffffff"
                            + "fffffffffffffffffffd4990000000000000000000000000000000000000000000000000000000000"
                            + "0000126161616661647366736661647366646173660000000000000000000000000000",
                    function.getOutputParameters()),
            equalTo(
                    Arrays.asList(
                            new Utf8String("aaafadsfsfadsfdasf"),
                            new Address("0x35ef07393b57464e93deb59175ff72e6499450cf"),
                            new Uint256(11111),
                            new Int256(-11111))));
}
 
Example 17
Source Project: WeBASE-Front   Source File: HelloWorld.java    License: Apache License 2.0 5 votes vote down vote up
public RemoteCall<List> get() {
    final Function function = new Function(FUNC_GET, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Uint256>>() {}));
    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: HelloWorld.java    License: Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> set(List<BigInteger> _ua) {
    final Function function = new Function(
            FUNC_SET, 
            Arrays.<Type>asList(_ua.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(_ua, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class))), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example 19
Source Project: WeBASE-Front   Source File: HelloWorld.java    License: Apache License 2.0 5 votes vote down vote up
public void set(List<BigInteger> _ua, TransactionSucCallback callback) {
    final Function function = new Function(
            FUNC_SET, 
            Arrays.<Type>asList(_ua.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(_ua, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class))), 
            Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example 20
Source Project: WeBASE-Front   Source File: HelloWorld.java    License: Apache License 2.0 5 votes vote down vote up
public String setSeq(List<BigInteger> _ua) {
    final Function function = new Function(
            FUNC_SET, 
            Arrays.<Type>asList(_ua.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(_ua, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class))), 
            Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example 21
Source Project: web3sdk   Source File: FunctionEncoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMixTypeEncode2() {

    Function function =
            new Function(
                    "set0",
                    Arrays.asList(
                            new Utf8String("dave"),
                            new Bool(true),
                            new DynamicArray<>(new Uint256(1), new Uint256(2), new Uint256(3))),
                    Collections.singletonList(
                            new TypeReference<DynamicArray<Utf8String>>() {}));

    assertThat(
            FunctionEncoder.encodeParameters(
                    function.getInputParameters(), new StringBuilder()),
            is(
                    "0000000000000000000000000000000000000000000000000000000000000060"
                            + "0000000000000000000000000000000000000000000000000000000000000001"
                            + "00000000000000000000000000000000000000000000000000000000000000a0"
                            + "0000000000000000000000000000000000000000000000000000000000000004"
                            + "6461766500000000000000000000000000000000000000000000000000000000"
                            + "0000000000000000000000000000000000000000000000000000000000000003"
                            + "0000000000000000000000000000000000000000000000000000000000000001"
                            + "0000000000000000000000000000000000000000000000000000000000000002"
                            + "0000000000000000000000000000000000000000000000000000000000000003"));
}
 
Example 22
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 23
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 24
Source Project: WeBASE-Front   Source File: Ok.java    License: Apache License 2.0 5 votes vote down vote up
public RemoteCall<BigInteger> get() {
  final Function function =
      new Function(
          FUNC_GET,
          Arrays.<Type>asList(),
          Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
  return executeRemoteCallSingleValueReturn(function, BigInteger.class);
}
 
Example 25
Source Project: WeBASE-Collect-Bee   Source File: BytesUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static String uint256DynamicArrayToString(List<Uint256> list) {
    List<String> stringList = new ArrayList<>();
    for (int i = 0; i < list.size(); i++) {
        stringList.add(list.get(i).getValue().toString());
    }
    return JacksonUtils.toJson(stringList);
}
 
Example 26
Source Project: WeBASE-Collect-Bee   Source File: BytesUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static String uint256ArrayToString(List<Uint256> list) {
    List<String> stringList = new ArrayList<>();
    for (int i = 0; i < list.size(); i++) {
        stringList.add(list.get(i).getValue().toString());
    }
    return JacksonUtils.toJson(stringList);
}
 
Example 27
Source Project: WeEvent   Source File: TopicController.java    License: 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 28
Source Project: web3sdk   Source File: FunctionReturnDecoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMixTypeDecod11() {

    // function set0(string[],uint256[],string[])
    Function function =
            new Function(
                    "set0",
                    Collections.<Type>emptyList(),
                    Arrays.asList(
                            new TypeReference<DynamicArray<Utf8String>>() {},
                            new TypeReference<DynamicArray<Uint256>>() {},
                            new TypeReference<DynamicArray<Utf8String>>() {}));

    assertThat(
            FunctionReturnDecoder.decode(
                    "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000076f63746f7075730000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000076f63746f707573000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000546b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b61616161616161616161616161616161616161616100000000000000000000000000000000000000000000000000000000000000000000000000000000000000036161610000000000000000000000000000000000000000000000000000000000",
                    function.getOutputParameters()),
            equalTo(
                    Arrays.asList(
                            new DynamicArray(
                                    new Utf8String("octopus"), new Utf8String("octopus")),
                            new DynamicArray(new Uint256(1), new Uint256(2)),
                            new DynamicArray(
                                    new Utf8String(
                                            "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkaaaaaaaaaaaaaaaaaaaaa"),
                                    new Utf8String("aaa")))));
}
 
Example 29
Source Project: WeEvent   Source File: TopicController.java    License: 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 30
Source Project: WeEvent   Source File: Topic.java    License: Apache License 2.0 5 votes vote down vote up
public Tuple1<BigInteger> getAddOperatorOutput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getOutput();
    final Function function = new Function(FUNC_ADDOPERATOR, 
            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()
            );
}