Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vikkkko committed Feb 29, 2024
1 parent 1dc69db commit faac6a2
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions Fura/VM/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,44 @@ public static List<ScCallModel> 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));
}
}
return scCalls;
}

public static (string, int) AnalysisInstruction(List<Instruction> 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<Instruction> Script2Instruction(UInt256 txid, byte[] script)
{
try
Expand Down

0 comments on commit faac6a2

Please sign in to comment.