feat: add err field to status results
This commit is contained in:
committed by
Michael Vines
parent
3120e681d6
commit
b0316f82b5
@@ -39,7 +39,7 @@ export async function sendAndConfirmRawTransaction(
|
||||
}
|
||||
}
|
||||
|
||||
if (status && status.status && 'Ok' in status.status) {
|
||||
if (status && !status.err) {
|
||||
return signature;
|
||||
}
|
||||
|
||||
|
@@ -66,9 +66,16 @@ async function _sendAndConfirmTransaction(
|
||||
await sleep((500 * DEFAULT_TICKS_PER_SLOT) / NUM_TICKS_PER_SECOND);
|
||||
}
|
||||
|
||||
if (status && 'Ok' in status.status) {
|
||||
break;
|
||||
if (status) {
|
||||
if (!status.err) {
|
||||
break;
|
||||
} else if (!('AccountInUse' in status.err)) {
|
||||
throw new Error(
|
||||
`Transaction ${signature} failed (${JSON.stringify(status)})`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (--sendRetries <= 0) {
|
||||
const duration = (Date.now() - start) / 1000;
|
||||
throw new Error(
|
||||
@@ -78,12 +85,6 @@ async function _sendAndConfirmTransaction(
|
||||
);
|
||||
}
|
||||
|
||||
if (status && status.status.Err && !('AccountInUse' in status.status.Err)) {
|
||||
throw new Error(
|
||||
`Transaction ${signature} failed (${JSON.stringify(status)})`,
|
||||
);
|
||||
}
|
||||
|
||||
// Retry in 0..100ms to try to avoid another AccountInUse collision
|
||||
await sleep(Math.random() * 100);
|
||||
}
|
||||
|
Reference in New Issue
Block a user