@manifest-network/manifest-mcp-core 0.8.0 → 0.10.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.
Files changed (106) hide show
  1. package/README.md +6 -2
  2. package/dist/__test-utils__/callToolWithElicitation.d.ts +43 -0
  3. package/dist/__test-utils__/callToolWithElicitation.d.ts.map +1 -0
  4. package/dist/__test-utils__/callToolWithElicitation.js +57 -0
  5. package/dist/__test-utils__/callToolWithElicitation.js.map +1 -0
  6. package/dist/__test-utils__/mocks.d.ts +8 -7
  7. package/dist/__test-utils__/mocks.d.ts.map +1 -1
  8. package/dist/__test-utils__/mocks.js +1 -1
  9. package/dist/config.d.ts +11 -1
  10. package/dist/config.d.ts.map +1 -1
  11. package/dist/config.js +1 -1
  12. package/dist/config.js.map +1 -1
  13. package/dist/index.d.ts +2 -2
  14. package/dist/index.js +2 -2
  15. package/dist/server-utils.d.ts +4 -2
  16. package/dist/server-utils.d.ts.map +1 -1
  17. package/dist/server-utils.js +9 -5
  18. package/dist/server-utils.js.map +1 -1
  19. package/dist/version.d.ts +1 -1
  20. package/dist/version.js +1 -1
  21. package/dist/version.js.map +1 -1
  22. package/package.json +13 -1
  23. package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +0 -78
  24. package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js.map +0 -1
  25. package/dist/node_modules/@vitest/expect/dist/index.d.ts +0 -802
  26. package/dist/node_modules/@vitest/expect/dist/index.d.ts.map +0 -1
  27. package/dist/node_modules/@vitest/expect/dist/index.js +0 -1457
  28. package/dist/node_modules/@vitest/expect/dist/index.js.map +0 -1
  29. package/dist/node_modules/@vitest/pretty-format/dist/index.d.ts +0 -95
  30. package/dist/node_modules/@vitest/pretty-format/dist/index.d.ts.map +0 -1
  31. package/dist/node_modules/@vitest/pretty-format/dist/index.js +0 -877
  32. package/dist/node_modules/@vitest/pretty-format/dist/index.js.map +0 -1
  33. package/dist/node_modules/@vitest/runner/dist/chunk-tasks.js +0 -91
  34. package/dist/node_modules/@vitest/runner/dist/chunk-tasks.js.map +0 -1
  35. package/dist/node_modules/@vitest/runner/dist/index.js +0 -1381
  36. package/dist/node_modules/@vitest/runner/dist/index.js.map +0 -1
  37. package/dist/node_modules/@vitest/runner/dist/tasks.d-D2GKpdwQ.d.ts +0 -540
  38. package/dist/node_modules/@vitest/runner/dist/tasks.d-D2GKpdwQ.d.ts.map +0 -1
  39. package/dist/node_modules/@vitest/runner/dist/utils.js +0 -1
  40. package/dist/node_modules/@vitest/snapshot/dist/environment.d-DOJxxZV9.d.ts +0 -16
  41. package/dist/node_modules/@vitest/snapshot/dist/environment.d-DOJxxZV9.d.ts.map +0 -1
  42. package/dist/node_modules/@vitest/snapshot/dist/index.d.ts +0 -89
  43. package/dist/node_modules/@vitest/snapshot/dist/index.d.ts.map +0 -1
  44. package/dist/node_modules/@vitest/snapshot/dist/index.js +0 -649
  45. package/dist/node_modules/@vitest/snapshot/dist/index.js.map +0 -1
  46. package/dist/node_modules/@vitest/snapshot/dist/rawSnapshot.d-U2kJUxDr.d.ts +0 -40
  47. package/dist/node_modules/@vitest/snapshot/dist/rawSnapshot.d-U2kJUxDr.d.ts.map +0 -1
  48. package/dist/node_modules/@vitest/spy/dist/index.d.ts +0 -343
  49. package/dist/node_modules/@vitest/spy/dist/index.d.ts.map +0 -1
  50. package/dist/node_modules/@vitest/spy/dist/index.js +0 -386
  51. package/dist/node_modules/@vitest/spy/dist/index.js.map +0 -1
  52. package/dist/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js +0 -82
  53. package/dist/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js.map +0 -1
  54. package/dist/node_modules/@vitest/utils/dist/diff.d.ts +0 -14
  55. package/dist/node_modules/@vitest/utils/dist/diff.d.ts.map +0 -1
  56. package/dist/node_modules/@vitest/utils/dist/diff.js +0 -1297
  57. package/dist/node_modules/@vitest/utils/dist/diff.js.map +0 -1
  58. package/dist/node_modules/@vitest/utils/dist/display.d.ts +0 -15
  59. package/dist/node_modules/@vitest/utils/dist/display.d.ts.map +0 -1
  60. package/dist/node_modules/@vitest/utils/dist/display.js +0 -558
  61. package/dist/node_modules/@vitest/utils/dist/display.js.map +0 -1
  62. package/dist/node_modules/@vitest/utils/dist/error.js +0 -30
  63. package/dist/node_modules/@vitest/utils/dist/error.js.map +0 -1
  64. package/dist/node_modules/@vitest/utils/dist/helpers.js +0 -181
  65. package/dist/node_modules/@vitest/utils/dist/helpers.js.map +0 -1
  66. package/dist/node_modules/@vitest/utils/dist/offset.js +0 -27
  67. package/dist/node_modules/@vitest/utils/dist/offset.js.map +0 -1
  68. package/dist/node_modules/@vitest/utils/dist/serialize.js +0 -77
  69. package/dist/node_modules/@vitest/utils/dist/serialize.js.map +0 -1
  70. package/dist/node_modules/@vitest/utils/dist/source-map.js +0 -367
  71. package/dist/node_modules/@vitest/utils/dist/source-map.js.map +0 -1
  72. package/dist/node_modules/@vitest/utils/dist/timers.js +0 -37
  73. package/dist/node_modules/@vitest/utils/dist/timers.js.map +0 -1
  74. package/dist/node_modules/@vitest/utils/dist/types.d-BCElaP-c.d.ts +0 -38
  75. package/dist/node_modules/@vitest/utils/dist/types.d-BCElaP-c.d.ts.map +0 -1
  76. package/dist/node_modules/@vitest/utils/dist/types.d.ts +0 -25
  77. package/dist/node_modules/@vitest/utils/dist/types.d.ts.map +0 -1
  78. package/dist/node_modules/chai/index.js +0 -2875
  79. package/dist/node_modules/chai/index.js.map +0 -1
  80. package/dist/node_modules/magic-string/dist/magic-string.es.js +0 -939
  81. package/dist/node_modules/magic-string/dist/magic-string.es.js.map +0 -1
  82. package/dist/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +0 -85
  83. package/dist/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js.map +0 -1
  84. package/dist/node_modules/tinybench/dist/index.d.ts +0 -91
  85. package/dist/node_modules/tinybench/dist/index.d.ts.map +0 -1
  86. package/dist/node_modules/tinyrainbow/dist/index.d.ts +0 -9
  87. package/dist/node_modules/tinyrainbow/dist/index.d.ts.map +0 -1
  88. package/dist/node_modules/tinyrainbow/dist/index.js +0 -86
  89. package/dist/node_modules/tinyrainbow/dist/index.js.map +0 -1
  90. package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -6
  91. package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js.map +0 -1
  92. package/dist/node_modules/vitest/dist/chunks/benchmark.D0SlKNbZ.js +0 -41
  93. package/dist/node_modules/vitest/dist/chunks/benchmark.D0SlKNbZ.js.map +0 -1
  94. package/dist/node_modules/vitest/dist/chunks/benchmark.d.DAaHLpsq.d.ts +0 -12
  95. package/dist/node_modules/vitest/dist/chunks/benchmark.d.DAaHLpsq.d.ts.map +0 -1
  96. package/dist/node_modules/vitest/dist/chunks/global.d.x-ILCfAE.d.ts +0 -100
  97. package/dist/node_modules/vitest/dist/chunks/global.d.x-ILCfAE.d.ts.map +0 -1
  98. package/dist/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js +0 -57
  99. package/dist/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js.map +0 -1
  100. package/dist/node_modules/vitest/dist/chunks/rpc.d.BFMWpdph.d.ts +0 -13
  101. package/dist/node_modules/vitest/dist/chunks/rpc.d.BFMWpdph.d.ts.map +0 -1
  102. package/dist/node_modules/vitest/dist/chunks/test.CTcmp4Su.js +0 -2791
  103. package/dist/node_modules/vitest/dist/chunks/test.CTcmp4Su.js.map +0 -1
  104. package/dist/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js +0 -44
  105. package/dist/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js.map +0 -1
  106. package/dist/node_modules/vitest/dist/index.d.ts +0 -9
package/README.md CHANGED
@@ -14,8 +14,9 @@ npm install @manifest-network/manifest-mcp-core
14
14
  - **LCD adapter** (`lcd-adapter.ts`) -- Converts LCD/REST responses to the RPC query client shape, making the codebase transport-agnostic
15
15
  - **Module registry** (`modules.ts`) -- Static maps of Cosmos SDK modules with metadata and handler functions
16
16
  - **Query/transaction routing** (`cosmos.ts`) -- Routes `(module, subcommand, args)` to per-module handlers
17
- - **On-chain tool functions** (`tools/`) -- `getBalance`, `fundCredits`, `stopApp` (used by the lease package)
18
- - **Server utilities** (`server-utils.ts`) -- `withErrorHandling`, `jsonResponse`, `bigIntReplacer`, `sanitizeForLogging`
17
+ - **On-chain tool functions** (`tools/`) -- `getBalance`, `fundCredits`, `setItemCustomDomain`, `stopApp` (used by lease and fred packages)
18
+ - **Server utilities** (`server-utils.ts`) -- `withErrorHandling`, `jsonResponse`, `structuredResponse`, `bigIntReplacer`, `sanitizeForLogging`
19
+ - **Tool annotation helpers** (`tool-metadata.ts`) -- `readOnlyAnnotations`, `mutatingAnnotations`, `manifestMeta` (versioned `_meta.manifest` payload, `MANIFEST_TOOL_META_VERSION = 1`)
19
20
  - **Wallet providers** (`wallet/`) -- `MnemonicWalletProvider` (BIP-39), `signArbitraryWithAmino` (ADR-036)
