SolidityFunction CreateElementMainFunction() { SolidityFunction function = new SolidityFunction(GetElementCallName(), SolidityVisibility.Public); function.AddModifier($"{ConversionTemplates.StateGuardModifierName(GetElementCallName())}({processConverter.GetIdentifierNames()})"); function.AddParameters(processConverter.GetIdentifiersAsParameters()); if (IsAddressGuardRequired()) { function.AddModifier($"{ConversionTemplates.AddressGuardModifierName(GetElementCallName())}({processConverter.GetIdentifierNames()})"); } boundaryEventCalls.ForEach(c => function.AddToBody(c)); function.AddToBody(new SolidityStatement(userTaskElement.ValidationScript, false)); if (userTaskElement.Form.Fields != null) { foreach (var field in userTaskElement.Form.Fields) { //TODO: throw exception if no property has been found var propertyAndEntity = processConverter.GetPropertyAndEntity(field.PropertyExpression); var property = propertyAndEntity.Item1; var entity = propertyAndEntity.Item2; var formPropertyDisplayName = Helpers.ToLowerCamelCase(field.DisplayName); function.AddParameter(new SolidityParameter(Helpers.PropertyTypeToString(property, processConverter.ContractConverter), formPropertyDisplayName)); } } function.AddToBody(CreateCallNextBody()); return(function); }
SolidityFunction CreateElementMainFunction(ElementConverter nextElement, List <SolidityStruct> dataModel) { SolidityFunction function = new SolidityFunction(GetTaskName(), SolidityVisibility.Public); function.AddModifier("is" + GetTaskName() + "State"); if (userTask.Assignee != null && (userTask.Assignee.Address != null || userTask.Assignee.Name != null)) { function.AddModifier("is" + GetTaskName() + "Authorized"); } SolidityStatement statement = new SolidityStatement(ProcessConverter.ACTIVE_STATES_NAME + "[\"" + GetTaskName() + "\"] = false"); function.AddToBody(statement); if (userTask.Form.Fields != null) { foreach (var field in userTask.Form.Fields) { foreach (var s in dataModel) { Property p = s.En.Properties.FirstOrDefault(p => p.Id == field.PropertyExpression); if (p != null) { function.AddParameter(new SolidityParameter(Helpers.GetSolidityStringType(p), field.DisplayName)); function.AddToBody(new SolidityStatement(s.VariableName() + "." + Helpers.GetPropertyVariableName(p.Name) + " = " + field.DisplayName)); } } } } function.AddToBody(nextElement.GetStatementForPrevious(userTask)); return(function); }
SolidityFunction CreateElementMainFunction() { SolidityFunction function = new SolidityFunction(GetElementCallName(), SolidityVisibility.Public); function.AddModifier($"{ConversionTemplates.StateGuardModifierName(GetElementCallName())}({processConverter.GetIdentifierNames()})"); function.AddParameters(processConverter.GetIdentifiersAsParameters()); /* * if (IsAddressGuardRequired()) * function.AddModifier($"{ConversionTemplates.AddressGuardModifierName(GetElementCallName())}({processConverter.GetIdentifierNames()})"); */ boundaryEventCalls.ForEach(c => function.AddToBody(c)); function.AddToBody(new SolidityStatement(userTaskElement.ValidationScript, false)); foreach (var fieldGroup in userTaskElement.Form.FieldGroups) { foreach (var field in fieldGroup.Fields) { //var property = processConverter.GetProperty(field.ParamBind); var formPropertyDisplayName = Helpers.ToLowerCamelCase(field.Label); function.AddParameter(new SolidityParameter(Helpers.FormFieldToDataType(field), formPropertyDisplayName)); } } function.AddToBody(CreateCallNextBody()); return(function); }
SolidityFunction CreateMintFunction() { SolidityFunction function = new SolidityFunction("mint", SolidityVisibility.Public); function.AddParameter(new SolidityParameter("address", "receiver")); function.AddModifier(ConverterConfig.OWNABLE_MODIFIER); function.AddToBody(new SolidityStatement(token.MintScript, false)); //function.AddToBody(new SolidityStatement("_safeMint(receiver, uint256(receiver))")); return(function); }
SolidityFunction CreateTransferFunction() { SolidityFunction function = new SolidityFunction("transfer", SolidityVisibility.Public); function.AddParameter(new SolidityParameter("address", "from")); function.AddParameter(new SolidityParameter("address", "to")); function.AddModifier(ConverterConfig.OWNABLE_MODIFIER); function.AddToBody(new SolidityStatement(token.TransferScript, false)); return(function); }
public override IList <SolidityComponent> GetElementCode(List <ElementConverter> nextElements, IList <SequenceFlow> outgoingSeqFlows, IList <SolidityStruct> dataModel = null) { SolidityFunction function = new SolidityFunction(GetTaskName(), SolidityVisibility.Internal); function.AddModifier("is" + GetTaskName() + "State"); SolidityStatement disableFunctionStatement = new SolidityStatement(ProcessConverter.ACTIVE_STATES_NAME + "[\"" + GetTaskName() + "\"] = false"); function.AddToBody(disableFunctionStatement); function.AddToBody(new SolidityStatement(scriptTask.Script, false)); function.AddToBody(nextElements[0].GetStatementForPrevious(scriptTask)); return(new List <SolidityComponent> { CreateStateGuard(), function }); }
SolidityFunction CreateTouchFunction(TaskConverter attachedToConverter) { var function = new SolidityFunction($"touch{GetElementCallName()}", SolidityVisibility.Public, "bool"); function.AddParameters(processConverter.GetIdentifiersAsParameters()); function.AddModifier($"{ConversionTemplates.StateGuardModifierName(attachedToConverter.GetElementCallName())}({processConverter.GetIdentifierNames()})"); var solidityCondition = new SolidityIfElse(); solidityCondition.AddConditionBlock($"now > {GetTimerCondition()}", CreateTouchFunctionLogic(attachedToConverter)); function.AddToBody(solidityCondition); function.AddToBody(new SolidityStatement("return true")); return(function); }