fix: fail faster on transaction errors
This commit is contained in:
parent
0510dbae6c
commit
5a42cadefe
|
@ -22,8 +22,19 @@ export async function sendAndConfirmTransaction(
|
|||
let i = 4;
|
||||
for (;;) {
|
||||
const status = await connection.getSignatureStatus(signature);
|
||||
if (status == 'Confirmed') return;
|
||||
if (runtimeErrorOk && status == 'ProgramRuntimeError') return;
|
||||
switch (status) {
|
||||
case 'Confirmed':
|
||||
return;
|
||||
case 'ProgramRuntimeError':
|
||||
if (runtimeErrorOk) return;
|
||||
//fall through
|
||||
case 'GenericError':
|
||||
default:
|
||||
throw new Error(`Transaction ${signature} failed (${status})`);
|
||||
case 'SignatureNotFound':
|
||||
break;
|
||||
}
|
||||
|
||||
await sleep(500);
|
||||
if (--i < 0) {
|
||||
const duration = (Date.now() - start) / 1000;
|
||||
|
|
Loading…
Reference in New Issue