20
21
  - **Logger** (`logger.ts`) -- Leveled logger (stderr output; defaults to `warn`, configurable via `logger.setLevel()`; the node package's bootstrap reads `LOG_LEVEL` and applies it)
21
22
  - **Retry** (`retry.ts`) -- Exponential backoff with transient/permanent error classification
@@ -36,7 +37,10 @@ npm install @manifest-network/manifest-mcp-core
36
37
  | poa | yes | yes |
37
38
  | tokenfactory | yes | yes |
38
39
  | ibc-transfer | yes | yes |
40
+ | authz | yes | yes |
41
+ | feegrant | yes | yes |
39
42
  | auth | yes | -- |
43
+ | mint | yes | -- |
40
44
  | manifest | -- | yes |
41
45
 
42
46
  ## Usage
@@ -0,0 +1,43 @@
1
+ import { ToolResult } from "./callTool.js";
2
+ import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
3
+ import { ElicitRequest, ElicitResult } from "@modelcontextprotocol/sdk/types.js";
4
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
5
+
6
+ //#region src/__test-utils__/callToolWithElicitation.d.ts
7
+ /**
8
+ * Scripted responder for incoming `elicitation/create` requests on the
9
+ * test-side MCP `Client`. The test author owns the mapping from request
10
+ * shape → result — the helper just wires it up.
11
+ *
12
+ * `respond` may be sync or async. It must return a valid `ElicitResult`
13
+ * (`{ action: 'accept' | 'decline' | 'cancel', content?: ... }`).
14
+ */
15
+ interface ElicitationScript {
16
+ respond: (req: ElicitRequest) => ElicitResult | Promise<ElicitResult>;
17
+ }
18
+ /**
19
+ * Mirror of `callTool` for tools that mid-execution call
20
+ * `server.elicitInput(...)`. Connects an MCP client (advertising the
21
+ * `elicitation` capability by default) to the server over an in-memory
22
+ * transport, registers a request handler that delegates each incoming
23
+ * elicitation to `script.respond`, then invokes the named tool.
24
+ *
25
+ * Cleanup always runs via the `finally` block: client and both transports
26
+ * are closed, then removed from `activeTransports` to prevent double-close
27
+ * in the caller's `afterEach`.
28
+ *
29
+ * @param server - The MCP `Server` instance (from `getServer()`)
30
+ * @param toolName - Name of the tool to invoke
31
+ * @param toolInput - Tool arguments
32
+ * @param script - Scripted responder for `elicitation/create` requests
33
+ * @param activeTransports - Optional mutable array; transports are added
34
+ * before the call and removed after cleanup completes.
35
+ * @param declareElicitationCapability - When `true` (default) the test
36
+ * `Client` advertises `capabilities: { elicitation: {} }`. Set to
37
+ * `false` to exercise the wrapper's capability-guard path (the tool
38
+ * should reject with `INVALID_CONFIG` before any elicitation happens).
39
+ */
40
+ declare function callToolWithElicitation(server: Server, toolName: string, toolInput: Record<string, unknown>, script: ElicitationScript, activeTransports?: InMemoryTransport[], declareElicitationCapability?: boolean): Promise<ToolResult>;
41
+ //#endregion
42
+ export { ElicitationScript, callToolWithElicitation };
43
+ //# sourceMappingURL=callToolWithElicitation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callToolWithElicitation.d.ts","names":[],"sources":["../../src/__test-utils__/callToolWithElicitation.ts"],"mappings":";;;;;;;;AAkBA;;;;;;UAAiB,iBAAA;EACf,OAAA,GAAU,GAAA,EAAK,aAAA,KAAkB,YAAA,GAAe,OAAA,CAAQ,YAAA;AAAA;;;;;;;;;AAyB1D;;;;;;;;;;;;;;iBAAsB,uBAAA,CACpB,MAAA,EAAQ,MAAA,EACR,QAAA,UACA,SAAA,EAAW,MAAA,mBACX,MAAA,EAAQ,iBAAA,EACR,gBAAA,GAAkB,iBAAA,IAClB,4BAAA,aACC,OAAA,CAAQ,UAAA"}
@@ -0,0 +1,57 @@
1
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
+ import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
3
+ import { ElicitRequestSchema } from "@modelcontextprotocol/sdk/types.js";
4
+ //#region src/__test-utils__/callToolWithElicitation.ts
5
+ /**
6
+ * Mirror of `callTool` for tools that mid-execution call
7
+ * `server.elicitInput(...)`. Connects an MCP client (advertising the
8
+ * `elicitation` capability by default) to the server over an in-memory
9
+ * transport, registers a request handler that delegates each incoming
10
+ * elicitation to `script.respond`, then invokes the named tool.
11
+ *
12
+ * Cleanup always runs via the `finally` block: client and both transports
13
+ * are closed, then removed from `activeTransports` to prevent double-close
14
+ * in the caller's `afterEach`.
15
+ *
16
+ * @param server - The MCP `Server` instance (from `getServer()`)
17
+ * @param toolName - Name of the tool to invoke
18
+ * @param toolInput - Tool arguments
19
+ * @param script - Scripted responder for `elicitation/create` requests
20
+ * @param activeTransports - Optional mutable array; transports are added
21
+ * before the call and removed after cleanup completes.
22
+ * @param declareElicitationCapability - When `true` (default) the test
23
+ * `Client` advertises `capabilities: { elicitation: {} }`. Set to
24
+ * `false` to exercise the wrapper's capability-guard path (the tool
25
+ * should reject with `INVALID_CONFIG` before any elicitation happens).
26
+ */
27
+ async function callToolWithElicitation(server, toolName, toolInput, script, activeTransports = [], declareElicitationCapability = true) {
28
+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
29
+ activeTransports.push(clientTransport, serverTransport);
30
+ const client = new Client({
31
+ name: "test-client",
32
+ version: "1.0.0"
33
+ }, declareElicitationCapability ? { capabilities: { elicitation: {} } } : { capabilities: {} });
34
+ if (declareElicitationCapability) client.setRequestHandler(ElicitRequestSchema, async (request) => {
35
+ return await script.respond(request);
36
+ });
37
+ try {
38
+ await server.connect(serverTransport);
39
+ await client.connect(clientTransport);
40
+ return await client.callTool({
41
+ name: toolName,
42
+ arguments: toolInput
43
+ });
44
+ } finally {
45
+ await client.close().catch(() => {});
46
+ await clientTransport.close().catch(() => {});
47
+ await serverTransport.close().catch(() => {});
48
+ for (const t of [clientTransport, serverTransport]) {
49
+ const idx = activeTransports.indexOf(t);
50
+ if (idx !== -1) activeTransports.splice(idx, 1);
51
+ }
52
+ }
53
+ }
54
+ //#endregion
55
+ export { callToolWithElicitation };
56
+
57
+ //# sourceMappingURL=callToolWithElicitation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callToolWithElicitation.js","names":[],"sources":["../../src/__test-utils__/callToolWithElicitation.ts"],"sourcesContent":["import { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';\nimport type { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport {\n type ElicitRequest,\n ElicitRequestSchema,\n type ElicitResult,\n} from '@modelcontextprotocol/sdk/types.js';\nimport type { ToolResult } from './callTool.js';\n\n/**\n * Scripted responder for incoming `elicitation/create` requests on the\n * test-side MCP `Client`. The test author owns the mapping from request\n * shape → result — the helper just wires it up.\n *\n * `respond` may be sync or async. It must return a valid `ElicitResult`\n * (`{ action: 'accept' | 'decline' | 'cancel', content?: ... }`).\n */\nexport interface ElicitationScript {\n respond: (req: ElicitRequest) => ElicitResult | Promise<ElicitResult>;\n}\n\n/**\n * Mirror of `callTool` for tools that mid-execution call\n * `server.elicitInput(...)`. Connects an MCP client (advertising the\n * `elicitation` capability by default) to the server over an in-memory\n * transport, registers a request handler that delegates each incoming\n * elicitation to `script.respond`, then invokes the named tool.\n *\n * Cleanup always runs via the `finally` block: client and both transports\n * are closed, then removed from `activeTransports` to prevent double-close\n * in the caller's `afterEach`.\n *\n * @param server - The MCP `Server` instance (from `getServer()`)\n * @param toolName - Name of the tool to invoke\n * @param toolInput - Tool arguments\n * @param script - Scripted responder for `elicitation/create` requests\n * @param activeTransports - Optional mutable array; transports are added\n * before the call and removed after cleanup completes.\n * @param declareElicitationCapability - When `true` (default) the test\n * `Client` advertises `capabilities: { elicitation: {} }`. Set to\n * `false` to exercise the wrapper's capability-guard path (the tool\n * should reject with `INVALID_CONFIG` before any elicitation happens).\n */\nexport async function callToolWithElicitation(\n server: Server,\n toolName: string,\n toolInput: Record<string, unknown>,\n script: ElicitationScript,\n activeTransports: InMemoryTransport[] = [],\n declareElicitationCapability = true,\n): Promise<ToolResult> {\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n activeTransports.push(clientTransport, serverTransport);\n\n const client = new Client(\n { name: 'test-client', version: '1.0.0' },\n declareElicitationCapability\n ? { capabilities: { elicitation: {} } }\n : { capabilities: {} },\n );\n\n // Register BEFORE connect so the handler is in place by the time the\n // server issues its first `elicitation/create` request mid-tool.\n //\n // Skip registration when the client did NOT advertise the elicitation\n // capability — the SDK's `setRequestHandler` enforces that the client\n // must have declared the capability for the request type, and would\n // throw before the tool call ever ran. The capability-guard test path\n // (`declareElicitationCapability: false`) exercises the wrapper's\n // `assertElicitationCapability` throw — no elicitation will arrive,\n // so no handler is needed.\n if (declareElicitationCapability) {\n client.setRequestHandler(ElicitRequestSchema, async (request) => {\n return await script.respond(request);\n });\n }\n\n try {\n await server.connect(serverTransport);\n await client.connect(clientTransport);\n\n return (await client.callTool({\n name: toolName,\n arguments: toolInput,\n })) as ToolResult;\n } finally {\n await client.close().catch(() => {});\n await clientTransport.close().catch(() => {});\n await serverTransport.close().catch(() => {});\n\n // Remove by identity so afterEach won't double-close\n for (const t of [clientTransport, serverTransport]) {\n const idx = activeTransports.indexOf(t);\n if (idx !== -1) activeTransports.splice(idx, 1);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,eAAsB,wBACpB,QACA,UACA,WACA,QACA,mBAAwC,EAAE,EAC1C,+BAA+B,MACV;CACrB,MAAM,CAAC,iBAAiB,mBACtB,kBAAkB,kBAAkB;AACtC,kBAAiB,KAAK,iBAAiB,gBAAgB;CAEvD,MAAM,SAAS,IAAI,OACjB;EAAE,MAAM;EAAe,SAAS;EAAS,EACzC,+BACI,EAAE,cAAc,EAAE,aAAa,EAAE,EAAE,EAAE,GACrC,EAAE,cAAc,EAAE,EAAE,CACzB;AAYD,KAAI,6BACF,QAAO,kBAAkB,qBAAqB,OAAO,YAAY;AAC/D,SAAO,MAAM,OAAO,QAAQ,QAAQ;GACpC;AAGJ,KAAI;AACF,QAAM,OAAO,QAAQ,gBAAgB;AACrC,QAAM,OAAO,QAAQ,gBAAgB;AAErC,SAAQ,MAAM,OAAO,SAAS;GAC5B,MAAM;GACN,WAAW;GACZ,CAAC;WACM;AACR,QAAM,OAAO,OAAO,CAAC,YAAY,GAAG;AACpC,QAAM,gBAAgB,OAAO,CAAC,YAAY,GAAG;AAC7C,QAAM,gBAAgB,OAAO,CAAC,YAAY,GAAG;AAG7C,OAAK,MAAM,KAAK,CAAC,iBAAiB,gBAAgB,EAAE;GAClD,MAAM,MAAM,iBAAiB,QAAQ,EAAE;AACvC,OAAI,QAAQ,GAAI,kBAAiB,OAAO,KAAK,EAAE"}
@@ -1,7 +1,8 @@
1
- import { Mock, Procedure } from "../node_modules/@vitest/spy/dist/index.js";
2
1
  import { ManifestMCPConfig, WalletProvider } from "../types.js";
3
2
  import { ManifestQueryClient } from "../client.js";
4
3
  import { LeaseState } from "@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js";
4
+ import * as vitest from "vitest";
5
+ import * as _vitest_spy0 from "@vitest/spy";
5
6
 
6
7
  //#region src/__test-utils__/mocks.d.ts
7
8
  /**
@@ -121,12 +122,12 @@ declare function makeMockClientManager(overrides?: {
121
122
  address?: string;
122
123
  config?: ManifestMCPConfig;
123
124
  }): {
124
- getQueryClient: Mock<Procedure>;
125
- getSigningClient: Mock<Procedure>;
126
- getAddress: Mock<Procedure>;
127
- getConfig: Mock<Procedure>;
128
- acquireRateLimit: Mock<Procedure>;
129
- disconnect: Mock<Procedure>;
125
+ getQueryClient: vitest.Mock<_vitest_spy0.Procedure>;
126
+ getSigningClient: vitest.Mock<_vitest_spy0.Procedure>;
127
+ getAddress: vitest.Mock<_vitest_spy0.Procedure>;
128
+ getConfig: vitest.Mock<_vitest_spy0.Procedure>;
129
+ acquireRateLimit: vitest.Mock<_vitest_spy0.Procedure>;
130
+ disconnect: vitest.Mock<_vitest_spy0.Procedure>;
130
131
  };
131
132
  //#endregion
132
133
  export { makeMockClientManager, makeMockConfig, makeMockQueryClient, makeMockWallet };
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.d.ts","names":[],"sources":["../../src/__test-utils__/mocks.ts"],"mappings":";;;;;;;;;iBAYgB,cAAA,CACd,SAAA,GAAY,OAAA,CAAQ,iBAAA,IACnB,iBAAA;AAFH;;;;AAAA,iBAgBgB,cAAA,CAAe,IAAA;EAC7B,aAAA;AAAA,IACE,cAAA;;;;UAiBM,gBAAA;EACR,QAAA;IAAa,KAAA;IAAe,MAAA;EAAA;EAC5B,aAAA;IACE,gBAAA;IACA,iBAAA;IACA,eAAA;MAAmB,KAAA;MAAe,MAAA;IAAA;EAAA;EAEpC,qBAAA;IAA0B,KAAA;IAAe,MAAA;EAAA;EACzC,8BAAA;IAAmC,KAAA;IAAe,MAAA;EAAA;EAClD,cAAA;IACE,cAAA;MAAkB,KAAA;MAAe,MAAA;IAAA;IACjC,kBAAA;MAAsB,KAAA;MAAe,MAAA;IAAA;IACrC,wBAAA;IACA,gBAAA;EAAA;EAEF,KAAA;IACE,IAAA;IACA,KAAA,EAAO,UAAA;IACP,YAAA;IACA,SAAA,GAAY,IAAA;IACZ,QAAA,GAAW,IAAA;EAAA;EA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KAAA;IAAe,MAAA;EAAA;EAClD,cAAA;IACE,cAAA;MAAkB,KAAA;MAAe,MAAA;IAAA;IACjC,kBAAA;MAAsB,KAAA;MAAe,MAAA;IAAA;IACrC,wBAAA;IACA,gBAAA;EAAA;EAEF,KAAA;IACE,IAAA;IACA,KAAA,EAAO,UAAA;IACP,YAAA;IACA,SAAA,GAAY,IAAA;IACZ,QAAA,GAAW,IAAA;EAAA;EAEb,YAAA;IAAiB,IAAA;IAAc,YAAA;IAAsB,SAAA,GAAY,IAAA;EAAA;EACjE,aAAA;IAAkB,IAAA;IAAc,YAAA;IAAsB,SAAA,GAAY,IAAA;EAAA;EAClE,YAAA;IAAiB,IAAA;IAAc,YAAA;IAAsB,SAAA,GAAY,IAAA;EAAA;EACjE,cAAA;IAAmB,IAAA;IAAc,YAAA;IAAsB,SAAA,GAAY,IAAA;EAAA;EACnE,aAAA;IAAkB,IAAA;IAAc,YAAA;IAAsB,SAAA,GAAY,IAAA;EAAA;AAAA;AAAA,UAG1D,YAAA;EACR,SAAA;IACE,IAAA;IACA,OAAA;IACA,MAAA;IACA,MAAA;EAAA;EAEF,IAAA;IACE,IAAA;IACA,IAAA;IACA,YAAA;IACA,SAAA;MAAc,MAAA;MAAgB,KAAA;IAAA;EAAA;EAEhC,cAAA,GAAiB,MAAA;IAAiB,QAAA;MAAY,MAAA;IAAA;EAAA;AAAA;;;;iBAMhC,mBAAA,CAAoB,SAAA;EAClC,OAAA,GAAU,gBAAA;EACV,GAAA,GAAM,YAAA;AAAA,IA4KU,mBAAA;;;;iBAMF,qBAAA,CAAsB,SAAA;EACpC,WAAA,GAAc,mBAAA;EACd,OAAA;EACA,MAAA,GAAS,iBAAA;AAAA;8BAAiB,YAAA,CAAA,SAAA"}
@@ -1,5 +1,5 @@
1
- import { vi } from "../node_modules/vitest/dist/chunks/test.CTcmp4Su.js";
2
1
  import { LeaseState } from "@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js";
2
+ import { vi } from "vitest";
3
3
  //#region src/__test-utils__/mocks.ts
4
4
  /**
5
5
  * Create a mock ManifestMCPConfig with sensible defaults.
package/dist/config.d.ts CHANGED
@@ -12,6 +12,16 @@ declare const DEFAULT_REQUESTS_PER_SECOND = 10;
12
12
  * the --gas-adjustment value used in this project's E2E scripts (e2e/scripts/init_billing.sh).
13
13
  */
14
14
  declare const DEFAULT_GAS_MULTIPLIER = 1.5;
15
+ /**
16
+ * Validate URL format and check if it uses HTTPS or is localhost (HTTP allowed for local dev)
17
+ * Returns validation result with error reason if invalid
18
+ */
19
+ declare function validateEndpointUrl(url: string, label: string): {
20
+ valid: true;
21
+ } | {
22
+ valid: false;
23
+ reason: string;
24
+ };
15
25
  /**
16
26
  * Create a configuration object with defaults applied
17
27
  */
@@ -32,5 +42,5 @@ declare function validateConfig(config: Partial<ManifestMCPConfig>): ValidationR
32
42
  */
33
43
  declare function createValidatedConfig(input: ManifestMCPConfig): ManifestMCPConfig;
34
44
  //#endregion
35
- export { DEFAULT_GAS_MULTIPLIER, DEFAULT_REQUESTS_PER_SECOND, DEFAULT_RETRY_CONFIG, ValidationResult, createConfig, createValidatedConfig, validateConfig };
45
+ export { DEFAULT_GAS_MULTIPLIER, DEFAULT_REQUESTS_PER_SECOND, DEFAULT_RETRY_CONFIG, ValidationResult, createConfig, createValidatedConfig, validateConfig, validateEndpointUrl };
36
46
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;;AAeA;cAAa,2BAAA;;;;AAOb;;cAAa,sBAAA;;AA8Eb;;iBAAgB,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAoB,iBAAA;;;;UAuBvC,gBAAA;EACf,KAAA;EACA,MAAA;AAAA;;;;iBAMc,cAAA,CACd,MAAA,EAAQ,OAAA,CAAQ,iBAAA,IACf,gBAAA;AAFH;;;AAAA,iBAsIgB,qBAAA,CACd,KAAA,EAAO,iBAAA,GACN,iBAAA"}
1
+ {"version":3,"file":"config.d.ts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;;AAeA;cAAa,2BAAA;;;;AAOb;;cAAa,sBAAA;;AAsBb;;;iBAAgB,mBAAA,CACd,GAAA,UACA,KAAA;EACG,KAAA;AAAA;EAAkB,KAAA;EAAc,MAAA;AAAA;;;AAqDrC;iBAAgB,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAoB,iBAAA;;;;UAuBvC,gBAAA;EACf,KAAA;EACA,MAAA;AAAA;AAFF;;;AAAA,iBAQgB,cAAA,CACd,MAAA,EAAQ,OAAA,CAAQ,iBAAA,IACf,gBAAA;;AAFH;;iBAsIgB,qBAAA,CACd,KAAA,EAAO,iBAAA,GACN,iBAAA"}
package/dist/config.js CHANGED
@@ -135,6 +135,6 @@ function createValidatedConfig(input) {
135
135
  return createConfig(input);
136
136
  }
137
137
  //#endregion
138
- export { DEFAULT_GAS_MULTIPLIER, DEFAULT_REQUESTS_PER_SECOND, DEFAULT_RETRY_CONFIG, createConfig, createValidatedConfig, validateConfig };
138
+ export { DEFAULT_GAS_MULTIPLIER, DEFAULT_REQUESTS_PER_SECOND, DEFAULT_RETRY_CONFIG, createConfig, createValidatedConfig, validateConfig, validateEndpointUrl };
139
139
 
140
140
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["import { DEFAULT_RETRY_CONFIG } from './retry.js';\nimport {\n type ManifestMCPConfig,\n ManifestMCPError,\n ManifestMCPErrorCode,\n} from './types.js';\n\n/**\n * Default address prefix for Manifest Network\n */\nconst DEFAULT_ADDRESS_PREFIX = 'manifest';\n\n/**\n * Default requests per second for rate limiting\n */\nexport const DEFAULT_REQUESTS_PER_SECOND = 10;\n\n/**\n * Default gas simulation multiplier. CosmJS defaults to 1.4 but billing module\n * transactions (close-lease in particular) can exceed that. 1.5 matches\n * the --gas-adjustment value used in this project's E2E scripts (e2e/scripts/init_billing.sh).\n */\nexport const DEFAULT_GAS_MULTIPLIER = 1.5;\n\n// Re-export for consumers\nexport { DEFAULT_RETRY_CONFIG };\n\n/**\n * Check if a hostname is localhost (IPv4, IPv6, or hostname)\n * Handles both bracketed and unbracketed IPv6 formats\n */\nfunction isLocalhostHostname(hostname: string): boolean {\n if (hostname === 'localhost' || hostname === '127.0.0.1') {\n return true;\n }\n // Handle IPv6 localhost - hostname may be '::1' or '[::1]' depending on environment\n const normalizedHostname = hostname.replace(/^\\[|\\]$/g, '');\n return normalizedHostname === '::1';\n}\n\n/**\n * Validate URL format and check if it uses HTTPS or is localhost (HTTP allowed for local dev)\n * Returns validation result with error reason if invalid\n */\nfunction validateEndpointUrl(\n url: string,\n label: string,\n): { valid: true } | { valid: false; reason: string } {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return { valid: false, reason: `${label} must be a valid URL` };\n }\n\n if (parsed.protocol === 'https:') {\n return { valid: true };\n }\n\n if (parsed.protocol === 'http:' && isLocalhostHostname(parsed.hostname)) {\n return { valid: true }; // HTTP allowed for localhost\n }\n\n return {\n valid: false,\n reason: `${label} must use HTTPS (got ${parsed.protocol}//). HTTP is only allowed for local development (localhost, 127.0.0.1, ::1).`,\n };\n}\n\n/**\n * Validate gas price format (e.g., \"1.0umfx\")\n */\nfunction isValidGasPrice(gasPrice: string): boolean {\n // Gas price should be a number followed by a denomination.\n // Denoms can be simple (umfx), IBC (ibc/ABC123...), or factory\n // (factory/manifest1.../utoken). Denoms are made of non-empty segments\n // separated by '/', with the first segment starting with a letter.\n // Each segment may contain letters, digits, dots, colons, underscores,\n // and hyphens. Denom length must be 3-128 chars per the Cosmos SDK spec.\n const match = gasPrice.match(\n /^(\\d+(?:\\.\\d+)?)([a-zA-Z][a-zA-Z0-9.:_-]*(?:\\/[a-zA-Z0-9.:_-]+)*)$/,\n );\n if (!match) {\n return false;\n }\n const denom = match[2];\n return denom.length >= 3 && denom.length <= 128;\n}\n\n/**\n * Validate chain ID format\n */\nfunction isValidChainId(chainId: string): boolean {\n // Chain ID should be alphanumeric with hyphens\n return /^[a-zA-Z0-9][\\w-]*$/.test(chainId);\n}\n\n/**\n * Create a configuration object with defaults applied\n */\nexport function createConfig(input: ManifestMCPConfig): ManifestMCPConfig {\n return {\n chainId: input.chainId,\n rpcUrl: input.rpcUrl,\n gasPrice: input.gasPrice,\n restUrl: input.restUrl,\n addressPrefix: input.addressPrefix ?? DEFAULT_ADDRESS_PREFIX,\n rateLimit: {\n requestsPerSecond:\n input.rateLimit?.requestsPerSecond ?? DEFAULT_REQUESTS_PER_SECOND,\n },\n retry: {\n maxRetries: input.retry?.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries,\n baseDelayMs: input.retry?.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs,\n maxDelayMs: input.retry?.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs,\n },\n gasMultiplier: input.gasMultiplier ?? DEFAULT_GAS_MULTIPLIER,\n };\n}\n\n/**\n * Validation result\n */\nexport interface ValidationResult {\n valid: boolean;\n errors: string[];\n}\n\n/**\n * Validate a configuration object\n */\nexport function validateConfig(\n config: Partial<ManifestMCPConfig>,\n): ValidationResult {\n const errors: string[] = [];\n\n // Required fields\n if (!config.chainId) {\n errors.push('chainId is required');\n } else if (!isValidChainId(config.chainId)) {\n errors.push(\n 'chainId must be alphanumeric with hyphens (e.g., \"manifest-ledger-testnet\")',\n );\n }\n\n // At least one of rpcUrl or restUrl must be provided\n if (!config.rpcUrl && !config.restUrl) {\n errors.push('At least one of rpcUrl or restUrl is required');\n }\n\n if (config.rpcUrl) {\n const urlCheck = validateEndpointUrl(config.rpcUrl, 'rpcUrl');\n if (!urlCheck.valid) {\n errors.push(urlCheck.reason);\n }\n }\n\n if (config.restUrl) {\n const urlCheck = validateEndpointUrl(config.restUrl, 'restUrl');\n if (!urlCheck.valid) {\n errors.push(urlCheck.reason);\n }\n }\n\n // gasPrice required when rpcUrl is provided (needed for signing)\n if (config.rpcUrl && !config.gasPrice) {\n errors.push('gasPrice is required when rpcUrl is provided');\n } else if (config.gasPrice && !isValidGasPrice(config.gasPrice)) {\n errors.push(\n 'gasPrice must be a number followed by denomination (e.g., \"1.0umfx\", \"0.5factory/addr/udenom\", or \"0.25ibc/ABC123\")',\n );\n }\n\n // Optional fields\n if (config.addressPrefix !== undefined) {\n if (!/^[a-z]+$/.test(config.addressPrefix)) {\n errors.push('addressPrefix must be lowercase letters only');\n }\n }\n\n if (config.rateLimit !== undefined) {\n if (\n typeof config.rateLimit !== 'object' ||\n config.rateLimit === null ||\n Array.isArray(config.rateLimit)\n ) {\n errors.push('rateLimit must be a plain object');\n } else if (config.rateLimit.requestsPerSecond !== undefined) {\n if (\n typeof config.rateLimit.requestsPerSecond !== 'number' ||\n config.rateLimit.requestsPerSecond <= 0 ||\n !Number.isInteger(config.rateLimit.requestsPerSecond)\n ) {\n errors.push('rateLimit.requestsPerSecond must be a positive integer');\n }\n }\n }\n\n if (config.retry !== undefined) {\n if (\n typeof config.retry !== 'object' ||\n config.retry === null ||\n Array.isArray(config.retry)\n ) {\n errors.push('retry must be a plain object');\n } else {\n if (config.retry.maxRetries !== undefined) {\n if (\n typeof config.retry.maxRetries !== 'number' ||\n config.retry.maxRetries < 0 ||\n !Number.isInteger(config.retry.maxRetries)\n ) {\n errors.push('retry.maxRetries must be a non-negative integer');\n }\n }\n if (config.retry.baseDelayMs !== undefined) {\n if (\n typeof config.retry.baseDelayMs !== 'number' ||\n config.retry.baseDelayMs <= 0 ||\n !Number.isInteger(config.retry.baseDelayMs)\n ) {\n errors.push('retry.baseDelayMs must be a positive integer');\n }\n }\n if (config.retry.maxDelayMs !== undefined) {\n if (\n typeof config.retry.maxDelayMs !== 'number' ||\n config.retry.maxDelayMs <= 0 ||\n !Number.isInteger(config.retry.maxDelayMs)\n ) {\n errors.push('retry.maxDelayMs must be a positive integer');\n }\n }\n // Validate maxDelayMs >= baseDelayMs if both are provided\n if (\n config.retry.baseDelayMs !== undefined &&\n config.retry.maxDelayMs !== undefined &&\n config.retry.maxDelayMs < config.retry.baseDelayMs\n ) {\n errors.push(\n 'retry.maxDelayMs must be greater than or equal to retry.baseDelayMs',\n );\n }\n }\n }\n\n if (config.gasMultiplier !== undefined) {\n if (\n typeof config.gasMultiplier !== 'number' ||\n !Number.isFinite(config.gasMultiplier) ||\n config.gasMultiplier < 1\n ) {\n errors.push('gasMultiplier must be a finite number >= 1');\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n };\n}\n\n/**\n * Create and validate a configuration, throwing on invalid config\n */\nexport function createValidatedConfig(\n input: ManifestMCPConfig,\n): ManifestMCPConfig {\n const validation = validateConfig(input);\n\n if (!validation.valid) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n `Invalid configuration: ${validation.errors.join(', ')}`,\n { errors: validation.errors },\n );\n }\n\n return createConfig(input);\n}\n"],"mappings":";;;;;;AAUA,MAAM,yBAAyB;;;;AAK/B,MAAa,8BAA8B;;;;;;AAO3C,MAAa,yBAAyB;;;;;AAStC,SAAS,oBAAoB,UAA2B;AACtD,KAAI,aAAa,eAAe,aAAa,YAC3C,QAAO;AAIT,QAD2B,SAAS,QAAQ,YAAY,GAAG,KAC7B;;;;;;AAOhC,SAAS,oBACP,KACA,OACoD;CACpD,IAAI;AACJ,KAAI;AACF,WAAS,IAAI,IAAI,IAAI;SACf;AACN,SAAO;GAAE,OAAO;GAAO,QAAQ,GAAG,MAAM;GAAuB;;AAGjE,KAAI,OAAO,aAAa,SACtB,QAAO,EAAE,OAAO,MAAM;AAGxB,KAAI,OAAO,aAAa,WAAW,oBAAoB,OAAO,SAAS,CACrE,QAAO,EAAE,OAAO,MAAM;AAGxB,QAAO;EACL,OAAO;EACP,QAAQ,GAAG,MAAM,uBAAuB,OAAO,SAAS;EACzD;;;;;AAMH,SAAS,gBAAgB,UAA2B;CAOlD,MAAM,QAAQ,SAAS,MACrB,qEACD;AACD,KAAI,CAAC,MACH,QAAO;CAET,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AAMH,SAAgB,sBACd,OACmB;CACnB,MAAM,aAAa,eAAe,MAAM;AAExC,KAAI,CAAC,WAAW,MACd,OAAM,IAAI,iBACR,qBAAqB,gBACrB,0BAA0B,WAAW,OAAO,KAAK,KAAK,IACtD,EAAE,QAAQ,WAAW,QAAQ,CAC9B;AAGH,QAAO,aAAa,MAAM"}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["import { DEFAULT_RETRY_CONFIG } from './retry.js';\nimport {\n type ManifestMCPConfig,\n ManifestMCPError,\n ManifestMCPErrorCode,\n} from './types.js';\n\n/**\n * Default address prefix for Manifest Network\n */\nconst DEFAULT_ADDRESS_PREFIX = 'manifest';\n\n/**\n * Default requests per second for rate limiting\n */\nexport const DEFAULT_REQUESTS_PER_SECOND = 10;\n\n/**\n * Default gas simulation multiplier. CosmJS defaults to 1.4 but billing module\n * transactions (close-lease in particular) can exceed that. 1.5 matches\n * the --gas-adjustment value used in this project's E2E scripts (e2e/scripts/init_billing.sh).\n */\nexport const DEFAULT_GAS_MULTIPLIER = 1.5;\n\n// Re-export for consumers\nexport { DEFAULT_RETRY_CONFIG };\n\n/**\n * Check if a hostname is localhost (IPv4, IPv6, or hostname)\n * Handles both bracketed and unbracketed IPv6 formats\n */\nfunction isLocalhostHostname(hostname: string): boolean {\n if (hostname === 'localhost' || hostname === '127.0.0.1') {\n return true;\n }\n // Handle IPv6 localhost - hostname may be '::1' or '[::1]' depending on environment\n const normalizedHostname = hostname.replace(/^\\[|\\]$/g, '');\n return normalizedHostname === '::1';\n}\n\n/**\n * Validate URL format and check if it uses HTTPS or is localhost (HTTP allowed for local dev)\n * Returns validation result with error reason if invalid\n */\nexport function validateEndpointUrl(\n url: string,\n label: string,\n): { valid: true } | { valid: false; reason: string } {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return { valid: false, reason: `${label} must be a valid URL` };\n }\n\n if (parsed.protocol === 'https:') {\n return { valid: true };\n }\n\n if (parsed.protocol === 'http:' && isLocalhostHostname(parsed.hostname)) {\n return { valid: true }; // HTTP allowed for localhost\n }\n\n return {\n valid: false,\n reason: `${label} must use HTTPS (got ${parsed.protocol}//). HTTP is only allowed for local development (localhost, 127.0.0.1, ::1).`,\n };\n}\n\n/**\n * Validate gas price format (e.g., \"1.0umfx\")\n */\nfunction isValidGasPrice(gasPrice: string): boolean {\n // Gas price should be a number followed by a denomination.\n // Denoms can be simple (umfx), IBC (ibc/ABC123...), or factory\n // (factory/manifest1.../utoken). Denoms are made of non-empty segments\n // separated by '/', with the first segment starting with a letter.\n // Each segment may contain letters, digits, dots, colons, underscores,\n // and hyphens. Denom length must be 3-128 chars per the Cosmos SDK spec.\n const match = gasPrice.match(\n /^(\\d+(?:\\.\\d+)?)([a-zA-Z][a-zA-Z0-9.:_-]*(?:\\/[a-zA-Z0-9.:_-]+)*)$/,\n );\n if (!match) {\n return false;\n }\n const denom = match[2];\n return denom.length >= 3 && denom.length <= 128;\n}\n\n/**\n * Validate chain ID format\n */\nfunction isValidChainId(chainId: string): boolean {\n // Chain ID should be alphanumeric with hyphens\n return /^[a-zA-Z0-9][\\w-]*$/.test(chainId);\n}\n\n/**\n * Create a configuration object with defaults applied\n */\nexport function createConfig(input: ManifestMCPConfig): ManifestMCPConfig {\n return {\n chainId: input.chainId,\n rpcUrl: input.rpcUrl,\n gasPrice: input.gasPrice,\n restUrl: input.restUrl,\n addressPrefix: input.addressPrefix ?? DEFAULT_ADDRESS_PREFIX,\n rateLimit: {\n requestsPerSecond:\n input.rateLimit?.requestsPerSecond ?? DEFAULT_REQUESTS_PER_SECOND,\n },\n retry: {\n maxRetries: input.retry?.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries,\n baseDelayMs: input.retry?.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs,\n maxDelayMs: input.retry?.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs,\n },\n gasMultiplier: input.gasMultiplier ?? DEFAULT_GAS_MULTIPLIER,\n };\n}\n\n/**\n * Validation result\n */\nexport interface ValidationResult {\n valid: boolean;\n errors: string[];\n}\n\n/**\n * Validate a configuration object\n */\nexport function validateConfig(\n config: Partial<ManifestMCPConfig>,\n): ValidationResult {\n const errors: string[] = [];\n\n // Required fields\n if (!config.chainId) {\n errors.push('chainId is required');\n } else if (!isValidChainId(config.chainId)) {\n errors.push(\n 'chainId must be alphanumeric with hyphens (e.g., \"manifest-ledger-testnet\")',\n );\n }\n\n // At least one of rpcUrl or restUrl must be provided\n if (!config.rpcUrl && !config.restUrl) {\n errors.push('At least one of rpcUrl or restUrl is required');\n }\n\n if (config.rpcUrl) {\n const urlCheck = validateEndpointUrl(config.rpcUrl, 'rpcUrl');\n if (!urlCheck.valid) {\n errors.push(urlCheck.reason);\n }\n }\n\n if (config.restUrl) {\n const urlCheck = validateEndpointUrl(config.restUrl, 'restUrl');\n if (!urlCheck.valid) {\n errors.push(urlCheck.reason);\n }\n }\n\n // gasPrice required when rpcUrl is provided (needed for signing)\n if (config.rpcUrl && !config.gasPrice) {\n errors.push('gasPrice is required when rpcUrl is provided');\n } else if (config.gasPrice && !isValidGasPrice(config.gasPrice)) {\n errors.push(\n 'gasPrice must be a number followed by denomination (e.g., \"1.0umfx\", \"0.5factory/addr/udenom\", or \"0.25ibc/ABC123\")',\n );\n }\n\n // Optional fields\n if (config.addressPrefix !== undefined) {\n if (!/^[a-z]+$/.test(config.addressPrefix)) {\n errors.push('addressPrefix must be lowercase letters only');\n }\n }\n\n if (config.rateLimit !== undefined) {\n if (\n typeof config.rateLimit !== 'object' ||\n config.rateLimit === null ||\n Array.isArray(config.rateLimit)\n ) {\n errors.push('rateLimit must be a plain object');\n } else if (config.rateLimit.requestsPerSecond !== undefined) {\n if (\n typeof config.rateLimit.requestsPerSecond !== 'number' ||\n config.rateLimit.requestsPerSecond <= 0 ||\n !Number.isInteger(config.rateLimit.requestsPerSecond)\n ) {\n errors.push('rateLimit.requestsPerSecond must be a positive integer');\n }\n }\n }\n\n if (config.retry !== undefined) {\n if (\n typeof config.retry !== 'object' ||\n config.retry === null ||\n Array.isArray(config.retry)\n ) {\n errors.push('retry must be a plain object');\n } else {\n if (config.retry.maxRetries !== undefined) {\n if (\n typeof config.retry.maxRetries !== 'number' ||\n config.retry.maxRetries < 0 ||\n !Number.isInteger(config.retry.maxRetries)\n ) {\n errors.push('retry.maxRetries must be a non-negative integer');\n }\n }\n if (config.retry.baseDelayMs !== undefined) {\n if (\n typeof config.retry.baseDelayMs !== 'number' ||\n config.retry.baseDelayMs <= 0 ||\n !Number.isInteger(config.retry.baseDelayMs)\n ) {\n errors.push('retry.baseDelayMs must be a positive integer');\n }\n }\n if (config.retry.maxDelayMs !== undefined) {\n if (\n typeof config.retry.maxDelayMs !== 'number' ||\n config.retry.maxDelayMs <= 0 ||\n !Number.isInteger(config.retry.maxDelayMs)\n ) {\n errors.push('retry.maxDelayMs must be a positive integer');\n }\n }\n // Validate maxDelayMs >= baseDelayMs if both are provided\n if (\n config.retry.baseDelayMs !== undefined &&\n config.retry.maxDelayMs !== undefined &&\n config.retry.maxDelayMs < config.retry.baseDelayMs\n ) {\n errors.push(\n 'retry.maxDelayMs must be greater than or equal to retry.baseDelayMs',\n );\n }\n }\n }\n\n if (config.gasMultiplier !== undefined) {\n if (\n typeof config.gasMultiplier !== 'number' ||\n !Number.isFinite(config.gasMultiplier) ||\n config.gasMultiplier < 1\n ) {\n errors.push('gasMultiplier must be a finite number >= 1');\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n };\n}\n\n/**\n * Create and validate a configuration, throwing on invalid config\n */\nexport function createValidatedConfig(\n input: ManifestMCPConfig,\n): ManifestMCPConfig {\n const validation = validateConfig(input);\n\n if (!validation.valid) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n `Invalid configuration: ${validation.errors.join(', ')}`,\n { errors: validation.errors },\n );\n }\n\n return createConfig(input);\n}\n"],"mappings":";;;;;;AAUA,MAAM,yBAAyB;;;;AA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AgB,KAAA;OAE7B,OAAO,OAAO,MAAM,gBAAgB,YACpC,OAAO,MAAM,eAAe,KAC5B,CAAC,OAAO,UAAU,OAAO,MAAM,YAAY,CAE3C,QAAO,KAAK,+CAA+C;;AAG/D,MAAI,OAAO,MAAM,eAAe,KAAA;OAE5B,OAAO,OAAO,MAAM,eAAe,YACnC,OAAO,MAAM,cAAc,KAC3B,CAAC,OAAO,UAAU,OAAO,MAAM,WAAW,CAE1C,QAAO,KAAK,8CAA8C;;AAI9D,MACE,OAAO,MAAM,gBAAgB,KAAA,KAC7B,OAAO,MAAM,eAAe,KAAA,KAC5B,OAAO,MAAM,aAAa,OAAO,MAAM,YAEvC,QAAO,KACL,sEACD;;AAKP,KAAI,OAAO,kBAAkB,KAAA;MAEzB,OAAO,OAAO,kBAAkB,YAChC,CAAC,OAAO,SAAS,OAAO,cAAc,IACtC,OAAO,gBAAgB,EAEvB,QAAO,KAAK,6CAA6C;;AAI7D,QAAO;EACL,OAAO,OAAO,WAAW;EACzB;EACD;;;;;AAMH,SAAgB,sBACd,OACmB;CACnB,MAAM,aAAa,eAAe,MAAM;AAExC,KAAI,CAAC,WAAW,MACd,OAAM,IAAI,iBACR,qBAAqB,gBACrB,0BAA0B,WAAW,OAAO,KAAK,KAAK,IACtD,EAAE,QAAQ,WAAW,QAAQ,CAC9B;AAGH,QAAO,aAAa,MAAM"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AccountInfo, AccountInfoResult, AddressBytesToStringResult, AddressStringToBytesResult, Any, AuthAccountResult, AuthAccountsResult, AuthParams, AuthParamsResult, AuthzGrant, AuthzGrantAuthorization, AuthzGranteeGrantsResult, AuthzGranterGrantsResult, AuthzGrantsResult, AvailableModules, BalanceResult, BalancesResult, BankMetadata, BankParams, BankParamsResult, BaseAccount, Bech32PrefixResult, BillingParams, BillingParamsResult, BuiltMessages, CodeInfoResponse, Coin, CommissionResult, CommunityPoolResult, ContractCodeHistoryEntry, ContractInfo, CosmosQueryResult, CosmosTxResult, CreditAccount, CreditAccountResult, CreditAccountsResult, CreditAddressResult, CreditEstimateResult, DecCoin, DelegationDelegatorReward, DelegationResponse, DelegationResult, DelegationsResult, DelegatorValidatorsResult, DelegatorWithdrawAddressResult, DenomAuthorityMetadata, DenomAuthorityMetadataResult, DenomMetadataResult, DenomTrace, DenomsFromAdminResult, DenomsFromCreatorResult, DenomsMetadataResult, DepositParams, DepositResult, DepositsResult, DistributionParams, DistributionParamsResult, FeeEstimateResult, FeegrantAllowanceResult, FeegrantAllowancesResult, FeegrantGrant, GovDeposit, GovParams, GovParamsResult, GovProposal, GovTallyResult, GovVote, GroupInfo, GroupInfoResult, GroupMember, GroupMembersResult, GroupPoliciesResult, GroupPolicyInfo, GroupPolicyInfoResult, GroupProposal, GroupProposalResult, GroupProposalsResult, GroupTallyQueryResult, GroupTallyResult, GroupVote, GroupVoteResult, GroupVotesResult, GroupsResult, HistoricalInfo, HistoricalInfoResult, IbcDenomTraceResult, IbcDenomTracesResult, IbcTransferParams, IbcTransferParamsResult, Lease, LeaseByCustomDomainResult, LeaseItemInput, LeaseResult, LeasesResult, ManifestMCPConfig, ManifestMCPError, ManifestMCPErrorCode, MintAnnualProvisionsResult, MintInflationResult, MintParams, MintParamsResult, Model, ModuleAccount, ModuleAccountsResult, ModuleInfo, PaginatedResult, PaginationResponse, PoAAuthorityResult, PoAConsensusPowerResult, PoAPendingValidatorsResult, PoAStakingParams, PoAValidator, ProposalResult, ProposalsResult, Provider, ProviderResult, ProviderWithdrawableResult, ProvidersResult, QueryCreditEstimateResponse, QueryResult, RateLimitConfig, RedelegationResponse, RedelegationsResult, RetryConfig, RewardsResult, SKU, SendEnabled, SendEnabledResult, SignArbitraryResult, SkuParams, SkuParamsResult, SkuResult, SkusResult, SlashesResult, StakingParams, StakingParamsResult, StakingPool, StakingPoolResult, SupplyOfResult, TallyParams, TallyResult, TokenfactoryParams, TokenfactoryParamsResult, TotalSupplyResult, TxBuildContext, TxOptions, TxOverrides, UnbondingDelegation, UnbondingDelegationResult, UnbondingDelegationsResult, Validator, ValidatorAccumulatedCommission, ValidatorOutstandingRewards, ValidatorOutstandingRewardsResult, ValidatorResult, ValidatorSlashEvent, ValidatorsResult, VoteResult, VotesResult, VotingParams, WalletProvider, WasmAllContractStateResult, WasmBuildAddressResult, WasmCodeInfo, WasmCodeInfoResult, WasmCodeResult, WasmCodesResult, WasmContractHistoryResult, WasmContractInfoResult, WasmContractsByCodeResult, WasmContractsByCreatorResult, WasmLimitsConfigResult, WasmParams, WasmParamsResult, WasmPinnedCodesResult, WasmRawContractStateResult, WasmSmartContractStateResult, WithdrawableAmountResult } from "./types.js";
2
2
  import { CosmosClientManager, ManifestQueryClient } from "./client.js";
