Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
lassemand committed Dec 18, 2024
1 parent 36210b1 commit 806308d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions backend-rust/src/graphql_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3139,21 +3139,27 @@ impl Account {
}

/// Timestamp of the block where this account was created.
async fn created_at(&self, ctx: &Context<'_>) -> ApiResult<Option<DateTime>> {
if let Some(transaction_index) = self.transaction_index {
let slot_time = sqlx::query_scalar!(
async fn created_at(&self, ctx: &Context<'_>) -> ApiResult<DateTime> {
let slot_time = if let Some(transaction_index) = self.transaction_index {
sqlx::query_scalar!(
"SELECT slot_time
FROM transactions
JOIN blocks ON transactions.block_height = blocks.height
WHERE transactions.index = $1",
transaction_index
)
.fetch_one(get_pool(ctx)?)
.await?;
Ok(Some(slot_time))
.await?
} else {
Ok(None)
}
sqlx::query_scalar!(
"SELECT slot_time
FROM blocks
WHERE height = 1"
)
.fetch_one(get_pool(ctx)?)
.await?
};
Ok(slot_time)
}

/// Number of transactions where this account is used as sender.
Expand Down

0 comments on commit 806308d

Please sign in to comment.