(tradeHash: string)
| 269 | } |
| 270 | |
| 271 | async function fetchStatusPeriodically(tradeHash: string) { |
| 272 | const intervalId = setInterval(async () => { |
| 273 | try { |
| 274 | const data = await fetchStatus(tradeHash); |
| 275 | console.log("checks: ", data); // Handle or log the fetched data as needed |
| 276 | |
| 277 | if (data.status === "confirmed") { |
| 278 | clearInterval(intervalId); // Stop interval if status is confirmed |
| 279 | console.log("🎉 Transaction Completed!"); |
| 280 | } |
| 281 | } catch (e) { |
| 282 | // Surface intermittent API errors but keep polling for a bit |
| 283 | console.error("status poll error:", e); |
| 284 | } |
| 285 | }, 3000); |
| 286 | console.log("⏳ Transaction Pending"); |
| 287 | return intervalId; |
| 288 | } |
| 289 | |
| 290 | async function startStatusCheck(successfulTradeHash: string | undefined) { |
| 291 | if (successfulTradeHash) { |
no test coverage detected