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

The following examples show how to use org.fisco.bcos.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: EventEncoderTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testEventbuildMethodSignature1() {
    Event event =
            new Event(
                    "f",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Uint>() {},
                            new TypeReference<DynamicArray<Uint32>>() {},
                            new TypeReference<Bytes10>() {},
                            new TypeReference<DynamicBytes>() {}));

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

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

    assertThat(
            EventEncoder.buildEventSignature("f(uint256,uint32[],bytes10,bytes)"),
            is("0x8be652465888a0c5d65fc9d0a7e898b9ca98de97185c53a54ec408fd2fd5d45d"));
}
 
Example #2
Source File: EventEncoderTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testEventbuildMethodSignature4() {
    Event event =
            new Event(
                    "test4",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Uint32>() {}, new TypeReference<Bool>() {}));

    assertThat(
            EventEncoder.buildMethodSignature(event.getName(), event.getParameters()),
            is("test4(uint32,bool)"));

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

    assertThat(
            EventEncoder.buildEventSignature("test4(uint32,bool)"),
            is("0xd7ee7b8ce8fd8944f6c4fc1d3d8f656f855a5b9c130a876af272bdb06b056f9c"));
}
 
Example #3
Source File: FunctionEncoderTest.java    From web3sdk 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 #4
Source File: FunctionEncoderTest.java    From web3sdk 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"));
}