当前位置: 首页>>代码示例>>Java>>正文


Java Utf8String类代码示例

本文整理汇总了Java中org.web3j.abi.datatypes.Utf8String的典型用法代码示例。如果您正苦于以下问题:Java Utf8String类的具体用法?Java Utf8String怎么用?Java Utf8String使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Utf8String类属于org.web3j.abi.datatypes包,在下文中一共展示了Utf8String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newMessageEventObservable

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
public Observable<NewMessageEventResponse> newMessageEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("NewMessage", 
            Arrays.<TypeReference<?>>asList(),
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Utf8String>() {}));
    EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
    filter.addSingleTopic(EventEncoder.encode(event));
    return web3j.ethLogObservable(filter).map(new Func1<Log, NewMessageEventResponse>() {
        @Override
        public NewMessageEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            NewMessageEventResponse typedResponse = new NewMessageEventResponse();
            typedResponse.from = (Address) eventValues.getNonIndexedValues().get(0);
            typedResponse.message = (Utf8String) eventValues.getNonIndexedValues().get(1);
            return typedResponse;
        }
    });
}
 
开发者ID:CDCgov,项目名称:blockchain-collab,代码行数:18,代码来源:Echo_sol_Echo.java

示例2: sendCreateContractTransaction

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
private String sendCreateContractTransaction() throws Exception {
    BigInteger nonce = getNonce(ALICE.getAddress());

    String encodedConstructor =
            FunctionEncoder.encodeConstructor(Collections.singletonList(new Utf8String(VALUE)));

    Transaction transaction = Transaction.createContractTransaction(
            ALICE.getAddress(),
            nonce,
            GAS_PRICE,
            GAS_LIMIT,
            BigInteger.ZERO,
            getGreeterSolidityBinary() + encodedConstructor);

    org.web3j.protocol.core.methods.response.EthSendTransaction
            transactionResponse = web3j.ethSendTransaction(transaction)
            .sendAsync().get();

    return transactionResponse.getTransactionHash();
}
 
开发者ID:web3j,项目名称:web3j,代码行数:21,代码来源:GreeterContractIT.java

示例3: shipments

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
public RemoteCall<Tuple8<String, String, BigInteger, BigInteger, BigInteger, BigInteger, String, byte[]>> shipments(String param0) {
    final Function function = new Function("shipments", 
            Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(param0)), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Address>() {}, new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<Uint8>() {}, new TypeReference<Uint256>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Bytes32>() {}));
    return new RemoteCall<Tuple8<String, String, BigInteger, BigInteger, BigInteger, BigInteger, String, byte[]>>(
            new Callable<Tuple8<String, String, BigInteger, BigInteger, BigInteger, BigInteger, String, byte[]>>() {
                @Override
                public Tuple8<String, String, BigInteger, BigInteger, BigInteger, BigInteger, String, byte[]> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);;
                    return new Tuple8<String, String, BigInteger, BigInteger, BigInteger, BigInteger, String, byte[]>(
                            (String) results.get(0).getValue(), 
                            (String) results.get(1).getValue(), 
                            (BigInteger) results.get(2).getValue(), 
                            (BigInteger) results.get(3).getValue(), 
                            (BigInteger) results.get(4).getValue(), 
                            (BigInteger) results.get(5).getValue(), 
                            (String) results.get(6).getValue(), 
                            (byte[]) results.get(7).getValue());
                }
            });
}
 
开发者ID:web3j,项目名称:web3j,代码行数:22,代码来源:ShipIt.java

示例4: decode

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
@SuppressWarnings("unchecked")
static <T extends Type> T decode(String input, int offset, Class<T> type) {
    if (NumericType.class.isAssignableFrom(type)) {
        return (T) decodeNumeric(input.substring(offset), (Class<NumericType>) type);
    } else if (Address.class.isAssignableFrom(type)) {
        return (T) decodeAddress(input.substring(offset));
    } else if (Bool.class.isAssignableFrom(type)) {
        return (T) decodeBool(input, offset);
    } else if (Bytes.class.isAssignableFrom(type)) {
        return (T) decodeBytes(input, offset, (Class<Bytes>) type);
    } else if (DynamicBytes.class.isAssignableFrom(type)) {
        return (T) decodeDynamicBytes(input, offset);
    } else if (Utf8String.class.isAssignableFrom(type)) {
        return (T) decodeUtf8String(input, offset);
    } else if (Array.class.isAssignableFrom(type)) {
        throw new UnsupportedOperationException(
                "Array types must be wrapped in a TypeReference");
    } else {
        throw new UnsupportedOperationException(
                "Type cannot be encoded: " + type.getClass());
    }
}
 
