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/young-ants-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@3loop/transaction-decoder': patch
---

Errors logging improvements
38 changes: 38 additions & 0 deletions apps/web/.cursor/rules/web.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
description:
globs:
alwaysApply: true
---
You are a Senior Front-End Developer and an Expert in ReactJS, NextJS, JavaScript, TypeScript, HTML, CSS and modern UI/UX frameworks (e.g., TailwindCSS, Shadcn, Radix). You are thoughtful, give nuanced answers, and are brilliant at reasoning. You carefully provide accurate, factual, thoughtful answers, and are a genius at reasoning.

- Follow the user’s requirements carefully & to the letter.
- First think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.
- Confirm, then write code!
- Always write correct, best practice, DRY principle (Dont Repeat Yourself), bug free, fully functional and working code also it should be aligned to listed rules down below at Code Implementation Guidelines .
- Focus on easy and readability code, over being performant.
- Fully implement all requested functionality.
- Leave NO todo’s, placeholders or missing pieces.
- Ensure code is complete! Verify thoroughly finalised.
- Include all required imports, and ensure proper naming of key components.
- Be concise Minimize any other prose.
- If you think there might not be a correct answer, you say so.
- If you do not know the answer, say so, instead of guessing.

### Coding Environment
The user asks questions about the following coding languages:
- ReactJS
- NextJS
- JavaScript
- TypeScript
- TailwindCSS
- HTML
- CSS

### Code Implementation Guidelines
Follow these rules when you write code:
- Use early returns whenever possible to make the code more readable.
- Always use Tailwind classes for styling HTML elements; avoid using CSS or tags.
- Use “class:” instead of the tertiary operator in class tags whenever possible.
- Use descriptive variable and function/const names. Also, event functions should be named with a “handle” prefix, like “handleClick” for onClick and “handleKeyDown” for onKeyDown.
- Implement accessibility features on elements. For example, a tag should have a tabindex=“0”, aria-label, on:click, and on:keydown, and similar attributes.
- Use consts instead of functions, for example, “const toggle = () =>”. Also, define a type if possible.
6 changes: 3 additions & 3 deletions packages/transaction-decoder/src/decoding/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const GetProxyResolver = RequestResolver.fromEffect(
const code = codeResult.right

//If code is empty and it is EOA, return empty result
if (!code) return undefined
if (!code || code === '0x') return undefined

let proxySlots: StorageSlot[] | undefined

Expand Down Expand Up @@ -213,8 +213,8 @@ export const GetProxyResolver = RequestResolver.fromEffect(
)

const res = yield* Effect.all(effects, {
concurrency: 'inherit',
batching: 'inherit',
concurrency: 'unbounded',
batching: true,
mode: 'either',
})

Expand Down
37 changes: 25 additions & 12 deletions packages/transaction-decoder/src/transaction-decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as CalldataDecode from './decoding/calldata-decode.js'
import type { DecodedTransaction, Interaction, ContractData, DecodeResult } from './types.js'
import { TxType } from './types.js'
import type { TraceLog } from './schema/trace.js'
import { getAssetsTransfers } from './transformers/tokens.js'
import { getAssetTransfers } from './transformers/transfers.js'
import { getAndCacheContractMeta } from './contract-meta-loader.js'
import { chainIdToNetwork } from './helpers/networks.js'
import { stringify } from './helpers/stringify.js'
Expand Down Expand Up @@ -112,24 +112,31 @@ export const decodeTransaction = ({
const decodedDataRight = Either.isRight(decodedData) ? decodedData.right : undefined
const decodedErrorTraceRight = decodedErrorTrace.filter(Either.isRight).map((r) => r.right)

const logsErrors = decodedLogs.filter(Either.isLeft).map((r) => r.left)

if (logsErrors.length > 0) {
yield* Effect.logError(`Logs decode errors: ${stringify(logsErrors)}`)
const logsDecodeErrors = decodedLogs.filter(Either.isLeft).map((r) => r.left)
if (logsDecodeErrors.length > 0) {
yield* Effect.logError(`Logs decode errors: ${stringify(logsDecodeErrors)}`)
}

if (!nativeTransfer && Either.isLeft(decodedData)) {
yield* Effect.logError(`Data decode error: ${decodedData.left}`)
}

const traceErrors = decodedTrace.filter(Either.isLeft).map((r) => r.left)
if (traceErrors.length > 0) {
yield* Effect.logError(`Trace decode errors: ${stringify(traceErrors)}`)
const traceDecodeErrors = decodedTrace
.filter(Either.isLeft)
.map((r) => r.left)
.filter((error, index, self) => self.findIndex((e) => e.message === error.message) === index)

if (traceDecodeErrors.length > 0) {
yield* Effect.logError(`Trace decode errors: ${stringify(traceDecodeErrors)}`)
}

const errorTraceErrors = decodedErrorTrace.filter(Either.isLeft).map((r) => r.left)
if (errorTraceErrors.length > 0) {
yield* Effect.logError(`ErrorTrace decode errors: ${stringify(errorTraceErrors)}`)
const errorTraceDecodeErrors = decodedErrorTrace
.filter(Either.isLeft)
.map((r) => r.left)
.filter((error, index, self) => self.findIndex((e) => e.message === error.message) === index)

if (errorTraceDecodeErrors.length > 0) {
yield* Effect.logError(`ErrorTrace decode errors: ${stringify(errorTraceDecodeErrors)}`)
}

const interactions: Interaction[] = TraceDecoder.augmentTraceLogs(transaction, decodedLogsRight, trace)
Expand Down Expand Up @@ -163,6 +170,12 @@ export const decodeTransaction = ({

const contractMeta = contractsMeta[contractAddress]

const transfersResult = yield* getAssetTransfers(interactions, value, receipt.from, receipt.to!)

if (transfersResult.errors.length > 0) {
yield* Effect.logError(`Transfers decode errors: ${stringify(transfersResult.errors)}`)
}

const decodedTx: DecodedTransaction = {
txHash: transaction.hash,
txType: nativeTransfer ? TxType.TRANSFER : TxType.CONTRACT_INTERACTION,
Expand All @@ -187,7 +200,7 @@ export const decodeTransaction = ({
timestamp,
txIndex: receipt.transactionIndex,
reverted: receipt.status === 'reverted', // will return true if status==undefined
transfers: getAssetsTransfers(interactions, value, receipt.from, receipt.to!),
transfers: transfersResult.transfers,
interactedAddresses,
addressesMeta: contractsMeta,
errors: decodedErrorTraceRight.length > 0 ? decodedErrorTraceRight : null,
Expand Down
163 changes: 0 additions & 163 deletions packages/transaction-decoder/src/transformers/tokens.ts

This file was deleted.

Loading
Loading