There was an error while loading. Please reload this page.
1 parent 62b1b9f commit 7af5632Copy full SHA for 7af5632
src/ton/helper/index.ts
@@ -0,0 +1,14 @@
1
+import { Trace, Transaction } from '@ton-api/client'
2
+
3
+export const getTransactionFromTrace = (trace: Trace, path: number[]): { transaction: Transaction } | { error: string } => {
4
+ const [id, ...remainingPath] = path
5
+ if (id == null) return { error: 'Invalid path provided' }
6
7
+ const childTrace = trace.children?.[id]
8
+ if (!childTrace) return { error: 'Path not found in trace' }
9
+ if (remainingPath.length === 0) {
10
+ if (!childTrace.transaction) return { error: 'Transaction not found in trace' }
11
+ return { transaction: childTrace.transaction }
12
+ }
13
+ return getTransactionFromTrace(childTrace, remainingPath)
14
+}
0 commit comments