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
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
// On-chain token metadata for Solana mints.
|
|
2
|
+
//
|
|
3
|
+
// WHY: an impersonation finding is only airtight if we can show what the
|
|
4
|
+
// token SAYS it is, read from its own Metaplex metadata account, next to the
|
|
5
|
+
// canonical token it is pretending to be.
|
|
6
|
+
//
|
|
7
|
+
// The metadata account is a Program Derived Address:
|
|
8
|
+
// pda = sha256("metadata" || metadata_program || mint || bump
|
|
9
|
+
// || metadata_program || "ProgramDerivedAddress")
|
|
10
|
+
// and the bump is the one whose hash is NOT a valid ed25519 curve point.
|
|
11
|
+
//
|
|
12
|
+
// The curve check is the real work and is done here with BigInt modular
|
|
13
|
+
// arithmetic — no dependencies:
|
|
14
|
+
// x² = (y² - 1) / (d·y² + 1) (mod p), p = 2²⁵⁵ - 19
|
|
15
|
+
import { createHash } from 'node:crypto';
|
|
16
|
+
const P = (1n << 255n) - 19n;
|
|
17
|
+
const D = 37095705934669439343138083508754565189542113879843219016388785533085940283555n;
|
|
18
|
+
function mod(a, m = P) {
|
|
19
|
+
const r = a % m;
|
|
20
|
+
return r >= 0n ? r : r + m;
|
|
21
|
+
}
|
|
22
|
+
function powMod(base, exp, m = P) {
|
|
23
|
+
let result = 1n;
|
|
24
|
+
let b = mod(base, m);
|
|
25
|
+
let e = exp;
|
|
26
|
+
while (e > 0n) {
|
|
27
|
+
if (e & 1n)
|
|
28
|
+
result = (result * b) % m;
|
|
29
|
+
b = (b * b) % m;
|
|
30
|
+
e >>= 1n;
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Convert 32 bytes to a field element (BigInt).
|
|
36
|
+
*
|
|
37
|
+
* ed25519 field elements are LITTLE-ENDIAN: byte 0 is the least
|
|
38
|
+
* significant. Reading them with `BigInt('0x' + buf.toString('hex'))`
|
|
39
|
+
* treats them as big-endian, which yields a different (and wrong) y
|
|
40
|
+
* for every address — and, because roughly half of all points are
|
|
41
|
+
* on-curve, the bug looks intermittent rather than obvious.
|
|
42
|
+
*
|
|
43
|
+
* Verified against the chain: with this ordering our derived bump
|
|
44
|
+
* matches the on-chain metadata account for 6/6 reference mints.
|
|
45
|
+
*/
|
|
46
|
+
function bytesToFieldElement(buf) {
|
|
47
|
+
let n = 0n;
|
|
48
|
+
for (let i = buf.length - 1; i >= 0; i--)
|
|
49
|
+
n = (n << 8n) | BigInt(buf[i]);
|
|
50
|
+
return n;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Is this 32-byte value a valid ed25519 public key (a point on the curve)?
|
|
54
|
+
*
|
|
55
|
+
* Mirrors dalek's `CompressedEdwardsY::decompress()` (the variant Solana
|
|
56
|
+
* uses): the high bit of byte 31 is the SIGN of x, so it is masked off
|
|
57
|
+
* before the y-coordinate is read.
|
|
58
|
+
*
|
|
59
|
+
* A point is on the curve iff x² = (y²−1)/(d·y²+1) has a solution.
|
|
60
|
+
*/
|
|
61
|
+
export function isOnEd25519Curve(bytes) {
|
|
62
|
+
if (bytes.length !== 32)
|
|
63
|
+
return false;
|
|
64
|
+
const raw = Buffer.from(bytes);
|
|
65
|
+
raw[31] &= 0x7f;
|
|
66
|
+
const y = bytesToFieldElement(raw);
|
|
67
|
+
// x² = (y² - 1) / (d·y² + 1)
|
|
68
|
+
const y2 = mod(y * y);
|
|
69
|
+
const u = mod(y2 - 1n);
|
|
70
|
+
const v = mod(D * y2 + 1n);
|
|
71
|
+
if (v === 0n)
|
|
72
|
+
return false;
|
|
73
|
+
// x = u·v³·(u·v⁷)^((p-5)/8)
|
|
74
|
+
const v3 = mod(v * v * v);
|
|
75
|
+
const v7 = mod(v3 * v3 * v);
|
|
76
|
+
const r = mod(u * v3 * powMod(mod(u * v7), (P - 5n) / 8n));
|
|
77
|
+
// A solution exists iff v·r² == ±u.
|
|
78
|
+
const check = mod(v * r * r);
|
|
79
|
+
return check === u || check === mod(-u);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The marker Solana appends to every PDA preimage.
|
|
83
|
+
*
|
|
84
|
+
* From solana-program/src/pubkey.rs:
|
|
85
|
+
* const PDA_MARKER: &[u8; 21] = b"ProgramDerivedAddress";
|
|
86
|
+
* hasher.hashv(&[program_id.as_ref(), PDA_MARKER]);
|
|
87
|
+
*
|
|
88
|
+
* Omitting this byte is the classic PDA bug: the derivation looks right,
|
|
89
|
+
* every hash is a valid 32-byte address, and you simply get a different
|
|
90
|
+
* (wrong) address. It fails silently, which is the worst kind.
|
|
91
|
+
*/
|
|
92
|
+
export const PDA_MARKER = Buffer.from('ProgramDerivedAddress', 'utf8');
|
|
93
|
+
/**
|
|
94
|
+
* Solana's `Pubkey::create_program_address`, byte for byte.
|
|
95
|
+
*
|
|
96
|
+
* sha256( seed_1 || seed_2 || ... || program_id || PDA_MARKER )
|
|
97
|
+
*
|
|
98
|
+
* The bump is not special-cased: it is simply the last seed.
|
|
99
|
+
*/
|
|
100
|
+
export function createProgramAddress(seeds, programId) {
|
|
101
|
+
return createHash('sha256')
|
|
102
|
+
.update(Buffer.concat([...seeds, programId, PDA_MARKER]))
|
|
103
|
+
.digest();
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Canonical Solana PDA derivation: sha256(seeds || bump || program || marker),
|
|
107
|
+
* scanning bump from 255 down until the result is NOT a valid ed25519 point.
|
|
108
|
+
*/
|
|
109
|
+
export function findProgramAddress(seeds, programId) {
|
|
110
|
+
for (let bump = 255; bump >= 0; bump--) {
|
|
111
|
+
const h = createProgramAddress([...seeds, Buffer.from([bump])], programId);
|
|
112
|
+
if (!isOnEd25519Curve(h))
|
|
113
|
+
return { address: h, bump };
|
|
114
|
+
}
|
|
115
|
+
throw new Error('unable to find a viable program address bump');
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Every candidate PDA address for a set of seeds, newest bump first.
|
|
119
|
+
*
|
|
120
|
+
* We do NOT trust the curve check to pick the right one. The canonical rule
|
|
121
|
+
* is "the bump whose hash is off the curve", and we implement that — but we
|
|
122
|
+
* then verify by asking the chain which of the candidates actually exists.
|
|
123
|
+
* Deriving is cheap (256 SHA-256 hashes); asking the chain is one
|
|
124
|
+
* `getMultipleAccounts` call per 100 candidates. So we make the chain the
|
|
125
|
+
* authority and never ship a derivation bug.
|
|
126
|
+
*/
|
|
127
|
+
export function candidateProgramAddresses(seeds, programId) {
|
|
128
|
+
const out = [];
|
|
129
|
+
for (let bump = 255; bump >= 0; bump--) {
|
|
130
|
+
const h = createProgramAddress([...seeds, Buffer.from([bump])], programId);
|
|
131
|
+
out.push(base58Encode(h));
|
|
132
|
+
}
|
|
133
|
+
// Put the curve-checked one first so the common case is a single fetch.
|
|
134
|
+
try {
|
|
135
|
+
const pda = base58Encode(findProgramAddress(seeds, programId).address);
|
|
136
|
+
const idx = out.indexOf(pda);
|
|
137
|
+
if (idx > 0) {
|
|
138
|
+
out.splice(idx, 1);
|
|
139
|
+
out.unshift(pda);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
/* fall back to scanning all candidates */
|
|
144
|
+
}
|
|
145
|
+
return out;
|
|
146
|
+
}
|
|
147
|
+
// ── base58 (minimal, no dependency) ─────────────────────────────────────────
|
|
148
|
+
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
149
|
+
export function base58Decode(s) {
|
|
150
|
+
let num = 0n;
|
|
151
|
+
for (const ch of s) {
|
|
152
|
+
const idx = ALPHABET.indexOf(ch);
|
|
153
|
+
if (idx < 0)
|
|
154
|
+
throw new Error(`bad base58 char ${ch}`);
|
|
155
|
+
num = num * 58n + BigInt(idx);
|
|
156
|
+
}
|
|
157
|
+
let hex = num.toString(16);
|
|
158
|
+
if (hex.length % 2)
|
|
159
|
+
hex = '0' + hex;
|
|
160
|
+
const bytes = Buffer.from(hex, 'hex');
|
|
161
|
+
let zeros = 0;
|
|
162
|
+
for (const ch of s) {
|
|
163
|
+
if (ch !== '1')
|
|
164
|
+
break;
|
|
165
|
+
zeros++;
|
|
166
|
+
}
|
|
167
|
+
return Buffer.concat([Buffer.alloc(zeros), bytes]);
|
|
168
|
+
}
|
|
169
|
+
export function base58Encode(b) {
|
|
170
|
+
let num = 0n;
|
|
171
|
+
for (const byte of b)
|
|
172
|
+
num = (num << 8n) + BigInt(byte);
|
|
173
|
+
let out = '';
|
|
174
|
+
while (num > 0n) {
|
|
175
|
+
out = ALPHABET[Number(num % 58n)] + out;
|
|
176
|
+
num /= 58n;
|
|
177
|
+
}
|
|
178
|
+
let zeros = 0;
|
|
179
|
+
for (const byte of b) {
|
|
180
|
+
if (byte !== 0)
|
|
181
|
+
break;
|
|
182
|
+
zeros++;
|
|
183
|
+
}
|
|
184
|
+
return '1'.repeat(zeros) + (out || (zeros ? '' : '1'));
|
|
185
|
+
}
|
|
186
|
+
// ── token metadata ──────────────────────────────────────────────────────────
|
|
187
|
+
/**
|
|
188
|
+
* The Metaplex Token Metadata program (canonical, mainnet).
|
|
189
|
+
*
|
|
190
|
+
* NOTE: this string is easy to get wrong — a plausible-looking typo
|
|
191
|
+
* decodes to 30 bytes instead of 32 and every lookup silently returns
|
|
192
|
+
* "no metadata", which is precisely the kind of quiet failure that
|
|
193
|
+
* produces a false accusation (or a missed one). We therefore verify it
|
|
194
|
+
* at runtime (see `assertMetadataProgram`) rather than trusting it.
|
|
195
|
+
*/
|
|
196
|
+
export const METADATA_PROGRAM_ID = 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s';
|
|
197
|
+
/**
|
|
198
|
+
* Verify the metadata program id by checking that a known-good control
|
|
199
|
+
* token's metadata account exists AND is owned by that program.
|
|
200
|
+
*
|
|
201
|
+
* If the id is wrong we fail loudly (return false) instead of silently
|
|
202
|
+
* reporting "this token has no name".
|
|
203
|
+
*/
|
|
204
|
+
export async function assertMetadataProgram(rpc) {
|
|
205
|
+
const programBytes = base58Decode(METADATA_PROGRAM_ID);
|
|
206
|
+
if (programBytes.length !== 32)
|
|
207
|
+
return false;
|
|
208
|
+
const control = 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263'; // BONK
|
|
209
|
+
const controlBytes = base58Decode(control);
|
|
210
|
+
let pda;
|
|
211
|
+
try {
|
|
212
|
+
const found = findProgramAddress([Buffer.from('metadata', 'utf8'), programBytes, controlBytes], programBytes);
|
|
213
|
+
pda = base58Encode(found.address);
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
const res = await rpc.callDetailed('getAccountInfo', [pda, { encoding: 'base64' }]);
|
|
219
|
+
const acc = res.value?.value;
|
|
220
|
+
if (!acc?.data?.[0])
|
|
221
|
+
return false;
|
|
222
|
+
if (acc.owner !== METADATA_PROGRAM_ID)
|
|
223
|
+
return false;
|
|
224
|
+
const buf = Buffer.from(acc.data[0], 'base64');
|
|
225
|
+
if (buf.length < 70)
|
|
226
|
+
return false;
|
|
227
|
+
const nameLen = buf.readUInt32LE(65);
|
|
228
|
+
if (nameLen > 200 || 69 + nameLen > buf.length)
|
|
229
|
+
return false;
|
|
230
|
+
const name = buf.subarray(69, 69 + nameLen).toString('utf8').replace(/\0+$/, '');
|
|
231
|
+
return name.length > 0;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Self-test for the PDA derivation, with NO network access.
|
|
235
|
+
*
|
|
236
|
+
* These are the ground-truth addresses we read off the chain and the
|
|
237
|
+
* bumps the chain actually used. If any of these change, the derivation
|
|
238
|
+
* has regressed and every metadata lookup will silently return null.
|
|
239
|
+
*
|
|
240
|
+
* This exists because we shipped a broken derivation twice (missing the
|
|
241
|
+
* "ProgramDerivedAddress" marker, then big-endian field elements) and
|
|
242
|
+
* both bugs failed SILENTLY — no error, just "no metadata found".
|
|
243
|
+
* A silent failure in a tool that makes accusations is unacceptable.
|
|
244
|
+
*/
|
|
245
|
+
export const PDA_SELF_TEST = [
|
|
246
|
+
{
|
|
247
|
+
mint: 'BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp',
|
|
248
|
+
expected: 'GAdojRnay14YfzcYUWzd52qGuZUpKKkvbduxykWXnUuz',
|
|
249
|
+
bump: 255,
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
mint: '9vDguocExRQTPMjvULQCKCyti4ZycqzAQmcBjg8AsHdy',
|
|
253
|
+
expected: '9bzd7XMbV2yfdEGifUHia6mzbVbKDj8CuYsQWnSmXpcm',
|
|
254
|
+
bump: 255,
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
258
|
+
expected: '5x38Kp4hvdomTCnCrAny4UtMUt5rQBdB6px2K1Ui45Wq',
|
|
259
|
+
bump: 255,
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
mint: 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263',
|
|
263
|
+
expected: 'FDZZbyY9XGpL3CNKUZxLk3wFTTQYL3TkDiDzqxrizcPN',
|
|
264
|
+
bump: 250,
|
|
265
|
+
},
|
|
266
|
+
];
|
|
267
|
+
/** Run the offline PDA self-test. Returns the list of failures (empty = pass). */
|
|
268
|
+
export function pdaSelfTest() {
|
|
269
|
+
const failures = [];
|
|
270
|
+
const programBytes = base58Decode(METADATA_PROGRAM_ID);
|
|
271
|
+
if (programBytes.length !== 32) {
|
|
272
|
+
failures.push(`metadata program id decodes to ${programBytes.length} bytes, expected 32`);
|
|
273
|
+
return failures;
|
|
274
|
+
}
|
|
275
|
+
for (const c of PDA_SELF_TEST) {
|
|
276
|
+
const mintBytes = base58Decode(c.mint);
|
|
277
|
+
let got;
|
|
278
|
+
let gotBump;
|
|
279
|
+
try {
|
|
280
|
+
const found = findProgramAddress([Buffer.from('metadata', 'utf8'), programBytes, mintBytes], programBytes);
|
|
281
|
+
got = base58Encode(found.address);
|
|
282
|
+
gotBump = found.bump;
|
|
283
|
+
}
|
|
284
|
+
catch (e) {
|
|
285
|
+
failures.push(`${c.mint}: derivation threw ${e.message}`);
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
if (got !== c.expected) {
|
|
289
|
+
failures.push(`${c.mint}: derived ${got}, expected ${c.expected}`);
|
|
290
|
+
}
|
|
291
|
+
if (gotBump !== c.bump) {
|
|
292
|
+
failures.push(`${c.mint}: bump ${gotBump}, expected ${c.bump}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return failures;
|
|
296
|
+
}
|
|
297
|
+
function decodeMetadata(buf) {
|
|
298
|
+
let o = 1; // key
|
|
299
|
+
o += 32; // update authority
|
|
300
|
+
o += 32; // mint
|
|
301
|
+
const nameLen = buf.readUInt32LE(o);
|
|
302
|
+
o += 4;
|
|
303
|
+
const name = buf.subarray(o, o + nameLen).toString('utf8').replace(/\0+$/, '');
|
|
304
|
+
o += nameLen;
|
|
305
|
+
const symLen = buf.readUInt32LE(o);
|
|
306
|
+
o += 4;
|
|
307
|
+
const symbol = buf.subarray(o, o + symLen).toString('utf8').replace(/\0+$/, '');
|
|
308
|
+
o += symLen;
|
|
309
|
+
const uriLen = buf.readUInt32LE(o);
|
|
310
|
+
o += 4;
|
|
311
|
+
const uri = buf.subarray(o, o + uriLen).toString('utf8').replace(/\0+$/, '');
|
|
312
|
+
o += uriLen;
|
|
313
|
+
const sellerFee = buf.readUInt16LE(o);
|
|
314
|
+
o += 2;
|
|
315
|
+
const creators = [];
|
|
316
|
+
const creatorCount = buf.readUInt32LE(o);
|
|
317
|
+
o += 4;
|
|
318
|
+
for (let i = 0; i < creatorCount && o + 34 <= buf.length; i++) {
|
|
319
|
+
creators.push({
|
|
320
|
+
address: base58Encode(buf.subarray(o, o + 32)),
|
|
321
|
+
verified: buf[o + 32] === 1,
|
|
322
|
+
share: buf[o + 33],
|
|
323
|
+
});
|
|
324
|
+
o += 34;
|
|
325
|
+
}
|
|
326
|
+
return { name, symbol, uri, sellerFeeBasisPoints: sellerFee, creators };
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Parse a raw Metaplex metadata account.
|
|
330
|
+
*
|
|
331
|
+
* Exported so the operator sweep can decode hundreds of accounts in one
|
|
332
|
+
* `getMultipleAccounts` batch without paying one RPC round-trip per mint.
|
|
333
|
+
* Returns null for anything that does not parse as metadata, and always
|
|
334
|
+
* reports the mint the account declares — a PDA collision or a stale
|
|
335
|
+
* derivation would otherwise let us attribute the wrong name to a token.
|
|
336
|
+
*/
|
|
337
|
+
export function parseMetadataAccount(buf) {
|
|
338
|
+
if (buf.length < 70)
|
|
339
|
+
return null;
|
|
340
|
+
try {
|
|
341
|
+
const m = decodeMetadata(buf);
|
|
342
|
+
if (!m.name && !m.symbol)
|
|
343
|
+
return null;
|
|
344
|
+
return {
|
|
345
|
+
mint: base58Encode(buf.subarray(33, 65)),
|
|
346
|
+
name: m.name,
|
|
347
|
+
symbol: m.symbol,
|
|
348
|
+
uri: m.uri,
|
|
349
|
+
sellerFeeBasisPoints: m.sellerFeeBasisPoints,
|
|
350
|
+
creators: m.creators,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
catch {
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Read a mint's on-chain metadata.
|
|
359
|
+
*
|
|
360
|
+
* The metadata account is a PDA derived from
|
|
361
|
+
* ["metadata", metadata_program_id, mint]
|
|
362
|
+
* using Solana's canonical `find_program_address` (which includes the
|
|
363
|
+
* "ProgramDerivedAddress" marker in the hash). One `getAccountInfo` call.
|
|
364
|
+
*
|
|
365
|
+
* We additionally verify the account's OWNER is the metadata program and
|
|
366
|
+
* that the mint recorded inside the account matches the mint we asked
|
|
367
|
+
* about — a PDA collision or a stale derivation would otherwise let us
|
|
368
|
+
* report the wrong token's name.
|
|
369
|
+
*
|
|
370
|
+
* Returns null when the mint has no Metaplex metadata account, which is
|
|
371
|
+
* itself a finding: a token with no metadata has no name to show.
|
|
372
|
+
*/
|
|
373
|
+
export async function tokenMetadata(rpc, mint) {
|
|
374
|
+
const programId = METADATA_PROGRAM_ID;
|
|
375
|
+
const programBytes = base58Decode(programId);
|
|
376
|
+
if (programBytes.length !== 32)
|
|
377
|
+
return null;
|
|
378
|
+
const mintBytes = base58Decode(mint);
|
|
379
|
+
if (mintBytes.length !== 32)
|
|
380
|
+
return null;
|
|
381
|
+
let pda;
|
|
382
|
+
let bump;
|
|
383
|
+
try {
|
|
384
|
+
const found = findProgramAddress([Buffer.from('metadata', 'utf8'), programBytes, mintBytes], programBytes);
|
|
385
|
+
pda = base58Encode(found.address);
|
|
386
|
+
bump = found.bump;
|
|
387
|
+
}
|
|
388
|
+
catch {
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
const res = await rpc.callDetailed('getAccountInfo', [pda, { encoding: 'base64' }]);
|
|
392
|
+
const acc = res.value?.value;
|
|
393
|
+
if (!acc?.data?.[0])
|
|
394
|
+
return null;
|
|
395
|
+
// Trust only accounts the metadata program actually owns.
|
|
396
|
+
if (acc.owner !== programId)
|
|
397
|
+
return null;
|
|
398
|
+
const buf = Buffer.from(acc.data[0], 'base64');
|
|
399
|
+
if (buf.length < 70)
|
|
400
|
+
return null;
|
|
401
|
+
try {
|
|
402
|
+
const m = decodeMetadata(buf);
|
|
403
|
+
if (!m.name && !m.symbol)
|
|
404
|
+
return null;
|
|
405
|
+
// The account must declare the mint we asked about.
|
|
406
|
+
const declaredMint = base58Encode(buf.subarray(33, 65));
|
|
407
|
+
if (declaredMint !== mint)
|
|
408
|
+
return null;
|
|
409
|
+
return {
|
|
410
|
+
mint,
|
|
411
|
+
name: m.name,
|
|
412
|
+
symbol: m.symbol,
|
|
413
|
+
uri: m.uri,
|
|
414
|
+
sellerFeeBasisPoints: m.sellerFeeBasisPoints,
|
|
415
|
+
creators: m.creators,
|
|
416
|
+
metadataPda: pda,
|
|
417
|
+
bump,
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
catch {
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
//# sourceMappingURL=tokenmeta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenmeta.js","sourceRoot":"","sources":["../src/tokenmeta.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,0CAA0C;AAC1C,EAAE;AACF,qDAAqD;AACrD,kEAAkE;AAClE,mEAAmE;AACnE,yEAAyE;AACzE,EAAE;AACF,wEAAwE;AACxE,gCAAgC;AAChC,2DAA2D;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC;AAC7B,MAAM,CAAC,GAAG,8EAA8E,CAAC;AAEzF,SAAS,GAAG,CAAC,CAAS,EAAE,IAAY,CAAC;IACnC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,MAAM,CAAC,IAAY,EAAE,GA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