pub async fn add_operation<'e>(
    executor: impl Executor<'e, Database = Db>,
    request_id: Option<&str>,
    address: &str,
    denom: &Identifier,
    amount: U256,
    operation_type: &OperationType,
    transaction_hash: &str,
) -> Result<()> {
    let operation_type = Json(operation_type);

    let amount_bytes: [u8; 32] = amount.into();

    let rows_affected = sqlx::query(
        "INSERT INTO operations (request_id, address, denom, amount, operation_type, transaction_hash) VALUES ($1, $2, $3, $4, $5, $6)",
    )
    .bind(request_id)
    .bind(address)
    .bind(denom.to_string())
    .bind(amount_bytes.to_vec())
    .bind(operation_type)
    .bind(transaction_hash)
    .execute(executor)
    .await
    .context("unable to add new account operation to database")?
    .rows_affected();

    ensure!(
        rows_affected == 1,
        "rows_affected should be equal to 1 when adding a new account operation"
    );

    Ok(())
}
/// Adds an account operation to database
Adds an account operation to database
Adds an account operation to database
pub async fn add_operation<'e>(
    executor: impl Executor<'e, Database = Db>,
    request_id: Option<&str>,
    address: &str,
    denom: &Identifier,
    amount: U256,
    operation_type: &OperationType,
    transaction_hash: &str,
) -> Result<()> {
    let operation_type = Json(operation_type);
    let amount_bytes: [u8; 32] = amount.into();
    let rows_affected = sqlx::query(
        "INSERT INTO operations (request_id, address, denom, amount, operation_type, transaction_hash) VALUES ($1, $2, $3, $4, $5, $6)",
    )
    .bind(request_id)
    .bind(address)
    .bind(denom.to_string())
    .bind(amount_bytes.to_vec())
    .bind(operation_type)
    .bind(transaction_hash)
    .execute(executor)
    .await
    .context("unable to add new account operation to database")?
    .rows_affected();
    ensure!(
        rows_affected == 1,
        "rows_affected should be equal to 1 when adding a new account operation"
    );
    Ok(())
}
pub async fn add_operation < ' e > ( executor : impl Executor < ' e , Database = Db > , request_id : Option < & str > , address : & str , denom : & Identifier , amount : U256 , operation_type : & OperationType , transaction_hash : & str , ) -> Result < ( ) > { let operation_type = Json ( operation_type ) ; let amount_bytes : [ u8 ; 32 ] = amount . into ( ) ; let rows_affected = sqlx :: query ( " " , ) . bind ( request_id ) . bind ( address ) . bind ( denom . to_string ( ) ) . bind ( amount_bytes . to_vec ( ) ) . bind ( operation_type ) . bind ( transaction_hash ) . execute ( executor ) . await . context ( " " ) ? . rows_affected ( ) ; ensure ! ( rows_affected 1 " " ) ; Ok ( ( ) ) }
Adds an account operation to database
Adds an account operation to database
executor
impl Executor<'e, Database = Db>
request_id
Option<&str>
address
&str
denom
&Identifier
amount
U256
operation_type
&OperationType
transaction_hash
&str
executor
impl Executor<'e, Database = Db>
request_id
Option<&str>
address
&str
denom
&Identifier
amount
U256
operation_type
&OperationType
transaction_hash
&str