org.web3j.abi.datatypes.generated.Uint64 Java Examples

The following examples show how to use org.web3j.abi.datatypes.generated.Uint64. 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: Proposal.java    From client-sdk-java with Apache License 2.0 6 votes vote down vote up
public List<Type> getSubmitInputParameters() {
    if (proposalType == ProposalType.TEXT_PROPOSAL) {
        return Arrays.asList(new BytesType(Numeric.hexStringToByteArray(this.verifier)),
                new Utf8String(this.piPid));
    } else if (proposalType == ProposalType.VERSION_PROPOSAL) {
        return Arrays.asList(new BytesType(Numeric.hexStringToByteArray(this.verifier)),
                new Utf8String(this.piPid),
                new Uint32(this.newVersion),
                new Uint64(this.endVotingBlock));
    } else if (proposalType == ProposalType.CANCEL_PROPOSAL) {
        return Arrays.asList(new BytesType(Numeric.hexStringToByteArray(this.verifier)),
                new Utf8String(this.piPid),
                new Uint64(this.endVotingBlock),
                new BytesType(Numeric.hexStringToByteArray(this.toBeCanceled)));
    } else if (proposalType == ProposalType.PARAM_PROPOSAL) {
        return Arrays.asList(new BytesType(Numeric.hexStringToByteArray(this.verifier)),
                new Utf8String(this.piPid),
                new Utf8String(this.module),
                new Utf8String(this.name),
                new Utf8String(this.newValue));
    }

    return new ArrayList<>();
}
 
Example #2
Source File: UtilsTest.java    From web3j with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetTypeName() {
    assertEquals(Utils.getTypeName(new TypeReference<Uint>() {}), ("uint256"));
    assertEquals(Utils.getTypeName(new TypeReference<Int>() {}), ("int256"));
    assertEquals(Utils.getTypeName(new TypeReference<Ufixed>() {}), ("ufixed256"));
    assertEquals(Utils.getTypeName(new TypeReference<Fixed>() {}), ("fixed256"));

    assertEquals(Utils.getTypeName(new TypeReference<Uint64>() {}), ("uint64"));
    assertEquals(Utils.getTypeName(new TypeReference<Int64>() {}), ("int64"));
    assertEquals(Utils.getTypeName(new TypeReference<Bool>() {}), ("bool"));
    assertEquals(Utils.getTypeName(new TypeReference<Utf8String>() {}), ("string"));
    assertEquals(Utils.getTypeName(new TypeReference<DynamicBytes>() {}), ("bytes"));

    assertEquals(
            Utils.getTypeName(
                    new TypeReference.StaticArrayTypeReference<StaticArray<Uint>>(5) {}),
            ("uint256[5]"));
    assertEquals(Utils.getTypeName(new TypeReference<DynamicArray<Uint>>() {}), ("uint256[]"));
}
 
Example #3
Source File: ENS.java    From etherscan-explorer with GNU General Public License v3.0 6 votes vote down vote up
public Observable<NewTTLEventResponse> newTTLEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("NewTTL", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>() {}),
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}));
    EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
    filter.addSingleTopic(EventEncoder.encode(event));
    return web3j.ethLogObservable(filter).map(new Func1<Log, NewTTLEventResponse>() {
        @Override
        public NewTTLEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            NewTTLEventResponse typedResponse = new NewTTLEventResponse();
            typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.ttl = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            return typedResponse;
        }
    });
}
 
