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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        SolidityModifier CreateStateGuard()
        {
            SolidityModifier stateGuard = new SolidityModifier(ConversionTemplates.StateGuardModifierName(GetElementCallName()));

            stateGuard.AddParameters(processConverter.GetIdentifiersAsParameters());
            var activeStateFunctionName = ConversionTemplates.ActiveStatesFunctionName(processConverter.Id);
            var callParameters          = processConverter.GetIdentifierNames();

            if (callParameters.Length > 0)
            {
                callParameters += ",";
            }
            callParameters += $"\"{GetElementCallName()}\"";
            SolidityStatement requireStatement = new SolidityStatement($"require({activeStateFunctionName}({callParameters}) == true)");

            stateGuard.AddToBody(requireStatement);
            return(stateGuard);
        }