MCPcopy Create free account
hub / github.com/CashScript/cashscript / getFinalExecutedVerifyIp

Function getFinalExecutedVerifyIp

packages/cashscript/src/debugging.ts:356–369  ·  view source on GitHub ↗
(executedDebugSteps: AuthenticationProgramStateCommon[])

Source from the content-addressed store, hash-verified

354};
355
356const getFinalExecutedVerifyIp = (executedDebugSteps: AuthenticationProgramStateCommon[]): number => {
357 // Map every executed debug step to its corresponding instruction
358 // (note that the last executed step(s) may not have a corresponding instruction and will be `undefined`)
359 const executedInstructions = executedDebugSteps.map((step) => step.instructions[step.ip]);
360
361 const finalExecutedDebugStepIndex = executedDebugSteps.length - 1;
362 const cleanupSize = calculateCleanupSize(executedInstructions);
363 const finalExecutedNonCleanupStep = executedDebugSteps[finalExecutedDebugStepIndex - cleanupSize];
364
365 // The final verify in a function is dropped, so after cleanup, we get the final OP that was executed *before* the
366 // final verify, so we need to add one to get the actual final verify instruction
367 const finalExecutedVerifyIp = finalExecutedNonCleanupStep.ip + 1;
368 return finalExecutedVerifyIp;
369};
370
371// After debugging, we want to verify the full transaction to ensure it is valid (this catches any errors that are not
372// necessarily script errors)

Callers 1

debugSingleScenarioFunction · 0.85

Calls 1

calculateCleanupSizeFunction · 0.85

Tested by

no test coverage detected