Skip to content

Commit 6827801

Browse files
committed
Use runtime in playground decoding
1 parent 031949f commit 6827801

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

apps/web/src/lib/decode.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getProvider, RPCProviderLive } from './rpc-provider'
2-
import { Effect, Layer } from 'effect'
2+
import { Effect, Layer, ManagedRuntime } from 'effect'
33
import {
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+
5759
export 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
})

packages/transaction-decoder/src/transformers/tokens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function getTokens(interactions: Interaction[]): Asset[] {
102102
]
103103
}
104104

105-
console.error('Unsupported type:', interaction)
105+
console.warn('Unsupported type:', interaction)
106106
// TODO: Batch transfers are not supported yet
107107
return []
108108
})

0 commit comments

Comments
 (0)