开发者ID:web3j,项目名称:web3j,代码行数:23,代码来源:TypeDecoder.java

示例5: encode

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static String encode(Type parameter) {
    if (parameter instanceof NumericType) {
        return encodeNumeric(((NumericType) parameter));
    } else if (parameter instanceof Address) {
        return encodeAddress((Address) parameter);
    } else if (parameter instanceof Bool) {
        return encodeBool((Bool) parameter);
    } else if (parameter instanceof Bytes) {
        return encodeBytes((Bytes) parameter);
    } else if (parameter instanceof DynamicBytes) {
        return encodeDynamicBytes((DynamicBytes) parameter);
    } else if (parameter instanceof Utf8String) {
        return encodeString((Utf8String) parameter);
    } else if (parameter instanceof StaticArray) {
        return encodeArrayValues((StaticArray) parameter);
    } else if (parameter instanceof DynamicArray) {
        return encodeDynamicArray((DynamicArray) parameter);
    } else {
        throw new UnsupportedOperationException(
                "Type cannot be encoded: " + parameter.getClass());
    }
}
 
开发者ID:web3j,项目名称:web3j,代码行数:24,代码来源:TypeEncoder.java

示例6: testStaticArray

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
@Test
public void testStaticArray() {
    assertThat(TypeDecoder.decodeStaticArray(
            "000000000000000000000000000000000000000000000000000000000000000a"
            + "0000000000000000000000000000000000000000000000007fffffffffffffff",
            0,
            new TypeReference.StaticArrayTypeReference<StaticArray<Uint256>>(2) {},
            2),
            is(new StaticArray<Uint256>(
                    new Uint256(BigInteger.TEN),
                    new Uint256(BigInteger.valueOf(Long.MAX_VALUE)))));

    assertThat(TypeDecoder.decodeStaticArray(
                    "000000000000000000000000000000000000000000000000000000000000000d"
                    + "48656c6c6f2c20776f726c642100000000000000000000000000000000000000"
                    + "000000000000000000000000000000000000000000000000000000000000000d"
                    + "776f726c64212048656c6c6f2c00000000000000000000000000000000000000",
            0,
            new TypeReference.StaticArrayTypeReference<StaticArray<Utf8String>>(2){},
            2
            ),
            equalTo(new StaticArray<Utf8String>(
                    new Utf8String("Hello, world!"),
                    new Utf8String("world! Hello,"))));
}
 
开发者ID:web3j,项目名称:web3j,代码行数:26,代码来源:TypeDecoderTest.java

示例7: testSimpleFunctionStringResultDecode

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
@Test
public void testSimpleFunctionStringResultDecode() {
    Function function = new Function("simple",
            Arrays.asList(),
            Collections.singletonList(new TypeReference<Utf8String>() {
            }));

    List<Type> utf8Strings = FunctionReturnDecoder.decode(

            "0x0000000000000000000000000000000000000000000000000000000000000020"
                    + "000000000000000000000000000000000000000000000000000000000000000d"
                    + "6f6e65206d6f72652074696d6500000000000000000000000000000000000000",
            function.getOutputParameters());

    assertThat(utf8Strings.get(0).getValue(), is("one more time"));
}
 
开发者ID:web3j,项目名称:web3j,代码行数:17,代码来源:FunctionReturnDecoderTest.java

示例8: testDecodeMultipleStringValues

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
@Test
public void testDecodeMultipleStringValues() {
    Function function = new Function("function",
            Collections.<Type>emptyList(),
            Arrays.asList(
                    new TypeReference<Utf8String>() { }, new TypeReference<Utf8String>() { },
                    new TypeReference<Utf8String>() { }, new TypeReference<Utf8String>() { }));

    assertThat(FunctionReturnDecoder.decode(
            "0x0000000000000000000000000000000000000000000000000000000000000080"
                    + "00000000000000000000000000000000000000000000000000000000000000c0"
                    + "0000000000000000000000000000000000000000000000000000000000000100"
                    + "0000000000000000000000000000000000000000000000000000000000000140"
                    + "0000000000000000000000000000000000000000000000000000000000000004"
                    + "6465663100000000000000000000000000000000000000000000000000000000"
                    + "0000000000000000000000000000000000000000000000000000000000000004"
                    + "6768693100000000000000000000000000000000000000000000000000000000"
                    + "0000000000000000000000000000000000000000000000000000000000000004"
                    + "6a6b6c3100000000000000000000000000000000000000000000000000000000"
                    + "0000000000000000000000000000000000000000000000000000000000000004"
                    + "6d6e6f3200000000000000000000000000000000000000000000000000000000",
            function.getOutputParameters()),
            equalTo(Arrays.asList(
                    new Utf8String("def1"), new Utf8String("ghi1"),
                    new Utf8String("jkl1"), new Utf8String("mno2"))));
}
 