3
3
  import { DEFAULT_RETRY_CONFIG, RetryOptions, calculateBackoff, isRetryableError, withRetry } from "./retry.js";
4
- import { ValidationResult, createConfig, createValidatedConfig, validateConfig } from "./config.js";
4
+ import { ValidationResult, createConfig, createValidatedConfig, validateConfig, validateEndpointUrl } from "./config.js";
5
5
  import { cosmosEstimateFee, cosmosQuery, cosmosTx } from "./cosmos.js";
6
6
  import { createLCDQueryClient } from "./lcd-adapter.js";
7
7
  import { LogLevel, logger, parseLogLevel } from "./logger.js";
@@ -19,4 +19,4 @@ import { VERSION } from "./version.js";
19
19
  import { MnemonicWalletProvider } from "./wallet/mnemonic.js";
20
20
  import { signArbitraryWithAmino } from "./wallet/sign-arbitrary.js";
21
21
  import { LeaseState, leaseStateFromJSON, leaseStateToJSON } from "@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js";
22
- export { AccountInfo, AccountInfoResult, AddressBytesToStringResult, AddressStringToBytesResult, Any, AuthAccountResult, AuthAccountsResult, AuthParams, AuthParamsResult, AuthzGrant, AuthzGrantAuthorization, AuthzGranteeGrantsResult, AuthzGranterGrantsResult, AuthzGrantsResult, AvailableModules, BalanceResult, BalancesResult, BankMetadata, BankParams, BankParamsResult, BaseAccount, Bech32PrefixResult, BillingParams, BillingParamsResult, BuiltMessages, CodeInfoResponse, Coin, CommissionResult, CommunityPoolResult, ContractCodeHistoryEntry, ContractInfo, CosmosClientManager, CosmosQueryResult, CosmosTxResult, CreditAccount, CreditAccountResult, CreditAccountsResult, CreditAddressResult, CreditEstimateResult, DEFAULT_RETRY_CONFIG, DNS_LABEL_RE, DecCoin, DelegationDelegatorReward, DelegationResponse, DelegationResult, DelegationsResult, DelegatorValidatorsResult, DelegatorWithdrawAddressResult, DenomAuthorityMetadata, DenomAuthorityMetadataResult, DenomMetadataResult, DenomTrace, DenomsFromAdminResult, DenomsFromCreatorResult, DenomsMetadataResult, DepositParams, DepositResult, DepositsResult, DistributionParams, DistributionParamsResult, FeeEstimateResult, FeegrantAllowanceResult, FeegrantAllowancesResult, FeegrantGrant, type FundCreditsResult, GovDeposit, GovParams, GovParamsResult, GovProposal, GovTallyResult, GovVote, GroupInfo, GroupInfoResult, GroupMember, GroupMembersResult, GroupPoliciesResult, GroupPolicyInfo, GroupPolicyInfoResult, GroupProposal, GroupProposalResult, GroupProposalsResult, GroupTallyQueryResult, GroupTallyResult, GroupVote, GroupVoteResult, GroupVotesResult, GroupsResult, HistoricalInfo, HistoricalInfoResult, INFRASTRUCTURE_ERROR_CODES, IbcDenomTraceResult, IbcDenomTracesResult, IbcTransferParams, IbcTransferParamsResult, Lease, LeaseByCustomDomainResult, LeaseItemInput, LeaseResult, LeaseState, LeasesResult, type LogLevel, MANIFEST_TOOL_META_VERSION, MAX_PAGE_LIMIT, ManifestMCPConfig, ManifestMCPError, ManifestMCPErrorCode, type ManifestMCPServerOptions, type ManifestQueryClient, type ManifestToolMeta, type ManifestToolMetaContainer, type ManifestToolMetaVersion, MintAnnualProvisionsResult, MintInflationResult, MintParams, MintParamsResult, type MnemonicServerConfig, MnemonicWalletProvider, Model, ModuleAccount, ModuleAccountsResult, ModuleInfo, PaginatedResult, PaginationResponse, PoAAuthorityResult, PoAConsensusPowerResult, PoAPendingValidatorsResult, PoAStakingParams, PoAValidator, ProposalResult, ProposalsResult, Provider, ProviderResult, ProviderWithdrawableResult, ProvidersResult, QueryCreditEstimateResponse, QueryResult, RateLimitConfig, RedelegationResponse, RedelegationsResult, RetryConfig, type RetryOptions, RewardsResult, SENSITIVE_FIELDS, SKU, SendEnabled, SendEnabledResult, type SetItemCustomDomainOptions, type SetItemCustomDomainResult, SignArbitraryResult, SkuParams, SkuParamsResult, SkuResult, SkusResult, SlashesResult, StakingParams, StakingParamsResult, StakingPool, StakingPoolResult, type StopAppResult, SupplyOfResult, TallyParams, TallyResult, TokenfactoryParams, TokenfactoryParamsResult, TotalSupplyResult, TxBuildContext, TxOptions, TxOverrides, UnbondingDelegation, UnbondingDelegationResult, UnbondingDelegationsResult, VERSION, type ValidationResult, Validator, ValidatorAccumulatedCommission, ValidatorOutstandingRewards, ValidatorOutstandingRewardsResult, ValidatorResult, ValidatorSlashEvent, ValidatorsResult, VoteResult, VotesResult, VotingParams, WalletProvider, WasmAllContractStateResult, WasmBuildAddressResult, WasmCodeInfo, WasmCodeInfoResult, WasmCodeResult, WasmCodesResult, WasmContractHistoryResult, WasmContractInfoResult, WasmContractsByCodeResult, WasmContractsByCreatorResult, WasmLimitsConfigResult, WasmParams, WasmParamsResult, WasmPinnedCodesResult, WasmRawContractStateResult, WasmSmartContractStateResult, WithdrawableAmountResult, bigIntReplacer, calculateBackoff, cosmosEstimateFee, cosmosQuery, cosmosTx, createConfig, createLCDQueryClient, createMnemonicServer, createPagination, createValidatedConfig, fundCredits, getAvailableModules, getBalance, getModuleSubcommands, getSubcommandUsage, getSupportedModules, isRetryableError, isSubcommandSupported, jsonResponse, leaseStateFromJSON, leaseStateToJSON, logger, manifestMeta, mutatingAnnotations, optionalBoolean, parseArgs, parseLogLevel, readOnlyAnnotations, requireString, requireStringEnum, requireUuid, sanitizeForLogging, setItemCustomDomain, signArbitraryWithAmino, stopApp, structuredResponse, validateAddress, validateConfig, withErrorHandling, withRetry };
22
+ export { AccountInfo, AccountInfoResult, AddressBytesToStringResult, AddressStringToBytesResult, Any, AuthAccountResult, AuthAccountsResult, AuthParams, AuthParamsResult, AuthzGrant, AuthzGrantAuthorization, AuthzGranteeGrantsResult, AuthzGranterGrantsResult, AuthzGrantsResult, AvailableModules, BalanceResult, BalancesResult, BankMetadata, BankParams, BankParamsResult, BaseAccount, Bech32PrefixResult, BillingParams, BillingParamsResult, BuiltMessages, CodeInfoResponse, Coin, CommissionResult, CommunityPoolResult, ContractCodeHistoryEntry, ContractInfo, CosmosClientManager, CosmosQueryResult, CosmosTxResult, CreditAccount, CreditAccountResult, CreditAccountsResult, CreditAddressResult, CreditEstimateResult, DEFAULT_RETRY_CONFIG, DNS_LABEL_RE, DecCoin, DelegationDelegatorReward, DelegationResponse, DelegationResult, DelegationsResult, DelegatorValidatorsResult, DelegatorWithdrawAddressResult, DenomAuthorityMetadata, DenomAuthorityMetadataResult, DenomMetadataResult, DenomTrace, DenomsFromAdminResult, DenomsFromCreatorResult, DenomsMetadataResult, DepositParams, DepositResult, DepositsResult, DistributionParams, DistributionParamsResult, FeeEstimateResult, FeegrantAllowanceResult, FeegrantAllowancesResult, FeegrantGrant, type FundCreditsResult, GovDeposit, GovParams, GovParamsResult, GovProposal, GovTallyResult, GovVote, GroupInfo, GroupInfoResult, GroupMember, GroupMembersResult, GroupPoliciesResult, GroupPolicyInfo, GroupPolicyInfoResult, GroupProposal, GroupProposalResult, GroupProposalsResult, GroupTallyQueryResult, GroupTallyResult, GroupVote, GroupVoteResult, GroupVotesResult, GroupsResult, HistoricalInfo, HistoricalInfoResult, INFRASTRUCTURE_ERROR_CODES, IbcDenomTraceResult, IbcDenomTracesResult, IbcTransferParams, IbcTransferParamsResult, Lease, LeaseByCustomDomainResult, LeaseItemInput, LeaseResult, LeaseState, LeasesResult, type LogLevel, MANIFEST_TOOL_META_VERSION, MAX_PAGE_LIMIT, ManifestMCPConfig, ManifestMCPError, ManifestMCPErrorCode, type ManifestMCPServerOptions, type ManifestQueryClient, type ManifestToolMeta, type ManifestToolMetaContainer, type ManifestToolMetaVersion, MintAnnualProvisionsResult, MintInflationResult, MintParams, MintParamsResult, type MnemonicServerConfig, MnemonicWalletProvider, Model, ModuleAccount, ModuleAccountsResult, ModuleInfo, PaginatedResult, PaginationResponse, PoAAuthorityResult, PoAConsensusPowerResult, PoAPendingValidatorsResult, PoAStakingParams, PoAValidator, ProposalResult, ProposalsResult, Provider, ProviderResult, ProviderWithdrawableResult, ProvidersResult, QueryCreditEstimateResponse, QueryResult, RateLimitConfig, RedelegationResponse, RedelegationsResult, RetryConfig, type RetryOptions, RewardsResult, SENSITIVE_FIELDS, SKU, SendEnabled, SendEnabledResult, type SetItemCustomDomainOptions, type SetItemCustomDomainResult, SignArbitraryResult, SkuParams, SkuParamsResult, SkuResult, SkusResult, SlashesResult, StakingParams, StakingParamsResult, StakingPool, StakingPoolResult, type StopAppResult, SupplyOfResult, TallyParams, TallyResult, TokenfactoryParams, TokenfactoryParamsResult, TotalSupplyResult, TxBuildContext, TxOptions, TxOverrides, UnbondingDelegation, UnbondingDelegationResult, UnbondingDelegationsResult, VERSION, type ValidationResult, Validator, ValidatorAccumulatedCommission, ValidatorOutstandingRewards, ValidatorOutstandingRewardsResult, ValidatorResult, ValidatorSlashEvent, ValidatorsResult, VoteResult, VotesResult, VotingParams, WalletProvider, WasmAllContractStateResult, WasmBuildAddressResult, WasmCodeInfo, WasmCodeInfoResult, WasmCodeResult, WasmCodesResult, WasmContractHistoryResult, WasmContractInfoResult, WasmContractsByCodeResult, WasmContractsByCreatorResult, WasmLimitsConfigResult, WasmParams, WasmParamsResult, WasmPinnedCodesResult, WasmRawContractStateResult, WasmSmartContractStateResult, WithdrawableAmountResult, bigIntReplacer, calculateBackoff, cosmosEstimateFee, cosmosQuery, cosmosTx, createConfig, createLCDQueryClient, createMnemonicServer, createPagination, createValidatedConfig, fundCredits, getAvailableModules, getBalance, getModuleSubcommands, getSubcommandUsage, getSupportedModules, isRetryableError, isSubcommandSupported, jsonResponse, leaseStateFromJSON, leaseStateToJSON, logger, manifestMeta, mutatingAnnotations, optionalBoolean, parseArgs, parseLogLevel, readOnlyAnnotations, requireString, requireStringEnum, requireUuid, sanitizeForLogging, setItemCustomDomain, signArbitraryWithAmino, stopApp, structuredResponse, validateAddress, validateConfig, validateEndpointUrl, withErrorHandling, withRetry };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ManifestMCPError, ManifestMCPErrorCode } from "./types.js";
2
2
  import { DEFAULT_RETRY_CONFIG, calculateBackoff, isRetryableError, withRetry } from "./retry.js";
