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

Fix crash in experimental erc20 resolver when address is empty. We provide an empty address when we decode logs for errors
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { erc20Abi, getAddress, getContract } from 'viem'

const getLocalFragments = (service: PublicClient, { address, chainId }: RequestModel.GetContractABIStrategy) =>
Effect.gen(function* () {
if (!address)
return yield* Effect.fail(new RequestModel.ResolveStrategyABIError('local-strategy', address, chainId))

const client = yield* service
.getPublicClient(chainId)
.pipe(
Expand All @@ -13,10 +16,16 @@ const getLocalFragments = (service: PublicClient, { address, chainId }: RequestM
),
)

const inst = getContract({
abi: erc20Abi,
address: getAddress(address),
client: client.client,
const inst = yield* Effect.try({
try: () =>
getContract({
abi: erc20Abi,
address: getAddress(address),
client: client.client,
}),
catch: () => {
throw new RequestModel.ResolveStrategyABIError('local-strategy', address, chainId)
},
})

const decimals = yield* Effect.tryPromise({
Expand Down
Loading