Skip to content

Commit

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

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

Ok(slot_time)
"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))
} else {
Ok(None)
}
}

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

0 comments on commit 36210b1

Please sign in to comment.