3
- import { createConfig, createValidatedConfig, validateConfig } from "./config.js";
3
+ import { createConfig, createValidatedConfig, validateConfig, validateEndpointUrl } from "./config.js";
4
4
  import { logger, parseLogLevel } from "./logger.js";
5
5
  import { createLCDQueryClient } from "./lcd-adapter.js";
6
6
  import { CosmosClientManager } from "./client.js";
@@ -20,4 +20,4 @@ import { setItemCustomDomain } from "./tools/setItemCustomDomain.js";
20
20
  import { stopApp } from "./tools/stopApp.js";
21
21
  import { VERSION } from "./version.js";
22
22
  import { LeaseState, leaseStateFromJSON, leaseStateToJSON } from "@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js";
23
- export { CosmosClientManager, DEFAULT_RETRY_CONFIG, DNS_LABEL_RE, INFRASTRUCTURE_ERROR_CODES, LeaseState, MANIFEST_TOOL_META_VERSION, MAX_PAGE_LIMIT, ManifestMCPError, ManifestMCPErrorCode, MnemonicWalletProvider, SENSITIVE_FIELDS, VERSION, bigIntReplacer, calculateBackoff, cosmosEstimateFee, cosmosQuery, cosmosTx, createConfig, createLCDQueryClient, createMnemonicServer, createPagination, createValidatedConfig, fundCredits, getAvailableModules, getBalance, getModuleSubcommands, getSubcommandUsage, getSupportedModules, isRetryableError, isSubcommandSupported, jsonResponse, leaseStateFromJSON, leaseStateToJSON, logger, manifestMeta, mutatingAnnotations, optionalBoolean, parseArgs, parseLogLevel, readOnlyAnnotations, requireString, requireStringEnum, requireUuid, sanitizeForLogging, setItemCustomDomain, signArbitraryWithAmino, stopApp, structuredResponse, validateAddress, validateConfig, withErrorHandling, withRetry };
23
+ export { CosmosClientManager, DEFAULT_RETRY_CONFIG, DNS_LABEL_RE, INFRASTRUCTURE_ERROR_CODES, LeaseState, MANIFEST_TOOL_META_VERSION, MAX_PAGE_LIMIT, ManifestMCPError, ManifestMCPErrorCode, MnemonicWalletProvider, SENSITIVE_FIELDS, VERSION, bigIntReplacer, calculateBackoff, cosmosEstimateFee, cosmosQuery, cosmosTx, createConfig, createLCDQueryClient, createMnemonicServer, createPagination, createValidatedConfig, fundCredits, getAvailableModules, getBalance, getModuleSubcommands, getSubcommandUsage, getSupportedModules, isRetryableError, isSubcommandSupported, jsonResponse, leaseStateFromJSON, leaseStateToJSON, logger, manifestMeta, mutatingAnnotations, optionalBoolean, parseArgs, parseLogLevel, readOnlyAnnotations, requireString, requireStringEnum, requireUuid, sanitizeForLogging, setItemCustomDomain, signArbitraryWithAmino, stopApp, structuredResponse, validateAddress, validateConfig, validateEndpointUrl, withErrorHandling, withRetry };
@@ -43,7 +43,9 @@ declare function jsonResponse(data: unknown, replacer?: (key: string, value: any
43
43
  * (consumed by clients that validate against the tool's outputSchema) and
44
44
  * `content` (text fallback for clients that don't). Use this for any tool
45
45
  * registered with an `outputSchema`. Per MCP spec, `structuredContent` must
46
- * be a JSON object — `data` is therefore typed as a record.
46
+ * be a JSON object — `data` is typed as `unknown` so callers don't need to
47
+ * widen typed result interfaces with double-casts; the runtime contract
48
+ * (object-shaped after JSON round-trip) is enforced below.
47
49
  *
48
50
  * The optional `replacer` is applied to BOTH `structuredContent` and the
49
51
  * text fallback by round-tripping through JSON. This keeps `structuredContent`
@@ -51,7 +53,7 @@ declare function jsonResponse(data: unknown, replacer?: (key: string, value: any
51
53
  * `Date`, or anything else `JSON.stringify` knows how to convert via the
52
54
  * replacer.
53
55
  */
54
- declare function structuredResponse(data: Record<string, unknown>, replacer?: (key: string, value: any) => any): CallToolResult;
56
+ declare function structuredResponse(data: unknown, replacer?: (key: string, value: any) => any): CallToolResult;
55
57
  /**
56
58
  * Config shape accepted by createMnemonicServer.
57
59
  * Derives from ManifestMCPConfig (minus rateLimit/retry) so new config fields propagate automatically.
@@ -1 +1 @@
1
- {"version":3,"file":"server-utils.d.ts","names":[],"sources":["../src/server-utils.ts"],"mappings":";;;;;;AAgBA;;;cAAa,0BAAA,EAA4B,WAAA,CAAY,oBAAA;;AAYrD;;cAAa,gBAAA,EAAkB,WAAA;;;AAwB/B;iBAAgB,cAAA,CAAe,IAAA,UAAc,KAAA;;;;iBAO7B,kBAAA,CAAmB,GAAA,WAAc,KAAA;;;;UAgDhC,wBAAA;EACf,MAAA,EAAQ,iBAAA;EACR,cAAA,EAAgB,cAAA;AAAA;;;;;;;iBAUF,iBAAA,eACA,IAAA,YAAgB,OAAA,CAAQ,cAAA,EAAA,CACtC,QAAA,UAAkB,EAAA,EAAI,CAAA,GAAI,CAAA;AAF5B;;;AAAA,iBAoFgB,YAAA,CACd,IAAA,WACA,QAAA,IAAY,GAAA,UAAa,KAAA,gBACxB,cAAA;;;;;;;;;;;;;;iBAwBa,kBAAA,CAEd,IAAA,EAAM,MAAA,mBACN,QAAA,IAAY,GAAA,UAAa,KAAA,gBACxB,cAAA;;AA/BH;;;KAiDY,oBAAA,GAAuB,IAAA,CACjC,iBAAA;EAAA,SAGS,QAAA;AAAA;;;;;;AA1BX;iBAmCsB,oBAAA,GAAA,CACpB,MAAA,EAAQ,oBAAA,EACR,WAAA,OAAkB,IAAA,EAAM,wBAAA,KAA6B,CAAA,GACpD,OAAA,CAAQ,CAAA"}
1
+ {"version":3,"file":"server-utils.d.ts","names":[],"sources":["../src/server-utils.ts"],"mappings":";;;;;;AAgBA;;;cAAa,0BAAA,EAA4B,WAAA,CAAY,oBAAA;;AAYrD;;cAAa,gBAAA,EAAkB,WAAA;;;AAwB/B;iBAAgB,cAAA,CAAe,IAAA,UAAc,KAAA;;;;iBAO7B,kBAAA,CAAmB,GAAA,WAAc,KAAA;;;;UAgDhC,wBAAA;EACf,MAAA,EAAQ,iBAAA;EACR,cAAA,EAAgB,cAAA;AAAA;;;;;;;iBAUF,iBAAA,eACA,IAAA,YAAgB,OAAA,CAAQ,cAAA,EAAA,CACtC,QAAA,UAAkB,EAAA,EAAI,CAAA,GAAI,CAAA;AAF5B;;;AAAA,iBAuFgB,YAAA,CACd,IAAA,WACA,QAAA,IAAY,GAAA,UAAa,KAAA,gBACxB,cAAA;;;;;;;;;;;;;;;;iBA0Ba,kBAAA,CACd,IAAA,WAEA,QAAA,IAAY,GAAA,UAAa,KAAA,gBACxB,cAAA;;;;;KAkBS,oBAAA,GAAuB,IAAA,CACjC,iBAAA;EAAA,SAGS,QAAA;AAAA;;;;AA1BX;;;iBAmCsB,oBAAA,GAAA,CACpB,MAAA,EAAQ,oBAAA,EACR,WAAA,OAAkB,IAAA,EAAM,wBAAA,KAA6B,CAAA,GACpD,OAAA,CAAQ,CAAA"}
@@ -82,12 +82,14 @@ function withErrorHandling(toolName, fn) {
82
82
  } catch (error) {
83
83
  const errorMessage = error instanceof Error ? error.message : String(error);
84
84
  const errorCode = error instanceof ManifestMCPError ? error.code : "UNKNOWN";
85
- if (error instanceof ManifestMCPError) logger.error(`[${toolName}] Tool error [${errorCode}]: ${errorMessage}`);
85
+ const safeMessage = sanitizeForLogging(errorMessage);
86
+ const messageWasRedacted = safeMessage !== errorMessage;
87
+ if (error instanceof ManifestMCPError) logger.error(`[${toolName}] Tool error [${errorCode}]: ${safeMessage}`);
86
88
  else {
87
- const stack = error instanceof Error && error.stack ? `\n${error.stack}` : "";
88
- logger.error(`[${toolName}] Tool error [${errorCode}]: ${errorMessage}${stack}`);
89
+ let stackSuffix = "";
90
+ if (!messageWasRedacted && error instanceof Error && error.stack) stackSuffix = `\n${sanitizeForLogging(error.stack)}`;
91
+ logger.error(`[${toolName}] Tool error [${errorCode}]: ${safeMessage}${stackSuffix}`);
89
92
  }
90
- const safeMessage = sanitizeForLogging(errorMessage);
91
93
  let errorResponse = {
92
94
  error: true,
93
95
  tool: toolName,
@@ -139,7 +141,9 @@ function jsonResponse(data, replacer) {
139
141
  * (consumed by clients that validate against the tool's outputSchema) and
140
142
  * `content` (text fallback for clients that don't). Use this for any tool
141
143
  * registered with an `outputSchema`. Per MCP spec, `structuredContent` must
142
- * be a JSON object — `data` is therefore typed as a record.
144
+ * be a JSON object — `data` is typed as `unknown` so callers don't need to
145
+ * widen typed result interfaces with double-casts; the runtime contract
146
+ * (object-shaped after JSON round-trip) is enforced below.
143
147
  *
144
148
  * The optional `replacer` is applied to BOTH `structuredContent` and the
145
149
  * text fallback by round-tripping through JSON. This keeps `structuredContent`
@@ -1 +1 @@
1
- {"version":3,"file":"server-utils.js","names":[],"sources":["../src/server-utils.ts"],"sourcesContent":["import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { createValidatedConfig } from './config.js';\nimport { logger } from './logger.js';\nimport {\n type ManifestMCPConfig,\n ManifestMCPError,\n ManifestMCPErrorCode,\n type WalletProvider,\n} from './types.js';\nimport { MnemonicWalletProvider } from './wallet/index.js';\n\n/**\n * Error codes that indicate infrastructure-level failures (wallet, RPC, config).\n * Used by tool implementations to distinguish infrastructure errors from\n * provider/application errors so that infrastructure errors are always re-thrown.\n */\nexport const INFRASTRUCTURE_ERROR_CODES: ReadonlySet<ManifestMCPErrorCode> =\n new Set([\n ManifestMCPErrorCode.WALLET_NOT_CONNECTED,\n ManifestMCPErrorCode.WALLET_CONNECTION_FAILED,\n ManifestMCPErrorCode.RPC_CONNECTION_FAILED,\n ManifestMCPErrorCode.INVALID_MNEMONIC,\n ManifestMCPErrorCode.INVALID_CONFIG,\n ]);\n\n/**\n * Sensitive field names that should be redacted from error responses\n */\nexport const SENSITIVE_FIELDS: ReadonlySet<string> = new Set([\n 'mnemonic',\n 'privatekey',\n 'private_key',\n 'secret',\n 'password',\n 'seed',\n 'secret_key',\n 'signing_key',\n 'apikey',\n 'api_key',\n 'auth_token',\n 'bearer_token',\n 'access_token',\n 'refresh_token',\n]);\n\n// Note: standalone \"key\" and \"token\" are intentionally excluded from SENSITIVE_FIELDS\n// because they are too generic — they would match pagination keys, map keys, and\n// non-sensitive token identifiers. Use compound names (api_key, auth_token, etc.) instead.\n\n/**\n * JSON replacer that converts BigInt values to strings\n */\nexport function bigIntReplacer(_key: string, value: unknown): unknown {\n return typeof value === 'bigint' ? value.toString() : value;\n}\n\n/**\n * Recursively sanitize an object by redacting sensitive fields\n */\nexport function sanitizeForLogging(obj: unknown, depth = 0): unknown {\n // Prevent infinite recursion\n if (depth > 10) {\n return '[max depth exceeded]';\n }\n\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n if (typeof obj === 'string') {\n // Redact strings that look like BIP-39 mnemonics (12/15/18/21/24 words).\n // BIP-39 words are all lowercase alphabetic, so require that to avoid\n // false positives on error messages that happen to be 12/24 words.\n const words = obj.trim().split(/\\s+/);\n const wordCount = words.length;\n if (wordCount >= 12 && wordCount <= 24 && wordCount % 3 === 0) {\n const allLowercaseAlpha = words.every((w) => /^[a-z]+$/.test(w));\n if (allLowercaseAlpha) {\n return '[REDACTED - possible mnemonic]';\n }\n }\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => sanitizeForLogging(item, depth + 1));\n }\n\n if (typeof obj === 'object') {\n const sanitized: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n const lowerKey = key.toLowerCase();\n if (SENSITIVE_FIELDS.has(lowerKey)) {\n sanitized[key] = '[REDACTED]';\n } else {\n sanitized[key] = sanitizeForLogging(value, depth + 1);\n }\n }\n return sanitized;\n }\n\n return obj;\n}\n\n/**\n * Options for creating a chain, lease, or fred MCP server\n */\nexport interface ManifestMCPServerOptions {\n config: ManifestMCPConfig;\n walletProvider: WalletProvider;\n}\n\n/**\n * Wrap a tool handler with error handling that preserves the existing error format.\n *\n * Generic over the callback type so that Zod-inferred argument types from\n * McpServer.registerTool flow through without requiring manual casts.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- preserves ToolCallback<Args> signature from McpServer\nexport function withErrorHandling<\n T extends (...args: any[]) => Promise<CallToolResult>,\n>(toolName: string, fn: T): T {\n // For tools with no inputSchema, McpServer calls cb(extra) with one arg.\n // For tools with inputSchema, McpServer calls cb(parsedArgs, extra).\n // We infer from cbArgs.length at call time (not fn.length) so default parameters are safe.\n const wrapped = async (...cbArgs: any[]) => {\n const hasArgs = cbArgs.length >= 2;\n const args = hasArgs ? (cbArgs[0] ?? {}) : {};\n try {\n return hasArgs ? await fn(args, cbArgs[1]) : await fn(cbArgs[0]);\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n const errorCode =\n error instanceof ManifestMCPError ? error.code : 'UNKNOWN';\n if (error instanceof ManifestMCPError) {\n logger.error(\n `[${toolName}] Tool error [${errorCode}]: ${errorMessage}`,\n );\n } else {\n const stack =\n error instanceof Error && error.stack ? `\\n${error.stack}` : '';\n logger.error(\n `[${toolName}] Tool error [${errorCode}]: ${errorMessage}${stack}`,\n );\n }\n\n // Sanitize error messages before including in the MCP response.\n // This catches mnemonic-like strings in error messages and redacts them.\n const safeMessage = sanitizeForLogging(errorMessage) as string;\n\n let errorResponse: Record<string, unknown> = {\n error: true,\n tool: toolName,\n input: sanitizeForLogging(args),\n };\n\n if (error instanceof ManifestMCPError) {\n errorResponse = {\n ...errorResponse,\n code: error.code,\n message: sanitizeForLogging(error.message) as string,\n details: sanitizeForLogging(error.details),\n };\n } else {\n errorResponse = {\n ...errorResponse,\n message: safeMessage,\n };\n }\n\n let responseText: string;\n try {\n responseText = JSON.stringify(errorResponse, bigIntReplacer, 2);\n } catch (stringifyError) {\n logger.error(\n `[${toolName}] Failed to serialize error response: ${stringifyError instanceof Error ? stringifyError.message : String(stringifyError)}`,\n );\n responseText = JSON.stringify({\n error: true,\n tool: toolName,\n message: safeMessage,\n });\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: responseText,\n },\n ],\n isError: true,\n };\n }\n };\n return wrapped as T;\n}\n\n/**\n * Helper to build a successful JSON text response\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches JSON.stringify's replacer signature\nexport function jsonResponse(\n data: unknown,\n replacer?: (key: string, value: any) => any,\n): CallToolResult {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(data, replacer, 2),\n },\n ],\n };\n}\n\n/**\n * Helper to build a successful CallToolResult with both `structuredContent`\n * (consumed by clients that validate against the tool's outputSchema) and\n * `content` (text fallback for clients that don't). Use this for any tool\n * registered with an `outputSchema`. Per MCP spec, `structuredContent` must\n * be a JSON object — `data` is therefore typed as a record.\n *\n * The optional `replacer` is applied to BOTH `structuredContent` and the\n * text fallback by round-tripping through JSON. This keeps `structuredContent`\n * JSON-serializable for the wire, even if the caller hands us a `BigInt`,\n * `Date`, or anything else `JSON.stringify` knows how to convert via the\n * replacer.\n */\nexport function structuredResponse(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches JSON.stringify's replacer signature\n data: Record<string, unknown>,\n replacer?: (key: string, value: any) => any,\n): CallToolResult {\n const serialized = JSON.stringify(data, replacer);\n const structuredContent = JSON.parse(serialized) as Record<string, unknown>;\n return {\n structuredContent,\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(structuredContent, undefined, 2),\n },\n ],\n };\n}\n\n/**\n * Config shape accepted by createMnemonicServer.\n * Derives from ManifestMCPConfig (minus rateLimit/retry) so new config fields propagate automatically.\n */\nexport type MnemonicServerConfig = Omit<\n ManifestMCPConfig,\n 'rateLimit' | 'retry'\n> & {\n readonly mnemonic: string;\n};\n\n/**\n * Generic factory that creates any MCP server class with a mnemonic wallet.\n *\n * Eliminates duplicated createMnemonic*Server patterns -- callers pass the\n * server constructor instead.\n */\nexport async function createMnemonicServer<T>(\n config: MnemonicServerConfig,\n ServerClass: new (opts: ManifestMCPServerOptions) => T,\n): Promise<T> {\n const { mnemonic, ...mcpConfig } = config;\n const validatedConfig = createValidatedConfig(mcpConfig);\n const walletProvider = new MnemonicWalletProvider(validatedConfig, mnemonic);\n await walletProvider.connect();\n\n return new ServerClass({\n config: validatedConfig,\n walletProvider,\n });\n}\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,6BACX,IAAI,IAAI;CACN,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CACtB,CAAC;;;;AAKJ,MAAa,mBAAwC,IAAI,IAAI;CAC3D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;;;AASF,SAAgB,eAAe,MAAc,OAAyB;AACpE,QAAO,OAAO,UAAU,WAAW,MAAM,UAAU,GAAG;;;;;AAMxD,SAAgB,mBAAmB,KAAc,QAAQ,GAAY;AAEnE,KAAI,QAAQ,GACV,QAAO;AAGT,KAAI,QAAQ,QAAQ,QAAQ,KAAA,EAC1B,QAAO;AAGT,KAAI,OAAO,QAAQ,UAAU;EAI3B,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,MAAM;EACrC,MAAM,YAAY,MAAM;AACxB,MAAI,aAAa,MAAM,aAAa,MAAM,YAAY,MAAM;OAChC,MAAM,OAAO,MAAM,WAAW,KAAK,EAAE,CAAC,CAE9D,QAAO;;AAGX,SAAO;;AAGT,KAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,KAAK,SAAS,mBAAmB,MAAM,QAAQ,EAAE,CAAC;AAG/D,KAAI,OAAO,QAAQ,UAAU;EAC3B,MAAM,YAAqC,EAAE;AAC7C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,EAAE;GAC9C,MAAM,WAAW,IAAI,aAAa;AAClC,OAAI,iBAAiB,IAAI,SAAS,CAChC,WAAU,OAAO;OAEjB,WAAU,OAAO,mBAAmB,OAAO,QAAQ,EAAE;;AAGzD,SAAO;;AAGT,QAAO;;;;;;;;AAkBT,SAAgB,kBAEd,UAAkB,IAAU;CAI5B,MAAM,UAAU,OAAO,GAAG,WAA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;EACxC,CACF,EACF;;;;;;;;;;;;;;;AAgBH,SAAgB,mBAEd,MACA,UACgB;CAChB,MAAM,aAAa,KAAK,UAAU,MAAM,SAAS;CACjD,MAAM,oBAAoB,KAAK,MAAM,WAAW;AAChD,QAAO;EACL;EACA,SAAS,CACP;GACE,MAAM;GACN,MAAM,KAAK,UAAU,mBAAmB,KAAA,GAAW,EAAE;GACtD,CACF;EACF;;;;;;;;AAoBH,eAAsB,qBACpB,QACA,aACY;CACZ,MAAM,EAAE,UAAU,GAAG,cAAc;CACnC,MAAM,kBAAkB,sBAAsB,UAAU;CACxD,MAAM,iBAAiB,IAAI,uBAAuB,iBAAiB,SAAS;AAC5E,OAAM,eAAe,SAAS;AAE9B,QAAO,IAAI,YAAY;EACrB,QAAQ;EACR;EACD,CAAC"}
1
+ {"version":3,"file":"server-utils.js","names":[],"sources":["../src/server-utils.ts"],"sourcesContent":["import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { createValidatedConfig } from './config.js';\nimport { logger } from './logger.js';\nimport {\n type ManifestMCPConfig,\n ManifestMCPError,\n ManifestMCPErrorCode,\n type WalletProvider,\n} from './types.js';\nimport { MnemonicWalletProvider } from './wallet/index.js';\n\n/**\n * Error codes that indicate infrastructure-level failures (wallet, RPC, config).\n * Used by tool implementations to distinguish infrastructure errors from\n * provider/application errors so that infrastructure errors are always re-thrown.\n */\nexport const INFRASTRUCTURE_ERROR_CODES: ReadonlySet<ManifestMCPErrorCode> =\n new Set([\n ManifestMCPErrorCode.WALLET_NOT_CONNECTED,\n ManifestMCPErrorCode.WALLET_CONNECTION_FAILED,\n ManifestMCPErrorCode.RPC_CONNECTION_FAILED,\n ManifestMCPErrorCode.INVALID_MNEMONIC,\n ManifestMCPErrorCode.INVALID_CONFIG,\n ]);\n\n/**\n * Sensitive field names that should be redacted from error responses\n */\nexport const SENSITIVE_FIELDS: ReadonlySet<string> = new Set([\n 'mnemonic',\n 'privatekey',\n 'private_key',\n 'secret',\n 'password',\n 'seed',\n 'secret_key',\n 'signing_key',\n 'apikey',\n 'api_key',\n 'auth_token',\n 'bearer_token',\n 'access_token',\n 'refresh_token',\n]);\n\n// Note: standalone \"key\" and \"token\" are intentionally excluded from SENSITIVE_FIELDS\n// because they are too generic — they would match pagination keys, map keys, and\n// non-sensitive token identifiers. Use compound names (api_key, auth_token, etc.) instead.\n\n/**\n * JSON replacer that converts BigInt values to strings\n */\nexport function bigIntReplacer(_key: string, value: unknown): unknown {\n return typeof value === 'bigint' ? value.toString() : value;\n}\n\n/**\n * Recursively sanitize an object by redacting sensitive fields\n */\nexport function sanitizeForLogging(obj: unknown, depth = 0): unknown {\n // Prevent infinite recursion\n if (depth > 10) {\n return '[max depth exceeded]';\n }\n\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n if (typeof obj === 'string') {\n // Redact strings that look like BIP-39 mnemonics (12/15/18/21/24 words).\n // BIP-39 words are all lowercase alphabetic, so require that to avoid\n // false positives on error messages that happen to be 12/24 words.\n const words = obj.trim().split(/\\s+/);\n const wordCount = words.length;\n if (wordCount >= 12 && wordCount <= 24 && wordCount % 3 === 0) {\n const allLowercaseAlpha = words.every((w) => /^[a-z]+$/.test(w));\n if (allLowercaseAlpha) {\n return '[REDACTED - possible mnemonic]';\n }\n }\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => sanitizeForLogging(item, depth + 1));\n }\n\n if (typeof obj === 'object') {\n const sanitized: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n const lowerKey = key.toLowerCase();\n if (SENSITIVE_FIELDS.has(lowerKey)) {\n sanitized[key] = '[REDACTED]';\n } else {\n sanitized[key] = sanitizeForLogging(value, depth + 1);\n }\n }\n return sanitized;\n }\n\n return obj;\n}\n\n/**\n * Options for creating a chain, lease, or fred MCP server\n */\nexport interface ManifestMCPServerOptions {\n config: ManifestMCPConfig;\n walletProvider: WalletProvider;\n}\n\n/**\n * Wrap a tool handler with error handling that preserves the existing error format.\n *\n * Generic over the callback type so that Zod-inferred argument types from\n * McpServer.registerTool flow through without requiring manual casts.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- preserves ToolCallback<Args> signature from McpServer\nexport function withErrorHandling<\n T extends (...args: any[]) => Promise<CallToolResult>,\n>(toolName: string, fn: T): T {\n // For tools with no inputSchema, McpServer calls cb(extra) with one arg.\n // For tools with inputSchema, McpServer calls cb(parsedArgs, extra).\n // We infer from cbArgs.length at call time (not fn.length) so default parameters are safe.\n const wrapped = async (...cbArgs: any[]) => {\n const hasArgs = cbArgs.length >= 2;\n const args = hasArgs ? (cbArgs[0] ?? {}) : {};\n try {\n return hasArgs ? await fn(args, cbArgs[1]) : await fn(cbArgs[0]);\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n const errorCode =\n error instanceof ManifestMCPError ? error.code : 'UNKNOWN';\n // Sanitize error messages before including in the MCP response or logs.\n // This catches mnemonic-like strings in error messages and redacts them.\n const safeMessage = sanitizeForLogging(errorMessage) as string;\n const messageWasRedacted = safeMessage !== errorMessage;\n if (error instanceof ManifestMCPError) {\n logger.error(`[${toolName}] Tool error [${errorCode}]: ${safeMessage}`);\n } else {\n // Stack traces embed error.message verbatim. If the message was\n // redacted, the stack would re-leak the original — so suppress the\n // stack in that case rather than emit a half-sanitized trace.\n let stackSuffix = '';\n if (!messageWasRedacted && error instanceof Error && error.stack) {\n stackSuffix = `\\n${sanitizeForLogging(error.stack) as string}`;\n }\n logger.error(\n `[${toolName}] Tool error [${errorCode}]: ${safeMessage}${stackSuffix}`,\n );\n }\n\n let errorResponse: Record<string, unknown> = {\n error: true,\n tool: toolName,\n input: sanitizeForLogging(args),\n };\n\n if (error instanceof ManifestMCPError) {\n errorResponse = {\n ...errorResponse,\n code: error.code,\n message: sanitizeForLogging(error.message) as string,\n details: sanitizeForLogging(error.details),\n };\n } else {\n errorResponse = {\n ...errorResponse,\n message: safeMessage,\n };\n }\n\n let responseText: string;\n try {\n responseText = JSON.stringify(errorResponse, bigIntReplacer, 2);\n } catch (stringifyError) {\n logger.error(\n `[${toolName}] Failed to serialize error response: ${stringifyError instanceof Error ? stringifyError.message : String(stringifyError)}`,\n );\n responseText = JSON.stringify({\n error: true,\n tool: toolName,\n message: safeMessage,\n });\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: responseText,\n },\n ],\n isError: true,\n };\n }\n };\n return wrapped as T;\n}\n\n/**\n * Helper to build a successful JSON text response\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches JSON.stringify's replacer signature\nexport function jsonResponse(\n data: unknown,\n replacer?: (key: string, value: any) => any,\n): CallToolResult {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(data, replacer, 2),\n },\n ],\n };\n}\n\n/**\n * Helper to build a successful CallToolResult with both `structuredContent`\n * (consumed by clients that validate against the tool's outputSchema) and\n * `content` (text fallback for clients that don't). Use this for any tool\n * registered with an `outputSchema`. Per MCP spec, `structuredContent` must\n * be a JSON object — `data` is typed as `unknown` so callers don't need to\n * widen typed result interfaces with double-casts; the runtime contract\n * (object-shaped after JSON round-trip) is enforced below.\n *\n * The optional `replacer` is applied to BOTH `structuredContent` and the\n * text fallback by round-tripping through JSON. This keeps `structuredContent`\n * JSON-serializable for the wire, even if the caller hands us a `BigInt`,\n * `Date`, or anything else `JSON.stringify` knows how to convert via the\n * replacer.\n */\nexport function structuredResponse(\n data: unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches JSON.stringify's replacer signature\n replacer?: (key: string, value: any) => any,\n): CallToolResult {\n const serialized = JSON.stringify(data, replacer);\n const structuredContent = JSON.parse(serialized) as Record<string, unknown>;\n return {\n structuredContent,\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(structuredContent, undefined, 2),\n },\n ],\n };\n}\n\n/**\n * Config shape accepted by createMnemonicServer.\n * Derives from ManifestMCPConfig (minus rateLimit/retry) so new config fields propagate automatically.\n */\nexport type MnemonicServerConfig = Omit<\n ManifestMCPConfig,\n 'rateLimit' | 'retry'\n> & {\n readonly mnemonic: string;\n};\n\n/**\n * Generic factory that creates any MCP server class with a mnemonic wallet.\n *\n * Eliminates duplicated createMnemonic*Server patterns -- callers pass the\n * server constructor instead.\n */\nexport async function createMnemonicServer<T>(\n config: MnemonicServerConfig,\n ServerClass: new (opts: ManifestMCPServerOptions) => T,\n): Promise<T> {\n const { mnemonic, ...mcpConfig } = config;\n const validatedConfig = createValidatedConfig(mcpConfig);\n const walletProvider = new MnemonicWalletProvider(validatedConfig, mnemonic);\n await walletProvider.connect();\n\n return new ServerClass({\n config: validatedConfig,\n walletProvider,\n });\n}\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,6BACX,IAAI,IAAI;CACN,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CACtB,CAAC;;;;AAKJ,MAAa,mBAAwC,IAAI,IAAI;CAC3D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;;;AASF,SAAgB,eAAe,MAAc,OAAyB;AACpE,QAAO,OAAO,UAAU,WAAW,MAAM,UAAU,GAAG;;;;;AAMxD,SAAgB,mBAAmB,KAAc,QAAQ,GAAY;AAEnE,KAAI,QAAQ,GACV,QAAO;AAGT,KAAI,QAAQ,QAAQ,QAAQ,KAAA,EAC1B,QAAO;AAGT,KAAI,OAAO,QAAQ,UAAU;EAI3B,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,MAAM;EACrC,MAAM,YAAY,MAAM;AACxB,MAAI,aAAa,MAAM,aAAa,MAAM,YAAY,MAAM;OAChC,MAAM,OAAO,MAAM,WAAW,KAAK,EAAE,CAAC,CAE9D,QAAO;;AAGX,SAAO;;AAGT,KAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,KAAK,SAAS,mBAAmB,MAAM,QAAQ,EAAE,CAAC;AAG/D,KAAI,OAAO,QAAQ,UAAU;EAC3B,MAAM,YAAqC,EAAE;A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xD,gBAAgB;AACvB,WAAO,MACL,IAAI,SAAS,wCAAwC,0BAA0B,QAAQ,eAAe,UAAU,OAAO,eAAe,GACvI;AACD,mBAAe,KAAK,UAAU;KAC5B,OAAO;KACP,MAAM;KACN,SAAS;KACV,CAAC;;AAGJ,UAAO;IACL,SAAS,CACP;KACE,MAAM;KACN,MAAM;KACP,CACF;IACD,SAAS;IACV;;;AAGL,QAAO;;;;;AAOT,SAAgB,aACd,MACA,UACgB;AAChB,QAAO,EACL,SAAS,CACP;EACE,MAAM;EACN,MAAM,KAAK,UAAU,MAAM,UAAU,EAAE;EACxC,CACF,EACF;;;;;;;;;;;;;;;;;AAkBH,SAAgB,mBACd,MAEA,UACgB;CAChB,MAAM,aAAa,KAAK,UAAU,MAAM,SAAS;CACjD,MAAM,oBAAoB,KAAK,MAAM,WAAW;AAChD,QAAO;EACL;EACA,SAAS,CACP;GACE,MAAM;GACN,MAAM,KAAK,UAAU,mBAAmB,KAAA,GAAW,EAAE;GACtD,CACF;EACF;;;;;;;;AAoBH,eAAsB,qBACpB,QACA,aACY;CACZ,MAAM,EAAE,UAAU,GAAG,cAAc;CACnC,MAAM,kBAAkB,sBAAsB,UAAU;CACxD,MAAM,iBAAiB,IAAI,uBAAuB,iBAAiB,SAAS;AAC5E,OAAM,eAAe,SAAS;AAE9B,QAAO,IAAI,YAAY;EACrB,QAAQ;EACR;EACD,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/version.d.ts
2
- declare const VERSION = "0.3.1";
2
+ declare const VERSION = "0.10.0";
3
3
  //#endregion
4
4
  export { VERSION };
5
5
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/version.ts
2
- const VERSION = "0.3.1";
2
+ const VERSION = "0.10.0";
3
3
  //#endregion
4
4
  export { VERSION };
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../src/version.ts"],"sourcesContent":["export const VERSION = '0.3.1';\n"],"mappings":";AAAA,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../src/version.ts"],"sourcesContent":["export const VERSION = '0.10.0';\n"],"mappings":";AAAA,MAAa,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manifest-network/manifest-mcp-core",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "Shared library for Cosmos SDK blockchain logic, tool functions, and server utilities (Manifest Network)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,6 +17,10 @@
17
17
  "./__test-utils__/callTool.js": {
18
18
  "import": "./dist/__test-utils__/callTool.js",
19
19
  "types": "./dist/__test-utils__/callTool.d.ts"
20
+ },
21
+ "./__test-utils__/callToolWithElicitation.js": {
22
+ "import": "./dist/__test-utils__/callToolWithElicitation.js",
23
+ "types": "./dist/__test-utils__/callToolWithElicitation.d.ts"
20
24
  }
21
25
  },
22
26
  "scripts": {
@@ -69,5 +73,13 @@
69
73
  "@types/node": "22.15.29",
70
74
  "typescript": "5.9.3",
71
75
  "vitest": "4.1.0"
76
+ },
77
+ "peerDependencies": {
78
+ "vitest": "^4.1.0"
79
+ },
80
+ "peerDependenciesMeta": {
81
+ "vitest": {
82
+ "optional": true
83
+ }
72
84
  }
73
85
  }
@@ -1,78 +0,0 @@
1
- //#region ../../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
2
- var comma = ",".charCodeAt(0);
3
- var semicolon = ";".charCodeAt(0);
4
- var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
5
- var intToChar = new Uint8Array(64);
6
- var charToInt = new Uint8Array(128);
7
- for (let i = 0; i < chars.length; i++) {
8
- const c = chars.charCodeAt(i);
9
- intToChar[i] = c;
10
- charToInt[c] = i;
11
- }
12
- function encodeInteger(builder, num, relative) {
13
- let delta = num - relative;
14
- delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
15
- do {
16
- let clamped = delta & 31;
17
- delta >>>= 5;
18
- if (delta > 0) clamped |= 32;
19
- builder.write(intToChar[clamped]);
20
- } while (delta > 0);
21
- return num;
22
- }
23
- var bufLength = 1024 * 16;
24
- var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? { decode(buf) {
25
- return Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength).toString();
26
- } } : { decode(buf) {
27
- let out = "";
28
- for (let i = 0; i < buf.length; i++) out += String.fromCharCode(buf[i]);
29
- return out;
30
- } };
31
- var StringWriter = class {
32
- constructor() {
33
- this.pos = 0;
34
- this.out = "";
35
- this.buffer = new Uint8Array(bufLength);
36
- }
37
- write(v) {
38
- const { buffer } = this;
39
- buffer[this.pos++] = v;
40
- if (this.pos === bufLength) {
41
- this.out += td.decode(buffer);
42
- this.pos = 0;
43
- }
44
- }
45
- flush() {
46
- const { buffer, out, pos } = this;
47
- return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
48
- }
49
- };
50
- function encode(decoded) {
51
- const writer = new StringWriter();
52
- let sourcesIndex = 0;
53
- let sourceLine = 0;
54
- let sourceColumn = 0;
55
- let namesIndex = 0;
56
- for (let i = 0; i < decoded.length; i++) {
57
- const line = decoded[i];
58
- if (i > 0) writer.write(semicolon);
59
- if (line.length === 0) continue;
60
- let genColumn = 0;
61
- for (let j = 0; j < line.length; j++) {
62
- const segment = line[j];
63
- if (j > 0) writer.write(comma);
64
- genColumn = encodeInteger(writer, segment[0], genColumn);
65
- if (segment.length === 1) continue;
66
- sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
67
- sourceLine = encodeInteger(writer, segment[2], sourceLine);
68
- sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
69
- if (segment.length === 4) continue;
70
- namesIndex = encodeInteger(writer, segment[4], namesIndex);
71
- }
72
- }
73
- return writer.flush();
74
- }
75
- //#endregion
76
- export { encode };
77
-
78
- //# sourceMappingURL=sourcemap-codec.js.map