chia-explorer 0.1.3 → 0.1.5
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/dist/coinset/pagination.d.ts +5 -0
- package/dist/coinset/pagination.js +23 -1
- package/dist/coinset/pagination.js.map +1 -1
- package/dist/prefarm/registry.d.ts +33 -0
- package/dist/prefarm/registry.js +121 -0
- package/dist/prefarm/registry.js.map +1 -0
- package/dist/prefarm/spends.d.ts +29 -0
- package/dist/prefarm/spends.js +113 -0
- package/dist/prefarm/spends.js.map +1 -0
- package/dist/prompts/prefarm-summary.d.ts +2 -0
- package/dist/prompts/prefarm-summary.js +27 -0
- package/dist/prompts/prefarm-summary.js.map +1 -0
- package/dist/server.js +14 -0
- package/dist/server.js.map +1 -1
- package/dist/tools/blockchain/get-block-additions-and-removals.d.ts +2 -0
- package/dist/tools/blockchain/get-block-additions-and-removals.js +52 -0
- package/dist/tools/blockchain/get-block-additions-and-removals.js.map +1 -0
- package/dist/tools/coins/get-coin-records-by-parent-ids.d.ts +2 -0
- package/dist/tools/coins/get-coin-records-by-parent-ids.js +40 -0
- package/dist/tools/coins/get-coin-records-by-parent-ids.js.map +1 -0
- package/dist/tools/coins/get-puzzle-and-solution.d.ts +2 -0
- package/dist/tools/coins/get-puzzle-and-solution.js +31 -0
- package/dist/tools/coins/get-puzzle-and-solution.js.map +1 -0
- package/dist/tools/prefarm/get-prefarm-spends.d.ts +2 -0
- package/dist/tools/prefarm/get-prefarm-spends.js +68 -0
- package/dist/tools/prefarm/get-prefarm-spends.js.map +1 -0
- package/dist/tools/prefarm/get-prefarm-status.d.ts +2 -0
- package/dist/tools/prefarm/get-prefarm-status.js +72 -0
- package/dist/tools/prefarm/get-prefarm-status.js.map +1 -0
- package/dist/tools/prefarm/list-prefarm-addresses.d.ts +2 -0
- package/dist/tools/prefarm/list-prefarm-addresses.js +33 -0
- package/dist/tools/prefarm/list-prefarm-addresses.js.map +1 -0
- package/package.json +1 -1
|
@@ -27,3 +27,8 @@ export declare function fetchCoinRecordsByPuzzleHash(agent: RPCAgent, puzzleHash
|
|
|
27
27
|
startHeight?: number;
|
|
28
28
|
endHeight?: number;
|
|
29
29
|
}): Promise<CoinRecordLike[]>;
|
|
30
|
+
export declare function fetchCoinRecordsByParentIds(agent: RPCAgent, parentIds: readonly string[], options?: {
|
|
31
|
+
includeSpent?: boolean;
|
|
32
|
+
startHeight?: number;
|
|
33
|
+
endHeight?: number;
|
|
34
|
+
}): Promise<CoinRecordLike[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get_coin_records_by_puzzle_hash } from 'chia-agent/api/rpc/full_node/index.js';
|
|
1
|
+
import { get_coin_records_by_parent_ids, get_coin_records_by_puzzle_hash, } from 'chia-agent/api/rpc/full_node/index.js';
|
|
2
2
|
const PAGE_SIZE_LIMIT = 5_000;
|
|
3
3
|
/**
|
|
4
4
|
* Fetch coin records by puzzle hash, paginating by height window if the response
|
|
@@ -48,4 +48,26 @@ export async function fetchCoinRecordsByPuzzleHash(agent, puzzleHashHex, options
|
|
|
48
48
|
}
|
|
49
49
|
return all;
|
|
50
50
|
}
|
|
51
|
+
const PARENT_IDS_BATCH = 200;
|
|
52
|
+
export async function fetchCoinRecordsByParentIds(agent, parentIds, options = {}) {
|
|
53
|
+
if (parentIds.length === 0)
|
|
54
|
+
return [];
|
|
55
|
+
const includeSpent = options.includeSpent ?? true;
|
|
56
|
+
const all = [];
|
|
57
|
+
for (let i = 0; i < parentIds.length; i += PARENT_IDS_BATCH) {
|
|
58
|
+
const batch = parentIds.slice(i, i + PARENT_IDS_BATCH);
|
|
59
|
+
const payload = {
|
|
60
|
+
parent_ids: batch,
|
|
61
|
+
include_spent_coins: includeSpent,
|
|
62
|
+
};
|
|
63
|
+
if (options.startHeight !== undefined)
|
|
64
|
+
payload.start_height = options.startHeight;
|
|
65
|
+
if (options.endHeight !== undefined)
|
|
66
|
+
payload.end_height = options.endHeight;
|
|
67
|
+
const res = await get_coin_records_by_parent_ids(agent, payload);
|
|
68
|
+
const records = (res.coin_records ?? []);
|
|
69
|
+
all.push(...records);
|
|
70
|
+
}
|
|
71
|
+
return all;
|
|
72
|
+
}
|
|
51
73
|
//# sourceMappingURL=pagination.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/coinset/pagination.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/coinset/pagination.ts"],"names":[],"mappings":"AACA,OAAO,EACL,8BAA8B,EAC9B,+BAA+B,GAChC,MAAM,uCAAuC,CAAC;AAkB/C,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B;;;;;;;;;;GAUG;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,CAAC;IAChC,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC;IAC9B,MAAM,GAAG,GAAqB,EAAE,CAAC;IACjC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,KAAK,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,IAAI,KAAK,GAAG,GAAG;YAAE,MAAM;QACnE,MAAM,OAAO,GAA+B;YAC1C,WAAW,EAAE,aAAa;YAC1B,mBAAmB,EAAE,YAAY;SAClC,CAAC;QACF,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC;QACtD,IAAI,GAAG,KAAK,SAAS;YAAE,OAAO,CAAC,UAAU,GAAG,GAAG,CAAC;QAChD,MAAM,GAAG,GAAG,MAAM,+BAA+B,CAAC,KAAK,EAAE,OAA4B,CAAC,CAAC;Q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AS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC;QACvD,MAAM,OAAO,GAA8B;YACzC,UAAU,EAAE,KAAK;YACjB,mBAAmB,EAAE,YAAY;SAClC,CAAC;QACF,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS;YAAE,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;QAClF,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS;YAAE,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;QAC5E,MAAM,GAAG,GAAG,MAAM,8BAA8B,CAAC,KAAK,EAAE,OAA2B,CAAC,CAAC;QACrF,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAqB,CAAC;QAC7D,GAAG,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type WalletId = 'us-cold' | 'us-warm' | 'ch-cold' | 'ch-warm';
|
|
2
|
+
export type Region = 'us' | 'ch';
|
|
3
|
+
export type Temperature = 'cold' | 'warm';
|
|
4
|
+
export type DestinationCategory = 'partner' | 'market-maker' | 'exchange' | 'other';
|
|
5
|
+
export interface PrefarmWallet {
|
|
6
|
+
id: WalletId;
|
|
7
|
+
label: string;
|
|
8
|
+
region: Region;
|
|
9
|
+
temperature: Temperature;
|
|
10
|
+
/**
|
|
11
|
+
* Current on-chain p2 addresses for this custody singleton. Warm wallets carry
|
|
12
|
+
* more than one because outgoing spends sit at a clawback intermediate before
|
|
13
|
+
* settling. Empty array = pending population.
|
|
14
|
+
*/
|
|
15
|
+
addresses: readonly string[];
|
|
16
|
+
/** Lower-case hex puzzle hashes derived from `addresses`. Same length, same order. */
|
|
17
|
+
puzzleHashes: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
export interface KnownDestination {
|
|
20
|
+
address: string;
|
|
21
|
+
puzzleHash: string;
|
|
22
|
+
entity: string;
|
|
23
|
+
label: string;
|
|
24
|
+
category: DestinationCategory;
|
|
25
|
+
}
|
|
26
|
+
/** Genesis total of the Chia strategic reserve. The only amount we hardcode; everything else is live. */
|
|
27
|
+
export declare const TOTAL_PREFARM_ALLOCATION_MOJO: bigint;
|
|
28
|
+
export declare const PREFARM_WALLETS: readonly PrefarmWallet[];
|
|
29
|
+
export declare const KNOWN_DESTINATIONS: readonly KnownDestination[];
|
|
30
|
+
export declare function lookupDestination(puzzleHashHex: string): KnownDestination | undefined;
|
|
31
|
+
export declare function lookupPrefarmWallet(puzzleHashHex: string): PrefarmWallet | undefined;
|
|
32
|
+
export declare function getWalletById(id: WalletId): PrefarmWallet | undefined;
|
|
33
|
+
export declare function isPopulated(wallet: PrefarmWallet): boolean;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { MOJOS_PER_XCH } from '../chia/amounts.js';
|
|
2
|
+
import { addressToPuzzleHash } from '../chia/bech32.js';
|
|
3
|
+
/** Genesis total of the Chia strategic reserve. The only amount we hardcode; everything else is live. */
|
|
4
|
+
export const TOTAL_PREFARM_ALLOCATION_MOJO = 21000000n * MOJOS_PER_XCH;
|
|
5
|
+
const WALLET_INPUTS = [
|
|
6
|
+
{
|
|
7
|
+
id: 'us-cold',
|
|
8
|
+
label: 'Strategic Reserve — US Cold',
|
|
9
|
+
region: 'us',
|
|
10
|
+
temperature: 'cold',
|
|
11
|
+
addresses: ['xch1yxqsmyuyjdlgxw4sqjg4vqlqv5ms2qzex00586nu643jqemmarwslh08yl'],
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: 'us-warm',
|
|
15
|
+
label: 'Strategic Reserve — US Warm',
|
|
16
|
+
region: 'us',
|
|
17
|
+
temperature: 'warm',
|
|
18
|
+
addresses: [
|
|
19
|
+
'xch12pc7qk46t8aktdsd7ss96pctdp0236sexakfsdvsqefuqyyll3hqzhnldc',
|
|
20
|
+
'xch1aukdy3djga7j8ckaw06lwjew9pnnv5hugqyx9lu9l2utaxjtgj5snuuwkc',
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'ch-cold',
|
|
25
|
+
label: 'Strategic Reserve — Swiss Cold',
|
|
26
|
+
region: 'ch',
|
|
27
|
+
temperature: 'cold',
|
|
28
|
+
addresses: ['xch1y6krqgs2cjz6mjgz5wy4dd5zqghm3a5pgueccjtudchn2xzcajtsnyzvgy'],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'ch-warm',
|
|
32
|
+
label: 'Strategic Reserve — Swiss Warm',
|
|
33
|
+
region: 'ch',
|
|
34
|
+
temperature: 'warm',
|
|
35
|
+
addresses: [
|
|
36
|
+
'xch18hp0afeqmcvn675dqpnxfhk7gggwcpjaa0huc45huu79tkaa28dsuse43w',
|
|
37
|
+
'xch1xhghtsdqdtt5eqr307lcacg49nt72zmeuq2qfwu7ymmqvqf0ej0qsruh0w',
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
const DESTINATION_INPUTS = [
|
|
42
|
+
{
|
|
43
|
+
address: 'xch1drz2ufckxz7dtlaajsw3gwtyd6ztss08vwxyfcr4rz0z0t77ufrq8qqe09',
|
|
44
|
+
entity: 'silicon',
|
|
45
|
+
label: 'Silicon.net',
|
|
46
|
+
category: 'partner',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
address: 'xch1mhw0vz0jl8etxqar0se73excayq2e4jg3g5zegzumyzm2u4htzusjfk8q4',
|
|
50
|
+
entity: 'koba42',
|
|
51
|
+
label: 'Koba42 Gaming RFP Grant',
|
|
52
|
+
category: 'partner',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
address: 'xch1plthft5ykcnnaxvpydzlmu2nlslzcevn3vv4s43rkm908d95nd5sv22nqr',
|
|
56
|
+
entity: 'nossd',
|
|
57
|
+
label: 'Purchase Agreement with NoSSD',
|
|
58
|
+
category: 'partner',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
address: 'xch1hy7r0hcq4xymv2d944dtsn7rw8tv8pntc7adr36u45zhmmh3ad4seh48zz',
|
|
62
|
+
entity: 'market-maker-primary',
|
|
63
|
+
label: 'Market Maker (primary)',
|
|
64
|
+
category: 'market-maker',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
address: 'xch1g8wl32qjyquzx6rnzn0rpj5l2q5acykawzped7nl5kdsfp3drpqqfavwnf',
|
|
68
|
+
entity: 'market-maker-secondary',
|
|
69
|
+
label: 'Market Maker (secondary)',
|
|
70
|
+
category: 'market-maker',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
address: 'xch1d6w3ctu8pqtkkmsa3hjmqam9fuy7q9u4fzy5hqw08rx36whpg3hs4xpjeu',
|
|
74
|
+
entity: 'market-maker-tertiary',
|
|
75
|
+
label: 'Market Maker (tertiary)',
|
|
76
|
+
category: 'market-maker',
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
function buildWallets() {
|
|
80
|
+
return WALLET_INPUTS.map((w) => {
|
|
81
|
+
const puzzleHashes = w.addresses.map((addr) => {
|
|
82
|
+
const { puzzleHash, network } = addressToPuzzleHash(addr);
|
|
83
|
+
if (network !== 'mainnet') {
|
|
84
|
+
throw new Error(`prefarm wallet ${w.id} must use mainnet addresses`);
|
|
85
|
+
}
|
|
86
|
+
return puzzleHash;
|
|
87
|
+
});
|
|
88
|
+
return { ...w, puzzleHashes };
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function buildDestinations() {
|
|
92
|
+
return DESTINATION_INPUTS.map((d) => {
|
|
93
|
+
const { puzzleHash, network } = addressToPuzzleHash(d.address);
|
|
94
|
+
if (network !== 'mainnet') {
|
|
95
|
+
throw new Error(`destination ${d.entity} must use a mainnet address`);
|
|
96
|
+
}
|
|
97
|
+
return { ...d, puzzleHash };
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export const PREFARM_WALLETS = buildWallets();
|
|
101
|
+
export const KNOWN_DESTINATIONS = buildDestinations();
|
|
102
|
+
const DESTINATION_INDEX = new Map(KNOWN_DESTINATIONS.map((d) => [d.puzzleHash, d]));
|
|
103
|
+
const WALLET_BY_PUZZLE_HASH = new Map();
|
|
104
|
+
for (const w of PREFARM_WALLETS) {
|
|
105
|
+
for (const ph of w.puzzleHashes)
|
|
106
|
+
WALLET_BY_PUZZLE_HASH.set(ph, w);
|
|
107
|
+
}
|
|
108
|
+
const WALLET_BY_ID = new Map(PREFARM_WALLETS.map((w) => [w.id, w]));
|
|
109
|
+
export function lookupDestination(puzzleHashHex) {
|
|
110
|
+
return DESTINATION_INDEX.get(puzzleHashHex.toLowerCase());
|
|
111
|
+
}
|
|
112
|
+
export function lookupPrefarmWallet(puzzleHashHex) {
|
|
113
|
+
return WALLET_BY_PUZZLE_HASH.get(puzzleHashHex.toLowerCase());
|
|
114
|
+
}
|
|
115
|
+
export function getWalletById(id) {
|
|
116
|
+
return WALLET_BY_ID.get(id);
|
|
117
|
+
}
|
|
118
|
+
export function isPopulated(wallet) {
|
|
119
|
+
return wallet.addresses.length > 0;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/prefarm/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAsCxD,yGAAyG;AACzG,MAAM,CAAC,MAAM,6BAA6B,GAAW,SAAW,GAAG,aAAa,CAAC;AAEjF,MAAM,aAAa,GAA2B;IAC5C;QACE,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,6BAA6B;QACpC,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,MAAM;QACnB,SAAS,EAAE,CAAC,gEAAgE,CAAC;KAC9E;I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,EAAE,CAAC;IAChC,KAAK,MAAM,EAAE,IAAI,CAAC,CAAC,YAAY;QAAE,qBAAqB,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC;AACD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpE,MAAM,UAAU,iBAAiB,CAAC,aAAqB;IACrD,OAAO,iBAAiB,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,aAAqB;IACvD,OAAO,qBAAqB,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAAY;IACxC,OAAO,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAqB;IAC/C,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RPCAgent } from 'chia-agent';
|
|
2
|
+
import { KnownDestination, PrefarmWallet } from './registry.js';
|
|
3
|
+
export interface DestinationOutflow {
|
|
4
|
+
puzzle_hash: string;
|
|
5
|
+
address: string;
|
|
6
|
+
amount_mojo: string;
|
|
7
|
+
amount_xch: string;
|
|
8
|
+
entity: string | null;
|
|
9
|
+
label: string | null;
|
|
10
|
+
category: KnownDestination['category'] | 'internal-rotation' | 'unknown';
|
|
11
|
+
internal_wallet_id?: PrefarmWallet['id'];
|
|
12
|
+
}
|
|
13
|
+
export interface PrefarmSpend {
|
|
14
|
+
wallet_id: PrefarmWallet['id'];
|
|
15
|
+
source_address: string;
|
|
16
|
+
source_puzzle_hash: string;
|
|
17
|
+
parent_coin_name: string;
|
|
18
|
+
spent_amount_mojo: string;
|
|
19
|
+
spent_amount_xch: string;
|
|
20
|
+
spent_height: number;
|
|
21
|
+
confirmed_height: number;
|
|
22
|
+
timestamp: number;
|
|
23
|
+
destinations: DestinationOutflow[];
|
|
24
|
+
outflow_mojo: string;
|
|
25
|
+
outflow_xch: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function getWalletSpends(agent: RPCAgent, wallet: PrefarmWallet, options?: {
|
|
28
|
+
sinceHeight?: number;
|
|
29
|
+
}): Promise<PrefarmSpend[]>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { mojoToXch, toBigInt } from '../chia/amounts.js';
|
|
2
|
+
import { puzzleHashToAddress } from '../chia/bech32.js';
|
|
3
|
+
import { coinName } from '../chia/coin-name.js';
|
|
4
|
+
import { fetchCoinRecordsByParentIds, fetchCoinRecordsByPuzzleHash, } from '../coinset/pagination.js';
|
|
5
|
+
import { isPopulated, lookupDestination, lookupPrefarmWallet, } from './registry.js';
|
|
6
|
+
function labelDestination(puzzleHash, address, amountMojo) {
|
|
7
|
+
const internal = lookupPrefarmWallet(puzzleHash);
|
|
8
|
+
if (internal) {
|
|
9
|
+
return {
|
|
10
|
+
puzzle_hash: puzzleHash,
|
|
11
|
+
address,
|
|
12
|
+
amount_mojo: amountMojo.toString(),
|
|
13
|
+
amount_xch: mojoToXch(amountMojo),
|
|
14
|
+
entity: 'prefarm',
|
|
15
|
+
label: internal.label,
|
|
16
|
+
category: 'internal-rotation',
|
|
17
|
+
internal_wallet_id: internal.id,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const known = lookupDestination(puzzleHash);
|
|
21
|
+
if (known) {
|
|
22
|
+
return {
|
|
23
|
+
puzzle_hash: puzzleHash,
|
|
24
|
+
address,
|
|
25
|
+
amount_mojo: amountMojo.toString(),
|
|
26
|
+
amount_xch: mojoToXch(amountMojo),
|
|
27
|
+
entity: known.entity,
|
|
28
|
+
label: known.label,
|
|
29
|
+
category: known.category,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
puzzle_hash: puzzleHash,
|
|
34
|
+
address,
|
|
35
|
+
amount_mojo: amountMojo.toString(),
|
|
36
|
+
amount_xch: mojoToXch(amountMojo),
|
|
37
|
+
entity: null,
|
|
38
|
+
label: null,
|
|
39
|
+
category: 'unknown',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export async function getWalletSpends(agent, wallet, options = {}) {
|
|
43
|
+
if (!isPopulated(wallet))
|
|
44
|
+
return [];
|
|
45
|
+
const ownPuzzleHashes = new Set(wallet.puzzleHashes.map((ph) => ph.toLowerCase()));
|
|
46
|
+
const recordGroups = await Promise.all(wallet.puzzleHashes.map((ph) => fetchCoinRecordsByPuzzleHash(agent, ph, {
|
|
47
|
+
includeSpent: true,
|
|
48
|
+
...(options.sinceHeight !== undefined ? { startHeight: options.sinceHeight } : {}),
|
|
49
|
+
})));
|
|
50
|
+
const records = recordGroups.flat();
|
|
51
|
+
const spent = records.filter((r) => r.spent_block_index > 0);
|
|
52
|
+
if (spent.length === 0)
|
|
53
|
+
return [];
|
|
54
|
+
const parentByName = new Map();
|
|
55
|
+
for (const r of spent) {
|
|
56
|
+
const name = coinName({
|
|
57
|
+
parent_coin_info: r.coin.parent_coin_info,
|
|
58
|
+
puzzle_hash: r.coin.puzzle_hash,
|
|
59
|
+
amount: toBigInt(r.coin.amount),
|
|
60
|
+
});
|
|
61
|
+
parentByName.set(name, r);
|
|
62
|
+
}
|
|
63
|
+
const children = await fetchCoinRecordsByParentIds(agent, [...parentByName.keys()], {
|
|
64
|
+
includeSpent: true,
|
|
65
|
+
});
|
|
66
|
+
const childrenByParent = new Map();
|
|
67
|
+
for (const child of children) {
|
|
68
|
+
const key = child.coin.parent_coin_info.toLowerCase().replace(/^0x/, '');
|
|
69
|
+
const list = childrenByParent.get(key) ?? [];
|
|
70
|
+
list.push(child);
|
|
71
|
+
childrenByParent.set(key, list);
|
|
72
|
+
}
|
|
73
|
+
const out = [];
|
|
74
|
+
for (const [parentName, parent] of parentByName) {
|
|
75
|
+
const childCoins = childrenByParent.get(parentName) ?? [];
|
|
76
|
+
// Filter out children that land back on one of *this* wallet's own puzzle hashes:
|
|
77
|
+
// those are singleton bookkeeping (e.g. the singleton recreating itself, or
|
|
78
|
+
// moving between a wallet's primary p2 and its clawback intermediate). Children
|
|
79
|
+
// landing on a different prefarm wallet are real inter-custody rotations.
|
|
80
|
+
const meaningful = childCoins.filter((c) => {
|
|
81
|
+
const ph = c.coin.puzzle_hash.toLowerCase().replace(/^0x/, '');
|
|
82
|
+
return !ownPuzzleHashes.has(ph);
|
|
83
|
+
});
|
|
84
|
+
if (meaningful.length === 0)
|
|
85
|
+
continue;
|
|
86
|
+
const destinations = meaningful.map((c) => {
|
|
87
|
+
const ph = c.coin.puzzle_hash.toLowerCase().replace(/^0x/, '');
|
|
88
|
+
const addr = puzzleHashToAddress(ph, 'mainnet');
|
|
89
|
+
return labelDestination(ph, addr, toBigInt(c.coin.amount));
|
|
90
|
+
});
|
|
91
|
+
const outflow = destinations
|
|
92
|
+
.filter((d) => d.category !== 'internal-rotation')
|
|
93
|
+
.reduce((acc, d) => acc + BigInt(d.amount_mojo), 0n);
|
|
94
|
+
const sourcePh = parent.coin.puzzle_hash.toLowerCase().replace(/^0x/, '');
|
|
95
|
+
out.push({
|
|
96
|
+
wallet_id: wallet.id,
|
|
97
|
+
source_puzzle_hash: sourcePh,
|
|
98
|
+
source_address: puzzleHashToAddress(sourcePh, 'mainnet'),
|
|
99
|
+
parent_coin_name: parentName,
|
|
100
|
+
spent_amount_mojo: toBigInt(parent.coin.amount).toString(),
|
|
101
|
+
spent_amount_xch: mojoToXch(toBigInt(parent.coin.amount)),
|
|
102
|
+
spent_height: parent.spent_block_index,
|
|
103
|
+
confirmed_height: parent.confirmed_block_index,
|
|
104
|
+
timestamp: Number(parent.timestamp),
|
|
105
|
+
destinations,
|
|
106
|
+
outflow_mojo: outflow.toString(),
|
|
107
|
+
outflow_xch: mojoToXch(outflow),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
out.sort((a, b) => b.spent_height - a.spent_height);
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=spends.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spends.js","sourceRoot":"","sources":["../../src/prefarm/spends.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAEL,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAGL,WAAW,EACX,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AA4BvB,SAAS,gBAAgB,CACvB,UAAkB,EAClB,OAAe,EACf,UAAkB;IAElB,MAAM,QAAQ,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACjD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO;YACL,WAAW,EAAE,UAAU;YACvB,OAAO;YACP,WAAW,EAAE,UAAU,CAAC,QAAQ,EAAE;YAClC,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC;YACjC,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,QAAQ,EAAE,mBAAmB;YAC7B,kBAAkB,EAAE,QAAQ,CAAC,EAAE;SAChC,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC5C,IAAI,KAAK,EAAE,CAAC;QACV,OAAO;YACL,WAAW,EAAE,UAAU;YACvB,OAAO;YACP,WAAW,EAAE,UAAU,CAAC,QAAQ,EAAE;YAClC,UAAU,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AAQ;YAC5B,cAAc,EAAE,mBAAmB,CAAC,QAAQ,EAAE,SAAS,CAAC;YACxD,gBAAgB,EAAE,UAAU;YAC5B,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;YAC1D,gBAAgB,EAAE,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACzD,YAAY,EAAE,MAAM,CAAC,iBAAiB;YACtC,gBAAgB,EAAE,MAAM,CAAC,qBAAqB;YAC9C,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;YACnC,YAAY;YACZ,YAAY,EAAE,OAAO,CAAC,QAAQ,EAAE;YAChC,WAAW,EAAE,SAAS,CAAC,OAAO,CAAC;SAChC,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC;IACpD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function register(server) {
|
|
2
|
+
server.registerPrompt('prefarm_summary', {
|
|
3
|
+
title: 'Chia strategic-reserve summary',
|
|
4
|
+
description: 'Summarise the Chia strategic reserve: how much pre-farm has been spent, how much remains, and where it has gone.',
|
|
5
|
+
argsSchema: {},
|
|
6
|
+
}, () => {
|
|
7
|
+
const text = [
|
|
8
|
+
`Summarise the state of the Chia strategic reserve (the 21M XCH pre-farm).`,
|
|
9
|
+
``,
|
|
10
|
+
`Steps:`,
|
|
11
|
+
`1. Call \`get_prefarm_status\` to get headline numbers and per-wallet balances.`,
|
|
12
|
+
`2. Call \`get_prefarm_spends\` with \`limit: 10\` to get the most recent outflows.`,
|
|
13
|
+
`3. Call \`get_xch_price\` to convert spent and remaining amounts to USD.`,
|
|
14
|
+
``,
|
|
15
|
+
`Present, in this order:`,
|
|
16
|
+
`- Total spent vs remaining as both XCH and USD, with the percentage of the 21M reserve spent so far. If some wallets are pending population, say so explicitly and base the percentage only on tracked wallets.`,
|
|
17
|
+
`- Per-wallet breakdown: id, balance in XCH, percent of its allocation spent. Skip wallets marked \`pending\`.`,
|
|
18
|
+
`- Last few outflows: height, amount in XCH, destination label (or "unknown" if unlabelled). Skip internal rotations between custody wallets.`,
|
|
19
|
+
``,
|
|
20
|
+
`Keep it tight. Plain prose, no tables unless asked.`,
|
|
21
|
+
].join('\n');
|
|
22
|
+
return {
|
|
23
|
+
messages: [{ role: 'user', content: { type: 'text', text } }],
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=prefarm-summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefarm-summary.js","sourceRoot":"","sources":["../../src/prompts/prefarm-summary.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,cAAc,CACnB,iBAAiB,EACjB;QACE,KAAK,EAAE,gCAAgC;QACvC,WAAW,EACT,kHAAkH;QACpH,UAAU,EAAE,EAAE;KACf,EACD,GAAG,EAAE;QACH,MAAM,IAAI,GAAG;YACX,2EAA2E;YAC3E,EAAE;YACF,QAAQ;YACR,iFAAiF;YACjF,oFAAoF;YACpF,0EAA0E;YAC1E,EAAE;YACF,yBAAyB;YACzB,iNAAiN;YACjN,+GAA+G;YAC/G,8IAA8I;YAC9I,EAAE;YACF,qDAAqD;SACtD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,OAAO;YACL,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;SAC9D,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -6,17 +6,24 @@ import { register as registerGetPeakHeight } from './tools/blockchain/get-peak-h
|
|
|
6
6
|
import { register as registerGetBlockByHeight } from './tools/blockchain/get-block-by-height.js';
|
|
7
7
|
import { register as registerGetBlockByHash } from './tools/blockchain/get-block-by-hash.js';
|
|
8
8
|
import { register as registerCountBlockTransactions } from './tools/blockchain/count-block-transactions.js';
|
|
9
|
+
import { register as registerGetBlockAdditionsAndRemovals } from './tools/blockchain/get-block-additions-and-removals.js';
|
|
9
10
|
import { register as registerGetBalance } from './tools/coins/get-balance.js';
|
|
10
11
|
import { register as registerGetCoinRecordsByPuzzleHash } from './tools/coins/get-coin-records-by-puzzle-hash.js';
|
|
12
|
+
import { register as registerGetCoinRecordsByParentIds } from './tools/coins/get-coin-records-by-parent-ids.js';
|
|
11
13
|
import { register as registerGetCoinByName } from './tools/coins/get-coin-by-name.js';
|
|
12
14
|
import { register as registerCalculateCoinName } from './tools/coins/calculate-coin-name.js';
|
|
15
|
+
import { register as registerGetPuzzleAndSolution } from './tools/coins/get-puzzle-and-solution.js';
|
|
13
16
|
import { register as registerAddressToPuzzleHash } from './tools/addresses/address-to-puzzle-hash.js';
|
|
14
17
|
import { register as registerPuzzleHashToAddress } from './tools/addresses/puzzle-hash-to-address.js';
|
|
15
18
|
import { register as registerGetXchPrice } from './tools/price/get-xch-price.js';
|
|
16
19
|
import { register as registerConvertXchToFiat } from './tools/price/convert-xch-to-fiat.js';
|
|
20
|
+
import { register as registerGetPrefarmStatus } from './tools/prefarm/get-prefarm-status.js';
|
|
21
|
+
import { register as registerGetPrefarmSpends } from './tools/prefarm/get-prefarm-spends.js';
|
|
22
|
+
import { register as registerListPrefarmAddresses } from './tools/prefarm/list-prefarm-addresses.js';
|
|
17
23
|
import { register as registerNetworkStatusPrompt } from './prompts/network-status.js';
|
|
18
24
|
import { register as registerAddressSummaryPrompt } from './prompts/address-summary.js';
|
|
19
25
|
import { register as registerBlockSummaryPrompt } from './prompts/block-summary.js';
|
|
26
|
+
import { register as registerPrefarmSummaryPrompt } from './prompts/prefarm-summary.js';
|
|
20
27
|
export function createServer() {
|
|
21
28
|
const server = new McpServer({ name: 'chia-explorer', version: VERSION }, {
|
|
22
29
|
instructions: 'chia-explorer answers questions about the Chia blockchain via the public coinset.org API, ' +
|
|
@@ -32,17 +39,24 @@ export function createServer() {
|
|
|
32
39
|
registerGetBlockByHeight(server);
|
|
33
40
|
registerGetBlockByHash(server);
|
|
34
41
|
registerCountBlockTransactions(server);
|
|
42
|
+
registerGetBlockAdditionsAndRemovals(server);
|
|
35
43
|
registerGetBalance(server);
|
|
36
44
|
registerGetCoinRecordsByPuzzleHash(server);
|
|
45
|
+
registerGetCoinRecordsByParentIds(server);
|
|
37
46
|
registerGetCoinByName(server);
|
|
38
47
|
registerCalculateCoinName(server);
|
|
48
|
+
registerGetPuzzleAndSolution(server);
|
|
39
49
|
registerAddressToPuzzleHash(server);
|
|
40
50
|
registerPuzzleHashToAddress(server);
|
|
41
51
|
registerGetXchPrice(server);
|
|
42
52
|
registerConvertXchToFiat(server);
|
|
53
|
+
registerGetPrefarmStatus(server);
|
|
54
|
+
registerGetPrefarmSpends(server);
|
|
55
|
+
registerListPrefarmAddresses(server);
|
|
43
56
|
registerNetworkStatusPrompt(server);
|
|
44
57
|
registerAddressSummaryPrompt(server);
|
|
45
58
|
registerBlockSummaryPrompt(server);
|
|
59
|
+
registerPrefarmSummaryPrompt(server);
|
|
46
60
|
return server;
|
|
47
61
|
}
|
|
48
62
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,QAAQ,IAAI,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AACpG,OAAO,EAAE,QAAQ,IAAI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M,CAAC,CAAC;IACjC,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC/B,8BAA8B,CAAC,MAAM,CAAC,CAAC;IACvC,oCAAoC,CAAC,MAAM,CAAC,CAAC;IAE7C,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC3B,kCAAkC,CAAC,MAAM,CAAC,CAAC;IAC3C,iCAAiC,CAAC,MAAM,CAAC,CAAC;IAC1C,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC9B,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAClC,4BAA4B,CAAC,MAAM,CAAC,CAAC;IAErC,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACpC,2BAA2B,CAAC,MAAM,CAAC,CAAC;IAEpC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC5B,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAEjC,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACjC,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACjC,4BAA4B,CAAC,MAAM,CAAC,CAAC;IAErC,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACpC,4BAA4B,CAAC,MAAM,CAAC,CAAC;IACrC,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACnC,4BAA4B,CAAC,MAAM,CAAC,CAAC;IAErC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { get_additions_and_removals, get_block_record_by_height, } from 'chia-agent/api/rpc/full_node/index.js';
|
|
3
|
+
import { getAgent } from '../../coinset/agent.js';
|
|
4
|
+
import { hex32Schema, heightSchema, networkSchema } from '../../schemas/common.js';
|
|
5
|
+
import { stripHexPrefix } from '../../chia/hex.js';
|
|
6
|
+
import { errorText, jsonText } from '../shared/response.js';
|
|
7
|
+
export function register(server) {
|
|
8
|
+
server.tool('get_block_additions_and_removals', 'List every coin created (additions) and destroyed (removals) in a single block. Pass either height OR header_hash. Use this when a singleton control coin and funds coin spend together — direct parent-id lookup misses the funds child but this tool surfaces it.', {
|
|
9
|
+
height: heightSchema.optional(),
|
|
10
|
+
header_hash: hex32Schema.optional(),
|
|
11
|
+
network: networkSchema,
|
|
12
|
+
}, async ({ height, header_hash, network }) => {
|
|
13
|
+
try {
|
|
14
|
+
if (height === undefined && header_hash === undefined) {
|
|
15
|
+
throw new Error('provide either height or header_hash');
|
|
16
|
+
}
|
|
17
|
+
if (height !== undefined && header_hash !== undefined) {
|
|
18
|
+
throw new Error('provide only one of height or header_hash, not both');
|
|
19
|
+
}
|
|
20
|
+
const agent = getAgent(network);
|
|
21
|
+
let resolvedHash;
|
|
22
|
+
let resolvedHeight = null;
|
|
23
|
+
if (header_hash !== undefined) {
|
|
24
|
+
resolvedHash = stripHexPrefix(header_hash).toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const rec = await get_block_record_by_height(agent, { height: height });
|
|
28
|
+
if (!rec.block_record)
|
|
29
|
+
throw new Error(`no block record at height ${height}`);
|
|
30
|
+
resolvedHash = rec.block_record.header_hash;
|
|
31
|
+
resolvedHeight = rec.block_record.height;
|
|
32
|
+
}
|
|
33
|
+
const res = await get_additions_and_removals(agent, { header_hash: resolvedHash });
|
|
34
|
+
const additions = res.additions ?? [];
|
|
35
|
+
const removals = res.removals ?? [];
|
|
36
|
+
return jsonText({
|
|
37
|
+
network,
|
|
38
|
+
height: resolvedHeight,
|
|
39
|
+
header_hash: resolvedHash,
|
|
40
|
+
additions_count: additions.length,
|
|
41
|
+
removals_count: removals.length,
|
|
42
|
+
additions,
|
|
43
|
+
removals,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
return errorText(err);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
void z;
|
|
52
|
+
//# sourceMappingURL=get-block-additions-and-removals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-block-additions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,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,GAAG,MAAM,0BAA0B,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAgB,EAAE,CAAC,CAAC;gBAClF,IAAI,CAAC,GAAG,CAAC,YAAY;oBAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,MAAO,EAAE,CAAC,CAAC;gBAC/E,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC,WAAW,CAAC;gBAC5C,cAAc,GAAG,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC;YAC3C,CAAC;YACD,MAAM,GAAG,GAAG,MAAM,0BAA0B,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,CAAC;YACnF,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC;YACtC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC;YACpC,OAAO,QAAQ,CAAC;gBACd,OAAO;gBACP,MAAM,EAAE,cAAc;gBACtB,WAAW,EAAE,YAAY;gBACzB,eAAe,EAAE,SAAS,CAAC,MAAM;gBACjC,cAAc,EAAE,QAAQ,CAAC,MAAM;gBAC/B,SAAS;gBACT,QAAQ;aACT,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getAgent } from '../../coinset/agent.js';
|
|
3
|
+
import { fetchCoinRecordsByParentIds } from '../../coinset/pagination.js';
|
|
4
|
+
import { hex32Schema, networkSchema } from '../../schemas/common.js';
|
|
5
|
+
import { stripHexPrefix } from '../../chia/hex.js';
|
|
6
|
+
import { errorText, jsonText } from '../shared/response.js';
|
|
7
|
+
export function register(server) {
|
|
8
|
+
server.tool('get_coin_records_by_parent_ids', 'Return raw coin records for the given parent coin names. Use this to find the children produced by spending a coin. include_spent_coins defaults to true.', {
|
|
9
|
+
parent_ids: z
|
|
10
|
+
.array(hex32Schema)
|
|
11
|
+
.min(1)
|
|
12
|
+
.max(1000)
|
|
13
|
+
.describe('32-byte coin names (parent ids), 0x-prefixed or bare hex'),
|
|
14
|
+
include_spent_coins: z.boolean().optional().describe('Include spent children (default true)'),
|
|
15
|
+
start_height: z.number().int().nonnegative().optional(),
|
|
16
|
+
end_height: z.number().int().nonnegative().optional(),
|
|
17
|
+
network: networkSchema,
|
|
18
|
+
}, async ({ parent_ids, include_spent_coins, start_height, end_height, network }) => {
|
|
19
|
+
try {
|
|
20
|
+
const agent = getAgent(network);
|
|
21
|
+
const normalized = parent_ids.map((id) => stripHexPrefix(id).toLowerCase());
|
|
22
|
+
const records = await fetchCoinRecordsByParentIds(agent, normalized, {
|
|
23
|
+
includeSpent: include_spent_coins ?? true,
|
|
24
|
+
...(start_height !== undefined ? { startHeight: start_height } : {}),
|
|
25
|
+
...(end_height !== undefined ? { endHeight: end_height } : {}),
|
|
26
|
+
});
|
|
27
|
+
return jsonText({
|
|
28
|
+
network,
|
|
29
|
+
parent_ids: normalized,
|
|
30
|
+
parent_count: normalized.length,
|
|
31
|
+
coin_count: records.length,
|
|
32
|
+
coin_records: records,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
return errorText(err);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=get-coin-records-by-parent-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-coin-records-by-parent-ids.js","sourceRoot":"","sources":["../../../src/tools/coins/get-coin-records-by-parent-ids.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACl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Y,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpE,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC/D,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC;gBACd,OAAO;gBACP,UAAU,EAAE,UAAU;gBACtB,YAAY,EAAE,UAAU,CAAC,MAAM;gBAC/B,UAAU,EAAE,OAAO,CAAC,MAAM;gBAC1B,YAAY,EAAE,OAAO;aACtB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { get_puzzle_and_solution } from 'chia-agent/api/rpc/full_node/index.js';
|
|
2
|
+
import { getAgent } from '../../coinset/agent.js';
|
|
3
|
+
import { hex32Schema, heightSchema, networkSchema } from '../../schemas/common.js';
|
|
4
|
+
import { stripHexPrefix } from '../../chia/hex.js';
|
|
5
|
+
import { errorText, jsonText } from '../shared/response.js';
|
|
6
|
+
export function register(server) {
|
|
7
|
+
server.tool('get_puzzle_and_solution', 'Fetch the CLVM puzzle reveal and solution for a coin at its spent block height. Reveals what a spend actually did — required for decoding singleton state transitions.', {
|
|
8
|
+
coin_id: hex32Schema.describe('32-byte coin name'),
|
|
9
|
+
height: heightSchema.describe('The spent_block_index of the coin (the block where the coin was spent)'),
|
|
10
|
+
network: networkSchema,
|
|
11
|
+
}, async ({ coin_id, height, network }) => {
|
|
12
|
+
try {
|
|
13
|
+
const agent = getAgent(network);
|
|
14
|
+
const normalized = stripHexPrefix(coin_id).toLowerCase();
|
|
15
|
+
const res = await get_puzzle_and_solution(agent, {
|
|
16
|
+
coin_id: normalized,
|
|
17
|
+
height,
|
|
18
|
+
});
|
|
19
|
+
return jsonText({
|
|
20
|
+
network,
|
|
21
|
+
coin_id: normalized,
|
|
22
|
+
height,
|
|
23
|
+
coin_solution: res.coin_solution,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
return errorText(err);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=get-puzzle-and-solution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-puzzle-and-solution.js","sourceRoot":"","sources":["../../../src/tools/coins/get-puzzle-and-solution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,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,yBAAyB,EACzB,wKAAwK,EACxK;QACE,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QAClD,MAAM,EAAE,YAAY,CAAC,QAAQ,CAC3B,wEAAwE,CACzE;QACD,OAAO,EAAE,aAAa;KACvB,EACD,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;QACrC,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAkB,CAAC,CAAC;YAC3C,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;YACzD,MAAM,GAAG,GAAG,MAAM,uBAAuB,CAAC,KAAK,EAAE;gBAC/C,OAAO,EAAE,UAAU;gBACnB,MAAM;aACP,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC;gBACd,OAAO;gBACP,OAAO,EAAE,UAAU;gBACnB,MAAM;gBACN,aAAa,EAAE,GAAG,CAAC,aAAa;aACjC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { mojoToXch } from '../../chia/amounts.js';
|
|
3
|
+
import { getAgent } from '../../coinset/agent.js';
|
|
4
|
+
import { PREFARM_WALLETS, getWalletById, isPopulated } from '../../prefarm/registry.js';
|
|
5
|
+
import { getWalletSpends } from '../../prefarm/spends.js';
|
|
6
|
+
import { errorText, jsonText } from '../shared/response.js';
|
|
7
|
+
const WALLET_IDS = [
|
|
8
|
+
'us-cold',
|
|
9
|
+
'us-warm',
|
|
10
|
+
'ch-cold',
|
|
11
|
+
'ch-warm',
|
|
12
|
+
];
|
|
13
|
+
export function register(server) {
|
|
14
|
+
server.tool('get_prefarm_spends', 'List outflows from the Chia strategic reserve. For each spent coin: the source wallet, the destination addresses (labelled when they map to a known partner / market maker / exchange), and amounts. Internal rotations between custody wallets are flagged and excluded from total outflow. Mainnet only.', {
|
|
15
|
+
wallet_id: z
|
|
16
|
+
.enum(WALLET_IDS)
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('Restrict to one wallet. Omit to query all four.'),
|
|
19
|
+
limit: z
|
|
20
|
+
.number()
|
|
21
|
+
.int()
|
|
22
|
+
.positive()
|
|
23
|
+
.max(500)
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('Maximum spends to return, sorted newest first. Default 50.'),
|
|
26
|
+
since_height: z
|
|
27
|
+
.number()
|
|
28
|
+
.int()
|
|
29
|
+
.nonnegative()
|
|
30
|
+
.optional()
|
|
31
|
+
.describe('Only include spends at or after this block height.'),
|
|
32
|
+
}, async ({ wallet_id, limit, since_height }) => {
|
|
33
|
+
try {
|
|
34
|
+
const targets = wallet_id
|
|
35
|
+
? (() => {
|
|
36
|
+
const w = getWalletById(wallet_id);
|
|
37
|
+
if (!w)
|
|
38
|
+
throw new Error(`unknown wallet_id: ${wallet_id}`);
|
|
39
|
+
return [w];
|
|
40
|
+
})()
|
|
41
|
+
: [...PREFARM_WALLETS];
|
|
42
|
+
const populated = targets.filter(isPopulated);
|
|
43
|
+
const pending = targets.filter((w) => !isPopulated(w)).map((w) => w.id);
|
|
44
|
+
const agent = getAgent('mainnet');
|
|
45
|
+
const grouped = await Promise.all(populated.map((w) => getWalletSpends(agent, w, {
|
|
46
|
+
...(since_height !== undefined ? { sinceHeight: since_height } : {}),
|
|
47
|
+
})));
|
|
48
|
+
const all = grouped.flat();
|
|
49
|
+
all.sort((a, b) => b.spent_height - a.spent_height);
|
|
50
|
+
const cap = limit ?? 50;
|
|
51
|
+
const trimmed = all.slice(0, cap);
|
|
52
|
+
const totalOutflow = all.reduce((acc, s) => acc + BigInt(s.outflow_mojo), 0n);
|
|
53
|
+
return jsonText({
|
|
54
|
+
spends: trimmed,
|
|
55
|
+
total_spend_count: all.length,
|
|
56
|
+
returned_count: trimmed.length,
|
|
57
|
+
total_outflow_mojo: totalOutflow.toString(),
|
|
58
|
+
total_outflow_xch: mojoToXch(totalOutflow),
|
|
59
|
+
wallets_queried: populated.map((w) => w.id),
|
|
60
|
+
wallets_pending: pending,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
return errorText(err);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=get-prefarm-spends.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-prefarm-spends.js","sourceRoot":"","sources":["../../../src/tools/prefarm/get-prefarm-spends.ts"],"names":[],"mappings":"AACA,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E,GAAG,CAAC,MAAM;gBAC7B,cAAc,EAAE,OAAO,CAAC,MAAM;gBAC9B,kBAAkB,EAAE,YAAY,CAAC,QAAQ,EAAE;gBAC3C,iBAAiB,EAAE,SAAS,CAAC,YAAY,CAAC;gBAC1C,eAAe,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3C,eAAe,EAAE,OAAO;aACzB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { mojoToXch, toBigInt } from '../../chia/amounts.js';
|
|
2
|
+
import { getAgent } from '../../coinset/agent.js';
|
|
3
|
+
import { fetchCoinRecordsByPuzzleHash } from '../../coinset/pagination.js';
|
|
4
|
+
import { PREFARM_WALLETS, TOTAL_PREFARM_ALLOCATION_MOJO, isPopulated, } from '../../prefarm/registry.js';
|
|
5
|
+
import { errorText, jsonText } from '../shared/response.js';
|
|
6
|
+
async function statusForWallet(wallet) {
|
|
7
|
+
const base = {
|
|
8
|
+
id: wallet.id,
|
|
9
|
+
label: wallet.label,
|
|
10
|
+
region: wallet.region,
|
|
11
|
+
temperature: wallet.temperature,
|
|
12
|
+
addresses: wallet.addresses,
|
|
13
|
+
puzzle_hashes: wallet.puzzleHashes,
|
|
14
|
+
};
|
|
15
|
+
if (!isPopulated(wallet)) {
|
|
16
|
+
return {
|
|
17
|
+
...base,
|
|
18
|
+
balance_mojo: null,
|
|
19
|
+
balance_xch: null,
|
|
20
|
+
unspent_coin_count: null,
|
|
21
|
+
pending: true,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const agent = getAgent('mainnet');
|
|
25
|
+
const groups = await Promise.all(wallet.puzzleHashes.map((ph) => fetchCoinRecordsByPuzzleHash(agent, ph, { includeSpent: false })));
|
|
26
|
+
let balance = 0n;
|
|
27
|
+
let coinCount = 0;
|
|
28
|
+
for (const records of groups) {
|
|
29
|
+
coinCount += records.length;
|
|
30
|
+
for (const r of records)
|
|
31
|
+
balance += toBigInt(r.coin.amount);
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
...base,
|
|
35
|
+
balance_mojo: balance.toString(),
|
|
36
|
+
balance_xch: mojoToXch(balance),
|
|
37
|
+
unspent_coin_count: coinCount,
|
|
38
|
+
pending: false,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function register(server) {
|
|
42
|
+
server.tool('get_prefarm_status', 'Aggregate status of the Chia strategic reserve (21M XCH across four custody wallets: US/CH × cold/warm). Per-wallet balances are read live from coinset.org; the only hardcoded amount is the 21M XCH genesis total. Mainnet only.', {}, async () => {
|
|
43
|
+
try {
|
|
44
|
+
const wallets = await Promise.all(PREFARM_WALLETS.map(statusForWallet));
|
|
45
|
+
const trackedBalance = wallets
|
|
46
|
+
.filter((w) => !w.pending)
|
|
47
|
+
.reduce((acc, w) => acc + BigInt(w.balance_mojo ?? '0'), 0n);
|
|
48
|
+
const walletsPending = wallets.filter((w) => w.pending).length;
|
|
49
|
+
const totalAllocation = TOTAL_PREFARM_ALLOCATION_MOJO;
|
|
50
|
+
const trackedSpent = totalAllocation - trackedBalance;
|
|
51
|
+
const spentPct = walletsPending > 0 ? null : Number((trackedSpent * 10000n) / totalAllocation) / 100;
|
|
52
|
+
return jsonText({
|
|
53
|
+
wallets,
|
|
54
|
+
totals: {
|
|
55
|
+
allocation_mojo: totalAllocation.toString(),
|
|
56
|
+
allocation_xch: mojoToXch(totalAllocation),
|
|
57
|
+
tracked_balance_mojo: trackedBalance.toString(),
|
|
58
|
+
tracked_balance_xch: mojoToXch(trackedBalance),
|
|
59
|
+
tracked_spent_mojo: trackedSpent.toString(),
|
|
60
|
+
tracked_spent_xch: mojoToXch(trackedSpent),
|
|
61
|
+
tracked_spent_pct: spentPct,
|
|
62
|
+
},
|
|
63
|
+
wallets_configured: wallets.filter((w) => !w.pending).length,
|
|
64
|
+
wallets_pending: walletsPending,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
return errorText(err);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=get-prefarm-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-prefarm-status.js","sourceRoot":"","sources":["../../../src/tools/prefarm/get-prefarm-status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EACL,eAAe,EAEf,6BAA6B,EAC7B,WAAW,GACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAe5D,KAAK,UAAU,eAAe,CAAC,MAAqB;IAClD,MAAM,IAAI,GAAG;QACX,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,aAAa,EAAE,MAAM,CAAC,YAAY;KACnC,CAAC;IACF,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,OAAO;YACL,GAAG,IAAI;YACP,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,IAAI;YACjB,kBAAkB,EAAE,IAAI;YACxB,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAClC,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AC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;YAC/D,MAAM,eAAe,GAAG,6BAA6B,CAAC;YACtD,MAAM,YAAY,GAAG,eAAe,GAAG,cAAc,CAAC;YACtD,MAAM,QAAQ,GACZ,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,YAAY,GAAG,MAAM,CAAC,GAAG,eAAe,CAAC,GAAG,GAAG,CAAC;YAEtF,OAAO,QAAQ,CAAC;gBACd,OAAO;gBACP,MAAM,EAAE;oBACN,eAAe,EAAE,eAAe,CAAC,QAAQ,EAAE;oBAC3C,cAAc,EAAE,SAAS,CAAC,eAAe,CAAC;oBAC1C,oBAAoB,EAAE,cAAc,CAAC,QAAQ,EAAE;oBAC/C,mBAAmB,EAAE,SAAS,CAAC,cAAc,CAAC;oBAC9C,kBAAkB,EAAE,YAAY,CAAC,QAAQ,EAAE;oBAC3C,iBAAiB,EAAE,SAAS,CAAC,YAAY,CAAC;oBAC1C,iBAAiB,EAAE,QAAQ;iBAC5B;gBACD,kBAAkB,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM;gBAC5D,eAAe,EAAE,cAAc;aAChC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { mojoToXch } from '../../chia/amounts.js';
|
|
2
|
+
import { KNOWN_DESTINATIONS, PREFARM_WALLETS, TOTAL_PREFARM_ALLOCATION_MOJO, } from '../../prefarm/registry.js';
|
|
3
|
+
import { jsonText } from '../shared/response.js';
|
|
4
|
+
export function register(server) {
|
|
5
|
+
server.tool('list_prefarm_addresses', 'Return the hardcoded registry of Chia strategic-reserve custody wallets and labelled destination addresses (partners, market makers, exchanges). Identities only — balances are not returned here; call `get_prefarm_status` for live amounts. Pure local data, no network call.', {}, async () => {
|
|
6
|
+
const wallets = PREFARM_WALLETS.map((w) => ({
|
|
7
|
+
id: w.id,
|
|
8
|
+
label: w.label,
|
|
9
|
+
region: w.region,
|
|
10
|
+
temperature: w.temperature,
|
|
11
|
+
addresses: w.addresses,
|
|
12
|
+
puzzle_hashes: w.puzzleHashes,
|
|
13
|
+
pending: w.addresses.length === 0,
|
|
14
|
+
}));
|
|
15
|
+
const destinations = KNOWN_DESTINATIONS.map((d) => ({
|
|
16
|
+
address: d.address,
|
|
17
|
+
puzzle_hash: d.puzzleHash,
|
|
18
|
+
entity: d.entity,
|
|
19
|
+
label: d.label,
|
|
20
|
+
category: d.category,
|
|
21
|
+
}));
|
|
22
|
+
return jsonText({
|
|
23
|
+
wallets,
|
|
24
|
+
destinations,
|
|
25
|
+
total_allocation_mojo: TOTAL_PREFARM_ALLOCATION_MOJO.toString(),
|
|
26
|
+
total_allocation_xch: mojoToXch(TOTAL_PREFARM_ALLOCATION_MOJO),
|
|
27
|
+
wallets_configured: wallets.filter((w) => !w.pending).length,
|
|
28
|
+
wallets_pending: wallets.filter((w) => w.pending).length,
|
|
29
|
+
destinations_configured: destinations.length,
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=list-prefarm-addresses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-prefarm-addresses.js","sourceRoot":"","sources":["../../../src/tools/prefarm/list-prefarm-addresses.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,6BAA6B,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,MA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