chia-explorer 0.1.5 → 0.2.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 +172 -10
- package/dist/chia/offer.d.ts +58 -0
- package/dist/chia/offer.js +356 -0
- package/dist/chia/offer.js.map +1 -0
- package/dist/chips/index.d.ts +68 -0
- package/dist/chips/index.js +214 -0
- package/dist/chips/index.js.map +1 -0
- package/dist/chips/parser.d.ts +30 -0
- package/dist/chips/parser.js +208 -0
- package/dist/chips/parser.js.map +1 -0
- package/dist/github/cache.d.ts +3 -0
- package/dist/github/cache.js +18 -0
- package/dist/github/cache.js.map +1 -0
- package/dist/github/client.d.ts +5 -0
- package/dist/github/client.js +68 -0
- package/dist/github/client.js.map +1 -0
- package/dist/schemas/chips.d.ts +8 -0
- package/dist/schemas/chips.js +39 -0
- package/dist/schemas/chips.js.map +1 -0
- package/dist/server.js +24 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/chips/get-chip.d.ts +2 -0
- package/dist/tools/chips/get-chip.js +30 -0
- package/dist/tools/chips/get-chip.js.map +1 -0
- package/dist/tools/chips/list-chip-drafts.d.ts +2 -0
- package/dist/tools/chips/list-chip-drafts.js +19 -0
- package/dist/tools/chips/list-chip-drafts.js.map +1 -0
- package/dist/tools/chips/list-chips.d.ts +2 -0
- package/dist/tools/chips/list-chips.js +33 -0
- package/dist/tools/chips/list-chips.js.map +1 -0
- package/dist/tools/chips/search-chips.d.ts +2 -0
- package/dist/tools/chips/search-chips.js +31 -0
- package/dist/tools/chips/search-chips.js.map +1 -0
- package/dist/tools/coins/get-puzzle-and-solution.js +23 -3
- package/dist/tools/coins/get-puzzle-and-solution.js.map +1 -1
- package/dist/tools/mempool/estimate-fee.d.ts +2 -0
- package/dist/tools/mempool/estimate-fee.js +73 -0
- package/dist/tools/mempool/estimate-fee.js.map +1 -0
- package/dist/tools/mempool/get-mempool.d.ts +2 -0
- package/dist/tools/mempool/get-mempool.js +51 -0
- package/dist/tools/mempool/get-mempool.js.map +1 -0
- package/dist/tools/mempool/is-in-mempool.d.ts +2 -0
- package/dist/tools/mempool/is-in-mempool.js +37 -0
- package/dist/tools/mempool/is-in-mempool.js.map +1 -0
- package/dist/tools/offers/decode-offer.d.ts +2 -0
- package/dist/tools/offers/decode-offer.js +20 -0
- package/dist/tools/offers/decode-offer.js.map +1 -0
- package/dist/tools/offers/decode-spend-bundle.d.ts +2 -0
- package/dist/tools/offers/decode-spend-bundle.js +20 -0
- package/dist/tools/offers/decode-spend-bundle.js.map +1 -0
- package/dist/tools/offers/decompile-puzzle.d.ts +2 -0
- package/dist/tools/offers/decompile-puzzle.js +62 -0
- package/dist/tools/offers/decompile-puzzle.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { get_puzzle_and_solution } from 'chia-agent/api/rpc/full_node/index.js';
|
|
3
|
+
import { getAgent } from '../../coinset/agent.js';
|
|
4
|
+
import { classifyPuzzle, parseConditions } from '../../chia/offer.js';
|
|
5
|
+
import { hex32Schema, heightSchema, networkSchema } from '../../schemas/common.js';
|
|
6
|
+
import { stripHexPrefix } from '../../chia/hex.js';
|
|
7
|
+
import { errorText, jsonText } from '../shared/response.js';
|
|
8
|
+
export function register(server) {
|
|
9
|
+
server.tool('decompile_puzzle', 'Classify a Chia CLVM puzzle reveal. Returns its kind (xch, cat, nft, did, singleton, unknown), asset_id for CATs, launcher_id for NFTs/DIDs, and the inner p2 puzzle hash. Either pass `puzzle_reveal` as hex directly, OR pass `coin_id` + `height` to auto-fetch from the full node. Set `include_conditions: true` to also parse the conditions a spend emits (requires `solution` hex, or a spent coin reachable via coin_id + height).', {
|
|
10
|
+
puzzle_reveal: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe('Hex-encoded puzzle reveal. Omit to auto-fetch via coin_id + height.'),
|
|
14
|
+
solution: z
|
|
15
|
+
.string()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe('Hex-encoded solution. Only used when include_conditions is true.'),
|
|
18
|
+
coin_id: hex32Schema
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('32-byte coin id. Use with `height` to auto-fetch the puzzle reveal.'),
|
|
21
|
+
height: heightSchema
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('The spent_block_index of the coin (where it was spent).'),
|
|
24
|
+
include_conditions: z
|
|
25
|
+
.boolean()
|
|
26
|
+
.default(false)
|
|
27
|
+
.describe('If true, run the puzzle with the solution and parse the emitted conditions.'),
|
|
28
|
+
network: networkSchema,
|
|
29
|
+
}, async ({ puzzle_reveal, solution, coin_id, height, include_conditions, network }) => {
|
|
30
|
+
try {
|
|
31
|
+
let revealHex = puzzle_reveal;
|
|
32
|
+
let solutionHex = solution;
|
|
33
|
+
if (!revealHex) {
|
|
34
|
+
if (!coin_id || height === undefined) {
|
|
35
|
+
throw new Error('must supply either `puzzle_reveal` (hex) or both `coin_id` and `height` to auto-fetch');
|
|
36
|
+
}
|
|
37
|
+
const agent = getAgent(network);
|
|
38
|
+
const normalizedCoinId = stripHexPrefix(coin_id).toLowerCase();
|
|
39
|
+
const res = await get_puzzle_and_solution(agent, {
|
|
40
|
+
coin_id: normalizedCoinId,
|
|
41
|
+
height,
|
|
42
|
+
});
|
|
43
|
+
revealHex = res.coin_solution.puzzle_reveal;
|
|
44
|
+
if (!solutionHex)
|
|
45
|
+
solutionHex = res.coin_solution.solution;
|
|
46
|
+
}
|
|
47
|
+
const classification = classifyPuzzle(revealHex);
|
|
48
|
+
const out = { classification };
|
|
49
|
+
if (include_conditions) {
|
|
50
|
+
if (!solutionHex) {
|
|
51
|
+
throw new Error('`include_conditions: true` requires a `solution` argument (or a fetchable coin_id + height that yields one)');
|
|
52
|
+
}
|
|
53
|
+
out.parsed_conditions = parseConditions(revealHex, solutionHex);
|
|
54
|
+
}
|
|
55
|
+
return jsonText(out);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
return errorText(err);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=decompile-puzzle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decompile-puzzle.js","sourceRoot":"","sources":["../../../src/tools/offers/decompile-puzzle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,IAAI,CACT,kBAAkB,EAClB,6aAA6a,EAC7a;QACE,aAAa,EAAE,CAAC;aACb,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,qEAAqE,CAAC;QAClF,QAAQ,EAAE,CAAC;aACR,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,kEAAkE,CAAC;QAC/E,OAAO,EAAE,WAAW;aACjB,QAAQ,EAAE;aACV,QAAQ,CAAC,qEAAqE,CAAC;QAClF,MAAM,EAAE,YAAY;aACjB,QAAQ,EAAE;aACV,QAAQ,CAAC,yDAAyD,CAAC;QACtE,kBAAkB,EAAE,CAAC;aAClB,OAAO,EAAE;aACT,OAAO,CAAC,KAAK,CAAC;aACd,QAAQ,CAAC,6EAA6E,CAAC;QAC1F,OAAO,EAAE,aAAa;KACvB,EACD,KAAK,EAAE,EAAE,aAAa,EAAE,QAAQ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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chia-explorer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "MCP server that answers questions about the Chia blockchain via the public coinset.org API",
|
|
5
5
|
"mcpName": "io.github.Spacetime-Technology/chia-explorer",
|
|
6
6
|
"type": "module",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
54
54
|
"@scure/base": "^1.1.9",
|
|
55
55
|
"chia-agent": "^14.3.1",
|
|
56
|
+
"chia-wallet-sdk": "^0.33.0",
|
|
56
57
|
"zod": "^3.24.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|