(template: WalletTemplate, unlockingScriptId: string, scenarioId: string)
| 204 | |
| 205 | // internal util. instantiates the virtual machine and compiles the template into a program |
| 206 | const createProgram = (template: WalletTemplate, unlockingScriptId: string, scenarioId: string): CreateProgramResult => { |
| 207 | const configuration = walletTemplateToCompilerConfiguration(template); |
| 208 | const vm = createVirtualMachine(template.supported[0] as VmTarget); |
| 209 | const compiler = createCompiler(configuration); |
| 210 | |
| 211 | if (!template.scripts[unlockingScriptId]) { |
| 212 | throw new Error(`No unlock script found in template for ID ${unlockingScriptId}`); |
| 213 | } |
| 214 | |
| 215 | if (!template.scenarios?.[scenarioId]) { |
| 216 | throw new Error(`No scenario found in template for ID ${scenarioId}`); |
| 217 | } |
| 218 | |
| 219 | const scenarioGeneration = compiler.generateScenario({ |
| 220 | debug: true, |
| 221 | unlockingScriptId, |
| 222 | scenarioId, |
| 223 | }); |
| 224 | |
| 225 | if (typeof scenarioGeneration === 'string') { |
| 226 | throw new FailedTransactionError(scenarioGeneration, getBitauthUri(template)); |
| 227 | } |
| 228 | |
| 229 | if (typeof scenarioGeneration.scenario === 'string') { |
| 230 | throw new FailedTransactionError(scenarioGeneration.scenario, getBitauthUri(template)); |
| 231 | } |
| 232 | |
| 233 | return { vm, program: scenarioGeneration.scenario.program }; |
| 234 | }; |
| 235 | |
| 236 | const logConsoleLogStatement = ( |
| 237 | log: LogEntry, |
no test coverage detected