MCPcopy Create free account
hub / github.com/clockwork-xyz/examples / waitForThreadExec

Function waitForThreadExec

utils/lib/index.ts:36–50  ·  view source on GitHub ↗
(clockworkProvider, thread: PublicKey, maxWait: number = 60)

Source from the content-addressed store, hash-verified

34
35let lastThreadExec = BigInt(0);
36const waitForThreadExec = async (clockworkProvider, thread: PublicKey, maxWait: number = 60) => {
37 let i = 1;
38 while (true) {
39 const execContext = (await clockworkProvider.getThreadAccount(thread)).execContext;
40 if (execContext) {
41 if (lastThreadExec.toString() == "0" || execContext.lastExecAt > lastThreadExec) {
42 lastThreadExec = execContext.lastExecAt;
43 break;
44 }
45 }
46 if (i == maxWait) throw Error("Timeout");
47 i += 1;
48 await new Promise((r) => setTimeout(r, i * 1000));
49 }
50}
51
52export {
53 print_address,

Callers 3

distributor.tsFile · 0.50
counter.tsFile · 0.50
payments.tsFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected