Skip to content
This repository was archived by the owner on Mar 18, 2026. It is now read-only.

Commit c8f70f5

Browse files
Merge branch 'main' into dependabot/uv/main/dev-dependencies-ba2befb238
2 parents a95f5f4 + eb644ce commit c8f70f5

5 files changed

Lines changed: 357 additions & 174 deletions

File tree

agent-tools-ts

app/api/tools/dao.py

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
ProposalType,
2323
Wallet,
2424
WalletFilter,
25-
WalletFilterN,
2625
)
2726
from app.config import config
2827
from app.lib.logger import configure_logger
@@ -115,34 +114,9 @@ async def _validate_airdrop_recipients(recipients: List[str]) -> Dict[str, bool]
115114
Returns:
116115
Dict mapping each recipient to whether it exists in wallets table
117116
"""
118-
if not recipients:
119-
return {}
120-
121-
# Determine which network to check based on config
122-
from app.config import config
123-
124-
use_mainnet = config.network.network == "mainnet"
125-
126-
# Query wallets table for all recipients at once, filtering by the appropriate network
127-
if use_mainnet:
128-
wallet_filter = WalletFilterN(mainnet_addresses=recipients)
129-
else:
130-
wallet_filter = WalletFilterN(testnet_addresses=recipients)
131-
132-
wallets = backend.list_wallets_n(filters=wallet_filter)
133-
134-
# Create set of valid addresses for efficient lookup
135-
if use_mainnet:
136-
valid_addresses = {w.mainnet_address for w in wallets if w.mainnet_address}
137-
else:
138-
valid_addresses = {w.testnet_address for w in wallets if w.testnet_address}
139-
140-
# Check each recipient
141-
validation_results = {}
142-
for recipient in recipients:
143-
validation_results[recipient] = recipient in valid_addresses
117+
from app.lib.utils import validate_wallet_recipients
144118

145-
return validation_results
119+
return await validate_wallet_recipients(recipients)
146120

147121

148122
async def _create_proposal_from_tool_result(

app/lib/utils.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,3 +566,45 @@ def calculate_token_cost(
566566
"currency": "USD",
567567
"details": token_details,
568568
}
569+
570+
571+
async def validate_wallet_recipients(recipients: List[str]) -> Dict[str, bool]:
572+
"""Validate recipients against the wallets table using network-specific filtering.
573+
574+
Args:
575+
recipients: List of recipient addresses to validate
576+
577+
Returns:
578+
Dict mapping each recipient to whether it exists in wallets table
579+
"""
580+
if not recipients:
581+
return {}
582+
583+
# Import here to avoid circular imports
584+
from app.config import config
585+
from app.backend.factory import backend
586+
from app.backend.models import WalletFilterN
587+
588+
# Determine which network to check based on config
589+
use_mainnet = config.network.network == "mainnet"
590+
591+
# Query wallets table for all recipients at once, filtering by the appropriate network
592+
if use_mainnet:
593+
wallet_filter = WalletFilterN(mainnet_addresses=recipients)
594+
else:
595+
wallet_filter = WalletFilterN(testnet_addresses=recipients)
596+
597+
wallets = backend.list_wallets_n(filters=wallet_filter)
598+
599+
# Create set of valid addresses for efficient lookup
600+
if use_mainnet:
601+
valid_addresses = {w.mainnet_address for w in wallets if w.mainnet_address}
602+
else:
603+
valid_addresses = {w.testnet_address for w in wallets if w.testnet_address}
604+
605+
# Check each recipient
606+
validation_results = {}
607+
for recipient in recipients:
608+
validation_results[recipient] = recipient in valid_addresses
609+
610+
return validation_results

0 commit comments

Comments
 (0)