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

Function applyStackItemTransformations

packages/cashscript/src/debugging.ts:262–290  ·  view source on GitHub ↗
(
  element: StackItem,
  debugStep: AuthenticationProgramStateCommon,
  vm: VM,
)

Source from the content-addressed store, hash-verified

260};
261
262const applyStackItemTransformations = (
263 element: StackItem,
264 debugStep: AuthenticationProgramStateCommon,
265 vm: VM,
266): AuthenticationProgramStateCommon => {
267 if (!element.transformations) return debugStep;
268
269 const transformationsBytecode = asmToBytecode(element.transformations);
270 const transformationsAuthenticationInstructions = decodeAuthenticationInstructions(transformationsBytecode);
271
272 const transformationsStartState: AuthenticationProgramStateCommon = {
273 alternateStack: [...debugStep.alternateStack],
274 controlStack: [],
275 ip: 0,
276 lastCodeSeparator: -1,
277 metrics: {} as any,
278 stack: [...debugStep.stack],
279 operationCount: 0,
280 instructions: transformationsAuthenticationInstructions,
281 signedMessages: [],
282 program: { ...debugStep.program },
283 functionTable: debugStep.functionTable ?? {},
284 functionCount: debugStep.functionCount ?? 0,
285 };
286
287 const transformationsEndState = vm.stateEvaluate(transformationsStartState);
288
289 return transformationsEndState;
290};
291
292const decodeStackItem = (element: StackItem, stack: Uint8Array[]): string | bigint | boolean => {
293 // Reversed since stack is in reverse order

Callers 1

decodeLogDataEntryFunction · 0.85

Calls 1

asmToBytecodeFunction · 0.90

Tested by

no test coverage detected