Skip to content

Commit 7af5632

Browse files
committed
feat: ton helper
1 parent 62b1b9f commit 7af5632

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/ton/helper/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)