fix: enforce real onchain balance checks in airdrop adapters#2128
Merged
Scottcjn merged 1 commit intoScottcjn:mainfrom Apr 6, 2026
Merged
fix: enforce real onchain balance checks in airdrop adapters#2128Scottcjn merged 1 commit intoScottcjn:mainfrom
Scottcjn merged 1 commit intoScottcjn:mainfrom
Conversation
Contributor
Author
|
For bounty payout, please use RTC wallet: RTC1d48d848a5aa5ecf2c5f01aa5fb64837daaf2f35. |
Owner
|
Reviewed. Replaces hardcoded mock balances (0.2 SOL, 0.02 ETH) with real RPC calls in Solana and Base adapters. Sets Payment: 65 RTC — Airdrop adapter real balance enforcement (High severity) Merging. Thank you createkr. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: replace hardcoded mock balances with real RPC calls in chain adapters
Problem
SolanaAdapterandBaseAdapterreturned hardcoded constant balances (0.2 SOL, 0.02 ETH) and ages (10 days, 14 days) fromget_balance()andget_wallet_age(), ignoring the wallet address parameter. Any syntactically valid address passed eligibility checks regardless of actual on-chain state.Solution
Replaced the four mock methods with actual JSON-RPC calls using the existing
reqwestdependency:SolanaAdapter::get_balance()Ok(200_000_000)POST getBalance→ parseresult.valueSolanaAdapter::get_wallet_age()Ok(10 * 86400)Ok(0)(conservative)BaseAdapter::get_balance()Ok(20_000_000_000_000_000)POST eth_getBalance→ parse hex resultBaseAdapter::get_wallet_age()Ok(14 * 86400)Ok(0)(conservative)Wallet age returns 0 because determining age requires historical transaction data (Solana
getSignaturesForAddress, Base Basescan API), which is significantly more complex than a single RPC call. Returning 0 is the safe default — wallets fail the age gate unless the policy minimum is set to 0.Key changes
src/chain_adapter.rs— replaced 4 mock methods with real RPC calls + proper error handling; added 6 new unit tests using mockito HTTP mockingTests
--features sqlite-storeCompatibility
ChainAdaptertrait signatures unchangedreqwest