Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(scan,metadata): stop an explorer outage reading as a wallet that never transacted

nirholas22668775a7c7
diff --git a/api/_lib/rugcheck.js b/api/_lib/rugcheck.js
index 85b2ee603..7f69d4863 100644
--- a/api/_lib/rugcheck.js
+++ b/api/_lib/rugcheck.js
@@ -15,6 +15,8 @@
// `level` is RugCheck's own grading ("warn" / "danger"). Unknown or invalid
// mints answer 400 with an error body.
+import { fetchUpstreamJson } from './upstream-fetch.js';
+
const RUGCHECK_API = 'https://api.rugcheck.xyz/v1';
const FETCH_TIMEOUT_MS = 6000;
@@ -59,12 +61,20 @@ export function rugcheckLevel(scoreNormalised) {
* }>}
*/
export async function fetchRugcheckSummary(mint, opts = {}) {
- const r = await fetch(`${RUGCHECK_API}/tokens/${encodeURIComponent(mint)}/report/summary`, {
- headers: { accept: 'application/json' },
- signal: opts.signal ?? AbortSignal.timeout(FETCH_TIMEOUT_MS),
- });
- if (!r.ok) return null;
- const d = await r.json().catch(() => null);
+ // Retried, because a null here reads downstream as "no risk data for this
+ // mint" rather than "we could not reach the risk source". Deliberately NOT
+ // kept as last-good: a risk report is a live verdict, and serving an old one
+ // for a token whose authority changed since is worse than having none.
+ let d;
+ try {
+ d = await fetchUpstreamJson(
+ `${RUGCHECK_API}/tokens/${encodeURIComponent(mint)}/report/summary`,
+ { headers: { accept: 'application/json' }, signal: opts.signal },
+ { name: 'rugcheck:summary', timeoutMs: FETCH_TIMEOUT_MS, attempts: 2 },
+ );
+ } catch {
+ return null;
+ }
if (!d || typeof d !== 'object') return null;
const score = num(d.score_normalised);
// A real report always carries the normalized score and/or a risks array;
diff --git a/api/_lib/token-metadata.js b/api/_lib/token-metadata.js
index 02d76a014..e5b4f3ecc 100644
--- a/api/_lib/token-metadata.js
+++ b/api/_lib/token-metadata.js
@@ -148,15 +148,19 @@ async function resolveViaJupiter(mints) {
for (let i = 0; i < mints.length; i += JUPITER_SEARCH_BATCH) {
const chunk = mints.slice(i, i + JUPITER_SEARCH_BATCH);
try {
- const r = await fetch(
- `https://lite-api.jup.ag/tokens/v2/search?query=${chunk.join(',')}`,
- { signal: AbortSignal.timeout(15_000) },
- );
- if (!r.ok) {
- console.warn('[token-metadata] jupiter search failed:', r.status);
+ // One chunk failing leaves those mints unnamed in the DB cache for as
+ // long as the row lives, so it is worth a retry rather than a skip.
+ let rows;
+ try {
+ rows = await fetchUpstreamJson(
+ `https://lite-api.jup.ag/tokens/v2/search?query=${chunk.join(',')}`,
+ {},
+ { name: 'jupiter:tokens-search', timeoutMs: 15_000, attempts: 2 },
+ );
+ } catch (err) {
+ console.warn('[token-metadata] jupiter search failed:', err?.message || err);
continue;
}
- const rows = await r.json();
if (!Array.isArray(rows)) continue;
for (const t of rows) {
if (!t?.id || !(t.symbol || t.name)) continue;
diff --git a/api/_lib/wallet-activity.js b/api/_lib/wallet-activity.js
index c6d2672d7..a1d822224 100644
--- a/api/_lib/wallet-activity.js
+++ b/api/_lib/wallet-activity.js
@@ -20,6 +20,7 @@ import { cacheWrap } from './cache.js';
import { env } from './env.js';
import { fetchUpstream } from './upstream-fetch.js';
+import { fetchCoinPriceUsdOrNull } from './market-fallbacks.js';
const DAY_MS = 86_400_000;
const ACTIVITY_TTL_S = 3600;
@@ -118,24 +119,25 @@ async function etherscan(chainid, params) {
headers: { accept: 'application/json' },
signal: AbortSignal.timeout(15_000),
}, { name: 'etherscan', timeoutMs: 15_000, attempts: 2, okWhen: () => true });
- if (!r.ok) return [];
+ // A failed call is NOT an empty wallet. Returning [] for both meant an
+ // explorer outage read as "this address has never transacted", which is the
+ // input airdrop eligibility is computed from, so a blip silently denied a
+ // real user. Throwing lets the per-chain settle below record the chain as
+ // unread instead of as inactive.
+ if (!r.ok) {
+ throw Object.assign(new Error(`etherscan ${r.status} on chain ${chainid}`), { code: 'explorer_unavailable', status: r.status });
+ }
const data = await r.json().catch(() => null);
// status "0" with "No transactions found" is a real empty answer, not an error.
return Array.isArray(data?.result) ? data.result : [];
}
async function ethUsdPrice() {
- try {
- const r = await fetch(
- 'https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd',
- { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(8000) },
- );
- const data = await r.json().catch(() => null);
- const p = Number(data?.ethereum?.usd);
- return Number.isFinite(p) && p > 0 ? p : null;
- } catch {
- return null;
- }
+ // CoinGecko's keyless tier is shared per egress IP, so this leg throttles on
+ // its own schedule; the shared fallback covers it with the other coin price
+ // sources and still returns null when every one of them misses.
+ const p = Number(await fetchCoinPriceUsdOrNull('ethereum'));
+ return Number.isFinite(p) && p > 0 ? p : null;
}
/**
@@ -198,6 +200,10 @@ export async function evmWalletActivity(address) {
if (!chains.length) {
throw Object.assign(new Error('every explorer call failed'), { code: 'upstream_unavailable' });
}
+ // Some chains answered and some did not. The scan is still worth returning,
+ // but it is a PARTIAL view, and a caller scoring eligibility on it has to be
+ // able to tell that from a wallet that is genuinely quiet on those chains.
+ const unreadChains = EVM_CHAIN_IDS.filter((id) => !chains.some((c) => c.chainid === id));
const days = new Set();
const tokens = new Set();
@@ -237,6 +243,15 @@ export async function evmWalletActivity(address) {
contract_interactions: contractCalls,
capped,
chains: activeChains.map((id) => ({ 1: 'ethereum', 10: 'optimism', 8453: 'base', 42161: 'arbitrum' })[id] || String(id)),
+ // Present only when a chain could not be read at all. A consumer scoring
+ // eligibility on this scan needs to tell "quiet on Base" from "we could
+ // not see Base", because the two look identical in every count above.
+ ...(unreadChains.length
+ ? {
+ partial: true,
+ unread_chains: unreadChains.map((id) => ({ 1: 'ethereum', 10: 'optimism', 8453: 'base', 42161: 'arbitrum' })[id] || String(id)),
+ }
+ : {}),
};
}