diff --git a/src/provider/rpc.ts b/src/provider/rpc.ts index a89fcd4a0..46fd35a44 100644 --- a/src/provider/rpc.ts +++ b/src/provider/rpc.ts @@ -183,9 +183,7 @@ export class RpcProvider implements ProviderInterface { } public async getTransactionReceipt(txHash: string): Promise { - return this.fetchEndpoint('starknet_getTransactionReceipt', { transaction_hash: txHash }).then( - this.responseParser.parseGetTransactionReceiptResponse - ); + return this.fetchEndpoint('starknet_getTransactionReceipt', { transaction_hash: txHash }); } public async getClass(classHash: RPC.Felt): Promise { @@ -356,9 +354,9 @@ export class RpcProvider implements ProviderInterface { // eslint-disable-next-line no-await-in-loop const res = await this.getTransactionReceipt(txHash); - if (successStates.includes(res.status)) { + if (res.status && successStates.includes(res.status)) { onchain = true; - } else if (errorStates.includes(res.status)) { + } else if (res.status && errorStates.includes(res.status)) { const message = res.status; const error = new Error(message) as Error & { response: any }; error.response = res; diff --git a/src/types/provider.ts b/src/types/provider.ts index 086860035..4f04e9c02 100644 --- a/src/types/provider.ts +++ b/src/types/provider.ts @@ -57,7 +57,7 @@ export type GetTransactionReceiptResponse = export interface CommonTransactionReceiptResponse { transaction_hash: string; - status: Status; + status?: Status; actual_fee?: string; status_data?: string; } diff --git a/src/utils/responseParser/rpc.ts b/src/utils/responseParser/rpc.ts index 5c57fb83b..5fcf64799 100644 --- a/src/utils/responseParser/rpc.ts +++ b/src/utils/responseParser/rpc.ts @@ -6,7 +6,6 @@ import { CallContractResponse, EstimateFeeResponse, GetBlockResponse, - GetTransactionReceiptResponse, GetTransactionResponse, } from '../../types'; import { RPC } from '../../types/api'; @@ -21,15 +20,14 @@ type GetTransactionByHashResponse = RPC.GetTransactionByHashResponse & { [key: string]: any; }; -type TransactionReceipt = RPC.TransactionReceipt & { - [key: string]: any; -}; - export class RPCResponseParser implements Omit< ResponseParser, - 'parseDeclareContractResponse' | 'parseDeployContractResponse' | 'parseInvokeFunctionResponse' + | 'parseDeclareContractResponse' + | 'parseDeployContractResponse' + | 'parseInvokeFunctionResponse' + | 'parseGetTransactionReceiptResponse' > { public parseGetBlockResponse(res: RpcGetBlockResponse): GetBlockResponse { @@ -56,20 +54,6 @@ export class RPCResponseParser }; } - public parseGetTransactionReceiptResponse( - res: TransactionReceipt - ): GetTransactionReceiptResponse { - return { - transaction_hash: res.transaction_hash, - actual_fee: res.actual_fee, - status: res.status, - status_data: res.status_data, - messages_sent: res.messages_sent, - l1_origin_message: res.l1_origin_message, - events: res.events, - }; - } - public parseFeeEstimateResponse(res: RPC.EstimateFeeResponse): EstimateFeeResponse { return { overall_fee: toBN(res.overall_fee),