(bytecode: Uint8Array)
| 102 | |
| 103 | // TODO: If we decide to change the ASM / artifact format, we can remove this function and merge it with bytecodeToAsm |
| 104 | export function bytecodeToBitAuthAsm(bytecode: Uint8Array): string { |
| 105 | // Convert the bytecode to libauth's ASM format |
| 106 | let asm = disassembleBytecodeBch(bytecode); |
| 107 | |
| 108 | // COnvert libauth's ASM format to BitAuth Script ASM |
| 109 | asm = asm.replace(/OP_PUSHBYTES_[^\s]+/g, ''); |
| 110 | asm = asm.replace(/OP_PUSHDATA[^\s]+ [^\s]+/g, ''); |
| 111 | asm = asm.replace(/(^|\s)(0x\w*)/g, ' \<$2\>'); |
| 112 | |
| 113 | // Remove any duplicate whitespace |
| 114 | asm = asm.replace(/\s+/g, ' ').trim(); |
| 115 | |
| 116 | return asm; |
| 117 | } |
| 118 | |
| 119 | export function countOpcodes(script: Script): number { |
| 120 | return script |
no outgoing calls
no test coverage detected