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);
        }
        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()
        {
            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);
        }
Exemple #4
0
        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 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);
        }
Exemple #6
0
        //Functions for comparison of matched rule and already matched outputs
        public override SolidityFunction CreateHelperFunction()
        {
            FunctionName = Regex.Replace(Decision.Id, @" ", "").ToLowerCamelCase();
            SolidityFunction function = new SolidityFunction($"{FunctionName}_decideByPriority", SolidityVisibility.Internal, $"{OutputStructName} memory", true);

            var prioritiesFormatted = GetPriorities(Decision);
            var noUniqueOutputs     = Regex.Matches(prioritiesFormatted, $"{OutputStructName}").Count;

            function.AddParameter(new SolidityParameter($"{OutputStructName}[{noUniqueOutputs}] memory", "priorities"));
            function.AddParameter(new SolidityParameter($"{OutputStructName} memory", "currentOutput"));
            function.AddParameter(new SolidityParameter($"{OutputStructName} memory", "newOutput"));

            var priorityComparison = GetPriorityComparisonBody();
            var priorityIteration  = new SolidityFor("i", $"{noUniqueOutputs}");

            priorityIteration.AddToBody(new SolidityStatement(priorityComparison.ToString(), false));
            function.AddToBody(priorityIteration);
            function.AddToBody(new SolidityStatement("revert('Undefined output')", true));
            return(function);
        }
        SolidityFunction CreateGetStateFunction()
        {
            var functionName     = ConversionTemplates.ActiveStatesFunctionName(Id);
            var getStateFunction = new SolidityFunction(functionName, SolidityVisibility.Public, "bool", true);

            getStateFunction.AddToBody(new SolidityStatement($"return " +
                                                             $"{ConversionTemplates.ActiveStateAssignment(ConverterConfig.STATE_PARAMETER_NAME, Id, InstanceIdentifiers, true)}"));
            //Add the potential process identifiers
            getStateFunction.AddParameters(GetIdentifiersAsParameters());
            getStateFunction.AddParameter(new SolidityParameter("string", ConverterConfig.STATE_PARAMETER_NAME));
            return(getStateFunction);
        }