diff --git a/src/main/java/org/fisco/bcos/sdk/abi/Constant.java b/src/main/java/org/fisco/bcos/sdk/abi/Constant.java new file mode 100644 index 000000000..0eb7880ff --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/Constant.java @@ -0,0 +1,12 @@ +package org.fisco.bcos.sdk.abi; + +import java.math.BigInteger; + +public class Constant { + public static final BigInteger MAX_UINT256 = + new BigInteger("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16); + public static final BigInteger MAX_INT256 = + new BigInteger("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16); + public static final BigInteger MIN_INT256 = + new BigInteger("-7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16); +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/EventEncoder.java b/src/main/java/org/fisco/bcos/sdk/abi/EventEncoder.java new file mode 100644 index 000000000..3e051a985 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/EventEncoder.java @@ -0,0 +1,47 @@ +package org.fisco.bcos.sdk.abi; + +import java.util.List; +import java.util.stream.Collectors; +import org.fisco.bcos.sdk.abi.datatypes.Event; +import org.fisco.bcos.sdk.abi.datatypes.Type; +import org.fisco.bcos.sdk.crypto.CryptoInterface; +import org.fisco.bcos.sdk.utils.Numeric; + +/** + * Ethereum filter encoding. Further limited details are available here. + */ +public class EventEncoder { + + private CryptoInterface cryptoInterface; + + public EventEncoder(CryptoInterface cryptoInterface) { + this.cryptoInterface = cryptoInterface; + } + + public String encode(Event event) { + + String methodSignature = buildMethodSignature(event.getName(), event.getParameters()); + + return buildEventSignature(methodSignature); + } + + private String buildMethodSignature( + String methodName, List> parameters) { + + StringBuilder result = new StringBuilder(); + result.append(methodName); + result.append("("); + String params = + parameters.stream().map(p -> Utils.getTypeName(p)).collect(Collectors.joining(",")); + result.append(params); + result.append(")"); + return result.toString(); + } + + public String buildEventSignature(String methodSignature) { + byte[] input = methodSignature.getBytes(); + byte[] hash = cryptoInterface.hash(input); + return Numeric.toHexString(hash); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/EventValues.java b/src/main/java/org/fisco/bcos/sdk/abi/EventValues.java new file mode 100644 index 000000000..d9a310617 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/EventValues.java @@ -0,0 +1,23 @@ +package org.fisco.bcos.sdk.abi; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** Persisted solidity event parameters. */ +public class EventValues { + private final List indexedValues; + private final List nonIndexedValues; + + public EventValues(List indexedValues, List nonIndexedValues) { + this.indexedValues = indexedValues; + this.nonIndexedValues = nonIndexedValues; + } + + public List getIndexedValues() { + return indexedValues; + } + + public List getNonIndexedValues() { + return nonIndexedValues; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/FunctionEncoder.java b/src/main/java/org/fisco/bcos/sdk/abi/FunctionEncoder.java new file mode 100644 index 000000000..5f2244dea --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/FunctionEncoder.java @@ -0,0 +1,78 @@ +package org.fisco.bcos.sdk.abi; + +import java.math.BigInteger; +import java.util.List; +import java.util.stream.Collectors; +import org.fisco.bcos.sdk.abi.datatypes.Function; +import org.fisco.bcos.sdk.abi.datatypes.Type; +import org.fisco.bcos.sdk.abi.datatypes.Uint; +import org.fisco.bcos.sdk.crypto.CryptoInterface; +import org.fisco.bcos.sdk.utils.Numeric; + +/** + * Ethereum Contract Application Binary Interface (ABI) encoding for functions. Further details are + * available here. + */ +public class FunctionEncoder { + + private CryptoInterface cryptoInterface; + + public FunctionEncoder(CryptoInterface cryptoInterface) { + this.cryptoInterface = cryptoInterface; + } + + public String encode(Function function) { + List parameters = function.getInputParameters(); + + String methodSignature = buildMethodSignature(function.getName(), parameters); + String methodId = buildMethodId(methodSignature); + + StringBuilder result = new StringBuilder(); + result.append(methodId); + + return encodeParameters(parameters, result); + } + + public String encodeConstructor(List parameters) { + return encodeParameters(parameters, new StringBuilder()); + } + + public String encodeParameters(List parameters, StringBuilder result) { + int dynamicDataOffset = Utils.getLength(parameters) * Type.MAX_BYTE_LENGTH; + StringBuilder dynamicData = new StringBuilder(); + + for (Type parameter : parameters) { + String encodedValue = TypeEncoder.encode(parameter); + + if (parameter.dynamicType()) { + String encodedDataOffset = + TypeEncoder.encodeNumeric(new Uint(BigInteger.valueOf(dynamicDataOffset))); + result.append(encodedDataOffset); + dynamicData.append(encodedValue); + dynamicDataOffset += (encodedValue.length() >> 1); + } else { + result.append(encodedValue); + } + } + result.append(dynamicData); + + return result.toString(); + } + + private String buildMethodSignature(String methodName, List parameters) { + StringBuilder result = new StringBuilder(); + result.append(methodName); + result.append("("); + String params = + parameters.stream().map(Type::getTypeAsString).collect(Collectors.joining(",")); + result.append(params); + result.append(")"); + return result.toString(); + } + + public String buildMethodId(String methodSignature) { + byte[] input = methodSignature.getBytes(); + byte[] hash = cryptoInterface.hash(input); + return Numeric.toHexString(hash).substring(0, 10); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/FunctionReturnDecoder.java b/src/main/java/org/fisco/bcos/sdk/abi/FunctionReturnDecoder.java new file mode 100644 index 000000000..cd9dea534 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/FunctionReturnDecoder.java @@ -0,0 +1,133 @@ +package org.fisco.bcos.sdk.abi; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.Array; +import org.fisco.bcos.sdk.abi.datatypes.Bytes; +import org.fisco.bcos.sdk.abi.datatypes.BytesType; +import org.fisco.bcos.sdk.abi.datatypes.DynamicArray; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; +import org.fisco.bcos.sdk.abi.datatypes.Utf8String; +import org.fisco.bcos.sdk.abi.datatypes.generated.Bytes32; +import org.fisco.bcos.sdk.utils.Numeric; +import org.fisco.bcos.sdk.utils.StringUtils; + +/** Decodes values returned by function or event calls. */ +public class FunctionReturnDecoder { + + private FunctionReturnDecoder() {} + + /** + * Decode ABI encoded return values from smart contract function call. + * + * @param rawInput ABI encoded input + * @param outputParameters list of return types as {@link TypeReference} + * @return {@link List} of values returned by function, {@link Collections#emptyList()} if + * invalid response + */ + public static List decode(String rawInput, List> outputParameters) { + String input = Numeric.cleanHexPrefix(rawInput); + + if (StringUtils.isEmpty(input)) { + return Collections.emptyList(); + } else { + return build(input, outputParameters); + } + } + + /** + * Decodes an indexed parameter associated with an event. Indexed parameters are individually + * encoded, unlike non-indexed parameters which are encoded as per ABI-encoded function + * parameters and return values. + * + *

If any of the following types are indexed, the Keccak-256 hashes of the values are + * returned instead. These are returned as a bytes32 value. + * + *

    + *
  • Arrays + *
  • Strings + *
  • Bytes + *
+ * + *

See the Solidity + * documentation for further information. + * + * @param rawInput ABI encoded input + * @param typeReference of expected result type + * @param type of TypeReference + * @return the decode value + */ + @SuppressWarnings("unchecked") + public static Type decodeIndexedValue( + String rawInput, TypeReference typeReference) { + String input = Numeric.cleanHexPrefix(rawInput); + + try { + Class type = typeReference.getClassType(); + + if (Bytes.class.isAssignableFrom(type)) { + return TypeDecoder.decodeBytes(input, (Class) Class.forName(type.getName())); + } else if (Array.class.isAssignableFrom(type) + || BytesType.class.isAssignableFrom(type) + || Utf8String.class.isAssignableFrom(type)) { + return TypeDecoder.decodeBytes(input, Bytes32.class); + } else { + return TypeDecoder.decode(input, 0, type); + } + } catch (ClassNotFoundException e) { + throw new UnsupportedOperationException("Invalid class reference provided", e); + } + } + + private static List build(String input, List> outputParameters) { + List results = new ArrayList<>(outputParameters.size()); + + int offset = 0; + for (TypeReference typeReference : outputParameters) { + try { + @SuppressWarnings("unchecked") + Class cls = (Class) typeReference.getClassType(); + + int hexStringDataOffset = getDataOffset(input, offset, typeReference.getType()); + + Type result; + if (DynamicArray.class.isAssignableFrom(cls)) { + result = + TypeDecoder.decodeDynamicArray( + input, hexStringDataOffset, typeReference.getType()); + } else if (StaticArray.class.isAssignableFrom(cls)) { + int length = + Integer.parseInt( + cls.getSimpleName() + .substring(StaticArray.class.getSimpleName().length())); + result = + TypeDecoder.decodeStaticArray( + input, hexStringDataOffset, typeReference.getType(), length); + } else { + result = TypeDecoder.decode(input, hexStringDataOffset, cls); + } + + results.add(result); + + offset += + Utils.getOffset(typeReference.getType()) + * TypeDecoder.MAX_BYTE_LENGTH_FOR_HEX_STRING; + + } catch (ClassNotFoundException e) { + throw new UnsupportedOperationException("Invalid class reference provided", e); + } + } + return results; + } + + private static int getDataOffset( + String input, int offset, java.lang.reflect.Type type) throws ClassNotFoundException { + if (Utils.dynamicType(type)) { + return TypeDecoder.decodeUintAsInt(input, offset) << 1; + } else { + return offset; + } + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/TypeDecoder.java b/src/main/java/org/fisco/bcos/sdk/abi/TypeDecoder.java new file mode 100644 index 000000000..e9710f807 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/TypeDecoder.java @@ -0,0 +1,282 @@ +package org.fisco.bcos.sdk.abi; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.ParameterizedType; +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.function.BiFunction; +import org.fisco.bcos.sdk.abi.datatypes.Address; +import org.fisco.bcos.sdk.abi.datatypes.Array; +import org.fisco.bcos.sdk.abi.datatypes.Bool; +import org.fisco.bcos.sdk.abi.datatypes.Bytes; +import org.fisco.bcos.sdk.abi.datatypes.DynamicArray; +import org.fisco.bcos.sdk.abi.datatypes.DynamicBytes; +import org.fisco.bcos.sdk.abi.datatypes.Fixed; +import org.fisco.bcos.sdk.abi.datatypes.FixedPointType; +import org.fisco.bcos.sdk.abi.datatypes.Int; +import org.fisco.bcos.sdk.abi.datatypes.IntType; +import org.fisco.bcos.sdk.abi.datatypes.NumericType; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; +import org.fisco.bcos.sdk.abi.datatypes.Ufixed; +import org.fisco.bcos.sdk.abi.datatypes.Uint; +import org.fisco.bcos.sdk.abi.datatypes.Utf8String; +import org.fisco.bcos.sdk.abi.datatypes.generated.Uint160; +import org.fisco.bcos.sdk.utils.Numeric; + +/** + * Ethereum Contract Application Binary Interface (ABI) decoding for types. Decoding is not + * documented, but is the reverse of the encoding details located here. + */ +public class TypeDecoder { + + static final int MAX_BYTE_LENGTH_FOR_HEX_STRING = Type.MAX_BYTE_LENGTH << 1; + + @SuppressWarnings("unchecked") + public static T decode(String input, int offset, Class type) { + if (NumericType.class.isAssignableFrom(type)) { + return (T) decodeNumeric(input.substring(offset), (Class) 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) 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()); + } + } + + static Address decodeAddress(String input) { + return new Address(decodeNumeric(input, Uint160.class)); + } + + static T decodeNumeric(String input, Class type) { + try { + byte[] inputByteArray = Numeric.hexStringToByteArray(input); + int typeLengthAsBytes = getTypeLengthInBytes(type); + + byte[] resultByteArray = new byte[typeLengthAsBytes + 1]; + + if (Int.class.isAssignableFrom(type) || Fixed.class.isAssignableFrom(type)) { + resultByteArray[0] = inputByteArray[0]; // take MSB as sign bit + } + + int valueOffset = Type.MAX_BYTE_LENGTH - typeLengthAsBytes; + System.arraycopy(inputByteArray, valueOffset, resultByteArray, 1, typeLengthAsBytes); + + BigInteger numericValue = new BigInteger(resultByteArray); + return type.getConstructor(BigInteger.class).newInstance(numericValue); + + } catch (NoSuchMethodException + | SecurityException + | InstantiationException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException e) { + throw new UnsupportedOperationException( + "Unable to create instance of " + type.getName(), e); + } + } + + static int getTypeLengthInBytes(Class type) { + return getTypeLength(type) >> 3; // divide by 8 + } + + static int getTypeLength(Class type) { + if (IntType.class.isAssignableFrom(type)) { + String regex = "(" + Uint.class.getSimpleName() + "|" + Int.class.getSimpleName() + ")"; + String[] splitName = type.getSimpleName().split(regex); + if (splitName.length == 2) { + return Integer.parseInt(splitName[1]); + } + } else if (FixedPointType.class.isAssignableFrom(type)) { + String regex = + "(" + Ufixed.class.getSimpleName() + "|" + Fixed.class.getSimpleName() + ")"; + String[] splitName = type.getSimpleName().split(regex); + if (splitName.length == 2) { + String[] bitsCounts = splitName[1].split("x"); + return Integer.parseInt(bitsCounts[0]) + Integer.parseInt(bitsCounts[1]); + } + } + return Type.MAX_BIT_LENGTH; + } + + static int decodeUintAsInt(String rawInput, int offset) { + String input = rawInput.substring(offset, offset + MAX_BYTE_LENGTH_FOR_HEX_STRING); + return decode(input, 0, Uint.class).getValue().intValue(); + } + + static Bool decodeBool(String rawInput, int offset) { + String input = rawInput.substring(offset, offset + MAX_BYTE_LENGTH_FOR_HEX_STRING); + BigInteger numericValue = Numeric.toBigInt(input); + boolean value = numericValue.equals(BigInteger.ONE); + return new Bool(value); + } + + static T decodeBytes(String input, Class type) { + return decodeBytes(input, 0, type); + } + + static T decodeBytes(String input, int offset, Class type) { + try { + String simpleName = type.getSimpleName(); + String[] splitName = simpleName.split(Bytes.class.getSimpleName()); + int length = Integer.parseInt(splitName[1]); + int hexStringLength = length << 1; + + byte[] bytes = + Numeric.hexStringToByteArray(input.substring(offset, offset + hexStringLength)); + return type.getConstructor(byte[].class).newInstance(bytes); + } catch (NoSuchMethodException + | SecurityException + | InstantiationException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException e) { + throw new UnsupportedOperationException( + "Unable to create instance of " + type.getName(), e); + } + } + + static DynamicBytes decodeDynamicBytes(String input, int offset) { + int encodedLength = decodeUintAsInt(input, offset); + int hexStringEncodedLength = encodedLength << 1; + + int valueOffset = offset + MAX_BYTE_LENGTH_FOR_HEX_STRING; + + String data = input.substring(valueOffset, valueOffset + hexStringEncodedLength); + byte[] bytes = Numeric.hexStringToByteArray(data); + + return new DynamicBytes(bytes); + } + + static Utf8String decodeUtf8String(String input, int offset) { + DynamicBytes dynamicBytesResult = decodeDynamicBytes(input, offset); + byte[] bytes = dynamicBytesResult.getValue(); + + return new Utf8String(new String(bytes, StandardCharsets.UTF_8)); + } + + /** Static array length cannot be passed as a type. */ + @SuppressWarnings("unchecked") + public static T decodeStaticArray( + String input, int offset, java.lang.reflect.Type type, int length) { + + BiFunction, String, T> function = + (elements, typeName) -> { + if (elements.isEmpty()) { + throw new UnsupportedOperationException( + "Zero length fixed array is invalid type"); + } else { + return instantiateStaticArray(type, elements); + } + }; + + return decodeArrayElements(input, offset, type, length, function); + } + + @SuppressWarnings("unchecked") + private static T instantiateStaticArray( + java.lang.reflect.Type type, List elements) { + try { + + Class cls = Utils.getClassType(type); + return cls.getConstructor(List.class).newInstance(elements); + + } catch (ReflectiveOperationException e) { + // noinspection unchecked + return (T) new StaticArray<>(elements); + } + } + + @SuppressWarnings("unchecked") + public static T decodeDynamicArray( + String input, int offset, java.lang.reflect.Type type) { + + int length = decodeUintAsInt(input, offset); + + BiFunction, String, T> function = + (elements, typeName) -> { + if (elements.isEmpty()) { + return (T) DynamicArray.empty(typeName); + } else { + return (T) new DynamicArray<>(elements); + } + }; + + int valueOffset = offset + MAX_BYTE_LENGTH_FOR_HEX_STRING; + + return decodeArrayElements(input, valueOffset, type, length, function); + } + + @SuppressWarnings("rawtypes") + private static T decodeArrayElements( + String input, + int offset, + java.lang.reflect.Type type, + int length, + BiFunction, String, T> consumer) { + + try { + List elements = new ArrayList<>(length); + + java.lang.reflect.Type[] types = ((ParameterizedType) type).getActualTypeArguments(); + Class paraType = Utils.getClassType(types[0]); + + for (int i = 0; i < length; ++i) { + + int currEleOffset = + offset + (i * MAX_BYTE_LENGTH_FOR_HEX_STRING * Utils.getOffset(types[0])); + + T t = null; + if (Array.class.isAssignableFrom(paraType)) { // nest array + int size = 0; + if (StaticArray.class.isAssignableFrom(paraType)) { + size = + Integer.parseInt( + Utils.getClassType(types[0]) + .getSimpleName() + .substring( + StaticArray.class + .getSimpleName() + .length())); + t = decodeStaticArray(input, currEleOffset, types[0], size); + } else { + int getOffset = TypeDecoder.decodeUintAsInt(input, currEleOffset) << 1; + t = decodeDynamicArray(input, offset + getOffset, types[0]); + } + + } else { + if (Utf8String.class.isAssignableFrom(paraType) + || DynamicBytes.class.isAssignableFrom(paraType)) { // dynamicType + int getOffset = TypeDecoder.decodeUintAsInt(input, currEleOffset) << 1; + t = decode(input, offset + getOffset, paraType); + } else { + t = decode(input, currEleOffset, paraType); + } + } + + elements.add(t); + } + + String typeName = Utils.getSimpleTypeName(paraType); + + return consumer.apply(elements, typeName); + + } catch (ClassNotFoundException e) { + throw new UnsupportedOperationException( + "Unable to access parameterized type " + type.getTypeName(), e); + } + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/TypeEncoder.java b/src/main/java/org/fisco/bcos/sdk/abi/TypeEncoder.java new file mode 100644 index 000000000..0d00b3760 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/TypeEncoder.java @@ -0,0 +1,174 @@ +package org.fisco.bcos.sdk.abi; + +import static org.fisco.bcos.sdk.abi.datatypes.Type.MAX_BYTE_LENGTH; + +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import org.fisco.bcos.sdk.abi.datatypes.*; +import org.fisco.bcos.sdk.utils.Numeric; + +/** + * Ethereum Contract Application Binary Interface (ABI) encoding for types. Further details are + * available here. + */ +public class TypeEncoder { + + private TypeEncoder() {} + + @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()); + } + } + + static String encodeAddress(Address address) { + return encodeNumeric(address.toUint160()); + } + + static String encodeNumeric(NumericType numericType) { + byte[] rawValue = toByteArray(numericType); + byte paddingValue = getPaddingValue(numericType); + byte[] paddedRawValue = new byte[MAX_BYTE_LENGTH]; + if (paddingValue != 0) { + for (int i = 0; i < paddedRawValue.length; i++) { + paddedRawValue[i] = paddingValue; + } + } + + System.arraycopy( + rawValue, 0, paddedRawValue, MAX_BYTE_LENGTH - rawValue.length, rawValue.length); + return Numeric.toHexStringNoPrefix(paddedRawValue); + } + + private static byte getPaddingValue(NumericType numericType) { + if (numericType.getValue().signum() == -1) { + return (byte) 0xff; + } else { + return 0; + } + } + + private static byte[] toByteArray(NumericType numericType) { + BigInteger value = numericType.getValue(); + if (numericType instanceof Ufixed || numericType instanceof Uint) { + if (value.bitLength() == Type.MAX_BIT_LENGTH) { + // As BigInteger is signed, if we have a 256 bit value, the resultant + // byte array will contain a sign byte in it's MSB, which we should + // ignore for this unsigned integer type. + byte[] byteArray = new byte[MAX_BYTE_LENGTH]; + System.arraycopy(value.toByteArray(), 1, byteArray, 0, MAX_BYTE_LENGTH); + return byteArray; + } + } + return value.toByteArray(); + } + + static String encodeBool(Bool value) { + byte[] rawValue = new byte[MAX_BYTE_LENGTH]; + if (value.getValue()) { + rawValue[rawValue.length - 1] = 1; + } + return Numeric.toHexStringNoPrefix(rawValue); + } + + static String encodeBytes(BytesType bytesType) { + byte[] value = bytesType.getValue(); + int length = value.length; + int mod = length % MAX_BYTE_LENGTH; + + byte[] dest; + if (mod != 0) { + int padding = MAX_BYTE_LENGTH - mod; + dest = new byte[length + padding]; + System.arraycopy(value, 0, dest, 0, length); + } else { + dest = value; + } + return Numeric.toHexStringNoPrefix(dest); + } + + static String encodeDynamicBytes(DynamicBytes dynamicBytes) { + int size = dynamicBytes.getValue().length; + String encodedLength = encode(new Uint(BigInteger.valueOf(size))); + String encodedValue = encodeBytes(dynamicBytes); + + StringBuilder result = new StringBuilder(); + result.append(encodedLength); + result.append(encodedValue); + return result.toString(); + } + + static String encodeString(Utf8String string) { + byte[] utfEncoded = string.getValue().getBytes(StandardCharsets.UTF_8); + return encodeDynamicBytes(new DynamicBytes(utfEncoded)); + } + + static String encodeArrayValues(Array value) { + + StringBuilder encodedOffset = new StringBuilder(); + StringBuilder encodedValue = new StringBuilder(); + + int offset = value.getValue().size() * MAX_BYTE_LENGTH; + + for (Type type : value.getValue()) { + String r = encode(type); + encodedValue.append(r); + if (type.dynamicType()) { + encodedOffset.append(encode(new Uint(BigInteger.valueOf(offset)))); + offset += (r.length() >> 1); + } + } + + StringBuilder result = new StringBuilder(); + result.append(encodedOffset); + result.append(encodedValue); + + return result.toString(); + } + + static String encodeDynamicArray(DynamicArray value) { + + StringBuilder encodedSize = new StringBuilder(); + StringBuilder encodedOffset = new StringBuilder(); + StringBuilder encodedValue = new StringBuilder(); + + encodedSize.append(encode(new Uint(BigInteger.valueOf(value.getValue().size())))); + + int offset = value.getValue().size() * MAX_BYTE_LENGTH; + + for (Type type : value.getValue()) { + String r = encode(type); + encodedValue.append(r); + + if (type.dynamicType()) { + encodedOffset.append(encode(new Uint(BigInteger.valueOf(offset)))); + offset += (r.length() >> 1); + } + } + + StringBuilder result = new StringBuilder(); + result.append(encodedSize); + result.append(encodedOffset); + result.append(encodedValue); + + return result.toString(); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/TypeMappingException.java b/src/main/java/org/fisco/bcos/sdk/abi/TypeMappingException.java new file mode 100644 index 000000000..58361e908 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/TypeMappingException.java @@ -0,0 +1,16 @@ +package org.fisco.bcos.sdk.abi; + +public class TypeMappingException extends RuntimeException { + + public TypeMappingException(Exception e) { + super(e); + } + + public TypeMappingException(String message) { + super(message); + } + + public TypeMappingException(String message, Exception e) { + super(message, e); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/TypeReference.java b/src/main/java/org/fisco/bcos/sdk/abi/TypeReference.java new file mode 100644 index 000000000..48a9d3217 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/TypeReference.java @@ -0,0 +1,77 @@ +package org.fisco.bcos.sdk.abi; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import org.fisco.bcos.sdk.abi.datatypes.Array; + +/** + * Type wrapper to get around limitations of Java's type erasure. This is so that we can pass around + * Typed {@link Array} types. + * + *

See this blog post + * for further details. + * + *

It may make sense to switch to using Java's reflection Type to avoid + * working around this fundamental generics limitation. + */ +public abstract class TypeReference + implements Comparable> { + + private final Type type; + private final boolean indexed; + + protected TypeReference() { + this(false); + } + + protected TypeReference(boolean indexed) { + Type superclass = getClass().getGenericSuperclass(); + if (superclass instanceof Class) { + throw new RuntimeException("Missing type parameter."); + } + this.type = ((ParameterizedType) superclass).getActualTypeArguments()[0]; + this.indexed = indexed; + } + + public int compareTo(TypeReference o) { + // taken from the blog post comments - this results in an errror if the + // type parameter is left out. + return 0; + } + + public Type getType() { + return type; + } + + public boolean isIndexed() { + return indexed; + } + + /** + * Workaround to ensure type does not come back as T due to erasure, this enables you to create + * a TypeReference via {@link Class Class<T>}. + * + * @return the parameterized Class type if applicable, otherwise a regular class + * @throws ClassNotFoundException if the class type cannot be determined + */ + @SuppressWarnings("unchecked") + public Class getClassType() throws ClassNotFoundException { + return Utils.getClassType(getType()); + } + + public static TypeReference create( + Class cls) { + return create(cls, false); + } + + public static TypeReference create( + Class cls, boolean indexed) { + return new TypeReference(indexed) { + @Override + public Type getType() { + return cls; + } + }; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/Utils.java b/src/main/java/org/fisco/bcos/sdk/abi/Utils.java new file mode 100644 index 000000000..e22aaf53a --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/Utils.java @@ -0,0 +1,205 @@ +package org.fisco.bcos.sdk.abi; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.ParameterizedType; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import org.fisco.bcos.sdk.abi.datatypes.DynamicArray; +import org.fisco.bcos.sdk.abi.datatypes.DynamicBytes; +import org.fisco.bcos.sdk.abi.datatypes.Fixed; +import org.fisco.bcos.sdk.abi.datatypes.Int; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; +import org.fisco.bcos.sdk.abi.datatypes.Ufixed; +import org.fisco.bcos.sdk.abi.datatypes.Uint; +import org.fisco.bcos.sdk.abi.datatypes.Utf8String; + +/** Utility functions. */ +public class Utils { + private Utils() {} + + public static String getTypeName(TypeReference typeReference) { + return getTypeName(typeReference.getType()); + } + + public static String getTypeName(java.lang.reflect.Type type) { + try { + + Class cls = Utils.getClassType(type); + if (type instanceof ParameterizedType) { // array + return getParameterizedTypeName(type); + } else { // simple type + return getSimpleTypeName(cls); + } + + } catch (ClassNotFoundException e) { + throw new UnsupportedOperationException("Invalid class reference provided", e); + } + } + + private static String getParameterizedTypeName( + java.lang.reflect.Type type) { + + try { + Class cls = Utils.getClassType(type); + + if (DynamicArray.class.isAssignableFrom(cls)) { + return getTypeName(((ParameterizedType) type).getActualTypeArguments()[0]) + "[]"; + } else if (StaticArray.class.isAssignableFrom(cls)) { + + int length = + Integer.parseInt( + cls.getSimpleName() + .substring(StaticArray.class.getSimpleName().length())); + + return getTypeName(((ParameterizedType) type).getActualTypeArguments()[0]) + + "[" + + length + + "]"; + + } else { + throw new UnsupportedOperationException("Invalid type provided " + cls.getName()); + } + } catch (ClassNotFoundException e) { + throw new UnsupportedOperationException("Invalid class reference provided", e); + } + } + + static String getSimpleTypeName(Class type) { + String simpleName = type.getSimpleName().toLowerCase(); + + if (type.equals(Uint.class) + || type.equals(Int.class) + || type.equals(Ufixed.class) + || type.equals(Fixed.class)) { + return simpleName + "256"; + } else if (type.equals(Utf8String.class)) { + return "string"; + } else if (type.equals(DynamicBytes.class)) { + return "bytes"; + } else { + return simpleName; + } + } + + @SuppressWarnings("rawtypes") + public static boolean dynamicType(java.lang.reflect.Type type) + throws ClassNotFoundException { + + Class cls = Utils.getClassType(type); + // dynamic type + if (Utf8String.class.isAssignableFrom(cls) + || DynamicBytes.class.isAssignableFrom(cls) + || DynamicArray.class.isAssignableFrom(cls)) { + return true; + } + + // not static type + if (!StaticArray.class.isAssignableFrom(cls)) { + return false; + } + + // unpack static array for checking if dynamic type + java.lang.reflect.Type[] types = ((ParameterizedType) type).getActualTypeArguments(); + return dynamicType(types[0]); + } + + public static int getLength(List parameters) { + int count = 0; + for (Type type : parameters) { + count += type.offset(); + } + return count; + } + + public static int getOffset(java.lang.reflect.Type type) + throws ClassNotFoundException { + + if (Utils.dynamicType(type)) { + return 1; + } + + Class cls = Utils.getClassType(type); + if (StaticArray.class.isAssignableFrom(cls)) { + int length = + Integer.parseInt( + cls.getSimpleName() + .substring(StaticArray.class.getSimpleName().length())); + java.lang.reflect.Type[] types = ((ParameterizedType) type).getActualTypeArguments(); + return getOffset(types[0]) * length; + } else { + return 1; + } + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + public static Class getClassType(java.lang.reflect.Type type) + throws ClassNotFoundException { + if (type instanceof ParameterizedType) { + return (Class) ((ParameterizedType) type).getRawType(); + } else { + return (Class) Class.forName(type.getTypeName()); + } + } + + @SuppressWarnings("unchecked") + private static Class getParameterizedTypeFromArray( + java.lang.reflect.Type type) throws ClassNotFoundException { + + java.lang.reflect.Type[] types = ((ParameterizedType) type).getActualTypeArguments(); + + return Utils.getClassType(types[0]); + } + + @SuppressWarnings("unchecked") + public static List> convert(List> input) { + List> result = new ArrayList<>(input.size()); + result.addAll( + input.stream() + .map(typeReference -> (TypeReference) typeReference) + .collect(Collectors.toList())); + return result; + } + + public static , E extends Type> List typeMap( + List> input, Class outerDestType, Class innerType) { + List result = new ArrayList<>(); + try { + Constructor constructor = outerDestType.getDeclaredConstructor(List.class); + for (List ts : input) { + E e = constructor.newInstance(typeMap(ts, innerType)); + result.add(e); + } + } catch (NoSuchMethodException + | IllegalAccessException + | InstantiationException + | InvocationTargetException e) { + throw new TypeMappingException(e); + } + return result; + } + + public static > List typeMap(List input, Class destType) + throws TypeMappingException { + + List result = new ArrayList(input.size()); + + if (!input.isEmpty()) { + try { + Constructor constructor = + destType.getDeclaredConstructor(input.get(0).getClass()); + for (T value : input) { + result.add(constructor.newInstance(value)); + } + } catch (NoSuchMethodException + | IllegalAccessException + | InvocationTargetException + | InstantiationException e) { + throw new TypeMappingException(e); + } + } + return result; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Address.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Address.java new file mode 100644 index 000000000..7fbc4b6b0 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Address.java @@ -0,0 +1,76 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.generated.Uint160; +import org.fisco.bcos.sdk.utils.Numeric; + +/** Address type, which is equivalent to uint160. */ +public class Address implements Type { + + public static final String TYPE_NAME = "address"; + public static final int LENGTH = 160; + public static final int LENGTH_IN_HEX = LENGTH >> 2; + public static final Address DEFAULT = new Address(BigInteger.ZERO); + + private final Uint160 value; + + public Address(Uint160 value) { + this.value = value; + } + + public Address(BigInteger value) { + this(new Uint160(value)); + } + + public Address(String hexValue) { + this(Numeric.toBigInt(hexValue)); + } + + public Uint160 toUint160() { + return value; + } + + @Override + public String getTypeAsString() { + return TYPE_NAME; + } + + @Override + public String toString() { + return Numeric.toHexStringWithPrefixZeroPadded(value.getValue(), LENGTH_IN_HEX); + } + + @Override + public String getValue() { + return toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + Address address = (Address) o; + + return value != null ? value.equals(address.value) : address.value == null; + } + + @Override + public int hashCode() { + return value != null ? value.hashCode() : 0; + } + + @Override + public boolean dynamicType() { + return false; + } + + @Override + public int offset() { + return 1; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Array.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Array.java new file mode 100644 index 000000000..797e7a1ee --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Array.java @@ -0,0 +1,83 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** Fixed size array. */ +public abstract class Array implements Type> { + + private String type; + protected final List value; + + @SafeVarargs + Array(String type, T... values) { + if (!valid(values, type)) { + throw new UnsupportedOperationException( + "If empty list is provided, use empty array instance"); + } + + this.type = type; + this.value = Arrays.asList(values); + } + + Array(String type, List values) { + if (!valid(values, type)) { + throw new UnsupportedOperationException( + "If empty list is provided, use empty array instance"); + } + + this.type = type; + this.value = values; + } + + Array(String type) { + this.type = type; + this.value = Collections.emptyList(); + } + + @Override + public List getValue() { + return value; + } + + @Override + public String getTypeAsString() { + return type; + } + + private boolean valid(T[] values, String type) { + return (values != null && values.length != 0) || type != null; + } + + private boolean valid(List values, String type) { + return (values != null && values.size() != 0) || type != null; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + Array array = (Array) o; + + if (!type.equals(array.type)) { + return false; + } + return value != null ? value.equals(array.value) : array.value == null; + } + + @Override + public int hashCode() { + int result = type.hashCode(); + result = 31 * result + (value != null ? value.hashCode() : 0); + return result; + } + + @Override + public abstract boolean dynamicType(); +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Bool.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Bool.java new file mode 100644 index 000000000..8798cfc5f --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Bool.java @@ -0,0 +1,57 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +/** Boolean type. */ +public class Bool implements Type { + + public static final String TYPE_NAME = "bool"; + public static final Bool DEFAULT = new Bool(false); + + private boolean value; + + public Bool(boolean value) { + this.value = value; + } + + public Bool(Boolean value) { + this.value = value; + } + + @Override + public String getTypeAsString() { + return TYPE_NAME; + } + + @Override + public Boolean getValue() { + return value; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + Bool bool = (Bool) o; + + return value == bool.value; + } + + @Override + public int hashCode() { + return (value ? 1 : 0); + } + + @Override + public boolean dynamicType() { + return false; + } + + @Override + public int offset() { + return 1; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Bytes.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Bytes.java new file mode 100644 index 000000000..0644645fc --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Bytes.java @@ -0,0 +1,30 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +/** Statically allocated sequence of bytes. */ +public class Bytes extends BytesType { + + public static final String TYPE_NAME = "bytes"; + + public Bytes(int byteSize, byte[] value) { + super(value, TYPE_NAME + value.length); + if (!isValid(byteSize, value)) { + throw new UnsupportedOperationException( + "Input byte array must be in range 0 < M <= 32 and length must match type"); + } + } + + private boolean isValid(int byteSize, byte[] value) { + int length = value.length; + return length > 0 && length <= 32 && length == byteSize; + } + + @Override + public boolean dynamicType() { + return false; + } + + @Override + public int offset() { + return 1; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/BytesType.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/BytesType.java new file mode 100644 index 000000000..ad7a27cf9 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/BytesType.java @@ -0,0 +1,52 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.util.Arrays; + +/** Binary sequence of bytes. */ +public abstract class BytesType implements Type { + + private byte[] value; + private String type; + + public BytesType(byte[] src, String type) { + this.value = src; + this.type = type; + } + + @Override + public byte[] getValue() { + return value; + } + + @Override + public String getTypeAsString() { + return type; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + BytesType bytesType = (BytesType) o; + + if (!Arrays.equals(value, bytesType.value)) { + return false; + } + return type.equals(bytesType.type); + } + + @Override + public int hashCode() { + int result = Arrays.hashCode(value); + result = 31 * result + type.hashCode(); + return result; + } + + @Override + public abstract boolean dynamicType(); +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/DynamicArray.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/DynamicArray.java new file mode 100644 index 000000000..01cd26929 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/DynamicArray.java @@ -0,0 +1,34 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.util.List; + +/** Dynamic array type. */ +public class DynamicArray extends Array { + + @SafeVarargs + public DynamicArray(T... values) { + super(values[0].getTypeAsString() + "[]", values); + } + + public DynamicArray(List values) { + super(values.get(0).getTypeAsString() + "[]", values); + } + + private DynamicArray(String type) { + super(type); + } + + public static DynamicArray empty(String type) { + return new DynamicArray(type); + } + + @Override + public boolean dynamicType() { + return true; + } + + @Override + public int offset() { + return 1; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/DynamicBytes.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/DynamicBytes.java new file mode 100644 index 000000000..37f6fe6d0 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/DynamicBytes.java @@ -0,0 +1,22 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +/** Dynamically allocated sequence of bytes. */ +public class DynamicBytes extends BytesType { + + public static final String TYPE_NAME = "bytes"; + public static final DynamicBytes DEFAULT = new DynamicBytes(new byte[] {}); + + public DynamicBytes(byte[] value) { + super(value, TYPE_NAME); + } + + @Override + public boolean dynamicType() { + return true; + } + + @Override + public int offset() { + return 1; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Event.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Event.java new file mode 100644 index 000000000..4046750af --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Event.java @@ -0,0 +1,33 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.util.List; +import java.util.stream.Collectors; +import org.fisco.bcos.sdk.abi.TypeReference; +import org.fisco.bcos.sdk.abi.Utils; + +/** Event wrapper type. */ +public class Event { + private String name; + private List> parameters; + + public Event(String name, List> parameters) { + this.name = name; + this.parameters = Utils.convert(parameters); + } + + public String getName() { + return name; + } + + public List> getParameters() { + return parameters; + } + + public List> getIndexedParameters() { + return parameters.stream().filter(TypeReference::isIndexed).collect(Collectors.toList()); + } + + public List> getNonIndexedParameters() { + return parameters.stream().filter(p -> !p.isIndexed()).collect(Collectors.toList()); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Fixed.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Fixed.java new file mode 100644 index 000000000..a5cfd7d69 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Fixed.java @@ -0,0 +1,36 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.math.BigInteger; + +/** Signed fixed type. */ +public class Fixed extends FixedPointType { + + public static final String TYPE_NAME = "fixed"; + public static final Fixed DEFAULT = new Fixed(BigInteger.ZERO); + + protected Fixed(int mBitSize, int nBitSize, BigInteger value) { + super(TYPE_NAME, mBitSize, nBitSize, value); + } + + public Fixed(BigInteger value) { + this(DEFAULT_BIT_LENGTH, DEFAULT_BIT_LENGTH, value); + } + + public Fixed(BigInteger m, BigInteger n) { + this(convert(m, n)); + } + + protected Fixed(int mBitSize, int nBitSize, BigInteger m, BigInteger n) { + this(convert(mBitSize, nBitSize, m, n)); + } + + @Override + public boolean dynamicType() { + return false; + } + + @Override + public int offset() { + return 1; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/FixedPointType.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/FixedPointType.java new file mode 100644 index 000000000..4448d956d --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/FixedPointType.java @@ -0,0 +1,43 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.math.BigInteger; + +/** Common fixed-point type properties. */ +public abstract class FixedPointType extends NumericType { + + static final int DEFAULT_BIT_LENGTH = MAX_BIT_LENGTH >> 1; + + public FixedPointType(String typePrefix, int mBitSize, int nBitSize, BigInteger value) { + super(typePrefix + mBitSize + "x" + nBitSize, value); + if (!valid(mBitSize, nBitSize, value)) { + throw new UnsupportedOperationException( + "Bitsize must be 8 bit aligned, and in range 0 < bitSize <= 256"); + } + } + + boolean valid(int mBitSize, int nBitSize, BigInteger value) { + return isValidBitSize(mBitSize, nBitSize) && isValidBitCount(mBitSize, nBitSize, value); + } + + static boolean isValidBitSize(int mBitSize, int nBitSize) { + int bitSize = mBitSize + nBitSize; + return mBitSize % 8 == 0 && nBitSize % 8 == 0 && bitSize > 0 && bitSize <= MAX_BIT_LENGTH; + } + + private static boolean isValidBitCount(int mBitSize, int nBitSize, BigInteger value) { + return value.bitCount() <= mBitSize + nBitSize; + } + + static BigInteger convert(BigInteger m, BigInteger n) { + return convert(DEFAULT_BIT_LENGTH, DEFAULT_BIT_LENGTH, m, n); + } + + static BigInteger convert(int mBitSize, int nBitSize, BigInteger m, BigInteger n) { + BigInteger mPadded = m.shiftLeft(nBitSize); + int nBitLength = n.bitLength(); + + // find next multiple of 4 + int shift = (nBitLength + 3) & ~0x03; + return mPadded.or(n.shiftLeft(nBitSize - shift)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Function.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Function.java new file mode 100644 index 000000000..21f51939d --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Function.java @@ -0,0 +1,38 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.util.Collections; +import java.util.List; +import org.fisco.bcos.sdk.abi.TypeReference; +import org.fisco.bcos.sdk.abi.Utils; + +/** Function type. */ +public class Function { + private String name; + private List inputParameters; + private List> outputParameters; + + public Function( + String name, List inputParameters, List> outputParameters) { + this.name = name; + this.inputParameters = inputParameters; + this.outputParameters = Utils.convert(outputParameters); + } + + public Function() { + this.name = ""; + this.inputParameters = Collections.emptyList(); + this.outputParameters = Collections.>emptyList(); + } + + public String getName() { + return name; + } + + public List getInputParameters() { + return inputParameters; + } + + public List> getOutputParameters() { + return outputParameters; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Int.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Int.java new file mode 100644 index 000000000..4e66909da --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Int.java @@ -0,0 +1,46 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.Constant; + +/** Integer type. */ +public class Int extends IntType { + + public static final String TYPE_NAME = "int"; + public static final Int DEFAULT = new Int(BigInteger.ZERO); + + public Int(BigInteger value) { + // "int" values should be declared as int256 in computing function selectors + this(MAX_BIT_LENGTH, value); + } + + /** + * check if value between MIN_INT256 ~ MIN_INT256 + * + * @param value + * @return + */ + public boolean validInt(BigInteger value) { + return value.compareTo(Constant.MIN_INT256) >= 0 + && value.compareTo(Constant.MAX_INT256) <= 0; + } + + @Override + boolean valid(int bitSize, BigInteger value) { + return super.valid(bitSize, value) && validInt(value); + } + + protected Int(int bitSize, BigInteger value) { + super(TYPE_NAME, bitSize, value); + } + + @Override + public boolean dynamicType() { + return false; + } + + @Override + public int offset() { + return 1; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/IntType.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/IntType.java new file mode 100644 index 000000000..3a1adf421 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/IntType.java @@ -0,0 +1,27 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.math.BigInteger; + +/** Common integer properties. */ +public abstract class IntType extends NumericType { + + public IntType(String typePrefix, int bitSize, BigInteger value) { + super(typePrefix + bitSize, value); + if (!valid(bitSize, value)) { + throw new UnsupportedOperationException( + "Bitsize must be 8 bit aligned, and in range 0 < bitSize <= 256, and in valid range."); + } + } + + boolean valid(int bitSize, BigInteger value) { + return isValidBitSize(bitSize) && isValidBitCount(bitSize, value); + } + + static boolean isValidBitSize(int bitSize) { + return bitSize % 8 == 0 && bitSize > 0 && bitSize <= MAX_BIT_LENGTH; + } + + private static boolean isValidBitCount(int bitSize, BigInteger value) { + return value.bitLength() <= bitSize; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/NumericType.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/NumericType.java new file mode 100644 index 000000000..b8a01e1ef --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/NumericType.java @@ -0,0 +1,50 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.math.BigInteger; + +/** Common numeric type. */ +public abstract class NumericType implements Type { + + private String type; + BigInteger value; + + public NumericType(String type, BigInteger value) { + this.type = type; + this.value = value; + } + + @Override + public String getTypeAsString() { + return type; + } + + @Override + public BigInteger getValue() { + return value; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + NumericType that = (NumericType) o; + + if (!type.equals(that.type)) { + return false; + } + + return value != null ? value.equals(that.value) : that.value == null; + } + + @Override + public int hashCode() { + int result = type.hashCode(); + result = 31 * result + (value != null ? value.hashCode() : 0); + return result; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/StaticArray.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/StaticArray.java new file mode 100644 index 000000000..957271c33 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/StaticArray.java @@ -0,0 +1,89 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.util.List; + +/** Static array type. */ +public class StaticArray extends Array { + /** + * Warning: increasing this constant will cause more generated StaticArrayN types, see: + * AbiTypesGenerator#generateStaticArrayTypes + */ + public static int MAX_SIZE_OF_STATIC_ARRAY = 1024; + + private Integer expectedSize; + + @SafeVarargs + public StaticArray(T... values) { + super(values[0].getTypeAsString() + "[" + values.length + "]", values); + isValid(); + } + + @SafeVarargs + public StaticArray(int expectedSize, T... values) { + super(values[0].getTypeAsString() + "[" + values.length + "]", values); + this.expectedSize = expectedSize; + isValid(); + } + + public StaticArray(List values) { + super(values.get(0).getTypeAsString() + "[" + values.size() + "]", values); + isValid(); + } + + public StaticArray(int expectedSize, List values) { + super(values.get(0).getTypeAsString() + "[" + values.size() + "]", values); + this.expectedSize = expectedSize; + isValid(); + } + + private void isValid() { + if (expectedSize == null && value.size() > MAX_SIZE_OF_STATIC_ARRAY) { + throw new UnsupportedOperationException( + "Static arrays with a length greater than 1024 are not supported."); + } else if (expectedSize != null && value.size() != expectedSize) { + throw new UnsupportedOperationException( + "Expected array of type [" + + getClass().getSimpleName() + + "] to have [" + + expectedSize + + "] elements."); + } + } + + @SuppressWarnings("unchecked") + @Override + public boolean dynamicType() { + Type obj = value.get(0); + + if (obj instanceof StaticArray) { + return ((T) obj).dynamicType(); + } else if ((obj instanceof NumericType) + || (obj instanceof Address) + || (obj instanceof Bool) + || (obj instanceof Bytes)) { + return false; + } else if ((obj instanceof DynamicBytes) + || (obj instanceof Utf8String) + || (obj instanceof DynamicArray)) { + return true; + } else { + throw new UnsupportedOperationException("Type cannot be encoded: " + obj.getClass()); + } + } + + @Override + public int offset() { + + if (dynamicType()) { + return 1; + } + + Object obj = value.get(0); + + if (obj instanceof StaticArray) { + return ((Type) obj).offset() * getValue().size(); + } + + return getValue().size(); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Type.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Type.java new file mode 100644 index 000000000..ca9cd09de --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Type.java @@ -0,0 +1,15 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +/** ABI Types. */ +public interface Type { + int MAX_BIT_LENGTH = 256; + int MAX_BYTE_LENGTH = MAX_BIT_LENGTH / 8; + + T getValue(); + + String getTypeAsString(); + + boolean dynamicType(); + + public int offset(); +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Ufixed.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Ufixed.java new file mode 100644 index 000000000..4dce94741 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Ufixed.java @@ -0,0 +1,41 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.math.BigInteger; + +/** Signed fixed type. */ +public class Ufixed extends FixedPointType { + + public static final String TYPE_NAME = "ufixed"; + public static final Ufixed DEFAULT = new Ufixed(BigInteger.ZERO); + + protected Ufixed(int mBitSize, int nBitSize, BigInteger value) { + super(TYPE_NAME, mBitSize, nBitSize, value); + } + + public Ufixed(BigInteger value) { + this(DEFAULT_BIT_LENGTH, DEFAULT_BIT_LENGTH, value); + } + + public Ufixed(BigInteger m, BigInteger n) { + this(convert(m, n)); + } + + protected Ufixed(int mBitSize, int nBitSize, BigInteger m, BigInteger n) { + this(convert(mBitSize, nBitSize, m, n)); + } + + @Override + boolean valid(int mBitSize, int nBitSize, BigInteger value) { + return super.valid(mBitSize, nBitSize, value) && value.signum() != -1; + } + + @Override + public boolean dynamicType() { + return false; + } + + @Override + public int offset() { + return 1; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Uint.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Uint.java new file mode 100644 index 000000000..6c66d5dc7 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Uint.java @@ -0,0 +1,49 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.Constant; + +/** Unsigned integer type. */ +public class Uint extends IntType { + + public static final String TYPE_NAME = "uint"; + public static final Uint DEFAULT = new Uint(BigInteger.ZERO); + /** This constructor is required by the {@link Address} type. */ + Uint(String typePrefix, int bitSize, BigInteger value) { + super(typePrefix, bitSize, value); + } + + protected Uint(int bitSize, BigInteger value) { + this(TYPE_NAME, bitSize, value); + } + + public Uint(BigInteger value) { + // "int" values should be declared as int256 in computing function selectors + this(MAX_BIT_LENGTH, value); + } + + /** + * check if value between 0 ~ MAX_UINT256 + * + * @param value + * @return + */ + public boolean validUint(BigInteger value) { + return value.compareTo(BigInteger.ZERO) >= 0 && value.compareTo(Constant.MAX_UINT256) <= 0; + } + + @Override + boolean valid(int bitSize, BigInteger value) { + return super.valid(bitSize, value) && value.signum() != -1 && validUint(value); + } + + @Override + public boolean dynamicType() { + return false; + } + + @Override + public int offset() { + return 1; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Utf8String.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Utf8String.java new file mode 100644 index 000000000..d978d2880 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/Utf8String.java @@ -0,0 +1,58 @@ +package org.fisco.bcos.sdk.abi.datatypes; + +/** UTF-8 encoded string type. */ +public class Utf8String implements Type { + + public static final String TYPE_NAME = "string"; + public static final Utf8String DEFAULT = new Utf8String(""); + + private String value; + + public Utf8String(String value) { + this.value = value; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getTypeAsString() { + return TYPE_NAME; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + Utf8String that = (Utf8String) o; + + return value != null ? value.equals(that.value) : that.value == null; + } + + @Override + public int hashCode() { + return value != null ? value.hashCode() : 0; + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean dynamicType() { + return true; + } + + @Override + public int offset() { + return 1; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/AbiTypes.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/AbiTypes.java new file mode 100644 index 000000000..5915b82ac --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/AbiTypes.java @@ -0,0 +1,230 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Address; +import org.fisco.bcos.sdk.abi.datatypes.Bool; +import org.fisco.bcos.sdk.abi.datatypes.DynamicBytes; +import org.fisco.bcos.sdk.abi.datatypes.Utf8String; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesMapperGenerator in the codegen module to update. + */ +public final class AbiTypes { + private AbiTypes() {} + + public static Class getType(String type) { + switch (type) { + case "address": + return Address.class; + case "bool": + return Bool.class; + case "string": + return Utf8String.class; + case "bytes": + return DynamicBytes.class; + case "uint8": + return Uint8.class; + case "int8": + return Int8.class; + case "uint16": + return Uint16.class; + case "int16": + return Int16.class; + case "uint24": + return Uint24.class; + case "int24": + return Int24.class; + case "uint32": + return Uint32.class; + case "int32": + return Int32.class; + case "uint40": + return Uint40.class; + case "int40": + return Int40.class; + case "uint48": + return Uint48.class; + case "int48": + return Int48.class; + case "uint56": + return Uint56.class; + case "int56": + return Int56.class; + case "uint64": + return Uint64.class; + case "int64": + return Int64.class; + case "uint72": + return Uint72.class; + case "int72": + return Int72.class; + case "uint80": + return Uint80.class; + case "int80": + return Int80.class; + case "uint88": + return Uint88.class; + case "int88": + return Int88.class; + case "uint96": + return Uint96.class; + case "int96": + return Int96.class; + case "uint104": + return Uint104.class; + case "int104": + return Int104.class; + case "uint112": + return Uint112.class; + case "int112": + return Int112.class; + case "uint120": + return Uint120.class; + case "int120": + return Int120.class; + case "uint128": + return Uint128.class; + case "int128": + return Int128.class; + case "uint136": + return Uint136.class; + case "int136": + return Int136.class; + case "uint144": + return Uint144.class; + case "int144": + return Int144.class; + case "uint152": + return Uint152.class; + case "int152": + return Int152.class; + case "uint160": + return Uint160.class; + case "int160": + return Int160.class; + case "uint168": + return Uint168.class; + case "int168": + return Int168.class; + case "uint176": + return Uint176.class; + case "int176": + return Int176.class; + case "uint184": + return Uint184.class; + case "int184": + return Int184.class; + case "uint192": + return Uint192.class; + case "int192": + return Int192.class; + case "uint200": + return Uint200.class; + case "int200": + return Int200.class; + case "uint208": + return Uint208.class; + case "int208": + return Int208.class; + case "uint216": + return Uint216.class; + case "int216": + return Int216.class; + case "uint224": + return Uint224.class; + case "int224": + return Int224.class; + case "uint232": + return Uint232.class; + case "int232": + return Int232.class; + case "uint240": + return Uint240.class; + case "int240": + return Int240.class; + case "uint248": + return Uint248.class; + case "int248": + return Int248.class; + case "uint256": + return Uint256.class; + case "int256": + return Int256.class; + case "bytes1": + return Bytes1.class; + case "bytes2": + return Bytes2.class; + case "bytes3": + return Bytes3.class; + case "bytes4": + return Bytes4.class; + case "bytes5": + return Bytes5.class; + case "bytes6": + return Bytes6.class; + case "bytes7": + return Bytes7.class; + case "bytes8": + return Bytes8.class; + case "bytes9": + return Bytes9.class; + case "bytes10": + return Bytes10.class; + case "bytes11": + return Bytes11.class; + case "bytes12": + return Bytes12.class; + case "bytes13": + return Bytes13.class; + case "bytes14": + return Bytes14.class; + case "bytes15": + return Bytes15.class; + case "bytes16": + return Bytes16.class; + case "bytes17": + return Bytes17.class; + case "bytes18": + return Bytes18.class; + case "bytes19": + return Bytes19.class; + case "bytes20": + return Bytes20.class; + case "bytes21": + return Bytes21.class; + case "bytes22": + return Bytes22.class; + case "bytes23": + return Bytes23.class; + case "bytes24": + return Bytes24.class; + case "bytes25": + return Bytes25.class; + case "bytes26": + return Bytes26.class; + case "bytes27": + return Bytes27.class; + case "bytes28": + return Bytes28.class; + case "bytes29": + return Bytes29.class; + case "bytes30": + return Bytes30.class; + case "bytes31": + return Bytes31.class; + case "bytes32": + return Bytes32.class; + /*case "TransactionSucCallback": + return TransactionSucCallbac.class; + case "EventLogPushCallback": + return EventLogPushWithDecodeCallback.class;*/ + + default: + throw new UnsupportedOperationException("Unsupported type encountered: " + type); + } + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes1.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes1.java new file mode 100644 index 000000000..d1446254e --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes1.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes1 extends Bytes { + public static final Bytes1 DEFAULT = new Bytes1(new byte[1]); + + public Bytes1(byte[] value) { + super(1, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes10.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes10.java new file mode 100644 index 000000000..f2b318019 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes10.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes10 extends Bytes { + public static final Bytes10 DEFAULT = new Bytes10(new byte[10]); + + public Bytes10(byte[] value) { + super(10, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes11.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes11.java new file mode 100644 index 000000000..5deef2905 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes11.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes11 extends Bytes { + public static final Bytes11 DEFAULT = new Bytes11(new byte[11]); + + public Bytes11(byte[] value) { + super(11, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes12.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes12.java new file mode 100644 index 000000000..1664078a1 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes12.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes12 extends Bytes { + public static final Bytes12 DEFAULT = new Bytes12(new byte[12]); + + public Bytes12(byte[] value) { + super(12, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes13.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes13.java new file mode 100644 index 000000000..9b422f0cd --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes13.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes13 extends Bytes { + public static final Bytes13 DEFAULT = new Bytes13(new byte[13]); + + public Bytes13(byte[] value) { + super(13, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes14.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes14.java new file mode 100644 index 000000000..b2f0756b9 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes14.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes14 extends Bytes { + public static final Bytes14 DEFAULT = new Bytes14(new byte[14]); + + public Bytes14(byte[] value) { + super(14, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes15.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes15.java new file mode 100644 index 000000000..1a4f6b727 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes15.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes15 extends Bytes { + public static final Bytes15 DEFAULT = new Bytes15(new byte[15]); + + public Bytes15(byte[] value) { + super(15, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes16.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes16.java new file mode 100644 index 000000000..c944b7feb --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes16.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes16 extends Bytes { + public static final Bytes16 DEFAULT = new Bytes16(new byte[16]); + + public Bytes16(byte[] value) { + super(16, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes17.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes17.java new file mode 100644 index 000000000..540b4734f --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes17.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes17 extends Bytes { + public static final Bytes17 DEFAULT = new Bytes17(new byte[17]); + + public Bytes17(byte[] value) { + super(17, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes18.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes18.java new file mode 100644 index 000000000..14470e067 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes18.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes18 extends Bytes { + public static final Bytes18 DEFAULT = new Bytes18(new byte[18]); + + public Bytes18(byte[] value) { + super(18, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes19.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes19.java new file mode 100644 index 000000000..8d4070bc8 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes19.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes19 extends Bytes { + public static final Bytes19 DEFAULT = new Bytes19(new byte[19]); + + public Bytes19(byte[] value) { + super(19, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes2.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes2.java new file mode 100644 index 000000000..21ef575ad --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes2.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes2 extends Bytes { + public static final Bytes2 DEFAULT = new Bytes2(new byte[2]); + + public Bytes2(byte[] value) { + super(2, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes20.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes20.java new file mode 100644 index 000000000..81af614ed --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes20.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes20 extends Bytes { + public static final Bytes20 DEFAULT = new Bytes20(new byte[20]); + + public Bytes20(byte[] value) { + super(20, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes21.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes21.java new file mode 100644 index 000000000..7d8a07cc8 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes21.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes21 extends Bytes { + public static final Bytes21 DEFAULT = new Bytes21(new byte[21]); + + public Bytes21(byte[] value) { + super(21, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes22.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes22.java new file mode 100644 index 000000000..cac31ef7a --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes22.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes22 extends Bytes { + public static final Bytes22 DEFAULT = new Bytes22(new byte[22]); + + public Bytes22(byte[] value) { + super(22, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes23.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes23.java new file mode 100644 index 000000000..348b68919 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes23.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes23 extends Bytes { + public static final Bytes23 DEFAULT = new Bytes23(new byte[23]); + + public Bytes23(byte[] value) { + super(23, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes24.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes24.java new file mode 100644 index 000000000..38e2219c7 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes24.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes24 extends Bytes { + public static final Bytes24 DEFAULT = new Bytes24(new byte[24]); + + public Bytes24(byte[] value) { + super(24, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes25.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes25.java new file mode 100644 index 000000000..d092a5040 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes25.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes25 extends Bytes { + public static final Bytes25 DEFAULT = new Bytes25(new byte[25]); + + public Bytes25(byte[] value) { + super(25, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes26.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes26.java new file mode 100644 index 000000000..c5b237de5 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes26.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes26 extends Bytes { + public static final Bytes26 DEFAULT = new Bytes26(new byte[26]); + + public Bytes26(byte[] value) { + super(26, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes27.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes27.java new file mode 100644 index 000000000..c1891a19c --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes27.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes27 extends Bytes { + public static final Bytes27 DEFAULT = new Bytes27(new byte[27]); + + public Bytes27(byte[] value) { + super(27, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes28.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes28.java new file mode 100644 index 000000000..6db753ff4 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes28.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes28 extends Bytes { + public static final Bytes28 DEFAULT = new Bytes28(new byte[28]); + + public Bytes28(byte[] value) { + super(28, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes29.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes29.java new file mode 100644 index 000000000..ee36929d0 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes29.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes29 extends Bytes { + public static final Bytes29 DEFAULT = new Bytes29(new byte[29]); + + public Bytes29(byte[] value) { + super(29, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes3.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes3.java new file mode 100644 index 000000000..02a52eebb --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes3.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes3 extends Bytes { + public static final Bytes3 DEFAULT = new Bytes3(new byte[3]); + + public Bytes3(byte[] value) { + super(3, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes30.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes30.java new file mode 100644 index 000000000..475d1cbc1 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes30.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes30 extends Bytes { + public static final Bytes30 DEFAULT = new Bytes30(new byte[30]); + + public Bytes30(byte[] value) { + super(30, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes31.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes31.java new file mode 100644 index 000000000..237bb680c --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes31.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes31 extends Bytes { + public static final Bytes31 DEFAULT = new Bytes31(new byte[31]); + + public Bytes31(byte[] value) { + super(31, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes32.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes32.java new file mode 100644 index 000000000..cb1e3a5cd --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes32.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes32 extends Bytes { + public static final Bytes32 DEFAULT = new Bytes32(new byte[32]); + + public Bytes32(byte[] value) { + super(32, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes4.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes4.java new file mode 100644 index 000000000..3bba13b8a --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes4.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes4 extends Bytes { + public static final Bytes4 DEFAULT = new Bytes4(new byte[4]); + + public Bytes4(byte[] value) { + super(4, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes5.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes5.java new file mode 100644 index 000000000..37d4e9c0c --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes5.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes5 extends Bytes { + public static final Bytes5 DEFAULT = new Bytes5(new byte[5]); + + public Bytes5(byte[] value) { + super(5, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes6.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes6.java new file mode 100644 index 000000000..0363c872e --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes6.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes6 extends Bytes { + public static final Bytes6 DEFAULT = new Bytes6(new byte[6]); + + public Bytes6(byte[] value) { + super(6, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes7.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes7.java new file mode 100644 index 000000000..cbd9e62d2 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes7.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes7 extends Bytes { + public static final Bytes7 DEFAULT = new Bytes7(new byte[7]); + + public Bytes7(byte[] value) { + super(7, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes8.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes8.java new file mode 100644 index 000000000..d0ca2bbf5 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes8.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes8 extends Bytes { + public static final Bytes8 DEFAULT = new Bytes8(new byte[8]); + + public Bytes8(byte[] value) { + super(8, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes9.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes9.java new file mode 100644 index 000000000..4d22eda8b --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Bytes9.java @@ -0,0 +1,19 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import org.fisco.bcos.sdk.abi.datatypes.Bytes; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Bytes9 extends Bytes { + public static final Bytes9 DEFAULT = new Bytes9(new byte[9]); + + public Bytes9(byte[] value) { + super(9, value); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int104.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int104.java new file mode 100644 index 000000000..91f430be1 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int104.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int104 extends Int { + public static final Int104 DEFAULT = new Int104(BigInteger.ZERO); + + public Int104(BigInteger value) { + super(104, value); + } + + public Int104(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int112.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int112.java new file mode 100644 index 000000000..1f1a8cf0b --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int112.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int112 extends Int { + public static final Int112 DEFAULT = new Int112(BigInteger.ZERO); + + public Int112(BigInteger value) { + super(112, value); + } + + public Int112(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int120.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int120.java new file mode 100644 index 000000000..cd7e1708b --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int120.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int120 extends Int { + public static final Int120 DEFAULT = new Int120(BigInteger.ZERO); + + public Int120(BigInteger value) { + super(120, value); + } + + public Int120(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int128.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int128.java new file mode 100644 index 000000000..344bf0060 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int128.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int128 extends Int { + public static final Int128 DEFAULT = new Int128(BigInteger.ZERO); + + public Int128(BigInteger value) { + super(128, value); + } + + public Int128(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int136.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int136.java new file mode 100644 index 000000000..856a44920 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int136.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int136 extends Int { + public static final Int136 DEFAULT = new Int136(BigInteger.ZERO); + + public Int136(BigInteger value) { + super(136, value); + } + + public Int136(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int144.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int144.java new file mode 100644 index 000000000..44aa9e51a --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int144.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int144 extends Int { + public static final Int144 DEFAULT = new Int144(BigInteger.ZERO); + + public Int144(BigInteger value) { + super(144, value); + } + + public Int144(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int152.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int152.java new file mode 100644 index 000000000..3bca3375e --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int152.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int152 extends Int { + public static final Int152 DEFAULT = new Int152(BigInteger.ZERO); + + public Int152(BigInteger value) { + super(152, value); + } + + public Int152(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int16.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int16.java new file mode 100644 index 000000000..804552972 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int16.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int16 extends Int { + public static final Int16 DEFAULT = new Int16(BigInteger.ZERO); + + public Int16(BigInteger value) { + super(16, value); + } + + public Int16(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int160.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int160.java new file mode 100644 index 000000000..ff39da4a8 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int160.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int160 extends Int { + public static final Int160 DEFAULT = new Int160(BigInteger.ZERO); + + public Int160(BigInteger value) { + super(160, value); + } + + public Int160(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int168.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int168.java new file mode 100644 index 000000000..cca780247 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int168.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int168 extends Int { + public static final Int168 DEFAULT = new Int168(BigInteger.ZERO); + + public Int168(BigInteger value) { + super(168, value); + } + + public Int168(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int176.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int176.java new file mode 100644 index 000000000..1091766a1 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int176.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int176 extends Int { + public static final Int176 DEFAULT = new Int176(BigInteger.ZERO); + + public Int176(BigInteger value) { + super(176, value); + } + + public Int176(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int184.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int184.java new file mode 100644 index 000000000..79bb8634e --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int184.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int184 extends Int { + public static final Int184 DEFAULT = new Int184(BigInteger.ZERO); + + public Int184(BigInteger value) { + super(184, value); + } + + public Int184(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int192.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int192.java new file mode 100644 index 000000000..83a1a3989 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int192.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int192 extends Int { + public static final Int192 DEFAULT = new Int192(BigInteger.ZERO); + + public Int192(BigInteger value) { + super(192, value); + } + + public Int192(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int200.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int200.java new file mode 100644 index 000000000..78350dceb --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int200.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int200 extends Int { + public static final Int200 DEFAULT = new Int200(BigInteger.ZERO); + + public Int200(BigInteger value) { + super(200, value); + } + + public Int200(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int208.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int208.java new file mode 100644 index 000000000..0a4f4bb37 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int208.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int208 extends Int { + public static final Int208 DEFAULT = new Int208(BigInteger.ZERO); + + public Int208(BigInteger value) { + super(208, value); + } + + public Int208(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int216.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int216.java new file mode 100644 index 000000000..5c57bc4e1 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int216.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int216 extends Int { + public static final Int216 DEFAULT = new Int216(BigInteger.ZERO); + + public Int216(BigInteger value) { + super(216, value); + } + + public Int216(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int224.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int224.java new file mode 100644 index 000000000..f0cabec18 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int224.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int224 extends Int { + public static final Int224 DEFAULT = new Int224(BigInteger.ZERO); + + public Int224(BigInteger value) { + super(224, value); + } + + public Int224(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int232.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int232.java new file mode 100644 index 000000000..82e5315ca --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int232.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int232 extends Int { + public static final Int232 DEFAULT = new Int232(BigInteger.ZERO); + + public Int232(BigInteger value) { + super(232, value); + } + + public Int232(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int24.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int24.java new file mode 100644 index 000000000..30e160d2f --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int24.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int24 extends Int { + public static final Int24 DEFAULT = new Int24(BigInteger.ZERO); + + public Int24(BigInteger value) { + super(24, value); + } + + public Int24(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int240.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int240.java new file mode 100644 index 000000000..f796a3430 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int240.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int240 extends Int { + public static final Int240 DEFAULT = new Int240(BigInteger.ZERO); + + public Int240(BigInteger value) { + super(240, value); + } + + public Int240(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int248.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int248.java new file mode 100644 index 000000000..4de02c9d2 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int248.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int248 extends Int { + public static final Int248 DEFAULT = new Int248(BigInteger.ZERO); + + public Int248(BigInteger value) { + super(248, value); + } + + public Int248(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int256.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int256.java new file mode 100644 index 000000000..fc5c1562e --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int256.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int256 extends Int { + public static final Int256 DEFAULT = new Int256(BigInteger.ZERO); + + public Int256(BigInteger value) { + super(256, value); + } + + public Int256(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int32.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int32.java new file mode 100644 index 000000000..3f0441a95 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int32.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int32 extends Int { + public static final Int32 DEFAULT = new Int32(BigInteger.ZERO); + + public Int32(BigInteger value) { + super(32, value); + } + + public Int32(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int40.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int40.java new file mode 100644 index 000000000..5807a2ac8 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int40.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int40 extends Int { + public static final Int40 DEFAULT = new Int40(BigInteger.ZERO); + + public Int40(BigInteger value) { + super(40, value); + } + + public Int40(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int48.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int48.java new file mode 100644 index 000000000..3533d5af6 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int48.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int48 extends Int { + public static final Int48 DEFAULT = new Int48(BigInteger.ZERO); + + public Int48(BigInteger value) { + super(48, value); + } + + public Int48(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int56.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int56.java new file mode 100644 index 000000000..d9ca278a3 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int56.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int56 extends Int { + public static final Int56 DEFAULT = new Int56(BigInteger.ZERO); + + public Int56(BigInteger value) { + super(56, value); + } + + public Int56(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int64.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int64.java new file mode 100644 index 000000000..d5a0020b2 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int64.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int64 extends Int { + public static final Int64 DEFAULT = new Int64(BigInteger.ZERO); + + public Int64(BigInteger value) { + super(64, value); + } + + public Int64(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int72.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int72.java new file mode 100644 index 000000000..e42301c56 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int72.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int72 extends Int { + public static final Int72 DEFAULT = new Int72(BigInteger.ZERO); + + public Int72(BigInteger value) { + super(72, value); + } + + public Int72(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int8.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int8.java new file mode 100644 index 000000000..caadabbfc --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int8.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int8 extends Int { + public static final Int8 DEFAULT = new Int8(BigInteger.ZERO); + + public Int8(BigInteger value) { + super(8, value); + } + + public Int8(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int80.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int80.java new file mode 100644 index 000000000..823826afb --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int80.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int80 extends Int { + public static final Int80 DEFAULT = new Int80(BigInteger.ZERO); + + public Int80(BigInteger value) { + super(80, value); + } + + public Int80(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int88.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int88.java new file mode 100644 index 000000000..3337b1cb4 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int88.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int88 extends Int { + public static final Int88 DEFAULT = new Int88(BigInteger.ZERO); + + public Int88(BigInteger value) { + super(88, value); + } + + public Int88(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int96.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int96.java new file mode 100644 index 000000000..70ffdf022 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Int96.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Int; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Int96 extends Int { + public static final Int96 DEFAULT = new Int96(BigInteger.ZERO); + + public Int96(BigInteger value) { + super(96, value); + } + + public Int96(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray1.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray1.java new file mode 100644 index 000000000..a3628ca82 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray1.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray1 extends StaticArray { + public StaticArray1(List values) { + super(1, values); + } + + @SafeVarargs + public StaticArray1(T... values) { + super(1, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray10.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray10.java new file mode 100644 index 000000000..549208a12 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray10.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray10 extends StaticArray { + public StaticArray10(List values) { + super(10, values); + } + + @SafeVarargs + public StaticArray10(T... values) { + super(10, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray11.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray11.java new file mode 100644 index 000000000..b64644485 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray11.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray11 extends StaticArray { + public StaticArray11(List values) { + super(11, values); + } + + @SafeVarargs + public StaticArray11(T... values) { + super(11, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray12.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray12.java new file mode 100644 index 000000000..b520868d7 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray12.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray12 extends StaticArray { + public StaticArray12(List values) { + super(12, values); + } + + @SafeVarargs + public StaticArray12(T... values) { + super(12, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray128.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray128.java new file mode 100644 index 000000000..a4469527b --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray128.java @@ -0,0 +1,35 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use org.web3j.codegen.AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray128 extends StaticArray { + @Deprecated + public StaticArray128(List values) { + super(128, values); + } + + @Deprecated + @SafeVarargs + public StaticArray128(T... values) { + super(128, values); + } + // + // public StaticArray128(Class type, List values) { + // super(type, 128, values); + // } + // + // @SafeVarargs + // public StaticArray128(Class type, T... values) { + // super(type, 128, values); + // } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray13.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray13.java new file mode 100644 index 000000000..32391fa9f --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray13.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray13 extends StaticArray { + public StaticArray13(List values) { + super(13, values); + } + + @SafeVarargs + public StaticArray13(T... values) { + super(13, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray14.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray14.java new file mode 100644 index 000000000..680d29e0a --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray14.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray14 extends StaticArray { + public StaticArray14(List values) { + super(14, values); + } + + @SafeVarargs + public StaticArray14(T... values) { + super(14, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray15.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray15.java new file mode 100644 index 000000000..c9f4b07bb --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray15.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray15 extends StaticArray { + public StaticArray15(List values) { + super(15, values); + } + + @SafeVarargs + public StaticArray15(T... values) { + super(15, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray16.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray16.java new file mode 100644 index 000000000..92e5a8442 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray16.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray16 extends StaticArray { + public StaticArray16(List values) { + super(16, values); + } + + @SafeVarargs + public StaticArray16(T... values) { + super(16, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray17.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray17.java new file mode 100644 index 000000000..c0e5a44b6 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray17.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray17 extends StaticArray { + public StaticArray17(List values) { + super(17, values); + } + + @SafeVarargs + public StaticArray17(T... values) { + super(17, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray18.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray18.java new file mode 100644 index 000000000..10261b048 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray18.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray18 extends StaticArray { + public StaticArray18(List values) { + super(18, values); + } + + @SafeVarargs + public StaticArray18(T... values) { + super(18, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray19.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray19.java new file mode 100644 index 000000000..861b9b68a --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray19.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray19 extends StaticArray { + public StaticArray19(List values) { + super(19, values); + } + + @SafeVarargs + public StaticArray19(T... values) { + super(19, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray2.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray2.java new file mode 100644 index 000000000..af50b5ed0 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray2.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray2 extends StaticArray { + public StaticArray2(List values) { + super(2, values); + } + + @SafeVarargs + public StaticArray2(T... values) { + super(2, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray20.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray20.java new file mode 100644 index 000000000..3a4ef52aa --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray20.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray20 extends StaticArray { + public StaticArray20(List values) { + super(20, values); + } + + @SafeVarargs + public StaticArray20(T... values) { + super(20, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray21.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray21.java new file mode 100644 index 000000000..83fad2583 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray21.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray21 extends StaticArray { + public StaticArray21(List values) { + super(21, values); + } + + @SafeVarargs + public StaticArray21(T... values) { + super(21, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray22.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray22.java new file mode 100644 index 000000000..ba6d078d6 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray22.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray22 extends StaticArray { + public StaticArray22(List values) { + super(22, values); + } + + @SafeVarargs + public StaticArray22(T... values) { + super(22, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray23.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray23.java new file mode 100644 index 000000000..f29d51ef1 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray23.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray23 extends StaticArray { + public StaticArray23(List values) { + super(23, values); + } + + @SafeVarargs + public StaticArray23(T... values) { + super(23, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray24.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray24.java new file mode 100644 index 000000000..9928e5bf8 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray24.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray24 extends StaticArray { + public StaticArray24(List values) { + super(24, values); + } + + @SafeVarargs + public StaticArray24(T... values) { + super(24, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray25.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray25.java new file mode 100644 index 000000000..fd204865e --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray25.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray25 extends StaticArray { + public StaticArray25(List values) { + super(25, values); + } + + @SafeVarargs + public StaticArray25(T... values) { + super(25, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray26.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray26.java new file mode 100644 index 000000000..919179488 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray26.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray26 extends StaticArray { + public StaticArray26(List values) { + super(26, values); + } + + @SafeVarargs + public StaticArray26(T... values) { + super(26, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray27.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray27.java new file mode 100644 index 000000000..d9df13688 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray27.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray27 extends StaticArray { + public StaticArray27(List values) { + super(27, values); + } + + @SafeVarargs + public StaticArray27(T... values) { + super(27, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray28.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray28.java new file mode 100644 index 000000000..90b6f2ea3 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray28.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray28 extends StaticArray { + public StaticArray28(List values) { + super(28, values); + } + + @SafeVarargs + public StaticArray28(T... values) { + super(28, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray29.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray29.java new file mode 100644 index 000000000..e245cd4ae --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray29.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray29 extends StaticArray { + public StaticArray29(List values) { + super(29, values); + } + + @SafeVarargs + public StaticArray29(T... values) { + super(29, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray3.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray3.java new file mode 100644 index 000000000..b412b5316 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray3.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray3 extends StaticArray { + public StaticArray3(List values) { + super(3, values); + } + + @SafeVarargs + public StaticArray3(T... values) { + super(3, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray30.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray30.java new file mode 100644 index 000000000..e933c647c --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray30.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray30 extends StaticArray { + public StaticArray30(List values) { + super(30, values); + } + + @SafeVarargs + public StaticArray30(T... values) { + super(30, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray31.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray31.java new file mode 100644 index 000000000..7a2112811 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray31.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray31 extends StaticArray { + public StaticArray31(List values) { + super(31, values); + } + + @SafeVarargs + public StaticArray31(T... values) { + super(31, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray32.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray32.java new file mode 100644 index 000000000..fe69fa45c --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray32.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray32 extends StaticArray { + public StaticArray32(List values) { + super(32, values); + } + + @SafeVarargs + public StaticArray32(T... values) { + super(32, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray4.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray4.java new file mode 100644 index 000000000..e6194e7da --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray4.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray4 extends StaticArray { + public StaticArray4(List values) { + super(4, values); + } + + @SafeVarargs + public StaticArray4(T... values) { + super(4, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray5.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray5.java new file mode 100644 index 000000000..c39451be5 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray5.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray5 extends StaticArray { + public StaticArray5(List values) { + super(5, values); + } + + @SafeVarargs + public StaticArray5(T... values) { + super(5, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray6.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray6.java new file mode 100644 index 000000000..2fdd2b60a --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray6.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray6 extends StaticArray { + public StaticArray6(List values) { + super(6, values); + } + + @SafeVarargs + public StaticArray6(T... values) { + super(6, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray7.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray7.java new file mode 100644 index 000000000..c31125d69 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray7.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray7 extends StaticArray { + public StaticArray7(List values) { + super(7, values); + } + + @SafeVarargs + public StaticArray7(T... values) { + super(7, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray8.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray8.java new file mode 100644 index 000000000..e36ad5cc8 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray8.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray8 extends StaticArray { + public StaticArray8(List values) { + super(8, values); + } + + @SafeVarargs + public StaticArray8(T... values) { + super(8, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray9.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray9.java new file mode 100644 index 000000000..bd297958b --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/StaticArray9.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.StaticArray; +import org.fisco.bcos.sdk.abi.datatypes.Type; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class StaticArray9 extends StaticArray { + public StaticArray9(List values) { + super(9, values); + } + + @SafeVarargs + public StaticArray9(T... values) { + super(9, values); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint104.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint104.java new file mode 100644 index 000000000..346bd2535 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint104.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint104 extends Uint { + public static final Uint104 DEFAULT = new Uint104(BigInteger.ZERO); + + public Uint104(BigInteger value) { + super(104, value); + } + + public Uint104(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint112.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint112.java new file mode 100644 index 000000000..1b2516e7f --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint112.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint112 extends Uint { + public static final Uint112 DEFAULT = new Uint112(BigInteger.ZERO); + + public Uint112(BigInteger value) { + super(112, value); + } + + public Uint112(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint120.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint120.java new file mode 100644 index 000000000..0eaebfc9a --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint120.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint120 extends Uint { + public static final Uint120 DEFAULT = new Uint120(BigInteger.ZERO); + + public Uint120(BigInteger value) { + super(120, value); + } + + public Uint120(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint128.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint128.java new file mode 100644 index 000000000..0c57ba77d --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint128.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint128 extends Uint { + public static final Uint128 DEFAULT = new Uint128(BigInteger.ZERO); + + public Uint128(BigInteger value) { + super(128, value); + } + + public Uint128(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint136.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint136.java new file mode 100644 index 000000000..d713bfb12 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint136.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint136 extends Uint { + public static final Uint136 DEFAULT = new Uint136(BigInteger.ZERO); + + public Uint136(BigInteger value) { + super(136, value); + } + + public Uint136(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint144.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint144.java new file mode 100644 index 000000000..aef591023 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint144.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint144 extends Uint { + public static final Uint144 DEFAULT = new Uint144(BigInteger.ZERO); + + public Uint144(BigInteger value) { + super(144, value); + } + + public Uint144(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint152.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint152.java new file mode 100644 index 000000000..3d0d1226c --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint152.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint152 extends Uint { + public static final Uint152 DEFAULT = new Uint152(BigInteger.ZERO); + + public Uint152(BigInteger value) { + super(152, value); + } + + public Uint152(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint16.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint16.java new file mode 100644 index 000000000..5addb5687 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint16.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint16 extends Uint { + public static final Uint16 DEFAULT = new Uint16(BigInteger.ZERO); + + public Uint16(BigInteger value) { + super(16, value); + } + + public Uint16(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint160.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint160.java new file mode 100644 index 000000000..2a6fff516 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint160.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint160 extends Uint { + public static final Uint160 DEFAULT = new Uint160(BigInteger.ZERO); + + public Uint160(BigInteger value) { + super(160, value); + } + + public Uint160(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint168.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint168.java new file mode 100644 index 000000000..f929b00f7 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint168.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint168 extends Uint { + public static final Uint168 DEFAULT = new Uint168(BigInteger.ZERO); + + public Uint168(BigInteger value) { + super(168, value); + } + + public Uint168(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint176.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint176.java new file mode 100644 index 000000000..1bf2c031c --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint176.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint176 extends Uint { + public static final Uint176 DEFAULT = new Uint176(BigInteger.ZERO); + + public Uint176(BigInteger value) { + super(176, value); + } + + public Uint176(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint184.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint184.java new file mode 100644 index 000000000..c8316e336 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint184.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint184 extends Uint { + public static final Uint184 DEFAULT = new Uint184(BigInteger.ZERO); + + public Uint184(BigInteger value) { + super(184, value); + } + + public Uint184(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint192.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint192.java new file mode 100644 index 000000000..81e5216ed --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint192.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint192 extends Uint { + public static final Uint192 DEFAULT = new Uint192(BigInteger.ZERO); + + public Uint192(BigInteger value) { + super(192, value); + } + + public Uint192(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint200.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint200.java new file mode 100644 index 000000000..b14a21e92 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint200.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint200 extends Uint { + public static final Uint200 DEFAULT = new Uint200(BigInteger.ZERO); + + public Uint200(BigInteger value) { + super(200, value); + } + + public Uint200(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint208.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint208.java new file mode 100644 index 000000000..d558bfbd1 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint208.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint208 extends Uint { + public static final Uint208 DEFAULT = new Uint208(BigInteger.ZERO); + + public Uint208(BigInteger value) { + super(208, value); + } + + public Uint208(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint216.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint216.java new file mode 100644 index 000000000..e947abc3b --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint216.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint216 extends Uint { + public static final Uint216 DEFAULT = new Uint216(BigInteger.ZERO); + + public Uint216(BigInteger value) { + super(216, value); + } + + public Uint216(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint224.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint224.java new file mode 100644 index 000000000..17a0b2086 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint224.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint224 extends Uint { + public static final Uint224 DEFAULT = new Uint224(BigInteger.ZERO); + + public Uint224(BigInteger value) { + super(224, value); + } + + public Uint224(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint232.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint232.java new file mode 100644 index 000000000..4940a511e --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint232.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint232 extends Uint { + public static final Uint232 DEFAULT = new Uint232(BigInteger.ZERO); + + public Uint232(BigInteger value) { + super(232, value); + } + + public Uint232(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint24.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint24.java new file mode 100644 index 000000000..ad31fe02b --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint24.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint24 extends Uint { + public static final Uint24 DEFAULT = new Uint24(BigInteger.ZERO); + + public Uint24(BigInteger value) { + super(24, value); + } + + public Uint24(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint240.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint240.java new file mode 100644 index 000000000..494a16e79 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint240.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint240 extends Uint { + public static final Uint240 DEFAULT = new Uint240(BigInteger.ZERO); + + public Uint240(BigInteger value) { + super(240, value); + } + + public Uint240(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint248.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint248.java new file mode 100644 index 000000000..65736b5a9 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint248.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint248 extends Uint { + public static final Uint248 DEFAULT = new Uint248(BigInteger.ZERO); + + public Uint248(BigInteger value) { + super(248, value); + } + + public Uint248(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint256.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint256.java new file mode 100644 index 000000000..cfc78549a --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint256.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint256 extends Uint { + public static final Uint256 DEFAULT = new Uint256(BigInteger.ZERO); + + public Uint256(BigInteger value) { + super(256, value); + } + + public Uint256(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint32.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint32.java new file mode 100644 index 000000000..12aa9af7f --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint32.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint32 extends Uint { + public static final Uint32 DEFAULT = new Uint32(BigInteger.ZERO); + + public Uint32(BigInteger value) { + super(32, value); + } + + public Uint32(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint40.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint40.java new file mode 100644 index 000000000..03aa46eb9 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint40.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint40 extends Uint { + public static final Uint40 DEFAULT = new Uint40(BigInteger.ZERO); + + public Uint40(BigInteger value) { + super(40, value); + } + + public Uint40(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint48.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint48.java new file mode 100644 index 000000000..25fddad29 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint48.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint48 extends Uint { + public static final Uint48 DEFAULT = new Uint48(BigInteger.ZERO); + + public Uint48(BigInteger value) { + super(48, value); + } + + public Uint48(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint56.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint56.java new file mode 100644 index 000000000..d0bf94023 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint56.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint56 extends Uint { + public static final Uint56 DEFAULT = new Uint56(BigInteger.ZERO); + + public Uint56(BigInteger value) { + super(56, value); + } + + public Uint56(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint64.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint64.java new file mode 100644 index 000000000..2cc9e4fdf --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint64.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint64 extends Uint { + public static final Uint64 DEFAULT = new Uint64(BigInteger.ZERO); + + public Uint64(BigInteger value) { + super(64, value); + } + + public Uint64(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint72.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint72.java new file mode 100644 index 000000000..1f2ff459e --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint72.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint72 extends Uint { + public static final Uint72 DEFAULT = new Uint72(BigInteger.ZERO); + + public Uint72(BigInteger value) { + super(72, value); + } + + public Uint72(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint8.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint8.java new file mode 100644 index 000000000..8b945e0e6 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint8.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint8 extends Uint { + public static final Uint8 DEFAULT = new Uint8(BigInteger.ZERO); + + public Uint8(BigInteger value) { + super(8, value); + } + + public Uint8(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint80.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint80.java new file mode 100644 index 000000000..66a7e78f4 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint80.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint80 extends Uint { + public static final Uint80 DEFAULT = new Uint80(BigInteger.ZERO); + + public Uint80(BigInteger value) { + super(80, value); + } + + public Uint80(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint88.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint88.java new file mode 100644 index 000000000..f8b24ac32 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint88.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint88 extends Uint { + public static final Uint88 DEFAULT = new Uint88(BigInteger.ZERO); + + public Uint88(BigInteger value) { + super(88, value); + } + + public Uint88(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint96.java b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint96.java new file mode 100644 index 000000000..4eaf7d9c6 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/datatypes/generated/Uint96.java @@ -0,0 +1,24 @@ +package org.fisco.bcos.sdk.abi.datatypes.generated; + +import java.math.BigInteger; +import org.fisco.bcos.sdk.abi.datatypes.Uint; + +/** + * Auto generated code. + * + *

Do not modifiy! + * + *

Please use AbiTypesGenerator in the codegen module to update. + */ +public class Uint96 extends Uint { + public static final Uint96 DEFAULT = new Uint96(BigInteger.ZERO); + + public Uint96(BigInteger value) { + super(96, value); + } + + public Uint96(long value) { + this(BigInteger.valueOf(value)); + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABICodecJsonWrapper.java b/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABICodecJsonWrapper.java new file mode 100644 index 000000000..46fd94092 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABICodecJsonWrapper.java @@ -0,0 +1,497 @@ +package org.fisco.bcos.sdk.abi.wrapper; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import java.io.IOException; +import java.security.InvalidParameterException; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Iterator; +import java.util.List; +import org.fisco.bcos.sdk.abi.datatypes.Address; +import org.fisco.bcos.sdk.abi.datatypes.Bool; +import org.fisco.bcos.sdk.abi.datatypes.Bytes; +import org.fisco.bcos.sdk.abi.datatypes.DynamicBytes; +import org.fisco.bcos.sdk.abi.datatypes.Utf8String; +import org.fisco.bcos.sdk.abi.datatypes.generated.Int256; +import org.fisco.bcos.sdk.abi.datatypes.generated.Uint256; +import org.fisco.bcos.sdk.abi.wrapper.ABIObject.ListType; +import org.fisco.bcos.sdk.utils.Numeric; +import org.fisco.bcos.sdk.utils.ObjectMapperFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ABICodecJsonWrapper { + + private static final Logger logger = LoggerFactory.getLogger(ABICodecJsonWrapper.class); + + private ObjectMapper objectMapper = ObjectMapperFactory.getObjectMapper(); + + private void errorReport(String path, String expected, String actual) + throws InvalidParameterException { + String errorMessage = + "Arguments mismatch: " + path + ", expected: " + expected + ", actual: " + actual; + logger.error(errorMessage); + throw new InvalidParameterException(errorMessage); + } + + private ABIObject encodeNode(String path, ABIObject template, JsonNode node) { + ABIObject abiObject = template.newObject(); + + switch (abiObject.getType()) { + case VALUE: + { + if (!node.isValueNode()) { + errorReport( + path, + abiObject.getType().toString(), + node.getNodeType().toString()); + } + + switch (template.getValueType()) { + case BOOL: + { + if (!node.isBoolean()) { + errorReport( + path, + template.getValueType().toString(), + node.getNodeType().toString()); + } + + abiObject.setBoolValue(new Bool(node.asBoolean())); + break; + } + case INT: + { + if (!node.isNumber() && !node.isBigInteger()) { + errorReport( + path, + template.getValueType().toString(), + node.getNodeType().toString()); + } + + if (node.isNumber()) { + abiObject.setNumericValue(new Int256(node.asLong())); + } else { + abiObject.setNumericValue(new Int256(node.bigIntegerValue())); + } + + break; + } + case UINT: + { + if (!node.isNumber() && !node.isBigInteger()) { + errorReport( + path, + template.getValueType().toString(), + node.getNodeType().toString()); + } + + if (node.isNumber()) { + abiObject.setNumericValue(new Uint256(node.asLong())); + } else { + abiObject.setNumericValue(new Uint256(node.bigIntegerValue())); + } + + break; + } + case ADDRESS: + { + if (!node.isTextual()) { + errorReport( + path, + template.getValueType().toString(), + node.getNodeType().toString()); + } + + try { + abiObject.setAddressValue(new Address(node.asText())); + } catch (Exception e) { + errorReport( + "Invalid address value", + template.getValueType().toString(), + node.asText()); + } + break; + } + case BYTES: + { + if (!node.isTextual()) { + errorReport( + path, + template.getValueType().toString(), + node.getNodeType().toString()); + } + + // Binary data requires base64 encoding + byte[] bytesValue = Base64.getDecoder().decode(node.asText()); + abiObject.setBytesValue(new Bytes(bytesValue.length, bytesValue)); + break; + } + case DBYTES: + { + if (!node.isTextual()) { + errorReport( + path, + template.getValueType().toString(), + node.getNodeType().toString()); + } + + byte[] bytesValue = Base64.getDecoder().decode(node.asText()); + abiObject.setDynamicBytesValue(new DynamicBytes(bytesValue)); + break; + } + case STRING: + { + if (!node.isTextual()) { + errorReport( + path, + template.getValueType().toString(), + node.getNodeType().toString()); + } + + abiObject.setStringValue(new Utf8String(node.asText())); + break; + } + } + break; + } + case LIST: + { + if (!node.isArray()) { + errorReport( + path, + abiObject.getType().toString(), + node.getNodeType().toString()); + } + + if ((abiObject.getListType() == ListType.FIXED) + && (node.size() != abiObject.getListLength())) { + errorReport( + "fixed list arguments size", + String.valueOf(abiObject.getListLength()), + String.valueOf(node.size())); + } + + int i = 0; + Iterator iterator = node.iterator(); + while (iterator.hasNext()) { + abiObject + .getListValues() + .add( + encodeNode( + path + ".<" + String.valueOf(i) + ">", + abiObject.getListValueType(), + iterator.next())); + } + + break; + } + case STRUCT: + { + if (!node.isArray() && !node.isObject()) { + errorReport( + path, + abiObject.getType().toString(), + node.getNodeType().toString()); + } + + if (node.size() != abiObject.getStructFields().size()) { + errorReport( + "struct arguments size", + String.valueOf(abiObject.getListLength()), + String.valueOf(node.size())); + } + + if (node.isArray()) { + for (int i = 0; i < abiObject.getStructFields().size(); i++) { + ABIObject field = abiObject.getStructFields().get(i); + abiObject + .getStructFields() + .set( + i, + encodeNode( + path + "." + field.getName(), + field, + node.get(i))); + } + } else { + for (int i = 0; i < abiObject.getStructFields().size(); ++i) { + ABIObject field = abiObject.getStructFields().get(i); + JsonNode structNode = node.get(field.getName()); + + if (structNode == null) { + errorReport( + path + "miss field value, field name: " + field.getName(), + template.getValueType().toString(), + node.getNodeType().toString()); + } + + abiObject + .getStructFields() + .set( + i, + encodeNode( + path + "." + field.getName(), + field, + structNode)); + } + } + + break; + } + } + + return abiObject; + } + + public ABIObject encode(ABIObject template, List inputs) throws IOException { + + ABIObject abiObject = template.newObject(); + + // check parameters match + if (inputs.size() != abiObject.getStructFields().size()) { + errorReport( + "arguments size", + String.valueOf(abiObject.getStructFields().size()), + String.valueOf(inputs.size())); + } + + for (int i = 0; i < abiObject.getStructFields().size(); ++i) { + + ABIObject argObject = abiObject.getStructFields().get(i).newObject(); + String value = inputs.get(i); + + switch (argObject.getType()) { + case VALUE: + { + try { + switch (argObject.getValueType()) { + case BOOL: + { + argObject.setBoolValue(new Bool(Boolean.valueOf(value))); + break; + } + case UINT: + { + argObject.setNumericValue( + new Uint256(Numeric.decodeQuantity(value))); + break; + } + case INT: + { + argObject.setNumericValue( + new Int256(Numeric.decodeQuantity(value))); + break; + } + case ADDRESS: + { + argObject.setAddressValue(new Address(value)); + break; + } + case BYTES: + { + // Binary data requires base64 encoding + byte[] bytesValue = Base64.getDecoder().decode(value); + argObject.setBytesValue( + new Bytes(bytesValue.length, bytesValue)); + break; + } + case DBYTES: + { + // Binary data requires base64 encoding + byte[] bytesValue = Base64.getDecoder().decode(value); + argObject.setDynamicBytesValue( + new DynamicBytes(bytesValue)); + break; + } + case STRING: + { + argObject.setStringValue(new Utf8String(value)); + break; + } + default: + { + throw new UnsupportedOperationException( + "Unrecognized valueType: " + + argObject.getValueType()); + } + } + } catch (Exception e) { + logger.error(" e: ", e); + errorReport("ROOT", argObject.getValueType().toString(), value); + } + + break; + } + case STRUCT: + case LIST: + { + JsonNode argNode = objectMapper.readTree(value.getBytes()); + argObject = encodeNode("ROOT", argObject, argNode); + break; + } + } + + abiObject.getStructFields().set(i, argObject); + } + + return abiObject; + } + + public JsonNode decode(ABIObject abiObject) { + JsonNodeFactory jsonNodeFactory = objectMapper.getNodeFactory(); + + switch (abiObject.getType()) { + case VALUE: + { + switch (abiObject.getValueType()) { + case BOOL: + { + return jsonNodeFactory.booleanNode( + abiObject.getBoolValue().getValue()); + } + case INT: + case UINT: + { + return jsonNodeFactory.numberNode( + abiObject.getNumericValue().getValue()); + } + case ADDRESS: + { + return jsonNodeFactory.textNode( + abiObject.getAddressValue().toString()); + } + case BYTES: + { + return jsonNodeFactory.binaryNode( + abiObject.getBytesValue().getValue()); + } + case DBYTES: + { + return jsonNodeFactory.binaryNode( + abiObject.getDynamicBytesValue().getValue()); + } + case STRING: + { + return jsonNodeFactory.textNode( + abiObject.getStringValue().getValue()); + } + } + break; + } + case LIST: + { + ArrayNode arrayNode = jsonNodeFactory.arrayNode(); + + for (ABIObject listObject : abiObject.getListValues()) { + arrayNode.add(decode(listObject)); + } + + return arrayNode; + } + case STRUCT: + { + ArrayNode structNode = jsonNodeFactory.arrayNode(); + + for (ABIObject listObject : abiObject.getStructFields()) { + structNode.add(decode(listObject)); + } + + return structNode; + } + } + + return null; + } + + public List decode(ABIObject template, String buffer) { + + if (logger.isTraceEnabled()) { + logger.trace(" ABIObject: {}, abi: {}", template.toString(), buffer); + } + + buffer = Numeric.cleanHexPrefix(buffer); + + ABIObject abiObject = template.decode(buffer); + + JsonNode jsonNode = decode(abiObject); + + List result = new ArrayList(); + for (int i = 0; i < abiObject.getStructFields().size(); ++i) { + ABIObject argObject = abiObject.getStructFields().get(i); + JsonNode argNode = jsonNode.get(i); + + switch (argObject.getType()) { + case VALUE: + { + switch (argObject.getValueType()) { + case BOOL: + { + result.add(String.valueOf(argObject.getBoolValue().getValue())); + break; + } + case UINT: + case INT: + { + result.add(argObject.getNumericValue().getValue().toString()); + break; + } + case ADDRESS: + { + result.add( + String.valueOf(argObject.getAddressValue().toString())); + break; + } + case BYTES: + { + byte[] base64Bytes = + Base64.getEncoder() + .encode(argObject.getBytesValue().getValue()); + result.add(new String(base64Bytes)); + break; + } + case DBYTES: + { + byte[] base64Bytes = + Base64.getEncoder() + .encode( + argObject + .getDynamicBytesValue() + .getValue()); + result.add(new String(base64Bytes)); + break; + } + case STRING: + { + result.add( + String.valueOf(argObject.getStringValue().getValue())); + break; + } + default: + { + throw new UnsupportedOperationException( + " Unsupported valueType: " + argObject.getValueType()); + } + } + break; + } + case LIST: + case STRUCT: + { + result.add(argNode.toPrettyString()); + break; + } + default: + { + throw new UnsupportedOperationException( + " Unsupported objectType: " + argObject.getType()); + } + } + } + + return result; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABIDefinition.java b/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABIDefinition.java new file mode 100644 index 000000000..d4df7e3ce --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABIDefinition.java @@ -0,0 +1,436 @@ +package org.fisco.bcos.sdk.abi.wrapper; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import org.fisco.bcos.sdk.abi.FunctionEncoder; +import org.fisco.bcos.sdk.crypto.CryptoInterface; + +/** + * ABIDefinition wrapper + * + *

Link https://solidity.readthedocs.io/en/develop/abi-spec.html#json
+ * type: "function", "constructor", "receive" (the "receive Ether" function) or "fallback" (the + * "default" function);
+ * name: the name of the function;
+ * inputs: an array of objects, each of which contains:
+ * name: the name of the parameter.
+ * type: the canonical type of the parameter (more below).
+ * components: used for tuple types (more below).
+ * outputs: an array of objects similar to inputs.
+ * stateMutability: a string with one of the following values: pure (specified to not read + * blockchain state), view (specified to not modify the blockchain state), nonpayable (function does + * not accept Ether - the default) and payable (function accepts Ether).
+ */ +public class ABIDefinition { + private String name; + private String type; + private boolean constant; + private boolean payable; + private boolean anonymous; + private String stateMutability; + + private List inputs; + private List outputs; + + public ABIDefinition() {} + + public ABIDefinition( + String name, + String type, + boolean constant, + boolean payable, + boolean anonymous, + String stateMutability) { + this.name = name; + this.type = type; + this.constant = constant; + this.payable = payable; + this.anonymous = anonymous; + this.stateMutability = stateMutability; + } + + public ABIDefinition( + boolean constant, + List inputs, + String name, + List outputs, + String type, + boolean payable) { + this(constant, inputs, name, outputs, type, payable, null); + } + + public ABIDefinition( + boolean constant, + List inputs, + String name, + List outputs, + String type, + boolean payable, + String stateMutability) { + this.constant = constant; + this.inputs = inputs; + this.name = name; + this.outputs = outputs; + this.type = type; + this.payable = payable; + this.stateMutability = stateMutability; + } + + /** + * string method signature + * + * @return + */ + public String getMethodSignatureAsString() { + StringBuilder result = new StringBuilder(); + result.append(name); + result.append("("); + String params = + getInputs() + .stream() + .map(abi -> abi.getTypeAsString()) + .collect(Collectors.joining(",")); + result.append(params); + result.append(")"); + return result.toString(); + } + + /** + * method id + * + * @return + */ + public String getMethodId(CryptoInterface cryptoInterface) { + FunctionEncoder encoder = new FunctionEncoder(cryptoInterface); + return encoder.buildMethodId(getMethodSignatureAsString()); + } + + public boolean isConstant() { + return constant; + } + + public void setConstant(boolean constant) { + this.constant = constant; + } + + public List getInputs() { + return inputs; + } + + public void setInputs(List inputs) { + this.inputs = inputs; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getOutputs() { + return outputs; + } + + public boolean hasOutputs() { + return !outputs.isEmpty(); + } + + public void setOutputs(List outputs) { + this.outputs = outputs; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public boolean isPayable() { + return payable; + } + + public void setPayable(boolean payable) { + this.payable = payable; + } + + public String getStateMutability() { + return stateMutability; + } + + public void setStateMutability(String stateMutability) { + this.stateMutability = stateMutability; + } + + public boolean isAnonymous() { + return anonymous; + } + + public void setAnonymous(boolean anonymous) { + this.anonymous = anonymous; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof ABIDefinition)) { + return false; + } + + ABIDefinition that = (ABIDefinition) o; + + if (isConstant() != that.isConstant()) { + return false; + } + if (isPayable() != that.isPayable()) { + return false; + } + if (getInputs() != null + ? !getInputs().equals(that.getInputs()) + : that.getInputs() != null) { + return false; + } + if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) { + return false; + } + if (getOutputs() != null + ? !getOutputs().equals(that.getOutputs()) + : that.getOutputs() != null) { + return false; + } + if (getStateMutability() != null + ? !getStateMutability().equals(that.getStateMutability()) + : that.getStateMutability() != null) { + return false; + } + return getType() != null ? getType().equals(that.getType()) : that.getType() == null; + } + + @Override + public int hashCode() { + int result = (isConstant() ? 1 : 0); + result = 31 * result + (getInputs() != null ? getInputs().hashCode() : 0); + result = 31 * result + (getName() != null ? getName().hashCode() : 0); + result = 31 * result + (getOutputs() != null ? getOutputs().hashCode() : 0); + result = 31 * result + (getType() != null ? getType().hashCode() : 0); + result = 31 * result + (isPayable() ? 1 : 0); + result = 31 * result + (getStateMutability() != null ? getStateMutability().hashCode() : 0); + return result; + } + + public static class Type { + public String type; + public String rawType; + public List dimensions = new ArrayList(); + + public Type(String name) { + int index = name.indexOf('['); + this.rawType = (-1 == index) ? name.trim() : name.substring(0, index); + this.type = name; + this.initialize(); + } + + private void initialize() { + Pattern p = Pattern.compile("\\[[0-9]{0,}\\]"); + Matcher m = p.matcher(type); + while (m.find()) { + String s = m.group(); + String dig = s.substring(s.indexOf('[') + 1, s.indexOf(']')).trim(); + if (dig.isEmpty()) { + dimensions.add(0); + } else { + dimensions.add(Integer.valueOf(dig)); + } + } + } + + @Override + public String toString() { + return "Type{" + + "name='" + + type + + '\'' + + ", baseName='" + + rawType + + '\'' + + ", dimensions=" + + dimensions + + '}'; + } + + public String getType() { + return type; + } + + public String getRawType() { + return rawType; + } + + public Type reduceDimensionAndGetType() { + if (isList()) { + String r = rawType; + for (int i = 0; i < dimensions.size() - 1; i++) { + r += ("[" + (dimensions.get(i) != 0 ? dimensions.get(i) : "") + "]"); + } + + return new Type(r); + } + + return new Type(rawType); + } + + public boolean isList() { + return !dimensions.isEmpty(); + } + + public boolean isDynamicList() { + return isList() && (dimensions.get(dimensions.size() - 1) == 0); + } + + public boolean isFixedList() { + return isList() && (dimensions.get(dimensions.size() - 1) != 0); + } + + public void setType(String type) { + this.type = type; + } + + public void setRawType(String rawType) { + this.rawType = rawType; + } + + public List getDimensions() { + return dimensions; + } + + public Integer getLastDimension() { + if (!isList()) { + return 0; + } + + return dimensions.get(dimensions.size() - 1); + } + + public void setDimensions(List dimensions) { + this.dimensions = dimensions; + } + } + + public static class NamedType { + private String name; + private String type; + private boolean indexed; + private List components; + + public NamedType() {} + + public NamedType(String name, String type) { + this(name, type, false); + } + + public NamedType(String name, String type, boolean indexed) { + this.name = name; + this.type = type; + this.indexed = indexed; + } + + public Type newType() { + return new Type(type); + } + + private String getTupleRawTypeAsString() { + StringBuilder result = new StringBuilder(); + String params = + getComponents() + .stream() + .map(abi -> abi.getTypeAsString()) + .collect(Collectors.joining(",")); + result.append(params); + return result.toString(); + } + + public String getTypeAsString() { + // not tuple, return + if (!type.startsWith("tuple")) { + return type; + } + + String tupleRawString = getTupleRawTypeAsString(); + String result = type.replaceAll("tuple", "(" + tupleRawString + ")"); + return result; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public boolean isIndexed() { + return indexed; + } + + public void setIndexed(boolean indexed) { + this.indexed = indexed; + } + + public List getComponents() { + return components; + } + + public void setComponents(List components) { + this.components = components; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + NamedType namedType = (NamedType) o; + return indexed == namedType.indexed + && Objects.equals(name, namedType.name) + && Objects.equals(type, namedType.type) + && Objects.equals(components, namedType.components); + } + + @Override + public int hashCode() { + return Objects.hash(name, type, indexed, components); + } + + @Override + public String toString() { + return "NamedType{" + + "name='" + + name + + '\'' + + ", type='" + + type + + '\'' + + ", indexed=" + + indexed + + ", components=" + + components + + '}'; + } + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABIDefinitionFactory.java b/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABIDefinitionFactory.java new file mode 100644 index 000000000..111777f8e --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABIDefinitionFactory.java @@ -0,0 +1,56 @@ +package org.fisco.bcos.sdk.abi.wrapper; + +import org.fisco.bcos.sdk.crypto.CryptoInterface; +import org.fisco.bcos.sdk.utils.ObjectMapperFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ABIDefinitionFactory { + + private static final Logger logger = LoggerFactory.getLogger(ABIDefinitionFactory.class); + + private CryptoInterface cryptoInterface; + + public ABIDefinitionFactory(CryptoInterface cryptoInterface) { + this.cryptoInterface = cryptoInterface; + } + + /** + * load ABI and construct ContractABIDefinition. + * + * @param abi + * @return + */ + public ContractABIDefinition loadABI(String abi) { + try { + ABIDefinition[] abiDefinitions = + ObjectMapperFactory.getObjectMapper().readValue(abi, ABIDefinition[].class); + + ContractABIDefinition contractABIDefinition = + new ContractABIDefinition(cryptoInterface); + for (ABIDefinition abiDefinition : abiDefinitions) { + if (abiDefinition.getType().equals("constructor")) { + contractABIDefinition.setConstructor(abiDefinition); + } else if (abiDefinition.getType().equals("function")) { + contractABIDefinition.addFunction(abiDefinition.getName(), abiDefinition); + } else if (abiDefinition.getType().equals("event")) { + contractABIDefinition.addEvent(abiDefinition.getName(), abiDefinition); + } else { + // skip and do nothing + } + + if (logger.isInfoEnabled()) { + logger.info(" abiDefinition: {}", abiDefinition); + } + } + + logger.info(" contractABIDefinition {} ", contractABIDefinition); + + return contractABIDefinition; + + } catch (Exception e) { + logger.error(" e: ", e); + return null; + } + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABIObject.java b/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABIObject.java new file mode 100644 index 000000000..c8e4f33d8 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABIObject.java @@ -0,0 +1,754 @@ +package org.fisco.bcos.sdk.abi.wrapper; + +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import org.fisco.bcos.sdk.abi.TypeDecoder; +import org.fisco.bcos.sdk.abi.TypeEncoder; +import org.fisco.bcos.sdk.abi.datatypes.Address; +import org.fisco.bcos.sdk.abi.datatypes.Bool; +import org.fisco.bcos.sdk.abi.datatypes.Bytes; +import org.fisco.bcos.sdk.abi.datatypes.DynamicBytes; +import org.fisco.bcos.sdk.abi.datatypes.NumericType; +import org.fisco.bcos.sdk.abi.datatypes.Type; +import org.fisco.bcos.sdk.abi.datatypes.Utf8String; +import org.fisco.bcos.sdk.abi.datatypes.generated.Bytes32; +import org.fisco.bcos.sdk.abi.datatypes.generated.Int256; +import org.fisco.bcos.sdk.abi.datatypes.generated.Uint256; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ABIObject { + + private static final Logger logger = LoggerFactory.getLogger(ABIObject.class); + + public enum ObjectType { + VALUE, // uint, int, bool, address, bytes, bytes, string + STRUCT, // tuple + LIST // T[], T[M] + } + + public enum ValueType { + BOOL, // bool + UINT, // uint + INT, // int + BYTES, // byteN + ADDRESS, // address + STRING, // string + DBYTES, // bytes + FIXED, // fixedx + UFIXED, // ufixedx + } + + public enum ListType { + DYNAMIC, // T[] + FIXED, // T[M] + } + + private String name; // field name + + private ObjectType type; // for value + private ValueType valueType; + + private NumericType numericValue; + private Bytes bytesValue; + private Address addressValue; + private Bool boolValue; + private DynamicBytes dynamicBytesValue; + private Utf8String stringValue; + + private ListType listType; + private List listValues; // for list + private int listLength; // for list + private ABIObject listValueType; // for list + + private List structFields; // for struct + + public ABIObject(ObjectType type) { + this.type = type; + + switch (type) { + case VALUE: + { + break; + } + case STRUCT: + { + structFields = new LinkedList(); + break; + } + case LIST: + { + listValues = new LinkedList(); + break; + } + } + } + + public ABIObject(ValueType valueType) { + this.type = ObjectType.VALUE; + this.valueType = valueType; + } + + public ABIObject(ListType listType) { + this.type = ObjectType.LIST; + this.listType = listType; + this.listValues = new LinkedList(); + } + + public ABIObject(Uint256 uintValue) { + this(ValueType.UINT); + this.numericValue = uintValue; + } + + public ABIObject(Int256 intValue) { + this(ValueType.INT); + this.numericValue = intValue; + } + + public ABIObject(Address addressValue) { + this(ValueType.ADDRESS); + this.addressValue = addressValue; + } + + public ABIObject(Bool boolValue) { + this(ValueType.BOOL); + this.boolValue = boolValue; + } + + public ABIObject(Utf8String stringValue) { + this(ValueType.STRING); + this.stringValue = stringValue; + } + + public ABIObject(DynamicBytes dynamicBytesValue) { + this(ValueType.DBYTES); + this.dynamicBytesValue = dynamicBytesValue; + } + + public ABIObject(Bytes bytesValue) { + this(ValueType.BYTES); + this.bytesValue = bytesValue; + } + + public ABIObject newObjectWithoutValue() { + ABIObject abiObject = new ABIObject(this.type); + // value + abiObject.setValueType(this.getValueType()); + abiObject.setName(this.getName()); + + // list + abiObject.setListType(this.getListType()); + abiObject.setListLength(this.getListLength()); + + if (this.getListValueType() != null) { + abiObject.setListValueType(this.getListValueType().newObjectWithoutValue()); + } + + if (this.listValues != null) { + for (ABIObject obj : this.listValues) { + abiObject.listValues.add(obj.newObjectWithoutValue()); + } + } + + // tuple + if (this.structFields != null) { + for (ABIObject obj : this.structFields) { + abiObject.structFields.add(obj.newObjectWithoutValue()); + } + } + + return abiObject; + } + + // clone itself + public ABIObject newObject() { + + ABIObject abiObject = new ABIObject(this.type); + + // value + abiObject.setValueType(this.getValueType()); + abiObject.setName(this.getName()); + + if (this.getNumericValue() != null) { + abiObject.setNumericValue( + new NumericType( + this.getNumericValue().getTypeAsString(), + this.getNumericValue().getValue()) { + @Override + public boolean dynamicType() { + return false; + } + + @Override + public int offset() { + return 1; + } + }); + } + + if (this.getBoolValue() != null) { + abiObject.setBoolValue(new Bool(this.getBoolValue().getValue())); + } + + if (this.getStringValue() != null) { + abiObject.setStringValue(new Utf8String(this.getStringValue().getValue())); + } + + if (this.getDynamicBytesValue() != null) { + abiObject.setDynamicBytesValue( + new DynamicBytes(this.getDynamicBytesValue().getValue())); + } + + if (this.getAddressValue() != null) { + abiObject.setAddressValue(new Address(this.getAddressValue().toUint160())); + } + + if (this.getBytesValue() != null) { + abiObject.setBytesValue( + new Bytes( + this.getBytesValue().getValue().length, + this.getBytesValue().getValue())); + } + + // list + abiObject.setListType(this.getListType()); + abiObject.setListLength(this.getListLength()); + + if (this.getListValueType() != null) { + abiObject.setListValueType(this.getListValueType().newObject()); + } + + if (this.listValues != null) { + for (ABIObject obj : this.listValues) { + abiObject.listValues.add(obj.newObject()); + } + } + + // tuple + if (this.structFields != null) { + for (ABIObject obj : this.structFields) { + abiObject.structFields.add(obj.newObject()); + } + } + + return abiObject; + } + + /** + * Checks to see if the current type is dynamic + * + * @return + */ + public boolean isDynamic() { + switch (type) { + case VALUE: + { + switch (valueType) { + case DBYTES: // bytes + case STRING: // string + return true; + default: + return false; + } + // break; + } + case LIST: + { + switch (listType) { + case FIXED: // T[M] + { + return listValueType.isDynamic(); + } + case DYNAMIC: // T[] + { + return true; + } + } + break; + } + case STRUCT: + { + for (ABIObject abiObject : structFields) { + if (abiObject.isDynamic()) { + return true; + } + } + return false; + } + } + + return false; + } + + /** + * dynamic offset of this object + * + * @return + */ + public int offset() { + if (isDynamic()) { // dynamic + return 1; + } + + int offset = 0; + if (type == ObjectType.VALUE) { // basic type + offset = 1; + } else if (type == ObjectType.STRUCT) { // tuple + int l = 0; + for (ABIObject abiObject : structFields) { + l += abiObject.offset(); + } + offset = l; + } else { // T[M] + int length = listLength; + int basicOffset = listValueType.offset(); + offset = length * basicOffset; + } + + return offset; + } + + public int offsetAsByteLength() { + return offset() * Type.MAX_BYTE_LENGTH; + } + + public int offsetAsHexLength() { + return offset() * (Type.MAX_BYTE_LENGTH << 1); + } + + /** + * encode this object + * + * @return + */ + public String encode() { + + StringBuffer stringBuffer = new StringBuffer(); + switch (type) { + case VALUE: + { + switch (valueType) { + case UINT: + case INT: + { + stringBuffer.append(TypeEncoder.encode(numericValue)); + break; + } + case BOOL: + { + stringBuffer.append(TypeEncoder.encode(boolValue)); + break; + } + case FIXED: + case UFIXED: + { + throw new UnsupportedOperationException( + " Unsupported fixed/unfixed type. "); + // break; + } + case BYTES: + { + stringBuffer.append(TypeEncoder.encode(bytesValue)); + break; + } + case ADDRESS: + { + stringBuffer.append(TypeEncoder.encode(addressValue)); + break; + } + case DBYTES: + { + stringBuffer.append(TypeEncoder.encode(dynamicBytesValue)); + break; + } + case STRING: + { + stringBuffer.append(TypeEncoder.encode(stringValue)); + break; + } + default: + { + throw new UnsupportedOperationException( + " Unrecognized valueType: " + valueType); + } + } + break; + } + case STRUCT: + { + long dynamicOffset = 0; + for (ABIObject abiObject : structFields) { + dynamicOffset += abiObject.offsetAsByteLength(); + } + + StringBuffer fixedBuffer = new StringBuffer(); + StringBuffer dynamicBuffer = new StringBuffer(); + + for (ABIObject abiObject : structFields) { + String encodeValue = abiObject.encode(); + if (abiObject.isDynamic()) { + fixedBuffer.append(TypeEncoder.encode(new Uint256(dynamicOffset))); + dynamicBuffer.append(encodeValue); + dynamicOffset += (encodeValue.length() >> 1); + } else { + fixedBuffer.append(encodeValue); + } + } + + stringBuffer.append(fixedBuffer).append(dynamicBuffer); + break; + } + case LIST: + { + StringBuffer lengthBuffer = new StringBuffer(); + StringBuffer listValueBuffer = new StringBuffer(); + StringBuffer offsetBuffer = new StringBuffer(); + + if (listType == ListType.DYNAMIC) { + lengthBuffer.append(TypeEncoder.encode(new Uint256(listValues.size()))); + } + + int dynamicOffset = listValues.size() * Type.MAX_BYTE_LENGTH; + + for (ABIObject abiObject : listValues) { + String listValueEncode = abiObject.encode(); + listValueBuffer.append(abiObject.encode()); + if (abiObject.isDynamic()) { + offsetBuffer.append(TypeEncoder.encode(new Uint256(dynamicOffset))); + dynamicOffset += (listValueEncode.length() >> 1); + } + } + + stringBuffer.append(lengthBuffer).append(offsetBuffer).append(listValueBuffer); + break; + } + } + + if (logger.isTraceEnabled()) { + logger.trace("ABI: {}", stringBuffer.toString()); + } + + return stringBuffer.toString(); + } + + /** + * decode this object + * + * @return + */ + public ABIObject decode(String input) { + return decode(input, 0); + } + + /** + * decode this object + * + * @return + */ + private ABIObject decode(String input, int offset) { + + ABIObject abiObject = newObject(); + + switch (type) { + case VALUE: + { + switch (valueType) { + case BOOL: + { + abiObject.setBoolValue( + TypeDecoder.decode(input, offset, Bool.class)); + break; + } + case UINT: + { + abiObject.setNumericValue( + TypeDecoder.decode(input, offset, Uint256.class)); + break; + } + case INT: + { + abiObject.setNumericValue( + TypeDecoder.decode(input, offset, Int256.class)); + break; + } + case FIXED: + case UFIXED: + { + throw new UnsupportedOperationException( + " Unsupported fixed/unfixed type. "); + // break; + } + case BYTES: + { + abiObject.setBytesValue( + TypeDecoder.decode(input, offset, Bytes32.class)); + break; + } + case ADDRESS: + { + abiObject.setAddressValue( + TypeDecoder.decode(input, offset, Address.class)); + break; + } + case DBYTES: + { + abiObject.setDynamicBytesValue( + TypeDecoder.decode(input, offset, DynamicBytes.class)); + break; + } + case STRING: + { + abiObject.setStringValue( + TypeDecoder.decode(input, offset, Utf8String.class)); + break; + } + } + break; + } + case STRUCT: + { + int structOffset = offset; + int initialOffset = offset; + + for (int i = 0; i < structFields.size(); ++i) { + ABIObject structObject = abiObject.structFields.get(i); + ABIObject itemObject = null; + if (structObject.isDynamic()) { + int structValueOffset = + TypeDecoder.decode(input, structOffset, Uint256.class) + .getValue() + .intValue(); + itemObject = + structObject.decode( + input, initialOffset + (structValueOffset << 1)); + + } else { + itemObject = structObject.decode(input, structOffset); + } + + abiObject.structFields.set(i, itemObject); + structOffset += structObject.offsetAsHexLength(); + } + break; + } + case LIST: + { + int listOffset = offset; + int initialOffset = offset; + + int listLength = 0; + if (listType == ListType.DYNAMIC) { + // dynamic list length + listLength = + TypeDecoder.decode(input, listOffset, Uint256.class) + .getValue() + .intValue(); + listOffset += (Type.MAX_BYTE_LENGTH << 1); + initialOffset += (Type.MAX_BYTE_LENGTH << 1); + } else { + // fixed list length + listLength = abiObject.getListLength(); + } + + if (logger.isTraceEnabled()) { + logger.trace(" listType: {}, listLength: {}", listType, listLength); + } + + ABIObject listValueObject = abiObject.getListValueType(); + + for (int i = 0; i < listLength; i++) { + ABIObject itemABIObject = null; + + if (listValueObject.isDynamic()) { + int listValueOffset = + TypeDecoder.decode(input, listOffset, Uint256.class) + .getValue() + .intValue(); + itemABIObject = + abiObject + .getListValueType() + .decode(input, initialOffset + (listValueOffset << 1)); + } else { + itemABIObject = abiObject.getListValueType().decode(input, listOffset); + } + + listOffset += listValueObject.offsetAsHexLength(); + + abiObject.getListValues().add(itemABIObject); + } + break; + } + } + + return abiObject; + } + + public ObjectType getType() { + return type; + } + + public void setType(ObjectType type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ValueType getValueType() { + return valueType; + } + + public NumericType getNumericValue() { + return numericValue; + } + + public Bool getBoolValue() { + return boolValue; + } + + public void setBoolValue(Bool boolValue) { + this.type = ObjectType.VALUE; + this.valueType = ValueType.BOOL; + this.boolValue = boolValue; + } + + public void setNumericValue(NumericType numericValue) { + this.type = ObjectType.VALUE; + this.valueType = ValueType.UINT; + this.numericValue = numericValue; + } + + public Bytes getBytesValue() { + return bytesValue; + } + + public void setBytesValue(Bytes bytesValue) { + this.type = ObjectType.VALUE; + this.valueType = ValueType.BYTES; + this.bytesValue = bytesValue; + } + + public Address getAddressValue() { + return addressValue; + } + + public void setAddressValue(Address addressValue) { + this.type = ObjectType.VALUE; + this.valueType = ValueType.ADDRESS; + this.addressValue = addressValue; + } + + public List getStructFields() { + return structFields; + } + + public void setStructFields(List structFields) { + this.type = ObjectType.STRUCT; + this.structFields = structFields; + } + + public ListType getListType() { + return listType; + } + + public void setListType(ListType listType) { + this.listType = listType; + } + + public List getListValues() { + return listValues; + } + + public void setListValues(List listValues) { + this.type = ObjectType.LIST; + this.listValues = listValues; + } + + public void setValueType(ValueType valueType) { + this.valueType = valueType; + } + + public DynamicBytes getDynamicBytesValue() { + return dynamicBytesValue; + } + + public void setDynamicBytesValue(DynamicBytes dynamicBytesValue) { + this.dynamicBytesValue = dynamicBytesValue; + } + + public Utf8String getStringValue() { + return stringValue; + } + + public void setStringValue(Utf8String stringValue) { + this.stringValue = stringValue; + } + + public ABIObject getListValueType() { + return listValueType; + } + + public void setListValueType(ABIObject listValueType) { + this.listValueType = listValueType; + } + + public int getListLength() { + return listLength; + } + + public void setListLength(int listLength) { + this.listLength = listLength; + } + + @Override + public String toString() { + + String str = "ABIObject{" + "name='" + name + '\'' + ", type=" + type; + + if (type == ObjectType.VALUE) { + str += ", valueType=" + valueType; + switch (valueType) { + case BOOL: + str += ", booValueType="; + str += Objects.isNull(boolValue) ? "null" : boolValue.getValue(); + break; + case UINT: + case INT: + str += ", numericValue="; + str += Objects.isNull(numericValue) ? "null" : numericValue.getValue(); + break; + case ADDRESS: + str += ", addressValue="; + str += Objects.isNull(addressValue) ? "null" : addressValue.getValue(); + break; + case BYTES: + str += ", bytesValue="; + str += Objects.isNull(bytesValue) ? "null" : bytesValue.getValue(); + break; + case DBYTES: + str += ", dynamicBytesValue="; + str += + Objects.isNull(dynamicBytesValue) + ? "null" + : dynamicBytesValue.getValue(); + case STRING: + str += ", stringValue="; + str += Objects.isNull(stringValue) ? "null" : stringValue.getValue(); + } + } else if (type == ObjectType.LIST) { + str += ", listType=" + listType; + str += ", listValues=" + listValues + ", listLength=" + listLength; + } else if (type == ObjectType.STRUCT) { + str += ", structFields=" + structFields; + } + + str += '}'; + return str; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABIObjectFactory.java b/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABIObjectFactory.java new file mode 100644 index 000000000..8e2a65772 --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ABIObjectFactory.java @@ -0,0 +1,129 @@ +package org.fisco.bcos.sdk.abi.wrapper; + +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ABIObjectFactory { + + private static final Logger logger = LoggerFactory.getLogger(ABIObjectFactory.class); + + public static ABIObject createInputObject(ABIDefinition abiDefinition) { + return createObject( + abiDefinition.getName(), abiDefinition.getType(), abiDefinition.getInputs()); + } + + public static ABIObject createOutputObject(ABIDefinition abiDefinition) { + return createObject( + abiDefinition.getName(), abiDefinition.getType(), abiDefinition.getOutputs()); + } + + private static ABIObject createObject( + String name, String type, List namedTypes) { + try { + ABIObject abiObject = new ABIObject(ABIObject.ObjectType.STRUCT); + + for (ABIDefinition.NamedType namedType : namedTypes) { + abiObject.getStructFields().add(buildTypeObject(namedType)); + } + + logger.info(" name: {}", name); + + return abiObject; + + } catch (Exception e) { + logger.error("namedTypes: {}, e: ", namedTypes, e); + } + + return null; + } + + /** + * build ABIObject by raw type name + * + * @param rawType + * @return + */ + public static ABIObject buildRawTypeObject(String rawType) { + + ABIObject abiObject = null; + + if (rawType.startsWith("uint")) { + abiObject = new ABIObject(ABIObject.ValueType.UINT); + } else if (rawType.startsWith("int")) { + abiObject = new ABIObject(ABIObject.ValueType.INT); + } else if (rawType.startsWith("bool")) { + abiObject = new ABIObject(ABIObject.ValueType.BOOL); + } else if (rawType.startsWith("string")) { + abiObject = new ABIObject(ABIObject.ValueType.STRING); + } else if (rawType.equals("bytes")) { + abiObject = new ABIObject(ABIObject.ValueType.DBYTES); + } else if (rawType.startsWith("bytes")) { + abiObject = new ABIObject(ABIObject.ValueType.BYTES); + } else if (rawType.startsWith("address")) { + abiObject = new ABIObject(ABIObject.ValueType.ADDRESS); + } else if (rawType.startsWith("fixed") || rawType.startsWith("ufixed")) { + throw new UnsupportedOperationException("Unsupported type:" + rawType); + } else { + throw new UnsupportedOperationException("Unrecognized type:" + rawType); + } + + return abiObject; + } + + private static ABIObject buildTupleObject(ABIDefinition.NamedType namedType) { + return createObject(namedType.getName(), namedType.getType(), namedType.getComponents()); + } + + private static ABIObject buildListObject( + ABIDefinition.Type typeObj, ABIDefinition.NamedType namedType) { + + ABIObject abiObject = null; + if (typeObj.isList()) { + ABIObject listObject = new ABIObject(ABIObject.ObjectType.LIST); + listObject.setListType( + typeObj.isFixedList() ? ABIObject.ListType.FIXED : ABIObject.ListType.DYNAMIC); + if (typeObj.isFixedList()) { + listObject.setListLength(typeObj.getLastDimension()); + } + + listObject.setListValueType( + buildListObject(typeObj.reduceDimensionAndGetType(), namedType)); + abiObject = listObject; + } else if (typeObj.getRawType().startsWith("tuple")) { + abiObject = buildTupleObject(namedType); + } else { + abiObject = buildRawTypeObject(typeObj.getRawType()); + } + + return abiObject; + } + + public static ABIObject buildTypeObject(ABIDefinition.NamedType namedType) { + try { + String type = namedType.getType(); + // String name = namedType.getName(); + // boolean indexed = namedType.isIndexed(); + + ABIDefinition.Type typeObj = new ABIDefinition.Type(type); + String rawType = typeObj.getRawType(); + + ABIObject abiObject = null; + if (typeObj.isList()) { + abiObject = buildListObject(typeObj, namedType); + } else if (rawType.startsWith("tuple")) { + abiObject = buildTupleObject(namedType); + } else { + abiObject = buildRawTypeObject(rawType); + } + + abiObject.setName(namedType.getName()); + + return abiObject; + } catch (Exception e) { + logger.error(" e: ", e); + } + + return null; + } +} diff --git a/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ContractABIDefinition.java b/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ContractABIDefinition.java new file mode 100644 index 000000000..c77a83d3c --- /dev/null +++ b/src/main/java/org/fisco/bcos/sdk/abi/wrapper/ContractABIDefinition.java @@ -0,0 +1,92 @@ +package org.fisco.bcos.sdk.abi.wrapper; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.fisco.bcos.sdk.crypto.CryptoInterface; +import org.fisco.bcos.sdk.utils.Numeric; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ContractABIDefinition { + + private static final Logger logger = LoggerFactory.getLogger(ContractABIDefinition.class); + + private ABIDefinition constructor = null; + private Map> functions = new HashMap<>(); + private Map> events = new HashMap<>(); + // method id => function + private Map methodIDToFunctions = new HashMap<>(); + private CryptoInterface cryptoInterface; + + public ContractABIDefinition(CryptoInterface cryptoInterface) { + this.cryptoInterface = cryptoInterface; + } + + public ABIDefinition getConstructor() { + return constructor; + } + + public void setConstructor(ABIDefinition constructor) { + this.constructor = constructor; + } + + public Map> getFunctions() { + return functions; + } + + public void setFunctions(Map> functions) { + this.functions = functions; + } + + public Map> getEvents() { + return events; + } + + public void setEvents(Map> events) { + this.events = events; + } + + public Map getMethodIDToFunctions() { + return methodIDToFunctions; + } + + public void setMethodIDToFunctions(Map methodIDToFunctions) { + this.methodIDToFunctions = methodIDToFunctions; + } + + public void addFunction(String name, ABIDefinition abiDefinition) { + + List abiDefinitions = functions.get(name); + if (abiDefinitions == null) { + functions.put(name, new ArrayList<>()); + abiDefinitions = functions.get(name); + } else { + logger.info(" overload method ??? name: {}, abiDefinition: {}", name, abiDefinition); + } + abiDefinitions.add(abiDefinition); + + // calculate method id and add abiDefinition to methodIdToFunctions + String methodId = abiDefinition.getMethodId(cryptoInterface); + methodIDToFunctions.put(methodId, abiDefinition); + + logger.info( + " name: {}, methodId: {}, methodSignature: {}, abi: {}", + name, + methodId, + abiDefinition.getMethodSignatureAsString(), + abiDefinition); + } + + public void addEvent(String name, ABIDefinition abiDefinition) { + events.putIfAbsent(name, new ArrayList<>()); + List abiDefinitions = events.get(name); + abiDefinitions.add(abiDefinition); + logger.info(" name: {}, abi: {}", name, abiDefinition); + } + + public ABIDefinition getABIDefinitionByMethodId(String methodId) { + return methodIDToFunctions.get(Numeric.prependHexPrefix(methodId)); + } +}