@manifest-network/manifest-mcp-core 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.ts CHANGED
@@ -21,7 +21,7 @@ declare class CosmosClientManager {
21
21
  * Get or create a singleton instance for the given config.
22
22
  * Instances are keyed by chainId:rpcUrl:restUrl. For existing instances:
23
23
  * - Config and walletProvider references are always updated
24
- * - Signing client is disconnected/recreated if gasPrice or walletProvider changed
24
+ * - Signing client is disconnected/recreated if gasPrice, gasMultiplier, or walletProvider changed
25
25
  * - Rate limiter is updated if requestsPerSecond changed (without affecting signing client)
26
26
  */
27
27
  static getInstance(config: ManifestMCPConfig, walletProvider: WalletProvider): CosmosClientManager;
@@ -1 +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;;cAsDa,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;EAlEoC;;;AAqD7C;;;;EArD6C,OAyFpC,WAAA,CACL,MAAA,EAAQ,iBAAA,EACR,cAAA,EAAgB,cAAA,GACf,mBAAA;EAAA;;;;EAAA,OAmDI,cAAA,CAAA;EAqLa;;;;;EAzKd,cAAA,CAAA,GAAkB,OAAA,CAAQ,mBAAA;EAnGxB;;;;;EA8KF,gBAAA,CAAA,GAAoB,OAAA,CAAQ,qBAAA;EAtK1B;;;EAoQF,UAAA,CAAA,GAAc,OAAA;EA1OlB;;;EAiPF,SAAA,CAAA,GAAa,iBAAA;EA5LN;;;;EAoMD,gBAAA,CAAA,GAAoB,OAAA;EA7GA;;;;;EAsH1B,UAAA,CAAA;AAAA"}
1
+ {"version":3,"file":"client.d.ts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;KAmCY,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,OAoDI,cAAA,CAAA;EA8La;;;;;EAlLd,cAAA,CAAA,GAAkB,OAAA,CAAQ,mBAAA;EApGxB;;;;;EA+KF,gBAAA,CAAA,GAAoB,OAAA,CAAQ,qBAAA;EAvK1B;;;EA8QF,UAAA,CAAA,GAAc,OAAA;EApPlB;;;EA2PF,SAAA,CAAA,GAAa,iBAAA;EArMN;;;;EA6MD,gBAAA,CAAA,GAAoB,OAAA;EAtHA;;;;;EA+H1B,UAAA,CAAA;AAAA"}
package/dist/client.js CHANGED
@@ -2,6 +2,7 @@ import { ManifestMCPError, ManifestMCPErrorCode } from "./types.js";
2
2
  import { withRetry } from "./retry.js";
3
3
  import "./config.js";
4
4
  import { createLCDQueryClient } from "./lcd-adapter.js";
5
+ import { logger } from "./logger.js";
5
6
  import { Registry } from "@cosmjs/proto-signing";
6
7
  import { AminoTypes, GasPrice, SigningStargateClient } from "@cosmjs/stargate";
7
8
  import { cosmosAminoConverters, cosmosProtoRegistry, liftedinit, liftedinitAminoConverters, liftedinitProtoRegistry, osmosisAminoConverters, osmosisProtoRegistry, strangeloveVenturesAminoConverters, strangeloveVenturesProtoRegistry } from "@manifest-network/manifestjs";
@@ -12,12 +13,6 @@ const DEFAULT_BROADCAST_TIMEOUT_MS = 6e4;
12
13
  /** Default polling interval for transaction confirmation (3 seconds) */
13
14
  const DEFAULT_BROADCAST_POLL_INTERVAL_MS = 3e3;
14
15
  /**
15
- * Gas simulation multiplier. CosmJS defaults to 1.4 but billing module
16
- * transactions (close-lease in particular) can exceed that. 1.5 matches
17
- * the --gas-adjustment used by the CLI.
18
- */
19
- const DEFAULT_GAS_MULTIPLIER = 1.5;
20
- /**
21
16
  * Get combined signing client options with all Manifest registries
22
17
  */
23
18
  function getSigningManifestClientOptions() {
@@ -56,7 +51,7 @@ var CosmosClientManager = class CosmosClientManager {
56
51
  * Get or create a singleton instance for the given config.
57
52
  * Instances are keyed by chainId:rpcUrl:restUrl. For existing instances:
58
53
  * - Config and walletProvider references are always updated
59
- * - Signing client is disconnected/recreated if gasPrice or walletProvider changed
54
+ * - Signing client is disconnected/recreated if gasPrice, gasMultiplier, or walletProvider changed
60
55
  * - Rate limiter is updated if requestsPerSecond changed (without affecting signing client)
61
56
  */
62
57
  static getInstance(config, walletProvider) {
@@ -68,7 +63,7 @@ var CosmosClientManager = class CosmosClientManager {
68
63
  instance = new CosmosClientManager(config, walletProvider);
69
64
  CosmosClientManager.instances.set(key, instance);
70
65
  } else {
71
- const signingClientAffected = instance.config.gasPrice !== config.gasPrice || instance.walletProvider !== walletProvider;
66
+ const signingClientAffected = instance.config.gasPrice !== config.gasPrice || instance.config.gasMultiplier !== config.gasMultiplier || instance.walletProvider !== walletProvider;
72
67
  const rateLimitChanged = instance.config.rateLimit?.requestsPerSecond !== config.rateLimit?.requestsPerSecond;
73
68
  instance.config = config;
74
69
  instance.walletProvider = walletProvider;
@@ -160,7 +155,11 @@ var CosmosClientManager = class CosmosClientManager {
160
155
  broadcastPollIntervalMs: DEFAULT_BROADCAST_POLL_INTERVAL_MS
161
156
  });
162
157
  const record = c;
163
- if (typeof record.defaultGasMultiplier === "number") record.defaultGasMultiplier = DEFAULT_GAS_MULTIPLIER;
158
+ if (typeof record.defaultGasMultiplier === "number") record.defaultGasMultiplier = this.config.gasMultiplier ?? 1.5;
159
+ else {
160
+ const effective = this.config.gasMultiplier ?? 1.5;
161
+ logger.warn(`gasMultiplier ${effective} could not be applied: signing client defaultGasMultiplier is ${typeof record.defaultGasMultiplier}, expected number. Transactions will use the CosmJS built-in gas multiplier instead.`);
162
+ }
164
163
  return c;
165
164
  }, {
166
165
  config: this.config.retry,
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["import { Registry } from '@cosmjs/proto-signing';\nimport {\n AminoTypes,\n GasPrice,\n type HttpEndpoint,\n SigningStargateClient,\n} from '@cosmjs/stargate';\nimport {\n cosmosAminoConverters,\n cosmosProtoRegistry,\n liftedinit,\n liftedinitAminoConverters,\n liftedinitProtoRegistry,\n osmosisAminoConverters,\n osmosisProtoRegistry,\n strangeloveVenturesAminoConverters,\n strangeloveVenturesProtoRegistry,\n} from '@manifest-network/manifestjs';\nimport { RateLimiter } from 'limiter';\nimport { DEFAULT_REQUESTS_PER_SECOND } from './config.js';\nimport { createLCDQueryClient } from './lcd-adapter.js';\nimport { withRetry } from './retry.js';\nimport {\n type ManifestMCPConfig,\n ManifestMCPError,\n ManifestMCPErrorCode,\n type WalletProvider,\n} from './types.js';\n\n// Type for the RPC query client from manifestjs liftedinit bundle\n// This includes cosmos modules + liftedinit-specific modules (billing, manifest, sku)\nexport type ManifestQueryClient = Awaited<\n ReturnType<typeof liftedinit.ClientFactory.createRPCQueryClient>\n>;\n\n/**\n * Extract the registry type expected by SigningStargateClient.connectWithSigner.\n *\n * The Registry type from @cosmjs/proto-signing doesn't perfectly match the registry type\n * in SigningStargateClientOptions due to telescope-generated proto types. This type alias\n * extracts the expected registry type from the function signature to enable type-safe casting.\n */\ntype SigningClientRegistry = Parameters<\n typeof SigningStargateClient.connectWithSigner\n>[2] extends { registry?: infer R }\n ? R\n : never;\n\n/** Default timeout for transaction broadcast (60 seconds) */\nconst DEFAULT_BROADCAST_TIMEOUT_MS = 60_000;\n\n/** Default polling interval for transaction confirmation (3 seconds) */\nconst DEFAULT_BROADCAST_POLL_INTERVAL_MS = 3_000;\n\n/**\n * 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 used by the CLI.\n */\nconst DEFAULT_GAS_MULTIPLIER = 1.5;\n\n/**\n * Get combined signing client options with all Manifest registries\n */\nfunction getSigningManifestClientOptions() {\n const registry = new Registry([\n ...cosmosProtoRegistry,\n ...liftedinitProtoRegistry,\n ...strangeloveVenturesProtoRegistry,\n ...osmosisProtoRegistry,\n ]);\n\n const aminoTypes = new AminoTypes({\n ...cosmosAminoConverters,\n ...liftedinitAminoConverters,\n ...strangeloveVenturesAminoConverters,\n ...osmosisAminoConverters,\n });\n\n return { registry, aminoTypes };\n}\n\n/**\n * Manages CosmJS client instances with lazy initialization and singleton pattern\n */\nexport class CosmosClientManager {\n private static instances: Map<string, CosmosClientManager> = new Map();\n\n private config: ManifestMCPConfig;\n private walletProvider: WalletProvider;\n private queryClient: ManifestQueryClient | null = null;\n private signingClient: SigningStargateClient | null = null;\n private rateLimiter: RateLimiter;\n\n // Promises to prevent concurrent client initialization (lazy init race condition)\n private queryClientPromise: Promise<ManifestQueryClient> | null = null;\n private signingClientPromise: Promise<SigningStargateClient> | null = null;\n\n private constructor(\n config: ManifestMCPConfig,\n walletProvider: WalletProvider,\n ) {\n this.config = config;\n this.walletProvider = walletProvider;\n\n // Initialize rate limiter with configured or default requests per second\n const requestsPerSecond =\n config.rateLimit?.requestsPerSecond ?? DEFAULT_REQUESTS_PER_SECOND;\n this.rateLimiter = new RateLimiter({\n tokensPerInterval: requestsPerSecond,\n interval: 'second',\n });\n }\n\n /**\n * Get or create a singleton instance for the given config.\n * Instances are keyed by chainId:rpcUrl:restUrl. For existing instances:\n * - Config and walletProvider references are always updated\n * - Signing client is disconnected/recreated if gasPrice or walletProvider changed\n * - Rate limiter is updated if requestsPerSecond changed (without affecting signing client)\n */\n static getInstance(\n config: ManifestMCPConfig,\n walletProvider: WalletProvider,\n ): CosmosClientManager {\n const parts = [config.chainId, config.rpcUrl ?? ''];\n if (config.restUrl) parts.push(config.restUrl);\n const key = parts.join(':');\n let instance = CosmosClientManager.instances.get(key);\n\n if (!instance) {\n instance = new CosmosClientManager(config, walletProvider);\n CosmosClientManager.instances.set(key, instance);\n } else {\n // Check what changed to determine what needs updating\n const signingClientAffected =\n instance.config.gasPrice !== config.gasPrice ||\n instance.walletProvider !== walletProvider;\n\n const rateLimitChanged =\n instance.config.rateLimit?.requestsPerSecond !==\n config.rateLimit?.requestsPerSecond;\n\n // Always update config reference\n instance.config = config;\n instance.walletProvider = walletProvider;\n\n // Only invalidate signing client if fields it depends on changed\n if (signingClientAffected) {\n if (instance.signingClient) {\n instance.signingClient.disconnect();\n instance.signingClient = null;\n }\n // Also clear the promise to allow re-initialization with new config\n instance.signingClientPromise = null;\n }\n\n // Update rate limiter independently (doesn't affect signing client)\n if (rateLimitChanged) {\n const newRps =\n config.rateLimit?.requestsPerSecond ?? DEFAULT_REQUESTS_PER_SECOND;\n instance.rateLimiter = new RateLimiter({\n tokensPerInterval: newRps,\n interval: 'second',\n });\n }\n }\n\n return instance;\n }\n\n /**\n * Clear all cached instances (useful for testing or reconnection).\n * Disconnects signing clients and releases query client references before clearing.\n */\n static clearInstances(): void {\n for (const instance of CosmosClientManager.instances.values()) {\n instance.disconnect();\n }\n CosmosClientManager.instances.clear();\n }\n\n /**\n * Get the manifestjs RPC query client with all module extensions\n *\n * Automatically retries on transient connection failures with exponential backoff.\n */\n async getQueryClient(): Promise<ManifestQueryClient> {\n // Return cached client if available\n if (this.queryClient) {\n return this.queryClient;\n }\n\n // If initialization is already in progress, wait for it\n if (this.queryClientPromise) {\n return this.queryClientPromise;\n }\n\n // Start initialization and cache the promise to prevent concurrent init\n this.queryClientPromise = (async () => {\n // Capture reference to detect if superseded by disconnect/config change\n const thisInitPromise = this.queryClientPromise;\n try {\n let client: ManifestQueryClient;\n if (this.config.restUrl) {\n // Use LCD/REST for queries when restUrl is configured\n client = await withRetry(\n () => createLCDQueryClient(this.config.restUrl!),\n {\n config: this.config.retry,\n operationName: 'connect LCD query client',\n },\n );\n } else if (this.config.rpcUrl) {\n // Use RPC (existing behavior)\n client = await withRetry(\n () =>\n liftedinit.ClientFactory.createRPCQueryClient({\n rpcEndpoint: this.config.rpcUrl!,\n }),\n {\n config: this.config.retry,\n operationName: 'connect query client',\n },\n );\n } else {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n 'Cannot create query client: neither restUrl nor rpcUrl is configured.',\n );\n }\n // Only store if this is still the active promise\n if (this.queryClientPromise === thisInitPromise) {\n this.queryClient = client;\n this.queryClientPromise = null;\n }\n return client;\n } catch (error) {\n // Clear promise on failure so retry is possible (only if still active)\n if (this.queryClientPromise === thisInitPromise) {\n this.queryClientPromise = null;\n }\n if (error instanceof ManifestMCPError) {\n throw error;\n }\n const endpoint = this.config.restUrl ?? this.config.rpcUrl;\n throw new ManifestMCPError(\n ManifestMCPErrorCode.RPC_CONNECTION_FAILED,\n `Failed to connect to ${this.config.restUrl ? 'REST' : 'RPC'} endpoint: ${error instanceof Error ? error.message : String(error)}`,\n { url: endpoint },\n );\n }\n })();\n\n return this.queryClientPromise;\n }\n\n /**\n * Get a signing client with all Manifest registries (for transactions)\n *\n * Automatically retries on transient connection failures with exponential backoff.\n */\n async getSigningClient(): Promise<SigningStargateClient> {\n if (!this.config.rpcUrl || !this.config.gasPrice) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n 'Signing client requires rpcUrl and gasPrice configuration. Current config is query-only (REST).',\n );\n }\n\n // Return cached client if available\n if (this.signingClient) {\n return this.signingClient;\n }\n\n // If initialization is already in progress, wait for it\n if (this.signingClientPromise) {\n return this.signingClientPromise;\n }\n\n // Start initialization and cache the promise to prevent concurrent init\n this.signingClientPromise = (async () => {\n // Capture reference to detect if superseded by disconnect/config change\n const thisInitPromise = this.signingClientPromise;\n try {\n const signer = await this.walletProvider.getSigner();\n const gasPrice = GasPrice.fromString(this.config.gasPrice!);\n const { registry, aminoTypes } = getSigningManifestClientOptions();\n\n // Configure endpoint as HttpEndpoint object (required for custom options)\n const endpoint: HttpEndpoint = {\n url: this.config.rpcUrl!,\n headers: {},\n };\n\n // Note: Registry type from @cosmjs/proto-signing doesn't perfectly match\n // SigningStargateClientOptions due to telescope-generated proto types.\n // This is a known limitation with custom cosmos-sdk module registries.\n // Wrap with retry for transient connection failures\n const client = await withRetry(\n async () => {\n const c = await SigningStargateClient.connectWithSigner(\n endpoint,\n signer,\n {\n registry: registry as SigningClientRegistry,\n aminoTypes,\n gasPrice,\n broadcastTimeoutMs: DEFAULT_BROADCAST_TIMEOUT_MS,\n broadcastPollIntervalMs: DEFAULT_BROADCAST_POLL_INTERVAL_MS,\n },\n );\n // The property is private readonly with no constructor option,\n // so we must bypass TypeScript's access control to override it.\n const record = c as unknown as Record<string, unknown>;\n if (typeof record.defaultGasMultiplier === 'number') {\n record.defaultGasMultiplier = DEFAULT_GAS_MULTIPLIER;\n }\n return c;\n },\n {\n config: this.config.retry,\n operationName: 'connect signing client',\n },\n );\n // Only store if this is still the active promise\n if (this.signingClientPromise === thisInitPromise) {\n this.signingClient = client;\n this.signingClientPromise = null;\n } else {\n // Promise was superseded, clean up the client we just created\n client.disconnect();\n }\n return client;\n } catch (error) {\n // Clear promise on failure so retry is possible (only if still active)\n if (this.signingClientPromise === thisInitPromise) {\n this.signingClientPromise = null;\n }\n if (error instanceof ManifestMCPError) {\n throw error;\n }\n throw new ManifestMCPError(\n ManifestMCPErrorCode.RPC_CONNECTION_FAILED,\n `Failed to connect signing client: ${error instanceof Error ? error.message : String(error)}`,\n { rpcUrl: this.config.rpcUrl },\n );\n }\n })();\n\n return this.signingClientPromise;\n }\n\n /**\n * Get the wallet address\n */\n async getAddress(): Promise<string> {\n return this.walletProvider.getAddress();\n }\n\n /**\n * Get the configuration\n */\n getConfig(): ManifestMCPConfig {\n return this.config;\n }\n\n /**\n * Acquire a rate limit token before making an RPC request.\n * This will wait if the rate limit has been exceeded.\n */\n async acquireRateLimit(): Promise<void> {\n await this.rateLimiter.removeTokens(1);\n }\n\n /**\n * Disconnect the signing client and release query client references.\n * The query client's underlying HTTP transport is stateless and does not\n * require an explicit disconnect.\n */\n disconnect(): void {\n if (this.signingClient) {\n this.signingClient.disconnect();\n this.signingClient = null;\n }\n this.signingClientPromise = null;\n this.queryClient = null;\n this.queryClientPromise = null;\n }\n}\n"],"mappings":";;;;;;;;;;AAiDA,MAAM,+BAA+B;;AAGrC,MAAM,qCAAqC;;;;;;AAO3C,MAAM,yBAAyB;;;;AAK/B,SAAS,kCAAkC;AAezC,QAAO;EAAE,UAdQ,IAAI,SAAS;GAC5B,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACJ,CAAC;EASiB,YAPA,IAAI,WAAW;GAChC,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACJ,CAAC;EAE6B;;;;;AAMjC,IAAa,sBAAb,MAAa,oBAAoB;CAa/B,YACE,QACA,gBACA;AAXF,OAAQ,cAA0C;AAClD,OAAQ,gBAA8C;AAItD,OAAQ,qBAA0D;AAClE,OAAQ,uBAA8D;AAMpE,OAAK,SAAS;AACd,OAAK,iBAAiB;AAKtB,OAAK,cAAc,IAAI,YAAY;GACjC,mBAFA,OAAO,WAAW,qBAAA;GAGlB,UAAU;GACX,CAAC;;;;;;;;;CAUJ,OAAO,YACL,QACA,gBACqB;EACrB,MAAM,QAAQ,CAAC,OAAO,SAAS,OAAO,UAAU,GAAG;AACnD,MAAI,OAAO,QAAS,OAAM,KAAK,OAAO,QAAQ;EAC9C,MAAM,MAAM,MAAM,KAAK,IAAI;EAC3B,IAAI,WAAW,oBAAoB,UAAU,IAAI,IAAI;AAErD,MAAI,CAAC,UAAU;AACb,cAAW,IAAI,oBAAoB,QAAQ,eAAe;AAC1D,uBAAoB,UAAU,IAAI,KAAK,SAAS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UAAU,OAAO,MAAM,IAC3F,EAAE,QAAQ,KAAK,OAAO,QAAQ,CAC/B;;MAED;AAEJ,SAAO,KAAK;;;;;CAMd,MAAM,aAA8B;AAClC,SAAO,KAAK,eAAe,YAAY;;;;;CAMzC,YAA+B;AAC7B,SAAO,KAAK;;;;;;CAOd,MAAM,mBAAkC;AACtC,QAAM,KAAK,YAAY,aAAa,EAAE;;;;;;;CAQxC,aAAmB;AACjB,MAAI,KAAK,eAAe;AACtB,QAAK,cAAc,YAAY;AAC/B,QAAK,gBAAgB;;AAEvB,OAAK,uBAAuB;AAC5B,OAAK,cAAc;AACnB,OAAK,qBAAqB;;;AA7S5B,oBAAe,4BAA8C,IAAI,KAAK"}
1
+ {"version":3,"file":"client.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["import { Registry } from '@cosmjs/proto-signing';\nimport {\n AminoTypes,\n GasPrice,\n type HttpEndpoint,\n SigningStargateClient,\n} from '@cosmjs/stargate';\nimport {\n cosmosAminoConverters,\n cosmosProtoRegistry,\n liftedinit,\n liftedinitAminoConverters,\n liftedinitProtoRegistry,\n osmosisAminoConverters,\n osmosisProtoRegistry,\n strangeloveVenturesAminoConverters,\n strangeloveVenturesProtoRegistry,\n} from '@manifest-network/manifestjs';\nimport { RateLimiter } from 'limiter';\nimport {\n DEFAULT_GAS_MULTIPLIER,\n DEFAULT_REQUESTS_PER_SECOND,\n} from './config.js';\nimport { createLCDQueryClient } from './lcd-adapter.js';\nimport { logger } from './logger.js';\nimport { withRetry } from './retry.js';\nimport {\n type ManifestMCPConfig,\n ManifestMCPError,\n ManifestMCPErrorCode,\n type WalletProvider,\n} from './types.js';\n\n// Type for the RPC query client from manifestjs liftedinit bundle\n// This includes cosmos modules + liftedinit-specific modules (billing, manifest, sku)\nexport type ManifestQueryClient = Awaited<\n ReturnType<typeof liftedinit.ClientFactory.createRPCQueryClient>\n>;\n\n/**\n * Extract the registry type expected by SigningStargateClient.connectWithSigner.\n *\n * The Registry type from @cosmjs/proto-signing doesn't perfectly match the registry type\n * in SigningStargateClientOptions due to telescope-generated proto types. This type alias\n * extracts the expected registry type from the function signature to enable type-safe casting.\n */\ntype SigningClientRegistry = Parameters<\n typeof SigningStargateClient.connectWithSigner\n>[2] extends { registry?: infer R }\n ? R\n : never;\n\n/** Default timeout for transaction broadcast (60 seconds) */\nconst DEFAULT_BROADCAST_TIMEOUT_MS = 60_000;\n\n/** Default polling interval for transaction confirmation (3 seconds) */\nconst DEFAULT_BROADCAST_POLL_INTERVAL_MS = 3_000;\n\n/**\n * Get combined signing client options with all Manifest registries\n */\nfunction getSigningManifestClientOptions() {\n const registry = new Registry([\n ...cosmosProtoRegistry,\n ...liftedinitProtoRegistry,\n ...strangeloveVenturesProtoRegistry,\n ...osmosisProtoRegistry,\n ]);\n\n const aminoTypes = new AminoTypes({\n ...cosmosAminoConverters,\n ...liftedinitAminoConverters,\n ...strangeloveVenturesAminoConverters,\n ...osmosisAminoConverters,\n });\n\n return { registry, aminoTypes };\n}\n\n/**\n * Manages CosmJS client instances with lazy initialization and singleton pattern\n */\nexport class CosmosClientManager {\n private static instances: Map<string, CosmosClientManager> = new Map();\n\n private config: ManifestMCPConfig;\n private walletProvider: WalletProvider;\n private queryClient: ManifestQueryClient | null = null;\n private signingClient: SigningStargateClient | null = null;\n private rateLimiter: RateLimiter;\n\n // Promises to prevent concurrent client initialization (lazy init race condition)\n private queryClientPromise: Promise<ManifestQueryClient> | null = null;\n private signingClientPromise: Promise<SigningStargateClient> | null = null;\n\n private constructor(\n config: ManifestMCPConfig,\n walletProvider: WalletProvider,\n ) {\n this.config = config;\n this.walletProvider = walletProvider;\n\n // Initialize rate limiter with configured or default requests per second\n const requestsPerSecond =\n config.rateLimit?.requestsPerSecond ?? DEFAULT_REQUESTS_PER_SECOND;\n this.rateLimiter = new RateLimiter({\n tokensPerInterval: requestsPerSecond,\n interval: 'second',\n });\n }\n\n /**\n * Get or create a singleton instance for the given config.\n * Instances are keyed by chainId:rpcUrl:restUrl. For existing instances:\n * - Config and walletProvider references are always updated\n * - Signing client is disconnected/recreated if gasPrice, gasMultiplier, or walletProvider changed\n * - Rate limiter is updated if requestsPerSecond changed (without affecting signing client)\n */\n static getInstance(\n config: ManifestMCPConfig,\n walletProvider: WalletProvider,\n ): CosmosClientManager {\n const parts = [config.chainId, config.rpcUrl ?? ''];\n if (config.restUrl) parts.push(config.restUrl);\n const key = parts.join(':');\n let instance = CosmosClientManager.instances.get(key);\n\n if (!instance) {\n instance = new CosmosClientManager(config, walletProvider);\n CosmosClientManager.instances.set(key, instance);\n } else {\n // Check what changed to determine what needs updating\n const signingClientAffected =\n instance.config.gasPrice !== config.gasPrice ||\n instance.config.gasMultiplier !== config.gasMultiplier ||\n instance.walletProvider !== walletProvider;\n\n const rateLimitChanged =\n instance.config.rateLimit?.requestsPerSecond !==\n config.rateLimit?.requestsPerSecond;\n\n // Always update config reference\n instance.config = config;\n instance.walletProvider = walletProvider;\n\n // Only invalidate signing client if fields it depends on changed\n if (signingClientAffected) {\n if (instance.signingClient) {\n instance.signingClient.disconnect();\n instance.signingClient = null;\n }\n // Also clear the promise to allow re-initialization with new config\n instance.signingClientPromise = null;\n }\n\n // Update rate limiter independently (doesn't affect signing client)\n if (rateLimitChanged) {\n const newRps =\n config.rateLimit?.requestsPerSecond ?? DEFAULT_REQUESTS_PER_SECOND;\n instance.rateLimiter = new RateLimiter({\n tokensPerInterval: newRps,\n interval: 'second',\n });\n }\n }\n\n return instance;\n }\n\n /**\n * Clear all cached instances (useful for testing or reconnection).\n * Disconnects signing clients and releases query client references before clearing.\n */\n static clearInstances(): void {\n for (const instance of CosmosClientManager.instances.values()) {\n instance.disconnect();\n }\n CosmosClientManager.instances.clear();\n }\n\n /**\n * Get the manifestjs RPC query client with all module extensions\n *\n * Automatically retries on transient connection failures with exponential backoff.\n */\n async getQueryClient(): Promise<ManifestQueryClient> {\n // Return cached client if available\n if (this.queryClient) {\n return this.queryClient;\n }\n\n // If initialization is already in progress, wait for it\n if (this.queryClientPromise) {\n return this.queryClientPromise;\n }\n\n // Start initialization and cache the promise to prevent concurrent init\n this.queryClientPromise = (async () => {\n // Capture reference to detect if superseded by disconnect/config change\n const thisInitPromise = this.queryClientPromise;\n try {\n let client: ManifestQueryClient;\n if (this.config.restUrl) {\n // Use LCD/REST for queries when restUrl is configured\n client = await withRetry(\n () => createLCDQueryClient(this.config.restUrl!),\n {\n config: this.config.retry,\n operationName: 'connect LCD query client',\n },\n );\n } else if (this.config.rpcUrl) {\n // Use RPC (existing behavior)\n client = await withRetry(\n () =>\n liftedinit.ClientFactory.createRPCQueryClient({\n rpcEndpoint: this.config.rpcUrl!,\n }),\n {\n config: this.config.retry,\n operationName: 'connect query client',\n },\n );\n } else {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n 'Cannot create query client: neither restUrl nor rpcUrl is configured.',\n );\n }\n // Only store if this is still the active promise\n if (this.queryClientPromise === thisInitPromise) {\n this.queryClient = client;\n this.queryClientPromise = null;\n }\n return client;\n } catch (error) {\n // Clear promise on failure so retry is possible (only if still active)\n if (this.queryClientPromise === thisInitPromise) {\n this.queryClientPromise = null;\n }\n if (error instanceof ManifestMCPError) {\n throw error;\n }\n const endpoint = this.config.restUrl ?? this.config.rpcUrl;\n throw new ManifestMCPError(\n ManifestMCPErrorCode.RPC_CONNECTION_FAILED,\n `Failed to connect to ${this.config.restUrl ? 'REST' : 'RPC'} endpoint: ${error instanceof Error ? error.message : String(error)}`,\n { url: endpoint },\n );\n }\n })();\n\n return this.queryClientPromise;\n }\n\n /**\n * Get a signing client with all Manifest registries (for transactions)\n *\n * Automatically retries on transient connection failures with exponential backoff.\n */\n async getSigningClient(): Promise<SigningStargateClient> {\n if (!this.config.rpcUrl || !this.config.gasPrice) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n 'Signing client requires rpcUrl and gasPrice configuration. Current config is query-only (REST).',\n );\n }\n\n // Return cached client if available\n if (this.signingClient) {\n return this.signingClient;\n }\n\n // If initialization is already in progress, wait for it\n if (this.signingClientPromise) {\n return this.signingClientPromise;\n }\n\n // Start initialization and cache the promise to prevent concurrent init\n this.signingClientPromise = (async () => {\n // Capture reference to detect if superseded by disconnect/config change\n const thisInitPromise = this.signingClientPromise;\n try {\n const signer = await this.walletProvider.getSigner();\n const gasPrice = GasPrice.fromString(this.config.gasPrice!);\n const { registry, aminoTypes } = getSigningManifestClientOptions();\n\n // Configure endpoint as HttpEndpoint object (required for custom options)\n const endpoint: HttpEndpoint = {\n url: this.config.rpcUrl!,\n headers: {},\n };\n\n // Note: Registry type from @cosmjs/proto-signing doesn't perfectly match\n // SigningStargateClientOptions due to telescope-generated proto types.\n // This is a known limitation with custom cosmos-sdk module registries.\n // Wrap with retry for transient connection failures\n const client = await withRetry(\n async () => {\n const c = await SigningStargateClient.connectWithSigner(\n endpoint,\n signer,\n {\n registry: registry as SigningClientRegistry,\n aminoTypes,\n gasPrice,\n broadcastTimeoutMs: DEFAULT_BROADCAST_TIMEOUT_MS,\n broadcastPollIntervalMs: DEFAULT_BROADCAST_POLL_INTERVAL_MS,\n },\n );\n // The property is private readonly with no constructor option,\n // so we must bypass TypeScript's access control to override it.\n const record = c as unknown as Record<string, unknown>;\n if (typeof record.defaultGasMultiplier === 'number') {\n record.defaultGasMultiplier =\n this.config.gasMultiplier ?? DEFAULT_GAS_MULTIPLIER;\n } else {\n const effective =\n this.config.gasMultiplier ?? DEFAULT_GAS_MULTIPLIER;\n logger.warn(\n `gasMultiplier ${effective} could not be applied: ` +\n `signing client defaultGasMultiplier is ${typeof record.defaultGasMultiplier}, expected number. ` +\n `Transactions will use the CosmJS built-in gas multiplier instead.`,\n );\n }\n return c;\n },\n {\n config: this.config.retry,\n operationName: 'connect signing client',\n },\n );\n // Only store if this is still the active promise\n if (this.signingClientPromise === thisInitPromise) {\n this.signingClient = client;\n this.signingClientPromise = null;\n } else {\n // Promise was superseded, clean up the client we just created\n client.disconnect();\n }\n return client;\n } catch (error) {\n // Clear promise on failure so retry is possible (only if still active)\n if (this.signingClientPromise === thisInitPromise) {\n this.signingClientPromise = null;\n }\n if (error instanceof ManifestMCPError) {\n throw error;\n }\n throw new ManifestMCPError(\n ManifestMCPErrorCode.RPC_CONNECTION_FAILED,\n `Failed to connect signing client: ${error instanceof Error ? error.message : String(error)}`,\n { rpcUrl: this.config.rpcUrl },\n );\n }\n })();\n\n return this.signingClientPromise;\n }\n\n /**\n * Get the wallet address\n */\n async getAddress(): Promise<string> {\n return this.walletProvider.getAddress();\n }\n\n /**\n * Get the configuration\n */\n getConfig(): ManifestMCPConfig {\n return this.config;\n }\n\n /**\n * Acquire a rate limit token before making an RPC request.\n * This will wait if the rate limit has been exceeded.\n */\n async acquireRateLimit(): Promise<void> {\n await this.rateLimiter.removeTokens(1);\n }\n\n /**\n * Disconnect the signing client and release query client references.\n * The query client's underlying HTTP transport is stateless and does not\n * require an explicit disconnect.\n */\n disconnect(): void {\n if (this.signingClient) {\n this.signingClient.disconnect();\n this.signingClient = null;\n }\n this.signingClientPromise = null;\n this.queryClient = null;\n this.queryClientPromise = null;\n }\n}\n"],"mappings":";;;;;;;;;;;AAqDA,MAAM,+BAA+B;;AAGrC,MAAM,qCAAqC;;;;AAK3C,SAAS,kCAAkC;AAezC,QAAO;EAAE,UAdQ,IAAI,SAAS;GAC5B,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACJ,CAAC;EASiB,YAPA,IAAI,WAAW;GAChC,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACJ,CAAC;EAE6B;;;;;AAMjC,IAAa,sBAAb,MAAa,oBAAoB;CAa/B,YACE,QACA,gBACA;AAXF,OAAQ,cAA0C;AAClD,OAAQ,gBAA8C;AAItD,OAAQ,qBAA0D;AAClE,OAAQ,uBAA8D;AAMpE,OAAK,SAAS;AACd,OAAK,iBAAiB;AAKtB,OAAK,cAAc,IAAI,YAAY;GACjC,mBAFA,OAAO,WAAW,qBAAA;GAGlB,UAAU;GACX,CAAC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,yBAAyB,SACzC,QAAO,uBACL,KAAK,OAAO,iBAAA;UACT;MACL,MAAM,YACJ,KAAK,OAAO,iBAAA;AACd,aAAO,KACL,iBAAiB,UAAU,gEACiB,OAAO,OAAO,qBAAqB,sFAEhF;;AAEH,YAAO;OAET;KACE,QAAQ,KAAK,OAAO;KACpB,eAAe;KAChB,CACF;AAED,QAAI,KAAK,yBAAyB,iBAAiB;AACjD,UAAK,gBAAgB;AACrB,UAAK,uBAAuB;UAG5B,QAAO,YAAY;AAErB,WAAO;YACA,OAAO;AAEd,QAAI,KAAK,yBAAyB,gBAChC,MAAK,uBAAuB;AAE9B,QAAI,iBAAiB,iBACnB,OAAM;AAER,UAAM,IAAI,iBACR,qBAAqB,uBACrB,qCAAqC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IAC3F,EAAE,QAAQ,KAAK,OAAO,QAAQ,CAC/B;;MAED;AAEJ,SAAO,KAAK;;;;;CAMd,MAAM,aAA8B;AAClC,SAAO,KAAK,eAAe,YAAY;;;;;CAMzC,YAA+B;AAC7B,SAAO,KAAK;;;;;;CAOd,MAAM,mBAAkC;AACtC,QAAM,KAAK,YAAY,aAAa,EAAE;;;;;;;CAQxC,aAAmB;AACjB,MAAI,KAAK,eAAe;AACtB,QAAK,cAAc,YAAY;AAC/B,QAAK,gBAAgB;;AAEvB,OAAK,uBAAuB;AAC5B,OAAK,cAAc;AACnB,OAAK,qBAAqB;;;AAvT5B,oBAAe,4BAA8C,IAAI,KAAK"}
package/dist/config.d.ts CHANGED
@@ -6,6 +6,12 @@ import { DEFAULT_RETRY_CONFIG } from "./retry.js";
6
6
  * Default requests per second for rate limiting
7
7
  */
8
8
  declare const DEFAULT_REQUESTS_PER_SECOND = 10;
9
+ /**
10
+ * Default gas simulation multiplier. CosmJS defaults to 1.4 but billing module
11
+ * transactions (close-lease in particular) can exceed that. 1.5 matches
12
+ * the --gas-adjustment value used in this project's E2E scripts (e2e/scripts/init_billing.sh).
13
+ */
14
+ declare const DEFAULT_GAS_MULTIPLIER = 1.5;
9
15
  /**
10
16
  * Create a configuration object with defaults applied
11
17
  */
@@ -26,5 +32,5 @@ declare function validateConfig(config: Partial<ManifestMCPConfig>): ValidationR
26
32
  */
27
33
  declare function createValidatedConfig(input: ManifestMCPConfig): ManifestMCPConfig;
28
34
  //#endregion
29
- export { DEFAULT_REQUESTS_PER_SECOND, DEFAULT_RETRY_CONFIG, ValidationResult, createConfig, createValidatedConfig, validateConfig };
35
+ export { DEFAULT_GAS_MULTIPLIER, DEFAULT_REQUESTS_PER_SECOND, DEFAULT_RETRY_CONFIG, ValidationResult, createConfig, createValidatedConfig, validateConfig };
30
36
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;;AAeA;cAAa,2BAAA;;;AAkEb;iBAAgB,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAoB,iBAAA;;;;UAsBvC,gBAAA;EACf,KAAA;EACA,MAAA;AAAA;AAFF;;;AAAA,iBAQgB,cAAA,CACd,MAAA,EAAQ,OAAA,CAAQ,iBAAA,IACf,gBAAA;;AAFH;;iBA4HgB,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;;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"}
package/dist/config.js CHANGED
@@ -10,6 +10,12 @@ const DEFAULT_ADDRESS_PREFIX = "manifest";
10
10
  */
11
11
  const DEFAULT_REQUESTS_PER_SECOND = 10;
12
12
  /**
13
+ * Default gas simulation multiplier. CosmJS defaults to 1.4 but billing module
14
+ * transactions (close-lease in particular) can exceed that. 1.5 matches
15
+ * the --gas-adjustment value used in this project's E2E scripts (e2e/scripts/init_billing.sh).
16
+ */
17
+ const DEFAULT_GAS_MULTIPLIER = 1.5;
18
+ /**
13
19
  * Check if a hostname is localhost (IPv4, IPv6, or hostname)
14
20
  * Handles both bracketed and unbracketed IPv6 formats
15
21
  */
@@ -42,7 +48,10 @@ function validateEndpointUrl(url, label) {
42
48
  * Validate gas price format (e.g., "1.0umfx")
43
49
  */
44
50
  function isValidGasPrice(gasPrice) {
45
- return /^\d+(\.\d+)?[a-zA-Z]+$/.test(gasPrice);
51
+ const match = gasPrice.match(/^(\d+(?:\.\d+)?)([a-zA-Z][a-zA-Z0-9.:_-]*(?:\/[a-zA-Z0-9.:_-]+)*)$/);
52
+ if (!match) return false;
53
+ const denom = match[2];
54
+ return denom.length >= 3 && denom.length <= 128;
46
55
  }
47
56
  /**
48
57
  * Validate chain ID format
@@ -65,7 +74,8 @@ function createConfig(input) {
65
74
  maxRetries: input.retry?.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries,
66
75
  baseDelayMs: input.retry?.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs,
67
76
  maxDelayMs: input.retry?.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs
68
- }
77
+ },
78
+ gasMultiplier: input.gasMultiplier ?? 1.5
69
79
  };
70
80
  }
71
81
  /**
@@ -85,7 +95,7 @@ function validateConfig(config) {
85
95
  if (!urlCheck.valid) errors.push(urlCheck.reason);
86
96
  }
87
97
  if (config.rpcUrl && !config.gasPrice) errors.push("gasPrice is required when rpcUrl is provided");
88
- else if (config.gasPrice && !isValidGasPrice(config.gasPrice)) errors.push("gasPrice must be a number followed by denomination (e.g., \"1.0umfx\")");
98
+ else if (config.gasPrice && !isValidGasPrice(config.gasPrice)) errors.push("gasPrice must be a number followed by denomination (e.g., \"1.0umfx\", \"0.5factory/addr/udenom\", or \"0.25ibc/ABC123\")");
89
99
  if (config.addressPrefix !== void 0) {
90
100
  if (!/^[a-z]+$/.test(config.addressPrefix)) errors.push("addressPrefix must be lowercase letters only");
91
101
  }
@@ -108,6 +118,9 @@ function validateConfig(config) {
108
118
  }
109
119
  if (config.retry.baseDelayMs !== void 0 && config.retry.maxDelayMs !== void 0 && config.retry.maxDelayMs < config.retry.baseDelayMs) errors.push("retry.maxDelayMs must be greater than or equal to retry.baseDelayMs");
110
120
  }
121
+ if (config.gasMultiplier !== void 0) {
122
+ if (typeof config.gasMultiplier !== "number" || !Number.isFinite(config.gasMultiplier) || config.gasMultiplier < 1) errors.push("gasMultiplier must be a finite number >= 1");
123
+ }
111
124
  return {
112
125
  valid: errors.length === 0,
113
126
  errors
@@ -122,6 +135,6 @@ function createValidatedConfig(input) {
122
135
  return createConfig(input);
123
136
  }
124
137
  //#endregion
125
- export { 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 };
126
139
 
127
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// 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 return /^\\d+(\\.\\d+)?[a-zA-Z]+$/.test(gasPrice);\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 };\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\")',\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 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;;;;;AAS3C,SAAS,oBAAoB,UAA2B;AACtD,KAAI,aAAa,eAAe,aAAa,YAC3C,QAA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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,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"}
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,MAAM,QAAQ,MAAM;AACpB,QAAO,MAAM,UAAU,KAAK,MAAM,UAAU;;;;;AAM9C,SAAS,eAAe,SAA0B;AAEhD,QAAO,sBAAsB,KAAK,QAAQ;;;;;AAM5C,SAAgB,aAAa,OAA6C;AACxE,QAAO;EACL,SAAS,MAAM;EACf,QAAQ,MAAM;EACd,UAAU,MAAM;EAChB,SAAS,MAAM;EACf,eAAe,MAAM,iBAAiB;EACtC,WAAW,EACT,mBACE,MAAM,WAAW,qBAAA,IACpB;EACD,OAAO;GACL,YAAY,MAAM,OAAO,cAAc,q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Q,OAAO,MAAM,CAE3B,QAAO,KAAK,+BAA+B;MACtC;AACL,MAAI,OAAO,MAAM,eAAe,KAAA;OAE5B,OAAO,OAAO,MAAM,eAAe,YACnC,OAAO,MAAM,aAAa,KAC1B,CAAC,OAAO,UAAU,OAAO,MAAM,WAAW,CAE1C,QAAO,KAAK,kDAAkD;;AAGlE,MAAI,OAAO,MAAM,gBAAgB,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.js CHANGED
@@ -2,12 +2,12 @@ import { ManifestMCPError, ManifestMCPErrorCode } from "./types.js";
2
2
  import { DEFAULT_RETRY_CONFIG, calculateBackoff, isRetryableError, withRetry } from "./retry.js";
3
3
  import { createConfig, createValidatedConfig, validateConfig } from "./config.js";
4
4
  import { createLCDQueryClient } from "./lcd-adapter.js";
5
+ import { logger } from "./logger.js";
5
6
  import { CosmosClientManager } from "./client.js";
6
7
  import { DNS_LABEL_RE, optionalBoolean, parseArgs, requireString, requireStringEnum, requireUuid } from "./validation.js";
7
8
  import { MAX_PAGE_LIMIT, createPagination } from "./queries/utils.js";
8
9
  import { getAvailableModules, getModuleSubcommands, getSubcommandUsage, getSupportedModules, isSubcommandSupported } from "./modules.js";
9
10
  import { cosmosQuery, cosmosTx } from "./cosmos.js";
10
- import { logger } from "./logger.js";
11
11
  import { signArbitraryWithAmino } from "./wallet/sign-arbitrary.js";
12
12
  import { MnemonicWalletProvider } from "./wallet/mnemonic.js";
13
13
  import "./wallet/index.js";
@@ -40,15 +40,11 @@ declare function withErrorHandling<T extends (...args: any[]) => Promise<CallToo
40
40
  declare function jsonResponse(data: unknown, replacer?: (key: string, value: any) => any): CallToolResult;
41
41
  /**
42
42
  * Config shape accepted by createMnemonicServer.
43
+ * Derives from ManifestMCPConfig (minus rateLimit/retry) so new config fields propagate automatically.
43
44
  */
44
- interface MnemonicServerConfig {
45
- chainId: string;
46
- rpcUrl?: string;
47
- gasPrice?: string;
48
- restUrl?: string;
49
- addressPrefix?: string;
50
- mnemonic: string;
51
- }
45
+ type MnemonicServerConfig = Omit<ManifestMCPConfig, 'rateLimit' | 'retry'> & {
46
+ readonly mnemonic: string;
47
+ };
52
48
  /**
53
49
  * Generic factory that creates any MCP server class with a mnemonic wallet.
54
50
  *
@@ -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;;;;UAgD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+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 * Config shape accepted by createMnemonicServer.\n */\nexport interface MnemonicServerConfig {\n chainId: string;\n rpcUrl?: string;\n gasPrice?: string;\n restUrl?: string;\n addressPrefix?: string;\n 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,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,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;;;;;;;;AAqBH,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 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 * 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;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gBAAyC;IAC3C,OAAO;IACP,MAAM;IACN,OAAO,mBAAmB,KAAK;IAChC;AAED,OAAI,iBAAiB,iBACnB,iBAAgB;IACd,GAAG;IACH,MAAM,MAAM;IACZ,SAAS,mBAAmB,MAAM,QAAQ;IAC1C,SAAS,mBAAmB,MAAM,QAAQ;IAC3C;OAED,iBAAgB;IACd,GAAG;IACH,SAAS;IACV;GAGH,IAAI;AACJ,OAAI;AACF,mBAAe,KAAK,UAAU,eAAe,gBAAgB,EAAE;YACxD,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;;;;;;;;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/types.d.ts CHANGED
@@ -48,6 +48,8 @@ interface ManifestMCPConfig {
48
48
  readonly rateLimit?: RateLimitConfig;
49
49
  /** Retry configuration for transient failures */
50
50
  readonly retry?: RetryConfig;
51
+ /** Gas simulation multiplier (default: 1.5, minimum: 1). A value of 1.0 uses the exact simulation result with no safety margin. Increase if transactions fail with out-of-gas errors. */
52
+ readonly gasMultiplier?: number;
51
53
  }
52
54
  /**
53
55
  * Wallet provider interface for different wallet implement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GACA,aAAA,GACA,gBAAA,GACA,mBAAA,GACA,wBAAA,GACA,iCAAA,GACA,aAAA,GACA,yBAAA,GACA,8BAAA,GACA,cAAA,GACA,eAAA,GACA,UAAA,GACA,WAAA,GACA,aAAA,GACA,cAAA,GACA,WAAA,GACA,eAAA,GACA,iBAAA,GACA,kBAAA,GACA,gBAAA,GACA,oBAAA,GACA,0BAAA,GACA,0BAAA,GACA,kBAAA,GACA,iBAAA,GACA,mBAAA,GACA,WAAA,GACA,YAAA,GACA,mBAAA,GACA,oBAAA,GACA,mBAAA,GACA,wBAAA,GACA,0BAAA,GACA,oBAAA,GACA,eAAA,GACA,cAAA,GACA,eAAA,GACA,SAAA,GACA,UAAA,GACA,eAAA,GACA,qBAAA,GACA,kBAAA,GACA,YAAA,GACA,mBAAA,GACA,mBAAA,GACA,oBAAA,GACA,eAAA,GACA,gBAAA,GACA,qBAAA;;;;UAKa,iBAAA;EAAA,SACN,MAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA,EAAQ,WAAA;AAAA"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;;;;;;;;AAwHA;;UAAiB,eAAA;EAEN;EAAA,SAAA,iBAAA;AAAA;;;;UAMM,WAAA;EAIN;EAAA,SAFA,UAAA;EAIU;EAAA,SAFV,WAAA;EAQM;EAAA,SANN,UAAA;AAAA;;;;UAMM,iBAAA;EAQN;EAAA,SANA,OAAA;EAUA;EAAA,SARA,MAAA;EAUA;EAAA,SARA,QAAA;EAUA;EAAA,SARA,OAAA;EAQa;EAAA,SANb,aAAA;EAcyB;EAAA,SAZzB,SAAA,GAAY,eAAA;EAYa;EAAA,SAVzB,KAAA,GAAQ,WAAA;EAWY;EAAA,SATpB,aAAA;AAAA;;;AAaX;;;UALiB,mBAAA;EAAA,SACN,OAAA;IAAA,SAAoB,IAAA;IAAA,SAAuB,KAAA;EAAA;EAAA,SAC3C,SAAA;AAAA;AAAA,UAGM,cAAA;EAUO;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AAA,SACN,MAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA,EAAQ,WAAA;AAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { OfflineSigner } from '@cosmjs/proto-signing';\n// Auth module types\nimport type {\n Params as AuthParams,\n BaseAccount,\n ModuleAccount,\n} from '@manifest-network/manifestjs/dist/codegen/cosmos/auth/v1beta1/auth.js';\n// Bank module types\nimport type {\n Metadata as BankMetadata,\n Params as BankParams,\n SendEnabled,\n} from '@manifest-network/manifestjs/dist/codegen/cosmos/bank/v1beta1/bank.js';\n\n// Distribution module types\nimport type {\n DelegationDelegatorReward,\n Params as DistributionParams,\n ValidatorAccumulatedCommission,\n ValidatorOutstandingRewards,\n ValidatorSlashEvent,\n} from '@manifest-network/manifestjs/dist/codegen/cosmos/distribution/v1beta1/distribution.js';\n\n// Gov module types (v1 for newer chains)\nimport type {\n DepositParams,\n Deposit as GovDeposit,\n Params as GovParams,\n Proposal as GovProposal,\n TallyResult as GovTallyResult,\n Vote as GovVote,\n TallyParams,\n VotingParams,\n} from '@manifest-network/manifestjs/dist/codegen/cosmos/gov/v1/gov.js';\n// Group module types\nimport type {\n GroupInfo,\n GroupMember,\n GroupPolicyInfo,\n Proposal as GroupProposal,\n TallyResult as GroupTallyResult,\n Vote as GroupVote,\n} from '@manifest-network/manifestjs/dist/codegen/cosmos/group/v1/types.js';\n// Staking module types\nimport type {\n DelegationResponse,\n HistoricalInfo,\n RedelegationResponse,\n Params as StakingParams,\n Pool as StakingPool,\n UnbondingDelegation,\n Validator,\n} from '@manifest-network/manifestjs/dist/codegen/cosmos/staking/v1beta1/staking.js';\n// Protobuf Any type for polymorphic account types\nimport type { Any } from '@manifest-network/manifestjs/dist/codegen/google/protobuf/any.js';\n// Billing credit estimate response\nimport type { QueryCreditEstimateResponse } from '@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/query.js';\nimport type { LeaseItemInput } from '@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/tx.js';\n// Billing module types (Manifest-specific)\nimport type {\n Params as BillingParams,\n CreditAccount,\n Lease,\n} from '@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js';\n\n// SKU module types (Manifest-specific)\nimport type {\n Provider,\n SKU,\n Params as SkuParams,\n} from '@manifest-network/manifestjs/dist/codegen/liftedinit/sku/v1/types.js';\n\n// Re-export commonly used protobuf types for consumers\nexport type {\n Any,\n AuthParams,\n BankMetadata,\n BankParams,\n BaseAccount,\n BillingParams,\n CreditAccount,\n DelegationDelegatorReward,\n DelegationResponse,\n DepositParams,\n DistributionParams,\n GovDeposit,\n GovParams,\n GovProposal,\n GovTallyResult,\n GovVote,\n GroupInfo,\n GroupMember,\n GroupPolicyInfo,\n GroupProposal,\n GroupTallyResult,\n GroupVote,\n HistoricalInfo,\n Lease,\n LeaseItemInput,\n ModuleAccount,\n Provider,\n QueryCreditEstimateResponse,\n RedelegationResponse,\n SendEnabled,\n SKU,\n SkuParams,\n StakingParams,\n StakingPool,\n TallyParams,\n UnbondingDelegation,\n Validator,\n ValidatorAccumulatedCommission,\n ValidatorOutstandingRewards,\n ValidatorSlashEvent,\n VotingParams,\n};\n\n/**\n * Rate limiting configuration\n */\nexport interface RateLimitConfig {\n /** Maximum requests per second (default: 10) */\n readonly requestsPerSecond?: number;\n}\n\n/**\n * Retry configuration for transient RPC failures\n */\nexport interface RetryConfig {\n /** Maximum number of retry attempts (default: 3) */\n readonly maxRetries?: number;\n /** Base delay in milliseconds before first retry (default: 1000) */\n readonly baseDelayMs?: number;\n /** Maximum delay in milliseconds between retries (default: 10000) */\n readonly maxDelayMs?: number;\n}\n\n/**\n * Configuration for the Manifest MCP server\n */\nexport interface ManifestMCPConfig {\n /** Chain ID (e.g., \"manifest-ledger-testnet\") */\n readonly chainId: string;\n /** RPC endpoint URL (required for transactions; optional if restUrl provided for query-only mode) */\n readonly rpcUrl?: string;\n /** Gas price with denomination (e.g., \"1.0umfx\"); required when rpcUrl is provided */\n readonly gasPrice?: string;\n /** REST/LCD endpoint URL for queries (e.g., \"http://localhost:1317\") */\n readonly restUrl?: string;\n /** Address prefix (e.g., \"manifest\") */\n readonly addressPrefix?: string;\n /** Rate limiting configuration */\n readonly rateLimit?: RateLimitConfig;\n /** Retry configuration for transient failures */\n readonly retry?: RetryConfig;\n}\n\n/**\n * Wallet provider interface for different wallet implementations\n *\n * Any wallet that provides an OfflineSigner works (Keplr, Web3Auth, Leap, cosmos-kit, etc.)\n */\nexport interface SignArbitraryResult {\n readonly pub_key: { readonly type: string; readonly value: string };\n readonly signature: string;\n}\n\nexport interface WalletProvider {\n /** Get the wallet's address */\n getAddress(): Promise<string>;\n /** Get the offline signer for signing transactions */\n getSigner(): Promise<OfflineSigner>;\n /** Optional: Sign arbitrary data (ADR-036) for off-chain authentication */\n signArbitrary?(address: string, data: string): Promise<SignArbitraryResult>;\n /** Optional: Connect to the wallet */\n connect?(): Promise<void>;\n /** Optional: Disconnect from the wallet */\n disconnect?(): Promise<void>;\n}\n\n/**\n * Result from a Cosmos transaction\n */\nexport interface CosmosTxResult {\n readonly module: string;\n readonly subcommand: string;\n readonly transactionHash: string;\n readonly code: number;\n readonly height: string;\n readonly rawLog?: string;\n readonly confirmed?: boolean;\n readonly confirmationHeight?: string;\n readonly gasUsed?: string;\n readonly gasWanted?: string;\n readonly events?: readonly {\n readonly type: string;\n readonly attributes: readonly {\n readonly key: string;\n readonly value: string;\n }[];\n }[];\n}\n\n/**\n * Module information for discovery\n */\nexport interface ModuleInfo {\n readonly name: string;\n readonly description: string;\n readonly args?: string; // Usage hint for arguments\n}\n\n/**\n * Available modules listing\n */\nexport interface AvailableModules {\n readonly queryModules: readonly ModuleInfo[];\n readonly txModules: readonly ModuleInfo[];\n}\n\n/**\n * Error codes for ManifestMCPError\n */\nexport enum ManifestMCPErrorCode {\n // Configuration errors\n INVALID_CONFIG = 'INVALID_CONFIG',\n MISSING_CONFIG = 'MISSING_CONFIG',\n\n // Wallet errors\n WALLET_NOT_CONNECTED = 'WALLET_NOT_CONNECTED',\n WALLET_CONNECTION_FAILED = 'WALLET_CONNECTION_FAILED',\n INVALID_MNEMONIC = 'INVALID_MNEMONIC',\n\n // Client errors\n RPC_CONNECTION_FAILED = 'RPC_CONNECTION_FAILED',\n\n // Query errors\n QUERY_FAILED = 'QUERY_FAILED',\n UNSUPPORTED_QUERY = 'UNSUPPORTED_QUERY',\n INVALID_ADDRESS = 'INVALID_ADDRESS',\n\n // Transaction errors\n TX_FAILED = 'TX_FAILED',\n TX_BROADCAST_FAILED = 'TX_BROADCAST_FAILED',\n UNSUPPORTED_TX = 'UNSUPPORTED_TX',\n INSUFFICIENT_FUNDS = 'INSUFFICIENT_FUNDS',\n\n // Module errors\n UNKNOWN_MODULE = 'UNKNOWN_MODULE',\n}\n\n/**\n * Custom error class for Manifest MCP errors\n */\nexport class ManifestMCPError extends Error {\n public readonly code: ManifestMCPErrorCode;\n public readonly details?: Record<string, unknown>;\n\n constructor(\n code: ManifestMCPErrorCode,\n message: string,\n details?: Record<string, unknown>,\n ) {\n super(message);\n this.name = 'ManifestMCPError';\n this.code = code;\n this.details = details;\n\n // Ensure proper prototype chain for instanceof checks\n Object.setPrototypeOf(this, ManifestMCPError.prototype);\n }\n\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n details: this.details,\n };\n }\n}\n\n/**\n * Account information\n */\nexport interface AccountInfo {\n readonly address: string;\n}\n\n// ============================================================================\n// Query Result Types\n// ============================================================================\n\n/**\n * Pagination response from Cosmos SDK queries\n */\nexport interface PaginationResponse {\n readonly nextKey?: Uint8Array;\n readonly total?: bigint;\n}\n\n/**\n * Base interface for paginated query results\n */\nexport interface PaginatedResult {\n readonly pagination?: PaginationResponse;\n}\n\n/**\n * Coin type from Cosmos SDK\n */\nexport interface Coin {\n readonly denom: string;\n readonly amount: string;\n}\n\n/**\n * DecCoin type from Cosmos SDK (for rewards, commission, etc.)\n *\n * DecCoin has the same structure as Coin but represents decimal amounts\n * used in distribution calculations. The amount string may contain decimals.\n */\nexport type DecCoin = Coin;\n\n// Bank query results\nexport interface BalanceResult {\n readonly balance?: Coin;\n}\n\nexport interface BalancesResult extends PaginatedResult {\n readonly balances: readonly Coin[];\n}\n\nexport interface TotalSupplyResult extends PaginatedResult {\n readonly supply: readonly Coin[];\n}\n\nexport interface SupplyOfResult {\n readonly amount?: Coin;\n}\n\nexport interface DenomMetadataResult {\n readonly metadata?: BankMetadata;\n}\n\nexport interface DenomsMetadataResult extends PaginatedResult {\n readonly metadatas: readonly BankMetadata[];\n}\n\nexport interface SendEnabledResult extends PaginatedResult {\n readonly sendEnabled: readonly SendEnabled[];\n}\n\nexport interface BankParamsResult {\n readonly params?: BankParams;\n}\n\n// Staking query results\nexport interface DelegationResult {\n readonly delegationResponse?: DelegationResponse;\n}\n\nexport interface DelegationsResult extends PaginatedResult {\n readonly delegationResponses: readonly DelegationResponse[];\n}\n\nexport interface UnbondingDelegationResult {\n readonly unbond?: UnbondingDelegation;\n}\n\nexport interface UnbondingDelegationsResult extends PaginatedResult {\n readonly unbondingResponses: readonly UnbondingDelegation[];\n}\n\nexport interface RedelegationsResult extends PaginatedResult {\n readonly redelegationResponses: readonly RedelegationResponse[];\n}\n\nexport interface ValidatorResult {\n readonly validator?: Validator;\n}\n\nexport interface ValidatorsResult extends PaginatedResult {\n readonly validators: readonly Validator[];\n}\n\nexport interface StakingPoolResult {\n readonly pool?: StakingPool;\n}\n\nexport interface StakingParamsResult {\n readonly params?: StakingParams;\n}\n\nexport interface HistoricalInfoResult {\n readonly hist?: HistoricalInfo;\n}\n\n// Distribution query results\n// Note: When querying all rewards, 'rewards' is DelegationDelegatorReward[] (per validator).\n// When querying specific validator, 'rewards' is DecCoin[] (direct reward coins).\nexport interface RewardsResult {\n readonly rewards: readonly DecCoin[] | readonly DelegationDelegatorReward[];\n readonly total?: readonly DecCoin[];\n}\n\nexport interface CommissionResult {\n readonly commission?: ValidatorAccumulatedCommission;\n}\n\nexport interface CommunityPoolResult {\n readonly pool: readonly DecCoin[];\n}\n\nexport interface DistributionParamsResult {\n readonly params?: DistributionParams;\n}\n\nexport interface ValidatorOutstandingRewardsResult {\n readonly rewards?: ValidatorOutstandingRewards;\n}\n\nexport interface SlashesResult extends PaginatedResult {\n readonly slashes: readonly ValidatorSlashEvent[];\n}\n\nexport interface DelegatorValidatorsResult {\n readonly validators: readonly string[];\n}\n\nexport interface DelegatorWithdrawAddressResult {\n readonly withdrawAddress: string;\n}\n\n// Gov query results\nexport interface ProposalResult {\n readonly proposal?: GovProposal;\n}\n\nexport interface ProposalsResult extends PaginatedResult {\n readonly proposals: readonly GovProposal[];\n}\n\nexport interface VoteResult {\n readonly vote?: GovVote;\n}\n\nexport interface VotesResult extends PaginatedResult {\n readonly votes: readonly GovVote[];\n}\n\nexport interface DepositResult {\n readonly deposit?: GovDeposit;\n}\n\nexport interface DepositsResult extends PaginatedResult {\n readonly deposits: readonly GovDeposit[];\n}\n\nexport interface TallyResult {\n readonly tally?: GovTallyResult;\n}\n\nexport interface GovParamsResult {\n readonly votingParams?: VotingParams;\n readonly depositParams?: DepositParams;\n readonly tallyParams?: TallyParams;\n readonly params?: GovParams;\n}\n\n// Auth query results\n// Note: Account types are polymorphic - the RPC can return BaseAccount, ModuleAccount, or other account types wrapped in Any\nexport interface AuthAccountResult {\n readonly account?: BaseAccount | ModuleAccount | Any;\n}\n\nexport interface AuthAccountsResult extends PaginatedResult {\n readonly accounts: readonly (BaseAccount | Any)[];\n}\n\nexport interface AuthParamsResult {\n readonly params?: AuthParams;\n}\n\nexport interface ModuleAccountsResult {\n readonly accounts: readonly (ModuleAccount | Any)[];\n}\n\nexport interface AddressBytesToStringResult {\n readonly addressString: string;\n}\n\nexport interface AddressStringToBytesResult {\n readonly addressBytes: string;\n}\n\nexport interface Bech32PrefixResult {\n readonly bech32Prefix: string;\n}\n\nexport interface AccountInfoResult {\n readonly info?: BaseAccount;\n}\n\n// Billing query results\nexport interface BillingParamsResult {\n readonly params?: BillingParams;\n}\n\nexport interface LeaseResult {\n readonly lease?: Lease;\n}\n\nexport interface LeasesResult extends PaginatedResult {\n readonly leases: readonly Lease[];\n}\n\nexport interface CreditAccountResult {\n readonly creditAccount?: CreditAccount;\n}\n\nexport interface CreditAccountsResult extends PaginatedResult {\n readonly creditAccounts: readonly CreditAccount[];\n}\n\nexport interface CreditAddressResult {\n readonly creditAddress: string;\n}\n\nexport interface WithdrawableAmountResult {\n readonly amounts: readonly Coin[];\n}\n\nexport interface ProviderWithdrawableResult {\n readonly amounts: readonly Coin[];\n}\n\nexport interface CreditEstimateResult {\n readonly estimate: QueryCreditEstimateResponse;\n}\n\n// Group query results\nexport interface GroupInfoResult {\n readonly info?: GroupInfo;\n}\n\nexport interface GroupPolicyInfoResult {\n readonly info?: GroupPolicyInfo;\n}\n\nexport interface GroupMembersResult extends PaginatedResult {\n readonly members: readonly GroupMember[];\n}\n\nexport interface GroupsResult extends PaginatedResult {\n readonly groups: readonly GroupInfo[];\n}\n\nexport interface GroupPoliciesResult extends PaginatedResult {\n readonly groupPolicies: readonly GroupPolicyInfo[];\n}\n\nexport interface GroupProposalResult {\n readonly proposal?: GroupProposal;\n}\n\nexport interface GroupProposalsResult extends PaginatedResult {\n readonly proposals: readonly GroupProposal[];\n}\n\nexport interface GroupVoteResult {\n readonly vote?: GroupVote;\n}\n\nexport interface GroupVotesResult extends PaginatedResult {\n readonly votes: readonly GroupVote[];\n}\n\nexport interface GroupTallyQueryResult {\n readonly tally?: GroupTallyResult;\n}\n\n// SKU query results\nexport interface SkuParamsResult {\n readonly params?: SkuParams;\n}\n\nexport interface ProviderResult {\n readonly provider?: Provider;\n}\n\nexport interface ProvidersResult extends PaginatedResult {\n readonly providers: readonly Provider[];\n}\n\nexport interface SkuResult {\n readonly sku?: SKU;\n}\n\nexport interface SkusResult extends PaginatedResult {\n readonly skus: readonly SKU[];\n}\n\n/**\n * Union type of all query results for type-safe handling\n */\nexport type QueryResult =\n | BalanceResult\n | BalancesResult\n | TotalSupplyResult\n | SupplyOfResult\n | DenomMetadataResult\n | DenomsMetadataResult\n | SendEnabledResult\n | BankParamsResult\n | DelegationResult\n | DelegationsResult\n | UnbondingDelegationResult\n | UnbondingDelegationsResult\n | RedelegationsResult\n | ValidatorResult\n | ValidatorsResult\n | StakingPoolResult\n | StakingParamsResult\n | HistoricalInfoResult\n | RewardsResult\n | CommissionResult\n | CommunityPoolResult\n | DistributionParamsResult\n | ValidatorOutstandingRewardsResult\n | SlashesResult\n | DelegatorValidatorsResult\n | DelegatorWithdrawAddressResult\n | ProposalResult\n | ProposalsResult\n | VoteResult\n | VotesResult\n | DepositResult\n | DepositsResult\n | TallyResult\n | GovParamsResult\n | AuthAccountResult\n | AuthAccountsResult\n | AuthParamsResult\n | ModuleAccountsResult\n | AddressBytesToStringResult\n | AddressStringToBytesResult\n | Bech32PrefixResult\n | AccountInfoResult\n | BillingParamsResult\n | LeaseResult\n | LeasesResult\n | CreditAccountResult\n | CreditAccountsResult\n | CreditAddressResult\n | WithdrawableAmountResult\n | ProviderWithdrawableResult\n | CreditEstimateResult\n | SkuParamsResult\n | ProviderResult\n | ProvidersResult\n | SkuResult\n | SkusResult\n | GroupInfoResult\n | GroupPolicyInfoResult\n | GroupMembersResult\n | GroupsResult\n | GroupPoliciesResult\n | GroupProposalResult\n | GroupProposalsResult\n | GroupVoteResult\n | GroupVotesResult\n | GroupTallyQueryResult;\n\n/**\n * Result from a Cosmos query\n */\nexport interface CosmosQueryResult {\n readonly module: string;\n readonly subcommand: string;\n readonly result: QueryResult;\n}\n"],"mappings":";;;;AA+NA,IAAY,uBAAL,yBAAA,sBAAA;AAEL,sBAAA,oBAAA;AACA,sBAAA,oBAAA;AAGA,sBAAA,0BAAA;AACA,sBAAA,8BAAA;AACA,sBAAA,sBAAA;AAGA,sBAAA,2BAAA;AAGA,sBAAA,kBAAA;AACA,sBAAA,uBAAA;AACA,sBAAA,qBAAA;AAGA,sBAAA,eAAA;AACA,sBAAA,yBAAA;AACA,sBAAA,oBAAA;AACA,sBAAA,wBAAA;AAGA,sBAAA,oBAAA;;KACD;;;;AAKD,IAAa,mBAAb,MAAa,yBAAyB,MAAM;CAI1C,YACE,MACA,SACA,SACA;AACA,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,UAAU;AAGf,SAAO,eAAe,MAAM,iBAAiB,UAAU;;CAGzD,SAAkC;AAChC,SAAO;GACL,MAAM,KAAK;GACX,MAAM,KAAK;GACX,SAAS,KAAK;GACd,SAAS,KAAK;GACf"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { OfflineSigner } from '@cosmjs/proto-signing';\n// Auth module types\nimport type {\n Params as AuthParams,\n BaseAccount,\n ModuleAccount,\n} from '@manifest-network/manifestjs/dist/codegen/cosmos/auth/v1beta1/auth.js';\n// Bank module types\nimport type {\n Metadata as BankMetadata,\n Params as BankParams,\n SendEnabled,\n} from '@manifest-network/manifestjs/dist/codegen/cosmos/bank/v1beta1/bank.js';\n\n// Distribution module types\nimport type {\n DelegationDelegatorReward,\n Params as DistributionParams,\n ValidatorAccumulatedCommission,\n ValidatorOutstandingRewards,\n ValidatorSlashEvent,\n} from '@manifest-network/manifestjs/dist/codegen/cosmos/distribution/v1beta1/distribution.js';\n\n// Gov module types (v1 for newer chains)\nimport type {\n DepositParams,\n Deposit as GovDeposit,\n Params as GovParams,\n Proposal as GovProposal,\n TallyResult as GovTallyResult,\n Vote as GovVote,\n TallyParams,\n VotingParams,\n} from '@manifest-network/manifestjs/dist/codegen/cosmos/gov/v1/gov.js';\n// Group module types\nimport type {\n GroupInfo,\n GroupMember,\n GroupPolicyInfo,\n Proposal as GroupProposal,\n TallyResult as GroupTallyResult,\n Vote as GroupVote,\n} from '@manifest-network/manifestjs/dist/codegen/cosmos/group/v1/types.js';\n// Staking module types\nimport type {\n DelegationResponse,\n HistoricalInfo,\n RedelegationResponse,\n Params as StakingParams,\n Pool as StakingPool,\n UnbondingDelegation,\n Validator,\n} from '@manifest-network/manifestjs/dist/codegen/cosmos/staking/v1beta1/staking.js';\n// Protobuf Any type for polymorphic account types\nimport type { Any } from '@manifest-network/manifestjs/dist/codegen/google/protobuf/any.js';\n// Billing credit estimate response\nimport type { QueryCreditEstimateResponse } from '@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/query.js';\nimport type { LeaseItemInput } from '@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/tx.js';\n// Billing module types (Manifest-specific)\nimport type {\n Params as BillingParams,\n CreditAccount,\n Lease,\n} from '@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js';\n\n// SKU module types (Manifest-specific)\nimport type {\n Provider,\n SKU,\n Params as SkuParams,\n} from '@manifest-network/manifestjs/dist/codegen/liftedinit/sku/v1/types.js';\n\n// Re-export commonly used protobuf types for consumers\nexport type {\n Any,\n AuthParams,\n BankMetadata,\n BankParams,\n BaseAccount,\n BillingParams,\n CreditAccount,\n DelegationDelegatorReward,\n DelegationResponse,\n DepositParams,\n DistributionParams,\n GovDeposit,\n GovParams,\n GovProposal,\n GovTallyResult,\n GovVote,\n GroupInfo,\n GroupMember,\n GroupPolicyInfo,\n GroupProposal,\n GroupTallyResult,\n GroupVote,\n HistoricalInfo,\n Lease,\n LeaseItemInput,\n ModuleAccount,\n Provider,\n QueryCreditEstimateResponse,\n RedelegationResponse,\n SendEnabled,\n SKU,\n SkuParams,\n StakingParams,\n StakingPool,\n TallyParams,\n UnbondingDelegation,\n Validator,\n ValidatorAccumulatedCommission,\n ValidatorOutstandingRewards,\n ValidatorSlashEvent,\n VotingParams,\n};\n\n/**\n * Rate limiting configuration\n */\nexport interface RateLimitConfig {\n /** Maximum requests per second (default: 10) */\n readonly requestsPerSecond?: number;\n}\n\n/**\n * Retry configuration for transient RPC failures\n */\nexport interface RetryConfig {\n /** Maximum number of retry attempts (default: 3) */\n readonly maxRetries?: number;\n /** Base delay in milliseconds before first retry (default: 1000) */\n readonly baseDelayMs?: number;\n /** Maximum delay in milliseconds between retries (default: 10000) */\n readonly maxDelayMs?: number;\n}\n\n/**\n * Configuration for the Manifest MCP server\n */\nexport interface ManifestMCPConfig {\n /** Chain ID (e.g., \"manifest-ledger-testnet\") */\n readonly chainId: string;\n /** RPC endpoint URL (required for transactions; optional if restUrl provided for query-only mode) */\n readonly rpcUrl?: string;\n /** Gas price with denomination (e.g., \"1.0umfx\"); required when rpcUrl is provided */\n readonly gasPrice?: string;\n /** REST/LCD endpoint URL for queries (e.g., \"http://localhost:1317\") */\n readonly restUrl?: string;\n /** Address prefix (e.g., \"manifest\") */\n readonly addressPrefix?: string;\n /** Rate limiting configuration */\n readonly rateLimit?: RateLimitConfig;\n /** Retry configuration for transient failures */\n readonly retry?: RetryConfig;\n /** Gas simulation multiplier (default: 1.5, minimum: 1). A value of 1.0 uses the exact simulation result with no safety margin. Increase if transactions fail with out-of-gas errors. */\n readonly gasMultiplier?: number;\n}\n\n/**\n * Wallet provider interface for different wallet implementations\n *\n * Any wallet that provides an OfflineSigner works (Keplr, Web3Auth, Leap, cosmos-kit, etc.)\n */\nexport interface SignArbitraryResult {\n readonly pub_key: { readonly type: string; readonly value: string };\n readonly signature: string;\n}\n\nexport interface WalletProvider {\n /** Get the wallet's address */\n getAddress(): Promise<string>;\n /** Get the offline signer for signing transactions */\n getSigner(): Promise<OfflineSigner>;\n /** Optional: Sign arbitrary data (ADR-036) for off-chain authentication */\n signArbitrary?(address: string, data: string): Promise<SignArbitraryResult>;\n /** Optional: Connect to the wallet */\n connect?(): Promise<void>;\n /** Optional: Disconnect from the wallet */\n disconnect?(): Promise<void>;\n}\n\n/**\n * Result from a Cosmos transaction\n */\nexport interface CosmosTxResult {\n readonly module: string;\n readonly subcommand: string;\n readonly transactionHash: string;\n readonly code: number;\n readonly height: string;\n readonly rawLog?: string;\n readonly confirmed?: boolean;\n readonly confirmationHeight?: string;\n readonly gasUsed?: string;\n readonly gasWanted?: string;\n readonly events?: readonly {\n readonly type: string;\n readonly attributes: readonly {\n readonly key: string;\n readonly value: string;\n }[];\n }[];\n}\n\n/**\n * Module information for discovery\n */\nexport interface ModuleInfo {\n readonly name: string;\n readonly description: string;\n readonly args?: string; // Usage hint for arguments\n}\n\n/**\n * Available modules listing\n */\nexport interface AvailableModules {\n readonly queryModules: readonly ModuleInfo[];\n readonly txModules: readonly ModuleInfo[];\n}\n\n/**\n * Error codes for ManifestMCPError\n */\nexport enum ManifestMCPErrorCode {\n // Configuration errors\n INVALID_CONFIG = 'INVALID_CONFIG',\n MISSING_CONFIG = 'MISSING_CONFIG',\n\n // Wallet errors\n WALLET_NOT_CONNECTED = 'WALLET_NOT_CONNECTED',\n WALLET_CONNECTION_FAILED = 'WALLET_CONNECTION_FAILED',\n INVALID_MNEMONIC = 'INVALID_MNEMONIC',\n\n // Client errors\n RPC_CONNECTION_FAILED = 'RPC_CONNECTION_FAILED',\n\n // Query errors\n QUERY_FAILED = 'QUERY_FAILED',\n UNSUPPORTED_QUERY = 'UNSUPPORTED_QUERY',\n INVALID_ADDRESS = 'INVALID_ADDRESS',\n\n // Transaction errors\n TX_FAILED = 'TX_FAILED',\n TX_BROADCAST_FAILED = 'TX_BROADCAST_FAILED',\n UNSUPPORTED_TX = 'UNSUPPORTED_TX',\n INSUFFICIENT_FUNDS = 'INSUFFICIENT_FUNDS',\n\n // Module errors\n UNKNOWN_MODULE = 'UNKNOWN_MODULE',\n}\n\n/**\n * Custom error class for Manifest MCP errors\n */\nexport class ManifestMCPError extends Error {\n public readonly code: ManifestMCPErrorCode;\n public readonly details?: Record<string, unknown>;\n\n constructor(\n code: ManifestMCPErrorCode,\n message: string,\n details?: Record<string, unknown>,\n ) {\n super(message);\n this.name = 'ManifestMCPError';\n this.code = code;\n this.details = details;\n\n // Ensure proper prototype chain for instanceof checks\n Object.setPrototypeOf(this, ManifestMCPError.prototype);\n }\n\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n details: this.details,\n };\n }\n}\n\n/**\n * Account information\n */\nexport interface AccountInfo {\n readonly address: string;\n}\n\n// ============================================================================\n// Query Result Types\n// ============================================================================\n\n/**\n * Pagination response from Cosmos SDK queries\n */\nexport interface PaginationResponse {\n readonly nextKey?: Uint8Array;\n readonly total?: bigint;\n}\n\n/**\n * Base interface for paginated query results\n */\nexport interface PaginatedResult {\n readonly pagination?: PaginationResponse;\n}\n\n/**\n * Coin type from Cosmos SDK\n */\nexport interface Coin {\n readonly denom: string;\n readonly amount: string;\n}\n\n/**\n * DecCoin type from Cosmos SDK (for rewards, commission, etc.)\n *\n * DecCoin has the same structure as Coin but represents decimal amounts\n * used in distribution calculations. The amount string may contain decimals.\n */\nexport type DecCoin = Coin;\n\n// Bank query results\nexport interface BalanceResult {\n readonly balance?: Coin;\n}\n\nexport interface BalancesResult extends PaginatedResult {\n readonly balances: readonly Coin[];\n}\n\nexport interface TotalSupplyResult extends PaginatedResult {\n readonly supply: readonly Coin[];\n}\n\nexport interface SupplyOfResult {\n readonly amount?: Coin;\n}\n\nexport interface DenomMetadataResult {\n readonly metadata?: BankMetadata;\n}\n\nexport interface DenomsMetadataResult extends PaginatedResult {\n readonly metadatas: readonly BankMetadata[];\n}\n\nexport interface SendEnabledResult extends PaginatedResult {\n readonly sendEnabled: readonly SendEnabled[];\n}\n\nexport interface BankParamsResult {\n readonly params?: BankParams;\n}\n\n// Staking query results\nexport interface DelegationResult {\n readonly delegationResponse?: DelegationResponse;\n}\n\nexport interface DelegationsResult extends PaginatedResult {\n readonly delegationResponses: readonly DelegationResponse[];\n}\n\nexport interface UnbondingDelegationResult {\n readonly unbond?: UnbondingDelegation;\n}\n\nexport interface UnbondingDelegationsResult extends PaginatedResult {\n readonly unbondingResponses: readonly UnbondingDelegation[];\n}\n\nexport interface RedelegationsResult extends PaginatedResult {\n readonly redelegationResponses: readonly RedelegationResponse[];\n}\n\nexport interface ValidatorResult {\n readonly validator?: Validator;\n}\n\nexport interface ValidatorsResult extends PaginatedResult {\n readonly validators: readonly Validator[];\n}\n\nexport interface StakingPoolResult {\n readonly pool?: StakingPool;\n}\n\nexport interface StakingParamsResult {\n readonly params?: StakingParams;\n}\n\nexport interface HistoricalInfoResult {\n readonly hist?: HistoricalInfo;\n}\n\n// Distribution query results\n// Note: When querying all rewards, 'rewards' is DelegationDelegatorReward[] (per validator).\n// When querying specific validator, 'rewards' is DecCoin[] (direct reward coins).\nexport interface RewardsResult {\n readonly rewards: readonly DecCoin[] | readonly DelegationDelegatorReward[];\n readonly total?: readonly DecCoin[];\n}\n\nexport interface CommissionResult {\n readonly commission?: ValidatorAccumulatedCommission;\n}\n\nexport interface CommunityPoolResult {\n readonly pool: readonly DecCoin[];\n}\n\nexport interface DistributionParamsResult {\n readonly params?: DistributionParams;\n}\n\nexport interface ValidatorOutstandingRewardsResult {\n readonly rewards?: ValidatorOutstandingRewards;\n}\n\nexport interface SlashesResult extends PaginatedResult {\n readonly slashes: readonly ValidatorSlashEvent[];\n}\n\nexport interface DelegatorValidatorsResult {\n readonly validators: readonly string[];\n}\n\nexport interface DelegatorWithdrawAddressResult {\n readonly withdrawAddress: string;\n}\n\n// Gov query results\nexport interface ProposalResult {\n readonly proposal?: GovProposal;\n}\n\nexport interface ProposalsResult extends PaginatedResult {\n readonly proposals: readonly GovProposal[];\n}\n\nexport interface VoteResult {\n readonly vote?: GovVote;\n}\n\nexport interface VotesResult extends PaginatedResult {\n readonly votes: readonly GovVote[];\n}\n\nexport interface DepositResult {\n readonly deposit?: GovDeposit;\n}\n\nexport interface DepositsResult extends PaginatedResult {\n readonly deposits: readonly GovDeposit[];\n}\n\nexport interface TallyResult {\n readonly tally?: GovTallyResult;\n}\n\nexport interface GovParamsResult {\n readonly votingParams?: VotingParams;\n readonly depositParams?: DepositParams;\n readonly tallyParams?: TallyParams;\n readonly params?: GovParams;\n}\n\n// Auth query results\n// Note: Account types are polymorphic - the RPC can return BaseAccount, ModuleAccount, or other account types wrapped in Any\nexport interface AuthAccountResult {\n readonly account?: BaseAccount | ModuleAccount | Any;\n}\n\nexport interface AuthAccountsResult extends PaginatedResult {\n readonly accounts: readonly (BaseAccount | Any)[];\n}\n\nexport interface AuthParamsResult {\n readonly params?: AuthParams;\n}\n\nexport interface ModuleAccountsResult {\n readonly accounts: readonly (ModuleAccount | Any)[];\n}\n\nexport interface AddressBytesToStringResult {\n readonly addressString: string;\n}\n\nexport interface AddressStringToBytesResult {\n readonly addressBytes: string;\n}\n\nexport interface Bech32PrefixResult {\n readonly bech32Prefix: string;\n}\n\nexport interface AccountInfoResult {\n readonly info?: BaseAccount;\n}\n\n// Billing query results\nexport interface BillingParamsResult {\n readonly params?: BillingParams;\n}\n\nexport interface LeaseResult {\n readonly lease?: Lease;\n}\n\nexport interface LeasesResult extends PaginatedResult {\n readonly leases: readonly Lease[];\n}\n\nexport interface CreditAccountResult {\n readonly creditAccount?: CreditAccount;\n}\n\nexport interface CreditAccountsResult extends PaginatedResult {\n readonly creditAccounts: readonly CreditAccount[];\n}\n\nexport interface CreditAddressResult {\n readonly creditAddress: string;\n}\n\nexport interface WithdrawableAmountResult {\n readonly amounts: readonly Coin[];\n}\n\nexport interface ProviderWithdrawableResult {\n readonly amounts: readonly Coin[];\n}\n\nexport interface CreditEstimateResult {\n readonly estimate: QueryCreditEstimateResponse;\n}\n\n// Group query results\nexport interface GroupInfoResult {\n readonly info?: GroupInfo;\n}\n\nexport interface GroupPolicyInfoResult {\n readonly info?: GroupPolicyInfo;\n}\n\nexport interface GroupMembersResult extends PaginatedResult {\n readonly members: readonly GroupMember[];\n}\n\nexport interface GroupsResult extends PaginatedResult {\n readonly groups: readonly GroupInfo[];\n}\n\nexport interface GroupPoliciesResult extends PaginatedResult {\n readonly groupPolicies: readonly GroupPolicyInfo[];\n}\n\nexport interface GroupProposalResult {\n readonly proposal?: GroupProposal;\n}\n\nexport interface GroupProposalsResult extends PaginatedResult {\n readonly proposals: readonly GroupProposal[];\n}\n\nexport interface GroupVoteResult {\n readonly vote?: GroupVote;\n}\n\nexport interface GroupVotesResult extends PaginatedResult {\n readonly votes: readonly GroupVote[];\n}\n\nexport interface GroupTallyQueryResult {\n readonly tally?: GroupTallyResult;\n}\n\n// SKU query results\nexport interface SkuParamsResult {\n readonly params?: SkuParams;\n}\n\nexport interface ProviderResult {\n readonly provider?: Provider;\n}\n\nexport interface ProvidersResult extends PaginatedResult {\n readonly providers: readonly Provider[];\n}\n\nexport interface SkuResult {\n readonly sku?: SKU;\n}\n\nexport interface SkusResult extends PaginatedResult {\n readonly skus: readonly SKU[];\n}\n\n/**\n * Union type of all query results for type-safe handling\n */\nexport type QueryResult =\n | BalanceResult\n | BalancesResult\n | TotalSupplyResult\n | SupplyOfResult\n | DenomMetadataResult\n | DenomsMetadataResult\n | SendEnabledResult\n | BankParamsResult\n | DelegationResult\n | DelegationsResult\n | UnbondingDelegationResult\n | UnbondingDelegationsResult\n | RedelegationsResult\n | ValidatorResult\n | ValidatorsResult\n | StakingPoolResult\n | StakingParamsResult\n | HistoricalInfoResult\n | RewardsResult\n | CommissionResult\n | CommunityPoolResult\n | DistributionParamsResult\n | ValidatorOutstandingRewardsResult\n | SlashesResult\n | DelegatorValidatorsResult\n | DelegatorWithdrawAddressResult\n | ProposalResult\n | ProposalsResult\n | VoteResult\n | VotesResult\n | DepositResult\n | DepositsResult\n | TallyResult\n | GovParamsResult\n | AuthAccountResult\n | AuthAccountsResult\n | AuthParamsResult\n | ModuleAccountsResult\n | AddressBytesToStringResult\n | AddressStringToBytesResult\n | Bech32PrefixResult\n | AccountInfoResult\n | BillingParamsResult\n | LeaseResult\n | LeasesResult\n | CreditAccountResult\n | CreditAccountsResult\n | CreditAddressResult\n | WithdrawableAmountResult\n | ProviderWithdrawableResult\n | CreditEstimateResult\n | SkuParamsResult\n | ProviderResult\n | ProvidersResult\n | SkuResult\n | SkusResult\n | GroupInfoResult\n | GroupPolicyInfoResult\n | GroupMembersResult\n | GroupsResult\n | GroupPoliciesResult\n | GroupProposalResult\n | GroupProposalsResult\n | GroupVoteResult\n | GroupVotesResult\n | GroupTallyQueryResult;\n\n/**\n * Result from a Cosmos query\n */\nexport interface CosmosQueryResult {\n readonly module: string;\n readonly subcommand: string;\n readonly result: QueryResult;\n}\n"],"mappings":";;;;AAiOA,IAAY,uBAAL,yBAAA,sBAAA;AAEL,sBAAA,oBAAA;AACA,sBAAA,oBAAA;AAGA,sBAAA,0BAAA;AACA,sBAAA,8BAAA;AACA,sBAAA,sBAAA;AAGA,sBAAA,2BAAA;AAGA,sBAAA,kBAAA;AACA,sBAAA,uBAAA;AACA,sBAAA,qBAAA;AAGA,sBAAA,eAAA;AACA,sBAAA,yBAAA;AACA,sBAAA,oBAAA;AACA,sBAAA,wBAAA;AAGA,sBAAA,oBAAA;;KACD;;;;AAKD,IAAa,mBAAb,MAAa,yBAAyB,MAAM;CAI1C,YACE,MACA,SACA,SACA;AACA,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,UAAU;AAGf,SAAO,eAAe,MAAM,iBAAiB,UAAU;;CAGzD,SAAkC;AAChC,SAAO;GACL,MAAM,KAAK;GACX,MAAM,KAAK;GACX,SAAS,KAAK;GACd,SAAS,KAAK;GACf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manifest-network/manifest-mcp-core",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
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",