public ContractABI ExtractContractABI(params Type[] contractMessagesTypes) { var contractABI = new ContractABI(); var functions = new List <FunctionABI>(); var events = new List <EventABI>(); var errors = new List <ErrorABI>(); foreach (var contractMessageType in contractMessagesTypes) { if (FunctionAttribute.IsFunctionType(contractMessageType)) { functions.Add(ExtractFunctionABI(contractMessageType)); } if (EventAttribute.IsEventType(contractMessageType)) { events.Add(ExtractEventABI(contractMessageType)); } if (ErrorAttribute.IsErrorType(contractMessageType)) { errors.Add(ExtractErrorABI(contractMessageType)); } } contractABI.Functions = functions.ToArray(); contractABI.Events = events.ToArray(); contractABI.Errors = errors.ToArray(); return(contractABI); }
public FunctionABI ExtractFunctionABI(Type contractMessageType) { if (FunctionAttribute.IsFunctionType(contractMessageType)) { var functionAttribute = FunctionAttribute.GetAttribute(contractMessageType); var functionABI = new FunctionABI(functionAttribute.Name, false); functionABI.InputParameters = ExtractParametersFromAttributes(contractMessageType); if (functionAttribute.DTOReturnType != null) { functionABI.OutputParameters = ExtractParametersFromAttributes(functionAttribute.DTOReturnType); } else if (functionAttribute.ReturnType != null) { var parameter = new Parameter(functionAttribute.ReturnType); functionABI.OutputParameters = new Parameter[] { parameter }; } return(functionABI); } return(null); }