Skip to content

Commit 6efda75

Browse files
committed
add ton reason for tx status check
1 parent e3f80a8 commit 6efda75

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/ton/src/TonBaseStaker.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -474,27 +474,32 @@ export class TonBaseStaker {
474474
const description = transaction.description as TransactionDescriptionGeneric
475475

476476
if (description.aborted) {
477-
return { status: 'failure', receipt: transaction }
477+
return { status: 'failure', receipt: transaction, reason: 'aborted' }
478478
}
479479

480480
if (description.computePhase.type === 'vm') {
481481
const compute = description.computePhase
482+
483+
if (description.actionPhase && description.actionPhase?.resultCode === 50 && compute.exitCode === 0) {
484+
return { status: 'failure', receipt: transaction, reason: 'out_of_storage' }
485+
}
486+
482487
if (compute.exitCode !== 0 || compute.success === false) {
483-
return { status: 'failure', receipt: transaction }
488+
return { status: 'failure', receipt: transaction, reason: 'compute_phase' }
484489
}
485490
}
486491

487492
if (description.actionPhase) {
488493
const action = description.actionPhase
489494

490495
if (action.success === false || action.valid === false) {
491-
return { status: 'failure', receipt: transaction }
496+
return { status: 'failure', receipt: transaction, reason: 'action_phase' }
492497
}
493498
}
494499

495500
// the transaction bounced if this is present (so likely it bounced due to error in the contract)
496501
if (description.bouncePhase) {
497-
return { status: 'failure', receipt: transaction }
502+
return { status: 'failure', receipt: transaction, reason: 'bounce_phase' }
498503
}
499504
}
500505

packages/ton/src/types.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,5 @@ export declare interface SignedTx {
141141
export interface TonTxStatus {
142142
status: 'success' | 'failure' | 'pending' | 'unknown'
143143
receipt: Transaction | null
144+
reason?: 'out_of_storage' | 'aborted' | 'compute_phase' | 'action_phase' | 'bounce_phase'
144145
}

0 commit comments

Comments
 (0)