Example #4
Source File: UtilsTest.java    From etherscan-explorer with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testGetTypeName() throws ClassNotFoundException {
    assertThat(Utils.getTypeName(new TypeReference<Uint>(){}), is("uint256"));
    assertThat(Utils.getTypeName(new TypeReference<Int>(){}), is("int256"));
    assertThat(Utils.getTypeName(new TypeReference<Ufixed>(){}), is("ufixed256"));
    assertThat(Utils.getTypeName(new TypeReference<Fixed>(){}), is("fixed256"));

    assertThat(Utils.getTypeName(new TypeReference<Uint64>(){}), is("uint64"));
    assertThat(Utils.getTypeName(new TypeReference<Int64>(){}), is("int64"));
    assertThat(Utils.getTypeName(new TypeReference<Bool>(){}), is("bool"));
    assertThat(Utils.getTypeName(new TypeReference<Utf8String>(){}), is("string"));
    assertThat(Utils.getTypeName(new TypeReference<DynamicBytes>(){}), is("bytes"));

    assertThat(Utils.getTypeName(
            new TypeReference.StaticArrayTypeReference<StaticArray<Uint>>(5){}),
            is("uint256[5]"));
    assertThat(Utils.getTypeName(
            new TypeReference<DynamicArray<Uint>>(){}),
            is("uint256[]"));
}
 
Example #5
Source File: TypeDecoderTest.java    From etherscan-explorer with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testUintDecode() {

    assertThat(TypeDecoder.decodeNumeric(
            "0000000000000000000000000000000000000000000000000000000000000000",
            Uint64.class
            ),
            is(new Uint64(BigInteger.ZERO)));

    assertThat(TypeDecoder.decodeNumeric(
            "0000000000000000000000000000000000000000000000007fffffffffffffff",
            Uint64.class
            ),
            is(new Uint64(BigInteger.valueOf(Long.MAX_VALUE))));

    assertThat(TypeDecoder.decodeNumeric(
            "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
            Uint64.class
            ),
            is(new Uint64(new BigInteger(
                    "0ffffffffffffffff", 16))));
}
 
