private bool InitInvoke() { var key = paramsList.Text; var f = _abi.functions[key]; _debugParameters = new DebugParameters(); //Get the private key used _debugParameters.PrivateKey = privateKeyInput.Text; //Get the witness mode CheckWitnessMode witnessMode; var ws = witnessComboBox.SelectedItem.ToString().Replace(" ", ""); if (!Enum.TryParse <CheckWitnessMode>(ws, out witnessMode)) { return(false); } _debugParameters.WitnessMode = witnessMode; //Get the trigger type TriggerType type; var ts = triggerComboBox.SelectedItem.ToString().Replace(" ", ""); if (!Enum.TryParse <TriggerType>(ts, out type)) { return(false); } _debugParameters.TriggerType = type; //Get the arguments list var argList = ""; if (f.inputs != null) { int index = 0; foreach (var p in f.inputs) { var temp = ($"{key}_{f.name}").ToLower(); var name = inputGrid.Rows[index].Cells[0].Value; object val; // detect placeholder if (inputGrid.Rows[index].Cells[1].Style.ForeColor == Color.Gray) { val = ""; } else { val = ReadCellVal(index, 1); } if (val == null) { val = ""; // temporary hack, necessary to avoid VM crash } if (val != null && !val.Equals("")) { var param_key = (currentContractName + "_" + f.name + "_" + p.name).ToLower(); //Add our default running parameters for next time _debugParameters.DefaultParams[param_key] = val.ToString(); } if (index > 0) { argList += ","; } if (p.type == Emulator.Type.Array || p.type == Emulator.Type.ByteArray) { var s = val.ToString(); if (s.StartsWith("[") && s.EndsWith("]")) { val = s; } else if (s.StartsWith("\"") && s.EndsWith("\"")) { s = s.Substring(1, s.Length - 2); if (DebuggerUtils.IsHex(s)) { var bytes = s.HexToBytes(); s = DebuggerUtils.BytesToString(bytes); } else if (DebuggerUtils.IsValidWallet(s)) { var scriptHash = Emulation.Helper.AddressToScriptHash(s); s = DebuggerUtils.BytesToString(scriptHash); } else { ShowArgumentError(f, index, val); return(false); } val = $"[{s}]"; } else { ShowArgumentError(f, index, val); return(false); } } else { switch (p.type) { case Emulator.Type.String: { var s = val.ToString(); if (!s.StartsWith("\"") || !s.EndsWith("\"")) { ShowArgumentError(f, index, val); return(false); } break; } case Emulator.Type.Integer: { BigInteger n; var s = val.ToString(); if (string.IsNullOrEmpty(s) || !BigInteger.TryParse(s, out n)) { ShowArgumentError(f, index, val); ResetTabs(); return(false); } break; } case Emulator.Type.Boolean: { switch (val.ToString().ToLower()) { case "true": val = true; break; case "false": val = false; break; default: { ShowArgumentError(f, index, val); ResetTabs(); return(false); } } break; } } } argList += val; index++; } } if (key != _abi.entryPoint.name) { if (f.inputs == null || f.inputs.Count == 0) { argList = "[null]"; } var operation = Char.ToLowerInvariant(key[0]) + key.Substring(1); argList = $"\"{operation}\", {argList}"; } //Set the arguments list try { _debugParameters.ArgList = DebuggerUtils.GetArgsListAsNode(argList); } catch { MessageBox.Show("Error parsing input!"); ResetTabs(); return(false); } if (assetComboBox.SelectedIndex > 0) { foreach (var entry in Asset.Entries) { if (entry.name == assetComboBox.SelectedItem.ToString()) { BigInteger amount; BigInteger.TryParse(assetAmount.Text, out amount); if (amount > 0) { amount *= Asset.Decimals; // fix decimals //Add the transaction info _debugParameters.Transaction.Add(entry.id, amount); } else { MessageBox.Show(entry.name + " amount must be greater than zero"); return(false); } break; } } } uint timestamp; if (!uint.TryParse(timestampBox.Text, out timestamp)) { MessageBox.Show("Invalid timestamp"); return(false); } else { _debugParameters.Timestamp = timestamp; } return(true); }