Skip to content

Commit

Permalink
fix: sequencer getBlock response
Browse files Browse the repository at this point in the history
  • Loading branch information
tabaktoni committed Sep 29, 2022
1 parent 292037a commit 165bce7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/types/api/sequencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export namespace Sequencer {
status: Status;
gas_price: string;
sequencer_address: string;
starknet_version: string;
};

export type CallContractTransaction = Omit<
Expand Down
4 changes: 4 additions & 0 deletions src/types/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export interface GetBlockResponse {
parent_hash: string;
status: Status;
transactions: Array<string>;
gas_price?: string;
sequencer_address?: string;
starknet_version?: string;
transaction_receipts?: any;
}

export interface GetCodeResponse {
Expand Down
7 changes: 2 additions & 5 deletions src/utils/responseParser/sequencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ import { ResponseParser } from '.';
export class SequencerAPIResponseParser extends ResponseParser {
public parseGetBlockResponse(res: Sequencer.GetBlockResponse): GetBlockResponse {
return {
timestamp: res.timestamp,
block_hash: res.block_hash,
block_number: res.block_number,
...res,
new_root: res.state_root,
parent_hash: res.parent_block_hash,
status: res.status,
transactions: Object.values(res.transactions)
.map((value) => 'transaction_hash' in value && value.transaction_hash)
.filter(Boolean) as Array<string>,
Expand Down Expand Up @@ -71,7 +68,7 @@ export class SequencerAPIResponseParser extends ResponseParser {
...('transaction_index' in res && { transaction_index: res.transaction_index }),
...('execution_resources' in res && { execution_resources: res.execution_resources }),
...('l1_to_l2_consumed_message' in res && {
l1_to_l2_consumed_message: res['l1_to_l2_consumed_message'],
l1_to_l2_consumed_message: res.l1_to_l2_consumed_message,
}),
...('transaction_failure_reason' in res && {
transaction_failure_reason: res.transaction_failure_reason,
Expand Down

0 comments on commit 165bce7

Please sign in to comment.