(element: StackItem, stack: Uint8Array[])
| 290 | }; |
| 291 | |
| 292 | const decodeStackItem = (element: StackItem, stack: Uint8Array[]): string | bigint | boolean => { |
| 293 | // Reversed since stack is in reverse order |
| 294 | const stackItem = [...stack].reverse()[element.stackIndex]; |
| 295 | |
| 296 | if (!stackItem) { |
| 297 | throw Error(`Stack item at index ${element.stackIndex} not found at instruction pointer ${element.ip}`); |
| 298 | } |
| 299 | |
| 300 | if (element.type === PrimitiveType.BOOL) return decodeBool(stackItem); |
| 301 | if (element.type === PrimitiveType.INT) return decodeInt(stackItem); |
| 302 | if (element.type === PrimitiveType.STRING) return decodeString(stackItem); |
| 303 | |
| 304 | return `0x${binToHex(stackItem)}`; |
| 305 | }; |
| 306 | |
| 307 | const failedFinalVerify = (evaluationResult: string | true): evaluationResult is string => { |
| 308 | // true indicates a successful evaluation (so no failed final verify) |
no test coverage detected