chain-insights 0.74.1 → 0.76.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/README.md +3 -2
- package/dist/{action-log-D49Par9P.mjs → action-log-Byv9Ln_6.mjs} +4 -10
- package/dist/{action-log-D49Par9P.mjs.map → action-log-Byv9Ln_6.mjs.map} +1 -1
- package/dist/{action-log-HniMMF7f.cjs → action-log-WMW6xFMx.cjs} +3 -9
- package/dist/{active-Dkf8AB1R.mjs → active-D2aabYRF.mjs} +3 -4
- package/dist/{active-Dkf8AB1R.mjs.map → active-D2aabYRF.mjs.map} +1 -1
- package/dist/{active-Bc13hJIm.cjs → active-q3yViZhc.cjs} +2 -3
- package/dist/answer-hint-BlYEBq_Y.cjs +57 -0
- package/dist/answer-hint-vOE1O6Lf.mjs +48 -0
- package/dist/answer-hint-vOE1O6Lf.mjs.map +1 -0
- package/dist/{buy-_mpdRieG.mjs → buy-B2luUbWF.mjs} +5 -6
- package/dist/{buy-_mpdRieG.mjs.map → buy-B2luUbWF.mjs.map} +1 -1
- package/dist/{buy-97M6dtEu.cjs → buy-DEoGITbT.cjs} +4 -5
- package/dist/{cache-location-CBVzUIxq.cjs → cache-location-C09AE55j.cjs} +2 -3
- package/dist/{cache-location-BO2XkfgI.mjs → cache-location-DxTTqBwk.mjs} +2 -3
- package/dist/{cache-location-BO2XkfgI.mjs.map → cache-location-DxTTqBwk.mjs.map} +1 -1
- package/dist/{call-args-B0oMK1-J.mjs → call-args-CBqbYfOE.mjs} +15 -4
- package/dist/{call-args-B0oMK1-J.mjs.map → call-args-CBqbYfOE.mjs.map} +1 -1
- package/dist/{call-args-C8Gp5gco.cjs → call-args-DXEmPeE-.cjs} +14 -2
- package/dist/{capabilities-DxojbX4D.mjs → capabilities-BRNHcabF.mjs} +5 -11
- package/dist/{capabilities-DxojbX4D.mjs.map → capabilities-BRNHcabF.mjs.map} +1 -1
- package/dist/{capabilities-Ds3320iS.cjs → capabilities-DalimVY2.cjs} +4 -10
- package/dist/{claude-desktop-Jmm4PlBZ.cjs → claude-desktop-3OksQZVE.cjs} +2 -3
- package/dist/{claude-desktop-6jwX0Lux.mjs → claude-desktop-C1SDYAP2.mjs} +2 -3
- package/dist/{claude-desktop-6jwX0Lux.mjs.map → claude-desktop-C1SDYAP2.mjs.map} +1 -1
- package/dist/cli.cjs +95 -76
- package/dist/cli.mjs +94 -75
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-7qOfAdpH.mjs → client-BaHAIidE.mjs} +10 -21
- package/dist/{client-7qOfAdpH.mjs.map → client-BaHAIidE.mjs.map} +1 -1
- package/dist/{client-C9uwHnBS.cjs → client-Ddk4X9Ko.cjs} +9 -20
- package/dist/{config-BxtMoo9c.cjs → config-BdE8LcF-.cjs} +3 -5
- package/dist/{config-9MabJh5R.mjs → config-BkLIqOYq.mjs} +4 -6
- package/dist/{config-9MabJh5R.mjs.map → config-BkLIqOYq.mjs.map} +1 -1
- package/dist/{create-CpfZq2fx.mjs → create-CluDZkuF.mjs} +3 -4
- package/dist/{create-CpfZq2fx.mjs.map → create-CluDZkuF.mjs.map} +1 -1
- package/dist/{create-DdggkF04.cjs → create-DvBumvHn.cjs} +2 -3
- package/dist/{dex-registry-Chs79Ukc.cjs → dex-registry-CZQB2YhU.cjs} +4 -26
- package/dist/{dex-registry-rziydXYq.mjs → dex-registry-D6Xxi_vr.mjs} +5 -27
- package/dist/{dex-registry-rziydXYq.mjs.map → dex-registry-D6Xxi_vr.mjs.map} +1 -1
- package/dist/{dex-tool-DsaAIa-a.mjs → dex-tool-BoAYqhZO.mjs} +13 -67
- package/dist/dex-tool-BoAYqhZO.mjs.map +1 -0
- package/dist/{dex-tool-DLWnff1n.cjs → dex-tool-DsM-pSku.cjs} +17 -77
- package/dist/{format-CSesEBvS.mjs → format-CsnW5M4D.mjs} +2 -3
- package/dist/{format-CSesEBvS.mjs.map → format-CsnW5M4D.mjs.map} +1 -1
- package/dist/{format-DfhRQq4L.cjs → format-DUzmoeaE.cjs} +1 -2
- package/dist/{graph-schema-BGbJumCY.cjs → graph-schema-C8Pi6r7c.cjs} +12 -29
- package/dist/{graph-schema-ClqjzgrM.mjs → graph-schema-D4LAefGf.mjs} +13 -30
- package/dist/graph-schema-D4LAefGf.mjs.map +1 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +0 -16
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -16
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/{known-keys-B87ZqOgE.mjs → known-keys-BbuzCZOW.mjs} +4 -7
- package/dist/{known-keys-B87ZqOgE.mjs.map → known-keys-BbuzCZOW.mjs.map} +1 -1
- package/dist/{known-keys-PKZF5GYd.cjs → known-keys-Cy8lKDOA.cjs} +3 -6
- package/dist/mcp-proxy.cjs +83 -57
- package/dist/mcp-proxy.d.cts +2 -2
- package/dist/mcp-proxy.d.cts.map +1 -1
- package/dist/mcp-proxy.d.mts +2 -2
- package/dist/mcp-proxy.d.mts.map +1 -1
- package/dist/mcp-proxy.mjs +81 -56
- package/dist/mcp-proxy.mjs.map +1 -1
- package/dist/{print-result-Cyqrlx8P.cjs → print-result-BYppJlUi.cjs} +20 -20
- package/dist/{print-result-C3YazZBw.mjs → print-result-IFARsMnL.mjs} +10 -22
- package/dist/print-result-IFARsMnL.mjs.map +1 -0
- package/dist/{public-tools-Bl_l_rKK.cjs → public-tools-Cfc1OPNS.cjs} +16 -21
- package/dist/{public-tools-CQjGt7_q.mjs → public-tools-DXlZcanX.mjs} +16 -21
- package/dist/public-tools-DXlZcanX.mjs.map +1 -0
- package/dist/{quote-DfTut0cx.mjs → quote-41CbMc37.mjs} +2 -3
- package/dist/{quote-DfTut0cx.mjs.map → quote-41CbMc37.mjs.map} +1 -1
- package/dist/{quote-B9sYNOiv.cjs → quote-pFKcSvMv.cjs} +1 -2
- package/dist/{request-timeout-CYmQF8N7.cjs → request-timeout-DxwNijQD.cjs} +1 -2
- package/dist/{request-timeout-lBBe0mGf.mjs → request-timeout-K3ljP0pa.mjs} +2 -3
- package/dist/{request-timeout-lBBe0mGf.mjs.map → request-timeout-K3ljP0pa.mjs.map} +1 -1
- package/dist/{robinhood-CCTMagwM.mjs → robinhood-0NZsA6ZW.mjs} +2 -3
- package/dist/robinhood-0NZsA6ZW.mjs.map +1 -0
- package/dist/{robinhood-ChiT69sc.cjs → robinhood-DumTxvlA.cjs} +1 -2
- package/dist/{rolldown-runtime-8H4AJuhK.mjs → rolldown-runtime-BJohB4LM.mjs} +1 -2
- package/dist/{rolldown-runtime-C0BPl7ul.cjs → rolldown-runtime-BW-eSwOZ.cjs} +1 -2
- package/dist/{rules-BWdbOtHi.mjs → rules-B3w9pCeQ.mjs} +2 -3
- package/dist/{rules-BWdbOtHi.mjs.map → rules-B3w9pCeQ.mjs.map} +1 -1
- package/dist/{rules-BD-cNHMX.cjs → rules-BKwfmNsJ.cjs} +1 -2
- package/dist/{schema-KjZqCHbu.mjs → schema-CKnQsdw9.mjs} +6 -13
- package/dist/{schema-KjZqCHbu.mjs.map → schema-CKnQsdw9.mjs.map} +1 -1
- package/dist/{schema-tX0U0-VI.cjs → schema-CSESfCvA.cjs} +5 -12
- package/dist/{schema-cache-DRObKUvS.mjs → schema-cache-BfKHodDY.mjs} +3 -4
- package/dist/{schema-cache-DRObKUvS.mjs.map → schema-cache-BfKHodDY.mjs.map} +1 -1
- package/dist/{schema-cache-C7v9ml6S.cjs → schema-cache-NLgJmh4X.cjs} +3 -4
- package/dist/{skill-refresh-xYWZ_hua.mjs → skill-refresh-BchIsODN.mjs} +2 -3
- package/dist/{skill-refresh-xYWZ_hua.mjs.map → skill-refresh-BchIsODN.mjs.map} +1 -1
- package/dist/{skill-refresh-Be2D5FrX.cjs → skill-refresh-DaCTxhhy.cjs} +2 -3
- package/dist/{subscription-status-DIuH84fM.mjs → subscription-status-5WfPhSep.mjs} +3 -4
- package/dist/{subscription-status-DIuH84fM.mjs.map → subscription-status-5WfPhSep.mjs.map} +1 -1
- package/dist/{subscription-status-9tMfD90J.cjs → subscription-status-w4zI2KCK.cjs} +2 -3
- package/dist/token-lookup-BJ00JO9A.cjs +342 -0
- package/dist/token-lookup-XnyisLQW.mjs +303 -0
- package/dist/token-lookup-XnyisLQW.mjs.map +1 -0
- package/dist/{tool-visibility-BNwvcuVx.cjs → tool-visibility-DIpgPULN.cjs} +5 -10
- package/dist/{tool-visibility-B6983rxo.mjs → tool-visibility-Dy3psowS.mjs} +6 -11
- package/dist/tool-visibility-Dy3psowS.mjs.map +1 -0
- package/dist/{tools-D9ep9E7Q.mjs → tools-6pZo4h_p.mjs} +6 -21
- package/dist/{tools-D9ep9E7Q.mjs.map → tools-6pZo4h_p.mjs.map} +1 -1
- package/dist/{tools-Cmnq7yip.cjs → tools-DZLizem9.cjs} +5 -20
- package/dist/{topup-B6gZbTmv.mjs → topup--7JTo4UQ.mjs} +6 -7
- package/dist/{topup-B6gZbTmv.mjs.map → topup--7JTo4UQ.mjs.map} +1 -1
- package/dist/{topup-DVTCU2le.cjs → topup-BgI9OcUd.cjs} +5 -6
- package/dist/{topup-server-ShuYSyBY.cjs → topup-server-D9Uk1Th3.cjs} +7 -24
- package/dist/{topup-server-KQDviFXG.mjs → topup-server-DR0HaUcR.mjs} +8 -25
- package/dist/{topup-server-KQDviFXG.mjs.map → topup-server-DR0HaUcR.mjs.map} +1 -1
- package/dist/{topup-server-BcT7DIpd.mjs → topup-server-DlwzFEF1.mjs} +5 -12
- package/dist/{topup-server-BcT7DIpd.mjs.map → topup-server-DlwzFEF1.mjs.map} +1 -1
- package/dist/{topup-server-f4Gx0vji.cjs → topup-server-H1M_7PJK.cjs} +4 -11
- package/dist/{transport-error-D4hmpkqL.mjs → transport-error-68G35VPH.mjs} +3 -4
- package/dist/{transport-error-D4hmpkqL.mjs.map → transport-error-68G35VPH.mjs.map} +1 -1
- package/dist/{transport-error-CgISST8l.cjs → transport-error-DXy1iTpS.cjs} +2 -3
- package/dist/{update-CZDHSi_u.mjs → update-BH8F4cQ2.mjs} +3 -4
- package/dist/{update-CZDHSi_u.mjs.map → update-BH8F4cQ2.mjs.map} +1 -1
- package/dist/{update-DGyRlm3J.cjs → update-DUDdQSEU.cjs} +2 -3
- package/dist/{usage-status-Frot6fPG.mjs → usage-status-BUZgRl4r.mjs} +3 -5
- package/dist/{usage-status-Frot6fPG.mjs.map → usage-status-BUZgRl4r.mjs.map} +1 -1
- package/dist/{usage-status-DonwoLR3.cjs → usage-status-DnV3I3gX.cjs} +2 -4
- package/dist/{wallet-QTo5YCFR.mjs → wallet-B1M0HdQh.mjs} +4 -8
- package/dist/{wallet-QTo5YCFR.mjs.map → wallet-B1M0HdQh.mjs.map} +1 -1
- package/dist/{wallet-CgIAfdxL.cjs → wallet-BubGd_sG.cjs} +3 -7
- package/docs/graph-query-compatibility.md +13 -13
- package/docs/graph-tools.md +22 -22
- package/docs/mcp-proxy.md +35 -1
- package/docs/stability.md +3 -2
- package/package.json +1 -1
- package/skills/chain-insights-cypher/SKILL.md +30 -27
- package/skills/chain-insights-dex/SKILL.md +2 -2
- package/skills/chain-insights-dex/reference.md +1 -1
- package/skills/chain-insights-dex-gauge/SKILL.md +4 -4
- package/skills/chain-insights-dex-launchpad/SKILL.md +2 -2
- package/skills/chain-insights-virtuals/reference.md +5 -5
- package/dist/dex-tool-DsaAIa-a.mjs.map +0 -1
- package/dist/graph-schema-ClqjzgrM.mjs.map +0 -1
- package/dist/print-result-C3YazZBw.mjs.map +0 -1
- package/dist/public-tools-CQjGt7_q.mjs.map +0 -1
- package/dist/robinhood-CCTMagwM.mjs.map +0 -1
- package/dist/tool-visibility-B6983rxo.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-
|
|
1
|
+
{"version":3,"file":"update-BH8F4cQ2.mjs","names":[],"sources":["../src/update.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process'\nimport type { Readable, Writable } from 'node:stream'\nimport { createInterface } from 'node:readline/promises'\nimport { stdin, stdout } from 'node:process'\nimport { PACKAGE_INFO, PACKAGE_VERSION } from './version.js'\n\nconst DEFAULT_REGISTRY_URL = 'https://registry.npmjs.org'\nconst DEFAULT_TIMEOUT_MS = 3000\n\nexport interface UpdateCheckOptions {\n packageName?: string\n currentVersion?: string\n registryUrl?: string\n timeoutMs?: number\n fetchImpl?: typeof fetch\n}\n\nexport interface UpdateCheckResult {\n packageName: string\n currentVersion: string\n latestVersion?: string\n updateAvailable: boolean\n updateCommand: string\n error?: string\n}\n\nexport interface NpmInvocation {\n command: string\n args: string[]\n displayCommand: string\n}\n\nexport interface UpdatePromptOptions extends UpdateCheckOptions {\n input?: NodeJS.ReadStream & Readable\n output?: NodeJS.WriteStream & Writable\n env?: NodeJS.ProcessEnv\n}\n\nexport function compareSemverVersions(a: string, b: string): number {\n const left = parseSemverCore(a)\n const right = parseSemverCore(b)\n for (let i = 0; i < 3; i += 1) {\n if (left[i] > right[i]) return 1\n if (left[i] < right[i]) return -1\n }\n return 0\n}\n\nexport function resolveUpdateRegistryUrl(env: NodeJS.ProcessEnv = process.env): string {\n return env['CHAIN_INSIGHTS_NPM_REGISTRY_URL']?.trim() || DEFAULT_REGISTRY_URL\n}\n\nexport function buildPackageLatestUrl(\n packageName: string,\n registryUrl = DEFAULT_REGISTRY_URL\n): string {\n const base = registryUrl.endsWith('/') ? registryUrl.slice(0, -1) : registryUrl\n return `${base}/${encodeURIComponent(packageName)}/latest`\n}\n\nexport function resolveNpmUpdateInvocation(\n packageName = PACKAGE_INFO.name,\n env: NodeJS.ProcessEnv = process.env\n): NpmInvocation {\n const packageSpec = `${packageName}@latest`\n const displayCommand = `npm install -g ${packageSpec}`\n const npmExecPath = env['npm_execpath']?.trim()\n if (npmExecPath) {\n return {\n command: process.execPath,\n args: [npmExecPath, 'install', '-g', packageSpec],\n displayCommand,\n }\n }\n return {\n command: process.platform === 'win32' ? 'npm.cmd' : 'npm',\n args: ['install', '-g', packageSpec],\n displayCommand,\n }\n}\n\nexport async function fetchLatestPackageVersion(options: UpdateCheckOptions = {}): Promise<string> {\n const packageName = options.packageName ?? PACKAGE_INFO.name\n const registryUrl = options.registryUrl ?? resolveUpdateRegistryUrl()\n const fetchImpl = options.fetchImpl ?? fetch\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort(), options.timeoutMs ?? DEFAULT_TIMEOUT_MS)\n\n try {\n const response = await fetchImpl(buildPackageLatestUrl(packageName, registryUrl), {\n headers: {\n accept: 'application/json',\n 'user-agent': `chain-insights/${PACKAGE_VERSION}`,\n },\n signal: controller.signal,\n })\n if (!response.ok) {\n throw new Error(`npmjs registry returned ${response.status}`)\n }\n const body = (await response.json()) as { version?: unknown }\n if (typeof body.version !== 'string' || !body.version.trim()) {\n throw new Error('npmjs registry response did not include a version')\n }\n return body.version.trim()\n } finally {\n clearTimeout(timeout)\n }\n}\n\nexport async function checkForUpdate(options: UpdateCheckOptions = {}): Promise<UpdateCheckResult> {\n const packageName = options.packageName ?? PACKAGE_INFO.name\n const currentVersion = options.currentVersion ?? PACKAGE_VERSION\n const updateCommand = resolveNpmUpdateInvocation(packageName).displayCommand\n try {\n const latestVersion = await fetchLatestPackageVersion(options)\n return {\n packageName,\n currentVersion,\n latestVersion,\n updateAvailable: compareSemverVersions(latestVersion, currentVersion) > 0,\n updateCommand,\n }\n } catch (err) {\n return {\n packageName,\n currentVersion,\n updateAvailable: false,\n updateCommand,\n error: (err as Error).message,\n }\n }\n}\n\nexport function runPackageUpdate(packageName = PACKAGE_INFO.name): void {\n const invocation = resolveNpmUpdateInvocation(packageName)\n const result = spawnSync(invocation.command, invocation.args, { stdio: 'inherit' })\n if (result.error) {\n throw result.error\n }\n if (result.status !== 0) {\n const detail = result.signal\n ? `signal ${result.signal}`\n : `exit code ${result.status ?? 'unknown'}`\n throw new Error(`Update failed with ${detail}`)\n }\n}\n\nexport function shouldPromptForUpdate(options: UpdatePromptOptions = {}): boolean {\n const env = options.env ?? process.env\n if (env['CHAIN_INSIGHTS_SKIP_UPDATE_CHECK'] === '1') return false\n if (env['CI'] === 'true') return false\n const input = options.input ?? stdin\n const output = options.output ?? stdout\n return input.isTTY === true && output.isTTY === true\n}\n\nexport async function maybePromptForUpdate(options: UpdatePromptOptions = {}): Promise<void> {\n if (!shouldPromptForUpdate(options)) return\n\n const check = await checkForUpdate(options)\n if (check.error || !check.updateAvailable || !check.latestVersion) return\n\n const output = options.output ?? stdout\n output.write(\n `\\nChain Insights ${check.latestVersion} is available (current ${check.currentVersion}).\\n`\n )\n output.write(`Update command: ${check.updateCommand}\\n`)\n\n const rl = createInterface({\n input: options.input ?? stdin,\n output,\n })\n try {\n const answer = await rl.question('Update now? [Y/n] ')\n if (!answer.trim() || answer.trim().toLowerCase().startsWith('y')) {\n try {\n runPackageUpdate(check.packageName)\n } catch (err) {\n output.write(`Update failed: ${(err as Error).message}\\n`)\n output.write('Workspace initialization is complete. Run `cia update` when ready.\\n')\n }\n } else {\n output.write('Skipped update. Run `cia update` when ready.\\n')\n }\n } finally {\n rl.close()\n }\n}\n\nfunction parseSemverCore(version: string): [number, number, number] {\n const match = /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:[-+].*)?$/.exec(version)\n if (!match) throw new Error(`Invalid semver version: ${version}`)\n return [Number(match[1]), Number(match[2]), Number(match[3])]\n}\n"],"mappings":";;;AAMA,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB;AA+B3B,SAAgB,sBAAsB,GAAW,GAAmB;CAClE,MAAM,OAAO,gBAAgB,CAAC;CAC9B,MAAM,QAAQ,gBAAgB,CAAC;CAC/B,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG;EAC7B,IAAI,KAAK,KAAK,MAAM,IAAI,OAAO;EAC/B,IAAI,KAAK,KAAK,MAAM,IAAI,OAAO;CACjC;CACA,OAAO;AACT;AAEA,SAAgB,yBAAyB,MAAyB,QAAQ,KAAa;CACrF,OAAO,IAAI,kCAAkC,EAAE,KAAK,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,cAAc,QAAQ,eAAe,aAAa;CACxD,MAAM,iBAAiB,QAAQ,kBAAkB;CACjD,MAAM,gBAAgB,2BAA2B,WAAW,CAAC,CAAC;CAC9D,IAAI;EACF,MAAM,gBAAgB,MAAM,0BAA0B,OAAO;EAC7D,OAAO;GACL;GACA;GACA;GACA,iBAAiB,sBAAsB,eAAe,cAAc,IAAI;GACxE;EACF;CACF,SAAS,KAAK;EACZ,OAAO;GACL;GACA;GACA,iBAAiB;GACjB;GACA,OAAQ,IAAc;EACxB;CACF;AACF;AAEA,SAAgB,iBAAiB,cAAc,aAAa,MAAY;CACtE,MAAM,aAAa,2BAA2B,WAAW;CACzD,MAAM,SAAS,UAAU,WAAW,SAAS,WAAW,MAAM,EAAE,OAAO,UAAU,CAAC;CAClF,IAAI,OAAO,OACT,MAAM,OAAO;CAEf,IAAI,OAAO,WAAW,GAAG;EACvB,MAAM,SAAS,OAAO,SAClB,UAAU,OAAO,WACjB,aAAa,OAAO,UAAU;EAClC,MAAM,IAAI,MAAM,sBAAsB,QAAQ;CAChD;AACF;AA4CA,SAAS,gBAAgB,SAA2C;CAClE,MAAM,QAAQ,wDAAwD,KAAK,OAAO;CAClF,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,2BAA2B,SAAS;CAChE,OAAO;EAAC,OAAO,MAAM,EAAE;EAAG,OAAO,MAAM,EAAE;EAAG,OAAO,MAAM,EAAE;CAAC;AAC9D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_print_result = require("./print-result-
|
|
1
|
+
const require_print_result = require("./print-result-BYppJlUi.cjs");
|
|
2
2
|
let node_child_process = require("node:child_process");
|
|
3
|
-
|
|
3
|
+
// src/update.ts
|
|
4
4
|
const DEFAULT_REGISTRY_URL = "https://registry.npmjs.org";
|
|
5
5
|
const DEFAULT_TIMEOUT_MS = 3e3;
|
|
6
6
|
function compareSemverVersions(a, b) {
|
|
@@ -105,6 +105,5 @@ function parseSemverCore(version) {
|
|
|
105
105
|
Number(match[3])
|
|
106
106
|
];
|
|
107
107
|
}
|
|
108
|
-
//#endregion
|
|
109
108
|
exports.checkForUpdate = checkForUpdate;
|
|
110
109
|
exports.runPackageUpdate = runPackageUpdate;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
2
|
-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.mjs";
|
|
2
|
+
// src/mcp/usage-status.ts
|
|
3
3
|
var usage_status_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
-
freeTierSpentText: () => freeTierSpentText,
|
|
5
4
|
isMissingUsageStatusToolError: () => isMissingUsageStatusToolError,
|
|
6
5
|
primitiveBackendUsageStatus: () => primitiveBackendUsageStatus,
|
|
7
6
|
usageStatusText: () => usageStatusText
|
|
@@ -59,7 +58,6 @@ function resetAtText(iso) {
|
|
|
59
58
|
const pad = (n) => String(n).padStart(2, "0");
|
|
60
59
|
return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())} UTC`;
|
|
61
60
|
}
|
|
62
|
-
//#endregion
|
|
63
61
|
export { primitiveBackendUsageStatus as n, usage_status_exports as r, freeTierSpentText as t };
|
|
64
62
|
|
|
65
|
-
//# sourceMappingURL=usage-status-
|
|
63
|
+
//# sourceMappingURL=usage-status-BUZgRl4r.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-status-
|
|
1
|
+
{"version":3,"file":"usage-status-BUZgRl4r.mjs","names":[],"sources":["../src/mcp/usage-status.ts"],"sourcesContent":["export type UsageStatusResult = {\n schema: 'chain-insights.result.v1'\n tool: 'meta_usage_status'\n facts: {\n usage: {\n mode: 'primitive_graph_backend'\n quota_enforced: false\n usage_status_tool: 'unavailable'\n }\n backend: {\n endpoint: string\n reason: string\n }\n }\n hint: string\n}\n\nexport function primitiveBackendUsageStatus(endpoint: string): UsageStatusResult {\n return {\n schema: 'chain-insights.result.v1',\n tool: 'meta_usage_status',\n facts: {\n usage: {\n mode: 'primitive_graph_backend',\n quota_enforced: false,\n usage_status_tool: 'unavailable',\n },\n backend: {\n endpoint,\n reason: 'The graph backend exposes primitive graph tools but no usage_status quota tool.',\n },\n },\n hint: 'This backend does not expose Chain Insights quota telemetry; calls against it are treated as unmetered by Chain Insights.',\n }\n}\n\nexport function usageStatusText(result: UsageStatusResult): string {\n return JSON.stringify(result, null, 2)\n}\n\nexport function isMissingUsageStatusToolError(err: unknown): boolean {\n const message = String((err as Error).message ?? err).toLowerCase()\n return (\n message.includes('unknown tool') ||\n message.includes('tool not found') ||\n message.includes('method not found') ||\n message.includes('usage_status')\n )\n}\n\n/**\n * The first sentence of a payment failure when the caller's free tier for the\n * day is spent. The server gives every caller 5,000 free units a day before\n * it answers 402, so a payment failure right after that is a used-up free\n * tier, not a service that must be paid for to try. `usage` is the\n * `facts.usage` object a `usage_status` read answers with. Undefined when the\n * quota is not spent, or the object is not a free-tier quota.\n */\nexport function freeTierSpentText(usage: unknown): string | undefined {\n if (typeof usage !== 'object' || usage === null) return undefined\n const u = usage as Record<string, unknown>\n if (u['access_mode'] !== 'public_free') return undefined\n const remaining = Number(u['remaining_units'])\n if (!Number.isFinite(remaining) || remaining > 0) return undefined\n const used = Number(u['daily_units_used'])\n const limit = Number(u['daily_units_limit'])\n const units =\n Number.isFinite(used) && Number.isFinite(limit)\n ? `${used.toLocaleString('en-US')} of ${limit.toLocaleString('en-US')} free units`\n : 'every free unit'\n const resetAt = typeof u['reset_at'] === 'string' ? u['reset_at'] : undefined\n const reset = resetAt ? resetAtText(resetAt) : 'midnight UTC'\n const who = u['identifier_kind'] === 'ip' ? 'this network address' : 'this caller'\n return (\n `The free tier for today is used up: ${who} spent ${units}, and the quota resets at ${reset}. ` +\n 'Until then every graph call is paid per call.'\n )\n}\n\nfunction resetAtText(iso: string): string {\n const ms = Date.parse(iso)\n if (!Number.isFinite(ms)) return iso\n const d = new Date(ms)\n const pad = (n: number) => String(n).padStart(2, '0')\n return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())} UTC`\n}\n"],"mappings":";;;;;;;AAiBA,SAAgB,4BAA4B,UAAqC;CAC/E,OAAO;EACL,QAAQ;EACR,MAAM;EACN,OAAO;GACL,OAAO;IACL,MAAM;IACN,gBAAgB;IAChB,mBAAmB;GACrB;GACA,SAAS;IACP;IACA,QAAQ;GACV;EACF;EACA,MAAM;CACR;AACF;AAEA,SAAgB,gBAAgB,QAAmC;CACjE,OAAO,KAAK,UAAU,QAAQ,MAAM,CAAC;AACvC;AAEA,SAAgB,8BAA8B,KAAuB;CACnE,MAAM,UAAU,OAAQ,IAAc,WAAW,GAAG,CAAC,CAAC,YAAY;CAClE,OACE,QAAQ,SAAS,cAAc,KAC/B,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,kBAAkB,KACnC,QAAQ,SAAS,cAAc;AAEnC;;;;;;;;;AAUA,SAAgB,kBAAkB,OAAoC;CACpE,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO,KAAA;CACxD,MAAM,IAAI;CACV,IAAI,EAAE,mBAAmB,eAAe,OAAO,KAAA;CAC/C,MAAM,YAAY,OAAO,EAAE,kBAAkB;CAC7C,IAAI,CAAC,OAAO,SAAS,SAAS,KAAK,YAAY,GAAG,OAAO,KAAA;CACzD,MAAM,OAAO,OAAO,EAAE,mBAAmB;CACzC,MAAM,QAAQ,OAAO,EAAE,oBAAoB;CAC3C,MAAM,QACJ,OAAO,SAAS,IAAI,KAAK,OAAO,SAAS,KAAK,IAC1C,GAAG,KAAK,eAAe,OAAO,EAAE,MAAM,MAAM,eAAe,OAAO,EAAE,eACpE;CACN,MAAM,UAAU,OAAO,EAAE,gBAAgB,WAAW,EAAE,cAAc,KAAA;CACpE,MAAM,QAAQ,UAAU,YAAY,OAAO,IAAI;CAE/C,OACE,uCAFU,EAAE,uBAAuB,OAAO,yBAAyB,cAExB,SAAS,MAAM,4BAA4B,MAAM;AAGhG;AAEA,SAAS,YAAY,KAAqB;CACxC,MAAM,KAAK,KAAK,MAAM,GAAG;CACzB,IAAI,CAAC,OAAO,SAAS,EAAE,GAAG,OAAO;CACjC,MAAM,IAAI,IAAI,KAAK,EAAE;CACrB,MAAM,OAAO,MAAc,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;CACpD,OAAO,GAAG,EAAE,eAAe,EAAE,GAAG,IAAI,EAAE,YAAY,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,EAAE,GAAG,IAAI,EAAE,YAAY,CAAC,EAAE,GAAG,IAAI,EAAE,cAAc,CAAC,EAAE;AACpI"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
var usage_status_exports = /* @__PURE__ */ require("./rolldown-runtime-
|
|
3
|
-
freeTierSpentText: () => freeTierSpentText,
|
|
1
|
+
// src/mcp/usage-status.ts
|
|
2
|
+
var usage_status_exports = /* @__PURE__ */ require("./rolldown-runtime-BW-eSwOZ.cjs").__exportAll({
|
|
4
3
|
isMissingUsageStatusToolError: () => isMissingUsageStatusToolError,
|
|
5
4
|
primitiveBackendUsageStatus: () => primitiveBackendUsageStatus,
|
|
6
5
|
usageStatusText: () => usageStatusText
|
|
@@ -58,7 +57,6 @@ function resetAtText(iso) {
|
|
|
58
57
|
const pad = (n) => String(n).padStart(2, "0");
|
|
59
58
|
return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())} UTC`;
|
|
60
59
|
}
|
|
61
|
-
//#endregion
|
|
62
60
|
Object.defineProperty(exports, "freeTierSpentText", {
|
|
63
61
|
enumerable: true,
|
|
64
62
|
get: function() {
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
2
|
-
import { n as assertPrivateKeyNotPublic, r as isPrivateKeyPublic } from "./known-keys-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.mjs";
|
|
2
|
+
import { n as assertPrivateKeyNotPublic, r as isPrivateKeyPublic } from "./known-keys-BbuzCZOW.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import crypto from "node:crypto";
|
|
7
7
|
import { privateKeyToAccount } from "viem/accounts";
|
|
8
|
-
|
|
8
|
+
// src/wallet/index.ts
|
|
9
9
|
var wallet_exports = /* @__PURE__ */ __exportAll({
|
|
10
10
|
assertStoredWalletReplaceable: () => assertStoredWalletReplaceable,
|
|
11
11
|
decryptKey: () => decryptKey,
|
|
12
|
-
encryptKey: () => encryptKey,
|
|
13
12
|
isWalletConfigured: () => isWalletConfigured,
|
|
14
|
-
normalizeWalletPrivateKey: () => normalizeWalletPrivateKey,
|
|
15
13
|
replacePublicWallet: () => replacePublicWallet,
|
|
16
14
|
setWalletPrivateKey: () => setWalletPrivateKey,
|
|
17
15
|
storedWalletKeyIsPublic: () => storedWalletKeyIsPublic,
|
|
18
|
-
walletAddressFromPrivateKey: () => walletAddressFromPrivateKey,
|
|
19
16
|
walletPath: () => walletPath
|
|
20
17
|
});
|
|
21
18
|
function walletPath() {
|
|
@@ -174,7 +171,6 @@ async function isWalletConfigured() {
|
|
|
174
171
|
throw err;
|
|
175
172
|
}
|
|
176
173
|
}
|
|
177
|
-
//#endregion
|
|
178
174
|
export { setWalletPrivateKey as a, normalizeWalletPrivateKey as i, encryptKey as n, walletAddressFromPrivateKey as o, isWalletConfigured as r, wallet_exports as s, decryptKey as t };
|
|
179
175
|
|
|
180
|
-
//# sourceMappingURL=wallet-
|
|
176
|
+
//# sourceMappingURL=wallet-B1M0HdQh.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-QTo5YCFR.mjs","names":["nodeErr"],"sources":["../src/wallet/index.ts"],"sourcesContent":["import crypto from 'node:crypto'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { readFile, writeFile, mkdir, stat } from 'node:fs/promises'\nimport type { Address, Hex } from 'viem'\nimport { privateKeyToAccount } from 'viem/accounts'\nimport { assertPrivateKeyNotPublic, isPrivateKeyPublic } from './known-keys.js'\n\n// Path derived at call time so tests can override HOME.\nexport function walletPath(): string {\n return path.join(os.homedir(), '.chain-insights', 'wallet.json')\n}\n\n// Derive a 32-byte key from the machine identity (hostname + username) and a\n// random per-wallet salt. The salt prevents precomputation attacks across wallets.\nfunction deriveKey(salt: Buffer): Buffer {\n return crypto.scryptSync(`${os.hostname()}:${os.userInfo().username}`, salt, 32)\n}\n\ninterface WalletData {\n salt: string\n iv: string\n tag: string\n data: string\n}\n\nexport function normalizeWalletPrivateKey(value: string): Hex {\n if (!/^0x[0-9a-fA-F]{64}$/.test(value)) {\n throw new Error('Stored wallet private key is not a valid 0x-prefixed EVM private key')\n }\n return value as Hex\n}\n\nexport function walletAddressFromPrivateKey(privateKey: string): Address {\n return privateKeyToAccount(normalizeWalletPrivateKey(privateKey)).address\n}\n\n/**\n * Encrypts a private key and writes it to ~/.chain-insights/wallet.json.\n * Uses AES-256-GCM with a machine-identity-derived key and a random per-wallet salt.\n * File is written with 0o600 permissions (owner read/write only).\n *\n * @param privateKey - The EVM private key to encrypt (0x-prefixed)\n */\nexport async function encryptKey(privateKey: string): Promise<void> {\n const normalizedPrivateKey = normalizeWalletPrivateKey(privateKey)\n const salt = crypto.randomBytes(16)\n const key = deriveKey(salt)\n const iv = crypto.randomBytes(12)\n const cipher = crypto.createCipheriv('aes-256-gcm', key, iv)\n\n const encrypted = Buffer.concat([cipher.update(normalizedPrivateKey, 'utf8'), cipher.final()])\n\n // getAuthTag() MUST be called after final()\n const tag = cipher.getAuthTag()\n\n const walletData: WalletData = {\n salt: salt.toString('hex'),\n iv: iv.toString('hex'),\n tag: tag.toString('hex'),\n data: encrypted.toString('hex'),\n }\n\n const p = walletPath()\n await mkdir(path.dirname(p), { recursive: true })\n await writeFile(p, JSON.stringify(walletData, null, 2) + '\\n', { mode: 0o600 })\n}\n\nexport interface SetWalletPrivateKeyOptions {\n /** Overwrite an existing wallet. The previous ciphertext is backed up first. */\n force?: boolean\n}\n\n/**\n * Best-effort address of the currently stored wallet, for overwrite messaging.\n * Returns null when the wallet can't be decrypted (e.g. hostname/username\n * changed) — the overwrite is still refused, just without naming the address.\n */\nasync function existingWalletAddress(): Promise<Address | null> {\n try {\n return walletAddressFromPrivateKey(await decryptKey())\n } catch {\n return null\n }\n}\n\n/**\n * Copies the existing wallet.json to a timestamped `.bak-*` sibling before it\n * is overwritten, preserving the 0o600 permission. No-op when absent.\n */\nasync function backupExistingWallet(): Promise<void> {\n const p = walletPath()\n let raw: string\n try {\n raw = await readFile(p, 'utf8')\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') return\n throw err\n }\n const stamp = new Date().toISOString().replace(/[:.]/g, '-')\n await writeFile(`${p}.bak-${stamp}`, raw, { mode: 0o600 })\n}\n\n/**\n * Encrypts and stores a private key, refusing to overwrite an existing wallet\n * unless `force` is set. Importing a new key over a funded wallet discards the\n * only local copy of the old key, so the overwrite is guarded and the previous\n * ciphertext is backed up.\n */\nexport async function setWalletPrivateKey(\n privateKey: string,\n options: SetWalletPrivateKeyOptions = {}\n): Promise<Address> {\n const normalizedPrivateKey = normalizeWalletPrivateKey(privateKey)\n // import, create and `config set walletPrivateKey` all land here: a public\n // key is never stored.\n assertPrivateKeyNotPublic(normalizedPrivateKey)\n const address = walletAddressFromPrivateKey(normalizedPrivateKey)\n\n if (await isWalletConfigured()) {\n if (!options.force) {\n const existing = await existingWalletAddress()\n const which = existing ? ` (${existing})` : ''\n throw new Error(\n `A payment wallet already exists${which}. Importing a new key overwrites it and permanently ` +\n `discards the old key. Re-run \\`cia wallet import <key> --force\\` to replace it; ` +\n `the previous encrypted key is backed up next to wallet.json first.`\n )\n }\n await backupExistingWallet()\n }\n\n await encryptKey(normalizedPrivateKey)\n return address\n}\n\n/**\n * True when the stored wallet's key is public (src/wallet/known-keys.ts),\n * false when it is not, null when no wallet exists or it cannot be read.\n */\nexport async function storedWalletKeyIsPublic(): Promise<boolean | null> {\n if (!(await isWalletConfigured())) return null\n try {\n return isPrivateKeyPublic(normalizeWalletPrivateKey(await decryptKey()))\n } catch {\n return null\n }\n}\n\n/**\n * Refuses unless a wallet exists and its key is public: `--replace` never\n * replaces a private key.\n */\nexport async function assertStoredWalletReplaceable(): Promise<void> {\n const stored = await storedWalletKeyIsPublic()\n if (stored === true) return\n throw new Error(\n stored === null\n ? '`--replace` replaces a wallet whose key is public, and no readable wallet exists. Run `cia wallet create`.'\n : \"`--replace` works only for a wallet whose key is public. This wallet's key is private; keep it, or use `cia wallet import <key> --force`.\"\n )\n}\n\n/**\n * Replaces a wallet whose key is public with `privateKey`. The old file is\n * backed up next to wallet.json first.\n */\nexport async function replacePublicWallet(privateKey: string): Promise<Address> {\n await assertStoredWalletReplaceable()\n return setWalletPrivateKey(privateKey, { force: true })\n}\n\n/**\n * Reads and decrypts the private key from ~/.chain-insights/wallet.json.\n * Throws a human-readable error if wallet is absent or decryption fails.\n *\n * @returns The decrypted EVM private key string\n */\nexport async function decryptKey(): Promise<string> {\n let raw: string\n try {\n raw = await readFile(walletPath(), 'utf8')\n } catch (err: unknown) {\n const nodeErr = err as NodeJS.ErrnoException\n if (nodeErr.code === 'ENOENT') {\n throw new Error(\n 'Wallet not configured. Run `cia wallet create` to generate one, or `cia wallet import <private-key>` to use an existing key. Then run `cia wallet ready`.'\n )\n }\n throw err\n }\n\n try {\n const stored = JSON.parse(raw) as WalletData\n const salt = Buffer.from(stored.salt, 'hex')\n const key = deriveKey(salt)\n const iv = Buffer.from(stored.iv, 'hex')\n const tag = Buffer.from(stored.tag, 'hex')\n const encrypted = Buffer.from(stored.data, 'hex')\n\n const decipher = crypto.createDecipheriv('aes-256-gcm', key, iv)\n // setAuthTag() MUST be called before update()\n decipher.setAuthTag(tag)\n\n const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()])\n\n return decrypted.toString('utf8')\n } catch {\n throw new Error(\n 'Wallet decryption failed. If you changed your hostname or username, re-import it with `cia wallet import <private-key>`.'\n )\n }\n}\n\n/**\n * Returns true if wallet.json exists, false if absent.\n * Does not validate the wallet contents.\n */\nexport async function isWalletConfigured(): Promise<boolean> {\n try {\n await stat(walletPath())\n return true\n } catch (err: unknown) {\n const nodeErr = err as NodeJS.ErrnoException\n if (nodeErr.code === 'ENOENT') return false\n throw err\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AASA,SAAgB,aAAqB;CACnC,OAAO,KAAK,KAAK,GAAG,QAAQ,GAAG,mBAAmB,aAAa;AACjE;AAIA,SAAS,UAAU,MAAsB;CACvC,OAAO,OAAO,WAAW,GAAG,GAAG,SAAS,EAAE,GAAG,GAAG,SAAS,CAAC,CAAC,YAAY,MAAM,EAAE;AACjF;AASA,SAAgB,0BAA0B,OAAoB;CAC5D,IAAI,CAAC,sBAAsB,KAAK,KAAK,GACnC,MAAM,IAAI,MAAM,sEAAsE;CAExF,OAAO;AACT;AAEA,SAAgB,4BAA4B,YAA6B;CACvE,OAAO,oBAAoB,0BAA0B,UAAU,CAAC,CAAC,CAAC;AACpE;;;;;;;;AASA,eAAsB,WAAW,YAAmC;CAClE,MAAM,uBAAuB,0BAA0B,UAAU;CACjE,MAAM,OAAO,OAAO,YAAY,EAAE;CAClC,MAAM,MAAM,UAAU,IAAI;CAC1B,MAAM,KAAK,OAAO,YAAY,EAAE;CAChC,MAAM,SAAS,OAAO,eAAe,eAAe,KAAK,EAAE;CAE3D,MAAM,YAAY,OAAO,OAAO,CAAC,OAAO,OAAO,sBAAsB,MAAM,GAAG,OAAO,MAAM,CAAC,CAAC;CAG7F,MAAM,MAAM,OAAO,WAAW;CAE9B,MAAM,aAAyB;EAC7B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Err"],"sources":["../src/wallet/index.ts"],"sourcesContent":["import crypto from 'node:crypto'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { readFile, writeFile, mkdir, stat } from 'node:fs/promises'\nimport type { Address, Hex } from 'viem'\nimport { privateKeyToAccount } from 'viem/accounts'\nimport { assertPrivateKeyNotPublic, isPrivateKeyPublic } from './known-keys.js'\n\n// Path derived at call time so tests can override HOME.\nexport function walletPath(): string {\n return path.join(os.homedir(), '.chain-insights', 'wallet.json')\n}\n\n// Derive a 32-byte key from the machine identity (hostname + username) and a\n// random per-wallet salt. The salt prevents precomputation attacks across wallets.\nfunction deriveKey(salt: Buffer): Buffer {\n return crypto.scryptSync(`${os.hostname()}:${os.userInfo().username}`, salt, 32)\n}\n\ninterface WalletData {\n salt: string\n iv: string\n tag: string\n data: string\n}\n\nexport function normalizeWalletPrivateKey(value: string): Hex {\n if (!/^0x[0-9a-fA-F]{64}$/.test(value)) {\n throw new Error('Stored wallet private key is not a valid 0x-prefixed EVM private key')\n }\n return value as Hex\n}\n\nexport function walletAddressFromPrivateKey(privateKey: string): Address {\n return privateKeyToAccount(normalizeWalletPrivateKey(privateKey)).address\n}\n\n/**\n * Encrypts a private key and writes it to ~/.chain-insights/wallet.json.\n * Uses AES-256-GCM with a machine-identity-derived key and a random per-wallet salt.\n * File is written with 0o600 permissions (owner read/write only).\n *\n * @param privateKey - The EVM private key to encrypt (0x-prefixed)\n */\nexport async function encryptKey(privateKey: string): Promise<void> {\n const normalizedPrivateKey = normalizeWalletPrivateKey(privateKey)\n const salt = crypto.randomBytes(16)\n const key = deriveKey(salt)\n const iv = crypto.randomBytes(12)\n const cipher = crypto.createCipheriv('aes-256-gcm', key, iv)\n\n const encrypted = Buffer.concat([cipher.update(normalizedPrivateKey, 'utf8'), cipher.final()])\n\n // getAuthTag() MUST be called after final()\n const tag = cipher.getAuthTag()\n\n const walletData: WalletData = {\n salt: salt.toString('hex'),\n iv: iv.toString('hex'),\n tag: tag.toString('hex'),\n data: encrypted.toString('hex'),\n }\n\n const p = walletPath()\n await mkdir(path.dirname(p), { recursive: true })\n await writeFile(p, JSON.stringify(walletData, null, 2) + '\\n', { mode: 0o600 })\n}\n\nexport interface SetWalletPrivateKeyOptions {\n /** Overwrite an existing wallet. The previous ciphertext is backed up first. */\n force?: boolean\n}\n\n/**\n * Best-effort address of the currently stored wallet, for overwrite messaging.\n * Returns null when the wallet can't be decrypted (e.g. hostname/username\n * changed) — the overwrite is still refused, just without naming the address.\n */\nasync function existingWalletAddress(): Promise<Address | null> {\n try {\n return walletAddressFromPrivateKey(await decryptKey())\n } catch {\n return null\n }\n}\n\n/**\n * Copies the existing wallet.json to a timestamped `.bak-*` sibling before it\n * is overwritten, preserving the 0o600 permission. No-op when absent.\n */\nasync function backupExistingWallet(): Promise<void> {\n const p = walletPath()\n let raw: string\n try {\n raw = await readFile(p, 'utf8')\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') return\n throw err\n }\n const stamp = new Date().toISOString().replace(/[:.]/g, '-')\n await writeFile(`${p}.bak-${stamp}`, raw, { mode: 0o600 })\n}\n\n/**\n * Encrypts and stores a private key, refusing to overwrite an existing wallet\n * unless `force` is set. Importing a new key over a funded wallet discards the\n * only local copy of the old key, so the overwrite is guarded and the previous\n * ciphertext is backed up.\n */\nexport async function setWalletPrivateKey(\n privateKey: string,\n options: SetWalletPrivateKeyOptions = {}\n): Promise<Address> {\n const normalizedPrivateKey = normalizeWalletPrivateKey(privateKey)\n // import, create and `config set walletPrivateKey` all land here: a public\n // key is never stored.\n assertPrivateKeyNotPublic(normalizedPrivateKey)\n const address = walletAddressFromPrivateKey(normalizedPrivateKey)\n\n if (await isWalletConfigured()) {\n if (!options.force) {\n const existing = await existingWalletAddress()\n const which = existing ? ` (${existing})` : ''\n throw new Error(\n `A payment wallet already exists${which}. Importing a new key overwrites it and permanently ` +\n `discards the old key. Re-run \\`cia wallet import <key> --force\\` to replace it; ` +\n `the previous encrypted key is backed up next to wallet.json first.`\n )\n }\n await backupExistingWallet()\n }\n\n await encryptKey(normalizedPrivateKey)\n return address\n}\n\n/**\n * True when the stored wallet's key is public (src/wallet/known-keys.ts),\n * false when it is not, null when no wallet exists or it cannot be read.\n */\nexport async function storedWalletKeyIsPublic(): Promise<boolean | null> {\n if (!(await isWalletConfigured())) return null\n try {\n return isPrivateKeyPublic(normalizeWalletPrivateKey(await decryptKey()))\n } catch {\n return null\n }\n}\n\n/**\n * Refuses unless a wallet exists and its key is public: `--replace` never\n * replaces a private key.\n */\nexport async function assertStoredWalletReplaceable(): Promise<void> {\n const stored = await storedWalletKeyIsPublic()\n if (stored === true) return\n throw new Error(\n stored === null\n ? '`--replace` replaces a wallet whose key is public, and no readable wallet exists. Run `cia wallet create`.'\n : \"`--replace` works only for a wallet whose key is public. This wallet's key is private; keep it, or use `cia wallet import <key> --force`.\"\n )\n}\n\n/**\n * Replaces a wallet whose key is public with `privateKey`. The old file is\n * backed up next to wallet.json first.\n */\nexport async function replacePublicWallet(privateKey: string): Promise<Address> {\n await assertStoredWalletReplaceable()\n return setWalletPrivateKey(privateKey, { force: true })\n}\n\n/**\n * Reads and decrypts the private key from ~/.chain-insights/wallet.json.\n * Throws a human-readable error if wallet is absent or decryption fails.\n *\n * @returns The decrypted EVM private key string\n */\nexport async function decryptKey(): Promise<string> {\n let raw: string\n try {\n raw = await readFile(walletPath(), 'utf8')\n } catch (err: unknown) {\n const nodeErr = err as NodeJS.ErrnoException\n if (nodeErr.code === 'ENOENT') {\n throw new Error(\n 'Wallet not configured. Run `cia wallet create` to generate one, or `cia wallet import <private-key>` to use an existing key. Then run `cia wallet ready`.'\n )\n }\n throw err\n }\n\n try {\n const stored = JSON.parse(raw) as WalletData\n const salt = Buffer.from(stored.salt, 'hex')\n const key = deriveKey(salt)\n const iv = Buffer.from(stored.iv, 'hex')\n const tag = Buffer.from(stored.tag, 'hex')\n const encrypted = Buffer.from(stored.data, 'hex')\n\n const decipher = crypto.createDecipheriv('aes-256-gcm', key, iv)\n // setAuthTag() MUST be called before update()\n decipher.setAuthTag(tag)\n\n const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()])\n\n return decrypted.toString('utf8')\n } catch {\n throw new Error(\n 'Wallet decryption failed. If you changed your hostname or username, re-import it with `cia wallet import <private-key>`.'\n )\n }\n}\n\n/**\n * Returns true if wallet.json exists, false if absent.\n * Does not validate the wallet contents.\n */\nexport async function isWalletConfigured(): Promise<boolean> {\n try {\n await stat(walletPath())\n return true\n } catch (err: unknown) {\n const nodeErr = err as NodeJS.ErrnoException\n if (nodeErr.code === 'ENOENT') return false\n throw err\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AASA,SAAgB,aAAqB;CACnC,OAAO,KAAK,KAAK,GAAG,QAAQ,GAAG,mBAAmB,aAAa;AACjE;AAIA,SAAS,UAAU,MAAsB;CACvC,OAAO,OAAO,WAAW,GAAG,GAAG,SAAS,EAAE,GAAG,GAAG,SAAS,CAAC,CAAC,YAAY,MAAM,EAAE;AACjF;AASA,SAAgB,0BAA0B,OAAoB;CAC5D,IAAI,CAAC,sBAAsB,KAAK,KAAK,GACnC,MAAM,IAAI,MAAM,sEAAsE;CAExF,OAAO;AACT;AAEA,SAAgB,4BAA4B,YAA6B;CACvE,OAAO,oBAAoB,0BAA0B,UAAU,CAAC,CAAC,CAAC;AACpE;;;;;;;;AASA,eAAsB,WAAW,YAAmC;CAClE,MAAM,uBAAuB,0BAA0B,UAAU;CACjE,MAAM,OAAO,OAAO,YAAY,EAAE;CAClC,MAAM,MAAM,UAAU,IAAI;CAC1B,MAAM,KAAK,OAAO,YAAY,EAAE;CAChC,MAAM,SAAS,OAAO,eAAe,eAAe,KAAK,EAAE;CAE3D,MAAM,YAAY,OAAO,OAAO,CAAC,OAAO,OAAO,sBAAsB,MAAM,GAAG,OAAO,MAAM,CAAC,CAAC;CAG7F,MAAM,MAAM,OAAO,WAAW;CAE9B,MAAM,aAAyB;EAC7B,MAAM,KAAK,SAAS,KAAK;EACzB,IA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_keys = require("./known-keys-
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-BW-eSwOZ.cjs");
|
|
2
|
+
const require_known_keys = require("./known-keys-Cy8lKDOA.cjs");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
5
5
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -8,17 +8,14 @@ node_os = require_rolldown_runtime.__toESM(node_os, 1);
|
|
|
8
8
|
let node_crypto = require("node:crypto");
|
|
9
9
|
node_crypto = require_rolldown_runtime.__toESM(node_crypto, 1);
|
|
10
10
|
let viem_accounts = require("viem/accounts");
|
|
11
|
-
|
|
11
|
+
// src/wallet/index.ts
|
|
12
12
|
var wallet_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
13
13
|
assertStoredWalletReplaceable: () => assertStoredWalletReplaceable,
|
|
14
14
|
decryptKey: () => decryptKey,
|
|
15
|
-
encryptKey: () => encryptKey,
|
|
16
15
|
isWalletConfigured: () => isWalletConfigured,
|
|
17
|
-
normalizeWalletPrivateKey: () => normalizeWalletPrivateKey,
|
|
18
16
|
replacePublicWallet: () => replacePublicWallet,
|
|
19
17
|
setWalletPrivateKey: () => setWalletPrivateKey,
|
|
20
18
|
storedWalletKeyIsPublic: () => storedWalletKeyIsPublic,
|
|
21
|
-
walletAddressFromPrivateKey: () => walletAddressFromPrivateKey,
|
|
22
19
|
walletPath: () => walletPath
|
|
23
20
|
});
|
|
24
21
|
function walletPath() {
|
|
@@ -177,7 +174,6 @@ async function isWalletConfigured() {
|
|
|
177
174
|
throw err;
|
|
178
175
|
}
|
|
179
176
|
}
|
|
180
|
-
//#endregion
|
|
181
177
|
Object.defineProperty(exports, "decryptKey", {
|
|
182
178
|
enumerable: true,
|
|
183
179
|
get: function() {
|
|
@@ -57,7 +57,7 @@ read as it is.
|
|
|
57
57
|
USE topology MATCH (a:Address) RETURN a.address AS address, a.network AS network LIMIT 20
|
|
58
58
|
|
|
59
59
|
-- Anchored: an address in the pattern
|
|
60
|
-
USE topology MATCH (a:Address {address: "0x…"})-[f:
|
|
60
|
+
USE topology MATCH (a:Address {address: "0x…"})-[f:FLOWED_TO]->(b:Address)
|
|
61
61
|
WHERE NOT a:Pool
|
|
62
62
|
RETURN b.address AS address LIMIT 100
|
|
63
63
|
```
|
|
@@ -88,7 +88,7 @@ admission + bounds gate below. This includes clause- and pattern-level `WHERE`,
|
|
|
88
88
|
`WITH` pipelines, `CASE`, `collect()`, temporal functions, `UNWIND`, map
|
|
89
89
|
projections, `UNION`, and the full traversal surface. The topology graph serves
|
|
90
90
|
`Address` nodes (with the role labels and flags),
|
|
91
|
-
`
|
|
91
|
+
`FLOWED_TO` lifetime money-flow edges, `OPERATED_BY` operator-mediated topology
|
|
92
92
|
edges (the next section), the `LINKED` ownership overlay, the links from
|
|
93
93
|
approvals, contract creations and smart accounts (`APPROVED`,
|
|
94
94
|
`DEPLOYED_CONTRACT`, `SPONSORED`, `BUNDLED`, `SIGNED_FOR` and
|
|
@@ -250,7 +250,7 @@ newer run replaces them. None is money flow.
|
|
|
250
250
|
### Swap attribution
|
|
251
251
|
|
|
252
252
|
Swap attribution is read from `SWAPPED`, the aggregate (`strength`, pools,
|
|
253
|
-
families), or from the facts `SWAP` row, one route. `
|
|
253
|
+
families), or from the facts `SWAP` row, one route. `FLOWED_TO` carries value
|
|
254
254
|
only.
|
|
255
255
|
|
|
256
256
|
### `LINKED` and `BRIDGED` properties
|
|
@@ -268,13 +268,13 @@ asset, with `asset` and `amount_raw_sum` (and `fees_raw_sum` on a removal).
|
|
|
268
268
|
|
|
269
269
|
| Form | Syntax | Supported |
|
|
270
270
|
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
|
|
271
|
-
| Quantified path | `MATCH p = (a:Address WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:
|
|
272
|
-
| One shortest path | `MATCH p = SHORTEST 1 (a:Address {address: $from} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:
|
|
273
|
-
| Any shortest path | `MATCH p = ANY SHORTEST (a:Address {address: $from} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:
|
|
274
|
-
| Open target | `MATCH SHORTEST 1 (a:Address {address: $addr} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:
|
|
271
|
+
| Quantified path | `MATCH p = (a:Address WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:FLOWED_TO\|SWAPPED]-(via:Address) WHERE NOT via:Pool AND NOT via:Protocol AND NOT via:System AND NOT via.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]){0,4} ()-[:FLOWED_TO\|SWAPPED]-(b:Address)` | ✅ upper bound ≤ 5 |
|
|
272
|
+
| One shortest path | `MATCH p = SHORTEST 1 (a:Address {address: $from} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:FLOWED_TO\|SWAPPED]-(via:Address) WHERE NOT via:Pool AND NOT via:Protocol AND NOT via:System AND NOT via.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]){0,4} ()-[:FLOWED_TO\|SWAPPED]-(b:Address {address: $to})` | ✅ upper bound ≤ 5 |
|
|
273
|
+
| Any shortest path | `MATCH p = ANY SHORTEST (a:Address {address: $from} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:FLOWED_TO\|SWAPPED]-(via:Address) WHERE NOT via:Pool AND NOT via:Protocol AND NOT via:System AND NOT via.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]){0,4} ()-[:FLOWED_TO\|SWAPPED]-(b:Address {address: $to})` | ✅ upper bound ≤ 5 |
|
|
274
|
+
| Open target | `MATCH SHORTEST 1 (a:Address {address: $addr} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:FLOWED_TO\|SWAPPED]-(via:Address) WHERE NOT via:Pool AND NOT via:Protocol AND NOT via:System AND NOT via.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]){0,4} ()-[:FLOWED_TO\|SWAPPED]-(b:Address)` | ✅ upper bound ≤ 5 |
|
|
275
275
|
|
|
276
276
|
Every form above carries the pool guard and walks `SWAPPED` beside
|
|
277
|
-
`
|
|
277
|
+
`FLOWED_TO`. `WHERE NOT a:Pool` keeps the walk from starting at a `:Pool`, the
|
|
278
278
|
inner `WHERE NOT via:Pool` keeps each address in the middle of the walk off
|
|
279
279
|
one, and `SWAPPED` crosses a swap from payer to recipient, per the
|
|
280
280
|
[pool trace rule](../skills/chain-insights-cypher/SKILL.md#pool-trace-rule).
|
|
@@ -297,8 +297,8 @@ bounded so an admitted query cannot become an unbounded graph walk:
|
|
|
297
297
|
|
|
298
298
|
| Bound | Limit | Rejected example |
|
|
299
299
|
| --------------------------------- | --------- | ---------------------------------------------------------------------------------------- |
|
|
300
|
-
| Traversal depth (upper hop bound) | ≤ 5 | `-[:
|
|
301
|
-
| Unbounded traversal | forbidden | `(a)-[:
|
|
300
|
+
| Traversal depth (upper hop bound) | ≤ 5 | `-[:FLOWED_TO]-{1,9}(b)` → _traversal depth 9 exceeds the maximum of 5_ |
|
|
301
|
+
| Unbounded traversal | forbidden | `(a)-[:FLOWED_TO]-(b)` with no quantifier bound → fail closed |
|
|
302
302
|
| Non-GQL path operators/functions | forbidden | Legacy path functions and starred path algorithms return a dialect error |
|
|
303
303
|
| `UNWIND` literal list length | ≤ 1000 | `UNWIND [ …1001 items… ] AS x` → _UNWIND list of 1001 items exceeds the maximum of 1000_ |
|
|
304
304
|
|
|
@@ -322,7 +322,7 @@ and the server admits exactly that shape:
|
|
|
322
322
|
|
|
323
323
|
| Construct | Notes |
|
|
324
324
|
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
325
|
-
| `MATCH` on a mapped node / single relationship | `(from:Address {address:"…"})-[t:TRANSFER]->(to:Address {address:"…"})`. `SWAP`, `LIQUIDITY_ADD`, `LIQUIDITY_REMOVE` and `BRIDGE_CROSSING` are single-event rows on the same pattern. Never serves `
|
|
325
|
+
| `MATCH` on a mapped node / single relationship | `(from:Address {address:"…"})-[t:TRANSFER]->(to:Address {address:"…"})`. `SWAP`, `LIQUIDITY_ADD`, `LIQUIDITY_REMOVE` and `BRIDGE_CROSSING` are single-event rows on the same pattern. Never serves `FLOWED_TO`, `OPERATED_BY`, `LINKED`, `SWAPPED`, `ADDED_LIQUIDITY`, `REMOVED_LIQUIDITY` or `BRIDGED`. |
|
|
326
326
|
| The pair | Both addresses, from then to, each as `{address: "…"}`. One address alone is refused (`facts_no_anchor`). `IN` is refused: one read per pair, several in one `graph_query_batch`. |
|
|
327
327
|
| The day | `t.block_date = "YYYY-MM-DD"`. A day alone, a window of days, a block range and a bare `LIMIT` are not enough. For more days, send one read per day. |
|
|
328
328
|
| A time window inside the day | `t.block_timestamp >= 1783738500000 AND t.block_timestamp < 1783738560000` beside the day equality narrows the day to a window. `block_timestamp` is epoch milliseconds. On its own it bounds nothing. |
|
|
@@ -339,7 +339,7 @@ its `example` once.
|
|
|
339
339
|
|
|
340
340
|
Every `TRANSFER` row has a `kind`: `token`, `native` or `internal`. An `internal`
|
|
341
341
|
row is ETH a contract sends while it runs a call, such as the ETH leg of a wrap.
|
|
342
|
-
The `
|
|
342
|
+
The `FLOWED_TO` link counts all three, so the rows of a pair are the transfers its
|
|
343
343
|
link counts, up to the height the link was built to. `kind` is a column and a
|
|
344
344
|
filter. Add `t.kind = "internal"` to the pair and the day to read only the
|
|
345
345
|
internal rows. A `kind` filter narrows the read of a pair and one day. It never
|
|
@@ -366,7 +366,7 @@ StarRocks. Use the topology graph, or restructure:
|
|
|
366
366
|
|
|
367
367
|
| Construct | Instead |
|
|
368
368
|
| ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
369
|
-
| `
|
|
369
|
+
| `FLOWED_TO` / `OPERATED_BY` topology edges | The topology graph — facts never serves either |
|
|
370
370
|
| A hop: two relationships in one pattern | The topology graph — a facts read has one relationship |
|
|
371
371
|
| `ORDER BY` | Sort the page yourself |
|
|
372
372
|
| One address with no counterparty, a day range, a block range, a bare `LIMIT` | Name the pair and one day; pick the pairs on the topology graph first |
|
package/docs/graph-tools.md
CHANGED
|
@@ -53,10 +53,10 @@ A transaction is a chain question: read it on `USE chain` by its `tx_id`. Chain
|
|
|
53
53
|
|
|
54
54
|
The layers hand each other keys, and each key keeps its name. Topology gives the pair and the first and last seen time. Facts gives the `tx_id` and the `block_height`. Chain takes an `address`, a `tx_id`, a `block_height` or a `block_hash`, and gives the `block_date` of a transaction or a block.
|
|
55
55
|
|
|
56
|
-
A question about the whole chain (recent activity, the biggest senders, a top list) is a `USE topology` search: bound it by time with `f.last_seen_timestamp >= <epoch ms>` on the `
|
|
56
|
+
A question about the whole chain (recent activity, the biggest senders, a top list) is a `USE topology` search: bound it by time with `f.last_seen_timestamp >= <epoch ms>` on the `FLOWED_TO` link, then sort and `LIMIT`. A search has 10 s. Read `Head` first (`USE chain MATCH (h:Head) RETURN h.behind_money, h.behind_dex, h.behind_transfers`, under a second): a `FLOWED_TO` search is sent when `behind_money` is at most 100000; a `SWAPPED`, `ADDED_LIQUIDITY` or `REMOVED_LIQUIDITY` search when `behind_dex` is at most 100000; a `TRANSFERRED` search when `behind_transfers` is at most 100000 (100000 blocks is a few hours: a robinhood block is about a tenth of a second apart from the next). When the family is further behind, the search cannot finish, so do not send it: say which family, how many blocks, and ask for an address. On a server whose Head has no `behind_money`, read `h.graph_blocks_behind` and hold it to the same limit. On a server whose Head has no `behind_transfers`, it serves no `TRANSFERRED` link: send no `TRANSFERRED` search. Never turn the block count into days or hours by head. To say how fresh the data is, give the newest `_utc` time you read on the layer you used: a family's lag counts its slowest layer, and the links of an address and the facts rows are often newer than it. If the server refuses the search with `anchor_missing` or `family_behind`, or stops it with `query_timeout`, it cannot search the whole chain now: say so in one line, name the family the refusal names, and ask for an address or drop the link type that is behind. A narrower window times out the same way, so do not send it again.
|
|
57
57
|
|
|
58
58
|
The graph layers are grouped into six families, and each family is as fresh
|
|
59
|
-
as its slowest layer: `money` (`
|
|
59
|
+
as its slowest layer: `money` (`FLOWED_TO`, `OPERATED_BY`), `dex` (`SWAPPED`,
|
|
60
60
|
`ADDED_LIQUIDITY`, `REMOVED_LIQUIDITY`), `interactions` (`APPROVED`,
|
|
61
61
|
`BRIDGED`, `DEPLOYED_CONTRACT`, `SIGNED_AUTHORIZATION`), `smart_accounts`
|
|
62
62
|
(`SPONSORED`, `BUNDLED`, `SIGNED_FOR`, `LINKED`), `annotations` (labels
|
|
@@ -74,8 +74,8 @@ too far behind the head: the refusal names the family and its lag, and its
|
|
|
74
74
|
|
|
75
75
|
| The question | Layer | First query |
|
|
76
76
|
| ---------------------------------------------------------- | ---------- | --------------------------------------------------------------------------- |
|
|
77
|
-
| Recent activity or newest links of one address? | `topology` | `
|
|
78
|
-
| Who sent money to an address? Who received from it? | `topology` | `
|
|
77
|
+
| Recent activity or newest links of one address? | `topology` | `FLOWED_TO` out of the address, `ORDER BY last_seen_timestamp`. |
|
|
78
|
+
| Who sent money to an address? Who received from it? | `topology` | `FLOWED_TO` into or out of the address, with a `LIMIT`. |
|
|
79
79
|
| Where did the money go, or come from, in N hops? | `topology` | A guarded quantified walk, at most 4 hops, with a `LIMIT`. |
|
|
80
80
|
| Is there a route between A and B? | `topology` | `SHORTEST 1` with both addresses. |
|
|
81
81
|
| How many, how much, first or last active, for one address? | `topology` | The address node: `degree_in`, `tx_total_count`, `last_activity_timestamp`. |
|
|
@@ -262,11 +262,11 @@ of truth.
|
|
|
262
262
|
nothing. The facts `SWAP` row says which side had no price:
|
|
263
263
|
`sold_price_missing` and `bought_price_missing`.
|
|
264
264
|
- Swap attribution is read from `SWAPPED`, the aggregate (`strength`, pools,
|
|
265
|
-
families), or from the facts `SWAP` row, one route. `
|
|
265
|
+
families), or from the facts `SWAP` row, one route. `FLOWED_TO` carries value
|
|
266
266
|
only.
|
|
267
267
|
- A missing `SWAPPED` edge or `SWAP` row is not proof that no swap happened.
|
|
268
268
|
|
|
269
|
-
`
|
|
269
|
+
`FLOWED_TO` into and out of pools stays as it is. A trace that reaches a
|
|
270
270
|
`:Pool` follows the pool trace rule:
|
|
271
271
|
|
|
272
272
|
- The rule is stated once, in the
|
|
@@ -275,13 +275,13 @@ of truth.
|
|
|
275
275
|
because an MCP client loads no skill. A test keeps the two equal.
|
|
276
276
|
- It stops a trace from fanning out to every trader who used the pool, and
|
|
277
277
|
it still reaches the address that took the liquidity out.
|
|
278
|
-
- Every documented `
|
|
278
|
+
- Every documented `FLOWED_TO` walk carries the pool guard on its start and
|
|
279
279
|
on every address in its middle: a walk may end at a `:Pool`, but never
|
|
280
280
|
starts at one or passes through one.
|
|
281
|
-
- Every documented trace walks `SWAPPED` beside `
|
|
281
|
+
- Every documented trace walks `SWAPPED` beside `FLOWED_TO`, so it crosses a
|
|
282
282
|
swap from payer to recipient without passing through the pool.
|
|
283
283
|
|
|
284
|
-
Route between two addresses under the rule. It walks `
|
|
284
|
+
Route between two addresses under the rule. It walks `FLOWED_TO` and
|
|
285
285
|
`SWAPPED`. The guards sit inside the path pattern, on the start and on every
|
|
286
286
|
address in the middle, so the search finds the shortest route that avoids
|
|
287
287
|
pools. `ANY SHORTEST` takes the same pattern in place of `SHORTEST 1`. Ask for
|
|
@@ -290,7 +290,7 @@ one path only:
|
|
|
290
290
|
```bash
|
|
291
291
|
cia mcp call graph_query \
|
|
292
292
|
network=robinhood \
|
|
293
|
-
'query=USE topology MATCH p = SHORTEST 1 (a:Address {address: "0x..."} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:
|
|
293
|
+
'query=USE topology MATCH p = SHORTEST 1 (a:Address {address: "0x..."} WHERE NOT a:Pool AND NOT a:Protocol AND NOT a:System AND NOT a.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]) (()-[:FLOWED_TO|SWAPPED]-(via:Address) WHERE NOT via:Pool AND NOT via:Protocol AND NOT via:System AND NOT via.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"]){0,4} ()-[:FLOWED_TO|SWAPPED]-(b:Address {address: "0x..."}) RETURN [n IN nodes(p) | n.address] AS route LIMIT 5'
|
|
294
294
|
```
|
|
295
295
|
|
|
296
296
|
The `chain-insights-cypher` skill shows how to read the properties of a link
|
|
@@ -301,7 +301,7 @@ Rug-pull check from a victim, under the rule:
|
|
|
301
301
|
```bash
|
|
302
302
|
cia mcp call graph_query \
|
|
303
303
|
network=robinhood \
|
|
304
|
-
'query=USE topology MATCH (victim:Address {address: "0x..."})-[paid:
|
|
304
|
+
'query=USE topology MATCH (victim:Address {address: "0x..."})-[paid:FLOWED_TO]->(pool:Pool)-[removal:REMOVED_LIQUIDITY]->(receiver:Address) WHERE NOT victim:Pool AND NOT victim:Protocol AND NOT victim:System AND NOT victim.address IN ["0x0000000000000000000000000000000000000000", "0x000000000000000000000000000000000000dead"] AND receiver.address <> victim.address RETURN pool.address AS pool_address, receiver.address AS receiver_address, max(paid.amount_usd_sum) AS paid_in_usd, sum(removal.usd) AS removed_usd, max(removal.receiver_added_usd) AS receiver_added_usd, sum(removal.usd) - max(removal.receiver_added_usd) AS receiver_profit_usd, max(removal.receiver_provided) AS receiver_provided ORDER BY removed_usd DESC LIMIT 25'
|
|
305
305
|
```
|
|
306
306
|
|
|
307
307
|
One transaction's swap routes, with their strength and the two sides:
|
|
@@ -326,9 +326,9 @@ A relationship is served only where its data exists. Check
|
|
|
326
326
|
|
|
327
327
|
## Tokens: one link per sender, receiver and token
|
|
328
328
|
|
|
329
|
-
`
|
|
329
|
+
`FLOWED_TO` is the total of a pair over every token. `TRANSFERRED` splits that
|
|
330
330
|
total by token: one link for each sender, receiver and token, in the
|
|
331
|
-
`transfers` family. `
|
|
331
|
+
`transfers` family. `FLOWED_TO` stays the pair total, and the `TRANSFERRED`
|
|
332
332
|
links of a pair add up to it.
|
|
333
333
|
|
|
334
334
|
| Property | Meaning |
|
|
@@ -414,7 +414,7 @@ flag on the node.
|
|
|
414
414
|
|
|
415
415
|
- `network` is required. Do not guess it in agent workflows.
|
|
416
416
|
- GQL/Cypher must be read-only.
|
|
417
|
-
- Use `USE topology` for topology (the address /
|
|
417
|
+
- Use `USE topology` for topology (the address / FLOWED_TO / OPERATED_BY / LINKED graph,
|
|
418
418
|
covering unified recent and full historical activity in one graph, plus the
|
|
419
419
|
the `SWAPPED`,
|
|
420
420
|
`ADDED_LIQUIDITY`, `REMOVED_LIQUIDITY` and `BRIDGED` totals, and the
|
|
@@ -422,7 +422,7 @@ flag on the node.
|
|
|
422
422
|
- Use `USE facts` for bounded individual `TRANSFER` rows and their amount,
|
|
423
423
|
`amount_usd`, asset, transaction, and block facts, and for single `SWAP`,
|
|
424
424
|
`LIQUIDITY_ADD`, `LIQUIDITY_REMOVE` and `BRIDGE_CROSSING` rows. Address
|
|
425
|
-
labels, risk, lifetime metrics, and `
|
|
425
|
+
labels, risk, lifetime metrics, and `FLOWED_TO`/`LINKED` relationships
|
|
426
426
|
belong to `USE topology`.
|
|
427
427
|
- Use `USE chain` for the chain node's own record of one known transaction,
|
|
428
428
|
block, address or the head. It looks up one key and never searches.
|
|
@@ -437,7 +437,7 @@ flag on the node.
|
|
|
437
437
|
of a pair one day at a time.
|
|
438
438
|
- Every `TRANSFER` row has a `kind`: `token`, `native` or `internal`. An
|
|
439
439
|
`internal` row is ETH a contract sends while it runs a call, such as the ETH
|
|
440
|
-
leg of a wrap. `
|
|
440
|
+
leg of a wrap. `FLOWED_TO` `tx_count` counts all three, so the rows of a pair
|
|
441
441
|
are the transfers its link counts, up to the height the link was built to.
|
|
442
442
|
`kind` is a column and a filter. Add `t.kind = "internal"` to the pair and the
|
|
443
443
|
day to read only the internal rows.
|
|
@@ -510,7 +510,7 @@ Example batch query:
|
|
|
510
510
|
```bash
|
|
511
511
|
cia mcp call graph_query_batch \
|
|
512
512
|
network=robinhood \
|
|
513
|
-
'queries=[{"id":"count","query":"USE topology MATCH (a:Address) RETURN count(a) AS count LIMIT 1"},{"id":"flows","query":"USE topology MATCH (src:Address)-[f:
|
|
513
|
+
'queries=[{"id":"count","query":"USE topology MATCH (a:Address) RETURN count(a) AS count LIMIT 1"},{"id":"flows","query":"USE topology MATCH (src:Address)-[f:FLOWED_TO]->(dst:Address) RETURN src.address AS source, dst.address AS target, f.amount_usd_sum AS amount_usd_sum, f.tx_count AS tx_count LIMIT 3"},{"id":"linked","query":"USE topology MATCH (a:Address)-[l:LINKED]-(b:Address) RETURN a.address AS address, b.address AS linked_address, l.basis AS basis, l.confidence AS confidence LIMIT 3"}]'
|
|
514
514
|
```
|
|
515
515
|
|
|
516
516
|
A batch is one call and counts the units of all its returned rows. The free
|
|
@@ -577,7 +577,7 @@ on `SWAPPED` checks every `SWAPPED` link. `LIMIT` stops the read only after it
|
|
|
577
577
|
has found enough rows, so a filter that matches few or none can run to the
|
|
578
578
|
60-second limit and fail with `query_timeout`. A discovery probe with no
|
|
579
579
|
filter, such as
|
|
580
|
-
`MATCH (:Address)-[r:
|
|
580
|
+
`MATCH (:Address)-[r:FLOWED_TO]->(:Address) RETURN r.tx_count LIMIT 20`, finds
|
|
581
581
|
its rows at once and stays valid.
|
|
582
582
|
|
|
583
583
|
Put an address in the pattern, and pick one with few links. Read `degree_out`
|
|
@@ -625,7 +625,7 @@ Notes:
|
|
|
625
625
|
are valid but heavy; at millions of edges they can exceed the 60-second
|
|
626
626
|
per-query limit. See `docs/graph-query-compatibility.md` for the
|
|
627
627
|
time-bounded sweep shape.
|
|
628
|
-
- Confirm any lead with `
|
|
628
|
+
- Confirm any lead with `FLOWED_TO` money-flow context and address labels
|
|
629
629
|
before drawing conclusions.
|
|
630
630
|
|
|
631
631
|
## Full addresses and units
|
|
@@ -658,9 +658,9 @@ Liquidity pools are the other trace boundary. At a `:Pool`, manual traversal
|
|
|
658
658
|
follows the
|
|
659
659
|
[pool trace rule](../skills/chain-insights-cypher/SKILL.md#pool-trace-rule),
|
|
660
660
|
so a trace does not fan out to every trader who used the pool. The start and
|
|
661
|
-
every address in the middle of a manual `
|
|
661
|
+
every address in the middle of a manual `FLOWED_TO` walk must satisfy
|
|
662
662
|
`NOT src:Pool` and `NOT mid:Pool`, and the walk follows `SWAPPED` beside
|
|
663
|
-
`
|
|
663
|
+
`FLOWED_TO` to cross a swap. On a walk of two or more hops the same addresses
|
|
664
664
|
also satisfy the system guard of the skill: `NOT x:Protocol`,
|
|
665
665
|
`NOT x:System`, and `NOT x.address IN [...]` with the zero and the dead
|
|
666
666
|
address until the graph writes the `System` kind. Shared infrastructure such
|
|
@@ -692,7 +692,7 @@ Useful schema probes:
|
|
|
692
692
|
cia mcp call graph_query_batch \
|
|
693
693
|
network=robinhood \
|
|
694
694
|
per_query_timeout_seconds=5 \
|
|
695
|
-
'queries=[{"id":"address_sample","query":"USE topology MATCH (a:Address) RETURN a.address AS address, a.network AS network, a.labels AS labels, a.is_exchange AS is_exchange LIMIT 10"},{"id":"flow_sample","query":"USE topology MATCH (src:Address)-[flow:
|
|
695
|
+
'queries=[{"id":"address_sample","query":"USE topology MATCH (a:Address) RETURN a.address AS address, a.network AS network, a.labels AS labels, a.is_exchange AS is_exchange LIMIT 10"},{"id":"flow_sample","query":"USE topology MATCH (src:Address)-[flow:FLOWED_TO]->(dst:Address) RETURN src.address AS from_address, dst.address AS to_address, flow.amount_usd_sum AS amount_usd_sum, flow.tx_count AS tx_count LIMIT 10"},{"id":"linked_sample","query":"USE topology MATCH (a:Address)-[l:LINKED]-(b:Address) RETURN a.address AS address, b.address AS linked_address, b.network AS linked_network, l.basis AS basis, l.confidence AS confidence LIMIT 10"},{"id":"operated_by_sample","query":"USE topology MATCH (owner:Address)-[operation:OPERATED_BY]->(operator:Address {address: \"0x...\"}) RETURN owner.address AS owner_address, operation.tx_count AS tx_count, operation.amount_usd_sum AS amount_usd_sum LIMIT 10"},{"id":"node_metric_sample","query":"USE topology MATCH (a:Address) RETURN a.address AS address, a.tx_out_count AS tx_out_count LIMIT 10"}]'
|
|
696
696
|
```
|
|
697
697
|
|
|
698
698
|
Use endpoint-safe property projections like `a.address` and `flow.tx_count`
|
package/docs/mcp-proxy.md
CHANGED
|
@@ -82,6 +82,7 @@ The proxy:
|
|
|
82
82
|
| `meta_network_capabilities` | Show the current Chain Insights network/tool support matrix |
|
|
83
83
|
| `meta_schema` | Show the live graph schema of a network: labels, link types, fields, indexes |
|
|
84
84
|
| `meta_dex_lookup` | Turn an exchange name into its factories, routers or manager, pools and first reads |
|
|
85
|
+
| `meta_token_lookup` | Turn a ticker or a token name into every contract that carries it, with its creator |
|
|
85
86
|
| `meta_rules` | Read the answer rules when the `chain-insights-cypher` skill is not loaded |
|
|
86
87
|
| `meta_help` | Show Chain Insights tool and workflow guidance |
|
|
87
88
|
| `meta_usage_status` | Check the caller's daily free-tier graph query allowance |
|
|
@@ -132,6 +133,32 @@ cache. `registry_source` in the answer says which copy answered: `fetched`,
|
|
|
132
133
|
`cached` or `packaged`. `CHAIN_INSIGHTS_DEX_REGISTRY_URL` points the fetch
|
|
133
134
|
somewhere else, for tests and the lab; `{network}` in it is filled in.
|
|
134
135
|
|
|
136
|
+
`meta_token_lookup` turns a ticker or a token name into the contracts that
|
|
137
|
+
carry it. It takes `network` and `symbol` (both required, `symbol` 1 to 64
|
|
138
|
+
characters). Tickers collide: a clone reuses a symbol on purpose, so the tool
|
|
139
|
+
never picks one.
|
|
140
|
+
|
|
141
|
+
1. One `graph_query` reads the `Asset` lookup on `USE facts` by symbol. When
|
|
142
|
+
no contract carries the symbol, the same read runs by name. The server
|
|
143
|
+
matches exactly, in any case, and orders the rows verified first, then
|
|
144
|
+
oldest first. The proxy keeps that order.
|
|
145
|
+
2. One `graph_query_batch` reads, for each candidate, the address that
|
|
146
|
+
deployed it (`factory`) and the sender of that transaction (`creator`) on
|
|
147
|
+
`USE topology`. A batch holds at most 20 reads, so 25 candidates take two.
|
|
148
|
+
A failed or refused creator read keeps the candidate, with `creator` and
|
|
149
|
+
`factory` empty, and the `hint` says the creators were not read.
|
|
150
|
+
3. The answer carries at most 25 `candidates`, `total` (the rows the server
|
|
151
|
+
sent, at most 26) and `truncated` (true when there are more than 25).
|
|
152
|
+
Each candidate has `first_seen_timestamp_utc` beside the milliseconds.
|
|
153
|
+
|
|
154
|
+
Zero candidates is an answer: no contract on the network carries the symbol
|
|
155
|
+
or the name. A contract address sent as `symbol` sends no read: an address is
|
|
156
|
+
already an anchor, read it on `USE topology`. A server that does not serve the
|
|
157
|
+
`Asset` read yet answers with no candidates and a `hint` to ask the user for
|
|
158
|
+
the contract. Both reads are billed as any read.
|
|
159
|
+
`cia mcp call meta_token_lookup network=robinhood symbol=TCITY` runs the same
|
|
160
|
+
lookup in a terminal.
|
|
161
|
+
|
|
135
162
|
## Host parity
|
|
136
163
|
|
|
137
164
|
**A rule a host never loads does not exist for that host.** Each host loads a
|
|
@@ -145,6 +172,7 @@ different part of what this package ships:
|
|
|
145
172
|
| tool descriptions | yes | yes | yes | yes | yes | yes |
|
|
146
173
|
| result `hint` | yes | yes | yes | yes | yes | yes |
|
|
147
174
|
| protocol tool doors | yes | yes | yes | yes | yes | yes |
|
|
175
|
+
| token door `meta_token_lookup` | yes | yes | yes | yes | yes | yes |
|
|
148
176
|
|
|
149
177
|
The scout agent pins the CLI by version in its image and copies only
|
|
150
178
|
`chain-insights-cypher` and `chain-insights-virtuals` into its project, yet asks
|
|
@@ -172,6 +200,12 @@ buying is `cia subscription buy` in a terminal, an agent never buys, and $CIA
|
|
|
172
200
|
sent by hand to any other address is not credited. The core skill repeats them
|
|
173
201
|
as its rule 12. `tests/subscription-rules.test.ts` holds both.
|
|
174
202
|
|
|
203
|
+
A token named by its ticker takes the same path. The `meta_token_lookup`
|
|
204
|
+
description carries the rule (tickers collide, zero candidates is an answer,
|
|
205
|
+
never search the web), the `graph_query` description sends a named token to
|
|
206
|
+
it, and the core skill `chain-insights-cypher` repeats it as a row of its
|
|
207
|
+
question table.
|
|
208
|
+
|
|
175
209
|
A host that loads skills gets both. A host that loads none gets the door.
|
|
176
210
|
`tests/host-parity.test.ts` checks it: every
|
|
177
211
|
`skills/chain-insights-<protocol>/SKILL.md` has a door, the door is in
|
|
@@ -494,7 +528,7 @@ LIMIT 10
|
|
|
494
528
|
```text
|
|
495
529
|
Use Chain Insights graph_query_batch on network robinhood with these read-only Cypher queries:
|
|
496
530
|
1. USE topology MATCH (a:Address) RETURN count(a) AS count LIMIT 1
|
|
497
|
-
2. USE topology MATCH (src:Address)-[f:
|
|
531
|
+
2. USE topology MATCH (src:Address)-[f:FLOWED_TO]->(dst:Address) RETURN src.address AS source, dst.address AS target, f.amount_usd_sum AS amount_usd_sum LIMIT 3
|
|
498
532
|
```
|
|
499
533
|
|
|
500
534
|
```text
|
package/docs/stability.md
CHANGED
|
@@ -18,13 +18,14 @@ Exit codes are contract. Scripts and agent harnesses may rely on them.
|
|
|
18
18
|
|
|
19
19
|
### MCP tool names
|
|
20
20
|
|
|
21
|
-
The public MCP surface is these
|
|
21
|
+
The public MCP surface is these thirteen tools:
|
|
22
22
|
|
|
23
23
|
- `graph_query`
|
|
24
24
|
- `graph_query_batch`
|
|
25
25
|
- `meta_network_capabilities`
|
|
26
26
|
- `meta_schema`
|
|
27
27
|
- `meta_dex_lookup`
|
|
28
|
+
- `meta_token_lookup`
|
|
28
29
|
- `meta_rules`
|
|
29
30
|
- `meta_help`
|
|
30
31
|
- `meta_usage_status`
|
|
@@ -33,7 +34,7 @@ The public MCP surface is these twelve tools:
|
|
|
33
34
|
- `wallet_topup`
|
|
34
35
|
- `subscription_topup`
|
|
35
36
|
|
|
36
|
-
`graph_expand` is the
|
|
37
|
+
`graph_expand` is the fourteenth tool the proxy registers. The view calls it
|
|
37
38
|
when you click in a picture; hosts keep it out of the model's tool list. It
|
|
38
39
|
is not part of the public surface.
|
|
39
40
|
|