From ea0973ca2f5f51ee523493076ad6d6785121be0b Mon Sep 17 00:00:00 2001 From: lambda-0x <0xlambda@protonmail.com> Date: Thu, 5 Dec 2024 21:23:55 +0530 Subject: [PATCH] fix(torii/graphql): filter out tokens with zero balance (#2769) commit-id:11f63cc1 Co-authored-by: glihm --- crates/torii/graphql/src/object/erc/token_balance.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/torii/graphql/src/object/erc/token_balance.rs b/crates/torii/graphql/src/object/erc/token_balance.rs index fd383746cc..7a4481ff8e 100644 --- a/crates/torii/graphql/src/object/erc/token_balance.rs +++ b/crates/torii/graphql/src/object/erc/token_balance.rs @@ -103,7 +103,13 @@ async fn fetch_token_balances( JOIN tokens t ON b.token_id = t.id JOIN contracts c ON t.contract_address = c.contract_address" ); - let mut conditions = vec!["(b.account_address = ?)".to_string()]; + + // Only select balances for the given account address and non-zero balances. + let mut conditions = vec![ + "(b.account_address = ?)".to_string(), + "b.balance != '0x0000000000000000000000000000000000000000000000000000000000000000'" + .to_string(), + ]; let mut cursor_param = &connection.after; if let Some(after_cursor) = &connection.after {