(bytecode: Uint8Array)
| 86 | } |
| 87 | |
| 88 | export function bytecodeToAsm(bytecode: Uint8Array): string { |
| 89 | // Convert the bytecode to libauth's ASM format |
| 90 | let asm = disassembleBytecodeBch(bytecode); |
| 91 | |
| 92 | // COnvert libauth's ASM format to BITBOX's |
| 93 | asm = asm.replace(/OP_PUSHBYTES_[^\s]+/g, ''); |
| 94 | asm = asm.replace(/OP_PUSHDATA[^\s]+ [^\s]+/g, ''); |
| 95 | asm = asm.replace(/(^|\s)0x/g, ' '); |
| 96 | |
| 97 | // Remove any duplicate whitespace |
| 98 | asm = asm.replace(/\s+/g, ' ').trim(); |
| 99 | |
| 100 | return asm; |
| 101 | } |
| 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 { |
no outgoing calls
no test coverage detected