Closed AryanGodara closed 8 months ago
@ermvrs, I need your help with this The resulting block may be pending and I can't figure out a way to check this in the response.
By comparing the openAPI specs of the two possible responses (given below); I wrote the following code, as these fields are present only in pending blocks (according to the openAPI doc here)
// Check if the block is pending by looking for pending-specific properties
const isPendingBlock = (block: any): boolean => {
// Check for required pending block properties
return 'parent_hash' in block && 'timestamp' in block && 'sequencer_address' in block &&
'l1_gas_price' in block && 'starknet_version' in block;
};
if (isPendingBlock(response.result)) {
// If it's a pending block, return an error response
return {
code: 7979,
message: 'Starknet RPC error',
data: 'The block is still pending. Pending blocks cannot be processed.',
}
}
And here are the specs for the Block Responses:
"PENDING_BLOCK_WITH_TXS": {
"title": "Pending block with transactions",
"description": "The dynamic block being constructed by the sequencer. Note that this object will be deprecated upon decentralization.",
"allOf": [
{
"title": "Block body with transactions",
"$ref": "#/components/schemas/BLOCK_BODY_WITH_TXS"
},
{
"title": "Pending block header",
"$ref": "#/components/schemas/PENDING_BLOCK_HEADER"
}
],
"additionalProperties": false
},
"BLOCK_WITH_TXS": {
"title": "Block with transactions",
"description": "The block object",
"allOf": [
{
"title": "block with txs",
"type": "object",
"properties": {
"status": {
"title": "Status",
"$ref": "#/components/schemas/BLOCK_STATUS"
}
},
"required": [
"status"
]
},
{
"title": "Block header",
"$ref": "#/components/schemas/BLOCK_HEADER"
},
{
"title": "Block body with transactions",
"$ref": "#/components/schemas/BLOCK_BODY_WITH_TXS"
}
]
},
Please fix ci error
Please fix ci error
It was a suggestion to change a var
to const
.
I pushed new changes, but the CI isn't running after the new commit
Please do not use type any. and console
Please do not use type any. and console
Please do not use type any. and console Removed both of those. Console was debug statement, forgot to remove it by mistake
Resolves #68 Some of the fields are still missing; and I'm going through both the starknet and Eth APIs to see what those corresponding fields are.