Skip to content

Commit

Permalink
fix: api. (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenduckgo authored Jul 5, 2024
1 parent 44dd13e commit 5e38972
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions indexer/src/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ pub async fn get_delegator_delegate_records(
let page_size = params.page_size.unwrap_or(10);

let (sql_total, sql_query) = if let Some(delegator) = params.0.delegator {
let delegator_lower = delegator.to_lowercase();
(
format!("SELECT count(block_num) FROM evm_delegations WHERE delegator='{}'", delegator)
format!("SELECT count(block_num) FROM evm_delegations WHERE delegator='{}'", delegator_lower)
,
format!("SELECT tx_id,block_id,validator,delegator,tm,amount FROM evm_delegations WHERE delegator='{}' ORDER BY tm DESC LIMIT {} OFFSET {}", delegator, page_size, (page-1)*page_size)
format!("SELECT tx_id,block_id,validator,delegator,tm,amount FROM evm_delegations WHERE delegator='{}' ORDER BY tm DESC LIMIT {} OFFSET {}", delegator_lower, page_size, (page-1)*page_size)
)
} else {
(
Expand Down
5 changes: 3 additions & 2 deletions indexer/src/undelegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ pub async fn get_delegator_undelegate_records(
let page_size = params.page_size.unwrap_or(10);

let (sql_total, sql_query) = if let Some(delegator) = params.0.delegator {
let delegator_lower = delegator.to_lowercase();
(
format!("SELECT count(block_num) FROM evm_undelegations WHERE delegator='{}'", delegator)
format!("SELECT count(block_num) FROM evm_undelegations WHERE delegator='{}'", delegator_lower)
,
format!("SELECT tx_id,block_id,validator,delegator,tm,amount FROM evm_undelegations WHERE delegator='{}' ORDER BY tm DESC LIMIT {} OFFSET {}", delegator, page_size, (page-1)*page_size)
format!("SELECT tx_id,block_id,validator,delegator,tm,amount FROM evm_undelegations WHERE delegator='{}' ORDER BY tm DESC LIMIT {} OFFSET {}", delegator_lower, page_size, (page-1)*page_size)
)
} else {
(
Expand Down

0 comments on commit 5e38972

Please sign in to comment.