Skip to content

Commit

Permalink
Fixing errors related to account and account delegation (#331)
Browse files Browse the repository at this point in the history
* fix format

* fixed naother issue

* revert

* fix optional

* fix format

* fix delegation event not being used

* fmt

* fix created at

* check for height

* fix sqlx
  • Loading branch information
lassemand authored Dec 18, 2024
1 parent 9fd5af1 commit 0ea2cba
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 15 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 19 additions & 10 deletions backend-rust/src/graphql_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3140,16 +3140,25 @@ impl Account {

/// Timestamp of the block where this account was created.
async fn created_at(&self, ctx: &Context<'_>) -> ApiResult<DateTime> {
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?;

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?
} else {
sqlx::query_scalar!(
"SELECT slot_time
FROM blocks
WHERE height = 0"
)
.fetch_one(get_pool(ctx)?)
.await?
};
Ok(slot_time)
}

Expand Down
2 changes: 1 addition & 1 deletion backend-rust/src/graphql_api/account_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub(crate) struct AccountMetricsQuery;

#[Object]
impl AccountMetricsQuery {
async fn account_metrics(
async fn accounts_metrics(
&self,
ctx: &Context<'_>,
period: MetricsPeriod,
Expand Down
9 changes: 7 additions & 2 deletions backend-rust/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1208,8 +1208,13 @@ impl PreparedEvent {
} => None,

AccountTransactionEffects::DelegationConfigured {
data,
} => None,
data: events,
} => Some(PreparedEvent::AccountDelegationEvents(
events
.iter()
.map(PreparedAccountDelegationEvent::prepare)
.collect::<anyhow::Result<Vec<_>>>()?,
)),
},
details => {
warn!("details = \n {:#?}", details);
Expand Down

0 comments on commit 0ea2cba

Please sign in to comment.