11import { getProvider , RPCProviderLive } from './rpc-provider'
2- import { Effect , Layer } from 'effect'
2+ import { Effect , Layer , ManagedRuntime } from 'effect'
33import {
44 DecodedTransaction ,
55 DecodeResult ,
@@ -54,6 +54,8 @@ const MainLayer = Layer.provideMerge(LoadersLayer, DataLayer) as Layer.Layer<
5454 never
5555>
5656
57+ const runtime = ManagedRuntime . make ( MainLayer )
58+
5759export async function decodeTransaction ( {
5860 chainID,
5961 hash,
@@ -62,9 +64,9 @@ export async function decodeTransaction({
6264 hash : string
6365} ) : Promise < DecodedTransaction | undefined > {
6466 // NOTE: For unknonw reason the context of main layer is still missing the SqlClient in the type
65- const runnable = Effect . provide ( decodeTransactionByHash ( hash as Hex , chainID ) , MainLayer )
67+ const runnable = decodeTransactionByHash ( hash as Hex , chainID )
6668
67- return Effect . runPromise ( runnable ) . catch ( ( error : unknown ) => {
69+ return runtime . runPromise ( runnable ) . catch ( ( error : unknown ) => {
6870 console . error ( 'Decode error' , JSON . stringify ( error , null , 2 ) )
6971 return undefined
7072 } )
@@ -79,16 +81,13 @@ export async function decodeCalldata({
7981 data : string
8082 contractAddress ?: string
8183} ) : Promise < DecodeResult | undefined > {
82- const runnable = Effect . provide (
83- calldataDecoder ( {
84- data : data as Hex ,
85- chainID,
86- contractAddress,
87- } ) ,
88- MainLayer ,
89- )
84+ const runnable = calldataDecoder ( {
85+ data : data as Hex ,
86+ chainID,
87+ contractAddress,
88+ } )
9089
91- return Effect . runPromise ( runnable ) . catch ( ( error : unknown ) => {
90+ return runtime . runPromise ( runnable ) . catch ( ( error : unknown ) => {
9291 console . error ( 'Decode error' , JSON . stringify ( error , null , 2 ) )
9392 return undefined
9493 } )
0 commit comments