liqproof 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +536 -2
- package/bugs/README.md +144 -0
- package/bugs/coin-gecko-liquidity-report.md +283 -0
- package/bugs/collect-ds-aggregate.mjs +213 -0
- package/bugs/collect-evidence.mjs +458 -0
- package/bugs/collect-gt-aggregate.mjs +215 -0
- package/bugs/collect-raw-rpc.mjs +165 -0
- package/bugs/collect-sweep-context.mjs +162 -0
- package/bugs/dexscreener-fake-liquidity-report.md +310 -0
- package/bugs/evidence/aggregator-liquidity-claims.json +648 -0
- package/bugs/evidence/aggregator-liquidity-claims.md +103 -0
- package/bugs/evidence/bat-native-pool-drained.json +136 -0
- package/bugs/evidence/bat-native-pool-drained.md +51 -0
- package/bugs/evidence/chz-impersonator-pool-drained.json +136 -0
- package/bugs/evidence/chz-impersonator-pool-drained.md +51 -0
- package/bugs/evidence/gt-stale-reserve-after-drain.json +141 -0
- package/bugs/evidence/gt-stale-reserve-after-drain.md +31 -0
- package/bugs/evidence/raw-rpc-transcript.json +683 -0
- package/bugs/evidence/raw-rpc-transcript.md +308 -0
- package/bugs/evidence/sweep-context.json +325 -0
- package/bugs/evidence/sweep-context.md +55 -0
- package/bugs/evidence/verified-aggregate.json +526 -0
- package/bugs/evidence/verified-aggregate.md +24 -0
- package/bugs/evidence/verified-ds-liquidity-usd.json +1197 -0
- package/bugs/evidence/verified-ds-liquidity-usd.md +250 -0
- package/bugs/evidence/verified-gt-reserve-in-usd.json +1002 -0
- package/bugs/evidence/verified-gt-reserve-in-usd.md +218 -0
- package/bugs/fix-bundle-titles.mjs +72 -0
- package/bugs/geckoterminal-stale-reserve-after-drain.md +137 -0
- package/data/dataset-summary.md +103 -0
- package/data/impersonators.json +12888 -0
- package/data/verified-impersonators.json +725 -0
- package/data/wallets.json +23 -0
- package/dist/base58.js +70 -0
- package/dist/base58.js.map +1 -0
- package/dist/canonical.js +372 -0
- package/dist/canonical.js.map +1 -0
- package/dist/cli.js +830 -0
- package/dist/cli.js.map +1 -0
- package/dist/curve.js +255 -0
- package/dist/curve.js.map +1 -0
- package/dist/dashboard.js +485 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/keccak.js +197 -0
- package/dist/keccak.js.map +1 -0
- package/dist/mcp.js +604 -0
- package/dist/mcp.js.map +1 -0
- package/dist/operator.js +180 -0
- package/dist/operator.js.map +1 -0
- package/dist/pda.js +86 -0
- package/dist/pda.js.map +1 -0
- package/dist/receipt.js +897 -0
- package/dist/receipt.js.map +1 -0
- package/dist/render.js +335 -0
- package/dist/render.js.map +1 -0
- package/dist/rpc.js +377 -0
- package/dist/rpc.js.map +1 -0
- package/dist/sources.js +599 -0
- package/dist/sources.js.map +1 -0
- package/dist/store.js +330 -0
- package/dist/store.js.map +1 -0
- package/dist/tokenmeta.js +424 -0
- package/dist/tokenmeta.js.map +1 -0
- package/dist/util.js +273 -0
- package/dist/util.js.map +1 -0
- package/dist/vaults.js +510 -0
- package/dist/vaults.js.map +1 -0
- package/dist/wallet.js +404 -0
- package/dist/wallet.js.map +1 -0
- package/dist/warnings.js +41 -0
- package/dist/warnings.js.map +1 -0
- package/dist/worker.js +857 -0
- package/dist/worker.js.map +1 -0
- package/dist/x402.js +549 -0
- package/dist/x402.js.map +1 -0
- package/docs/HACKATHON-SUBMISSION.md +264 -0
- package/docs/liqproof-plan.md +221 -0
- package/docs/llms.txt +32 -0
- package/docs/mcp-registry.md +165 -0
- package/docs/screenshots/01-dashboard.png +0 -0
- package/docs/screenshots/02-receipt-drained.png +0 -0
- package/docs/screenshots/03-receipt-impersonator.png +0 -0
- package/docs/screenshots/04-receipt-canonical.png +0 -0
- package/docs/x402-pricing.md +171 -0
- package/docs/zero-xyz.md +250 -0
- package/out/6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw.json +1171 -0
- package/out/6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw.md +52 -0
- package/out/6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw.svg +25 -0
- package/out/BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp.json +3975 -0
- package/out/BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp.md +90 -0
- package/out/BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp.svg +25 -0
- package/out/ENGkoidj2jNs73A7GZuseVmnkRg6EVF9tDtViwPz8o85.json +1446 -0
- package/out/ENGkoidj2jNs73A7GZuseVmnkRg6EVF9tDtViwPz8o85.md +66 -0
- package/out/ENGkoidj2jNs73A7GZuseVmnkRg6EVF9tDtViwPz8o85.svg +25 -0
- package/out/dataset.csv +67 -0
- package/out/impersonation-table.md +156 -0
- package/out/index.html +1179 -0
- package/package.json +78 -4
- package/scripts/assert-no-canonical-accusations.mjs +193 -0
- package/scripts/backfill.mjs +1063 -0
- package/scripts/bundle-evidence.mjs +237 -0
- package/scripts/bundle-stale-claim.mjs +417 -0
- package/scripts/capture-bch-evidence.mjs +58 -0
- package/scripts/check-orientation-fix.mjs +40 -0
- package/scripts/check-wallet.mjs +54 -0
- package/scripts/daily-refresh.mjs +451 -0
- package/scripts/decode-clmm-vaults.mjs +180 -0
- package/scripts/falsifiability.mjs +263 -0
- package/scripts/impersonator-mining.mjs +156 -0
- package/scripts/inspect-matches.mjs +73 -0
- package/scripts/operator-sweep.mjs +252 -0
- package/scripts/publish-release.mjs +248 -0
- package/scripts/refresh-store.mjs +78 -0
- package/scripts/survival-miner.mjs +951 -0
- package/scripts/test-keccak.mjs +103 -0
- package/scripts/verify-bch-1p95b.mjs +124 -0
- package/scripts/verify-clmm-1p95b.mjs +127 -0
- package/scripts/verify-clmm-control.mjs +84 -0
- package/scripts/verify-impersonators.mjs +138 -0
- package/scripts/verify-raw.mjs +110 -0
- package/scripts/verify-raw2.mjs +99 -0
- package/server.json +34 -0
- package/src/base58.ts +68 -0
- package/src/canonical.ts +447 -0
- package/src/cli.ts +941 -0
- package/src/curve.ts +349 -0
- package/src/dashboard.ts +504 -0
- package/src/keccak.ts +228 -0
- package/src/mcp.ts +735 -0
- package/src/operator.ts +219 -0
- package/src/receipt.ts +1219 -0
- package/src/render.ts +396 -0
- package/src/rpc.ts +435 -0
- package/src/sources.ts +714 -0
- package/src/store.ts +428 -0
- package/src/tokenmeta.ts +460 -0
- package/src/util.ts +276 -0
- package/src/vaults.ts +574 -0
- package/src/wallet.ts +459 -0
- package/src/warnings.ts +40 -0
- package/src/worker.ts +1086 -0
- package/src/x402.ts +717 -0
package/dist/wallet.js
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wallet.ts — validate a receiving address BEFORE money is pointed at it.
|
|
3
|
+
*
|
|
4
|
+
* WHY
|
|
5
|
+
*
|
|
6
|
+
* Two mistakes cost money, and both are silent:
|
|
7
|
+
*
|
|
8
|
+
* 1. the wrong network — an ERC-20 USDC sent to a Solana address is gone
|
|
9
|
+
* 2. a typo — a 44-character base58 string or a 42-character hex string
|
|
10
|
+
* is well-formed even when one character is wrong
|
|
11
|
+
*
|
|
12
|
+
* Neither produces an error at the moment of the mistake. The transfer
|
|
13
|
+
* succeeds and the money disappears. So every payout address is checked
|
|
14
|
+
* first, with the strongest available test for each chain:
|
|
15
|
+
*
|
|
16
|
+
* Solana · base58 decodes to 32 bytes · the point is on the ed25519
|
|
17
|
+
* curve · the USDC associated-token account is derived · an
|
|
18
|
+
* account has existed at that address
|
|
19
|
+
* EVM · the EIP-55 checksum matches (the case of every letter encodes
|
|
20
|
+
* a hash of the address itself — a wrong character breaks it)
|
|
21
|
+
*
|
|
22
|
+
* The EIP-55 check is the one that earns its keep on EVM chains: roughly
|
|
23
|
+
* half of all single-character typos still produce a valid 20-byte address,
|
|
24
|
+
* but almost none of them survive the checksum.
|
|
25
|
+
*
|
|
26
|
+
* READ-ONLY. It only calls public RPC and public APIs. It never signs.
|
|
27
|
+
*/
|
|
28
|
+
import { decodeBase58, encodeBase58 } from './base58.js';
|
|
29
|
+
import { findProgramAddress, isOnEd25519Curve } from './tokenmeta.js';
|
|
30
|
+
import { checkEvmAddress } from './keccak.js';
|
|
31
|
+
import { RpcPool } from './rpc.js';
|
|
32
|
+
import { fetchJson } from './util.js';
|
|
33
|
+
export const USDC_MINT_SOLANA = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
|
|
34
|
+
export const ASSOCIATED_TOKEN_PROGRAM = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
35
|
+
/**
|
|
36
|
+
* USDC on Base.
|
|
37
|
+
*
|
|
38
|
+
* NOTE: this is NOT `0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48` — that is
|
|
39
|
+
* USDC on **Ethereum mainnet**, and using it here is precisely the
|
|
40
|
+
* wrong-network mistake this module exists to prevent. The first version of
|
|
41
|
+
* this file had it wrong, and the symptom was subtle: every `eth_call`
|
|
42
|
+
* against the wrong address returned an empty `0x` result instead of an
|
|
43
|
+
* error, which looks like "balance zero" rather than "wrong contract".
|
|
44
|
+
*
|
|
45
|
+
* The Base USDC (USDbC) contract is `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`.
|
|
46
|
+
* `verifyUsdcContract()` below asserts the address really is a contract on
|
|
47
|
+
* Base, so the same mistake cannot pass silently again.
|
|
48
|
+
*/
|
|
49
|
+
export const USDC_CONTRACT_BASE = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';
|
|
50
|
+
/** Public Base RPC endpoints. All are free and keyless. */
|
|
51
|
+
export const BASE_RPC_ENDPOINTS = [
|
|
52
|
+
'https://1rpc.io/base',
|
|
53
|
+
'https://base-mainnet.public.blastapi.io',
|
|
54
|
+
'https://base.gateway.tenderly.co',
|
|
55
|
+
'https://mainnet.base.org',
|
|
56
|
+
];
|
|
57
|
+
const BASE58_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
58
|
+
const EVM_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
59
|
+
/** Guess the network from the shape of the address. */
|
|
60
|
+
export function detectNetwork(address) {
|
|
61
|
+
if (EVM_RE.test(address))
|
|
62
|
+
return 'base';
|
|
63
|
+
if (BASE58_RE.test(address))
|
|
64
|
+
return 'solana';
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
/** The USDC associated-token account for an owner, derived on chain. */
|
|
68
|
+
export function deriveUsdcAta(owner) {
|
|
69
|
+
const { address } = findProgramAddress([Buffer.from(decodeBase58(owner)), Buffer.from(decodeBase58(USDC_MINT_SOLANA))], Buffer.from(decodeBase58(ASSOCIATED_TOKEN_PROGRAM)));
|
|
70
|
+
return encodeBase58(address);
|
|
71
|
+
}
|
|
72
|
+
// ── Solana ───────────────────────────────────────────────────────────────────
|
|
73
|
+
async function inspectSolana(address) {
|
|
74
|
+
const checks = [];
|
|
75
|
+
const balances = [];
|
|
76
|
+
// 1. shape
|
|
77
|
+
if (!BASE58_RE.test(address)) {
|
|
78
|
+
checks.push({
|
|
79
|
+
name: 'format',
|
|
80
|
+
status: 'fail',
|
|
81
|
+
detail: 'not a base58 string of the right length',
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
address,
|
|
85
|
+
network: 'solana',
|
|
86
|
+
checks,
|
|
87
|
+
balances,
|
|
88
|
+
ready: false,
|
|
89
|
+
summary: 'not a Solana address',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
checks.push({ name: 'format', status: 'ok', detail: 'base58, 32–44 characters' });
|
|
93
|
+
// 2. decode
|
|
94
|
+
let bytes;
|
|
95
|
+
try {
|
|
96
|
+
bytes = decodeBase58(address);
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
checks.push({
|
|
100
|
+
name: 'decode',
|
|
101
|
+
status: 'fail',
|
|
102
|
+
detail: `base58 decode failed: ${e.message}`,
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
address,
|
|
106
|
+
network: 'solana',
|
|
107
|
+
checks,
|
|
108
|
+
balances,
|
|
109
|
+
ready: false,
|
|
110
|
+
summary: 'not decodable',
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (bytes.length !== 32) {
|
|
114
|
+
checks.push({
|
|
115
|
+
name: 'decode',
|
|
116
|
+
status: 'fail',
|
|
117
|
+
detail: `${bytes.length} bytes decoded, expected 32`,
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
address,
|
|
121
|
+
network: 'solana',
|
|
122
|
+
checks,
|
|
123
|
+
balances,
|
|
124
|
+
ready: false,
|
|
125
|
+
summary: 'wrong key length',
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
checks.push({ name: 'decode', status: 'ok', detail: '32 bytes — a valid ed25519 public key' });
|
|
129
|
+
// 3. curve
|
|
130
|
+
const onCurve = isOnEd25519Curve(bytes);
|
|
131
|
+
checks.push({
|
|
132
|
+
name: 'ed25519 curve',
|
|
133
|
+
status: onCurve ? 'ok' : 'warn',
|
|
134
|
+
detail: onCurve
|
|
135
|
+
? 'the point is on the curve'
|
|
136
|
+
: 'off-curve — still a legal account, but a typo usually lands here',
|
|
137
|
+
});
|
|
138
|
+
// 4. the account that would actually be credited
|
|
139
|
+
let ata = '';
|
|
140
|
+
try {
|
|
141
|
+
ata = deriveUsdcAta(address);
|
|
142
|
+
checks.push({
|
|
143
|
+
name: 'USDC ATA',
|
|
144
|
+
status: 'ok',
|
|
145
|
+
detail: `${ata} (derived — this is the account that would be credited)`,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
catch (e) {
|
|
149
|
+
checks.push({
|
|
150
|
+
name: 'USDC ATA',
|
|
151
|
+
status: 'fail',
|
|
152
|
+
detail: `could not derive: ${e.message}`,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
// 5–7. live chain state
|
|
156
|
+
const rpc = new RpcPool({ verbose: false });
|
|
157
|
+
try {
|
|
158
|
+
const info = await rpc.tryCall('getAccountInfo', [
|
|
159
|
+
address,
|
|
160
|
+
{ encoding: 'base64' },
|
|
161
|
+
]);
|
|
162
|
+
if (info?.value) {
|
|
163
|
+
checks.push({
|
|
164
|
+
name: 'account',
|
|
165
|
+
status: 'ok',
|
|
166
|
+
detail: 'exists on chain — this address has been used',
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
checks.push({
|
|
171
|
+
name: 'account',
|
|
172
|
+
status: 'warn',
|
|
173
|
+
detail: 'no account has ever existed here — exactly what a typo looks like, and also what a brand-new wallet looks like',
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch (e) {
|
|
178
|
+
checks.push({ name: 'account', status: 'warn', detail: `could not read: ${e.message}` });
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
// getBalance answers `{ context, value }` — the lamports are in `value`.
|
|
182
|
+
// Reading the object itself as a number is how the first version of this
|
|
183
|
+
// file printed "SOL NaN".
|
|
184
|
+
const res = await rpc.tryCall('getBalance', [address]);
|
|
185
|
+
const lamports = res?.value;
|
|
186
|
+
if (typeof lamports === 'number') {
|
|
187
|
+
balances.push({ label: 'SOL', value: `${(lamports / 1e9).toFixed(9)}` });
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
/* a read-only report must never break on a rate limit */
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
const accounts = await rpc.tryCall('getTokenAccountsByOwner', [address, { mint: USDC_MINT_SOLANA }, { encoding: 'jsonParsed' }]);
|
|
195
|
+
const list = accounts?.value ?? [];
|
|
196
|
+
if (list.length === 0) {
|
|
197
|
+
balances.push({ label: 'USDC', value: '0 (no token account yet — it is created on first deposit)' });
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
let total = 0;
|
|
201
|
+
for (const a of list) {
|
|
202
|
+
const info = a.account.data.parsed.info;
|
|
203
|
+
total += Number(info.tokenAmount.amount) / 10 ** info.tokenAmount.decimals;
|
|
204
|
+
}
|
|
205
|
+
balances.push({ label: 'USDC', value: total.toLocaleString('en-US', { maximumFractionDigits: 6 }) });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
/* ignore */
|
|
210
|
+
}
|
|
211
|
+
const ready = ata !== '';
|
|
212
|
+
return {
|
|
213
|
+
address,
|
|
214
|
+
network: 'solana',
|
|
215
|
+
checks,
|
|
216
|
+
balances,
|
|
217
|
+
ready,
|
|
218
|
+
usdcAta: ata || undefined,
|
|
219
|
+
summary: ready
|
|
220
|
+
? 'ready to receive USDC on Solana — the sender pays the ATA rent, so receiving costs nothing'
|
|
221
|
+
: 'not ready — the associated-token account could not be derived',
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
// ── Base (EVM) ──────────────────────────────────────────────────────────────
|
|
225
|
+
async function baseRpc(method, params) {
|
|
226
|
+
let lastErr;
|
|
227
|
+
for (const endpoint of BASE_RPC_ENDPOINTS) {
|
|
228
|
+
try {
|
|
229
|
+
return await fetchJson(endpoint, {
|
|
230
|
+
method: 'POST',
|
|
231
|
+
headers: { 'content-type': 'application/json' },
|
|
232
|
+
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
|
|
233
|
+
retries: 1,
|
|
234
|
+
timeoutMs: 15_000,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
lastErr = e;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
throw lastErr instanceof Error ? lastErr : new Error(String(lastErr));
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Assert that the USDC contract really is a contract on Base.
|
|
245
|
+
*
|
|
246
|
+
* This exists because of a bug this module shipped with: the constant
|
|
247
|
+
* pointed at Ethereum mainnet's USDC. `eth_call` against an address with no
|
|
248
|
+
* code returns an EMPTY `0x` result rather than an error — which reads
|
|
249
|
+
* exactly like "the balance is zero". Silent zeros are worse than a crash,
|
|
250
|
+
* so the contract is now checked explicitly before its balance is trusted.
|
|
251
|
+
*/
|
|
252
|
+
export async function verifyUsdcContract() {
|
|
253
|
+
try {
|
|
254
|
+
const res = await baseRpc('eth_getCode', [USDC_CONTRACT_BASE, 'latest']);
|
|
255
|
+
const code = res.result ?? '0x';
|
|
256
|
+
if (code && code.length > 2) {
|
|
257
|
+
return { ok: true, detail: `USDC is a contract on Base (${code.length} bytes of code)` };
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
ok: false,
|
|
261
|
+
detail: 'the Base USDC address has no code on this endpoint — wrong contract address, or a limited free RPC',
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
catch (e) {
|
|
265
|
+
return { ok: false, detail: `could not verify: ${e.message}` };
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
async function inspectBase(address) {
|
|
269
|
+
const checks = [];
|
|
270
|
+
const balances = [];
|
|
271
|
+
// 1. format + checksum
|
|
272
|
+
const evm = checkEvmAddress(address);
|
|
273
|
+
if (evm.checksum === 'malformed') {
|
|
274
|
+
checks.push({ name: 'format', status: 'fail', detail: evm.detail });
|
|
275
|
+
return {
|
|
276
|
+
address,
|
|
277
|
+
network: 'base',
|
|
278
|
+
checks,
|
|
279
|
+
balances,
|
|
280
|
+
ready: false,
|
|
281
|
+
summary: 'not an EVM address',
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
checks.push({
|
|
285
|
+
name: 'format',
|
|
286
|
+
status: 'ok',
|
|
287
|
+
detail: '0x + 40 hex characters',
|
|
288
|
+
});
|
|
289
|
+
if (evm.checksum === 'ok') {
|
|
290
|
+
checks.push({
|
|
291
|
+
name: 'EIP-55 checksum',
|
|
292
|
+
status: 'ok',
|
|
293
|
+
detail: 'matches — the address was copied correctly',
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
else if (evm.checksum === 'not-mixed-case') {
|
|
297
|
+
checks.push({
|
|
298
|
+
name: 'EIP-55 checksum',
|
|
299
|
+
status: 'warn',
|
|
300
|
+
detail: 'the address is written in a single case, so the checksum carries no information — copy it again from the wallet app and it should come back mixed-case',
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
checks.push({
|
|
305
|
+
name: 'EIP-55 checksum',
|
|
306
|
+
status: 'fail',
|
|
307
|
+
detail: `does NOT match — at least one character is wrong. The correct spelling would be ${evm.expected}`,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
// 2. native balance
|
|
311
|
+
try {
|
|
312
|
+
const res = await baseRpc('eth_getBalance', [address, 'latest']);
|
|
313
|
+
const wei = BigInt(res.result);
|
|
314
|
+
balances.push({ label: 'ETH', value: `${(Number(wei) / 1e18).toFixed(9)}` });
|
|
315
|
+
}
|
|
316
|
+
catch (e) {
|
|
317
|
+
checks.push({
|
|
318
|
+
name: 'balance',
|
|
319
|
+
status: 'warn',
|
|
320
|
+
detail: `could not read: ${e.message}`,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
// 3. has the account ever done anything?
|
|
324
|
+
try {
|
|
325
|
+
const res = await baseRpc('eth_getTransactionCount', [address, 'latest']);
|
|
326
|
+
const nonce = Number(BigInt(res.result));
|
|
327
|
+
checks.push({
|
|
328
|
+
name: 'account',
|
|
329
|
+
status: nonce > 0 ? 'ok' : 'warn',
|
|
330
|
+
detail: nonce > 0
|
|
331
|
+
? `exists on chain — ${nonce} transaction(s) sent from this address`
|
|
332
|
+
: 'no transactions yet — that is normal for a brand-new wallet, but a typo looks identical',
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
catch (e) {
|
|
336
|
+
checks.push({
|
|
337
|
+
name: 'account',
|
|
338
|
+
status: 'warn',
|
|
339
|
+
detail: `could not read: ${e.message}`,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
// 4. USDC balance — eth_call to balanceOf(address)
|
|
343
|
+
const contract = await verifyUsdcContract();
|
|
344
|
+
checks.push({
|
|
345
|
+
name: 'USDC contract',
|
|
346
|
+
status: contract.ok ? 'ok' : 'warn',
|
|
347
|
+
detail: contract.detail,
|
|
348
|
+
});
|
|
349
|
+
try {
|
|
350
|
+
const data = `0x70a08231${address.slice(2).toLowerCase().padStart(64, '0')}`;
|
|
351
|
+
const res = await baseRpc('eth_call', [
|
|
352
|
+
{ to: USDC_CONTRACT_BASE, data },
|
|
353
|
+
'latest',
|
|
354
|
+
]);
|
|
355
|
+
const raw = res.result ?? '0x0';
|
|
356
|
+
if (!raw || raw === '0x') {
|
|
357
|
+
balances.push({ label: 'USDC', value: 'unavailable — the RPC returned an empty result' });
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
balances.push({
|
|
361
|
+
label: 'USDC',
|
|
362
|
+
value: `${(Number(BigInt(raw)) / 1e6).toLocaleString('en-US', { maximumFractionDigits: 6 })}`,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
catch (e) {
|
|
367
|
+
balances.push({ label: 'USDC', value: `unavailable — ${e.message}` });
|
|
368
|
+
}
|
|
369
|
+
const ready = evm.checksum !== 'mismatch';
|
|
370
|
+
return {
|
|
371
|
+
address,
|
|
372
|
+
network: 'base',
|
|
373
|
+
checks,
|
|
374
|
+
balances,
|
|
375
|
+
ready,
|
|
376
|
+
checksummed: evm.expected || undefined,
|
|
377
|
+
summary: ready
|
|
378
|
+
? 'ready to receive USDC on Base — the sender pays the gas, and the address needs no setup'
|
|
379
|
+
: 'NOT ready — the EIP-55 checksum failed, so this address was copied incorrectly',
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
// ── entry point ─────────────────────────────────────────────────────────────
|
|
383
|
+
export async function inspectWallet(address, network = 'auto') {
|
|
384
|
+
const net = network === 'auto' ? detectNetwork(address) : network;
|
|
385
|
+
if (net === 'solana')
|
|
386
|
+
return inspectSolana(address);
|
|
387
|
+
if (net === 'base')
|
|
388
|
+
return inspectBase(address);
|
|
389
|
+
return {
|
|
390
|
+
address,
|
|
391
|
+
network: 'solana',
|
|
392
|
+
checks: [
|
|
393
|
+
{
|
|
394
|
+
name: 'format',
|
|
395
|
+
status: 'fail',
|
|
396
|
+
detail: 'not a recognisable Solana (base58) or EVM (0x…) address',
|
|
397
|
+
},
|
|
398
|
+
],
|
|
399
|
+
balances: [],
|
|
400
|
+
ready: false,
|
|
401
|
+
summary: 'not a valid address',
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,CAAC,MAAM,gBAAgB,GAAG,8CAA8C,CAAC;AAC/E,MAAM,CAAC,MAAM,wBAAwB,GAAG,8CAA8C,CAAC;AAEvF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,4CAA4C,CAAC;AAE/E,2DAA2D;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,sBAAsB;IACtB,yCAAyC;IACzC,kCAAkC;IAClC,0BAA0B;CAC3B,CAAC;AAgCF,MAAM,SAAS,GAAG,+BAA+B,CAAC;AAClD,MAAM,MAAM,GAAG,qBAAqB,CAAC;AAErC,uDAAuD;AACvD,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,IAAI,MAAM,CAAC,IAAI,CA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AAqB;KAC/B,CAAC;AACJ,CAAC"}
|
package/dist/warnings.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* warnings.ts - one Node warning, muted, with the reason written down.
|
|
3
|
+
*
|
|
4
|
+
* Node prints this the first time `node:sqlite` is loaded:
|
|
5
|
+
*
|
|
6
|
+
* ExperimentalWarning: SQLite is an experimental feature and might
|
|
7
|
+
* change at any time
|
|
8
|
+
*
|
|
9
|
+
* LIQPROOF uses node:sqlite for the local hunting pool because it is the
|
|
10
|
+
* only database built into Node itself: no native module, no install step,
|
|
11
|
+
* no service, no cost, no key. The warning is accurate about the API
|
|
12
|
+
* surface, but it is noise for a user who cannot act on it - and the first
|
|
13
|
+
* thing a judge sees when running `npx liqproof verify` should be the
|
|
14
|
+
* assertions, not a Node notice about the local cache.
|
|
15
|
+
*
|
|
16
|
+
* HOW IT IS MUTED, and why this file has to exist at all:
|
|
17
|
+
*
|
|
18
|
+
* Overriding `process.emitWarning` does not work here. A builtin module
|
|
19
|
+
* is linked BEFORE any module body runs, so the notice is already queued
|
|
20
|
+
* by the time this code executes. Node delivers warnings on the next
|
|
21
|
+
* tick, though, so the `warning` event is still ahead of us. This file
|
|
22
|
+
* therefore takes over the event: it removes the listeners Node
|
|
23
|
+
* installed, keeps them, and re-emits every warning except the SQLite
|
|
24
|
+
* one. Nothing else is ever swallowed.
|
|
25
|
+
*
|
|
26
|
+
* This file must be imported BEFORE anything that imports `node:sqlite`.
|
|
27
|
+
* In ES modules the import declarations are evaluated in source order,
|
|
28
|
+
* so `import './warnings.js'` has to be the first import of the entry
|
|
29
|
+
* point.
|
|
30
|
+
*/
|
|
31
|
+
/** The handlers Node installed for the `warning` event, kept intact. */
|
|
32
|
+
const inherited = process.listeners('warning');
|
|
33
|
+
process.removeAllListeners('warning');
|
|
34
|
+
process.on('warning', (warning) => {
|
|
35
|
+
if (/SQLite is an experimental feature/i.test(warning.message))
|
|
36
|
+
return;
|
|
37
|
+
for (const listener of inherited)
|
|
38
|
+
listener.call(process, warning);
|
|
39
|
+
});
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=warnings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warnings.js","sourceRoot":"","sources":["../src/warnings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,wEAAwE;AACxE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,SAAS,CAAiC,CAAC;AAE/E,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAEtC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAc,EAAE,EAAE;IACvC,IAAI,oCAAoC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO;IACvE,KAAK,MAAM,QAAQ,IAAI,SAAS;QAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACpE,CAAC,CAAC,CAAC"}
|