Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/proud-books-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@3loop/transaction-decoder': minor
---

Allow disabling tracer for an RPC client thus relaying only on logs and receipt
4 changes: 2 additions & 2 deletions apps/docs/src/content/docs/recipes/fc-bot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
description: The simple way to Create a Farcaster Bot for human-readable alerts
---

import { Content as MemoryAbiLoader } from '../../components/memory-abi-loader.md'

Check warning on line 6 in apps/docs/src/content/docs/recipes/fc-bot.mdx

View workflow job for this annotation

GitHub Actions / pr

'MemoryAbiLoader' is defined but never used
import { Content as MemoryContractLoader } from '../../components/memory-contract-loader.md'

Check warning on line 7 in apps/docs/src/content/docs/recipes/fc-bot.mdx

View workflow job for this annotation

GitHub Actions / pr

'MemoryContractLoader' is defined but never used

import { Steps } from '@astrojs/starlight/components'

Check warning on line 9 in apps/docs/src/content/docs/recipes/fc-bot.mdx

View workflow job for this annotation

GitHub Actions / pr

'Steps' is defined but never used

In this guide, you will learn how to create a Farcaster bot that sends human-readable alerts about transactions happening on-chain. You can customize this bot for any EVM-compatible blockchain, and you don't need any specific knowledge about EVM transaction decoding and interpretation.

Expand Down Expand Up @@ -73,7 +73,7 @@
export const RPC = {
8453: {
url: `wss://base-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`,
supportTraceAPI: false,
traceAPI: 'none',
},
}
```
Expand All @@ -95,7 +95,7 @@
transport: webSocket(rpc.url),
}),
config: {
supportTraceAPI: rpc.supportTraceAPI,
traceAPI: rpc.traceAPI,
},
}
}
Expand Down
18 changes: 12 additions & 6 deletions apps/web/src/app/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ export const EXAMPLE_TXS = {
],
}

export const supportedChains = [
export const supportedChains: {
name: string
chainID: number
rpcUrl: string
traceAPI?: 'parity' | 'geth' | 'none'
batchMaxCount?: number
}[] = [
{
name: 'Ethereum Mainnet',
chainID: 1,
Expand All @@ -100,32 +106,32 @@ export const supportedChains = [
name: 'Base mainnet',
chainID: 8453,
rpcUrl: process.env.BASE_RPC_URL as string,
supportTraceAPI: false,
traceAPI: 'geth',
batchMaxCount: 1,
},
{
name: 'Polygon Mainnet',
chainID: 137,
rpcUrl: (process.env.POLYGON_RPC_URL as string) ?? 'https://rpc.ankr.com/polygon',
suppurtTraceAPI: true,
traceAPI: 'geth',
},
{
name: 'Optimism Mainnet',
chainID: 10,
rpcUrl: process.env.OPTIMISM_RPC_URL as string,
supportTraceAPI: false,
traceAPI: 'geth',
},
{
name: 'Arbitrum One',
chainID: 42161,
rpcUrl: process.env.ARBITRUM_RPC_URL as string,
supportTraceAPI: false,
traceAPI: 'geth',
},
{
name: 'Manta pacific',
chainID: 169,
rpcUrl: (process.env.MANTA_RPC_URL as string) ?? 'https://pacific-rpc.manta.network/http',
supportTraceAPI: false,
traceAPI: 'geth',
},
]

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/lib/rpc-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function getProvider(chainID: number): PublicClientObject | null {
transport: http(url),
}),
config: {
supportTraceAPI: providerConfigs[chainID]?.supportTraceAPI,
traceAPI: providerConfigs[chainID]?.traceAPI,
},
}

Expand Down
2 changes: 1 addition & 1 deletion packages/transaction-decoder/src/public-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class RPCFetchError {
}

export interface PublicClientConfig {
readonly supportTraceAPI?: boolean
readonly traceAPI?: 'parity' | 'geth' | 'none'
}

export interface PublicClientObject {
Expand Down
14 changes: 8 additions & 6 deletions packages/transaction-decoder/src/transaction-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export const getTransactionReceipt = (hash: Hash, chainID: number) =>
export const getTrace = (hash: Hash, chainID: number) =>
Effect.gen(function* () {
const service = yield* PublicClient
const { client, config } = yield* service.getPublicClient(chainID)
const traceAPISupport = config?.supportTraceAPI ?? true
const { client, config = {} } = yield* service.getPublicClient(chainID)
const traceAPI = config.traceAPI ?? 'parity'

if (traceAPISupport) {
if (traceAPI === 'parity') {
const trace = yield* Effect.withSpan(
Effect.tryPromise({
try: async () => {
Expand All @@ -60,7 +60,7 @@ export const getTrace = (hash: Hash, chainID: number) =>
catch: () => new RPCFetchError('Get trace'),
}),
'TransactionLoader.Trace',
{ attributes: { hash, chainID, traceAPISupport } },
{ attributes: { hash, chainID, traceAPI } },
)

const effects: Effect.Effect<TraceLog, ParseError>[] = trace.map((log: string) => {
Expand All @@ -73,7 +73,7 @@ export const getTrace = (hash: Hash, chainID: number) =>
})

return results
} else {
} else if (traceAPI === 'geth') {
const trace = yield* Effect.withSpan(
Effect.tryPromise({
try: async () => {
Expand All @@ -87,13 +87,15 @@ export const getTrace = (hash: Hash, chainID: number) =>
catch: (e) => new RPCFetchError(e),
}),
'TransactionLoader.Trace',
{ attributes: { hash, chainID, traceAPISupport } },
{ attributes: { hash, chainID, traceAPI } },
)

const transformedTrace = transformTraceTree(trace as unknown as TraceLogTree)

return transformedTrace
}

return []
})

export const getBlockTimestamp = (blockNumber: bigint, chainID: number) =>
Expand Down
Loading