Skip to content

Commit 806eb7d

Browse files
committed
fix: transaction receipt
1 parent 5a40cd6 commit 806eb7d

File tree

3 files changed

+15
-24
lines changed

3 files changed

+15
-24
lines changed

src/provider/default.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ import {
1717
GetTransactionStatusResponse,
1818
GetTransactionTraceResponse,
1919
Invocation,
20-
TransactionReceipt,
20+
TransactionReceiptResponse,
2121
} from '../types';
2222
import { getSelectorFromName } from '../utils/hash';
2323
import { parse, stringify } from '../utils/json';
2424
import { BigNumberish, bigNumberishArrayToDecimalStringArray, toBN, toHex } from '../utils/number';
2525
import { compressProgram, randomAddress } from '../utils/stark';
2626
import { ProviderInterface } from './interface';
27-
import { BlockIdentifier, getFormattedBlockIdentifier, txIdentifier } from './utils';
27+
import { BlockIdentifier, getFormattedBlockIdentifier } from './utils';
2828

2929
type NetworkName = 'mainnet-alpha' | 'goerli-alpha';
3030

@@ -272,22 +272,12 @@ export class Provider implements ProviderInterface {
272272
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L104-L111)
273273
*
274274
* @param txHash
275-
* @param txId
276275
* @returns the transaction receipt object
277276
*/
278277

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;
278+
public async getTransactionReceipt(txHash: BigNumberish): Promise<TransactionReceiptResponse> {
279+
const txHashHex = toHex(toBN(txHash));
280+
return this.fetchEndpoint('get_transaction_receipt', { transactionHash: txHashHex });
291281
}
292282

293283
/**

src/provider/interface.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
GetTransactionResponse,
1111
GetTransactionStatusResponse,
1212
Invocation,
13-
TransactionReceipt,
13+
TransactionReceiptResponse,
1414
} from '../types';
1515
import type { BigNumberish } from '../utils/number';
1616
import { BlockIdentifier } from './utils';
@@ -109,13 +109,7 @@ export abstract class ProviderInterface {
109109
*/
110110
public abstract getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
111111

112-
public abstract getTransactionReceipt({
113-
txHash,
114-
txId,
115-
}: {
116-
txHash?: BigNumberish;
117-
txId?: BigNumberish;
118-
}): Promise<TransactionReceipt>;
112+
public abstract getTransactionReceipt(txHash: BigNumberish): Promise<TransactionReceiptResponse>;
119113

120114
/**
121115
* Deploys a given compiled contract (json) to starknet

src/types/api.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ export type Endpoints = {
4343
REQUEST: never;
4444
RESPONSE: GetTransactionTraceResponse;
4545
};
46+
get_transaction_receipt: {
47+
QUERY: {
48+
transactionHash: string;
49+
};
50+
REQUEST: never;
51+
RESPONSE: TransactionReceiptResponse;
52+
};
4653
get_storage_at: {
4754
QUERY: {
4855
contractAddress: string;
@@ -217,7 +224,7 @@ export type AddTransactionResponse = {
217224
address?: string;
218225
};
219226

220-
export type TransactionReceipt = {
227+
export type TransactionReceiptResponse = {
221228
status: Status;
222229
transaction_hash: string;
223230
transaction_index: number;

0 commit comments

Comments
 (0)