use crate::registry::types::*; use sqlx::PgPool; // ===== GHG Minting Services ===== pub async fn log_ghg_minting( pool: &PgPool, req: LogGhgMintingRequest, ) -> Result { sqlx::query_as::<_, GhgMintingLog>( r#" INSERT INTO ghg_minting_log ( company_pubkey, company_name, ghg_vault, amount, local_admin_pubkey, local_admin_state, verification_note, ghg_mint ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING * "#, ) .bind(&req.company_pubkey) .bind(&req.company_name) .bind(&req.ghg_vault) .bind(req.amount) .bind(&req.local_admin_pubkey) .bind(&req.local_admin_state) .bind(&req.verification_note) .bind(&req.ghg_mint) .fetch_one(pool) .await } pub async fn get_ghg_minting_logs( pool: &PgPool, company_pubkey: &str, ) -> Result, sqlx::Error> { sqlx::query_as::<_, GhgMintingLog>( "SELECT * FROM ghg_minting_log WHERE company_pubkey = $1 ORDER BY created_at DESC", ) .bind(company_pubkey) .fetch_all(pool) .await }