Esempio n. 1
0
        public OutputDescription Compile(string[] contractFilePaths,
                                         OutputType[] outputSelection,
                                         Optimizer optimizer = null,
                                         CompileErrorHandling errorHandling = CompileErrorHandling.ThrowOnError,
                                         Dictionary <string, string> soliditySourceFileContent = null)
        {
            var inputDesc = new InputDescription();

            inputDesc.Settings.OutputSelection["*"] = new Dictionary <string, OutputType[]>
            {
                ["*"] = outputSelection,
                [""]  = outputSelection
            };

            if (optimizer != null)
            {
                inputDesc.Settings.Optimizer = optimizer;
            }

            foreach (var filePath in contractFilePaths)
            {
                var normalizedPath = filePath.Replace('\\', '/');
                var source         = new Source {
                    Urls = new List <string> {
                        normalizedPath
                    }
                };
                inputDesc.Sources[normalizedPath] = source;
            }

            return(Compile(inputDesc, errorHandling, soliditySourceFileContent));
        }
Esempio n. 2
0
        public static List <InputDescription> GetInputs(this BehaviourTask task)
        {
            var inputs = new List <InputDescription>();

            if (task == null)
            {
                return(inputs);
            }

            var type             = task.GetType();
            var serializedFields = type.GetSerializedFieldsUpToBase();

            foreach (var f in serializedFields)
            {
                if (f.FieldType.IsSubclassOf(typeof(InputBase)))
                {
                    var inputObject = (InputBase)f.GetValue(task);
                    var definition  = f.FieldType.GetGenericTypeDefinition();
                    var description = new InputDescription(inputObject.ValueType, definition == typeof(InputValue <>), f.Name, f.Name);
                    inputs.Add(description);
                }
            }

            return(inputs);
        }
Esempio n. 3
0
        public OutputDescription Compile(InputDescription input,
                                         CompileErrorHandling errorHandling = CompileErrorHandling.ThrowOnError,
                                         Dictionary <string, string> soliditySourceFileContent = null)
        {
            var jsonStr = input.ToJsonString();

            return(CompileInputDescriptionJson(jsonStr, errorHandling, soliditySourceFileContent));
        }
 public InputFieldDescriptor(PropertyInfo property)
     : base(new InputFieldDescription())
 {
     InputDescription.Property = property
                                 ?? throw new ArgumentNullException(nameof(property));
     InputDescription.Name          = property.GetGraphQLName();
     InputDescription.Description   = property.GetGraphQLDescription();
     InputDescription.TypeReference = property.GetInputType();
     InputDescription.AcquireNonNullStatus(property);
 }
Esempio n. 5
0
        public JsonResult Compile(string source)
        {
            var compiler = new SolcLib();

            var input = new InputDescription
            {
                Language = Language.Solidity,
                Settings = new Settings
                {
                    OutputSelection = new Dictionary <string, Dictionary <string, OutputType[]> >
                    {
                        { "*", new Dictionary <string, OutputType[]> {
                              {
                                  "*",
                                  new[]
                                  {
                                      OutputType.Abi,
                                      OutputType.EvmBytecodeObject
                                  }
                              }
                          } }
                    },
                    EvmVersion = EvmVersion.Byzantium,
                    Optimizer  = new Optimizer
                    {
                        Enabled = false,
                        Runs    = 200
                    }
                },
                Sources = new Dictionary <string, Source>
                {
                    { "comiled.sol", new Source {
                          Content = source
                      } }
                }
            };

            var output = compiler.Compile(input);
            var regex  = new Regex("contract[ ]*.*_xtemplate");
            var name   = regex.Match(source).Value.Split(" ")[1];

            var result = new object[]
            {
                output.Contracts["comiled.sol"][name].Abi,
                output.Contracts["comiled.sol"][name].Evm.Bytecode.Object
            };

            return(new JsonResult(result));
        }
Esempio n. 6
0
        protected Port CreateInputPort(InputDescription description)
        {
            if (IsEntry)
            {
                return(null);
            }
            bool isExecution = description.ValueType == typeof(ExecutionPin);
            bool isMulti     = isExecution;
            var  capacity    = isMulti ? Port.Capacity.Multi : Port.Capacity.Single;
            var  port        = InstantiatePort(Orientation.Horizontal, Direction.Input, capacity, description.ValueType);

            port.portName = isExecution ? string.Empty : ObjectNames.NicifyVariableName(description.IdName);
            port.userData = description;

            if (description.PortType == typeof(ExecutionPin))
            {
                StylizeExecutionPort(port);
            }

            inputContainer.Add(port);
            return(port);
        }