MCPcopy Create free account
hub / github.com/0xProject/0x-examples / fetchStatusPeriodically

Function fetchStatusPeriodically

gasless-v2-headless-example/index.ts:271–288  ·  view source on GitHub ↗
(tradeHash: string)

Source from the content-addressed store, hash-verified

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) {

Callers 1

startStatusCheckFunction · 0.85

Calls 1

fetchStatusFunction · 0.85

Tested by

no test coverage detected