Skip to content

Commit

Permalink
fix: undefined transaction GetTransactionResponse provide LibraryError
Browse files Browse the repository at this point in the history
  • Loading branch information
tabaktoni committed Aug 5, 2023
1 parent 4a8f4f9 commit f57e844
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/utils/responseParser/sequencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Intersection (sequencer response ∩ (∪ rpc responses))
*/

import { LibraryError } from '../../provider/errors';
import {
CallContractResponse,
CompiledContract,
Expand All @@ -19,6 +20,8 @@ import {
Sequencer,
SimulateTransactionResponse,
StateUpdateResponse,
TransactionFinalityStatus,
TransactionStatus,
} from '../../types';
import { isSierra } from '../contract';
import { toBigInt } from '../num';
Expand All @@ -41,6 +44,13 @@ export class SequencerAPIResponseParser extends ResponseParser {
public parseGetTransactionResponse(
res: Sequencer.GetTransactionResponse
): GetTransactionResponse {
if (
res.status === TransactionStatus.NOT_RECEIVED &&
res.finality_status === TransactionFinalityStatus.NOT_RECEIVED
) {
throw new LibraryError();
}

return {
...res,
calldata: 'calldata' in res.transaction ? (res.transaction.calldata as HexCalldata) : [],
Expand Down

0 comments on commit f57e844

Please sign in to comment.