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

The following examples show how to use org.web3j.abi.datatypes.generated.Uint32. 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: 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: FunctionEncoderTest.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuildMessageSignature() {
    assertThat(
            FunctionEncoder.buildMethodSignature(
                    "baz",
                    Arrays.asList(
                            new Uint32(BigInteger.valueOf(69)),
                            new Bool(true))
            ),
            is("baz(uint32,bool)"));
}
 
Example #4
Source File: FunctionEncoderTest.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testFunctionSimpleEncode() {
    Function function = new Function(
            "baz",
            Arrays.asList(new Uint32(BigInteger.valueOf(69)), new Bool(true)),
            Collections.<TypeReference<?>>emptyList()
    );

    assertThat(FunctionEncoder.encode(function),
            is("0xcdcd77c0"
                    + "0000000000000000000000000000000000000000000000000000000000000045"
                    + "0000000000000000000000000000000000000000000000000000000000000001"
            ));
}
 
Example #5
Source File: FunctionEncoderTest.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testFunctionMDynamicArrayEncode2() {
    Function function = new Function(
            "f",
            Arrays.asList(
                new Uint(BigInteger.valueOf(0x123)),
                new DynamicArray<>(
                        new Uint32(BigInteger.valueOf(0x456)),
                        new Uint32(BigInteger.valueOf(0x789))
                ),
                new Bytes10("1234567890".getBytes()),
                new DynamicBytes("Hello, world!".getBytes())),
            Collections.<TypeReference<?>>emptyList()
    );

    assertThat(FunctionEncoder.encode(function),
            is("0x8be65246"
                    + "0000000000000000000000000000000000000000000000000000000000000123"
                    + "0000000000000000000000000000000000000000000000000000000000000080"
                    + "3132333435363738393000000000000000000000000000000000000000000000"
                    + "00000000000000000000000000000000000000000000000000000000000000e0"
                    + "0000000000000000000000000000000000000000000000000000000000000002"
                    + "0000000000000000000000000000000000000000000000000000000000000456"
                    + "0000000000000000000000000000000000000000000000000000000000000789"
                    + "000000000000000000000000000000000000000000000000000000000000000d"
                    + "48656c6c6f2c20776f726c642100000000000000000000000000000000000000"
            ));
}
 
Example #6
Source File: ProposalContract.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
private Function createVoteFunction(ProgramVersion programVersion, String proposalID, String verifier, VoteOption voteOption) {
    Function function = new Function(FunctionType.VOTE_FUNC_TYPE,
            Arrays.asList(new BytesType(Numeric.hexStringToByteArray(verifier)),
                    new BytesType(Numeric.hexStringToByteArray(proposalID)), new Uint8(voteOption.getValue()),
                    new Uint32(programVersion.getProgramVersion()),
                    new BytesType(Numeric.hexStringToByteArray(programVersion.getProgramVersionSign()))));
    return function;
}
 
Example #7
Source File: ProposalContract.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
private Function createDeclareVersionFunction(ProgramVersion programVersion, String verifier)  {
    Function function = new Function(FunctionType.DECLARE_VERSION_FUNC_TYPE,
            Arrays.asList(new BytesType(Numeric.hexStringToByteArray(verifier)),
                    new Uint32(programVersion.getProgramVersion()),
                    new BytesType(Numeric.hexStringToByteArray(programVersion.getProgramVersionSign()))));
    return function;
}
 
Example #8
Source File: FunctionEncoderTest.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testBuildMessageSignature() {
    assertThat(
            FunctionEncoder.buildMethodSignature(
                    "baz",
                    Arrays.asList(
                            new Uint32(BigInteger.valueOf(69)),
                            new Bool(true))
            ),
            is("baz(uint32,bool)"));
}
 
Example #9
Source File: FunctionEncoderTest.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testFunctionSimpleEncode() {
    Function function = new Function(
            "baz",
            Arrays.asList(new Uint32(BigInteger.valueOf(69)), new Bool(true)),
            Collections.<TypeReference<?>>emptyList()
    );

    assertThat(FunctionEncoder.encode(function),
            is("0xcdcd77c0"
                    + "0000000000000000000000000000000000000000000000000000000000000045"
                    + "0000000000000000000000000000000000000000000000000000000000000001"
            ));
}
 