Example #6
Source File: TypeEncoderTest.java    From client-sdk-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testUintEncode() {
    Uint zero = new Uint64(BigInteger.ZERO);
    assertThat(TypeEncoder.encodeNumeric(zero),
            is("0000000000000000000000000000000000000000000000000000000000000000"));

    Uint maxLong = new Uint64(BigInteger.valueOf(Long.MAX_VALUE));
    assertThat(TypeEncoder.encodeNumeric(maxLong),
            is("0000000000000000000000000000000000000000000000007fffffffffffffff"));

    Uint maxValue = new Uint(
            new BigInteger("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
            16));
    assertThat(TypeEncoder.encodeNumeric(maxValue),
            is("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));

    Uint largeValue = new Uint(
            new BigInteger("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe",
            16));
    assertThat(TypeEncoder.encodeNumeric(largeValue),
            is("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"));
}
 
Example #7
Source File: TypeEncoderTest.java    From etherscan-explorer with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testUintEncode() {
    Uint zero = new Uint64(BigInteger.ZERO);
    assertThat(TypeEncoder.encodeNumeric(zero),
            is("0000000000000000000000000000000000000000000000000000000000000000"));

    Uint maxLong = new Uint64(BigInteger.valueOf(Long.MAX_VALUE));
    assertThat(TypeEncoder.encodeNumeric(maxLong),
            is("0000000000000000000000000000000000000000000000007fffffffffffffff"));

    Uint maxValue = new Uint(
            new BigInteger("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
            16));
    assertThat(TypeEncoder.encodeNumeric(maxValue),
            is("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));

    Uint largeValue = new Uint(
            new BigInteger("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe",
            16));
    assertThat(TypeEncoder.encodeNumeric(largeValue),
            is("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"));
}
 
Example #8
Source File: UtilsTest.java    From client-sdk-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetTypeName() throws ClassNotFoundException {
    assertThat(Utils.getTypeName(new TypeReference<Uint>(){}), is("uint256"));
    assertThat(Utils.getTypeName(new TypeReference<Int>(){}), is("int256"));
    assertThat(Utils.getTypeName(new TypeReference<Ufixed>(){}), is("ufixed256"));
    assertThat(Utils.getTypeName(new TypeReference<Fixed>(){}), is("fixed256"));

    assertThat(Utils.getTypeName(new TypeReference<Uint64>(){}), is("uint64"));
    assertThat(Utils.getTypeName(new TypeReference<Int64>(){}), is("int64"));
    assertThat(Utils.getTypeName(new TypeReference<Bool>(){}), is("bool"));
    assertThat(Utils.getTypeName(new TypeReference<Utf8String>(){}), is("string"));
    assertThat(Utils.getTypeName(new TypeReference<DynamicBytes>(){}), is("bytes"));

    assertThat(Utils.getTypeName(
            new TypeReference.StaticArrayTypeReference<StaticArray<Uint>>(5){}),
            is("uint256[5]"));
    assertThat(Utils.getTypeName(
            new TypeReference<DynamicArray<Uint>>(){}),
            is("uint256[]"));
}
 
Example #9
Source File: TypeDecoderTest.java    From client-sdk-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testUintDecode() {

    assertThat(TypeDecoder.decodeNumeric(
            "0000000000000000000000000000000000000000000000000000000000000000",
            Uint64.class
            ),
            is(new Uint64(BigInteger.ZERO)));

    assertThat(TypeDecoder.decodeNumeric(
            "0000000000000000000000000000000000000000000000007fffffffffffffff",
            Uint64.class
            ),
            is(new Uint64(BigInteger.valueOf(Long.MAX_VALUE))));

    assertThat(TypeDecoder.decodeNumeric(
            "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
            Uint64.class
            ),
            is(new Uint64(new BigInteger(
                    "0ffffffffffffffff", 16))));
}
 
Example #10
Source File: SolidityFunctionWrapperTest.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuildTypeName() {
    assertThat(buildTypeName("uint256"),
            is(ClassName.get(Uint256.class)));
    assertThat(buildTypeName("uint64"),
            is(ClassName.get(Uint64.class)));
    assertThat(buildTypeName("string"),
            is(ClassName.get(Utf8String.class)));

    assertThat(buildTypeName("uint256[]"),
            is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[] storage"),
            is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[] memory"),
            is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[10]"),
            is(ParameterizedTypeName.get(StaticArray10.class, Uint256.class)));

    assertThat(buildTypeName("uint256[33]"),
            is(ParameterizedTypeName.get(StaticArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[10][3]"),
            is(ParameterizedTypeName.get(ClassName.get(StaticArray3.class),
                    ParameterizedTypeName.get(StaticArray10.class, Uint256.class))));

    assertThat(buildTypeName("uint256[2][]"),
            is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(StaticArray2.class, Uint256.class))));

    assertThat(buildTypeName("uint256[33][]"),
            is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(StaticArray.class, Uint256.class))));

    assertThat(buildTypeName("uint256[][]"),
            is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(DynamicArray.class, Uint256.class))));
}
 
Example #11
Source File: DelegateContract.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
private Function createUnDelegateFunction(String nodeId, BigInteger stakingBlockNum, BigInteger amount) {
	Function function = new Function(FunctionType.WITHDREW_DELEGATE_FUNC_TYPE,
            Arrays.asList(new Uint64(stakingBlockNum)
                    , new BytesType(Numeric.hexStringToByteArray(nodeId))
                    , new Uint256(amount)));
    return function;
}
 
Example #12
Source File: DelegateContract.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 * 查询当前单个委托信息
 *
 * @param nodeId          验证人的节点Id
 * @param delAddr         委托人账户地址
 * @param stakingBlockNum 发起质押时的区块高度
 * @return
 */
public RemoteCall<CallResponse<Delegation>> getDelegateInfo(String nodeId, String delAddr, BigInteger stakingBlockNum) {

    Function function = new Function(FunctionType.GET_DELEGATEINFO_FUNC_TYPE,
            Arrays.asList(new Uint64(stakingBlockNum)
                    , new BytesType(Numeric.hexStringToByteArray(delAddr))
                    , new BytesType(Numeric.hexStringToByteArray(nodeId))));

    return executeRemoteCallObjectValueReturn(function, Delegation.class);
}
 
