nara-sdk 1.0.79 → 1.0.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/tx.ts +7 -10
package/package.json
CHANGED
package/src/tx.ts
CHANGED
|
@@ -196,19 +196,16 @@ export async function sendTx(
|
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
//
|
|
200
|
-
|
|
199
|
+
// Wait a couple of seconds for the validator to see and process the tx,
|
|
200
|
+
// then poll getSignatureStatuses every 2s until confirmed or timeout.
|
|
201
201
|
const TIMEOUT_MS = 20_000;
|
|
202
|
-
const POLL_INTERVAL_MS =
|
|
202
|
+
const POLL_INTERVAL_MS = 2_000;
|
|
203
|
+
const INITIAL_DELAY_MS = 2_000;
|
|
203
204
|
|
|
204
|
-
|
|
205
|
-
const currentBlockHeight = await connection.getBlockHeight("confirmed");
|
|
206
|
-
if (currentBlockHeight > lastValidBlockHeight) {
|
|
207
|
-
throw new Error(
|
|
208
|
-
`Transaction ${signature} expired: block height exceeded`
|
|
209
|
-
);
|
|
210
|
-
}
|
|
205
|
+
await new Promise((r) => setTimeout(r, INITIAL_DELAY_MS));
|
|
211
206
|
|
|
207
|
+
const startTime = Date.now();
|
|
208
|
+
while (Date.now() - startTime < TIMEOUT_MS) {
|
|
212
209
|
const statusResult = await connection.getSignatureStatuses([signature]);
|
|
213
210
|
const status = statusResult?.value?.[0];
|
|
214
211
|
|