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

Function bytecodeToBitAuthAsm

packages/utils/src/script.ts:104–117  ·  view source on GitHub ↗
(bytecode: Uint8Array)

Source from the content-addressed store, hash-verified

102
103// TODO: If we decide to change the ASM / artifact format, we can remove this function and merge it with bytecodeToAsm
104export 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
119export function countOpcodes(script: Script): number {
120 return script

Callers 1

scriptToBitAuthAsmFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected