MCPcopy Create free account
hub / github.com/ChainSecurity/deployment_validation / get_block_number_for_tx

Function get_block_number_for_tx

lib/web3.rs:372–392  ·  view source on GitHub ↗
(
    config: &DVFConfig,
    transaction_hash: &str,
)

Source from the content-addressed store, hash-verified

370}
371
372pub fn get_block_number_for_tx(
373 config: &DVFConfig,
374 transaction_hash: &str,
375) -> Result<u64, ValidationError> {
376 let request_body = json!({
377 "jsonrpc": "2.0",
378 "method": "eth_getTransactionByHash",
379 "params": [transaction_hash],
380 "id": 1
381 });
382 let result = send_blocking_web3_post(config, &request_body)?;
383
384 if let Some(block_number) = result.get("blockNumber") {
385 let block_number =
386 u64::from_str_radix(block_number.as_str().unwrap().trim_start_matches("0x"), 16)?;
387 return Ok(block_number);
388 }
389 Err(ValidationError::Error(
390 "Invalid response from eth_getTransactionByHash".to_string(),
391 ))
392}
393
394fn get_deployment_tx_from_graphql(
395 config: &DVFConfig,

Callers 1

get_deploymentFunction · 0.85

Calls 2

send_blocking_web3_postFunction · 0.85
to_stringMethod · 0.80

Tested by

no test coverage detected