@odatano/core-mcp 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 +178 -0
- package/README.md +180 -0
- package/dist/client.d.ts +60 -0
- package/dist/client.js +177 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +36 -0
- package/dist/config.js +40 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/output.d.ts +20 -0
- package/dist/output.js +45 -0
- package/dist/output.js.map +1 -0
- package/dist/schemas.d.ts +37 -0
- package/dist/schemas.js +76 -0
- package/dist/schemas.js.map +1 -0
- package/dist/server.d.ts +17 -0
- package/dist/server.js +27 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/build.d.ts +3 -0
- package/dist/tools/build.js +208 -0
- package/dist/tools/build.js.map +1 -0
- package/dist/tools/index.d.ts +11 -0
- package/dist/tools/index.js +23 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/indexer.d.ts +3 -0
- package/dist/tools/indexer.js +30 -0
- package/dist/tools/indexer.js.map +1 -0
- package/dist/tools/query.d.ts +12 -0
- package/dist/tools/query.js +98 -0
- package/dist/tools/query.js.map +1 -0
- package/dist/tools/read.d.ts +9 -0
- package/dist/tools/read.js +173 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/shared.d.ts +31 -0
- package/dist/tools/shared.js +42 -0
- package/dist/tools/shared.js.map +1 -0
- package/dist/tools/sign.d.ts +3 -0
- package/dist/tools/sign.js +120 -0
- package/dist/tools/sign.js.map +1 -0
- package/dist/tools/worker.d.ts +3 -0
- package/dist/tools/worker.js +60 -0
- package/dist/tools/worker.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { makeRunner } from './shared.js';
|
|
3
|
+
/*
|
|
4
|
+
* ODATANO v2.0 chain crawler / pre-sync (CardanoIndexerService). Status only;
|
|
5
|
+
* pauseCrawler / resumeCrawler are Admin operations and never exposed.
|
|
6
|
+
*/
|
|
7
|
+
export function registerIndexerTools(server, ctx) {
|
|
8
|
+
const { client, config } = ctx;
|
|
9
|
+
const run = makeRunner(ctx);
|
|
10
|
+
server.registerTool('get_sync_status', {
|
|
11
|
+
description: 'Chain crawler / pre-sync status on the host (ODATANO >= 2.0): running, syncStatus (idle / syncing / ' +
|
|
12
|
+
'synced / error), last indexed slot + height, chain tip height, syncProgress, consecutive errors. ' +
|
|
13
|
+
'When synced, query_entity over Blocks / Transactions answers from local data with no backend round-trip.',
|
|
14
|
+
inputSchema: {},
|
|
15
|
+
}, run(async () => client.callFunction('indexer', 'getStatus')));
|
|
16
|
+
server.registerTool('get_reorg_log', {
|
|
17
|
+
description: 'Recent chain reorganisations handled by the crawler (newest first): fork slot/height, blocks rolled ' +
|
|
18
|
+
'back, detected time. Empty when none occurred since the cursor start.',
|
|
19
|
+
inputSchema: {
|
|
20
|
+
limit: z.number().int().min(1).max(config.maxRows).optional().describe(`Max entries (default ${Math.min(20, config.maxRows)})`),
|
|
21
|
+
},
|
|
22
|
+
}, run(async (args) => {
|
|
23
|
+
const payload = (await client.queryEntity('indexer', 'ReorgLog', {
|
|
24
|
+
orderby: 'detectedAt desc',
|
|
25
|
+
top: args.limit ?? Math.min(20, config.maxRows),
|
|
26
|
+
}));
|
|
27
|
+
return Array.isArray(payload?.value) ? payload.value : payload;
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=indexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer.js","sourceRoot":"","sources":["../../src/tools/indexer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAoB,MAAM,aAAa,CAAC;AAE3D;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAiB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} from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { ServiceKey } from '../config.js';
|
|
3
|
+
import { type ToolContext } from './shared.js';
|
|
4
|
+
/** Read-only entities an agent may query, mapped to the service that serves them. */
|
|
5
|
+
export declare const ENTITY_SERVICE: Record<string, ServiceKey>;
|
|
6
|
+
/** v2.0 entities, only offered when the capability probe found the service. */
|
|
7
|
+
export declare const V2_ENTITY_SERVICE: Record<string, ServiceKey>;
|
|
8
|
+
export interface QueryCapabilities {
|
|
9
|
+
worker: boolean;
|
|
10
|
+
indexer: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function registerQueryTools(server: McpServer, ctx: ToolContext, caps: QueryCapabilities): void;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { makeRunner } from './shared.js';
|
|
3
|
+
/** Read-only entities an agent may query, mapped to the service that serves them. */
|
|
4
|
+
export const ENTITY_SERVICE = {
|
|
5
|
+
// CardanoODataService — the indexer cache (populated by Get* reads and by the v2.0 crawler)
|
|
6
|
+
NetworkInformation: 'odata',
|
|
7
|
+
Blocks: 'odata',
|
|
8
|
+
Epochs: 'odata',
|
|
9
|
+
Pools: 'odata',
|
|
10
|
+
Dreps: 'odata',
|
|
11
|
+
Assets: 'odata',
|
|
12
|
+
AssetHistory: 'odata',
|
|
13
|
+
Transactions: 'odata',
|
|
14
|
+
TransactionInputs: 'odata',
|
|
15
|
+
TransactionOutputs: 'odata',
|
|
16
|
+
TransactionInputAssets: 'odata',
|
|
17
|
+
TransactionOutputAssets: 'odata',
|
|
18
|
+
TransactionMetadata: 'odata',
|
|
19
|
+
Accounts: 'odata',
|
|
20
|
+
Addresses: 'odata',
|
|
21
|
+
AddressAssets: 'odata',
|
|
22
|
+
AddressUTxOs: 'odata',
|
|
23
|
+
AddressTransactions: 'odata',
|
|
24
|
+
UTxOAssets: 'odata',
|
|
25
|
+
LedgerProtocolParameters: 'odata',
|
|
26
|
+
// CardanoTransactionService — build / submission audit trail
|
|
27
|
+
TransactionBuilds: 'transaction',
|
|
28
|
+
TransactionBuildInputs: 'transaction',
|
|
29
|
+
TransactionBuildOutputs: 'transaction',
|
|
30
|
+
TransactionBuildInputAssets: 'transaction',
|
|
31
|
+
TransactionBuildOutputAssets: 'transaction',
|
|
32
|
+
TransactionSubmissions: 'transaction',
|
|
33
|
+
TransactionSubmissionErrors: 'transaction',
|
|
34
|
+
AddressTransactionBuilds: 'transaction',
|
|
35
|
+
// CardanoSignService — signing workflow audit trail
|
|
36
|
+
SigningRequests: 'sign',
|
|
37
|
+
SignatureVerifications: 'sign',
|
|
38
|
+
AddressSigningRequests: 'sign',
|
|
39
|
+
};
|
|
40
|
+
/** v2.0 entities, only offered when the capability probe found the service. */
|
|
41
|
+
export const V2_ENTITY_SERVICE = {
|
|
42
|
+
WalletJobs: 'worker',
|
|
43
|
+
WorkerWallets: 'worker',
|
|
44
|
+
SyncState: 'indexer',
|
|
45
|
+
ReorgLog: 'indexer',
|
|
46
|
+
};
|
|
47
|
+
export function registerQueryTools(server, ctx, caps) {
|
|
48
|
+
const { client, config } = ctx;
|
|
49
|
+
const run = makeRunner(ctx);
|
|
50
|
+
const entityMap = { ...ENTITY_SERVICE };
|
|
51
|
+
for (const [name, service] of Object.entries(V2_ENTITY_SERVICE)) {
|
|
52
|
+
if ((service === 'worker' && caps.worker) || (service === 'indexer' && caps.indexer)) {
|
|
53
|
+
entityMap[name] = service;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const entityNames = Object.keys(entityMap);
|
|
57
|
+
server.registerTool('query_entity', {
|
|
58
|
+
description: 'Generic OData V4 query over the ODATANO entity sets (the indexer cache: everything previously ' +
|
|
59
|
+
'fetched by the get_* tools, plus - on hosts with the v2.0 crawler - contiguously pre-synced blocks ' +
|
|
60
|
+
'and transactions). Standard OData syntax: $filter (e.g. "fee gt 500000 and blockHeight ge 1000000"), ' +
|
|
61
|
+
'$select, $expand (e.g. "inputs,outputs" on Transactions), $orderby, $top/$skip, $count. Numeric ' +
|
|
62
|
+
'Int64/Decimal fields are returned as strings (CAP 10). Read-only; write verbs are rejected upstream ' +
|
|
63
|
+
`with 405. Results are capped at ${config.maxRows} rows unless top is set lower; use skip to page. ` +
|
|
64
|
+
`Entities: ${entityNames.join(', ')}.`,
|
|
65
|
+
inputSchema: {
|
|
66
|
+
entity: z.enum(entityNames).describe('Entity set name'),
|
|
67
|
+
filter: z.string().max(4000).optional().describe('OData $filter expression'),
|
|
68
|
+
select: z.string().max(1000).optional().describe('Comma-separated $select list'),
|
|
69
|
+
expand: z.string().max(500).optional().describe('Comma-separated $expand list (compositions/associations)'),
|
|
70
|
+
orderby: z.string().max(500).optional().describe('$orderby, e.g. "blockHeight desc"'),
|
|
71
|
+
top: z.number().int().min(1).max(config.maxRows).optional()
|
|
72
|
+
.describe(`Max rows (1-${config.maxRows}, default ${config.maxRows})`),
|
|
73
|
+
skip: z.number().int().nonnegative().optional().describe('Rows to skip (paging)'),
|
|
74
|
+
count: z.boolean().optional().describe('Include the total match count as `count`'),
|
|
75
|
+
},
|
|
76
|
+
}, run(async (args) => {
|
|
77
|
+
const service = entityMap[args.entity];
|
|
78
|
+
const payload = (await client.queryEntity(service, args.entity, {
|
|
79
|
+
filter: args.filter,
|
|
80
|
+
select: args.select,
|
|
81
|
+
expand: args.expand,
|
|
82
|
+
orderby: args.orderby,
|
|
83
|
+
top: args.top ?? config.maxRows,
|
|
84
|
+
skip: args.skip,
|
|
85
|
+
count: args.count,
|
|
86
|
+
}));
|
|
87
|
+
// Collection responses are { value: [...] } (+ count when requested).
|
|
88
|
+
const rows = Array.isArray(payload?.value) ? payload.value : [];
|
|
89
|
+
return {
|
|
90
|
+
entity: args.entity,
|
|
91
|
+
service,
|
|
92
|
+
returned: rows.length,
|
|
93
|
+
...(payload?.count !== undefined ? { count: payload.count } : {}),
|
|
94
|
+
rows,
|
|
95
|
+
};
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
//# sour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,CAAC,CAA4B,CAAC;QAC/B,sEAAsE;QACtE,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAE,OAAO,CAAC,KAAmB,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/E,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO;YACP,QAAQ,EAAE,IAAI,CAAC,MAAM;YACrB,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjE,IAAI;SACL,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { type ToolContext } from './shared.js';
|
|
3
|
+
/**
|
|
4
|
+
* Read tools over CardanoODataService. All upstream operations are OData
|
|
5
|
+
* actions (POST); each fetches from the configured backends on a cache miss
|
|
6
|
+
* and UPSERTs into the ODATANO indexer, so repeated calls are cheap.
|
|
7
|
+
* Lookups return `{ found: false }` on 404 instead of an error.
|
|
8
|
+
*/
|
|
9
|
+
export declare function registerReadTools(server: McpServer, ctx: ToolContext): void;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { assetUnit, bech32Address, clampedInt, drepId, hex56, hex64, hexString, poolId, stakeAddress, } from '../schemas.js';
|
|
3
|
+
import { makeRunner } from './shared.js';
|
|
4
|
+
/**
|
|
5
|
+
* Read tools over CardanoODataService. All upstream operations are OData
|
|
6
|
+
* actions (POST); each fetches from the configured backends on a cache miss
|
|
7
|
+
* and UPSERTs into the ODATANO indexer, so repeated calls are cheap.
|
|
8
|
+
* Lookups return `{ found: false }` on 404 instead of an error.
|
|
9
|
+
*/
|
|
10
|
+
export function registerReadTools(server, ctx) {
|
|
11
|
+
const { client } = ctx;
|
|
12
|
+
const run = makeRunner(ctx);
|
|
13
|
+
// ── Chain & network ────────────────────────────────────────────────
|
|
14
|
+
server.registerTool('get_network_info', {
|
|
15
|
+
description: 'Network summary of the ODATANO host: configured Cardano network (mainnet / preview / preprod), ' +
|
|
16
|
+
'current tip (block, slot, epoch) and backend health. Call once before submitting anything so ' +
|
|
17
|
+
'you know which network the host talks to.',
|
|
18
|
+
inputSchema: {},
|
|
19
|
+
}, run(async () => client.callAction('odata', 'GetNetworkInformation')));
|
|
20
|
+
server.registerTool('get_latest_block', {
|
|
21
|
+
description: 'The most recent Cardano block seen by the host (hash, height, slot, epoch, time, tx count).',
|
|
22
|
+
inputSchema: {},
|
|
23
|
+
}, run(async () => client.callAction('odata', 'GetLatestBlock')));
|
|
24
|
+
server.registerTool('get_block', {
|
|
25
|
+
description: 'Block details by block hash. Returns found:false (not an error) when the block is unknown.',
|
|
26
|
+
inputSchema: {
|
|
27
|
+
hash: hex64('hash').describe('Block hash (blake2b-256, 64 hex)'),
|
|
28
|
+
},
|
|
29
|
+
}, run(async (args) => client.callAction('odata', 'GetBlockByHash', { hash: args.hash }), {
|
|
30
|
+
notFoundAs: (args) => ({ hash: args.hash }),
|
|
31
|
+
}));
|
|
32
|
+
server.registerTool('get_epoch', {
|
|
33
|
+
description: 'Epoch details (start/end time, block and tx counts, output, fees, active stake). ' +
|
|
34
|
+
'Omit epochNumber for the current epoch.',
|
|
35
|
+
inputSchema: {
|
|
36
|
+
epochNumber: z.number().int().nonnegative().optional().describe('Epoch number; omit for the latest epoch'),
|
|
37
|
+
},
|
|
38
|
+
}, run(async (args) => args.epochNumber === undefined
|
|
39
|
+
? client.callAction('odata', 'GetLatestEpoch')
|
|
40
|
+
: client.callAction('odata', 'GetEpochByNumber', { epochNumber: args.epochNumber }), { notFoundAs: (args) => ({ epochNumber: args.epochNumber }) }));
|
|
41
|
+
server.registerTool('get_protocol_parameters', {
|
|
42
|
+
description: 'Current ledger protocol parameters (min fee coefficients, min UTxO / coinsPerUtxoByte, max tx size, ' +
|
|
43
|
+
'Plutus cost models, collateral percentage, ...). Use when reasoning about fees, min-ADA or script budgets.',
|
|
44
|
+
inputSchema: {},
|
|
45
|
+
}, run(async () => client.callAction('odata', 'GetLedgerProtocolParameters')));
|
|
46
|
+
server.registerTool('get_transaction', {
|
|
47
|
+
description: 'Transaction by hash: block, slot, fee, size, deposit, validity, asset movements. ' +
|
|
48
|
+
'Set includeInputsOutputs to also return the resolved inputs and outputs (addresses, lovelace, assets, datums). ' +
|
|
49
|
+
'Returns found:false when the transaction is unknown to all backends.',
|
|
50
|
+
inputSchema: {
|
|
51
|
+
hash: hex64('hash').describe('Transaction hash (64 hex)'),
|
|
52
|
+
includeInputsOutputs: z.boolean().optional()
|
|
53
|
+
.describe('Also return inputs and outputs (one extra request); default false'),
|
|
54
|
+
},
|
|
55
|
+
}, run(async (args) => {
|
|
56
|
+
const tx = await client.callAction('odata', 'GetTransactionByHash', { hash: args.hash });
|
|
57
|
+
if (!args.includeInputsOutputs)
|
|
58
|
+
return tx;
|
|
59
|
+
// The action indexed the tx (and its inputs/outputs). Expand via a
|
|
60
|
+
// collection query: ODATANO's key-read handler serves the row straight
|
|
61
|
+
// from the indexer and ignores $expand, the collection path honours it.
|
|
62
|
+
const page = (await client.queryEntity('odata', 'Transactions', {
|
|
63
|
+
filter: `hash eq '${args.hash}'`,
|
|
64
|
+
expand: 'inputs,outputs',
|
|
65
|
+
top: 1,
|
|
66
|
+
}));
|
|
67
|
+
return page?.value?.[0] ?? tx;
|
|
68
|
+
}, { notFoundAs: (args) => ({ hash: args.hash }) }));
|
|
69
|
+
server.registerTool('get_transaction_metadata', {
|
|
70
|
+
description: 'On-chain metadata of a transaction as a list of { label, json } entries (CIP-20 messages, ' +
|
|
71
|
+
'label-1447 financial anchors, CIP-25 NFT metadata, ...). Empty list when the tx carries none.',
|
|
72
|
+
inputSchema: {
|
|
73
|
+
txHash: hex64('txHash').describe('Transaction hash (64 hex)'),
|
|
74
|
+
},
|
|
75
|
+
}, run(async (args) => client.callAction('odata', 'GetMetadataByTxHash', { txHash: args.txHash }), {
|
|
76
|
+
notFoundAs: (args) => ({ txHash: args.txHash }),
|
|
77
|
+
}));
|
|
78
|
+
server.registerTool('parse_transaction_cbor', {
|
|
79
|
+
description: 'Decode hex transaction CBOR (signed or unsigned) into structured fields: inputs, outputs, fee, ' +
|
|
80
|
+
'validity interval, mint, metadata, required signers, witness summary. Pure function - no network, ' +
|
|
81
|
+
'no DB write. Use it to inspect an unsigned build before asking a human to sign, or to check a ' +
|
|
82
|
+
'signed CBOR before submitting. Capped at 128 KiB of hex.',
|
|
83
|
+
inputSchema: {
|
|
84
|
+
cbor: hexString('cbor', 131072).describe('Hex-encoded transaction CBOR'),
|
|
85
|
+
},
|
|
86
|
+
}, run(async (args) => client.callAction('odata', 'ParseTransactionCbor', { cbor: args.cbor }), { keepCbor: true }));
|
|
87
|
+
// ── Address, UTxO & assets ─────────────────────────────────────────
|
|
88
|
+
server.registerTool('get_address', {
|
|
89
|
+
description: 'Address summary: lovelace balance, native-asset balances, stake address, tx count. ' +
|
|
90
|
+
'Returns found:false when the address has never appeared on-chain.',
|
|
91
|
+
inputSchema: {
|
|
92
|
+
address: bech32Address.describe('Bech32 payment address (addr… / addr_test…)'),
|
|
93
|
+
},
|
|
94
|
+
}, run(async (args) => client.callAction('odata', 'GetAddressByBech32', { address: args.address }), {
|
|
95
|
+
notFoundAs: (args) => ({ address: args.address }),
|
|
96
|
+
}));
|
|
97
|
+
server.registerTool('get_utxos', {
|
|
98
|
+
description: 'Unspent outputs. Pass EITHER address (bech32) OR credential (28-byte payment credential hash, 56 hex) - ' +
|
|
99
|
+
'the credential form aggregates every bech32 address sharing that payment key/script hash (Koios-only, ' +
|
|
100
|
+
'always fresh). Each UTxO: txHash, outputIndex, lovelace, assets, inline datum / datum hash, reference script.',
|
|
101
|
+
inputSchema: {
|
|
102
|
+
address: bech32Address.optional().describe('Bech32 payment address'),
|
|
103
|
+
credential: hex56('credential').optional().describe('Payment credential hash (56 hex)'),
|
|
104
|
+
},
|
|
105
|
+
}, run(async (args) => {
|
|
106
|
+
if (!!args.address === !!args.credential) {
|
|
107
|
+
throw new Error('pass exactly one of address / credential');
|
|
108
|
+
}
|
|
109
|
+
return args.address
|
|
110
|
+
? client.callAction('odata', 'GetUTxOsByAddress', { address: args.address })
|
|
111
|
+
: client.callAction('odata', 'GetUTxOsByCredential', { credential: args.credential });
|
|
112
|
+
}, { notFoundAs: (args) => ({ address: args.address, credential: args.credential }) }));
|
|
113
|
+
server.registerTool('get_address_assets', {
|
|
114
|
+
description: 'Native assets held by an address: unit (policyId+assetNameHex), quantity, decoded asset name.',
|
|
115
|
+
inputSchema: {
|
|
116
|
+
address: bech32Address.describe('Bech32 payment address'),
|
|
117
|
+
},
|
|
118
|
+
}, run(async (args) => client.callAction('odata', 'GetAssetsByAddress', { address: args.address }), {
|
|
119
|
+
notFoundAs: (args) => ({ address: args.address }),
|
|
120
|
+
}));
|
|
121
|
+
server.registerTool('get_address_transactions', {
|
|
122
|
+
description: 'Most recent transactions touching an address (newest first): txHash, block, slot, time.',
|
|
123
|
+
inputSchema: {
|
|
124
|
+
address: bech32Address.describe('Bech32 payment address'),
|
|
125
|
+
limit: clampedInt('limit', 1, 100, 20).describe('Max transactions (1-100, default 20)'),
|
|
126
|
+
},
|
|
127
|
+
}, run(async (args) => client.callAction('odata', 'GetLatestTransactionsByAddress', { address: args.address, limit: args.limit }), { notFoundAs: (args) => ({ address: args.address }) }));
|
|
128
|
+
server.registerTool('get_asset_info', {
|
|
129
|
+
description: 'Native asset by unit (policyId + assetNameHex): total supply, mint/burn tx count, first mint, ' +
|
|
130
|
+
'CIP-25 (on-chain, label 721) and CIP-26 (off-chain registry) metadata where available.',
|
|
131
|
+
inputSchema: {
|
|
132
|
+
unit: assetUnit.describe('policyId (56 hex) + assetNameHex (0-64 hex)'),
|
|
133
|
+
},
|
|
134
|
+
}, run(async (args) => client.callAction('odata', 'GetAssetInfo', { unit: args.unit }), {
|
|
135
|
+
notFoundAs: (args) => ({ unit: args.unit }),
|
|
136
|
+
}));
|
|
137
|
+
server.registerTool('get_asset_history', {
|
|
138
|
+
description: 'Mint / burn events of a native asset, most recent first: txHash, quantity delta, block time ' +
|
|
139
|
+
'(time may be null when only Blockfrost is available).',
|
|
140
|
+
inputSchema: {
|
|
141
|
+
unit: assetUnit.describe('policyId (56 hex) + assetNameHex (0-64 hex)'),
|
|
142
|
+
limit: clampedInt('limit', 1, 100, 20).describe('Max events (1-100, default 20)'),
|
|
143
|
+
},
|
|
144
|
+
}, run(async (args) => client.callAction('odata', 'GetAssetHistory', { unit: args.unit, limit: args.limit }), {
|
|
145
|
+
notFoundAs: (args) => ({ unit: args.unit }),
|
|
146
|
+
}));
|
|
147
|
+
// ── Staking & governance ───────────────────────────────────────────
|
|
148
|
+
server.registerTool('get_account', {
|
|
149
|
+
description: 'Stake account by stake address: controlled amount, rewards, withdrawals, delegated pool, DRep delegation.',
|
|
150
|
+
inputSchema: {
|
|
151
|
+
stakeAddress: stakeAddress.describe('Bech32 stake address (stake… / stake_test…)'),
|
|
152
|
+
},
|
|
153
|
+
}, run(async (args) => client.callAction('odata', 'GetAccountByStakeAddress', { stakeAddress: args.stakeAddress }), {
|
|
154
|
+
notFoundAs: (args) => ({ stakeAddress: args.stakeAddress }),
|
|
155
|
+
}));
|
|
156
|
+
server.registerTool('get_pool', {
|
|
157
|
+
description: 'Stake pool by pool id: ticker, name, pledge, margin, fixed cost, live/active stake, saturation, delegators.',
|
|
158
|
+
inputSchema: {
|
|
159
|
+
poolId: poolId.describe('Bech32 pool id (pool1…)'),
|
|
160
|
+
},
|
|
161
|
+
}, run(async (args) => client.callAction('odata', 'GetPoolById', { poolId: args.poolId }), {
|
|
162
|
+
notFoundAs: (args) => ({ poolId: args.poolId }),
|
|
163
|
+
}));
|
|
164
|
+
server.registerTool('get_drep', {
|
|
165
|
+
description: 'Governance DRep by id: voting power, active status, anchor URL/hash, delegator count.',
|
|
166
|
+
inputSchema: {
|
|
167
|
+
drepId: drepId.describe('Bech32 DRep id (drep1… / drep_script1…)'),
|
|
168
|
+
},
|
|
169
|
+
}, run(async (args) => client.callAction('odata', 'GetDrepById', { drepId: args.drepId }), {
|
|
170
|
+
notFoundAs: (args) => ({ drepId: args.drepId }),
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAC5F,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAoB,MAAM,aAAa,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAiB,EAAE,GAAgB;IACnE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IACvB,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAE5B,sEAAsE;IAEtE,MAAM,CAAC,YAAY,CACjB,kBAAkB,EAClB;QACE,WAAW,EACT,iGAAiG;YACjG,+FAA+F;YAC/F,2CAA2C;QAC7C,WAAW,EAAE,EAAE;KAChB,EACD,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC,CACrE,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,kBAAkB,EAClB;QACE,WAAW,EAAE,6FAA6F;QAC1G,WAAW,EAAE,EAAE;KAChB,EACD,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,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D,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE;QACtF,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;KAChD,CAAC,CACH,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,UAAU,EACV;QACE,WAAW,EAAE,uFAAuF;QACpG,WAAW,EAAE;YACX,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,yCAAyC,CAAC;SACnE;KACF,EACD,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE;QACtF,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;KAChD,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type OdatanoClient } from '../client.js';
|
|
2
|
+
import type { OdatanoMcpConfig } from '../config.js';
|
|
3
|
+
export interface ToolContext {
|
|
4
|
+
client: OdatanoClient;
|
|
5
|
+
config: OdatanoMcpConfig;
|
|
6
|
+
}
|
|
7
|
+
export type ToolResult = {
|
|
8
|
+
content: Array<{
|
|
9
|
+
type: 'text';
|
|
10
|
+
text: string;
|
|
11
|
+
}>;
|
|
12
|
+
isError?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export interface RunOptions<A> {
|
|
15
|
+
/** Keep CBOR/script hex fields verbatim (tools whose job is returning them). */
|
|
16
|
+
keepCbor?: boolean;
|
|
17
|
+
/** Turn an upstream 404 into `{ found: false, ...detail(args) }` instead of an error. */
|
|
18
|
+
notFoundAs?: (args: A) => Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/** Fixed sentence appended to every build tool description. */
|
|
21
|
+
export declare const UNSIGNED_HINT: string;
|
|
22
|
+
export declare const JSON_HINT = " JSON parameters may be passed as a JSON string or as a native JSON value.";
|
|
23
|
+
/**
|
|
24
|
+
* Uniform handler wrapper: JSON success payloads (trimmed), API errors reported
|
|
25
|
+
* as tool errors (isError) with status + ODATANO code so the agent can react
|
|
26
|
+
* (401 -> credentials, 429 -> back off, 400 ODATANO_INVALID_INPUT -> fix args)
|
|
27
|
+
* instead of crashing the call. Two upstream outcomes are NOT errors for an
|
|
28
|
+
* agent and are normalised: 404 on a lookup (`found: false`) and 409
|
|
29
|
+
* ODATANO_TX_ALREADY_SUBMITTED (`alreadySubmitted: true`).
|
|
30
|
+
*/
|
|
31
|
+
export declare function makeRunner(ctx: ToolContext): <A>(fn: (args: A) => Promise<unknown>, opts?: RunOptions<A>) => (args: A) => Promise<ToolResult>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { OdatanoApiError } from '../client.js';
|
|
2
|
+
import { notFound, trimResult } from '../output.js';
|
|
3
|
+
/** Fixed sentence appended to every build tool description. */
|
|
4
|
+
export const UNSIGNED_HINT = ' Returns UNSIGNED CBOR (unsignedTxCbor) + fee + buildId; NOTHING is signed or submitted. ' +
|
|
5
|
+
'Hand the buildId to create_signing_request so a human / wallet can sign, then submit_signed_transaction.';
|
|
6
|
+
export const JSON_HINT = ' JSON parameters may be passed as a JSON string or as a native JSON value.';
|
|
7
|
+
/**
|
|
8
|
+
* Uniform handler wrapper: JSON success payloads (trimmed), API errors reported
|
|
9
|
+
* as tool errors (isError) with status + ODATANO code so the agent can react
|
|
10
|
+
* (401 -> credentials, 429 -> back off, 400 ODATANO_INVALID_INPUT -> fix args)
|
|
11
|
+
* instead of crashing the call. Two upstream outcomes are NOT errors for an
|
|
12
|
+
* agent and are normalised: 404 on a lookup (`found: false`) and 409
|
|
13
|
+
* ODATANO_TX_ALREADY_SUBMITTED (`alreadySubmitted: true`).
|
|
14
|
+
*/
|
|
15
|
+
export function makeRunner(ctx) {
|
|
16
|
+
return function run(fn, opts = {}) {
|
|
17
|
+
return async (args) => {
|
|
18
|
+
try {
|
|
19
|
+
const raw = await fn(args);
|
|
20
|
+
const result = trimResult(raw, { maxRows: ctx.config.maxRows, keepCbor: opts.keepCbor });
|
|
21
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
if (err instanceof OdatanoApiError) {
|
|
25
|
+
if (err.status === 404 && opts.notFoundAs) {
|
|
26
|
+
const body = notFound({ ...opts.notFoundAs(args), message: err.message });
|
|
27
|
+
return { content: [{ type: 'text', text: JSON.stringify(body, null, 2) }] };
|
|
28
|
+
}
|
|
29
|
+
if (err.status === 409 && err.code === 'ODATANO_TX_ALREADY_SUBMITTED') {
|
|
30
|
+
const body = { alreadySubmitted: true, httpStatus: 409, code: err.code, message: err.message };
|
|
31
|
+
return { content: [{ type: 'text', text: JSON.stringify(body, null, 2) }] };
|
|
32
|
+
}
|
|
33
|
+
const detail = { httpStatus: err.status, code: err.code ?? null, message: err.message };
|
|
34
|
+
return { content: [{ type: 'text', text: JSON.stringify(detail, null, 2) }], isError: true };
|
|
35
|
+
}
|
|
36
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
37
|
+
return { content: [{ type: 'text', text: message }], isError: true };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/tools/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAsB,MAAM,cAAc,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAmBpD,+DAA+D;AAC/D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,EAAE,CAAC;wBACtE,MAAM,IAAI,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;wBAC/F,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;oBAC9E,CAAC;oBACD,MAAM,MAAM,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;oBACxF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBAC/F,CAAC;gBACD,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACjE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YACvE,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { bech32Address, hexString, network, uuid } from '../schemas.js';
|
|
3
|
+
import { makeRunner } from './shared.js';
|
|
4
|
+
/*
|
|
5
|
+
* Signing handoff, verification and submit. The MCP server never signs:
|
|
6
|
+
* a build becomes a signing request whose instructions a human, a CIP-30
|
|
7
|
+
* wallet or a CLI fulfil; the agent then verifies and/or submits the signed
|
|
8
|
+
* CBOR. HSM signing (SignWithHsm / SignAndSubmitWithHsm) is deliberately not
|
|
9
|
+
* exposed - that is a server-held key, i.e. the wallet the agent must not have.
|
|
10
|
+
*/
|
|
11
|
+
const signerType = z.enum(['cardano-cli', 'browser-wallet', 'hardware-wallet', 'custom'])
|
|
12
|
+
.describe('Which kind of signer produced the CBOR');
|
|
13
|
+
export function registerSignTools(server, ctx) {
|
|
14
|
+
const { client } = ctx;
|
|
15
|
+
const run = makeRunner(ctx);
|
|
16
|
+
server.registerTool('create_signing_request', {
|
|
17
|
+
description: 'Turn a build into a signing request for EXTERNAL signing: returns signingRequestId, the unsigned CBOR, ' +
|
|
18
|
+
'human-readable signing instructions and a ready-to-run cardano-cli command. This is the artefact you ' +
|
|
19
|
+
'hand to the human / wallet owner. State machine: pending -> verified (verify_signature) -> submitted ' +
|
|
20
|
+
'(submit_verified_transaction). Persisted for audit.',
|
|
21
|
+
inputSchema: {
|
|
22
|
+
buildId: uuid('buildId').describe('Build id from a build_* tool'),
|
|
23
|
+
message: z.string().max(500).optional().describe('Optional note shown to the signer (what this tx is for)'),
|
|
24
|
+
},
|
|
25
|
+
}, run(async (args) => client.callAction('sign', 'CreateSigningRequest', args), {
|
|
26
|
+
keepCbor: true,
|
|
27
|
+
notFoundAs: (args) => ({ buildId: args.buildId }),
|
|
28
|
+
}));
|
|
29
|
+
server.registerTool('get_signing_request', {
|
|
30
|
+
description: 'Signing request by id: status (pending / verified / submitted / failed), build, instructions, tx hash once submitted.',
|
|
31
|
+
inputSchema: {
|
|
32
|
+
signingRequestId: uuid('signingRequestId').describe('Signing request id'),
|
|
33
|
+
},
|
|
34
|
+
}, run(async (args) => client.callAction('sign', 'GetSigningRequest', { signingRequestId: args.signingRequestId }), {
|
|
35
|
+
keepCbor: true,
|
|
36
|
+
notFoundAs: (args) => ({ signingRequestId: args.signingRequestId }),
|
|
37
|
+
}));
|
|
38
|
+
server.registerTool('list_signing_requests', {
|
|
39
|
+
description: 'Signing requests created for a sender address (newest first): id, status, buildId, created time.',
|
|
40
|
+
inputSchema: {
|
|
41
|
+
address: bech32Address.describe('Sender address (bech32)'),
|
|
42
|
+
},
|
|
43
|
+
}, run(async (args) => client.callAction('sign', 'GetSigningRequestsByAddress', { address: args.address }), {
|
|
44
|
+
notFoundAs: (args) => ({ address: args.address }),
|
|
45
|
+
}));
|
|
46
|
+
server.registerTool('verify_signature', {
|
|
47
|
+
description: 'Verify a signed transaction CBOR against its signing request WITHOUT submitting: checks that the body ' +
|
|
48
|
+
'matches the build and that valid Ed25519 witnesses exist for the fee payer and every required signer. ' +
|
|
49
|
+
'Stores the verification for audit and moves the request to "verified". Optionally binds the request ' +
|
|
50
|
+
'to a sender address.',
|
|
51
|
+
inputSchema: {
|
|
52
|
+
signingRequestId: uuid('signingRequestId').describe('Signing request id'),
|
|
53
|
+
signedTxCbor: hexString('signedTxCbor').describe('Signed transaction CBOR (hex)'),
|
|
54
|
+
signerType,
|
|
55
|
+
signerInfo: z.string().max(100).optional().describe('Free-text signer info (wallet name, operator, ...)'),
|
|
56
|
+
address: bech32Address.optional().describe('Optional sender address for ownership verification'),
|
|
57
|
+
},
|
|
58
|
+
}, run(async (args) => client.callAction('sign', 'VerifySignature', args)));
|
|
59
|
+
server.registerTool('verify_data_signature', {
|
|
60
|
+
description: 'Verify a CIP-30 signData (COSE_Sign1) message signature against a bech32 address: Ed25519 signature ' +
|
|
61
|
+
'valid, signer key hashes to the address payment credential, and (optionally) the signed payload equals ' +
|
|
62
|
+
'expectedPayload (anti-replay). Stateless - no DB write, no key access. Use for wallet-based login / ' +
|
|
63
|
+
'consent proofs. Returns { valid, reason?, signedPayload, signerVkh }.',
|
|
64
|
+
inputSchema: {
|
|
65
|
+
address: bech32Address.describe('Address the wallet claimed to sign with'),
|
|
66
|
+
coseSignature: hexString('coseSignature').describe('Hex COSE_Sign1 CBOR (the `signature` field from signData)'),
|
|
67
|
+
coseKey: hexString('coseKey').describe('Hex COSE_Key CBOR (the `key` field from signData)'),
|
|
68
|
+
expectedPayload: z.string().max(10000).optional().describe('Optional expected UTF-8 payload; when set the signed payload must equal it'),
|
|
69
|
+
},
|
|
70
|
+
}, run(async (args) => client.callAction('sign', 'VerifyDataSignature', args)));
|
|
71
|
+
server.registerTool('submit_signed_transaction', {
|
|
72
|
+
description: 'Submit an ALREADY SIGNED transaction CBOR to the Cardano network. Two modes: with buildId the host ' +
|
|
73
|
+
'checks the CBOR against the recorded build and links the submission to it; without buildId pass ' +
|
|
74
|
+
'network and the raw signed CBOR is submitted as-is (parse_transaction_cbor first if unsure). ' +
|
|
75
|
+
'This tool only submits - the CBOR must already carry valid witnesses; the host will reject unsigned ' +
|
|
76
|
+
'or mis-signed CBOR. Returns { id (submissionId), txHash, status }. A duplicate submit returns ' +
|
|
77
|
+
'alreadySubmitted:true rather than an error.',
|
|
78
|
+
inputSchema: {
|
|
79
|
+
signedTxCbor: hexString('signedTxCbor').describe('Signed transaction CBOR (hex)'),
|
|
80
|
+
buildId: uuid('buildId').optional().describe('Build id to submit against (preferred)'),
|
|
81
|
+
network: network.optional().describe('Required when no buildId: the network the host must submit to (safety check)'),
|
|
82
|
+
},
|
|
83
|
+
}, run(async (args) => {
|
|
84
|
+
if (args.buildId) {
|
|
85
|
+
return client.callAction('transaction', 'SubmitTransaction', { buildId: args.buildId, signedTxCbor: args.signedTxCbor });
|
|
86
|
+
}
|
|
87
|
+
if (!args.network)
|
|
88
|
+
throw new Error('pass buildId, or network for a raw signed CBOR submit');
|
|
89
|
+
return client.callAction('transaction', 'SubmitSignedTransaction', { signedTxCbor: args.signedTxCbor, network: args.network });
|
|
90
|
+
}));
|
|
91
|
+
server.registerTool('submit_verified_transaction', {
|
|
92
|
+
description: 'Verify + submit in one step for a signing request: runs the same checks as verify_signature, then ' +
|
|
93
|
+
'submits, updates the request to "submitted" and records the submission. deferSubmit=true returns ' +
|
|
94
|
+
'immediately with the tx hash and status pending while the network submit happens detached (track via ' +
|
|
95
|
+
'get_signing_request / get_submission_status).',
|
|
96
|
+
inputSchema: {
|
|
97
|
+
signingRequestId: uuid('signingRequestId').describe('Signing request id'),
|
|
98
|
+
signedTxCbor: hexString('signedTxCbor').describe('Signed transaction CBOR (hex)'),
|
|
99
|
+
signerType,
|
|
100
|
+
signerInfo: z.string().max(100).optional().describe('Free-text signer info'),
|
|
101
|
+
address: bech32Address.optional().describe('Optional sender address for ownership verification'),
|
|
102
|
+
deferSubmit: z.boolean().optional().describe('Return after verify + claim; submit runs detached'),
|
|
103
|
+
},
|
|
104
|
+
}, run(async (args) => client.callAction('sign', 'SubmitVerifiedTransaction', args)));
|
|
105
|
+
server.registerTool('get_submission_status', {
|
|
106
|
+
description: 'Status of a transaction submission by submission id: pending -> submitted -> confirmed | failed. ' +
|
|
107
|
+
'With refresh=true the host re-queries the chain for confirmation before answering (bound action ' +
|
|
108
|
+
'CheckSubmissionStatus; only meaningful while status is submitted).',
|
|
109
|
+
inputSchema: {
|
|
110
|
+
submissionId: uuid('submissionId').describe('Submission id (`id` from a submit_* result)'),
|
|
111
|
+
refresh: z.boolean().optional().describe('Re-check the chain for confirmation first (default false)'),
|
|
112
|
+
},
|
|
113
|
+
}, run(async (args) => {
|
|
114
|
+
if (args.refresh) {
|
|
115
|
+
return client.callBoundAction('transaction', 'TransactionSubmissions', args.submissionId, 'CardanoTransactionService.CheckSubmissionStatus');
|
|
116
|
+
}
|
|
117
|
+
return client.readEntity('transaction', 'TransactionSubmissions', args.submissionId);
|
|
118
|
+
}, { notFoundAs: (args) => ({ submissionId: args.submissionId }) }));
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=sign.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign.js","sourceRoot":"","sources":["../../src/tools/sign.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,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