Example #13
Source File: PlatOnTypeDecoderTest.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testUintDecode() {

    assertThat(PlatOnTypeDecoder.decode(
    		Numeric.hexStringToByteArray("0000000000000000"),
            Uint64.class
            ),
            is(new Uint64(BigInteger.ZERO)));

    assertThat(PlatOnTypeDecoder.decode(
    		Numeric.hexStringToByteArray("7fffffffffffffff"),
            Uint64.class
            ),
            is(new Uint64(BigInteger.valueOf(Long.MAX_VALUE))));
}
 
Example #14
Source File: ENS.java    From web3j with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> setTTL(byte[] node, BigInteger ttl) {
    final Function function = new Function(
            FUNC_SETTTL, 
            Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(node), 
            new org.web3j.abi.datatypes.generated.Uint64(ttl)), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #15
Source File: PlatOnTypeEncoderTest.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testUintEncode() {
    Uint zero = new Uint64(BigInteger.ZERO);
    assertThat(PlatOnTypeEncoder.encode(zero),
            is("0000000000000000"));

    Uint maxLong = new Uint64(BigInteger.valueOf(Long.MAX_VALUE));
    assertThat(PlatOnTypeEncoder.encode(maxLong),
            is("7fffffffffffffff"));	
}
 
Example #16
Source File: SolidityFunctionWrapperTest.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testBuildTypeName() {
    assertThat(buildTypeName("uint256"),
            is(ClassName.get(Uint256.class)));
    assertThat(buildTypeName("uint64"),
            is(ClassName.get(Uint64.class)));
    assertThat(buildTypeName("string"),
            is(ClassName.get(Utf8String.class)));

    assertThat(buildTypeName("uint256[]"),
            is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[] storage"),
            is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[] memory"),
            is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[10]"),
            is(ParameterizedTypeName.get(StaticArray10.class, Uint256.class)));

    assertThat(buildTypeName("uint256[33]"),
            is(ParameterizedTypeName.get(StaticArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[10][3]"),
            is(ParameterizedTypeName.get(ClassName.get(StaticArray3.class),
                    ParameterizedTypeName.get(StaticArray10.class, Uint256.class))));

    assertThat(buildTypeName("uint256[2][]"),
            is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(StaticArray2.class, Uint256.class))));

    assertThat(buildTypeName("uint256[33][]"),
            is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(StaticArray.class, Uint256.class))));

    assertThat(buildTypeName("uint256[][]"),
            is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(DynamicArray.class, Uint256.class))));
}
 
