Skip to content

Commit 68f00d3

Browse files
committed
fix: simulate decoding
1 parent 3a7fba4 commit 68f00d3

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

.changeset/poor-cooks-fold.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"viem": patch
3+
---
4+
5+
Fixed `simulate` data decoding.

src/actions/public/simulate.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,14 @@ export async function simulate<
242242
const logs = call.logs?.map((log) => formatLog(log))
243243
const status = call.status === '0x1' ? 'success' : 'failure'
244244

245-
const result = abi
246-
? decodeFunctionResult({
247-
abi,
248-
data,
249-
functionName,
250-
})
251-
: null
245+
const result =
246+
abi && status === 'success'
247+
? decodeFunctionResult({
248+
abi,
249+
data,
250+
functionName,
251+
})
252+
: null
252253

253254
const error = (() => {
254255
if (status === 'success') return undefined

0 commit comments

Comments
 (0)