From f379dabead4a28917518fdb5014a87439c5df918 Mon Sep 17 00:00:00 2001 From: Christopher Schuchardt Date: Fri, 21 Jun 2024 04:50:04 -0400 Subject: [PATCH] Fixed `ApplicationLogs` `GetMethodParameterName` method (#3348) Co-authored-by: Jimmy Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com> --- src/Plugins/ApplicationLogs/LogReader.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Plugins/ApplicationLogs/LogReader.cs b/src/Plugins/ApplicationLogs/LogReader.cs index 3155ecea1f..3c1b5ecb94 100644 --- a/src/Plugins/ApplicationLogs/LogReader.cs +++ b/src/Plugins/ApplicationLogs/LogReader.cs @@ -272,8 +272,9 @@ private void PrintExecutionToConsole(BlockchainExecutionModel model) ConsoleHelper.Info(" ScriptHash: ", $"{notifyItem.ScriptHash}"); ConsoleHelper.Info(" Event Name: ", $"{notifyItem.EventName}"); ConsoleHelper.Info(" State Parameters:"); - for (int i = 0; i < notifyItem.State.Length; i++) - ConsoleHelper.Info($" {GetMethodParameterName(notifyItem.ScriptHash, notifyItem.EventName, i)}: ", $"{notifyItem.State[i].ToJson()}"); + var ncount = (uint)notifyItem.State.Length; + for (var i = 0; i < ncount; i++) + ConsoleHelper.Info($" {GetMethodParameterName(notifyItem.ScriptHash, notifyItem.EventName, ncount, i)}: ", $"{notifyItem.State[i].ToJson()}"); } } if (Settings.Default.Debug) @@ -301,18 +302,21 @@ private void PrintEventModelToConsole(IReadOnlyCollection<(BlockchainEventModel ConsoleHelper.Info(); ConsoleHelper.Info(" Event Name: ", $"{notifyItem.EventName}"); ConsoleHelper.Info(" State Parameters:"); - for (int i = 0; i < notifyItem.State.Length; i++) - ConsoleHelper.Info($" {GetMethodParameterName(notifyItem.ScriptHash, notifyItem.EventName, i)}: ", $"{notifyItem.State[i].ToJson()}"); + var ncount = (uint)notifyItem.State.Length; + for (var i = 0; i < ncount; i++) + ConsoleHelper.Info($" {GetMethodParameterName(notifyItem.ScriptHash, notifyItem.EventName, ncount, i)}: ", $"{notifyItem.State[i].ToJson()}"); ConsoleHelper.Info("--------------------------------"); } } - private string GetMethodParameterName(UInt160 scriptHash, string methodName, int parameterIndex) + private string GetMethodParameterName(UInt160 scriptHash, string methodName, uint ncount, int parameterIndex) { var contract = NativeContract.ContractManagement.GetContract(_neosystem.StoreView, scriptHash); if (contract == null) return $"{parameterIndex}"; - var contractEvent = contract.Manifest.Abi.Events.SingleOrDefault(s => s.Name == methodName); + var contractEvent = contract.Manifest.Abi.Events.SingleOrDefault(s => s.Name == methodName && (uint)s.Parameters.Length == ncount); + if (contractEvent == null) + return $"{parameterIndex}"; return contractEvent.Parameters[parameterIndex].Name; }