Skip to content

Commit

Permalink
Fix response decoding for debug trace api
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiarods committed Jan 5, 2024
1 parent eb73069 commit 2d920d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
14 changes: 7 additions & 7 deletions packages/transaction-decoder/src/helpers/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export function nodeToTraceLog(node: TraceLogTree, path: number[]): TraceLog | u
subtraces: node.calls?.length ?? 0,
traceAddress: path,
result: {
output: node.output,
gasUsed: node.gasUsed,
output: node.output ?? '0x0',
gasUsed: BigInt(node.gasUsed),
},
}

Expand All @@ -24,9 +24,9 @@ export function nodeToTraceLog(node: TraceLogTree, path: number[]): TraceLog | u
callType: node.type.toLowerCase() as CallType,
from: node.from,
to: node.to,
gas: node.gas,
gas: BigInt(node.gas),
input: node.input,
value: node.value ?? BigInt('0x0'),
value: BigInt(node.value ?? '0x0'),
},
}
break
Expand All @@ -36,8 +36,8 @@ export function nodeToTraceLog(node: TraceLogTree, path: number[]): TraceLog | u
type: 'create',
action: {
from: node.from,
gas: node.gas,
value: node.value ?? BigInt('0x0'),
gas: BigInt(node.gas),
value: BigInt(node.value ?? '0x0'),
},
}
break
Expand All @@ -48,7 +48,7 @@ export function nodeToTraceLog(node: TraceLogTree, path: number[]): TraceLog | u
action: {
refundAddress: node.to,
address: node.from,
balance: node.value ?? BigInt('0x0'),
balance: BigInt(node.value ?? '0x0'),
},
}
break
Expand Down
8 changes: 4 additions & 4 deletions packages/transaction-decoder/src/schema/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ const DebugCallType = Schema.literal(
'REWARD',
)

const EthDebugTraceBase = Schema.struct({
gas: bigintFromString,
export const EthDebugTraceBase = Schema.struct({
gas: Schema.string,
to: Address,
from: Address,
gasUsed: bigintFromString,
gasUsed: Schema.string,
input: Schema.string,
type: DebugCallType,
value: Schema.optional(bigintFromString),
value: Schema.optional(Schema.string),
output: Schema.string,
})

Expand Down
6 changes: 2 additions & 4 deletions packages/transaction-decoder/src/transaction-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ export const getTrace = (hash: string, chainID: number) =>
if (trace == null) return []
return trace
},
catch: () => new RPCFetchError('Get trace'),
catch: (e) => new RPCFetchError(e),
}),
)

const result = trace as TraceLogTree

const transformedTrace = transformTraceTree(result)
const transformedTrace = transformTraceTree(trace as TraceLogTree)

return transformedTrace
}
Expand Down

0 comments on commit 2d920d7

Please sign in to comment.