chia-explorer 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 +81 -0
- package/dist/chia/amounts.d.ts +11 -0
- package/dist/chia/amounts.js +52 -0
- package/dist/chia/amounts.js.map +1 -0
- package/dist/chia/bech32.d.ts +8 -0
- package/dist/chia/bech32.js +31 -0
- package/dist/chia/bech32.js.map +1 -0
- package/dist/chia/coin-name.d.ts +15 -0
- package/dist/chia/coin-name.js +40 -0
- package/dist/chia/coin-name.js.map +1 -0
- package/dist/chia/hex.d.ts +4 -0
- package/dist/chia/hex.js +26 -0
- package/dist/chia/hex.js.map +1 -0
- package/dist/coinset/agent.d.ts +7 -0
- package/dist/coinset/agent.js +26 -0
- package/dist/coinset/agent.js.map +1 -0
- package/dist/coinset/pagination.d.ts +24 -0
- package/dist/coinset/pagination.js +42 -0
- package/dist/coinset/pagination.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/network.d.ts +6 -0
- package/dist/network.js +18 -0
- package/dist/network.js.map +1 -0
- package/dist/prompts/address-summary.d.ts +2 -0
- package/dist/prompts/address-summary.js +34 -0
- package/dist/prompts/address-summary.js.map +1 -0
- package/dist/prompts/block-summary.d.ts +2 -0
- package/dist/prompts/block-summary.js +50 -0
- package/dist/prompts/block-summary.js.map +1 -0
- package/dist/prompts/network-status.d.ts +2 -0
- package/dist/prompts/network-status.js +29 -0
- package/dist/prompts/network-status.js.map +1 -0
- package/dist/schemas/common.d.ts +7 -0
- package/dist/schemas/common.js +24 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +42 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/addresses/address-to-puzzle-hash.d.ts +2 -0
- package/dist/tools/addresses/address-to-puzzle-hash.js +21 -0
- package/dist/tools/addresses/address-to-puzzle-hash.js.map +1 -0
- package/dist/tools/addresses/puzzle-hash-to-address.d.ts +2 -0
- package/dist/tools/addresses/puzzle-hash-to-address.js +24 -0
- package/dist/tools/addresses/puzzle-hash-to-address.js.map +1 -0
- package/dist/tools/blockchain/count-block-transactions.d.ts +2 -0
- package/dist/tools/blockchain/count-block-transactions.js +52 -0
- package/dist/tools/blockchain/count-block-transactions.js.map +1 -0
- package/dist/tools/blockchain/get-block-by-hash.d.ts +2 -0
- package/dist/tools/blockchain/get-block-by-hash.js +27 -0
- package/dist/tools/blockchain/get-block-by-hash.js.map +1 -0
- package/dist/tools/blockchain/get-block-by-height.d.ts +2 -0
- package/dist/tools/blockchain/get-block-by-height.js +28 -0
- package/dist/tools/blockchain/get-block-by-height.js.map +1 -0
- package/dist/tools/blockchain/get-blockchain-state.d.ts +2 -0
- package/dist/tools/blockchain/get-blockchain-state.js +37 -0
- package/dist/tools/blockchain/get-blockchain-state.js.map +1 -0
- package/dist/tools/blockchain/get-netspace.d.ts +2 -0
- package/dist/tools/blockchain/get-netspace.js +26 -0
- package/dist/tools/blockchain/get-netspace.js.map +1 -0
- package/dist/tools/blockchain/get-peak-height.d.ts +2 -0
- package/dist/tools/blockchain/get-peak-height.js +23 -0
- package/dist/tools/blockchain/get-peak-height.js.map +1 -0
- package/dist/tools/coins/calculate-coin-name.d.ts +2 -0
- package/dist/tools/coins/calculate-coin-name.js +28 -0
- package/dist/tools/coins/calculate-coin-name.js.map +1 -0
- package/dist/tools/coins/get-balance.d.ts +2 -0
- package/dist/tools/coins/get-balance.js +35 -0
- package/dist/tools/coins/get-balance.js.map +1 -0
- package/dist/tools/coins/get-coin-by-name.d.ts +2 -0
- package/dist/tools/coins/get-coin-by-name.js +34 -0
- package/dist/tools/coins/get-coin-by-name.js.map +1 -0
- package/dist/tools/coins/get-coin-records-by-puzzle-hash.d.ts +2 -0
- package/dist/tools/coins/get-coin-records-by-puzzle-hash.js +36 -0
- package/dist/tools/coins/get-coin-records-by-puzzle-hash.js.map +1 -0
- package/dist/tools/shared/address-input.d.ts +12 -0
- package/dist/tools/shared/address-input.js +26 -0
- package/dist/tools/shared/address-input.js.map +1 -0
- package/dist/tools/shared/response.d.ts +3 -0
- package/dist/tools/shared/response.js +16 -0
- package/dist/tools/shared/response.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { addressToPuzzleHash, looksLikeAddress, puzzleHashToAddress } from '../../chia/bech32.js';
|
|
2
|
+
import { isHex32, stripHexPrefix } from '../../chia/hex.js';
|
|
3
|
+
import { DEFAULT_NETWORK } from '../../network.js';
|
|
4
|
+
/**
|
|
5
|
+
* Resolve a user-supplied "address or puzzle hash" into a normalized form.
|
|
6
|
+
* If both an address and a network argument are provided and they disagree,
|
|
7
|
+
* throws — better to surface the mismatch than silently pick one.
|
|
8
|
+
*/
|
|
9
|
+
export function resolveAddressOrPuzzleHash(input, requestedNetwork) {
|
|
10
|
+
const trimmed = input.trim();
|
|
11
|
+
if (looksLikeAddress(trimmed)) {
|
|
12
|
+
const { puzzleHash, network: detected } = addressToPuzzleHash(trimmed);
|
|
13
|
+
if (requestedNetwork && requestedNetwork !== detected) {
|
|
14
|
+
throw new Error(`network mismatch: address belongs to ${detected} but network argument was ${requestedNetwork}`);
|
|
15
|
+
}
|
|
16
|
+
return { puzzleHash, address: trimmed.toLowerCase(), network: detected };
|
|
17
|
+
}
|
|
18
|
+
if (isHex32(trimmed)) {
|
|
19
|
+
const network = requestedNetwork ?? DEFAULT_NETWORK;
|
|
20
|
+
const puzzleHash = stripHexPrefix(trimmed).toLowerCase();
|
|
21
|
+
const address = puzzleHashToAddress(puzzleHash, network);
|
|
22
|
+
return { puzzleHash, address, network };
|
|
23
|
+
}
|
|
24
|
+
throw new Error(`input is neither a valid xch/txch address nor a 32-byte hex puzzle hash: ${trimmed.slice(0, 40)}`);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMapping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AAE,EAAE,CAAC,EAAE,CACnG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function bigIntReplacer(_key, value) {
|
|
2
|
+
return typeof value === 'bigint' ? value.toString() : value;
|
|
3
|
+
}
|
|
4
|
+
export function jsonText(data) {
|
|
5
|
+
return {
|
|
6
|
+
content: [{ type: 'text', text: JSON.stringify(data, bigIntReplacer) }],
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function errorText(err) {
|
|
10
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
11
|
+
return {
|
|
12
|
+
content: [{ type: 'text', text: JSON.stringify({ error: message }) }],
|
|
13
|
+
isError: true,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/tools/shared/response.ts"],"names":[],"mappings":"AAEA,SAAS,cAAc,CAAC,IAAY,EAAE,KAAc;IAClD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAa;IACpC,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,CAAC;KACxE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,GAAY;IACpC,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;QACrE,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION: string;
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
const pkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
|
|
5
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
6
|
+
export const VERSION = pkg.version;
|
|
7
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;AACpF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAwB,CAAC;AAE7E,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chia-explorer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server that answers questions about the Chia blockchain via the public coinset.org API",
|
|
5
|
+
"mcpName": "io.github.Spacetime-Technology/chia-explorer",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "Spacetime Technology",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"mcp",
|
|
11
|
+
"model-context-protocol",
|
|
12
|
+
"mcp-server",
|
|
13
|
+
"chia",
|
|
14
|
+
"blockchain",
|
|
15
|
+
"coinset",
|
|
16
|
+
"xch",
|
|
17
|
+
"claude",
|
|
18
|
+
"claude-desktop"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/Spacetime-Technology/chia-explorer.git"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/Spacetime-Technology/chia-explorer#readme",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/Spacetime-Technology/chia-explorer/issues"
|
|
27
|
+
},
|
|
28
|
+
"bin": {
|
|
29
|
+
"chia-explorer": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist/**/*",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"prepare": "husky",
|
|
38
|
+
"preversion": "bash scripts/prerelease.sh",
|
|
39
|
+
"version": "node scripts/sync-server-json.js && git add server.json",
|
|
40
|
+
"postversion": "git push --follow-tags origin main",
|
|
41
|
+
"prepublishOnly": "npm run build",
|
|
42
|
+
"build": "tsc -p tsconfig.build.json && chmod +x dist/index.js",
|
|
43
|
+
"dev": "tsx src/index.ts",
|
|
44
|
+
"start": "node dist/index.js",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"test:watch": "vitest",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"lint": "eslint src tests",
|
|
49
|
+
"format": "prettier --write src tests",
|
|
50
|
+
"format:check": "prettier --check src tests"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
54
|
+
"@scure/base": "^1.1.9",
|
|
55
|
+
"chia-agent": "^14.3.1",
|
|
56
|
+
"zod": "^3.24.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@eslint/js": "^10.0.1",
|
|
60
|
+
"@types/node": "^22.0.0",
|
|
61
|
+
"@typescript-eslint/eslint-plugin": "^8.59.3",
|
|
62
|
+
"@typescript-eslint/parser": "^8.59.3",
|
|
63
|
+
"eslint": "^10.4.0",
|
|
64
|
+
"eslint-config-prettier": "^10.1.8",
|
|
65
|
+
"husky": "^9.1.7",
|
|
66
|
+
"prettier": "^3.8.3",
|
|
67
|
+
"tsx": "^4.19.0",
|
|
68
|
+
"typescript": "^5.7.0",
|
|
69
|
+
"typescript-eslint": "^8.59.3",
|
|
70
|
+
"vitest": "^3.2.0"
|
|
71
|
+
},
|
|
72
|
+
"engines": {
|
|
73
|
+
"node": ">=20.0.0"
|
|
74
|
+
}
|
|
75
|
+
}
|