Skip to content

Commit

Permalink
DebugScriptWithSession
Browse files Browse the repository at this point in the history
  • Loading branch information
Hecate2 committed Sep 10, 2024
1 parent 68367d9 commit 1932922
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Fairy.Debugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,32 @@ protected virtual JToken DebugFunctionWithSession(JArray _params)
return DumpDebugResultJson(newEngine, breakReason);
}

[RpcMethod]
protected virtual JToken DebugScriptWithSession(JArray _params)
{
string session = _params[0]!.AsString();
bool writeSnapshot = _params[1]!.AsBoolean();
byte[] script = Convert.FromBase64String(_params[2]!.AsString());
Signer[]? signers = _params.Count >= 4 ? SignersFromJson((JArray)_params[3]!, system.Settings) : null;
Witness[]? witnesses = _params.Count >= 5 ? WitnessesFromJson((JArray)_params[4]!) : null;
Transaction? tx = signers == null ? null : new Transaction
{
Signers = signers,
Attributes = System.Array.Empty<TransactionAttribute>(),
Witnesses = witnesses,
};
FairySession testSession = GetOrCreateFairySession(session);
FairyEngine newEngine;
logs.Clear();
FairyEngine.Log += CacheLog!;
BreakReason breakReason = BreakReason.None;
newEngine = DebugRun(script, testSession.engine.Snapshot.CreateSnapshot(), out breakReason, container: tx, settings: system.Settings, gas: settings.MaxGasInvoke, oldEngine: testSession.engine);
FairyEngine.Log -= CacheLog!;
if (writeSnapshot)
sessionStringToFairySession[session].debugEngine = newEngine;
return DumpDebugResultJson(newEngine, breakReason);
}

[RpcMethod]
protected virtual JToken DebugContinue(JArray _params)
{
Expand Down

0 comments on commit 1932922

Please sign in to comment.