Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/upset-sides-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@onflow/react-sdk": minor
---

Fixed transaction management so that it clears up transaction state on error
16 changes: 12 additions & 4 deletions packages/react-sdk/src/provider/GlobalTransactionProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,20 @@ export const GlobalTransactionProvider: React.FC<
if (!txId) return

// Subscribe to transaction updates
const unsub = fcl.tx(txId).subscribe(txStatus => {
if (txStatus.status >= TransactionExecutionStatus.EXECUTED) {
// Transaction has been executed, reset the global transaction ID
const unsub = fcl.tx(txId).subscribe(
txStatus => {
if (txStatus.status >= TransactionExecutionStatus.EXECUTED) {
// Transaction has been executed, reset the global transaction ID
setTxId(null)
}
},
error => {
// Handle subscription errors
console.error("Transaction status subscription error:", error)
// Clear the transaction ID to prevent button from staying in processing state
setTxId(null)
}
})
)

return () => {
unsub()
Expand Down