@@ -10,21 +10,22 @@ import {
1010 CompiledContract ,
1111 DeployContractPayload ,
1212 Endpoints ,
13+ EstimateFeeResponse ,
1314 GetBlockResponse ,
1415 GetCodeResponse ,
1516 GetContractAddressesResponse ,
1617 GetTransactionResponse ,
1718 GetTransactionStatusResponse ,
1819 GetTransactionTraceResponse ,
1920 Invocation ,
20- TransactionReceipt ,
21+ TransactionReceiptResponse ,
2122} from '../types' ;
2223import { getSelectorFromName } from '../utils/hash' ;
2324import { parse , stringify } from '../utils/json' ;
2425import { BigNumberish , bigNumberishArrayToDecimalStringArray , toBN , toHex } from '../utils/number' ;
2526import { compressProgram , randomAddress } from '../utils/stark' ;
2627import { ProviderInterface } from './interface' ;
27- import { BlockIdentifier , getFormattedBlockIdentifier , txIdentifier } from './utils' ;
28+ import { BlockIdentifier , getFormattedBlockIdentifier } from './utils' ;
2829
2930type NetworkName = 'mainnet-alpha' | 'goerli-alpha' ;
3031
@@ -153,6 +154,17 @@ export class Provider implements ProviderInterface {
153154 try {
154155 const { data } = await axios . request < Endpoints [ T ] [ 'RESPONSE' ] > ( {
155156 method,
157+ transformResponse :
158+ endpoint === 'estimate_fee'
159+ ? ( res ) : EstimateFeeResponse => {
160+ return parse ( res , ( _ , v ) => {
161+ if ( v && typeof v === 'bigint' ) {
162+ return toBN ( v . toString ( ) ) ;
163+ }
164+ return v ;
165+ } ) ;
166+ }
167+ : axios . defaults . transformResponse ,
156168 url : urljoin ( baseUrl , endpoint , queryString ) ,
157169 data : stringify ( request ) ,
158170 headers,
@@ -272,22 +284,12 @@ export class Provider implements ProviderInterface {
272284 * [Reference] (https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L104-L111)
273285 *
274286 * @param txHash
275- * @param txId
276287 * @returns the transaction receipt object
277288 */
278289
279- public async getTransactionReceipt ( {
280- txHash,
281- txId,
282- } : {
283- txHash ?: BigNumberish ;
284- txId ?: BigNumberish ;
285- } ) : Promise < TransactionReceipt > {
286- const { data } = await axios . get < TransactionReceipt > (
287- urljoin ( this . feederGatewayUrl , 'get_transaction_receipt' , `?${ txIdentifier ( txHash , txId ) } ` )
288- ) ;
289-
290- return data ;
290+ public async getTransactionReceipt ( txHash : BigNumberish ) : Promise < TransactionReceiptResponse > {
291+ const txHashHex = toHex ( toBN ( txHash ) ) ;
292+ return this . fetchEndpoint ( 'get_transaction_receipt' , { transactionHash : txHashHex } ) ;
291293 }
292294
293295 /**
0 commit comments