Skip to content

Commit f78b97a

Browse files
committed
fix: wait for transaction receipt
1 parent 11ccfc1 commit f78b97a

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/mixin/AccountCall.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ export default class AccountCall extends Vue {
156156
// Stop any existing polling
157157
this.stopReceiptPolling();
158158

159-
// Set timeout (5 blocks * ~2 seconds per block = 10 seconds)
160-
const timeoutMs = 5 * 2000;
159+
// Set timeout to 60 seconds (30 blocks * ~2 seconds per block)
160+
// This gives enough time for mainnet transactions which can take longer
161+
const timeoutMs = 30 * 2000;
161162
const startTime = Date.now();
162163

163164
// Poll every 1000ms
@@ -169,15 +170,26 @@ export default class AccountCall extends Vue {
169170
this.receipt = receipt;
170171
this.receiptStatus = receipt.reverted ? "completed" : "completed";
171172
this.stopReceiptPolling();
172-
} else {
173-
// Check timeout
174-
if (Date.now() - startTime > timeoutMs) {
175-
this.receiptStatus = "error";
176-
this.stopReceiptPolling();
177-
}
173+
return;
174+
}
175+
176+
// If no receipt yet, check if transaction exists
177+
// This helps distinguish between "not yet included" vs "doesn't exist"
178+
try {
179+
const tx = await this.$connex.thor.transaction(txid).get();
180+
// Transaction exists but receipt not ready yet - continue polling
181+
} catch (txError: any) {
182+
// Transaction doesn't exist - might be a real error or still pending
183+
// Continue polling anyway until timeout
184+
}
185+
186+
// Check timeout
187+
if (Date.now() - startTime > timeoutMs) {
188+
this.receiptStatus = "error";
189+
this.stopReceiptPolling();
178190
}
179191
} catch (error: any) {
180-
// Transaction not found yet, continue polling unless timeout
192+
// Error getting receipt - continue polling unless timeout
181193
if (Date.now() - startTime > timeoutMs) {
182194
this.receiptStatus = "error";
183195
this.stopReceiptPolling();

0 commit comments

Comments
 (0)