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

Function bytecodeToAsm

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

Source from the content-addressed store, hash-verified

86}
87
88export 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
104export function bytecodeToBitAuthAsm(bytecode: Uint8Array): string {

Callers 5

util.test.tsFile · 0.90
logDebugStepsFunction · 0.90
Location.test.tsFile · 0.90
script.test.tsFile · 0.85
scriptToAsmFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected