@manifest-network/manifest-mcp-core 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"cosmos.d.ts","names":[],"sources":["../src/cosmos.ts"],"mappings":";;;;;;AA2CA;;;;iBAAsB,WAAA,CACpB,aAAA,EAAe,mBAAA,EACf,MAAA,UACA,UAAA,UACA,IAAA,cACC,OAAA,CAAQ,iBAAA;;;;;;;;;;iBAoDW,QAAA,CACpB,aAAA,EAAe,mBAAA,EACf,MAAA,UACA,UAAA,UACA,IAAA,aACA,mBAAA,YACA,SAAA,GAAY,WAAA,GACX,OAAA,CAAQ,cAAA;;;AAPX;;;;;;;;;iBA2FsB,iBAAA,CACpB,aAAA,EAAe,mBAAA,EACf,MAAA,UACA,UAAA,UACA,IAAA,aACA,SAAA,GAAY,WAAA,GACX,OAAA,CAAQ,iBAAA"}
1
+ {"version":3,"file":"cosmos.d.ts","names":[],"sources":["../src/cosmos.ts"],"mappings":";;;;;;AAqGA;;;;iBAAsB,WAAA,CACpB,aAAA,EAAe,mBAAA,EACf,MAAA,UACA,UAAA,UACA,IAAA,cACC,OAAA,CAAQ,iBAAA;;;;;;;;;;iBA+DW,QAAA,CACpB,aAAA,EAAe,mBAAA,EACf,MAAA,UACA,UAAA,UACA,IAAA,aACA,mBAAA,YACA,SAAA,GAAY,WAAA,GACX,OAAA,CAAQ,cAAA;;;AAPX;;;;;;;;;iBA4GsB,iBAAA,CACpB,aAAA,EAAe,mBAAA,EACf,MAAA,UACA,UAAA,UACA,IAAA,aACA,SAAA,GAAY,WAAA,GACX,OAAA,CAAQ,iBAAA"}
package/dist/cosmos.js CHANGED
@@ -1,11 +1,44 @@
1
1
  import { ManifestMCPError, ManifestMCPErrorCode } from "./types.js";
2
2
  import { withRetry } from "./retry.js";
3
3
  import "./config.js";
4
- import { getQueryHandler, getTxHandler, getTxMsgBuilder } from "./modules.js";
4
+ import { getQueryHandler, getTxContextLoader, getTxHandler, getTxMsgBuilder } from "./modules.js";
5
5
  import { calculateFee } from "@cosmjs/stargate";
6
6
  //#region src/cosmos.ts
7
7
  const VALID_NAME_PATTERN = /^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/;
