chia-explorer 0.1.0 → 0.1.2

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.
@@ -16,6 +16,11 @@ export interface CoinRecordLike {
16
16
  * looks capped. Coinset returns up to a fixed number of records per call; when
17
17
  * we see exactly that many, we re-query the range above the highest confirmed
18
18
  * height we've seen so far.
19
+ *
20
+ * Only include start_height / end_height in the payload when the caller asked
21
+ * for them. coinset.org treats end_height literally as a block height, so the
22
+ * full-node convention of passing 0xffffffff to mean "no upper bound" returns
23
+ * zero records.
19
24
  */
20
25
  export declare function fetchCoinRecordsByPuzzleHash(agent: RPCAgent, puzzleHashHex: string, options?: {
21
26
  includeSpent?: boolean;
@@ -1,27 +1,36 @@
1
1
  import { get_coin_records_by_puzzle_hash } from 'chia-agent/api/rpc/full_node/index.js';
2
- const MAX_HEIGHT = 0xffffffff;
3
2
  const PAGE_SIZE_LIMIT = 5_000;
4
3
  /**
5
4
  * Fetch coin records by puzzle hash, paginating by height window if the response
6
5
  * looks capped. Coinset returns up to a fixed number of records per call; when
7
6
  * we see exactly that many, we re-query the range above the highest confirmed
8
7
  * height we've seen so far.
8
+ *
9
+ * Only include start_height / end_height in the payload when the caller asked
10
+ * for them. coinset.org treats end_height literally as a block height, so the
11
+ * full-node convention of passing 0xffffffff to mean "no upper bound" returns
12
+ * zero records.
9
13
  */
10
14
  export async function fetchCoinRecordsByPuzzleHash(agent, puzzleHashHex, options = {}) {
11
15
  const includeSpent = options.includeSpent ?? false;
12
- let start = options.startHeight ?? 0;
13
- const end = options.endHeight ?? MAX_HEIGHT;
16
+ let start = options.startHeight;
17
+ const end = options.endHeight;
14
18
  const all = [];
15
19
  const seen = new Set();
16
- while (start <= end) {
17
- const res = await get_coin_records_by_puzzle_hash(agent, {
20
+ while (true) {
21
+ if (start !== undefined && end !== undefined && start > end)
22
+ break;
23
+ const payload = {
18
24
  puzzle_hash: puzzleHashHex,
19
- start_height: start,
20
- end_height: end,
21
25
  include_spent_coins: includeSpent,
22
- });
26
+ };
27
+ if (start !== undefined)
28
+ payload.start_height = start;
29
+ if (end !== undefined)
30
+ payload.end_height = end;
31
+ const res = await get_coin_records_by_puzzle_hash(agent, payload);
23
32
  const records = (res.coin_records ?? []);
24
- let maxHeight = start;
33
+ let maxHeight = start ?? 0;
25
34
  for (const r of records) {
26
35
  const key = `${r.coin.parent_coin_info}|${r.coin.puzzle_hash}|${r.coin.amount.toString()}`;
27
36
  if (seen.has(key))
@@ -33,7 +42,7 @@ export async function fetchCoinRecordsByPuzzleHash(agent, puzzleHashHex, options
33
42
  }
34
43
  if (records.length < PAGE_SIZE_LIMIT)
35
44
  break;
36
- if (maxHeight <= start)
45
+ if (start !== undefined && maxHeight <= start)
37
46
  break;
38
47
  start = maxHeight + 1;
39
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/coinset/pagination.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AAexF,MAAM,UAAU,GAAG,UAAU,CAAC;AAC9B,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,KAAe,EACf,aAAqB,EACrB,UAAgF,EAAE;IAElF,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,KAAK,CAAC;IACnD,IAAI,KAAK,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,IAAI,UAAU,CAAC;IAC5C,MAAM,GAAG,GAAqB,EAAE,CAAC;IACjC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,OAAO,KAAK,IAAI,GAAG,EAAE,CAAC;QACpB,MAAM,GAAG,GAAG,MAAM,+BAA+B,CAAC,KAAK,EAAE;YACvD,WAAW,EAAE,aAAa;YAC1B,YAAY,EAAE,KAAK;Y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,IAAI,SAAS,IAAI,KAAK;YAAE,MAAM;QACrD,KAAK,GAAG,SAAS,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chia-explorer",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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",