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; }