Example #17
Source File: ENS.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
public List<NewTTLEventResponse> getNewTTLEvents(TransactionReceipt transactionReceipt) {
    final Event event = new Event("NewTTL", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>() {}),
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}));
    List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
    ArrayList<NewTTLEventResponse> responses = new ArrayList<NewTTLEventResponse>(valueList.size());
    for (EventValues eventValues : valueList) {
        NewTTLEventResponse typedResponse = new NewTTLEventResponse();
        typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
        typedResponse.ttl = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #18
Source File: ENS.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> setTTL(byte[] node, BigInteger ttl) {
    Function function = new Function(
            "setTTL",
            Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(node),
            new org.web3j.abi.datatypes.generated.Uint64(ttl)),
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #19
Source File: TypeEncoderTest.java    From etherscan-explorer with GNU General Public License v3.0 4 votes vote down vote up
@Test(expected = UnsupportedOperationException.class)
public void testInvalidUintEncode() {
    new Uint64(BigInteger.valueOf(-1));
}
 
Example #20
Source File: SolidityFunctionWrapperTest.java    From web3j with Apache License 2.0 4 votes vote down vote up
@Test
public void testBuildTypeName() throws Exception {
    assertEquals(buildTypeName("uint256"), (ClassName.get(Uint256.class)));
    assertEquals(buildTypeName("uint64"), (ClassName.get(Uint64.class)));
    assertEquals(buildTypeName("string"), (ClassName.get(Utf8String.class)));

    assertEquals(
            buildTypeName("uint256[]"),
            (ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertEquals(
            buildTypeName("uint256[] storage"),
            (ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertEquals(
            buildTypeName("uint256[] memory"),
            (ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertEquals(
            buildTypeName("uint256[10]"),
            (ParameterizedTypeName.get(StaticArray10.class, Uint256.class)));

    assertEquals(
            buildTypeName("uint256[33]"),
            (ParameterizedTypeName.get(StaticArray.class, Uint256.class)));

    assertEquals(
            buildTypeName("uint256[10][3]"),
            (ParameterizedTypeName.get(
                    ClassName.get(StaticArray3.class),
                    ParameterizedTypeName.get(StaticArray10.class, Uint256.class))));

    assertEquals(
            buildTypeName("uint256[2][]"),
            (ParameterizedTypeName.get(
                    ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(StaticArray2.class, Uint256.class))));

    assertEquals(
            buildTypeName("uint256[33][]"),
            (ParameterizedTypeName.get(
                    ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(StaticArray.class, Uint256.class))));

    assertEquals(
            buildTypeName("uint256[][]"),
            (ParameterizedTypeName.get(
                    ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(DynamicArray.class, Uint256.class))));
}
 
Example #21
Source File: ENS.java    From web3j with Apache License 2.0 4 votes vote down vote up
public RemoteCall<BigInteger> ttl(byte[] node) {
    final Function function = new Function(FUNC_TTL, 
            Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(node)), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}));
    return executeRemoteCallSingleValueReturn(function, BigInteger.class);
}
 
Example #22
Source File: TypeEncoderTest.java    From web3j with Apache License 2.0 4 votes vote down vote up
@Test
public void testInvalidUintEncode() {
    assertThrows(UnsupportedOperationException.class, () -> new Uint64(BigInteger.valueOf(-1)));
}
 
Example #23
Source File: ENS.java    From etherscan-explorer with GNU General Public License v3.0 4 votes vote down vote up
public RemoteCall<BigInteger> ttl(byte[] node) {
    Function function = new Function("ttl",
            Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(node)),
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}));
    return executeRemoteCallSingleValueReturn(function, BigInteger.class);
}
 
Example #24
Source File: PlatOnTypeEncoderTest.java    From client-sdk-java with Apache License 2.0 4 votes vote down vote up
@Test(expected = UnsupportedOperationException.class)
public void testInvalidUintEncode() {
    new Uint64(BigInteger.valueOf(-1));
}
 
Example #25
Source File: TypeEncoderTest.java    From client-sdk-java with Apache License 2.0 4 votes vote down vote up
@Test(expected = UnsupportedOperationException.class)
public void testInvalidUintEncode() {
    new Uint64(BigInteger.valueOf(-1));
}
 
Example #26
Source File: SlashContract.java    From client-sdk-java with Apache License 2.0 3 votes vote down vote up
/**
 * 查询节点是否已被举报过多签
 *
 * @param doubleSignType 代表双签类型,1:prepare,2:viewChange
 * @param address        举报的节点地址
 * @param blockNumber    多签的块高
 * @return
 */
public RemoteCall<CallResponse<String>> checkDoubleSign(DuplicateSignType doubleSignType, String address, BigInteger blockNumber) {
    Function function = new Function(FunctionType.CHECK_DOUBLESIGN_FUNC_TYPE,
            Arrays.asList(new Uint32(doubleSignType.getValue())
                    , new BytesType(Numeric.hexStringToByteArray(address))
                    , new Uint64(blockNumber)));
    return executeRemoteCallObjectValueReturn(function, String.class);
}