@@ -5,9 +5,10 @@ import { Interpreter, InterpreterOptions } from './types.js'
55import { getInterpreter } from './interpreters.js'
66import { QuickjsVM } from './quickjs.js'
77import { TransactionInterpreter } from './interpreter.js'
8+ import { QuickjsConfig } from './QuickjsConfig.js'
89
910const make = Effect . gen ( function * ( ) {
10- const vm = yield * QuickjsVM
11+ const config = yield * QuickjsConfig
1112
1213 return {
1314 findInterpreter : ( decodedTx : DecodedTransaction ) => {
@@ -28,23 +29,35 @@ const make = Effect.gen(function* () {
2829 options ?: { interpretAsUserAddress ?: string } ,
2930 ) =>
3031 Effect . gen ( function * ( ) {
32+ const vm = yield * QuickjsVM
33+
3134 const input = stringify ( decodedTransaction ) + ( options ? `,${ stringify ( options ) } ` : '' )
3235 const code = interpreter . schema + '\n' + 'transformEvent(' + input + ')'
3336 const result = yield * vm . eval ( code )
3437 return result
35- } ) . pipe ( Effect . withSpan ( 'TransactionInterpreter.interpretTx' ) ) ,
38+ } ) . pipe (
39+ Effect . withSpan ( 'TransactionInterpreter.interpretTx' ) ,
40+ Effect . scoped ,
41+ Effect . provideService ( QuickjsConfig , config ) ,
42+ ) ,
3643
3744 interpretTransaction : (
3845 decodedTransaction : DecodedTransaction ,
3946 interpreter : Interpreter ,
4047 options ?: InterpreterOptions ,
4148 ) =>
4249 Effect . gen ( function * ( ) {
50+ const vm = yield * QuickjsVM
51+
4352 const input = stringify ( decodedTransaction ) + ( options ? `,${ stringify ( options ) } ` : '' )
4453 const code = interpreter . schema + '\n' + 'transformEvent(' + input + ')'
4554 const result = yield * vm . eval ( code )
4655 return result
47- } ) . pipe ( Effect . withSpan ( 'TransactionInterpreter.interpretTransaction' ) ) ,
56+ } ) . pipe (
57+ Effect . withSpan ( 'TransactionInterpreter.interpretTransaction' ) ,
58+ Effect . scoped ,
59+ Effect . provideService ( QuickjsConfig , config ) ,
60+ ) ,
4861 }
4962} )
5063
0 commit comments