Skip to content

Commit

Permalink
feat: add get_block_traces support in sequencer
Browse files Browse the repository at this point in the history
  • Loading branch information
irisdv committed Jan 16, 2023
1 parent be7b792 commit b8dec62
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/provider/sequencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,4 +587,11 @@ export class SequencerProvider implements ProviderInterface {
}
).then(this.responseParser.parseFeeSimulateTransactionResponse);
}

// consider adding an optional trace retrieval parameter to the getBlock method
public async getBlockTraces(
blockIdentifier: BlockIdentifier = this.blockIdentifier
): Promise<Sequencer.BlockTransactionTracesResponse> {
return this.fetchEndpoint('get_block_traces', { blockIdentifier });
}
}
11 changes: 11 additions & 0 deletions src/types/api/sequencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ export namespace Sequencer {

export type EstimateFeeResponseBulk = AllowArray<EstimateFeeResponse>;

export type BlockTransactionTracesResponse = Array<
TransactionTraceResponse & { transaction_hash: string }
>;

export type Endpoints = {
get_contract_addresses: {
QUERY: never;
Expand Down Expand Up @@ -394,5 +398,12 @@ export namespace Sequencer {
REQUEST: EstimateFeeRequestBulk;
RESPONSE: EstimateFeeResponseBulk;
};
get_block_traces: {
QUERY: {
blockIdentifier: BlockIdentifier;
};
REQUEST: never;
RESPONSE: BlockTransactionTracesResponse;
};
};
}
41 changes: 41 additions & 0 deletions www/docs/API/Provider/sequencerProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,44 @@ Gets the transaction trace from a tx hash.
};
}
```

---

### getBlockTraces()

provider.**getBlockTraces**(blockIdentifier) => _Promise < BlockTransactionTracesResponse >_

Gets the transaction traces of an entire block

###### _BlockTransactionTracesResponse_

```typescript
Array<TransactionTraceResponse & { transaction_hash: string }>
{
TransactionTraceResponse: {
validate_invocation?: FunctionInvocation;
function_invocation?: FunctionInvocation;
fee_transfer_invocation?: FunctionInvocation;
signature: Signature;
}
FunctionInvocation: {
caller_address: string;
contract_address: string;
calldata: {
[inputName: string]: string | string[] | { type: 'struct'; [k: string]: BigNumberish };
};
call_type?: string;
class_hash?: string;
selector?: string;
entry_point_type?: EntryPointType;
result: Array<any>;
execution_resources: ExecutionResources;
internal_calls: Array<FunctionInvocation>;
events: Array<any>;
messages: Array<any>;
};
}
```

0 comments on commit b8dec62

Please sign in to comment.