fn find_priority_op_by_hash(&self, hash: &[u8]) -> QueryResult<Option<TxByHashResponse>> {
        // TODO: Maybe move the transformations to api_server?
        let tx: Option<StoredExecutedPriorityOperation> = executed_priority_operations::table
            .filter(executed_priority_operations::eth_hash.eq(hash))
            .first(self.0.conn())
            .optional()?;

        if let Some(tx) = tx {
            let operation = tx.operation;
            let block_number = tx.block_number;
            let created_at = tx.created_at.format("%Y-%m-%dT%H:%M:%S%.6f").to_string();

            let tx_type = operation["type"].as_str().unwrap_or("unknown type");
            let tx_token = operation["priority_op"]["token"]
                .as_i64()
                .expect("must be here");

            let (tx_from, tx_to, tx_fee, tx_amount) = match tx_type {
                "Deposit" => (
                    operation["priority_op"]["from"]
                        .as_str()
                        .unwrap_or("unknown from")
                        .to_string(),
                    operation["priority_op"]["to"]
                        .as_str()
                        .unwrap_or("unknown to")
                        .to_string(),
                    None,
                    operation["priority_op"]["amount"]
                        .as_str()
                        .unwrap_or("unknown amount"),
                ),
                "FullExit" => (
                    operation["priority_op"]["eth_address"]
                        .as_str()
                        .unwrap_or("unknown from")
                        .to_string(),
                    operation["priority_op"]["eth_address"]
                        .as_str()
                        .unwrap_or("unknown to")
                        .to_string(),
                    None,
                    operation["withdraw_amount"]
                        .as_str()
                        .unwrap_or("unknown amount"),
                ),
                &_ => (
                    "unknown from".to_string(),
                    "unknown to".to_string(),
                    Some("unknown fee".to_string()),
                    "unknown amount",
                ),
            };

            return Ok(Some(TxByHashResponse {
                tx_type: tx_type.to_string(),
                from: tx_from,
                to: tx_to,
                token: tx_token as i32,
                amount: tx_amount.to_string(),
                fee: tx_fee,
                block_number,
                nonce: -1,
                created_at,
                fail_reason: None,
                tx: operation,
            }));
        };

        Ok(None)
    }
/// Helper method for `get_tx_by_hash` which attempts to find a transaction
/// in the list of executed priority operations.
Helper method for `get_tx_by_hash` which attempts to find a transaction
in the list of executed priority operations.
Helper method for ` get_tx_by_hash ` which attempts to find a transaction in the list of executed priority operations .
fn find_priority_op_by_hash(&self, hash: &[u8]) -> QueryResult<Option<TxByHashResponse>> {
        // TODO: Maybe move the transformations to api_server?
        let tx: Option<StoredExecutedPriorityOperation> = executed_priority_operations::table
            .filter(executed_priority_operations::eth_hash.eq(hash))
            .first(self.0.conn())
            .optional()?;
        if let Some(tx) = tx {
            let operation = tx.operation;
            let block_number = tx.block_number;
            let created_at = tx.created_at.format("%Y-%m-%dT%H:%M:%S%.6f").to_string();
            let tx_type = operation["type"].as_str().unwrap_or("unknown type");
            let tx_token = operation["priority_op"]["token"]
                .as_i64()
                .expect("must be here");
            let (tx_from, tx_to, tx_fee, tx_amount) = match tx_type {
                "Deposit" => (
                    operation["priority_op"]["from"]
                        .as_str()
                        .unwrap_or("unknown from")
                        .to_string(),
                    operation["priority_op"]["to"]
                        .as_str()
                        .unwrap_or("unknown to")
                        .to_string(),
                    None,
                    operation["priority_op"]["amount"]
                        .as_str()
                        .unwrap_or("unknown amount"),
                ),
                "FullExit" => (
                    operation["priority_op"]["eth_address"]
                        .as_str()
                        .unwrap_or("unknown from")
                        .to_string(),
                    operation["priority_op"]["eth_address"]
                        .as_str()
                        .unwrap_or("unknown to")
                        .to_string(),
                    None,
                    operation["withdraw_amount"]
                        .as_str()
                        .unwrap_or("unknown amount"),
                ),
                &_ => (
                    "unknown from".to_string(),
                    "unknown to".to_string(),
                    Some("unknown fee".to_string()),
                    "unknown amount",
                ),
            };
            return Ok(Some(TxByHashResponse {
                tx_type: tx_type.to_string(),
                from: tx_from,
                to: tx_to,
                token: tx_token as i32,
                amount: tx_amount.to_string(),
                fee: tx_fee,
                block_number,
                nonce: -1,
                created_at,
                fail_reason: None,
                tx: operation,
            }));
        };
        Ok(None)
    }
fn find_priority_op_by_hash ( & self , hash : & [ u8 ] ) -> QueryResult < Option < TxByHashResponse > > { // TODO: Maybe move the transformations to api_server? let tx : Option < StoredExecutedPriorityOperation > = executed_priority_operations :: table . filter ( executed_priority_operations :: eth_hash . eq ( hash ) ) . first ( self . 0 . conn ( ) ) . optional ( ) ? ; if let Some ( tx ) = tx { let operation = tx . operation ; let block_number = tx . block_number ; let created_at = tx . created_at . format ( " " ) . to_string ( ) ; let tx_type = operation [ " " ] . as_str ( ) . unwrap_or ( " " ) ; let tx_token = operation [ " " ] [ " " ] . as_i64 ( ) . expect ( " " ) ; let ( tx_from , tx_to , tx_fee , tx_amount ) = match tx_type { " " => ( operation [ " " ] [ " " ] . as_str ( ) . unwrap_or ( " " ) . to_string ( ) , operation [ " " ] [ " " ] . as_str ( ) . unwrap_or ( " " ) . to_string ( ) , None , operation [ " " ] [ " " ] . as_str ( ) . unwrap_or ( " " ) , ) , " " => ( operation [ " " ] [ " " ] . as_str ( ) . unwrap_or ( " " ) . to_string ( ) , operation [ " " ] [ " " ] . as_str ( ) . unwrap_or ( " " ) . to_string ( ) , None , operation [ " " ] . as_str ( ) . unwrap_or ( " " ) , ) , & _ => ( " " . to_string ( ) , " " . to_string ( ) , Some ( " " . to_string ( ) ) , " " , ) , } ; return Ok ( Some ( TxByHashResponse { tx_type : tx_type . to_string ( ) , from : tx_from , to : tx_to , token : tx_token as i32 , amount : tx_amount . to_string ( ) , fee : tx_fee , block_number , nonce : - 1 , created_at , fail_reason : None , tx : operation , } ) ) ; } ; Ok ( None ) }
Helper method for `get_tx_by_hash` which attempts to find a transaction
in the list of executed priority operations.
Helper method for ` get_tx_by_hash ` which attempts to find a transaction in the list of executed priority operations .
&self
hash
&[u8]