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

The following examples show how to use org.web3j.abi.datatypes.generated.Uint160. 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: TypeDecoder.java    From client-sdk-java with Apache License 2.0 4 votes vote down vote up
static Address decodeAddress(String input) {
    return new Address(decodeNumeric(input, Uint160.class));
}
 
Example #2
Source File: Address.java    From client-sdk-java with Apache License 2.0 4 votes vote down vote up
public Address(Uint160 value) {
    this.value = value;
}
 
Example #3
Source File: Address.java    From client-sdk-java with Apache License 2.0 4 votes vote down vote up
public Address(BigInteger value) {
    this(new Uint160(value));
}
 
Example #4
Source File: Address.java    From client-sdk-java with Apache License 2.0 4 votes vote down vote up
public Uint160 toUint160() {
    return value;
}
 
Example #5
Source File: TypeDecoder.java    From etherscan-explorer with GNU General Public License v3.0 4 votes vote down vote up
static Address decodeAddress(String input) {
    return new Address(decodeNumeric(input, Uint160.class));
}
 
Example #6
Source File: Address.java    From etherscan-explorer with GNU General Public License v3.0 4 votes vote down vote up
public Address(Uint160 value) {
    this.value = value;
}
 
Example #7
Source File: Address.java    From etherscan-explorer with GNU General Public License v3.0 4 votes vote down vote up
public Address(BigInteger value) {
    this(new Uint160(value));
}
 
Example #8
Source File: Address.java    From etherscan-explorer with GNU General Public License v3.0 4 votes vote down vote up
public Uint160 toUint160() {
    return value;
}
 
Example #9
Source File: TypeDecoder.java    From web3j with Apache License 2.0 4 votes vote down vote up
static Address decodeAddress(String input) {
    return new Address(decodeNumeric(input, Uint160.class));
}
 
Example #10
Source File: TypeDecoder.java    From web3j with Apache License 2.0 4 votes vote down vote up
static Type instantiateAtomicType(Class<?> referenceClass, Object value)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
                InstantiationException, ClassNotFoundException {
    Object constructorArg = null;
    if (NumericType.class.isAssignableFrom(referenceClass)) {
        constructorArg = asBigInteger(value);
    } else if (BytesType.class.isAssignableFrom(referenceClass)) {
        if (value instanceof byte[]) {
            constructorArg = value;
        } else if (value instanceof BigInteger) {
            constructorArg = ((BigInteger) value).toByteArray();
        } else if (value instanceof String) {
            constructorArg = Numeric.hexStringToByteArray((String) value);
        }
    } else if (Utf8String.class.isAssignableFrom(referenceClass)) {
        constructorArg = value.toString();
    } else if (Address.class.isAssignableFrom(referenceClass)) {
        if (value instanceof BigInteger || value instanceof Uint160) {
            constructorArg = value;
        } else {
            constructorArg = value.toString();
        }
    } else if (Bool.class.isAssignableFrom(referenceClass)) {
        if (value instanceof Boolean) {
            constructorArg = value;
        } else {
            BigInteger bival = asBigInteger(value);
            constructorArg = bival == null ? null : !bival.equals(BigInteger.ZERO);
        }
    }
    if (constructorArg == null) {
        throw new InstantiationException(
                "Could not create type "
                        + referenceClass
                        + " from arg "
                        + value.toString()
                        + " of type "
                        + value.getClass());
    }
    Class<?>[] types = new Class[] {constructorArg.getClass()};
    Constructor cons = referenceClass.getConstructor(types);
    return (Type) cons.newInstance(constructorArg);
}