@manifest-network/manifest-mcp-core 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/dist/__test-utils__/callTool.d.ts +29 -0
- package/dist/__test-utils__/callTool.d.ts.map +1 -0
- package/dist/__test-utils__/callTool.js +45 -0
- package/dist/__test-utils__/callTool.js.map +1 -0
- package/dist/__test-utils__/mocks.d.ts +125 -0
- package/dist/__test-utils__/mocks.d.ts.map +1 -0
- package/dist/__test-utils__/mocks.js +146 -0
- package/dist/__test-utils__/mocks.js.map +1 -0
- package/dist/client.d.ts +67 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +209 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +30 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +127 -0
- package/dist/config.js.map +1 -0
- package/dist/cosmos.d.ts +24 -0
- package/dist/cosmos.d.ts.map +1 -0
- package/dist/cosmos.js +85 -0
- package/dist/cosmos.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +20 -0
- package/dist/lcd-adapter.d.ts +15 -0
- package/dist/lcd-adapter.d.ts.map +1 -0
- package/dist/lcd-adapter.js +98 -0
- package/dist/lcd-adapter.js.map +1 -0
- package/dist/logger.d.ts +20 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +43 -0
- package/dist/logger.js.map +1 -0
- package/dist/modules.d.ts +63 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +759 -0
- package/dist/modules.js.map +1 -0
- package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +78 -0
- package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js.map +1 -0
- package/dist/node_modules/@vitest/expect/dist/index.d.ts +802 -0
- package/dist/node_modules/@vitest/expect/dist/index.d.ts.map +1 -0
- package/dist/node_modules/@vitest/expect/dist/index.js +1457 -0
- package/dist/node_modules/@vitest/expect/dist/index.js.map +1 -0
- package/dist/node_modules/@vitest/pretty-format/dist/index.d.ts +95 -0
- package/dist/node_modules/@vitest/pretty-format/dist/index.d.ts.map +1 -0
- package/dist/node_modules/@vitest/pretty-format/dist/index.js +877 -0
- package/dist/node_modules/@vitest/pretty-format/dist/index.js.map +1 -0
- package/dist/node_modules/@vitest/runner/dist/chunk-tasks.js +91 -0
- package/dist/node_modules/@vitest/runner/dist/chunk-tasks.js.map +1 -0
- package/dist/node_modules/@vitest/runner/dist/index.js +1381 -0
- package/dist/node_modules/@vitest/runner/dist/index.js.map +1 -0
- package/dist/node_modules/@vitest/runner/dist/tasks.d-D2GKpdwQ.d.ts +540 -0
- package/dist/node_modules/@vitest/runner/dist/tasks.d-D2GKpdwQ.d.ts.map +1 -0
- package/dist/node_modules/@vitest/runner/dist/utils.js +1 -0
- package/dist/node_modules/@vitest/snapshot/dist/environment.d-DOJxxZV9.d.ts +16 -0
- package/dist/node_modules/@vitest/snapshot/dist/environment.d-DOJxxZV9.d.ts.map +1 -0
- package/dist/node_modules/@vitest/snapshot/dist/index.d.ts +89 -0
- package/dist/node_modules/@vitest/snapshot/dist/index.d.ts.map +1 -0
- package/dist/node_modules/@vitest/snapshot/dist/index.js +649 -0
- package/dist/node_modules/@vitest/snapshot/dist/index.js.map +1 -0
- package/dist/node_modules/@vitest/snapshot/dist/rawSnapshot.d-U2kJUxDr.d.ts +40 -0
- package/dist/node_modules/@vitest/snapshot/dist/rawSnapshot.d-U2kJUxDr.d.ts.map +1 -0
- package/dist/node_modules/@vitest/spy/dist/index.d.ts +343 -0
- package/dist/node_modules/@vitest/spy/dist/index.d.ts.map +1 -0
- package/dist/node_modules/@vitest/spy/dist/index.js +386 -0
- package/dist/node_modules/@vitest/spy/dist/index.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js +82 -0
- package/dist/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/diff.d.ts +14 -0
- package/dist/node_modules/@vitest/utils/dist/diff.d.ts.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/diff.js +1297 -0
- package/dist/node_modules/@vitest/utils/dist/diff.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/display.d.ts +15 -0
- package/dist/node_modules/@vitest/utils/dist/display.d.ts.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/display.js +558 -0
- package/dist/node_modules/@vitest/utils/dist/display.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/error.js +30 -0
- package/dist/node_modules/@vitest/utils/dist/error.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/helpers.js +181 -0
- package/dist/node_modules/@vitest/utils/dist/helpers.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/offset.js +27 -0
- package/dist/node_modules/@vitest/utils/dist/offset.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/serialize.js +77 -0
- package/dist/node_modules/@vitest/utils/dist/serialize.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/source-map.js +367 -0
- package/dist/node_modules/@vitest/utils/dist/source-map.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/timers.js +37 -0
- package/dist/node_modules/@vitest/utils/dist/timers.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/types.d-BCElaP-c.d.ts +38 -0
- package/dist/node_modules/@vitest/utils/dist/types.d-BCElaP-c.d.ts.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/types.d.ts +25 -0
- package/dist/node_modules/@vitest/utils/dist/types.d.ts.map +1 -0
- package/dist/node_modules/chai/index.js +2875 -0
- package/dist/node_modules/chai/index.js.map +1 -0
- package/dist/node_modules/magic-string/dist/magic-string.es.js +939 -0
- package/dist/node_modules/magic-string/dist/magic-string.es.js.map +1 -0
- package/dist/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +85 -0
- package/dist/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js.map +1 -0
- package/dist/node_modules/tinybench/dist/index.d.ts +91 -0
- package/dist/node_modules/tinybench/dist/index.d.ts.map +1 -0
- package/dist/node_modules/tinyrainbow/dist/index.d.ts +9 -0
- package/dist/node_modules/tinyrainbow/dist/index.d.ts.map +1 -0
- package/dist/node_modules/tinyrainbow/dist/index.js +86 -0
- package/dist/node_modules/tinyrainbow/dist/index.js.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
- package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/benchmark.D0SlKNbZ.js +41 -0
- package/dist/node_modules/vitest/dist/chunks/benchmark.D0SlKNbZ.js.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/benchmark.d.DAaHLpsq.d.ts +12 -0
- package/dist/node_modules/vitest/dist/chunks/benchmark.d.DAaHLpsq.d.ts.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/global.d.x-ILCfAE.d.ts +100 -0
- package/dist/node_modules/vitest/dist/chunks/global.d.x-ILCfAE.d.ts.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js +57 -0
- package/dist/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/rpc.d.BFMWpdph.d.ts +13 -0
- package/dist/node_modules/vitest/dist/chunks/rpc.d.BFMWpdph.d.ts.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/test.CTcmp4Su.js +2791 -0
- package/dist/node_modules/vitest/dist/chunks/test.CTcmp4Su.js.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js +44 -0
- package/dist/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js.map +1 -0
- package/dist/node_modules/vitest/dist/index.d.ts +9 -0
- package/dist/queries/auth.d.ts +15 -0
- package/dist/queries/auth.d.ts.map +1 -0
- package/dist/queries/auth.js +58 -0
- package/dist/queries/auth.js.map +1 -0
- package/dist/queries/bank.d.ts +15 -0
- package/dist/queries/bank.d.ts.map +1 -0
- package/dist/queries/bank.js +93 -0
- package/dist/queries/bank.js.map +1 -0
- package/dist/queries/billing.d.ts +15 -0
- package/dist/queries/billing.d.ts.map +1 -0
- package/dist/queries/billing.js +114 -0
- package/dist/queries/billing.js.map +1 -0
- package/dist/queries/distribution.d.ts +15 -0
- package/dist/queries/distribution.d.ts.map +1 -0
- package/dist/queries/distribution.js +73 -0
- package/dist/queries/distribution.js.map +1 -0
- package/dist/queries/gov.d.ts +15 -0
- package/dist/queries/gov.d.ts.map +1 -0
- package/dist/queries/gov.js +98 -0
- package/dist/queries/gov.js.map +1 -0
- package/dist/queries/group.d.ts +15 -0
- package/dist/queries/group.d.ts.map +1 -0
- package/dist/queries/group.js +159 -0
- package/dist/queries/group.js.map +1 -0
- package/dist/queries/index.d.ts +10 -0
- package/dist/queries/index.js +10 -0
- package/dist/queries/sku.d.ts +16 -0
- package/dist/queries/sku.d.ts.map +1 -0
- package/dist/queries/sku.js +85 -0
- package/dist/queries/sku.js.map +1 -0
- package/dist/queries/staking.d.ts +15 -0
- package/dist/queries/staking.d.ts.map +1 -0
- package/dist/queries/staking.js +127 -0
- package/dist/queries/staking.js.map +1 -0
- package/dist/queries/utils.d.ts +54 -0
- package/dist/queries/utils.d.ts.map +1 -0
- package/dist/queries/utils.js +74 -0
- package/dist/queries/utils.js.map +1 -0
- package/dist/retry.d.ts +48 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +106 -0
- package/dist/retry.js.map +1 -0
- package/dist/server-utils.d.ts +61 -0
- package/dist/server-utils.d.ts.map +1 -0
- package/dist/server-utils.js +156 -0
- package/dist/server-utils.js.map +1 -0
- package/dist/tools/fundCredits.d.ts +8 -0
- package/dist/tools/fundCredits.d.ts.map +1 -0
- package/dist/tools/fundCredits.js +9 -0
- package/dist/tools/fundCredits.js.map +1 -0
- package/dist/tools/getBalance.d.ts +26 -0
- package/dist/tools/getBalance.d.ts.map +1 -0
- package/dist/tools/getBalance.js +59 -0
- package/dist/tools/getBalance.js.map +1 -0
- package/dist/tools/stopApp.d.ts +13 -0
- package/dist/tools/stopApp.d.ts.map +1 -0
- package/dist/tools/stopApp.js +15 -0
- package/dist/tools/stopApp.js.map +1 -0
- package/dist/transactions/bank.d.ts +11 -0
- package/dist/transactions/bank.d.ts.map +1 -0
- package/dist/transactions/bank.js +75 -0
- package/dist/transactions/bank.js.map +1 -0
- package/dist/transactions/billing.d.ts +11 -0
- package/dist/transactions/billing.d.ts.map +1 -0
- package/dist/transactions/billing.js +189 -0
- package/dist/transactions/billing.js.map +1 -0
- package/dist/transactions/distribution.d.ts +11 -0
- package/dist/transactions/distribution.d.ts.map +1 -0
- package/dist/transactions/distribution.js +60 -0
- package/dist/transactions/distribution.js.map +1 -0
- package/dist/transactions/gov.d.ts +11 -0
- package/dist/transactions/gov.d.ts.map +1 -0
- package/dist/transactions/gov.js +108 -0
- package/dist/transactions/gov.js.map +1 -0
- package/dist/transactions/group.d.ts +11 -0
- package/dist/transactions/group.d.ts.map +1 -0
- package/dist/transactions/group.js +347 -0
- package/dist/transactions/group.js.map +1 -0
- package/dist/transactions/index.d.ts +10 -0
- package/dist/transactions/index.js +10 -0
- package/dist/transactions/manifest.d.ts +11 -0
- package/dist/transactions/manifest.d.ts.map +1 -0
- package/dist/transactions/manifest.js +59 -0
- package/dist/transactions/manifest.js.map +1 -0
- package/dist/transactions/sku.d.ts +11 -0
- package/dist/transactions/sku.d.ts.map +1 -0
- package/dist/transactions/sku.js +191 -0
- package/dist/transactions/sku.js.map +1 -0
- package/dist/transactions/staking.d.ts +11 -0
- package/dist/transactions/staking.d.ts.map +1 -0
- package/dist/transactions/staking.js +79 -0
- package/dist/transactions/staking.js.map +1 -0
- package/dist/transactions/utils.d.ts +161 -0
- package/dist/transactions/utils.d.ts.map +1 -0
- package/dist/transactions/utils.js +272 -0
- package/dist/transactions/utils.js.map +1 -0
- package/dist/types.d.ts +390 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +45 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +30 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +53 -0
- package/dist/validation.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/wallet/index.d.ts +4 -0
- package/dist/wallet/index.js +3 -0
- package/dist/wallet/mnemonic.d.ts +47 -0
- package/dist/wallet/mnemonic.d.ts.map +1 -0
- package/dist/wallet/mnemonic.js +97 -0
- package/dist/wallet/mnemonic.js.map +1 -0
- package/dist/wallet/sign-arbitrary.d.ts +12 -0
- package/dist/wallet/sign-arbitrary.d.ts.map +1 -0
- package/dist/wallet/sign-arbitrary.js +36 -0
- package/dist/wallet/sign-arbitrary.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/__test-utils__/callTool.d.ts
|
|
5
|
+
interface ToolResult {
|
|
6
|
+
content: Array<{
|
|
7
|
+
type: string;
|
|
8
|
+
text: string;
|
|
9
|
+
}>;
|
|
10
|
+
isError?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Shared test helper: connects an MCP client to a server via in-memory
|
|
14
|
+
* transport, calls the given tool, then cleans up both transports.
|
|
15
|
+
*
|
|
16
|
+
* Cleanup always runs via the `finally` block: client and both transports
|
|
17
|
+
* are closed, then removed from `activeTransports` to prevent double-close
|
|
18
|
+
* in the caller's `afterEach`.
|
|
19
|
+
*
|
|
20
|
+
* @param server - The MCP `Server` instance (from `getServer()`)
|
|
21
|
+
* @param toolName - Name of the tool to invoke
|
|
22
|
+
* @param toolInput - Optional tool arguments
|
|
23
|
+
* @param activeTransports - Optional mutable array; transports are added
|
|
24
|
+
* before the call and removed after cleanup completes.
|
|
25
|
+
*/
|
|
26
|
+
declare function callTool(server: Server, toolName: string, toolInput?: Record<string, unknown>, activeTransports?: InMemoryTransport[]): Promise<ToolResult>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { ToolResult, callTool };
|
|
29
|
+
//# sourceMappingURL=callTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callTool.d.ts","names":[],"sources":["../../src/__test-utils__/callTool.ts"],"mappings":";;;;UAIiB,UAAA;EACf,OAAA,EAAS,KAAA;IAAQ,IAAA;IAAc,IAAA;EAAA;EAC/B,OAAA;AAAA;;;;;;;AAiBF;;;;;;;;iBAAsB,QAAA,CACpB,MAAA,EAAQ,MAAA,EACR,QAAA,UACA,SAAA,GAAW,MAAA,mBACX,gBAAA,GAAkB,iBAAA,KACjB,OAAA,CAAQ,UAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
3
|
+
//#region src/__test-utils__/callTool.ts
|
|
4
|
+
/**
|
|
5
|
+
* Shared test helper: connects an MCP client to a server via in-memory
|
|
6
|
+
* transport, calls the given tool, then cleans up both transports.
|
|
7
|
+
*
|
|
8
|
+
* Cleanup always runs via the `finally` block: client and both transports
|
|
9
|
+
* are closed, then removed from `activeTransports` to prevent double-close
|
|
10
|
+
* in the caller's `afterEach`.
|
|
11
|
+
*
|
|
12
|
+
* @param server - The MCP `Server` instance (from `getServer()`)
|
|
13
|
+
* @param toolName - Name of the tool to invoke
|
|
14
|
+
* @param toolInput - Optional tool arguments
|
|
15
|
+
* @param activeTransports - Optional mutable array; transports are added
|
|
16
|
+
* before the call and removed after cleanup completes.
|
|
17
|
+
*/
|
|
18
|
+
async function callTool(server, toolName, toolInput = {}, activeTransports = []) {
|
|
19
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
20
|
+
activeTransports.push(clientTransport, serverTransport);
|
|
21
|
+
const client = new Client({
|
|
22
|
+
name: "test-client",
|
|
23
|
+
version: "1.0.0"
|
|
24
|
+
});
|
|
25
|
+
try {
|
|
26
|
+
await server.connect(serverTransport);
|
|
27
|
+
await client.connect(clientTransport);
|
|
28
|
+
return await client.callTool({
|
|
29
|
+
name: toolName,
|
|
30
|
+
arguments: toolInput
|
|
31
|
+
});
|
|
32
|
+
} finally {
|
|
33
|
+
await client.close().catch(() => {});
|
|
34
|
+
await clientTransport.close().catch(() => {});
|
|
35
|
+
await serverTransport.close().catch(() => {});
|
|
36
|
+
for (const t of [clientTransport, serverTransport]) {
|
|
37
|
+
const idx = activeTransports.indexOf(t);
|
|
38
|
+
if (idx !== -1) activeTransports.splice(idx, 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { callTool };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=callTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callTool.js","names":[],"sources":["../../src/__test-utils__/callTool.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';\n\nexport interface ToolResult {\n content: Array<{ type: string; text: string }>;\n isError?: boolean;\n}\n\n/**\n * Shared test helper: connects an MCP client to a server via in-memory\n * transport, calls the given tool, then cleans up both transports.\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 - Optional tool arguments\n * @param activeTransports - Optional mutable array; transports are added\n * before the call and removed after cleanup completes.\n */\nexport async function callTool(\n server: Server,\n toolName: string,\n toolInput: Record<string, unknown> = {},\n activeTransports: InMemoryTransport[] = [],\n): Promise<ToolResult> {\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n activeTransports.push(clientTransport, serverTransport);\n\n const client = new Client({ name: 'test-client', version: '1.0.0' });\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":";;;;;;;;;;;;;;;;;AAuBA,eAAsB,SACpB,QACA,UACA,YAAqC,EAAE,EACvC,mBAAwC,EAAE,EACrB;CACrB,MAAM,CAAC,iBAAiB,mBACtB,kBAAkB,kBAAkB;AACtC,kBAAiB,KAAK,iBAAiB,gBAAgB;CAEvD,MAAM,SAAS,IAAI,OAAO;EAAE,MAAM;EAAe,SAAS;EAAS,CAAC;AAEpE,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"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Mock, Procedure } from "../node_modules/@vitest/spy/dist/index.js";
|
|
2
|
+
import { ManifestMCPConfig, WalletProvider } from "../types.js";
|
|
3
|
+
import { ManifestQueryClient } from "../client.js";
|
|
4
|
+
import { LeaseState } from "@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js";
|
|
5
|
+
|
|
6
|
+
//#region src/__test-utils__/mocks.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Create a mock ManifestMCPConfig with sensible defaults.
|
|
9
|
+
*/
|
|
10
|
+
declare function makeMockConfig(overrides?: Partial<ManifestMCPConfig>): ManifestMCPConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Create a mock WalletProvider.
|
|
13
|
+
* Pass `signArbitrary: true` to include a signArbitrary stub.
|
|
14
|
+
*/
|
|
15
|
+
declare function makeMockWallet(opts?: {
|
|
16
|
+
signArbitrary?: boolean;
|
|
17
|
+
}): WalletProvider;
|
|
18
|
+
/**
|
|
19
|
+
* Billing mock data defaults
|
|
20
|
+
*/
|
|
21
|
+
interface BillingOverrides {
|
|
22
|
+
balances?: {
|
|
23
|
+
denom: string;
|
|
24
|
+
amount: string;
|
|
25
|
+
}[];
|
|
26
|
+
creditAccount?: {
|
|
27
|
+
activeLeaseCount: bigint;
|
|
28
|
+
pendingLeaseCount: bigint;
|
|
29
|
+
reservedAmounts: {
|
|
30
|
+
denom: string;
|
|
31
|
+
amount: string;
|
|
32
|
+
}[];
|
|
33
|
+
} | null;
|
|
34
|
+
creditEstimate?: {
|
|
35
|
+
currentBalance: {
|
|
36
|
+
denom: string;
|
|
37
|
+
amount: string;
|
|
38
|
+
}[];
|
|
39
|
+
totalRatePerSecond: {
|
|
40
|
+
denom: string;
|
|
41
|
+
amount: string;
|
|
42
|
+
}[];
|
|
43
|
+
estimatedDurationSeconds: bigint;
|
|
44
|
+
activeLeaseCount: bigint;
|
|
45
|
+
} | null;
|
|
46
|
+
lease?: {
|
|
47
|
+
uuid: string;
|
|
48
|
+
state: LeaseState;
|
|
49
|
+
providerUuid: string;
|
|
50
|
+
createdAt?: Date;
|
|
51
|
+
closedAt?: Date;
|
|
52
|
+
} | null;
|
|
53
|
+
activeLeases?: {
|
|
54
|
+
uuid: string;
|
|
55
|
+
providerUuid: string;
|
|
56
|
+
createdAt?: Date;
|
|
57
|
+
}[];
|
|
58
|
+
pendingLeases?: {
|
|
59
|
+
uuid: string;
|
|
60
|
+
providerUuid: string;
|
|
61
|
+
createdAt?: Date;
|
|
62
|
+
}[];
|
|
63
|
+
closedLeases?: {
|
|
64
|
+
uuid: string;
|
|
65
|
+
providerUuid: string;
|
|
66
|
+
createdAt?: Date;
|
|
67
|
+
}[];
|
|
68
|
+
rejectedLeases?: {
|
|
69
|
+
uuid: string;
|
|
70
|
+
providerUuid: string;
|
|
71
|
+
createdAt?: Date;
|
|
72
|
+
}[];
|
|
73
|
+
expiredLeases?: {
|
|
74
|
+
uuid: string;
|
|
75
|
+
providerUuid: string;
|
|
76
|
+
createdAt?: Date;
|
|
77
|
+
}[];
|
|
78
|
+
}
|
|
79
|
+
interface SkuOverrides {
|
|
80
|
+
providers?: {
|
|
81
|
+
uuid: string;
|
|
82
|
+
address: string;
|
|
83
|
+
apiUrl: string;
|
|
84
|
+
active: boolean;
|
|
85
|
+
}[];
|
|
86
|
+
skus?: {
|
|
87
|
+
uuid?: string;
|
|
88
|
+
name: string;
|
|
89
|
+
providerUuid: string;
|
|
90
|
+
basePrice?: {
|
|
91
|
+
amount: string;
|
|
92
|
+
denom: string;
|
|
93
|
+
};
|
|
94
|
+
}[];
|
|
95
|
+
providerLookup?: Record<string, {
|
|
96
|
+
provider: {
|
|
97
|
+
apiUrl: string;
|
|
98
|
+
};
|
|
99
|
+
}>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Create a mock ManifestQueryClient with configurable billing, bank, and SKU data.
|
|
103
|
+
*/
|
|
104
|
+
declare function makeMockQueryClient(overrides?: {
|
|
105
|
+
billing?: BillingOverrides;
|
|
106
|
+
sku?: SkuOverrides;
|
|
107
|
+
}): ManifestQueryClient;
|
|
108
|
+
/**
|
|
109
|
+
* Create a mock CosmosClientManager.
|
|
110
|
+
*/
|
|
111
|
+
declare function makeMockClientManager(overrides?: {
|
|
112
|
+
queryClient?: ManifestQueryClient;
|
|
113
|
+
address?: string;
|
|
114
|
+
config?: ManifestMCPConfig;
|
|
115
|
+
}): {
|
|
116
|
+
getQueryClient: Mock<Procedure>;
|
|
117
|
+
getSigningClient: Mock<Procedure>;
|
|
118
|
+
getAddress: Mock<Procedure>;
|
|
119
|
+
getConfig: Mock<Procedure>;
|
|
120
|
+
acquireRateLimit: Mock<Procedure>;
|
|
121
|
+
disconnect: Mock<Procedure>;
|
|
122
|
+
};
|
|
123
|
+
//#endregion
|
|
124
|
+
export { makeMockClientManager, makeMockConfig, makeMockQueryClient, makeMockWallet };
|
|
125
|
+
//# sourceMappingURL=mocks.d.ts.map
|
|
@@ -0,0 +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,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;AAhBwB;;;AAAA,iBAsBxD,mBAAA,CAAoB,SAAA;EAClC,OAAA,GAAU,gBAAA;EACV,GAAA,GAAM,YAAA;AAAA,IA4HU,mBAAA;;;;iBAMF,qBAAA,CAAsB,SAAA;EACpC,WAAA,GAAc,mBAAA;EACd,OAAA;EACA,MAAA,GAAS,iBAAA;AAAA;uBAAiB,SAAA"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { vi } from "../node_modules/vitest/dist/chunks/test.CTcmp4Su.js";
|
|
2
|
+
import { LeaseState } from "@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js";
|
|
3
|
+
//#region src/__test-utils__/mocks.ts
|
|
4
|
+
/**
|
|
5
|
+
* Create a mock ManifestMCPConfig with sensible defaults.
|
|
6
|
+
*/
|
|
7
|
+
function makeMockConfig(overrides) {
|
|
8
|
+
return {
|
|
9
|
+
chainId: "test-chain",
|
|
10
|
+
rpcUrl: "https://rpc.example.com",
|
|
11
|
+
gasPrice: "1.0umfx",
|
|
12
|
+
addressPrefix: "manifest",
|
|
13
|
+
...overrides
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a mock WalletProvider.
|
|
18
|
+
* Pass `signArbitrary: true` to include a signArbitrary stub.
|
|
19
|
+
*/
|
|
20
|
+
function makeMockWallet(opts) {
|
|
21
|
+
const wallet = {
|
|
22
|
+
getAddress: vi.fn().mockResolvedValue("manifest1abc"),
|
|
23
|
+
getSigner: vi.fn().mockResolvedValue({})
|
|
24
|
+
};
|
|
25
|
+
if (opts?.signArbitrary) wallet.signArbitrary = vi.fn().mockResolvedValue({
|
|
26
|
+
pub_key: {
|
|
27
|
+
type: "tendermint/PubKeySecp256k1",
|
|
28
|
+
value: "mockPubKey"
|
|
29
|
+
},
|
|
30
|
+
signature: "mockSignature"
|
|
31
|
+
});
|
|
32
|
+
return wallet;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a mock ManifestQueryClient with configurable billing, bank, and SKU data.
|
|
36
|
+
*/
|
|
37
|
+
function makeMockQueryClient(overrides) {
|
|
38
|
+
const billing = overrides?.billing ?? {};
|
|
39
|
+
const sku = overrides?.sku ?? {};
|
|
40
|
+
const balances = billing.balances ?? [{
|
|
41
|
+
denom: "umfx",
|
|
42
|
+
amount: "1000000"
|
|
43
|
+
}];
|
|
44
|
+
const creditAccount = billing.creditAccount ?? null;
|
|
45
|
+
const creditEstimate = billing.creditEstimate ?? null;
|
|
46
|
+
const lease = billing.lease ?? null;
|
|
47
|
+
const activeLeases = billing.activeLeases ?? [];
|
|
48
|
+
const pendingLeases = billing.pendingLeases ?? [];
|
|
49
|
+
const closedLeases = billing.closedLeases ?? [];
|
|
50
|
+
const rejectedLeases = billing.rejectedLeases ?? [];
|
|
51
|
+
const expiredLeases = billing.expiredLeases ?? [];
|
|
52
|
+
const providers = sku.providers ?? [];
|
|
53
|
+
const skus = sku.skus ?? [];
|
|
54
|
+
const providerLookup = sku.providerLookup ?? {};
|
|
55
|
+
return {
|
|
56
|
+
cosmos: { bank: { v1beta1: { allBalances: vi.fn().mockResolvedValue({ balances }) } } },
|
|
57
|
+
liftedinit: {
|
|
58
|
+
billing: { v1: {
|
|
59
|
+
creditAccount: vi.fn().mockImplementation(async () => {
|
|
60
|
+
if (creditAccount === null) throw new Error("key not found");
|
|
61
|
+
return { creditAccount };
|
|
62
|
+
}),
|
|
63
|
+
creditEstimate: vi.fn().mockImplementation(async () => {
|
|
64
|
+
if (creditEstimate === null) throw new Error("credit not found");
|
|
65
|
+
return creditEstimate;
|
|
66
|
+
}),
|
|
67
|
+
lease: vi.fn().mockImplementation(async () => {
|
|
68
|
+
return { lease };
|
|
69
|
+
}),
|
|
70
|
+
leasesByTenant: vi.fn().mockImplementation(async ({ stateFilter }) => {
|
|
71
|
+
if (stateFilter === LeaseState.LEASE_STATE_UNSPECIFIED) return { leases: [
|
|
72
|
+
...activeLeases.map((l) => ({
|
|
73
|
+
state: LeaseState.LEASE_STATE_ACTIVE,
|
|
74
|
+
...l
|
|
75
|
+
})),
|
|
76
|
+
...pendingLeases.map((l) => ({
|
|
77
|
+
state: LeaseState.LEASE_STATE_PENDING,
|
|
78
|
+
...l
|
|
79
|
+
})),
|
|
80
|
+
...closedLeases.map((l) => ({
|
|
81
|
+
state: LeaseState.LEASE_STATE_CLOSED,
|
|
82
|
+
...l
|
|
83
|
+
})),
|
|
84
|
+
...rejectedLeases.map((l) => ({
|
|
85
|
+
state: LeaseState.LEASE_STATE_REJECTED,
|
|
86
|
+
...l
|
|
87
|
+
})),
|
|
88
|
+
...expiredLeases.map((l) => ({
|
|
89
|
+
state: LeaseState.LEASE_STATE_EXPIRED,
|
|
90
|
+
...l
|
|
91
|
+
}))
|
|
92
|
+
] };
|
|
93
|
+
if (stateFilter === LeaseState.LEASE_STATE_ACTIVE) return { leases: activeLeases.map((l) => ({
|
|
94
|
+
state: LeaseState.LEASE_STATE_ACTIVE,
|
|
95
|
+
...l
|
|
96
|
+
})) };
|
|
97
|
+
if (stateFilter === LeaseState.LEASE_STATE_PENDING) return { leases: pendingLeases.map((l) => ({
|
|
98
|
+
state: LeaseState.LEASE_STATE_PENDING,
|
|
99
|
+
...l
|
|
100
|
+
})) };
|
|
101
|
+
if (stateFilter === LeaseState.LEASE_STATE_CLOSED) return { leases: closedLeases.map((l) => ({
|
|
102
|
+
state: LeaseState.LEASE_STATE_CLOSED,
|
|
103
|
+
...l
|
|
104
|
+
})) };
|
|
105
|
+
if (stateFilter === LeaseState.LEASE_STATE_REJECTED) return { leases: rejectedLeases.map((l) => ({
|
|
106
|
+
state: LeaseState.LEASE_STATE_REJECTED,
|
|
107
|
+
...l
|
|
108
|
+
})) };
|
|
109
|
+
if (stateFilter === LeaseState.LEASE_STATE_EXPIRED) return { leases: expiredLeases.map((l) => ({
|
|
110
|
+
state: LeaseState.LEASE_STATE_EXPIRED,
|
|
111
|
+
...l
|
|
112
|
+
})) };
|
|
113
|
+
return { leases: [] };
|
|
114
|
+
})
|
|
115
|
+
} },
|
|
116
|
+
sku: { v1: {
|
|
117
|
+
providers: vi.fn().mockResolvedValue({ providers }),
|
|
118
|
+
sKUs: vi.fn().mockResolvedValue({ skus }),
|
|
119
|
+
provider: vi.fn().mockImplementation(async ({ uuid }) => {
|
|
120
|
+
if (providerLookup[uuid]) return providerLookup[uuid];
|
|
121
|
+
throw new Error(`provider ${uuid} not found`);
|
|
122
|
+
})
|
|
123
|
+
} }
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Create a mock CosmosClientManager.
|
|
129
|
+
*/
|
|
130
|
+
function makeMockClientManager(overrides) {
|
|
131
|
+
const queryClient = overrides?.queryClient ?? makeMockQueryClient();
|
|
132
|
+
const address = overrides?.address ?? "manifest1abc";
|
|
133
|
+
const config = overrides?.config ?? makeMockConfig();
|
|
134
|
+
return {
|
|
135
|
+
getQueryClient: vi.fn().mockResolvedValue(queryClient),
|
|
136
|
+
getSigningClient: vi.fn().mockResolvedValue({}),
|
|
137
|
+
getAddress: vi.fn().mockResolvedValue(address),
|
|
138
|
+
getConfig: vi.fn().mockReturnValue(config),
|
|
139
|
+
acquireRateLimit: vi.fn().mockResolvedValue(void 0),
|
|
140
|
+
disconnect: vi.fn()
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { makeMockClientManager, makeMockConfig, makeMockQueryClient, makeMockWallet };
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=mocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mocks.js","names":[],"sources":["../../src/__test-utils__/mocks.ts"],"sourcesContent":["import { LeaseState } from '@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js';\nimport { vi } from 'vitest';\nimport type { ManifestQueryClient } from '../client.js';\nimport type {\n ManifestMCPConfig,\n SignArbitraryResult,\n WalletProvider,\n} from '../types.js';\n\n/**\n * Create a mock ManifestMCPConfig with sensible defaults.\n */\nexport function makeMockConfig(\n overrides?: Partial<ManifestMCPConfig>,\n): ManifestMCPConfig {\n return {\n chainId: 'test-chain',\n rpcUrl: 'https://rpc.example.com',\n gasPrice: '1.0umfx',\n addressPrefix: 'manifest',\n ...overrides,\n };\n}\n\n/**\n * Create a mock WalletProvider.\n * Pass `signArbitrary: true` to include a signArbitrary stub.\n */\nexport function makeMockWallet(opts?: {\n signArbitrary?: boolean;\n}): WalletProvider {\n const wallet: WalletProvider = {\n getAddress: vi.fn().mockResolvedValue('manifest1abc'),\n getSigner: vi.fn().mockResolvedValue({}),\n };\n if (opts?.signArbitrary) {\n wallet.signArbitrary = vi.fn().mockResolvedValue({\n pub_key: { type: 'tendermint/PubKeySecp256k1', value: 'mockPubKey' },\n signature: 'mockSignature',\n } satisfies SignArbitraryResult);\n }\n return wallet;\n}\n\n/**\n * Billing mock data defaults\n */\ninterface BillingOverrides {\n balances?: { denom: string; amount: string }[];\n creditAccount?: {\n activeLeaseCount: bigint;\n pendingLeaseCount: bigint;\n reservedAmounts: { denom: string; amount: string }[];\n } | null;\n creditEstimate?: {\n currentBalance: { denom: string; amount: string }[];\n totalRatePerSecond: { denom: string; amount: string }[];\n estimatedDurationSeconds: bigint;\n activeLeaseCount: bigint;\n } | null;\n lease?: {\n uuid: string;\n state: LeaseState;\n providerUuid: string;\n createdAt?: Date;\n closedAt?: Date;\n } | null;\n activeLeases?: { uuid: string; providerUuid: string; createdAt?: Date }[];\n pendingLeases?: { uuid: string; providerUuid: string; createdAt?: Date }[];\n closedLeases?: { uuid: string; providerUuid: string; createdAt?: Date }[];\n rejectedLeases?: { uuid: string; providerUuid: string; createdAt?: Date }[];\n expiredLeases?: { uuid: string; providerUuid: string; createdAt?: Date }[];\n}\n\ninterface SkuOverrides {\n providers?: {\n uuid: string;\n address: string;\n apiUrl: string;\n active: boolean;\n }[];\n skus?: {\n uuid?: string;\n name: string;\n providerUuid: string;\n basePrice?: { amount: string; denom: string };\n }[];\n providerLookup?: Record<string, { provider: { apiUrl: string } }>;\n}\n\n/**\n * Create a mock ManifestQueryClient with configurable billing, bank, and SKU data.\n */\nexport function makeMockQueryClient(overrides?: {\n billing?: BillingOverrides;\n sku?: SkuOverrides;\n}) {\n const billing = overrides?.billing ?? {};\n const sku = overrides?.sku ?? {};\n\n const balances = billing.balances ?? [{ denom: 'umfx', amount: '1000000' }];\n const creditAccount = billing.creditAccount ?? null;\n const creditEstimate = billing.creditEstimate ?? null;\n const lease = billing.lease ?? null;\n const activeLeases = billing.activeLeases ?? [];\n const pendingLeases = billing.pendingLeases ?? [];\n const closedLeases = billing.closedLeases ?? [];\n const rejectedLeases = billing.rejectedLeases ?? [];\n const expiredLeases = billing.expiredLeases ?? [];\n\n const providers = sku.providers ?? [];\n const skus = sku.skus ?? [];\n const providerLookup = sku.providerLookup ?? {};\n\n return {\n cosmos: {\n bank: {\n v1beta1: {\n allBalances: vi.fn().mockResolvedValue({ balances }),\n },\n },\n },\n liftedinit: {\n billing: {\n v1: {\n creditAccount: vi.fn().mockImplementation(async () => {\n if (creditAccount === null) throw new Error('key not found');\n return { creditAccount };\n }),\n creditEstimate: vi.fn().mockImplementation(async () => {\n if (creditEstimate === null) throw new Error('credit not found');\n return creditEstimate;\n }),\n lease: vi.fn().mockImplementation(async () => {\n return { lease };\n }),\n leasesByTenant: vi\n .fn()\n .mockImplementation(\n async ({ stateFilter }: { stateFilter: LeaseState }) => {\n if (stateFilter === LeaseState.LEASE_STATE_UNSPECIFIED) {\n return {\n leases: [\n ...activeLeases.map((l) => ({\n state: LeaseState.LEASE_STATE_ACTIVE,\n ...l,\n })),\n ...pendingLeases.map((l) => ({\n state: LeaseState.LEASE_STATE_PENDING,\n ...l,\n })),\n ...closedLeases.map((l) => ({\n state: LeaseState.LEASE_STATE_CLOSED,\n ...l,\n })),\n ...rejectedLeases.map((l) => ({\n state: LeaseState.LEASE_STATE_REJECTED,\n ...l,\n })),\n ...expiredLeases.map((l) => ({\n state: LeaseState.LEASE_STATE_EXPIRED,\n ...l,\n })),\n ],\n };\n }\n if (stateFilter === LeaseState.LEASE_STATE_ACTIVE)\n return {\n leases: activeLeases.map((l) => ({\n state: LeaseState.LEASE_STATE_ACTIVE,\n ...l,\n })),\n };\n if (stateFilter === LeaseState.LEASE_STATE_PENDING)\n return {\n leases: pendingLeases.map((l) => ({\n state: LeaseState.LEASE_STATE_PENDING,\n ...l,\n })),\n };\n if (stateFilter === LeaseState.LEASE_STATE_CLOSED)\n return {\n leases: closedLeases.map((l) => ({\n state: LeaseState.LEASE_STATE_CLOSED,\n ...l,\n })),\n };\n if (stateFilter === LeaseState.LEASE_STATE_REJECTED)\n return {\n leases: rejectedLeases.map((l) => ({\n state: LeaseState.LEASE_STATE_REJECTED,\n ...l,\n })),\n };\n if (stateFilter === LeaseState.LEASE_STATE_EXPIRED)\n return {\n leases: expiredLeases.map((l) => ({\n state: LeaseState.LEASE_STATE_EXPIRED,\n ...l,\n })),\n };\n return { leases: [] };\n },\n ),\n },\n },\n sku: {\n v1: {\n providers: vi.fn().mockResolvedValue({ providers }),\n sKUs: vi.fn().mockResolvedValue({ skus }),\n provider: vi\n .fn()\n .mockImplementation(async ({ uuid }: { uuid: string }) => {\n if (providerLookup[uuid]) return providerLookup[uuid];\n throw new Error(`provider ${uuid} not found`);\n }),\n },\n },\n },\n } as unknown as ManifestQueryClient;\n}\n\n/**\n * Create a mock CosmosClientManager.\n */\nexport function makeMockClientManager(overrides?: {\n queryClient?: ManifestQueryClient;\n address?: string;\n config?: ManifestMCPConfig;\n}) {\n const queryClient = overrides?.queryClient ?? makeMockQueryClient();\n const address = overrides?.address ?? 'manifest1abc';\n const config = overrides?.config ?? makeMockConfig();\n\n return {\n getQueryClient: vi.fn().mockResolvedValue(queryClient),\n getSigningClient: vi.fn().mockResolvedValue({}),\n getAddress: vi.fn().mockResolvedValue(address),\n getConfig: vi.fn().mockReturnValue(config),\n acquireRateLimit: vi.fn().mockResolvedValue(undefined),\n disconnect: vi.fn(),\n };\n}\n"],"mappings":"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"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ManifestMCPConfig, WalletProvider } from "./types.js";
|
|
2
|
+
import { SigningStargateClient } from "@cosmjs/stargate";
|
|
3
|
+
import { liftedinit } from "@manifest-network/manifestjs";
|
|
4
|
+
|
|
5
|
+
//#region src/client.d.ts
|
|
6
|
+
type ManifestQueryClient = Awaited<ReturnType<typeof liftedinit.ClientFactory.createRPCQueryClient>>;
|
|
7
|
+
/**
|
|
8
|
+
* Manages CosmJS client instances with lazy initialization and singleton pattern
|
|
9
|
+
*/
|
|
10
|
+
declare class CosmosClientManager {
|
|
11
|
+
private static instances;
|
|
12
|
+
private config;
|
|
13
|
+
private walletProvider;
|
|
14
|
+
private queryClient;
|
|
15
|
+
private signingClient;
|
|
16
|
+
private rateLimiter;
|
|
17
|
+
private queryClientPromise;
|
|
18
|
+
private signingClientPromise;
|
|
19
|
+
private constructor();
|
|
20
|
+
/**
|
|
21
|
+
* Get or create a singleton instance for the given config.
|
|
22
|
+
* Instances are keyed by chainId:rpcUrl:restUrl. For existing instances:
|
|
23
|
+
* - Config and walletProvider references are always updated
|
|
24
|
+
* - Signing client is disconnected/recreated if gasPrice or walletProvider changed
|
|
25
|
+
* - Rate limiter is updated if requestsPerSecond changed (without affecting signing client)
|
|
26
|
+
*/
|
|
27
|
+
static getInstance(config: ManifestMCPConfig, walletProvider: WalletProvider): CosmosClientManager;
|
|
28
|
+
/**
|
|
29
|
+
* Clear all cached instances (useful for testing or reconnection).
|
|
30
|
+
* Disconnects signing clients and releases query client references before clearing.
|
|
31
|
+
*/
|
|
32
|
+
static clearInstances(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Get the manifestjs RPC query client with all module extensions
|
|
35
|
+
*
|
|
36
|
+
* Automatically retries on transient connection failures with exponential backoff.
|
|
37
|
+
*/
|
|
38
|
+
getQueryClient(): Promise<ManifestQueryClient>;
|
|
39
|
+
/**
|
|
40
|
+
* Get a signing client with all Manifest registries (for transactions)
|
|
41
|
+
*
|
|
42
|
+
* Automatically retries on transient connection failures with exponential backoff.
|
|
43
|
+
*/
|
|
44
|
+
getSigningClient(): Promise<SigningStargateClient>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the wallet address
|
|
47
|
+
*/
|
|
48
|
+
getAddress(): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Get the configuration
|
|
51
|
+
*/
|
|
52
|
+
getConfig(): ManifestMCPConfig;
|
|
53
|
+
/**
|
|
54
|
+
* Acquire a rate limit token before making an RPC request.
|
|
55
|
+
* This will wait if the rate limit has been exceeded.
|
|
56
|
+
*/
|
|
57
|
+
acquireRateLimit(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Disconnect the signing client and release query client references.
|
|
60
|
+
* The query client's underlying HTTP transport is stateless and does not
|
|
61
|
+
* require an explicit disconnect.
|
|
62
|
+
*/
|
|
63
|
+
disconnect(): void;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { CosmosClientManager, ManifestQueryClient };
|
|
67
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;KA+BY,mBAAA,GAAsB,OAAA,CAChC,UAAA,QAAkB,UAAA,CAAW,aAAA,CAAc,oBAAA;;AAD7C;;cA+Ca,mBAAA;EAAA,eACI,SAAA;EAAA,QAEP,MAAA;EAAA,QACA,cAAA;EAAA,QACA,WAAA;EAAA,QACA,aAAA;EAAA,QACA,WAAA;EAAA,QAGA,kBAAA;EAAA,QACA,oBAAA;EAAA,QAED,WAAA,CAAA;EA3DoC;;;AA8C7C;;;;EA9C6C,OAkFpC,WAAA,CACL,MAAA,EAAQ,iBAAA,EACR,cAAA,EAAgB,cAAA,GACf,mBAAA;EAAA;;;;EAAA,OAmDI,cAAA,CAAA;EAyKa;;;;;EA7Jd,cAAA,CAAA,GAAkB,OAAA,CAAQ,mBAAA;EAnGxB;;;;;EA8KF,gBAAA,CAAA,GAAoB,OAAA,CAAQ,qBAAA;EAtK1B;;;EAwPF,UAAA,CAAA,GAAc,OAAA;EA9NlB;;;EAqOF,SAAA,CAAA,GAAa,iBAAA;EAhLN;;;;EAwLD,gBAAA,CAAA,GAAoB,OAAA;EAjGA;;;;;EA0G1B,UAAA,CAAA;AAAA"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { ManifestMCPError, ManifestMCPErrorCode } from "./types.js";
|
|
2
|
+
import { withRetry } from "./retry.js";
|
|
3
|
+
import "./config.js";
|
|
4
|
+
import { createLCDQueryClient } from "./lcd-adapter.js";
|
|
5
|
+
import { Registry } from "@cosmjs/proto-signing";
|
|
6
|
+
import { AminoTypes, GasPrice, SigningStargateClient } from "@cosmjs/stargate";
|
|
7
|
+
import { cosmosAminoConverters, cosmosProtoRegistry, liftedinit, liftedinitAminoConverters, liftedinitProtoRegistry, osmosisAminoConverters, osmosisProtoRegistry, strangeloveVenturesAminoConverters, strangeloveVenturesProtoRegistry } from "@manifest-network/manifestjs";
|
|
8
|
+
import { RateLimiter } from "limiter";
|
|
9
|
+
//#region src/client.ts
|
|
10
|
+
/** Default timeout for transaction broadcast (60 seconds) */
|
|
11
|
+
const DEFAULT_BROADCAST_TIMEOUT_MS = 6e4;
|
|
12
|
+
/** Default polling interval for transaction confirmation (3 seconds) */
|
|
13
|
+
const DEFAULT_BROADCAST_POLL_INTERVAL_MS = 3e3;
|
|
14
|
+
/**
|
|
15
|
+
* Get combined signing client options with all Manifest registries
|
|
16
|
+
*/
|
|
17
|
+
function getSigningManifestClientOptions() {
|
|
18
|
+
return {
|
|
19
|
+
registry: new Registry([
|
|
20
|
+
...cosmosProtoRegistry,
|
|
21
|
+
...liftedinitProtoRegistry,
|
|
22
|
+
...strangeloveVenturesProtoRegistry,
|
|
23
|
+
...osmosisProtoRegistry
|
|
24
|
+
]),
|
|
25
|
+
aminoTypes: new AminoTypes({
|
|
26
|
+
...cosmosAminoConverters,
|
|
27
|
+
...liftedinitAminoConverters,
|
|
28
|
+
...strangeloveVenturesAminoConverters,
|
|
29
|
+
...osmosisAminoConverters
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Manages CosmJS client instances with lazy initialization and singleton pattern
|
|
35
|
+
*/
|
|
36
|
+
var CosmosClientManager = class CosmosClientManager {
|
|
37
|
+
constructor(config, walletProvider) {
|
|
38
|
+
this.queryClient = null;
|
|
39
|
+
this.signingClient = null;
|
|
40
|
+
this.queryClientPromise = null;
|
|
41
|
+
this.signingClientPromise = null;
|
|
42
|
+
this.config = config;
|
|
43
|
+
this.walletProvider = walletProvider;
|
|
44
|
+
this.rateLimiter = new RateLimiter({
|
|
45
|
+
tokensPerInterval: config.rateLimit?.requestsPerSecond ?? 10,
|
|
46
|
+
interval: "second"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get or create a singleton instance for the given config.
|
|
51
|
+
* Instances are keyed by chainId:rpcUrl:restUrl. For existing instances:
|
|
52
|
+
* - Config and walletProvider references are always updated
|
|
53
|
+
* - Signing client is disconnected/recreated if gasPrice or walletProvider changed
|
|
54
|
+
* - Rate limiter is updated if requestsPerSecond changed (without affecting signing client)
|
|
55
|
+
*/
|
|
56
|
+
static getInstance(config, walletProvider) {
|
|
57
|
+
const parts = [config.chainId, config.rpcUrl ?? ""];
|
|
58
|
+
if (config.restUrl) parts.push(config.restUrl);
|
|
59
|
+
const key = parts.join(":");
|
|
60
|
+
let instance = CosmosClientManager.instances.get(key);
|
|
61
|
+
if (!instance) {
|
|
62
|
+
instance = new CosmosClientManager(config, walletProvider);
|
|
63
|
+
CosmosClientManager.instances.set(key, instance);
|
|
64
|
+
} else {
|
|
65
|
+
const signingClientAffected = instance.config.gasPrice !== config.gasPrice || instance.walletProvider !== walletProvider;
|
|
66
|
+
const rateLimitChanged = instance.config.rateLimit?.requestsPerSecond !== config.rateLimit?.requestsPerSecond;
|
|
67
|
+
instance.config = config;
|
|
68
|
+
instance.walletProvider = walletProvider;
|
|
69
|
+
if (signingClientAffected) {
|
|
70
|
+
if (instance.signingClient) {
|
|
71
|
+
instance.signingClient.disconnect();
|
|
72
|
+
instance.signingClient = null;
|
|
73
|
+
}
|
|
74
|
+
instance.signingClientPromise = null;
|
|
75
|
+
}
|
|
76
|
+
if (rateLimitChanged) {
|
|
77
|
+
const newRps = config.rateLimit?.requestsPerSecond ?? 10;
|
|
78
|
+
instance.rateLimiter = new RateLimiter({
|
|
79
|
+
tokensPerInterval: newRps,
|
|
80
|
+
interval: "second"
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return instance;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Clear all cached instances (useful for testing or reconnection).
|
|
88
|
+
* Disconnects signing clients and releases query client references before clearing.
|
|
89
|
+
*/
|
|
90
|
+
static clearInstances() {
|
|
91
|
+
for (const instance of CosmosClientManager.instances.values()) instance.disconnect();
|
|
92
|
+
CosmosClientManager.instances.clear();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get the manifestjs RPC query client with all module extensions
|
|
96
|
+
*
|
|
97
|
+
* Automatically retries on transient connection failures with exponential backoff.
|
|
98
|
+
*/
|
|
99
|
+
async getQueryClient() {
|
|
100
|
+
if (this.queryClient) return this.queryClient;
|
|
101
|
+
if (this.queryClientPromise) return this.queryClientPromise;
|
|
102
|
+
this.queryClientPromise = (async () => {
|
|
103
|
+
const thisInitPromise = this.queryClientPromise;
|
|
104
|
+
try {
|
|
105
|
+
let client;
|
|
106
|
+
if (this.config.restUrl) client = await withRetry(() => createLCDQueryClient(this.config.restUrl), {
|
|
107
|
+
config: this.config.retry,
|
|
108
|
+
operationName: "connect LCD query client"
|
|
109
|
+
});
|
|
110
|
+
else if (this.config.rpcUrl) client = await withRetry(() => liftedinit.ClientFactory.createRPCQueryClient({ rpcEndpoint: this.config.rpcUrl }), {
|
|
111
|
+
config: this.config.retry,
|
|
112
|
+
operationName: "connect query client"
|
|
113
|
+
});
|
|
114
|
+
else throw new ManifestMCPError(ManifestMCPErrorCode.INVALID_CONFIG, "Cannot create query client: neither restUrl nor rpcUrl is configured.");
|
|
115
|
+
if (this.queryClientPromise === thisInitPromise) {
|
|
116
|
+
this.queryClient = client;
|
|
117
|
+
this.queryClientPromise = null;
|
|
118
|
+
}
|
|
119
|
+
return client;
|
|
120
|
+
} catch (error) {
|
|
121
|
+
if (this.queryClientPromise === thisInitPromise) this.queryClientPromise = null;
|
|
122
|
+
if (error instanceof ManifestMCPError) throw error;
|
|
123
|
+
const endpoint = this.config.restUrl ?? this.config.rpcUrl;
|
|
124
|
+
throw new ManifestMCPError(ManifestMCPErrorCode.RPC_CONNECTION_FAILED, `Failed to connect to ${this.config.restUrl ? "REST" : "RPC"} endpoint: ${error instanceof Error ? error.message : String(error)}`, { url: endpoint });
|
|
125
|
+
}
|
|
126
|
+
})();
|
|
127
|
+
return this.queryClientPromise;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get a signing client with all Manifest registries (for transactions)
|
|
131
|
+
*
|
|
132
|
+
* Automatically retries on transient connection failures with exponential backoff.
|
|
133
|
+
*/
|
|
134
|
+
async getSigningClient() {
|
|
135
|
+
if (!this.config.rpcUrl || !this.config.gasPrice) throw new ManifestMCPError(ManifestMCPErrorCode.INVALID_CONFIG, "Signing client requires rpcUrl and gasPrice configuration. Current config is query-only (REST).");
|
|
136
|
+
if (this.signingClient) return this.signingClient;
|
|
137
|
+
if (this.signingClientPromise) return this.signingClientPromise;
|
|
138
|
+
this.signingClientPromise = (async () => {
|
|
139
|
+
const thisInitPromise = this.signingClientPromise;
|
|
140
|
+
try {
|
|
141
|
+
const signer = await this.walletProvider.getSigner();
|
|
142
|
+
const gasPrice = GasPrice.fromString(this.config.gasPrice);
|
|
143
|
+
const { registry, aminoTypes } = getSigningManifestClientOptions();
|
|
144
|
+
const endpoint = {
|
|
145
|
+
url: this.config.rpcUrl,
|
|
146
|
+
headers: {}
|
|
147
|
+
};
|
|
148
|
+
const client = await withRetry(() => SigningStargateClient.connectWithSigner(endpoint, signer, {
|
|
149
|
+
registry,
|
|
150
|
+
aminoTypes,
|
|
151
|
+
gasPrice,
|
|
152
|
+
broadcastTimeoutMs: DEFAULT_BROADCAST_TIMEOUT_MS,
|
|
153
|
+
broadcastPollIntervalMs: DEFAULT_BROADCAST_POLL_INTERVAL_MS
|
|
154
|
+
}), {
|
|
155
|
+
config: this.config.retry,
|
|
156
|
+
operationName: "connect signing client"
|
|
157
|
+
});
|
|
158
|
+
if (this.signingClientPromise === thisInitPromise) {
|
|
159
|
+
this.signingClient = client;
|
|
160
|
+
this.signingClientPromise = null;
|
|
161
|
+
} else client.disconnect();
|
|
162
|
+
return client;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
if (this.signingClientPromise === thisInitPromise) this.signingClientPromise = null;
|
|
165
|
+
if (error instanceof ManifestMCPError) throw error;
|
|
166
|
+
throw new ManifestMCPError(ManifestMCPErrorCode.RPC_CONNECTION_FAILED, `Failed to connect signing client: ${error instanceof Error ? error.message : String(error)}`, { rpcUrl: this.config.rpcUrl });
|
|
167
|
+
}
|
|
168
|
+
})();
|
|
169
|
+
return this.signingClientPromise;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get the wallet address
|
|
173
|
+
*/
|
|
174
|
+
async getAddress() {
|
|
175
|
+
return this.walletProvider.getAddress();
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Get the configuration
|
|
179
|
+
*/
|
|
180
|
+
getConfig() {
|
|
181
|
+
return this.config;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Acquire a rate limit token before making an RPC request.
|
|
185
|
+
* This will wait if the rate limit has been exceeded.
|
|
186
|
+
*/
|
|
187
|
+
async acquireRateLimit() {
|
|
188
|
+
await this.rateLimiter.removeTokens(1);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Disconnect the signing client and release query client references.
|
|
192
|
+
* The query client's underlying HTTP transport is stateless and does not
|
|
193
|
+
* require an explicit disconnect.
|
|
194
|
+
*/
|
|
195
|
+
disconnect() {
|
|
196
|
+
if (this.signingClient) {
|
|
197
|
+
this.signingClient.disconnect();
|
|
198
|
+
this.signingClient = null;
|
|
199
|
+
}
|
|
200
|
+
this.signingClientPromise = null;
|
|
201
|
+
this.queryClient = null;
|
|
202
|
+
this.queryClientPromise = null;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
CosmosClientManager.instances = /* @__PURE__ */ new Map();
|
|
206
|
+
//#endregion
|
|
207
|
+
export { CosmosClientManager };
|
|
208
|
+
|
|
209
|
+
//# sourceMappingURL=client.js.map
|