Example #10
Source File: FunctionEncoderTest.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testFunctionMDynamicArrayEncode2() {
    Function function = new Function(
            "f",
            Arrays.asList(
                new Uint(BigInteger.valueOf(0x123)),
                new DynamicArray<>(
                        new Uint32(BigInteger.valueOf(0x456)),
                        new Uint32(BigInteger.valueOf(0x789))
                ),
                new Bytes10("1234567890".getBytes()),
                new DynamicBytes("Hello, world!".getBytes())),
            Collections.<TypeReference<?>>emptyList()
    );

    assertThat(FunctionEncoder.encode(function),
            is("0x8be65246"
                    + "0000000000000000000000000000000000000000000000000000000000000123"
                    + "0000000000000000000000000000000000000000000000000000000000000080"
                    + "3132333435363738393000000000000000000000000000000000000000000000"
                    + "00000000000000000000000000000000000000000000000000000000000000e0"
                    + "0000000000000000000000000000000000000000000000000000000000000002"
                    + "0000000000000000000000000000000000000000000000000000000000000456"
                    + "0000000000000000000000000000000000000000000000000000000000000789"
                    + "000000000000000000000000000000000000000000000000000000000000000d"
                    + "48656c6c6f2c20776f726c642100000000000000000000000000000000000000"
            ));
}
 
Example #11
Source File: DefaultFunctionEncoderTest.java    From web3j with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuildMessageSignature() {
    assertEquals(
            "baz(uint32,bool)",
            DefaultFunctionEncoder.buildMethodSignature(
                    "baz", Arrays.asList(new Uint32(BigInteger.valueOf(69)), new Bool(true))));
}
 
Example #12
Source File: DefaultFunctionEncoderTest.java    From web3j with Apache License 2.0 5 votes vote down vote up
@Test
public void testFunctionSimpleEncode() {
    Function function =
            new Function(
                    "baz",
                    Arrays.asList(new Uint32(BigInteger.valueOf(69)), new Bool(true)),
                    Collections.emptyList());

    assertEquals(
            "0xcdcd77c0"
                    + "0000000000000000000000000000000000000000000000000000000000000045"
                    + "0000000000000000000000000000000000000000000000000000000000000001",
            FunctionEncoder.encode(function));
}
 
Example #13
Source File: DefaultFunctionEncoderTest.java    From web3j with Apache License 2.0 5 votes vote down vote up
@Test
public void testFunctionMDynamicArrayEncode2() {
    Function function =
            new Function(
                    "f",
                    Arrays.asList(
                            new Uint(BigInteger.valueOf(0x123)),
                            new DynamicArray<>(
                                    new Uint32(BigInteger.valueOf(0x456)),
                                    new Uint32(BigInteger.valueOf(0x789))),
                            new Bytes10("1234567890".getBytes()),
                            new DynamicBytes("Hello, world!".getBytes())),
                    Collections.emptyList());

    assertEquals(
            "0x8be65246"
                    + "0000000000000000000000000000000000000000000000000000000000000123"
                    + "0000000000000000000000000000000000000000000000000000000000000080"
                    + "3132333435363738393000000000000000000000000000000000000000000000"
                    + "00000000000000000000000000000000000000000000000000000000000000e0"
                    + "0000000000000000000000000000000000000000000000000000000000000002"
                    + "0000000000000000000000000000000000000000000000000000000000000456"
                    + "0000000000000000000000000000000000000000000000000000000000000789"
                    + "000000000000000000000000000000000000000000000000000000000000000d"
                    + "48656c6c6f2c20776f726c642100000000000000000000000000000000000000",
            FunctionEncoder.encode(function));
}
 
Example #14
Source File: SlashContract.java    From client-sdk-java with Apache License 2.0 4 votes vote down vote up
private Function createReportDoubleSignFunction(DuplicateSignType duplicateSignType, String data) {
    Function function = new Function(FunctionType.REPORT_DOUBLESIGN_FUNC_TYPE,
            Arrays.asList(new Uint32(BigInteger.valueOf(duplicateSignType.getValue())), new Utf8String(data)));
    return function;
}
 
Example #15
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);
}