org.fisco.bcos.web3j.abi.datatypes.generated.Int256 Java Examples

The following examples show how to use org.fisco.bcos.web3j.abi.datatypes.generated.Int256. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventEncoderTest.java    From web3sdk with 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 #2
Source File: MixContract.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>> read(String name) {
    final Function function =
            new Function(
                    FUNC_READ,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name)),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<DynamicArray<Bytes32>>() {},
                            new TypeReference<DynamicArray<Int256>>() {},
                            new TypeReference<DynamicArray<Bytes32>>() {}));
    return new RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>(
            new Callable<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>() {
                @Override
                public Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>> call()
                        throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>(
                            convertToNative((List<Bytes32>) results.get(0).getValue()),
                            convertToNative((List<Int256>) results.get(1).getValue()),
                            convertToNative((List<Bytes32>) results.get(2).getValue()));
                }
            });
}
 
Example #3
Source File: FunctionEncoderTest.java    From web3sdk with 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 #4
Source File: TableTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>> select(String name) {
    final Function function =
            new Function(
                    FUNC_SELECT,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name)),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<DynamicArray<Bytes32>>() {},
                            new TypeReference<DynamicArray<Int256>>() {},
                            new TypeReference<DynamicArray<Bytes32>>() {}));
    return new RemoteCall<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>(
            new Callable<Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>>() {
                @Override
                public Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>> call()
                        throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple3<List<byte[]>, List<BigInteger>, List<byte[]>>(
                            convertToNative((List<Bytes32>) results.get(0).getValue()),
                            convertToNative((List<Int256>) results.get(1).getValue()),
                            convertToNative((List<Bytes32>) results.get(2).getValue()));
                }
            });
}
 
Example #5
Source File: EventEncoderTest.java    From web3sdk with 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 #6
Source File: ResultEntityTest.java    From web3sdk with 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 #7
Source File: ChainGovernance.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple2<Boolean, BigInteger>> queryCommitteeMemberWeight(String user) {
    final Function function =
            new Function(
                    FUNC_QUERYCOMMITTEEMEMBERWEIGHT,
                    Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Address(user)),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Bool>() {}, new TypeReference<Int256>() {}));
    return new RemoteCall<Tuple2<Boolean, BigInteger>>(
            new Callable<Tuple2<Boolean, BigInteger>>() {
                @Override
                public Tuple2<Boolean, BigInteger> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple2<Boolean, BigInteger>(
                            (Boolean) results.get(0).getValue(),
                            (BigInteger) results.get(1).getValue());
                }
            });
}
 
Example #8
Source File: ContractLifeCyclePrecompiled.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple2<BigInteger, List<String>>> listManager(String addr) {
    final Function function =
            new Function(
                    FUNC_LISTMANAGER,
                    Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Address(addr)),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Int256>() {},
                            new TypeReference<DynamicArray<Address>>() {}));
    return new RemoteCall<Tuple2<BigInteger, List<String>>>(
            new Callable<Tuple2<BigInteger, List<String>>>() {
                @Override
                public Tuple2<BigInteger, List<String>> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple2<BigInteger, List<String>>(
                            (BigInteger) results.get(0).getValue(),
                            convertToNative((List<Address>) results.get(1).getValue()));
                }
            });
}
 
Example #9
Source File: TableTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple3<List<String>, List<BigInteger>, List<String>>> select(String name) {
    final Function function =
            new Function(
                    FUNC_SELECT,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name)),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<DynamicArray<Utf8String>>() {},
                            new TypeReference<DynamicArray<Int256>>() {},
                            new TypeReference<DynamicArray<Utf8String>>() {}));
    return new RemoteCall<Tuple3<List<String>, List<BigInteger>, List<String>>>(
            new Callable<Tuple3<List<String>, List<BigInteger>, List<String>>>() {
                @Override
                public Tuple3<List<String>, List<BigInteger>, List<String>> call()
                        throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple3<List<String>, List<BigInteger>, List<String>>(
                            convertToNative((List<Utf8String>) results.get(0).getValue()),
                            convertToNative((List<Int256>) results.get(1).getValue()),
                            convertToNative((List<Utf8String>) results.get(2).getValue()));
                }
            });
}
 
