From faac6a2b189f56bc3d15b8012b702269878f177d Mon Sep 17 00:00:00 2001 From: yinwei <82604458@qq.com> Date: Thu, 29 Feb 2024 20:24:52 +0800 Subject: [PATCH] fix --- Fura/VM/Helper.cs | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/Fura/VM/Helper.cs b/Fura/VM/Helper.cs index 0451109..ebea7c1 100644 --- a/Fura/VM/Helper.cs +++ b/Fura/VM/Helper.cs @@ -65,14 +65,8 @@ public static List Script2ScCallModels(byte[] script, UInt256 txid, for (var i = 0; i < paramsCount; i++) { ++index; - if (instructions[index].OpCode >= OpCode.PUSH0 && instructions[index].OpCode <= OpCode.PUSH16) - { - hexParams[i] = (Convert.ToInt16(instructions[index].OpCode) - 16).ToString("X2"); - } - else - { - hexParams[i] = instructions[index].Operand.Span.ToHexString(); - } + (var str, index) = AnalysisInstruction(instructions, index); + hexParams[i] = str; } scCalls.Add(new(vmstate, txid, sender, UInt160.Parse(contractHash), method, callFlags.ToString(), hexParams)); } @@ -80,6 +74,35 @@ public static List Script2ScCallModels(byte[] script, UInt256 txid, return scCalls; } + public static (string, int) AnalysisInstruction(List instructions, int index) + { + var instruction = instructions[index]; + if (instruction.OpCode >= OpCode.PUSH0 && instruction.OpCode <= OpCode.PUSH16) + { + return (Opcode2PushNumber(instruction.OpCode, instruction.Operand.Span.ToArray()).ToString("X"), index);//(Convert.ToInt16(instructions[index].OpCode) - 16).ToString("X2"); + } + else if (instructions[index].OpCode == OpCode.SETITEM) + { + var json = new Neo.Json.JArray(); + while (true) + { + ++index; + if(instruction.OpCode == OpCode.DUP) + { + ++index; + break; + } + (var str, index) = AnalysisInstruction(instructions, index); + json.Add(str); + } + return (json.ToString(), index); + } + else + { + return (instruction.Operand.Span.ToHexString(), index); + } + } + public static List Script2Instruction(UInt256 txid, byte[] script) { try