@Test public void testFunctionMDynamicArrayEncode2() { Function function = new Function( "f", Arrays.asList( new Uint(BigInteger.valueOf(0x123)), new DynamicArray<>( new Uint32(BigInteger.valueOf(0x456)), new Uint32(BigInteger.valueOf(0x789)) ), new Bytes10("1234567890".getBytes()), new DynamicBytes("Hello, world!".getBytes())), Collections.<TypeReference<?>>emptyList() ); assertThat(FunctionEncoder.encode(function), is("0x8be65246" + "0000000000000000000000000000000000000000000000000000000000000123" + "0000000000000000000000000000000000000000000000000000000000000080" + "3132333435363738393000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000e0" + "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000456" + "0000000000000000000000000000000000000000000000000000000000000789" + "000000000000000000000000000000000000000000000000000000000000000d" + "48656c6c6f2c20776f726c642100000000000000000000000000000000000000" )); }
public static String encode(Function function) { List<Type> parameters = function.getInputParameters(); String methodSignature = buildMethodSignature(function.getName(), parameters); String methodId = buildMethodId(methodSignature); StringBuilder result = new StringBuilder(); result.append(methodId); return encodeParameters(parameters, result); }
FunctionEncoder { public static String encode(Function function) { List<Type> parameters = function.getInputParameters(); String methodSignature = buildMethodSignature(function.getName(), parameters); String methodId = buildMethodId(methodSignature); StringBuilder result = new StringBuilder(); result.append(methodId); return encodeParameters(parameters, result); } }
FunctionEncoder { public static String encode(Function function) { List<Type> parameters = function.getInputParameters(); String methodSignature = buildMethodSignature(function.getName(), parameters); String methodId = buildMethodId(methodSignature); StringBuilder result = new StringBuilder(); result.append(methodId); return encodeParameters(parameters, result); } private  FunctionEncoder(); }
FunctionEncoder { public static String encode(Function function) { List<Type> parameters = function.getInputParameters(); String methodSignature = buildMethodSignature(function.getName(), parameters); String methodId = buildMethodId(methodSignature); StringBuilder result = new StringBuilder(); result.append(methodId); return encodeParameters(parameters, result); } private  FunctionEncoder(); static String encode(Function function); static String encodeConstructor(List<Type> parameters); static String buildMethodId(String methodSignature); }
FunctionEncoder { public static String encode(Function function) { List<Type> parameters = function.getInputParameters(); String methodSignature = buildMethodSignature(function.getName(), parameters); String methodId = buildMethodId(methodSignature); StringBuilder result = new StringBuilder(); result.append(methodId); return encodeParameters(parameters, result); } private  FunctionEncoder(); static String encode(Function function); static String encodeConstructor(List<Type> parameters); static String buildMethodId(String methodSignature);  }