Exemple #1
0
 public override void Execute(string[] args, Action <ShellMessageType, string> output)
 {
     if (Shell.Debugger.Info.state == DebuggerState.State.Running || Shell.Debugger.Info.state == DebuggerState.State.Break)
     {
         output(ShellMessageType.Default, "Resuming invoke.");
         Shell.Debugger.Run();
         ShellRunner.UpdateState(Shell, output);
     }
     else
     {
         output(ShellMessageType.Error, "Start a transaction with invoke first.");
     }
 }
Exemple #2
0
        public override void Execute(string[] args, Action <ShellMessageType, string> output)
        {
            if (Shell.Debugger.Info.state == DebuggerState.State.Running || Shell.Debugger.Info.state == DebuggerState.State.Break)
            {
                output(ShellMessageType.Default, "Stepping invoke.");

                string startFile;
                var    startLine = Shell.Debugger.ResolveLine(Shell.Debugger.Info.offset, true, out startFile);

                string currentFile;
                int    currentLine;
                do
                {
                    Shell.Debugger.Step();
                    currentLine = Shell.Debugger.ResolveLine(Shell.Debugger.Info.offset, true, out currentFile);
                } while (currentFile == startFile && currentLine == startLine);

                ShellRunner.UpdateState(Shell, output);
            }
            else
            {
                output(ShellMessageType.Error, "Start a transaction with invoke first.");
            }
        }
        public override void Execute(string[] args, Action <ShellMessageType, string> output)
        {
            if (Shell.Debugger.IsSteppingOrOnBreakpoint)
            {
                output(ShellMessageType.Error, $"Please finish debugging the current invoke: {Shell.Debugger.Emulator.currentMethod}");
                return;
            }

            DataNode inputs;

            try
            {
                inputs = JSONReader.ReadFromString(args[1]);
            }
            catch
            {
                output(ShellMessageType.Error, "Invalid arguments format. Must be valid JSON.");
                return;
            }

            if (args.Length >= 3)
            {
                bool valid = false;

                if (args[2].ToLower() == "with")
                {
                    if (args.Length >= 5)
                    {
                        var assetAmount = BigInteger.Parse(args[3]);
                        var assetName   = args[4];

                        foreach (var entry in Asset.Entries)
                        {
                            if (entry.name == assetName)
                            {
                                output(ShellMessageType.Default, $"Attaching {assetAmount} {assetName} to transaction");
                                Shell.Debugger.Emulator.SetTransaction(entry.id, assetAmount);
                                break;
                            }
                        }

                        valid = true;
                    }
                }

                if (!valid)
                {
                    output(ShellMessageType.Error, "Invalid sintax.");
                    return;
                }
            }

            output(ShellMessageType.Default, "Executing transaction...");

            var methodName   = inputs.ChildCount > 0 ? inputs[0].Value : null;
            var loaderScript = Shell.Debugger.Emulator.GenerateLoaderScriptFromInputs(inputs, Shell.Debugger.ABI);

            Shell.Debugger.Emulator.Reset(loaderScript, Shell.Debugger.ABI, methodName);

            Runtime.OnLogMessage = (x => output(ShellMessageType.Default, x));

            Shell.Debugger.Run();
            ShellRunner.UpdateState(Shell, output);
        }