@Test public void testFunctionMDynamicArrayEncode1() { Function function = new Function( "sam", Arrays.asList( new DynamicBytes("dave".getBytes()), new Bool(true), new DynamicArray<>( new Uint(BigInteger.ONE), new Uint(BigInteger.valueOf(2)), new Uint(BigInteger.valueOf(3)))), Collections.<TypeReference<?>>emptyList() ); assertThat(FunctionEncoder.encode(function), is("0xa5643bf2" + "0000000000000000000000000000000000000000000000000000000000000060" + "0000000000000000000000000000000000000000000000000000000000000001" + "00000000000000000000000000000000000000000000000000000000000000a0" + "0000000000000000000000000000000000000000000000000000000000000004" + "6461766500000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000003" + "0000000000000000000000000000000000000000000000000000000000000001" + "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000003")); }
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);  }