8
8
  /**
9
+ * Resolve and run the `TxBuildContext` loader registered for `(module,
10
+ * subcommand)` in `TX_MODULES`. Returns `undefined` when no loader is
11
+ * registered (the common case) so the caller can short-circuit and skip the
12
+ * chain read.
13
+ *
14
+ * Acquires a rate-limit token before the loader runs so each extra RPC is
15
+ * counted against the same budget every other RPC respects, and wraps any
16
+ * non-`ManifestMCPError` failure as `QUERY_FAILED` with `{module, subcommand}`
17
+ * details for symmetric error classification on both broadcast and estimate
18
+ * paths.
19
+ */
20
+ async function loadBuildContext(clientManager, module, subcommand) {
21
+ const loader = getTxContextLoader(module, subcommand);
22
+ if (!loader) return void 0;
23
+ try {
24
+ await clientManager.acquireRateLimit();
25
+ return await loader(await clientManager.getQueryClient());
26
+ } catch (error) {
27
+ if (error instanceof ManifestMCPError) {
28
+ if (!error.details?.module) throw new ManifestMCPError(error.code, error.message, {
29
+ ...error.details,
30
+ module,
31
+ subcommand
32
+ });
33
+ throw error;
34
+ }
35
+ throw new ManifestMCPError(ManifestMCPErrorCode.QUERY_FAILED, `Failed to load build context for ${module} ${subcommand}: ${error instanceof Error ? error.message : String(error)}`, {
36
+ module,
37
+ subcommand
38
+ });
39
+ }
40
+ }
41
+ /**
9
42
  * Validate that a string is safe for use as a module or subcommand name.
10
43
  * Uses the appropriate UNSUPPORTED_QUERY or UNSUPPORTED_TX code so that
11
44
  * the error is immediately classified as non-retryable.
@@ -24,17 +57,26 @@ async function cosmosQuery(clientManager, module, subcommand, args = []) {
24
57
  validateName(subcommand, "subcommand", ManifestMCPErrorCode.UNSUPPORTED_QUERY);
25
58
  const handler = getQueryHandler(module);
26
59
  return withRetry(async () => {
27
- await clientManager.acquireRateLimit();
28
- const queryClient = await clientManager.getQueryClient();
29
60
  try {
61
+ await clientManager.acquireRateLimit();
30
62
  return {
31
63
  module,
32
64
  subcommand,
33
- result: await handler(queryClient, subcommand, args)
65
+ result: await handler(await clientManager.getQueryClient(), subcommand, args)
34
66
  };
35
67
  } catch (error) {
36
- if (error instanceof ManifestMCPError) throw error;
37
- throw new ManifestMCPError(ManifestMCPErrorCode.QUERY_FAILED, `Query ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`);
68
+ if (error instanceof ManifestMCPError) {
69
+ if (!error.details?.module) throw new ManifestMCPError(error.code, error.message, {
70
+ ...error.details,
71
+ module,
72
+ subcommand
73
+ });
74
+ throw error;
75
+ }
76
+ throw new ManifestMCPError(ManifestMCPErrorCode.QUERY_FAILED, `Query ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`, {
77
+ module,
78
+ subcommand
79
+ });
38
80
  }
39
81
  }, {
40
82
  config: clientManager.getConfig().retry,
@@ -64,12 +106,14 @@ async function cosmosTx(clientManager, module, subcommand, args = [], waitForCon
64
106
  };
65
107
  }
66
108
  const handler = getTxHandler(module);
109
+ const buildContext = await withRetry(() => loadBuildContext(clientManager, module, subcommand), {
110
+ config: clientManager.getConfig().retry,
111
+ operationName: `load-context ${module} ${subcommand}`
112
+ });
67
113
  return withRetry(async () => {
68
- await clientManager.acquireRateLimit();
69
- const signingClient = await clientManager.getSigningClient();
70
- const senderAddress = await clientManager.getAddress();
71
114
  try {
72
- return await handler(signingClient, senderAddress, subcommand, args, waitForConfirmation, txOptions);
115
+ await clientManager.acquireRateLimit();
116
+ return await handler(await clientManager.getSigningClient(), await clientManager.getAddress(), subcommand, args, waitForConfirmation, txOptions, buildContext);
73
117
  } catch (error) {
74
118
  if (error instanceof ManifestMCPError) {
75
119
  if (!error.details?.module) throw new ManifestMCPError(error.code, error.message, {
@@ -112,14 +156,18 @@ async function cosmosEstimateFee(clientManager, module, subcommand, args = [], o
112
156
  if (!Number.isFinite(overrides.gasMultiplier) || overrides.gasMultiplier < 1) throw new ManifestMCPError(ManifestMCPErrorCode.INVALID_CONFIG, `gasMultiplier must be a finite number >= 1, got ${overrides.gasMultiplier}`);
113
157
  }
114
158
  const builder = getTxMsgBuilder(module);
159
+ const buildContext = await withRetry(() => loadBuildContext(clientManager, module, subcommand), {
160
+ config: config.retry,
161
+ operationName: `load-context ${module} ${subcommand}`
162
+ });
115
163
  return withRetry(async () => {
116
- await clientManager.acquireRateLimit();
117
- const signingClient = await clientManager.getSigningClient();
118
- const senderAddress = await clientManager.getAddress();
119
- const clientMultiplier = signingClient.defaultGasMultiplier;
120
- const gasMultiplier = overrides?.gasMultiplier ?? (typeof clientMultiplier === "number" ? clientMultiplier : 1.5);
121
164
  try {
122
- const built = builder(senderAddress, subcommand, args);
165
+ await clientManager.acquireRateLimit();
166
+ const signingClient = await clientManager.getSigningClient();
167
+ const senderAddress = await clientManager.getAddress();
168
+ const clientMultiplier = signingClient.defaultGasMultiplier;
169
+ const gasMultiplier = overrides?.gasMultiplier ?? (typeof clientMultiplier === "number" ? clientMultiplier : 1.5);
170
+ const built = builder(senderAddress, subcommand, args, buildContext);
123
171
  const gasEstimate = await signingClient.simulate(senderAddress, built.messages, built.memo);
124
172
  const fee = calculateFee(Math.ceil(gasEstimate * gasMultiplier), gasPrice);
125
173
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"cosmos.js","names":[],"sources":["../src/cosmos.ts"],"sourcesContent":["import { calculateFee } from '@cosmjs/stargate';\nimport type { CosmosClientManager } from './client.js';\nimport { DEFAULT_GAS_MULTIPLIER } from './config.js';\nimport { getQueryHandler, getTxHandler, getTxMsgBuilder } from './modules.js';\nimport { withRetry } from './retry.js';\nimport {\n type CosmosQueryResult,\n type CosmosTxResult,\n type FeeEstimateResult,\n ManifestMCPError,\n ManifestMCPErrorCode,\n type TxOptions,\n type TxOverrides,\n} from './types.js';\n\n// Validation pattern for module/subcommand names (alphanumeric, hyphens, underscores)\n// First character must not be a hyphen to prevent potential issues\nconst VALID_NAME_PATTERN = /^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/;\n\n/**\n * Validate that a string is safe for use as a module or subcommand name.\n * Uses the appropriate UNSUPPORTED_QUERY or UNSUPPORTED_TX code so that\n * the error is immediately classified as non-retryable.\n */\nfunction validateName(\n name: string,\n field: string,\n errorCode: ManifestMCPErrorCode,\n): void {\n if (!name || !VALID_NAME_PATTERN.test(name)) {\n throw new ManifestMCPError(\n errorCode,\n `Invalid ${field}: \"${name}\". Only alphanumeric characters, hyphens, and underscores are allowed.`,\n );\n }\n}\n\n/**\n * Execute a Cosmos query via manifestjs RPC client\n *\n * Automatically retries on transient failures (network errors, timeouts, 5xx)\n * with exponential backoff. Configure retry behavior via `config.retry`.\n */\nexport async function cosmosQuery(\n clientManager: CosmosClientManager,\n module: string,\n subcommand: string,\n args: string[] = [],\n): Promise<CosmosQueryResult> {\n validateName(module, 'module', ManifestMCPErrorCode.UNSUPPORTED_QUERY);\n validateName(\n subcommand,\n 'subcommand',\n ManifestMCPErrorCode.UNSUPPORTED_QUERY,\n );\n\n // Get handler from registry (throws if module not found) - do this before retry loop\n const handler = getQueryHandler(module);\n\n return withRetry(\n async () => {\n // Apply rate limiting before making RPC request\n await clientManager.acquireRateLimit();\n\n const queryClient = await clientManager.getQueryClient();\n\n try {\n const result = await handler(queryClient, subcommand, args);\n\n return {\n module,\n subcommand,\n result,\n };\n } catch (error) {\n if (error instanceof ManifestMCPError) {\n throw error;\n }\n throw new ManifestMCPError(\n ManifestMCPErrorCode.QUERY_FAILED,\n `Query ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n {\n config: clientManager.getConfig().retry,\n operationName: `query ${module} ${subcommand}`,\n },\n );\n}\n\n/**\n * Execute a Cosmos transaction via manifestjs signing client\n *\n * Automatically retries on transient failures (network errors, timeouts, 5xx)\n * with exponential backoff. Configure retry behavior via `config.retry`.\n *\n * Note: Only network-level failures are retried. Transaction validation errors\n * (insufficient funds, invalid args, etc.) are not retried as they won't succeed.\n */\nexport async function cosmosTx(\n clientManager: CosmosClientManager,\n module: string,\n subcommand: string,\n args: string[] = [],\n waitForConfirmation: boolean = false,\n overrides?: TxOverrides,\n): Promise<CosmosTxResult> {\n validateName(module, 'module', ManifestMCPErrorCode.UNSUPPORTED_TX);\n validateName(subcommand, 'subcommand', ManifestMCPErrorCode.UNSUPPORTED_TX);\n\n // Build fully-resolved gas options from caller overrides + server config\n let txOptions: TxOptions | undefined;\n if (overrides?.gasMultiplier !== undefined) {\n if (\n !Number.isFinite(overrides.gasMultiplier) ||\n overrides.gasMultiplier < 1\n ) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n `gasMultiplier must be a finite number >= 1, got ${overrides.gasMultiplier}`,\n );\n }\n const gasPrice = clientManager.getConfig().gasPrice;\n if (!gasPrice) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n 'gasMultiplier override requires gasPrice configuration',\n );\n }\n txOptions = { gasMultiplier: overrides.gasMultiplier, gasPrice };\n }\n\n // Get handler from registry (throws if module not found) - do this before retry loop\n const handler = getTxHandler(module);\n\n return withRetry(\n async () => {\n // Apply rate limiting before making RPC request\n await clientManager.acquireRateLimit();\n\n const signingClient = await clientManager.getSigningClient();\n const senderAddress = await clientManager.getAddress();\n\n try {\n return await handler(\n signingClient,\n senderAddress,\n subcommand,\n args,\n waitForConfirmation,\n txOptions,\n );\n } catch (error) {\n if (error instanceof ManifestMCPError) {\n // Re-throw with enriched context if not already present\n if (!error.details?.module) {\n throw new ManifestMCPError(error.code, error.message, {\n ...error.details,\n module,\n subcommand,\n args,\n });\n }\n throw error;\n }\n throw new ManifestMCPError(\n ManifestMCPErrorCode.TX_FAILED,\n `Tx ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`,\n { module, subcommand, args },\n );\n }\n },\n {\n config: clientManager.getConfig().retry,\n operationName: `tx ${module} ${subcommand}`,\n },\n );\n}\n\n/**\n * Estimate the fee for a Cosmos transaction without broadcasting it.\n *\n * Looks up the message builder for the given module, builds the messages,\n * and calls `client.simulate()` to get a gas estimate. Multiplies by the\n * configured (or overridden) gas multiplier and computes the fee.\n *\n * Automatically retries on transient failures via `withRetry`.\n *\n * @returns FeeEstimateResult with raw gas estimate and computed fee\n */\nexport async function cosmosEstimateFee(\n clientManager: CosmosClientManager,\n module: string,\n subcommand: string,\n args: string[] = [],\n overrides?: TxOverrides,\n): Promise<FeeEstimateResult> {\n validateName(module, 'module', ManifestMCPErrorCode.UNSUPPORTED_TX);\n validateName(subcommand, 'subcommand', ManifestMCPErrorCode.UNSUPPORTED_TX);\n\n // Always need gasPrice for fee calculation (unlike cosmosTx which can use 'auto')\n const config = clientManager.getConfig();\n const gasPrice = config.gasPrice;\n if (!gasPrice) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n 'Fee estimation requires gasPrice configuration',\n );\n }\n\n // Validate the override eagerly (the resolved fallback values are always valid).\n if (overrides?.gasMultiplier !== undefined) {\n if (\n !Number.isFinite(overrides.gasMultiplier) ||\n overrides.gasMultiplier < 1\n ) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n `gasMultiplier must be a finite number >= 1, got ${overrides.gasMultiplier}`,\n );\n }\n }\n\n // Get builder from registry (throws if module not found) - do this before retry loop\n const builder = getTxMsgBuilder(module);\n\n return withRetry(\n async () => {\n // Apply rate limiting before making RPC request\n await clientManager.acquireRateLimit();\n\n const signingClient = await clientManager.getSigningClient();\n const senderAddress = await clientManager.getAddress();\n\n // Resolve gasMultiplier from the signing client when no override is provided.\n // This guarantees parity with cosmosTx's 'auto' path: client.ts patches the\n // signing client's defaultGasMultiplier to config.gasMultiplier; if that\n // patch fails (rare — only when CosmJS internals change), the client\n // falls back to CosmJS's built-in default. Reading from the client uses\n // the same value cosmosTx would.\n const clientMultiplier = (\n signingClient as unknown as { defaultGasMultiplier?: unknown }\n ).defaultGasMultiplier;\n const gasMultiplier =\n overrides?.gasMultiplier ??\n (typeof clientMultiplier === 'number'\n ? clientMultiplier\n : DEFAULT_GAS_MULTIPLIER);\n\n try {\n const built = builder(senderAddress, subcommand, args);\n const gasEstimate = await signingClient.simulate(\n senderAddress,\n built.messages,\n built.memo,\n );\n const gasLimit = Math.ceil(gasEstimate * gasMultiplier);\n const fee = calculateFee(gasLimit, gasPrice);\n\n return {\n module,\n subcommand: built.canonicalSubcommand ?? subcommand,\n gasEstimate: String(gasEstimate),\n fee: { amount: fee.amount, gas: fee.gas },\n };\n } catch (error) {\n if (error instanceof ManifestMCPError) {\n // Re-throw with enriched context if not already present (mirrors cosmosTx)\n if (!error.details?.module) {\n throw new ManifestMCPError(error.code, error.message, {\n ...error.details,\n module,\n subcommand,\n args,\n });\n }\n throw error;\n }\n // SIMULATION_FAILED is NOT in NON_RETRYABLE_ERROR_CODES, so withRetry\n // will fall through to isTransientErrorMessage for message-based\n // classification. Transient errors (network/5xx) get retried; real\n // simulation failures (insufficient funds, etc) fail fast.\n throw new ManifestMCPError(\n ManifestMCPErrorCode.SIMULATION_FAILED,\n `Fee estimation for ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`,\n { module, subcommand, args },\n );\n }\n },\n {\n config: config.retry,\n operationName: `estimate ${module} ${subcommand}`,\n },\n );\n}\n"],"mappings":";;;;;;AAiBA,MAAM,qBAAqB;;;;;;AAO3B,SAAS,aACP,MACA,OACA,WACM;AACN,KAAI,CAAC,QAAQ,CAAC,mBAAmB,KAAK,KAAK,CACzC,OAAM,IAAI,iBACR,WACA,WAAW,MAAM,KAAK,KAAK,wEAC5B;;;;;;;;AAUL,eAAsB,YACpB,eACA,QACA,YACA,OAAiB,EAAE,EACS;AAC5B,cAAa,QAAQ,UAAU,qBAAqB,kBAAkB;AACtE,cACE,YACA,cACA,qBAAqB,kBACtB;CAGD,MAAM,UAAU,gBAAgB,OAAO;AAEvC,QAAO,UACL,YAAY;AAEV,QAAM,cAAc,kBAAkB;EAEtC,MAAM,cAAc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iB,kBAAkB;AAErC,QAAI,CAAC,MAAM,SAAS,OAClB,OAAM,IAAI,iBAAiB,MAAM,MAAM,MAAM,SAAS;KACpD,GAAG,MAAM;KACT;KACA;KACA;KACD,CAAC;AAEJ,UAAM;;AAMR,SAAM,IAAI,iBACR,qBAAqB,mBACrB,sBAAsB,OAAO,GAAG,WAAW,WAAW,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IAC5G;IAAE;IAAQ;IAAY;IAAM,CAC7B;;IAGL;EACE,QAAQ,OAAO;EACf,eAAe,YAAY,OAAO,GAAG;EACtC,CACF"}
1
+ {"version":3,"file":"cosmos.js","names":[],"sources":["../src/cosmos.ts"],"sourcesContent":["import { calculateFee } from '@cosmjs/stargate';\nimport type { CosmosClientManager } from './client.js';\nimport { DEFAULT_GAS_MULTIPLIER } from './config.js';\nimport {\n getQueryHandler,\n getTxContextLoader,\n getTxHandler,\n getTxMsgBuilder,\n} from './modules.js';\nimport { withRetry } from './retry.js';\nimport {\n type CosmosQueryResult,\n type CosmosTxResult,\n type FeeEstimateResult,\n ManifestMCPError,\n ManifestMCPErrorCode,\n type TxBuildContext,\n type TxOptions,\n type TxOverrides,\n} from './types.js';\n\n// Validation pattern for module/subcommand names (alphanumeric, hyphens, underscores)\n// First character must not be a hyphen to prevent potential issues\nconst VALID_NAME_PATTERN = /^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/;\n\n/**\n * Resolve and run the `TxBuildContext` loader registered for `(module,\n * subcommand)` in `TX_MODULES`. Returns `undefined` when no loader is\n * registered (the common case) so the caller can short-circuit and skip the\n * chain read.\n *\n * Acquires a rate-limit token before the loader runs so each extra RPC is\n * counted against the same budget every other RPC respects, and wraps any\n * non-`ManifestMCPError` failure as `QUERY_FAILED` with `{module, subcommand}`\n * details for symmetric error classification on both broadcast and estimate\n * paths.\n */\nasync function loadBuildContext(\n clientManager: CosmosClientManager,\n module: string,\n subcommand: string,\n): Promise<TxBuildContext | undefined> {\n const loader = getTxContextLoader(module, subcommand);\n if (!loader) return undefined;\n\n // The full loader call sequence — rate-limit acquire, query-client\n // construction, loader invocation — runs inside the try/catch so every\n // failure mode gets the {module, subcommand} attribution callers expect\n // from a structured error. Without the wrap, an INVALID_CONFIG from\n // `getQueryClient` (or a connection failure that escapes the inner\n // withRetry) would propagate without telling the caller which tx was\n // being prepared.\n try {\n await clientManager.acquireRateLimit();\n const queryClient = await clientManager.getQueryClient();\n return await loader(queryClient);\n } catch (error) {\n if (error instanceof ManifestMCPError) {\n if (!error.details?.module) {\n throw new ManifestMCPError(error.code, error.message, {\n ...error.details,\n module,\n subcommand,\n });\n }\n throw error;\n }\n throw new ManifestMCPError(\n ManifestMCPErrorCode.QUERY_FAILED,\n `Failed to load build context for ${module} ${subcommand}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n { module, subcommand },\n );\n }\n}\n\n/**\n * Validate that a string is safe for use as a module or subcommand name.\n * Uses the appropriate UNSUPPORTED_QUERY or UNSUPPORTED_TX code so that\n * the error is immediately classified as non-retryable.\n */\nfunction validateName(\n name: string,\n field: string,\n errorCode: ManifestMCPErrorCode,\n): void {\n if (!name || !VALID_NAME_PATTERN.test(name)) {\n throw new ManifestMCPError(\n errorCode,\n `Invalid ${field}: \"${name}\". Only alphanumeric characters, hyphens, and underscores are allowed.`,\n );\n }\n}\n\n/**\n * Execute a Cosmos query via manifestjs RPC client\n *\n * Automatically retries on transient failures (network errors, timeouts, 5xx)\n * with exponential backoff. Configure retry behavior via `config.retry`.\n */\nexport async function cosmosQuery(\n clientManager: CosmosClientManager,\n module: string,\n subcommand: string,\n args: string[] = [],\n): Promise<CosmosQueryResult> {\n validateName(module, 'module', ManifestMCPErrorCode.UNSUPPORTED_QUERY);\n validateName(\n subcommand,\n 'subcommand',\n ManifestMCPErrorCode.UNSUPPORTED_QUERY,\n );\n\n // Get handler from registry (throws if module not found) - do this before retry loop\n const handler = getQueryHandler(module);\n\n return withRetry(\n async () => {\n // The rate-limit + query-client acquisition runs inside the try/catch\n // so a failure during either step is wrapped with {module, subcommand}\n // attribution, matching the handler-leg semantics. Otherwise an\n // INVALID_CONFIG from `getQueryClient` (or a connection failure that\n // escapes the inner withRetry) would propagate without telling the\n // caller which query was being routed.\n try {\n await clientManager.acquireRateLimit();\n const queryClient = await clientManager.getQueryClient();\n const result = await handler(queryClient, subcommand, args);\n\n return {\n module,\n subcommand,\n result,\n };\n } catch (error) {\n if (error instanceof ManifestMCPError) {\n if (!error.details?.module) {\n throw new ManifestMCPError(error.code, error.message, {\n ...error.details,\n module,\n subcommand,\n });\n }\n throw error;\n }\n throw new ManifestMCPError(\n ManifestMCPErrorCode.QUERY_FAILED,\n `Query ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`,\n { module, subcommand },\n );\n }\n },\n {\n config: clientManager.getConfig().retry,\n operationName: `query ${module} ${subcommand}`,\n },\n );\n}\n\n/**\n * Execute a Cosmos transaction via manifestjs signing client\n *\n * Automatically retries on transient failures (network errors, timeouts, 5xx)\n * with exponential backoff. Configure retry behavior via `config.retry`.\n *\n * Note: Only network-level failures are retried. Transaction validation errors\n * (insufficient funds, invalid args, etc.) are not retried as they won't succeed.\n */\nexport async function cosmosTx(\n clientManager: CosmosClientManager,\n module: string,\n subcommand: string,\n args: string[] = [],\n waitForConfirmation: boolean = false,\n overrides?: TxOverrides,\n): Promise<CosmosTxResult> {\n validateName(module, 'module', ManifestMCPErrorCode.UNSUPPORTED_TX);\n validateName(subcommand, 'subcommand', ManifestMCPErrorCode.UNSUPPORTED_TX);\n\n // Build fully-resolved gas options from caller overrides + server config\n let txOptions: TxOptions | undefined;\n if (overrides?.gasMultiplier !== undefined) {\n if (\n !Number.isFinite(overrides.gasMultiplier) ||\n overrides.gasMultiplier < 1\n ) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n `gasMultiplier must be a finite number >= 1, got ${overrides.gasMultiplier}`,\n );\n }\n const gasPrice = clientManager.getConfig().gasPrice;\n if (!gasPrice) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n 'gasMultiplier override requires gasPrice configuration',\n );\n }\n txOptions = { gasMultiplier: overrides.gasMultiplier, gasPrice };\n }\n\n // Get handler from registry (throws if module not found) - do this before retry loop\n const handler = getTxHandler(module);\n // Fetch chain context once before the broadcast retry loop: every broadcast\n // attempt uses the same snapshot and we don't consume extra rate-limit\n // tokens per broadcast retry. The loader is independently wrapped in its\n // own withRetry so transient LCD failures during the chain read still get\n // retried (parity with cosmosQuery's params reads).\n const buildContext = await withRetry(\n () => loadBuildContext(clientManager, module, subcommand),\n {\n config: clientManager.getConfig().retry,\n operationName: `load-context ${module} ${subcommand}`,\n },\n );\n\n return withRetry(\n async () => {\n // The rate-limit + signing-client + address acquisition runs inside\n // the try/catch so a failure during any of those steps is wrapped\n // with {module, subcommand, args} attribution, matching the\n // handler-leg semantics. Otherwise an INVALID_CONFIG / wallet error\n // from these calls would propagate without telling the caller which\n // tx was being prepared.\n try {\n await clientManager.acquireRateLimit();\n const signingClient = await clientManager.getSigningClient();\n const senderAddress = await clientManager.getAddress();\n\n return await handler(\n signingClient,\n senderAddress,\n subcommand,\n args,\n waitForConfirmation,\n txOptions,\n buildContext,\n );\n } catch (error) {\n if (error instanceof ManifestMCPError) {\n // Re-throw with enriched context if not already present\n if (!error.details?.module) {\n throw new ManifestMCPError(error.code, error.message, {\n ...error.details,\n module,\n subcommand,\n args,\n });\n }\n throw error;\n }\n throw new ManifestMCPError(\n ManifestMCPErrorCode.TX_FAILED,\n `Tx ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`,\n { module, subcommand, args },\n );\n }\n },\n {\n config: clientManager.getConfig().retry,\n operationName: `tx ${module} ${subcommand}`,\n },\n );\n}\n\n/**\n * Estimate the fee for a Cosmos transaction without broadcasting it.\n *\n * Looks up the message builder for the given module, builds the messages,\n * and calls `client.simulate()` to get a gas estimate. Multiplies by the\n * configured (or overridden) gas multiplier and computes the fee.\n *\n * Automatically retries on transient failures via `withRetry`.\n *\n * @returns FeeEstimateResult with raw gas estimate and computed fee\n */\nexport async function cosmosEstimateFee(\n clientManager: CosmosClientManager,\n module: string,\n subcommand: string,\n args: string[] = [],\n overrides?: TxOverrides,\n): Promise<FeeEstimateResult> {\n validateName(module, 'module', ManifestMCPErrorCode.UNSUPPORTED_TX);\n validateName(subcommand, 'subcommand', ManifestMCPErrorCode.UNSUPPORTED_TX);\n\n // Always need gasPrice for fee calculation (unlike cosmosTx which can use 'auto')\n const config = clientManager.getConfig();\n const gasPrice = config.gasPrice;\n if (!gasPrice) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n 'Fee estimation requires gasPrice configuration',\n );\n }\n\n // Validate the override eagerly (the resolved fallback values are always valid).\n if (overrides?.gasMultiplier !== undefined) {\n if (\n !Number.isFinite(overrides.gasMultiplier) ||\n overrides.gasMultiplier < 1\n ) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n `gasMultiplier must be a finite number >= 1, got ${overrides.gasMultiplier}`,\n );\n }\n }\n\n // Get builder from registry (throws if module not found) - do this before retry loop\n const builder = getTxMsgBuilder(module);\n // Fetch chain context once before the simulate retry loop: every simulate\n // attempt uses the same snapshot and we don't consume extra rate-limit\n // tokens per simulate retry. The loader is independently wrapped in its\n // own withRetry so transient LCD failures during the chain read still get\n // retried (parity with cosmosQuery's params reads).\n const buildContext = await withRetry(\n () => loadBuildContext(clientManager, module, subcommand),\n {\n config: config.retry,\n operationName: `load-context ${module} ${subcommand}`,\n },\n );\n\n return withRetry(\n async () => {\n // The rate-limit + signing-client + address acquisition runs inside\n // the try/catch so a failure during any of those steps is wrapped\n // with {module, subcommand, args} attribution, matching the\n // handler-leg semantics. Otherwise an INVALID_CONFIG / wallet error\n // from these calls would propagate without telling the caller which\n // estimate was being computed.\n try {\n await clientManager.acquireRateLimit();\n const signingClient = await clientManager.getSigningClient();\n const senderAddress = await clientManager.getAddress();\n\n // Resolve gasMultiplier from the signing client when no override is provided.\n // This guarantees parity with cosmosTx's 'auto' path: client.ts patches the\n // signing client's defaultGasMultiplier to config.gasMultiplier; if that\n // patch fails (rare — only when CosmJS internals change), the client\n // falls back to CosmJS's built-in default. Reading from the client uses\n // the same value cosmosTx would.\n const clientMultiplier = (\n signingClient as unknown as { defaultGasMultiplier?: unknown }\n ).defaultGasMultiplier;\n const gasMultiplier =\n overrides?.gasMultiplier ??\n (typeof clientMultiplier === 'number'\n ? clientMultiplier\n : DEFAULT_GAS_MULTIPLIER);\n\n const built = builder(senderAddress, subcommand, args, buildContext);\n const gasEstimate = await signingClient.simulate(\n senderAddress,\n built.messages,\n built.memo,\n );\n const gasLimit = Math.ceil(gasEstimate * gasMultiplier);\n const fee = calculateFee(gasLimit, gasPrice);\n\n return {\n module,\n subcommand: built.canonicalSubcommand ?? subcommand,\n gasEstimate: String(gasEstimate),\n fee: { amount: fee.amount, gas: fee.gas },\n };\n } catch (error) {\n if (error instanceof ManifestMCPError) {\n // Re-throw with enriched context if not already present (mirrors cosmosTx)\n if (!error.details?.module) {\n throw new ManifestMCPError(error.code, error.message, {\n ...error.details,\n module,\n subcommand,\n args,\n });\n }\n throw error;\n }\n // SIMULATION_FAILED is NOT in NON_RETRYABLE_ERROR_CODES, so withRetry\n // will fall through to isTransientErrorMessage for message-based\n // classification. Transient errors (network/5xx) get retried; real\n // simulation failures (insufficient funds, etc) fail fast.\n throw new ManifestMCPError(\n ManifestMCPErrorCode.SIMULATION_FAILED,\n `Fee estimation for ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`,\n { module, subcommand, args },\n );\n }\n },\n {\n config: config.retry,\n operationName: `estimate ${module} ${subcommand}`,\n },\n );\n}\n"],"mappings":";;;;;;AAuBA,MAAM,qBAAqB;;;;;;;;;;;;;AAc3B,eAAe,iBACb,eACA,QACA,YACqC;CACrC,MAAM,SAAS,mBAAmB,QAAQ,WAAW;AACrD,KAAI,CAAC,OAAQ,QAAO,KAAA;AASpB,KAAI;A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AAS;KACpD,GAAG,MAAM;KACT;KACA;KACA;KACD,CAAC;AAEJ,UAAM;;AAMR,SAAM,IAAI,iBACR,qBAAqB,mBACrB,sBAAsB,OAAO,GAAG,WAAW,WAAW,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IAC5G;IAAE;IAAQ;IAAY;IAAM,CAC7B;;IAGL;EACE,QAAQ,OAAO;EACf,eAAe,YAAY,OAAO,GAAG;EACtC,CACF"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AccountInfo, AccountInfoResult, AddressBytesToStringResult, AddressStringToBytesResult, Any, AuthAccountResult, AuthAccountsResult, AuthParams, AuthParamsResult, AuthzGrant, AuthzGrantAuthorization, AuthzGranteeGrantsResult, AuthzGranterGrantsResult, AuthzGrantsResult, AvailableModules, BalanceResult, BalancesResult, BankMetadata, BankParams, BankParamsResult, BaseAccount, Bech32PrefixResult, BillingParams, BillingParamsResult, BuiltMessages, CodeInfoResponse, Coin, CommissionResult, CommunityPoolResult, ContractCodeHistoryEntry, ContractInfo, CosmosQueryResult, CosmosTxResult, CreditAccount, CreditAccountResult, CreditAccountsResult, CreditAddressResult, CreditEstimateResult, DecCoin, DelegationDelegatorReward, DelegationResponse, DelegationResult, DelegationsResult, DelegatorValidatorsResult, DelegatorWithdrawAddressResult, DenomAuthorityMetadata, DenomAuthorityMetadataResult, DenomMetadataResult, DenomTrace, DenomsFromAdminResult, DenomsFromCreatorResult, DenomsMetadataResult, DepositParams, DepositResult, DepositsResult, DistributionParams, DistributionParamsResult, FeeEstimateResult, FeegrantAllowanceResult, FeegrantAllowancesResult, FeegrantGrant, GovDeposit, GovParams, GovParamsResult, GovProposal, GovTallyResult, GovVote, GroupInfo, GroupInfoResult, GroupMember, GroupMembersResult, GroupPoliciesResult, GroupPolicyInfo, GroupPolicyInfoResult, GroupProposal, GroupProposalResult, GroupProposalsResult, GroupTallyQueryResult, GroupTallyResult, GroupVote, GroupVoteResult, GroupVotesResult, GroupsResult, HistoricalInfo, HistoricalInfoResult, IbcDenomTraceResult, IbcDenomTracesResult, IbcTransferParams, IbcTransferParamsResult, Lease, LeaseItemInput, LeaseResult, LeasesResult, ManifestMCPConfig, ManifestMCPError, ManifestMCPErrorCode, MintAnnualProvisionsResult, MintInflationResult, MintParams, MintParamsResult, Model, ModuleAccount, ModuleAccountsResult, ModuleInfo, PaginatedResult, PaginationResponse, PoAAuthorityResult, PoAConsensusPowerResult, PoAPendingValidatorsResult, PoAStakingParams, PoAValidator, ProposalResult, ProposalsResult, Provider, ProviderResult, ProviderWithdrawableResult, ProvidersResult, QueryCreditEstimateResponse, QueryResult, RateLimitConfig, RedelegationResponse, RedelegationsResult, RetryConfig, RewardsResult, SKU, SendEnabled, SendEnabledResult, SignArbitraryResult, SkuParams, SkuParamsResult, SkuResult, SkusResult, SlashesResult, StakingParams, StakingParamsResult, StakingPool, StakingPoolResult, SupplyOfResult, TallyParams, TallyResult, TokenfactoryParams, TokenfactoryParamsResult, TotalSupplyResult, TxOptions, TxOverrides, UnbondingDelegation, UnbondingDelegationResult, UnbondingDelegationsResult, Validator, ValidatorAccumulatedCommission, ValidatorOutstandingRewards, ValidatorOutstandingRewardsResult, ValidatorResult, ValidatorSlashEvent, ValidatorsResult, VoteResult, VotesResult, VotingParams, WalletProvider, WasmAllContractStateResult, WasmBuildAddressResult, WasmCodeInfo, WasmCodeInfoResult, WasmCodeResult, WasmCodesResult, WasmContractHistoryResult, WasmContractInfoResult, WasmContractsByCodeResult, WasmContractsByCreatorResult, WasmLimitsConfigResult, WasmParams, WasmParamsResult, WasmPinnedCodesResult, WasmRawContractStateResult, WasmSmartContractStateResult, WithdrawableAmountResult } from "./types.js";
1
+ import { AccountInfo, AccountInfoResult, AddressBytesToStringResult, AddressStringToBytesResult, Any, AuthAccountResult, AuthAccountsResult, AuthParams, AuthParamsResult, AuthzGrant, AuthzGrantAuthorization, AuthzGranteeGrantsResult, AuthzGranterGrantsResult, AuthzGrantsResult, AvailableModules, BalanceResult, BalancesResult, BankMetadata, BankParams, BankParamsResult, BaseAccount, Bech32PrefixResult, BillingParams, BillingParamsResult, BuiltMessages, CodeInfoResponse, Coin, CommissionResult, CommunityPoolResult, ContractCodeHistoryEntry, ContractInfo, CosmosQueryResult, CosmosTxResult, CreditAccount, CreditAccountResult, CreditAccountsResult, CreditAddressResult, CreditEstimateResult, DecCoin, DelegationDelegatorReward, DelegationResponse, DelegationResult, DelegationsResult, DelegatorValidatorsResult, DelegatorWithdrawAddressResult, DenomAuthorityMetadata, DenomAuthorityMetadataResult, DenomMetadataResult, DenomTrace, DenomsFromAdminResult, DenomsFromCreatorResult, DenomsMetadataResult, DepositParams, DepositResult, DepositsResult, DistributionParams, DistributionParamsResult, FeeEstimateResult, FeegrantAllowanceResult, FeegrantAllowancesResult, FeegrantGrant, GovDeposit, GovParams, GovParamsResult, GovProposal, GovTallyResult, GovVote, GroupInfo, GroupInfoResult, GroupMember, GroupMembersResult, GroupPoliciesResult, GroupPolicyInfo, GroupPolicyInfoResult, GroupProposal, GroupProposalResult, GroupProposalsResult, GroupTallyQueryResult, GroupTallyResult, GroupVote, GroupVoteResult, GroupVotesResult, GroupsResult, HistoricalInfo, HistoricalInfoResult, IbcDenomTraceResult, IbcDenomTracesResult, IbcTransferParams, IbcTransferParamsResult, Lease, LeaseByCustomDomainResult, LeaseItemInput, LeaseResult, LeasesResult, ManifestMCPConfig, ManifestMCPError, ManifestMCPErrorCode, MintAnnualProvisionsResult, MintInflationResult, MintParams, MintParamsResult, Model, ModuleAccount, ModuleAccountsResult, ModuleInfo, PaginatedResult, PaginationResponse, PoAAuthorityResult, PoAConsensusPowerResult, PoAPendingValidatorsResult, PoAStakingParams, PoAValidator, ProposalResult, ProposalsResult, Provider, ProviderResult, ProviderWithdrawableResult, ProvidersResult, QueryCreditEstimateResponse, QueryResult, RateLimitConfig, RedelegationResponse, RedelegationsResult, RetryConfig, RewardsResult, SKU, SendEnabled, SendEnabledResult, SignArbitraryResult, SkuParams, SkuParamsResult, SkuResult, SkusResult, SlashesResult, StakingParams, StakingParamsResult, StakingPool, StakingPoolResult, SupplyOfResult, TallyParams, TallyResult, TokenfactoryParams, TokenfactoryParamsResult, TotalSupplyResult, TxBuildContext, TxOptions, TxOverrides, UnbondingDelegation, UnbondingDelegationResult, UnbondingDelegationsResult, Validator, ValidatorAccumulatedCommission, ValidatorOutstandingRewards, ValidatorOutstandingRewardsResult, ValidatorResult, ValidatorSlashEvent, ValidatorsResult, VoteResult, VotesResult, VotingParams, WalletProvider, WasmAllContractStateResult, WasmBuildAddressResult, WasmCodeInfo, WasmCodeInfoResult, WasmCodeResult, WasmCodesResult, WasmContractHistoryResult, WasmContractInfoResult, WasmContractsByCodeResult, WasmContractsByCreatorResult, WasmLimitsConfigResult, WasmParams, WasmParamsResult, WasmPinnedCodesResult, WasmRawContractStateResult, WasmSmartContractStateResult, WithdrawableAmountResult } from "./types.js";
2
2
  import { CosmosClientManager, ManifestQueryClient } from "./client.js";
3
3
  import { DEFAULT_RETRY_CONFIG, RetryOptions, calculateBackoff, isRetryableError, withRetry } from "./retry.js";
4
4
  import { ValidationResult, createConfig, createValidatedConfig, validateConfig } from "./config.js";
@@ -12,10 +12,11 @@ import { INFRASTRUCTURE_ERROR_CODES, ManifestMCPServerOptions, MnemonicServerCon
12
12
  import { MANIFEST_TOOL_META_VERSION, ManifestToolMeta, ManifestToolMetaContainer, ManifestToolMetaVersion, manifestMeta, mutatingAnnotations, readOnlyAnnotations } from "./tool-metadata.js";
13
13
  import { FundCreditsResult, fundCredits } from "./tools/fundCredits.js";
14
14
  import { getBalance } from "./tools/getBalance.js";
15
+ import { SetItemCustomDomainOptions, SetItemCustomDomainResult, setItemCustomDomain } from "./tools/setItemCustomDomain.js";
15
16
  import { StopAppResult, stopApp } from "./tools/stopApp.js";
16
17
  import { DNS_LABEL_RE, optionalBoolean, parseArgs, requireString, requireStringEnum, requireUuid } from "./validation.js";
17
18
  import { VERSION } from "./version.js";
18
19
  import { MnemonicWalletProvider } from "./wallet/mnemonic.js";
19
20
  import { signArbitraryWithAmino } from "./wallet/sign-arbitrary.js";
20
21
  import { LeaseState, leaseStateFromJSON, leaseStateToJSON } from "@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js";
21
- export { AccountInfo, AccountInfoResult, AddressBytesToStringResult, AddressStringToBytesResult, Any, AuthAccountResult, AuthAccountsResult, AuthParams, AuthParamsResult, AuthzGrant, AuthzGrantAuthorization, AuthzGranteeGrantsResult, AuthzGranterGrantsResult, AuthzGrantsResult, AvailableModules, BalanceResult, BalancesResult, BankMetadata, BankParams, BankParamsResult, BaseAccount, Bech32PrefixResult, BillingParams, BillingParamsResult, BuiltMessages, CodeInfoResponse, Coin, CommissionResult, CommunityPoolResult, ContractCodeHistoryEntry, ContractInfo, CosmosClientManager, CosmosQueryResult, CosmosTxResult, CreditAccount, CreditAccountResult, CreditAccountsResult, CreditAddressResult, CreditEstimateResult, DEFAULT_RETRY_CONFIG, DNS_LABEL_RE, DecCoin, DelegationDelegatorReward, DelegationResponse, DelegationResult, DelegationsResult, DelegatorValidatorsResult, DelegatorWithdrawAddressResult, DenomAuthorityMetadata, DenomAuthorityMetadataResult, DenomMetadataResult, DenomTrace, DenomsFromAdminResult, DenomsFromCreatorResult, DenomsMetadataResult, DepositParams, DepositResult, DepositsResult, DistributionParams, DistributionParamsResult, FeeEstimateResult, FeegrantAllowanceResult, FeegrantAllowancesResult, FeegrantGrant, type FundCreditsResult, GovDeposit, GovParams, GovParamsResult, GovProposal, GovTallyResult, GovVote, GroupInfo, GroupInfoResult, GroupMember, GroupMembersResult, GroupPoliciesResult, GroupPolicyInfo, GroupPolicyInfoResult, GroupProposal, GroupProposalResult, GroupProposalsResult, GroupTallyQueryResult, GroupTallyResult, GroupVote, GroupVoteResult, GroupVotesResult, GroupsResult, HistoricalInfo, HistoricalInfoResult, INFRASTRUCTURE_ERROR_CODES, IbcDenomTraceResult, IbcDenomTracesResult, IbcTransferParams, IbcTransferParamsResult, Lease, LeaseItemInput, LeaseResult, LeaseState, LeasesResult, type LogLevel, MANIFEST_TOOL_META_VERSION, MAX_PAGE_LIMIT, ManifestMCPConfig, ManifestMCPError, ManifestMCPErrorCode, type ManifestMCPServerOptions, type ManifestQueryClient, type ManifestToolMeta, type ManifestToolMetaContainer, type ManifestToolMetaVersion, MintAnnualProvisionsResult, MintInflationResult, MintParams, MintParamsResult, type MnemonicServerConfig, MnemonicWalletProvider, Model, ModuleAccount, ModuleAccountsResult, ModuleInfo, PaginatedResult, PaginationResponse, PoAAuthorityResult, PoAConsensusPowerResult, PoAPendingValidatorsResult, PoAStakingParams, PoAValidator, ProposalResult, ProposalsResult, Provider, ProviderResult, ProviderWithdrawableResult, ProvidersResult, QueryCreditEstimateResponse, QueryResult, RateLimitConfig, RedelegationResponse, RedelegationsResult, RetryConfig, type RetryOptions, RewardsResult, SENSITIVE_FIELDS, SKU, SendEnabled, SendEnabledResult, SignArbitraryResult, SkuParams, SkuParamsResult, SkuResult, SkusResult, SlashesResult, StakingParams, StakingParamsResult, StakingPool, StakingPoolResult, type StopAppResult, SupplyOfResult, TallyParams, TallyResult, TokenfactoryParams, TokenfactoryParamsResult, TotalSupplyResult, TxOptions, TxOverrides, UnbondingDelegation, UnbondingDelegationResult, UnbondingDelegationsResult, VERSION, type ValidationResult, Validator, ValidatorAccumulatedCommission, ValidatorOutstandingRewards, ValidatorOutstandingRewardsResult, ValidatorResult, ValidatorSlashEvent, ValidatorsResult, VoteResult, VotesResult, VotingParams, WalletProvider, WasmAllContractStateResult, WasmBuildAddressResult, WasmCodeInfo, WasmCodeInfoResult, WasmCodeResult, WasmCodesResult, WasmContractHistoryResult, WasmContractInfoResult, WasmContractsByCodeResult, WasmContractsByCreatorResult, WasmLimitsConfigResult, WasmParams, WasmParamsResult, WasmPinnedCodesResult, WasmRawContractStateResult, WasmSmartContractStateResult, WithdrawableAmountResult, bigIntReplacer, calculateBackoff, cosmosEstimateFee, cosmosQuery, cosmosTx, createConfig, createLCDQueryClient, createMnemonicServer, createPagination, createValidatedConfig, fundCredits, getAvailableModules, getBalance, getModuleSubcommands, getSubcommandUsage, getSupportedModules, isRetryableError, isSubcommandSupported, jsonResponse, leaseStateFromJSON, leaseStateToJSON, logger, manifestMeta, mutatingAnnotations, optionalBoolean, parseArgs, parseLogLevel, readOnlyAnnotations, requireString, requireStringEnum, requireUuid, sanitizeForLogging, signArbitraryWithAmino, stopApp, structuredResponse, validateAddress, validateConfig, withErrorHandling, withRetry };
22
+ export { AccountInfo, AccountInfoResult, AddressBytesToStringResult, AddressStringToBytesResult, Any, AuthAccountResult, AuthAccountsResult, AuthParams, AuthParamsResult, AuthzGrant, AuthzGrantAuthorization, AuthzGranteeGrantsResult, AuthzGranterGrantsResult, AuthzGrantsResult, AvailableModules, BalanceResult, BalancesResult, BankMetadata, BankParams, BankParamsResult, BaseAccount, Bech32PrefixResult, BillingParams, BillingParamsResult, BuiltMessages, CodeInfoResponse, Coin, CommissionResult, CommunityPoolResult, ContractCodeHistoryEntry, ContractInfo, CosmosClientManager, CosmosQueryResult, CosmosTxResult, CreditAccount, CreditAccountResult, CreditAccountsResult, CreditAddressResult, CreditEstimateResult, DEFAULT_RETRY_CONFIG, DNS_LABEL_RE, DecCoin, DelegationDelegatorReward, DelegationResponse, DelegationResult, DelegationsResult, DelegatorValidatorsResult, DelegatorWithdrawAddressResult, DenomAuthorityMetadata, DenomAuthorityMetadataResult, DenomMetadataResult, DenomTrace, DenomsFromAdminResult, DenomsFromCreatorResult, DenomsMetadataResult, DepositParams, DepositResult, DepositsResult, DistributionParams, DistributionParamsResult, FeeEstimateResult, FeegrantAllowanceResult, FeegrantAllowancesResult, FeegrantGrant, type FundCreditsResult, GovDeposit, GovParams, GovParamsResult, GovProposal, GovTallyResult, GovVote, GroupInfo, GroupInfoResult, GroupMember, GroupMembersResult, GroupPoliciesResult, GroupPolicyInfo, GroupPolicyInfoResult, GroupProposal, GroupProposalResult, GroupProposalsResult, GroupTallyQueryResult, GroupTallyResult, GroupVote, GroupVoteResult, GroupVotesResult, GroupsResult, HistoricalInfo, HistoricalInfoResult, INFRASTRUCTURE_ERROR_CODES, IbcDenomTraceResult, IbcDenomTracesResult, IbcTransferParams, IbcTransferParamsResult, Lease, LeaseByCustomDomainResult, LeaseItemInput, LeaseResult, LeaseState, LeasesResult, type LogLevel, MANIFEST_TOOL_META_VERSION, MAX_PAGE_LIMIT, ManifestMCPConfig, ManifestMCPError, ManifestMCPErrorCode, type ManifestMCPServerOptions, type ManifestQueryClient, type ManifestToolMeta, type ManifestToolMetaContainer, type ManifestToolMetaVersion, MintAnnualProvisionsResult, MintInflationResult, MintParams, MintParamsResult, type MnemonicServerConfig, MnemonicWalletProvider, Model, ModuleAccount, ModuleAccountsResult, ModuleInfo, PaginatedResult, PaginationResponse, PoAAuthorityResult, PoAConsensusPowerResult, PoAPendingValidatorsResult, PoAStakingParams, PoAValidator, ProposalResult, ProposalsResult, Provider, ProviderResult, ProviderWithdrawableResult, ProvidersResult, QueryCreditEstimateResponse, QueryResult, RateLimitConfig, RedelegationResponse, RedelegationsResult, RetryConfig, type RetryOptions, RewardsResult, SENSITIVE_FIELDS, SKU, SendEnabled, SendEnabledResult, type SetItemCustomDomainOptions, type SetItemCustomDomainResult, SignArbitraryResult, SkuParams, SkuParamsResult, SkuResult, SkusResult, SlashesResult, StakingParams, StakingParamsResult, StakingPool, StakingPoolResult, type StopAppResult, SupplyOfResult, TallyParams, TallyResult, TokenfactoryParams, TokenfactoryParamsResult, TotalSupplyResult, TxBuildContext, TxOptions, TxOverrides, UnbondingDelegation, UnbondingDelegationResult, UnbondingDelegationsResult, VERSION, type ValidationResult, Validator, ValidatorAccumulatedCommission, ValidatorOutstandingRewards, ValidatorOutstandingRewardsResult, ValidatorResult, ValidatorSlashEvent, ValidatorsResult, VoteResult, VotesResult, VotingParams, WalletProvider, WasmAllContractStateResult, WasmBuildAddressResult, WasmCodeInfo, WasmCodeInfoResult, WasmCodeResult, WasmCodesResult, WasmContractHistoryResult, WasmContractInfoResult, WasmContractsByCodeResult, WasmContractsByCreatorResult, WasmLimitsConfigResult, WasmParams, WasmParamsResult, WasmPinnedCodesResult, WasmRawContractStateResult, WasmSmartContractStateResult, WithdrawableAmountResult, bigIntReplacer, calculateBackoff, cosmosEstimateFee, cosmosQuery, cosmosTx, createConfig, createLCDQueryClient, createMnemonicServer, createPagination, createValidatedConfig, fundCredits, getAvailableModules, getBalance, getModuleSubcommands, getSubcommandUsage, getSupportedModules, isRetryableError, isSubcommandSupported, jsonResponse, leaseStateFromJSON, leaseStateToJSON, logger, manifestMeta, mutatingAnnotations, optionalBoolean, parseArgs, parseLogLevel, readOnlyAnnotations, requireString, requireStringEnum, requireUuid, sanitizeForLogging, setItemCustomDomain, signArbitraryWithAmino, stopApp, structuredResponse, validateAddress, validateConfig, withErrorHandling, withRetry };
package/dist/index.js CHANGED
@@ -16,7 +16,8 @@ import { INFRASTRUCTURE_ERROR_CODES, SENSITIVE_FIELDS, bigIntReplacer, createMne
16
16
  import { MANIFEST_TOOL_META_VERSION, manifestMeta, mutatingAnnotations, readOnlyAnnotations } from "./tool-metadata.js";
17
17
  import { fundCredits } from "./tools/fundCredits.js";
18
18
  import { getBalance } from "./tools/getBalance.js";
19
+ import { setItemCustomDomain } from "./tools/setItemCustomDomain.js";
19
20
  import { stopApp } from "./tools/stopApp.js";
20
21
  import { VERSION } from "./version.js";
21
22
  import { LeaseState, leaseStateFromJSON, leaseStateToJSON } from "@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js";
22
- export { CosmosClientManager, DEFAULT_RETRY_CONFIG, DNS_LABEL_RE, INFRASTRUCTURE_ERROR_CODES, LeaseState, MANIFEST_TOOL_META_VERSION, MAX_PAGE_LIMIT, ManifestMCPError, ManifestMCPErrorCode, MnemonicWalletProvider, SENSITIVE_FIELDS, VERSION, bigIntReplacer, calculateBackoff, cosmosEstimateFee, cosmosQuery, cosmosTx, createConfig, createLCDQueryClient, createMnemonicServer, createPagination, createValidatedConfig, fundCredits, getAvailableModules, getBalance, getModuleSubcommands, getSubcommandUsage, getSupportedModules, isRetryableError, isSubcommandSupported, jsonResponse, leaseStateFromJSON, leaseStateToJSON, logger, manifestMeta, mutatingAnnotations, optionalBoolean, parseArgs, parseLogLevel, readOnlyAnnotations, requireString, requireStringEnum, requireUuid, sanitizeForLogging, signArbitraryWithAmino, stopApp, structuredResponse, validateAddress, validateConfig, withErrorHandling, withRetry };
23
+ export { CosmosClientManager, DEFAULT_RETRY_CONFIG, DNS_LABEL_RE, INFRASTRUCTURE_ERROR_CODES, LeaseState, MANIFEST_TOOL_META_VERSION, MAX_PAGE_LIMIT, ManifestMCPError, ManifestMCPErrorCode, MnemonicWalletProvider, SENSITIVE_FIELDS, VERSION, bigIntReplacer, calculateBackoff, cosmosEstimateFee, cosmosQuery, cosmosTx, createConfig, createLCDQueryClient, createMnemonicServer, createPagination, createValidatedConfig, fundCredits, getAvailableModules, getBalance, getModuleSubcommands, getSubcommandUsage, getSupportedModules, isRetryableError, isSubcommandSupported, jsonResponse, leaseStateFromJSON, leaseStateToJSON, logger, manifestMeta, mutatingAnnotations, optionalBoolean, parseArgs, parseLogLevel, readOnlyAnnotations, requireString, requireStringEnum, requireUuid, sanitizeForLogging, setItemCustomDomain, signArbitraryWithAmino, stopApp, structuredResponse, validateAddress, validateConfig, withErrorHandling, withRetry };
package/dist/modules.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AvailableModules, BuiltMessages, CosmosTxResult, ModuleInfo, QueryResult, TxOptions } from "./types.js";
1
+ import { AvailableModules, BuiltMessages, CosmosTxResult, ModuleInfo, QueryResult, TxBuildContext, TxOptions } from "./types.js";
2
2
  import { ManifestQueryClient } from "./client.js";
3
3
  import { SigningStargateClient } from "@cosmjs/stargate";
4
4
 
@@ -8,14 +8,23 @@ import { SigningStargateClient } from "@cosmjs/stargate";
8
8
  */
9
9
  type QueryHandler = (queryClient: ManifestQueryClient, subcommand: string, args: string[]) => Promise<QueryResult>;
10
10
  /**
11
- * Handler function type for transaction modules
11
+ * Handler function type for transaction modules.
12
+ *
13
+ * `context` carries optional read-only chain state (currently the on-chain
14
+ * billing Params) for handlers that must merge against existing values to
15
+ * preserve fields the caller did not explicitly set. Most handlers ignore it.
12
16
  */
13
- type TxHandler = (signingClient: SigningStargateClient, senderAddress: string, subcommand: string, args: string[], waitForConfirmation: boolean, options?: TxOptions) => Promise<CosmosTxResult>;
17
+ type TxHandler = (signingClient: SigningStargateClient, senderAddress: string, subcommand: string, args: string[], waitForConfirmation: boolean, options?: TxOptions, context?: TxBuildContext) => Promise<CosmosTxResult>;
14
18
  /**
15
19
  * Pure synchronous function type for building transaction messages.
16
20
  * Used by `cosmosEstimateFee` to obtain `EncodeObject[]` without signing/broadcasting.
21
+ *
22
+ * `context` carries optional chain state for builders that need it (e.g.
23
+ * billing `update-params` preserves on-chain `allowedList` /
24
+ * `reservedDomainSuffixes` when not explicitly overridden). Builders that
25
+ * don't need context simply ignore it.
17
26
  */
18
- type TxMsgBuilder = (senderAddress: string, subcommand: string, args: string[]) => BuiltMessages;
27
+ type TxMsgBuilder = (senderAddress: string, subcommand: string, args: string[], context?: TxBuildContext) => BuiltMessages;
19
28
  /**
20
29
  * Throw an error for an unsupported subcommand.
21
30
  * Automatically looks up available subcommands from the module registry.
@@ -25,6 +34,12 @@ type TxMsgBuilder = (senderAddress: string, subcommand: string, args: string[])
25
34
  * @param subcommand - The unsupported subcommand that was requested
26
35
  */
27
36
  declare function throwUnsupportedSubcommand(type: 'query' | 'tx', module: string, subcommand: string): never;
37
+ /**
38
+ * Loader that fetches the chain state a `TxBuildContext`-aware msgBuilder
39
+ * needs. Receives a `ManifestQueryClient`; the dispatcher in `cosmos.ts`
40
+ * handles rate-limit acquisition and error wrapping around the call.
41
+ */
42
+ type TxBuildContextLoader = (queryClient: ManifestQueryClient) => Promise<TxBuildContext>;
28
43
  /**
29
44
  * Get all available query and transaction modules
30
45
  */
@@ -68,6 +83,14 @@ declare function getTxHandler(module: string): TxHandler;
68
83
  * @throws ManifestMCPError if module is not found
69
84
  */
70
85
  declare function getTxMsgBuilder(module: string): TxMsgBuilder;
86
+ /**
87
+ * Look up the optional `TxBuildContext` loader for a (module, subcommand)
88
+ * pair. Returns `undefined` when the module is unknown OR when the module
89
+ * doesn't declare a loader for that subcommand — both are normal cases
90
+ * (most txs need no context). Callers are expected to short-circuit on
91
+ * `undefined` and skip the chain read.
92
+ */
93
+ declare function getTxContextLoader(module: string, subcommand: string): TxBuildContextLoader | undefined;
71
94
  //#endregion
72
- export { QueryHandler, TxHandler, TxMsgBuilder, getAvailableModules, getModuleSubcommands, getQueryHandler, getSubcommandUsage, getSupportedModules, getTxHandler, getTxMsgBuilder, isSubcommandSupported, throwUnsupportedSubcommand };
95
+ export { QueryHandler, TxBuildContextLoader, TxHandler, TxMsgBuilder, getAvailableModules, getModuleSubcommands, getQueryHandler, getSubcommandUsage, getSupportedModules, getTxContextLoader, getTxHandler, getTxMsgBuilder, isSubcommandSupported, throwUnsupportedSubcommand };
73
96
  //# sourceMappingURL=modules.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modules.d.ts","names":[],"sources":["../src/modules.ts"],"mappings":";;;;;;;AAiFA;KAAY,YAAA,IACV,WAAA,EAAa,mBAAA,EACb,UAAA,UACA,IAAA,eACG,OAAA,CAAQ,WAAA;;;;KAKD,SAAA,IACV,aAAA,EAAe,qBAAA,EACf,aAAA,UACA,UAAA,UACA,IAAA,YACA,mBAAA,WACA,OAAA,GAAU,SAAA,KACP,OAAA,CAAQ,cAAA;;;;;KAMD,YAAA,IACV,aAAA,UACA,UAAA,UACA,IAAA,eACG,aAAA;;;;;;AAjBL;;;iBA2BgB,0BAAA,CACd,IAAA,kBACA,MAAA,UACA,UAAA;;;;iBA+5Bc,mBAAA,CAAA,GAAuB,gBAAA;;;;iBAwBvB,oBAAA,CACd,IAAA,kBACA,MAAA,WACC,UAAA;;;;iBAsBa,qBAAA,CACd,IAAA,kBACA,MAAA,UACA,UAAA;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;iBAgBjC,YAAA,CAAa,MAAA,WAAiB,SAAA;;;AA/H9C;;iBA+IgB,eAAA,CAAgB,MAAA,WAAiB,YAAA;;;AAvHjD;;;;;iBA0IgB,kBAAA,CACd,MAAA,UACA,UAAA,WACC,oBAAA"}
package/dist/modules.js CHANGED
@@ -16,7 +16,7 @@ import { routeTokenfactoryQuery } from "./queries/tokenfactory.js";
16
16
  import { routeWasmQuery } from "./queries/wasm.js";
17
17
  import { buildAuthzMessages, routeAuthzTransaction } from "./transactions/authz.js";
18
18
  import { buildBankMessages, routeBankTransaction } from "./transactions/bank.js";
19
- import { buildBillingMessages, routeBillingTransaction } from "./transactions/billing.js";
19
+ import { buildBillingMessages, loadBillingUpdateParamsContext, routeBillingTransaction } from "./transactions/billing.js";
20
20
  import { buildDistributionMessages, routeDistributionTransaction } from "./transactions/distribution.js";
21
21
  import { buildFeegrantMessages, routeFeegrantTransaction } from "./transactions/feegrant.js";
22
22
  import { buildGovMessages, routeGovTransaction } from "./transactions/gov.js";
@@ -375,6 +375,11 @@ const QUERY_MODULES = {
375
375
  {
376
376
  name: "credit-estimate",
377
377
  description: "Query credit estimate for a tenant"
378
+ },
379
+ {
380
+ name: "lease-by-custom-domain",
381
+ description: "Reverse-lookup the active or pending lease that has claimed a custom_domain",
382
+ args: "<custom-domain>"
378
383
  }
379
384
  ]
380
385
  },
@@ -760,6 +765,7 @@ const TX_MODULES = {
760
765
  description: "Manifest billing transaction subcommands",
761
766
  handler: routeBillingTransaction,
762
767
  msgBuilder: buildBillingMessages,
768
+ contextLoaders: { "update-params": loadBillingUpdateParamsContext },
763
769
  subcommands: [
764
770
  {
765
771
  name: "fund-credit",
@@ -803,8 +809,13 @@ const TX_MODULES = {
803
809
  },
804
810
  {
805
811
  name: "update-params",
806
- description: "Update billing module parameters (governance)",
807
- args: "<max-leases-per-tenant> <max-items-per-lease> <min-lease-duration> <max-pending-leases-per-tenant> <pending-timeout> [<allowed-address>...]"
812
+ description: "Update billing module parameters (governance). List-typed fields (allowed_list, reserved_domain_suffixes) preserve their on-chain values when not explicitly overridden; pass --clear-allowed-list or --clear-reserved-suffixes to clear them. Mutually exclusive: positional <allowed-address> with --clear-allowed-list, and --reserved-suffix with --clear-reserved-suffixes.",
813
+ args: "<max-leases-per-tenant> <max-items-per-lease> <min-lease-duration> <max-pending-leases-per-tenant> <pending-timeout> [<allowed-address>...] [--clear-allowed-list] [--reserved-suffix <.example.com>...] [--clear-reserved-suffixes]"
814
+ },
815
+ {
816
+ name: "set-item-custom-domain",
817
+ description: "Set or clear the custom_domain on a lease item (signer must be tenant, authority, or in params.allowed_list). <custom-domain> must be non-empty when not using --clear; --service-name (when supplied) must be a valid RFC 1123 DNS label. <custom-domain> and --clear are mutually exclusive.",
818
+ args: "<lease-uuid> <custom-domain> [--service-name <name>] OR <lease-uuid> --clear [--service-name <name>]"
808
819
  }
809
820
  ]
810
821
  },
@@ -1145,7 +1156,17 @@ function getTxMsgBuilder(module) {
1145
1156
  if (!moduleInfo) throw new ManifestMCPError(ManifestMCPErrorCode.UNKNOWN_MODULE, `Unknown tx module: ${module}`, { availableModules: Object.keys(TX_MODULES) });
1146
1157
  return moduleInfo.msgBuilder;
1147
1158
  }
1159
+ /**
1160
+ * Look up the optional `TxBuildContext` loader for a (module, subcommand)
1161
+ * pair. Returns `undefined` when the module is unknown OR when the module
1162
+ * doesn't declare a loader for that subcommand — both are normal cases
1163
+ * (most txs need no context). Callers are expected to short-circuit on
1164
+ * `undefined` and skip the chain read.
1165
+ */
1166
+ function getTxContextLoader(module, subcommand) {
1167
+ return TX_MODULES[module]?.contextLoaders?.[subcommand];
1168
+ }
1148
1169
  //#endregion
1149
- export { getAvailableModules, getModuleSubcommands, getQueryHandler, getSubcommandUsage, getSupportedModules, getTxHandler, getTxMsgBuilder, isSubcommandSupported, throwUnsupportedSubcommand };
1170
+ export { getAvailableModules, getModuleSubcommands, getQueryHandler, getSubcommandUsage, getSupportedModules, getTxContextLoader, getTxHandler, getTxMsgBuilder, isSubcommandSupported, throwUnsupportedSubcommand };
1150
1171
 
1151
1172
  //# sourceMappingURL=modules.js.map