Skip to content

Add ability to try the decoder over multiple ABIs - #239

Merged
anastasiarods merged 16 commits into
mainfrom
add-support-for-fallbacks-in-decode
Aug 21, 2025
Merged

Add ability to try the decoder over multiple ABIs#239
anastasiarods merged 16 commits into
mainfrom
add-support-for-fallbacks-in-decode

Conversation

@Ferossgp

@FerossgpFerossgp commented Aug 17, 2025

Copy link
Copy Markdown
Member

This version changes the public API for ABI store. If you use built in stores evrything should work out of the box. When using SQL store ensure that migrations complete on start. Additionally the AbiLoader will now also return an array of ABIs when accessing the cached data. These changes allows us to run over multiple ABIs when decoding a transaction, instead of failing when the cached ABI is wrong.

@FerossgpFerossgp self-assigned this Aug 17, 2025
@vercel

vercelBot commented Aug 17, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
loop-decoder-webReadyReadyPreviewCommentAug 21, 2025 7:54am

@cloudflare-workers-and-pages

cloudflare-workers-and-pagesBot commented Aug 17, 2025

Copy link
Copy Markdown

Deploying loop-decoder with Cloudflare Pages Cloudflare Pages

Latest commit:cc791f8
Status: ✅ Deploy successful!
Preview URL:https://64c5ef51.loop-decoder.pages.dev
Branch Preview URL:https://add-support-for-fallbacks-in.loop-decoder.pages.dev

View logs

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds the ability to try multiple ABIs when decoding transactions, enhancing resilience against cached ABIs that become invalid. The changes modify the ABI store architecture to support multiple ABI versions per lookup key and implement validation logic that marks failed ABIs as invalid.

  • Refactors ABI storage to handle multiple ABIs per lookup key with status tracking
  • Implements fallback decoding logic that tries multiple ABIs sequentially
  • Adds migration system for SQL store to upgrade schema and preserve existing data

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
packages/transaction-decoder/src/abi-store.tsUpdates ABI store interface to return arrays and support status tracking
packages/transaction-decoder/src/sql/abi-store.tsImplements new v3 schema with migrations and multi-ABI support
packages/transaction-decoder/src/in-memory/abi-store.tsUpdates in-memory store to handle multiple ABIs per key
packages/transaction-decoder/src/decoding/abi-decode.tsAdds validation functions that try multiple ABIs with fallback
packages/transaction-decoder/src/abi-loader.tsModifies loader to return arrays of ABIs with metadata
packages/transaction-decoder/src/decoding/*.tsUpdates decoding functions to use new multi-ABI validation
test filesUpdates mocks to return arrays instead of single results
documentationUpdates interface documentation to reflect new multi-ABI API

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

import { type Hex, type GetTransactionReturnType, Abi, getAddress } from 'viem'
import { stringify } from '../helpers/stringify.js'
import { errorFunctionSignatures, panicReasons, solidityError, solidityPanic } from '../helpers/error.js'
import { e } from 'vitest/dist/types-63abf2e0.js'

CopilotAIAug 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import appears to be an accidental leftover from debugging. The variable 'e' is not used anywhere in the file and this import path suggests it's a test-related dependency that shouldn't be in production code.

Suggested change
import { e } from 'vitest/dist/types-63abf2e0.js'

Copilot uses AI. Check for mistakes.
const result = yield* decodeMethod(data, abi)

if (result == null) {
return yield* Effect.fail(new DecodeError(`ABI ${abi} failed to decode`))

CopilotAIAug 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message interpolates the entire ABI object which will result in '[object Object]' being displayed. Consider using a more descriptive error message or abi identifier.

Suggested change
returnyield*Effect.fail(newDecodeError(`ABI ${abi} failed to decode`))
returnyield*Effect.fail(newDecodeError(`ABI with id ${id} failed to decode`))

Copilot uses AI. Check for mistakes.
'@3loop/transaction-decoder': minor
---

BREAKING! This version changes the public API for ABI store. If you use built in stores evrything should work out of the box. When using SQL store ensure that migrations complete on start. Additionally the AbiLoader will now also return an array of ABIs when accessing the cached data. These changes allows us to run over multiple ABIs when decoding a transaction, instead of failing when the cached ABI is wrong.

CopilotAIAug 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: 'evrything' should be 'everything'.

Suggested change
BREAKING! This version changes the public API for ABI store. If you use built in stores evrything should work out of the box. When using SQL store ensure that migrations complete on start. Additionally the AbiLoader will now also return an array of ABIs when accessing the cached data. These changes allows us to run over multiple ABIs when decoding a transaction, instead of failing when the cached ABI is wrong.
BREAKING! This version changes the public API for ABI store. If you use built in stores everything should work out of the box. When using SQL store ensure that migrations complete on start. Additionally the AbiLoader will now also return an array of ABIs when accessing the cached data. These changes allows us to run over multiple ABIs when decoding a transaction, instead of failing when the cached ABI is wrong.

Copilot uses AI. Check for mistakes.
@anastasiarods
anastasiarods merged commit a064c72 into mainAug 21, 2025
7 checks passed
@anastasiarods
anastasiarods deleted the add-support-for-fallbacks-in-decode branch August 21, 2025 08:14
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Ferossgp@anastasiarods