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

The following examples show how to use org.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: SolidityFunctionWrapperTest.java    From client-sdk-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetNativeType() {
    assertThat(getNativeType(TypeName.get(Address.class)),
            equalTo(TypeName.get(String.class)));
    assertThat(getNativeType(TypeName.get(Uint256.class)),
            equalTo(TypeName.get(BigInteger.class)));
    assertThat(getNativeType(TypeName.get(Int256.class)),
            equalTo(TypeName.get(BigInteger.class)));
    assertThat(getNativeType(TypeName.get(Utf8String.class)),
            equalTo(TypeName.get(String.class)));
    assertThat(getNativeType(TypeName.get(Bool.class)),
            equalTo(TypeName.get(Boolean.class)));
    assertThat(getNativeType(TypeName.get(Bytes32.class)),
            equalTo(TypeName.get(byte[].class)));
    assertThat(getNativeType(TypeName.get(DynamicBytes.class)),
            equalTo(TypeName.get(byte[].class)));
}
 
Example #2
Source File: StakingParam.java    From client-sdk-java with Apache License 2.0 6 votes vote down vote up
public List<Type> getSubmitInputParameters() {
    return Arrays.<Type>asList(new Uint16(stakingAmountType.getValue())
            , new BytesType(Numeric.hexStringToByteArray(benifitAddress))
            , new BytesType(Numeric.hexStringToByteArray(nodeId))
            , new Utf8String(externalId)
            , new Utf8String(nodeName)
            , new Utf8String(webSite)
            , new Utf8String(details)
            , new Int256(amount)
            , new Uint16(rewardPer)
            , new Uint32(processVersion.getProgramVersion())
            , new BytesType(Numeric.hexStringToByteArray(processVersion.getProgramVersionSign()))
            , new BytesType(Numeric.hexStringToByteArray(blsPubKey))
            , new BytesType(Numeric.hexStringToByteArray(blsProof))
    );
}
 
Example #3
Source File: SolidityFunctionWrapperTest.java    From etherscan-explorer with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testGetNativeType() {
    assertThat(getNativeType(TypeName.get(Address.class)),
            equalTo(TypeName.get(String.class)));
    assertThat(getNativeType(TypeName.get(Uint256.class)),
            equalTo(TypeName.get(BigInteger.class)));
    assertThat(getNativeType(TypeName.get(Int256.class)),
            equalTo(TypeName.get(BigInteger.class)));
    assertThat(getNativeType(TypeName.get(Utf8String.class)),
            equalTo(TypeName.get(String.class)));
    assertThat(getNativeType(TypeName.get(Bool.class)),
            equalTo(TypeName.get(Boolean.class)));
    assertThat(getNativeType(TypeName.get(Bytes32.class)),
            equalTo(TypeName.get(byte[].class)));
    assertThat(getNativeType(TypeName.get(DynamicBytes.class)),
            equalTo(TypeName.get(byte[].class)));
}
 
Example #4
Source File: TypeDecoderTest.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testIntDecode() {
    assertThat(TypeDecoder.decodeNumeric(
            "0000000000000000000000000000000000000000000000000000000000000000",
            Int64.class
            ),
            is(new Int64(BigInteger.ZERO)));

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

    assertThat(TypeDecoder.decodeNumeric(
            "fffffffffffffffffffffffffffffffffffffffffffffff88000000000000000",
            Int64.class
            ),
            is(new Int64(BigInteger.valueOf(Long.MIN_VALUE))));

    assertThat(TypeDecoder.decodeNumeric(
            "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
            Int64.class
            ),
            is(new Int64(BigInteger.valueOf(-1))));

    assertThat(TypeDecoder.decodeNumeric(
            "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
            Int256.class
            ),
            is(new Int256(BigInteger.valueOf(-1))));
}
 
Example #5
Source File: TypeDecoderTest.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testIntDecode() {
    assertThat(TypeDecoder.decodeNumeric(
            "0000000000000000000000000000000000000000000000000000000000000000",
            Int64.class
            ),
            is(new Int64(BigInteger.ZERO)));

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

    assertThat(TypeDecoder.decodeNumeric(
            "fffffffffffffffffffffffffffffffffffffffffffffff88000000000000000",
            Int64.class
            ),
            is(new Int64(BigInteger.valueOf(Long.MIN_VALUE))));

    assertThat(TypeDecoder.decodeNumeric(
            "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
            Int64.class
            ),
            is(new Int64(BigInteger.valueOf(-1))));

    assertThat(TypeDecoder.decodeNumeric(
            "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
            Int256.class
            ),
            is(new Int256(BigInteger.valueOf(-1))));
}
 
Example #6
Source File: SolidityFunctionWrapperTest.java    From web3j with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetNativeType() {
    assertEquals(getNativeType(TypeName.get(Address.class)), (TypeName.get(String.class)));
    assertEquals(getNativeType(TypeName.get(Uint256.class)), (TypeName.get(BigInteger.class)));
    assertEquals(getNativeType(TypeName.get(Int256.class)), (TypeName.get(BigInteger.class)));
    assertEquals(getNativeType(TypeName.get(Utf8String.class)), (TypeName.get(String.class)));
    assertEquals(getNativeType(TypeName.get(Bool.class)), (TypeName.get(Boolean.class)));
    assertEquals(getNativeType(TypeName.get(Bytes32.class)), (TypeName.get(byte[].class)));
    assertEquals(getNativeType(TypeName.get(DynamicBytes.class)), (TypeName.get(byte[].class)));
}