(script: Script)
| 37 | } |
| 38 | |
| 39 | export function scriptToBytecode(script: Script): Uint8Array { |
| 40 | // Convert the script elements to AuthenticationInstructions |
| 41 | const instructions = script.map((opOrData) => { |
| 42 | if (typeof opOrData === 'number') { |
| 43 | return { opcode: opOrData }; |
| 44 | } |
| 45 | |
| 46 | return decodeAuthenticationInstructions(encodeDataPush(opOrData))[0]; |
| 47 | }); |
| 48 | |
| 49 | // Convert the AuthenticationInstructions to bytecode |
| 50 | return encodeAuthenticationInstructions(instructions); |
| 51 | } |
| 52 | |
| 53 | export function bytecodeToScript(bytecode: Uint8Array): Script { |
| 54 | // Convert the bytecode to AuthenticationInstructions |
no outgoing calls
no test coverage detected