fix: Update signature status result type
This commit is contained in:
committed by
Michael Vines
parent
f2b38bcc56
commit
7f72bbeba3
@@ -124,13 +124,13 @@ const ConfirmTransactionRpcResult = jsonRpcResult('boolean');
|
||||
* Expected JSON RPC response for the "getSignatureStatus" message
|
||||
*/
|
||||
const GetSignatureStatusRpcResult = jsonRpcResult(
|
||||
struct.enum([
|
||||
'AccountInUse',
|
||||
'Confirmed',
|
||||
'GenericFailure',
|
||||
'ProgramRuntimeError',
|
||||
'SignatureNotFound',
|
||||
]),
|
||||
struct.union([
|
||||
'null',
|
||||
struct.union([
|
||||
struct({Ok: 'null'}),
|
||||
struct({Err: 'string'})
|
||||
])
|
||||
])
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -28,7 +28,7 @@ export async function sendAndConfirmTransaction(
|
||||
let statusRetries = 6;
|
||||
for (;;) {
|
||||
status = await connection.getSignatureStatus(signature);
|
||||
if (status !== 'SignatureNotFound') {
|
||||
if (status) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export async function sendAndConfirmTransaction(
|
||||
await sleep((500 * DEFAULT_TICKS_PER_SLOT) / NUM_TICKS_PER_SECOND);
|
||||
}
|
||||
|
||||
if (status === 'Confirmed') {
|
||||
if ('Ok' in status) {
|
||||
break;
|
||||
}
|
||||
if (--sendRetries <= 0) {
|
||||
@@ -51,7 +51,7 @@ export async function sendAndConfirmTransaction(
|
||||
);
|
||||
}
|
||||
|
||||
if (status !== 'AccountInUse' && status !== 'SignatureNotFound') {
|
||||
if ('Err' in status && !status.includes('AccountInUse')) {
|
||||
throw new Error(`Transaction ${signature} failed (${status})`);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user