コード例 #1
0
        private (Computer comp, Maybe <Transaction> result) RunHelper(string label, List <Expression> expList, Dictionary <string, ISCType> varList = null)
        {
            Smartcontract smart = new Smartcontract("cool name", Utils.GenerateRandomString(81));

            smart.AddExpression(new Expression(05, "Main"));

            expList.ForEach(x => smart.AddExpression(x));

            if (varList != null)
            {
                smart.Code.Variables = varList;
            }

            smart.Final(_settings);

            Transaction trans = new Transaction("me", 2, Utils.GenerateRandomString(81));

            trans.AddFee(0)
            .AddData(label)
            .Final(_settings);

            Computer comp   = new Computer(smart);
            var      result = comp.Run(trans);

            return(comp, result);
        }
コード例 #2
0
        private static Smartcontract CreateSmartcontract()
        {
            var smart = new Smartcontract("me", "sendto");

            smart.AddExpression(new Expression(00, "asd", "asd", "asd"))
            .AddExpression(new Expression(00, "bbb", "bbb", "bbb"))
            .AddExpression(new Expression(00, "ccc", "ccc"))
            .AddExpression(new Expression(00, "ccc"))
            .AddExpression(new Expression(00))
            .AddVariable("lol", new SC_Int(1110))
            .AddVariable("lol2", new SC_String("lol3333"))
            .AddVariable("lol3", new SC_String("lol3"))
            .AddVariable("lol4", new SC_Int("2323222"))
            .Final(_settings);

            return(smart);
        }
コード例 #3
0
        public Smartcontract GenerateSmartcontract(string sendTo, IXISettings settings)
        {
            //we first take the code and lex it
            var lexedCode = Lexing(_code);

            var name = lexedCode.Line.Split(' ')[0];

            var smart = new Smartcontract(name, sendTo);

            var list = new List <string>();

            SearchForNode(list, lexedCode);

            list.SelectMany(x => {
                var helper = new ExpressionHelper(x);

                if (helper.Contains("["))
                {
                    var arrayList = new List <string>();
                    for (int i = 0; i < int.Parse(helper[helper.Length - 2]); i++)
                    {
                        arrayList.Add(helper[1] + "_" + i);
                    }

                    return(arrayList);
                }
                else
                {
                    return(new List <string>()
                    {
                        helper[1]
                    });
                }
            }).ToList().ForEach(x => smart.AddVariable(x, new SC_Int()));

            return(smart.AddExpression(Parse(lexedCode).Compile()).Final(settings));
        }