-
Notifications
You must be signed in to change notification settings - Fork 806
Closed
Labels
Description
Describe the bug
A clear and concise description of what the bug is.
In the block class:
private setIdentifier(__identifier: BlockIdentifier) {
if (isString(__identifier)) {
if (isHex(__identifier)) {
this.hash = __identifier;
} else if (validBlockTags.includes(__identifier as BlockTag)) {
this.tag = __identifier;
}
} else if (isBigInt(__identifier)) {
this.hash = toHex(__identifier);
} else if (isNumber(__identifier)) {
this.number = __identifier;
} else {
this.tag = BlockTag.pending;
}
}
But in the type declaration, we get:
/**
* hex string and BN are detected as block hashes
* decimal string and number are detected as block numbers
* null appends nothing to the request url
*/
type BlockIdentifier = BlockNumber | BigNumberish;
To Reproduce
Steps to reproduce the behavior
Do a provider.call("some_method", {blockIdentifier: "1020230320")) -> it'll be converted to block pending
Additional resources:
Logs from our docker shows that we're trying to query a certain block number, but the request itself defaults to blocktag pending
9f51448426d8931694e51db5795e6","entry_point_selector":"0x1197c0cc3e1cbbe95556c0e2cfbfede9b831b095b4ab4f04f14ad7ff918a72f","calldata":[]},"block_id":"pending"}
2024-04-09 15:52:34 20: Contract not found: undefined
2024-04-09 15:52:34 ⚠️ Failed to get coinbase for block 0x0000000000000e0b - Error: RPC: starknet_call with params {"request":{"contract_address":"0x612fb5de32723a19b073b3aba348e48a3d9f51448426d8931694e51db5795e6","entry_point_selector":"0x15cb1934fc042b6b0bd8880dbf0571efa4896dcea2163e8f4797890445f6cc4","calldata":[]},"block_id":"pending"}
2024-04-09 15:52:34 20: Contract not found: undefined
2024-04-09 15:52:34 ⚠️ Failed to get base fee for block 0x0000000000000e0b - Error: RPC: starknet_call with params
try {
const response = (await KAKAROT.call("get_coinbase", [], {
// ⚠️ StarknetJS: blockIdentifier is a block hash if value is BigInt or HexString, otherwise it's a block number.
blockIdentifier: BigInt(blockNumber).toString(),
})) as {
coinbase: bigint;
};
coinbase = response.coinbase;
} catch (error) {
console.warn(
`⚠️ Failed to get coinbase for block ${blockNumber} - Error: ${error.message}`,
);
coinbase = BigInt(0);
}