Example #10
Source File: ContractLifeCyclePrecompiled.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple2<BigInteger, String>> getStatus(String addr) {
    final Function function =
            new Function(
                    FUNC_GETSTATUS,
                    Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Address(addr)),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Int256>() {},
                            new TypeReference<Utf8String>() {}));
    return new RemoteCall<Tuple2<BigInteger, String>>(
            new Callable<Tuple2<BigInteger, String>>() {
                @Override
                public Tuple2<BigInteger, String> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple2<BigInteger, String>(
                            (BigInteger) results.get(0).getValue(),
                            (String) results.get(1).getValue());
                }
            });
}
 
Example #11
Source File: CallContract.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public Object type2Object(Type data, String javaType) throws Exception {
    switch (javaType) {
        case "Int":
            {
                return ((BigInteger) data.getValue()).intValue();
            }
        case "String":
            {
                return (String) data.getValue();
            }
        case "IntArray":
            {
                List<BigInteger> bigIntegers = convertList((List<Int256>) data.getValue());
                return bigIntegerstoIntegers(bigIntegers);
            }
        case "StringArray":
            {
                return convertList((List<Utf8String>) data.getValue());
            }
        default:
            {
                throw new Exception("Unsupported type :" + javaType);
            }
    }
}
 
Example #12
Source File: OkD.java    From web3sdk with 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<Int256>() {}));
    return executeRemoteCallSingleValueReturn(function, BigInteger.class);
}
 
Example #13
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> remove(String name, BigInteger item_id) {
    final Function function =
            new Function(
                    FUNC_REMOVE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #14
Source File: OkD.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> trans(String from_accout, BigInteger num) {
    final Function function =
            new Function(
                    FUNC_TRANS,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(from_accout),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(num)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #15
Source File: OkD.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void trans(String from_accout, BigInteger num, TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_TRANS,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(from_accout),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(num)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #16
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> update(
        String name, BigInteger item_id, String item_name) {
    final Function function =
            new Function(
                    FUNC_UPDATE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(item_name)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #17
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public String removeSeq(String name, BigInteger item_id) {
    final Function function =
            new Function(
                    FUNC_REMOVE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id)),
                    Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #18
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void insert(
        String name, BigInteger item_id, String item_name, TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_INSERT,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(item_name)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #19
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public String insertSeq(String name, BigInteger item_id, String item_name) {
    final Function function =
            new Function(
                    FUNC_INSERT,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(item_name)),
                    Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #20
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public String updateSeq(String name, BigInteger item_id, String item_name) {
    final Function function =
            new Function(
                    FUNC_UPDATE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(item_name)),
                    Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #21
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void insert(
        String name, BigInteger item_id, String item_name, TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_INSERT,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(item_name)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #22
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void insert(
        String name, BigInteger item_id, String item_name, TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_INSERT,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(item_name)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #23
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> insert(
        String name, BigInteger item_id, String item_name) {
    final Function function =
            new Function(
                    FUNC_INSERT,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(item_name)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #24
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> remove(String name, BigInteger item_id) {
    final Function function =
            new Function(
                    FUNC_REMOVE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #25
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void update(
        String name, BigInteger item_id, String item_name, TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_UPDATE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(item_name)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #26
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> update(
        String name, BigInteger item_id, String item_name) {
    final Function function =
            new Function(
                    FUNC_UPDATE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(item_name)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #27
Source File: MixContract.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void insert(
        String name, BigInteger item_id, String item_name, TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_INSERT,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(item_name)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #28
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public String insertSeq(String name, BigInteger item_id, String item_name) {
    final Function function =
            new Function(
                    FUNC_INSERT,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(item_name)),
                    Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #29
Source File: MixContract.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<BigInteger> totalKeys() {
    final Function function =
            new Function(
                    FUNC_TOTALKEYS,
                    Arrays.<Type>asList(),
                    Arrays.<TypeReference<?>>asList(new TypeReference<Int256>() {}));
    return executeRemoteCallSingleValueReturn(function, BigInteger.class);
}
 
Example #30
Source File: TableTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> remove(String name, BigInteger item_id) {
    final Function function =
            new Function(
                    FUNC_REMOVE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Int256(item_id)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}