fix: Update signature status result type

This commit is contained in:
Tyera Eulberg
2019-04-10 13:15:41 -07:00
committed by Michael Vines
parent f2b38bcc56
commit 7f72bbeba3
3 changed files with 16 additions and 16 deletions

View File

@@ -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'})
])
])
);
/**

View File

@@ -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})`);
}