开发者ID:web3j,项目名称:web3j,代码行数:27,代码来源:FunctionReturnDecoderTest.java

示例9: testGetTypeName

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
@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[]"));
}
 
开发者ID:web3j,项目名称:web3j,代码行数:21,代码来源:UtilsTest.java

示例10: addTypes

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
private MethodSpec.Builder addTypes(MethodSpec.Builder builder, String packageName) {
    builder = addStatement(builder, packageName,
            Address.TYPE_NAME, Address.class.getSimpleName());

    builder = addStatement(builder, packageName,
            Bool.TYPE_NAME, Bool.class.getSimpleName());

    builder = addStatement(builder, packageName,
            Utf8String.TYPE_NAME, Utf8String.class.getSimpleName());

    builder = addStatement(builder, packageName,
            DynamicBytes.TYPE_NAME, DynamicBytes.class.getSimpleName());

    // TODO: Fixed array & dynamic array support
    return builder;
}
 
开发者ID:web3j,项目名称:web3j,代码行数:17,代码来源:AbiTypesMapperGenerator.java

示例11: testBuildTypeName

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
@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)));
}
 
开发者ID:web3j,项目名称:web3j,代码行数:25,代码来源:SolidityFunctionWrapperTest.java

示例12: testGetNativeType

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
@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)));
}
 
开发者ID:web3j,项目名称:web3j,代码行数:18,代码来源:SolidityFunctionWrapperTest.java

示例13: nameChangedEventObservable

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
public Observable<NameChangedEventResponse> nameChangedEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("NameChanged", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>() {}),
            Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}));
    EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
    filter.addSingleTopic(EventEncoder.encode(event));
    return web3j.ethLogObservable(filter).map(new Func1<Log, NameChangedEventResponse>() {
        @Override
        public NameChangedEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            NameChangedEventResponse typedResponse = new NameChangedEventResponse();
            typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.name = (String) eventValues.getNonIndexedValues().get(0).getValue();
            return typedResponse;
        }
    });
}
 
开发者ID:web3j,项目名称:web3j,代码行数:18,代码来源:PublicResolver.java

示例14: textChangedEventObservable

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
public Observable<TextChangedEventResponse> textChangedEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("TextChanged", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>() {}, new TypeReference<Utf8String>() {}),
            Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}));
    EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
    filter.addSingleTopic(EventEncoder.encode(event));
    return web3j.ethLogObservable(filter).map(new Func1<Log, TextChangedEventResponse>() {
        @Override
        public TextChangedEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            TextChangedEventResponse typedResponse = new TextChangedEventResponse();
            typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.indexedKey = (String) eventValues.getIndexedValues().get(1).getValue();
            typedResponse.key = (String) eventValues.getNonIndexedValues().get(0).getValue();
            return typedResponse;
        }
    });
}
 
开发者ID:web3j,项目名称:web3j,代码行数:19,代码来源:PublicResolver.java

示例15: registerEndpoint

import org.web3j.abi.datatypes.Utf8String; //导入依赖的package包/类
public void registerEndpoint(Address address, String endpointUrl) {
    try {
        String currentEndpoint = registry.findEndpointByAddress(address).send().getValue();
        if (currentEndpoint != null && currentEndpoint.equals(endpointUrl)) {
            log.info("Endpoint already registered, will not update");
        } else {
            log.info("Registering endpoint {} -> {}", address, endpointUrl);
            registry.registerEndpoint(new Utf8String(endpointUrl)).send();
        }
    } catch (Exception e) {
        throw new IllegalStateException("Failed to register node", e);
    }
}
 
开发者ID:papyrusglobal,项目名称:state-channels,代码行数:14,代码来源:EndpointRegistry.java


注:本文中的org.web3j.abi.datatypes.Utf8String类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。