Skip to content

Commit

Permalink
Fixed ApplicationLogs GetMethodParameterName method (#3348)
Browse files Browse the repository at this point in the history
Co-authored-by: Jimmy <[email protected]>
Co-authored-by: NGD Admin <[email protected]>
  • Loading branch information
3 people committed Jun 21, 2024
1 parent 60bb9c6 commit f379dab
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Plugins/ApplicationLogs/LogReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit f379dab

Please sign in to comment.