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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +6 -2
  2. package/dist/__test-utils__/mocks.d.ts +8 -7
  3. package/dist/__test-utils__/mocks.d.ts.map +1 -1
  4. package/dist/__test-utils__/mocks.js +1 -1
  5. package/dist/config.d.ts +11 -1
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js +1 -1
  8. package/dist/config.js.map +1 -1
  9. package/dist/cosmos.d.ts.map +1 -1
  10. package/dist/cosmos.js +64 -16
  11. package/dist/cosmos.js.map +1 -1
  12. package/dist/index.d.ts +4 -3
  13. package/dist/index.js +3 -2
  14. package/dist/modules.d.ts +28 -5
  15. package/dist/modules.d.ts.map +1 -1
  16. package/dist/modules.js +25 -4
  17. package/dist/modules.js.map +1 -1
  18. package/dist/queries/billing.d.ts +2 -2
  19. package/dist/queries/billing.d.ts.map +1 -1
  20. package/dist/queries/billing.js +12 -0
  21. package/dist/queries/billing.js.map +1 -1
  22. package/dist/server-utils.d.ts +4 -2
  23. package/dist/server-utils.d.ts.map +1 -1
  24. package/dist/server-utils.js +9 -5
  25. package/dist/server-utils.js.map +1 -1
  26. package/dist/tools/setItemCustomDomain.d.ts +51 -0
  27. package/dist/tools/setItemCustomDomain.d.ts.map +1 -0
  28. package/dist/tools/setItemCustomDomain.js +45 -0
  29. package/dist/tools/setItemCustomDomain.js.map +1 -0
  30. package/dist/transactions/billing.d.ts +26 -4
  31. package/dist/transactions/billing.d.ts.map +1 -1
  32. package/dist/transactions/billing.js +78 -9
  33. package/dist/transactions/billing.js.map +1 -1
  34. package/dist/transactions/utils.d.ts +22 -1
  35. package/dist/transactions/utils.d.ts.map +1 -1
  36. package/dist/transactions/utils.js +28 -1
  37. package/dist/transactions/utils.js.map +1 -1
  38. package/dist/types.d.ts +23 -2
  39. package/dist/types.d.ts.map +1 -1
  40. package/dist/types.js.map +1 -1
  41. package/dist/version.d.ts +1 -1
  42. package/dist/version.js +1 -1
  43. package/dist/version.js.map +1 -1
  44. package/package.json +10 -2
  45. package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +0 -78
  46. package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js.map +0 -1
  47. package/dist/node_modules/@vitest/expect/dist/index.d.ts +0 -802
  48. package/dist/node_modules/@vitest/expect/dist/index.d.ts.map +0 -1
  49. package/dist/node_modules/@vitest/expect/dist/index.js +0 -1457
  50. package/dist/node_modules/@vitest/expect/dist/index.js.map +0 -1
  51. package/dist/node_modules/@vitest/pretty-format/dist/index.d.ts +0 -95
  52. package/dist/node_modules/@vitest/pretty-format/dist/index.d.ts.map +0 -1
  53. package/dist/node_modules/@vitest/pretty-format/dist/index.js +0 -877
  54. package/dist/node_modules/@vitest/pretty-format/dist/index.js.map +0 -1
  55. package/dist/node_modules/@vitest/runner/dist/chunk-tasks.js +0 -91
  56. package/dist/node_modules/@vitest/runner/dist/chunk-tasks.js.map +0 -1
  57. package/dist/node_modules/@vitest/runner/dist/index.js +0 -1381
  58. package/dist/node_modules/@vitest/runner/dist/index.js.map +0 -1
  59. package/dist/node_modules/@vitest/runner/dist/tasks.d-D2GKpdwQ.d.ts +0 -540
  60. package/dist/node_modules/@vitest/runner/dist/tasks.d-D2GKpdwQ.d.ts.map +0 -1
  61. package/dist/node_modules/@vitest/runner/dist/utils.js +0 -1
  62. package/dist/node_modules/@vitest/snapshot/dist/environment.d-DOJxxZV9.d.ts +0 -16
  63. package/dist/node_modules/@vitest/snapshot/dist/environment.d-DOJxxZV9.d.ts.map +0 -1
  64. package/dist/node_modules/@vitest/snapshot/dist/index.d.ts +0 -89
  65. package/dist/node_modules/@vitest/snapshot/dist/index.d.ts.map +0 -1
  66. package/dist/node_modules/@vitest/snapshot/dist/index.js +0 -649
  67. package/dist/node_modules/@vitest/snapshot/dist/index.js.map +0 -1
  68. package/dist/node_modules/@vitest/snapshot/dist/rawSnapshot.d-U2kJUxDr.d.ts +0 -40
  69. package/dist/node_modules/@vitest/snapshot/dist/rawSnapshot.d-U2kJUxDr.d.ts.map +0 -1
  70. package/dist/node_modules/@vitest/spy/dist/index.d.ts +0 -343
  71. package/dist/node_modules/@vitest/spy/dist/index.d.ts.map +0 -1
  72. package/dist/node_modules/@vitest/spy/dist/index.js +0 -386
  73. package/dist/node_modules/@vitest/spy/dist/index.js.map +0 -1
  74. package/dist/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js +0 -82
  75. package/dist/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js.map +0 -1
  76. package/dist/node_modules/@vitest/utils/dist/diff.d.ts +0 -14
  77. package/dist/node_modules/@vitest/utils/dist/diff.d.ts.map +0 -1
  78. package/dist/node_modules/@vitest/utils/dist/diff.js +0 -1297
  79. package/dist/node_modules/@vitest/utils/dist/diff.js.map +0 -1
  80. package/dist/node_modules/@vitest/utils/dist/display.d.ts +0 -15
  81. package/dist/node_modules/@vitest/utils/dist/display.d.ts.map +0 -1
  82. package/dist/node_modules/@vitest/utils/dist/display.js +0 -558
  83. package/dist/node_modules/@vitest/utils/dist/display.js.map +0 -1
  84. package/dist/node_modules/@vitest/utils/dist/error.js +0 -30
  85. package/dist/node_modules/@vitest/utils/dist/error.js.map +0 -1
  86. package/dist/node_modules/@vitest/utils/dist/helpers.js +0 -181
  87. package/dist/node_modules/@vitest/utils/dist/helpers.js.map +0 -1
  88. package/dist/node_modules/@vitest/utils/dist/offset.js +0 -27
  89. package/dist/node_modules/@vitest/utils/dist/offset.js.map +0 -1
  90. package/dist/node_modules/@vitest/utils/dist/serialize.js +0 -77
  91. package/dist/node_modules/@vitest/utils/dist/serialize.js.map +0 -1
  92. package/dist/node_modules/@vitest/utils/dist/source-map.js +0 -367
  93. package/dist/node_modules/@vitest/utils/dist/source-map.js.map +0 -1
  94. package/dist/node_modules/@vitest/utils/dist/timers.js +0 -37
  95. package/dist/node_modules/@vitest/utils/dist/timers.js.map +0 -1
  96. package/dist/node_modules/@vitest/utils/dist/types.d-BCElaP-c.d.ts +0 -38
  97. package/dist/node_modules/@vitest/utils/dist/types.d-BCElaP-c.d.ts.map +0 -1
  98. package/dist/node_modules/@vitest/utils/dist/types.d.ts +0 -25
  99. package/dist/node_modules/@vitest/utils/dist/types.d.ts.map +0 -1
  100. package/dist/node_modules/chai/index.js +0 -2875
  101. package/dist/node_modules/chai/index.js.map +0 -1
  102. package/dist/node_modules/magic-string/dist/magic-string.es.js +0 -939
  103. package/dist/node_modules/magic-string/dist/magic-string.es.js.map +0 -1
  104. package/dist/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +0 -85
  105. package/dist/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js.map +0 -1
  106. package/dist/node_modules/tinybench/dist/index.d.ts +0 -91
  107. package/dist/node_modules/tinybench/dist/index.d.ts.map +0 -1
  108. package/dist/node_modules/tinyrainbow/dist/index.d.ts +0 -9
  109. package/dist/node_modules/tinyrainbow/dist/index.d.ts.map +0 -1
  110. package/dist/node_modules/tinyrainbow/dist/index.js +0 -86
  111. package/dist/node_modules/tinyrainbow/dist/index.js.map +0 -1
  112. package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -6
  113. package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js.map +0 -1
  114. package/dist/node_modules/vitest/dist/chunks/benchmark.D0SlKNbZ.js +0 -41
  115. package/dist/node_modules/vitest/dist/chunks/benchmark.D0SlKNbZ.js.map +0 -1
  116. package/dist/node_modules/vitest/dist/chunks/benchmark.d.DAaHLpsq.d.ts +0 -12
  117. package/dist/node_modules/vitest/dist/chunks/benchmark.d.DAaHLpsq.d.ts.map +0 -1
  118. package/dist/node_modules/vitest/dist/chunks/global.d.x-ILCfAE.d.ts +0 -100
  119. package/dist/node_modules/vitest/dist/chunks/global.d.x-ILCfAE.d.ts.map +0 -1
  120. package/dist/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js +0 -57
  121. package/dist/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js.map +0 -1
  122. package/dist/node_modules/vitest/dist/chunks/rpc.d.BFMWpdph.d.ts +0 -13
  123. package/dist/node_modules/vitest/dist/chunks/rpc.d.BFMWpdph.d.ts.map +0 -1
  124. package/dist/node_modules/vitest/dist/chunks/test.CTcmp4Su.js +0 -2791
  125. package/dist/node_modules/vitest/dist/chunks/test.CTcmp4Su.js.map +0 -1
  126. package/dist/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js +0 -44
  127. package/dist/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js.map +0 -1
  128. package/dist/node_modules/vitest/dist/index.d.ts +0 -9
package/README.md CHANGED
@@ -14,8 +14,9 @@ npm install @manifest-network/manifest-mcp-core
14
14
  - **LCD adapter** (`lcd-adapter.ts`) -- Converts LCD/REST responses to the RPC query client shape, making the codebase transport-agnostic
15
15
  - **Module registry** (`modules.ts`) -- Static maps of Cosmos SDK modules with metadata and handler functions
16
16
  - **Query/transaction routing** (`cosmos.ts`) -- Routes `(module, subcommand, args)` to per-module handlers
17
- - **On-chain tool functions** (`tools/`) -- `getBalance`, `fundCredits`, `stopApp` (used by the lease package)
18
- - **Server utilities** (`server-utils.ts`) -- `withErrorHandling`, `jsonResponse`, `bigIntReplacer`, `sanitizeForLogging`
17
+ - **On-chain tool functions** (`tools/`) -- `getBalance`, `fundCredits`, `setItemCustomDomain`, `stopApp` (used by lease and fred packages)
18
+ - **Server utilities** (`server-utils.ts`) -- `withErrorHandling`, `jsonResponse`, `structuredResponse`, `bigIntReplacer`, `sanitizeForLogging`
19
+ - **Tool annotation helpers** (`tool-metadata.ts`) -- `readOnlyAnnotations`, `mutatingAnnotations`, `manifestMeta` (versioned `_meta.manifest` payload, `MANIFEST_TOOL_META_VERSION = 1`)
19
20
  - **Wallet providers** (`wallet/`) -- `MnemonicWalletProvider` (BIP-39), `signArbitraryWithAmino` (ADR-036)
20
21
  - **Logger** (`logger.ts`) -- Leveled logger (stderr output; defaults to `warn`, configurable via `logger.setLevel()`; the node package's bootstrap reads `LOG_LEVEL` and applies it)
21
22
  - **Retry** (`retry.ts`) -- Exponential backoff with transient/permanent error classification
@@ -36,7 +37,10 @@ npm install @manifest-network/manifest-mcp-core
36
37
  | poa | yes | yes |
37
38
  | tokenfactory | yes | yes |
38
39
  | ibc-transfer | yes | yes |
40
+ | authz | yes | yes |
41
+ | feegrant | yes | yes |
39
42
  | auth | yes | -- |
43
+ | mint | yes | -- |
40
44
  | manifest | -- | yes |
41
45
 
42
46
  ## Usage
@@ -1,7 +1,8 @@
1
- import { Mock, Procedure } from "../node_modules/@vitest/spy/dist/index.js";
2
1
  import { ManifestMCPConfig, WalletProvider } from "../types.js";
3
2
  import { ManifestQueryClient } from "../client.js";
4
3
  import { LeaseState } from "@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js";
4
+ import * as vitest from "vitest";
5
+ import * as _vitest_spy0 from "@vitest/spy";
5
6
 
6
7
  //#region src/__test-utils__/mocks.d.ts
7
8
  /**
@@ -121,12 +122,12 @@ declare function makeMockClientManager(overrides?: {
121
122
  address?: string;
122
123
  config?: ManifestMCPConfig;
123
124
  }): {
124
- getQueryClient: Mock<Procedure>;
125
- getSigningClient: Mock<Procedure>;
126
- getAddress: Mock<Procedure>;
127
- getConfig: Mock<Procedure>;
128
- acquireRateLimit: Mock<Procedure>;
129
- disconnect: Mock<Procedure>;
125
+ getQueryClient: vitest.Mock<_vitest_spy0.Procedure>;
126
+ getSigningClient: vitest.Mock<_vitest_spy0.Procedure>;
127
+ getAddress: vitest.Mock<_vitest_spy0.Procedure>;
128
+ getConfig: vitest.Mock<_vitest_spy0.Procedure>;
129
+ acquireRateLimit: vitest.Mock<_vitest_spy0.Procedure>;
130
+ disconnect: vitest.Mock<_vitest_spy0.Procedure>;
130
131
  };
131
132
  //#endregion
132
133
  export { makeMockClientManager, makeMockConfig, makeMockQ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AsB,SAAA,GAAY,IAAA;EAAA;EACnE,aAAA;IAAkB,IAAA;IAAc,YAAA;IAAsB,SAAA,GAAY,IAAA;EAAA;AAAA;AAAA,UAG1D,YAAA;EACR,SAAA;IACE,IAAA;IACA,OAAA;IACA,MAAA;IACA,MAAA;EAAA;EAEF,IAAA;IACE,IAAA;IACA,IAAA;IACA,YAAA;IACA,SAAA;MAAc,MAAA;MAAgB,KAAA;IAAA;EAAA;EAEhC,cAAA,GAAiB,MAAA;IAAiB,QAAA;MAAY,MAAA;IAAA;EAAA;AAAA;;;;iBAMhC,mBAAA,CAAoB,SAAA;EAClC,OAAA,GAAU,gBAAA;EACV,GAAA,GAAM,YAAA;AAAA,IA4KU,mBAAA;;;;iBAMF,qBAAA,CAAsB,SAAA;EACpC,WAAA,GAAc,mBAAA;EACd,OAAA;EACA,MAAA,GAAS,iBAAA;AAAA;8BAAiB,YAAA,CAAA,SAAA"}
@@ -1,5 +1,5 @@
1
- import { vi } from "../node_modules/vitest/dist/chunks/test.CTcmp4Su.js";
2
1
  import { LeaseState } from "@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js";
2
+ import { vi } from "vitest";
3
3
  //#region src/__test-utils__/mocks.ts
4
4
  /**
5
5
  * Create a mock ManifestMCPConfig with sensible defaults.
package/dist/config.d.ts CHANGED
@@ -12,6 +12,16 @@ declare const DEFAULT_REQUESTS_PER_SECOND = 10;
12
12
  * the --gas-adjustment value used in this project's E2E scripts (e2e/scripts/init_billing.sh).
13
13
  */
14
14
  declare const DEFAULT_GAS_MULTIPLIER = 1.5;
15
+ /**
16
+ * Validate URL format and check if it uses HTTPS or is localhost (HTTP allowed for local dev)
17
+ * Returns validation result with error reason if invalid
18
+ */
19
+ declare function validateEndpointUrl(url: string, label: string): {
20
+ valid: true;
21
+ } | {
22
+ valid: false;
23
+ reason: string;
24
+ };
15
25
  /**
16
26
  * Create a configuration object with defaults applied
17
27
  */
@@ -32,5 +42,5 @@ declare function validateConfig(config: Partial<ManifestMCPConfig>): ValidationR
32
42
  */
33
43
  declare function createValidatedConfig(input: ManifestMCPConfig): ManifestMCPConfig;
34
44
  //#endregion
35
- export { DEFAULT_GAS_MULTIPLIER, DEFAULT_REQUESTS_PER_SECOND, DEFAULT_RETRY_CONFIG, ValidationResult, createConfig, createValidatedConfig, validateConfig };
45
+ export { DEFAULT_GAS_MULTIPLIER, DEFAULT_REQUESTS_PER_SECOND, DEFAULT_RETRY_CONFIG, ValidationResult, createConfig, createValidatedConfig, validateConfig, validateEndpointUrl };
36
46
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;;AAeA;cAAa,2BAAA;;;;AAOb;;cAAa,sBAAA;;AA8Eb;;iBAAgB,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAoB,iBAAA;;;;UAuBvC,gBAAA;EACf,KAAA;EACA,MAAA;AAAA;;;;iBAMc,cAAA,CACd,MAAA,EAAQ,OAAA,CAAQ,iBAAA,IACf,gBAAA;AAFH;;;AAAA,iBAsIgB,qBAAA,CACd,KAAA,EAAO,iBAAA,GACN,iBAAA"}
1
+ {"version":3,"file":"config.d.ts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;;AAeA;cAAa,2BAAA;;;;AAOb;;cAAa,sBAAA;;AAsBb;;;iBAAgB,mBAAA,CACd,GAAA,UACA,KAAA;EACG,KAAA;AAAA;EAAkB,KAAA;EAAc,MAAA;AAAA;;;AAqDrC;iBAAgB,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAoB,iBAAA;;;;UAuBvC,gBAAA;EACf,KAAA;EACA,MAAA;AAAA;AAFF;;;AAAA,iBAQgB,cAAA,CACd,MAAA,EAAQ,OAAA,CAAQ,iBAAA,IACf,gBAAA;;AAFH;;iBAsIgB,qBAAA,CACd,KAAA,EAAO,iBAAA,GACN,iBAAA"}
package/dist/config.js CHANGED
@@ -135,6 +135,6 @@ function createValidatedConfig(input) {
135
135
  return createConfig(input);
136
136
  }
137
137
  //#endregion
138
- export { DEFAULT_GAS_MULTIPLIER, DEFAULT_REQUESTS_PER_SECOND, DEFAULT_RETRY_CONFIG, createConfig, createValidatedConfig, validateConfig };
138
+ export { DEFAULT_GAS_MULTIPLIER, DEFAULT_REQUESTS_PER_SECOND, DEFAULT_RETRY_CONFIG, createConfig, createValidatedConfig, validateConfig, validateEndpointUrl };
139
139
 
140
140
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["import { DEFAULT_RETRY_CONFIG } from './retry.js';\nimport {\n type ManifestMCPConfig,\n ManifestMCPError,\n ManifestMCPErrorCode,\n} from './types.js';\n\n/**\n * Default address prefix for Manifest Network\n */\nconst DEFAULT_ADDRESS_PREFIX = 'manifest';\n\n/**\n * Default requests per second for rate limiting\n */\nexport const DEFAULT_REQUESTS_PER_SECOND = 10;\n\n/**\n * Default gas simulation multiplier. CosmJS defaults to 1.4 but billing module\n * transactions (close-lease in particular) can exceed that. 1.5 matches\n * the --gas-adjustment value used in this project's E2E scripts (e2e/scripts/init_billing.sh).\n */\nexport const DEFAULT_GAS_MULTIPLIER = 1.5;\n\n// Re-export for consumers\nexport { DEFAULT_RETRY_CONFIG };\n\n/**\n * Check if a hostname is localhost (IPv4, IPv6, or hostname)\n * Handles both bracketed and unbracketed IPv6 formats\n */\nfunction isLocalhostHostname(hostname: string): boolean {\n if (hostname === 'localhost' || hostname === '127.0.0.1') {\n return true;\n }\n // Handle IPv6 localhost - hostname may be '::1' or '[::1]' depending on environment\n const normalizedHostname = hostname.replace(/^\\[|\\]$/g, '');\n return normalizedHostname === '::1';\n}\n\n/**\n * Validate URL format and check if it uses HTTPS or is localhost (HTTP allowed for local dev)\n * Returns validation result with error reason if invalid\n */\nfunction validateEndpointUrl(\n url: string,\n label: string,\n): { valid: true } | { valid: false; reason: string } {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return { valid: false, reason: `${label} must be a valid URL` };\n }\n\n if (parsed.protocol === 'https:') {\n return { valid: true };\n }\n\n if (parsed.protocol === 'http:' && isLocalhostHostname(parsed.hostname)) {\n return { valid: true }; // HTTP allowed for localhost\n }\n\n return {\n valid: false,\n reason: `${label} must use HTTPS (got ${parsed.protocol}//). HTTP is only allowed for local development (localhost, 127.0.0.1, ::1).`,\n };\n}\n\n/**\n * Validate gas price format (e.g., \"1.0umfx\")\n */\nfunction isValidGasPrice(gasPrice: string): boolean {\n // Gas price should be a number followed by a denomination.\n // Denoms can be simple (umfx), IBC (ibc/ABC123...), or factory\n // (factory/manifest1.../utoken). Denoms are made of non-empty segments\n // separated by '/', with the first segment starting with a letter.\n // Each segment may contain letters, digits, dots, colons, underscores,\n // and hyphens. Denom length must be 3-128 chars per the Cosmos SDK spec.\n const match = gasPrice.match(\n /^(\\d+(?:\\.\\d+)?)([a-zA-Z][a-zA-Z0-9.:_-]*(?:\\/[a-zA-Z0-9.:_-]+)*)$/,\n );\n if (!match) {\n return false;\n }\n const denom = match[2];\n return denom.length >= 3 && denom.length <= 128;\n}\n\n/**\n * Validate chain ID format\n */\nfunction isValidChainId(chainId: string): boolean {\n // Chain ID should be alphanumeric with hyphens\n return /^[a-zA-Z0-9][\\w-]*$/.test(chainId);\n}\n\n/**\n * Create a configuration object with defaults applied\n */\nexport function createConfig(input: ManifestMCPConfig): ManifestMCPConfig {\n return {\n chainId: input.chainId,\n rpcUrl: input.rpcUrl,\n gasPrice: input.gasPrice,\n restUrl: input.restUrl,\n addressPrefix: input.addressPrefix ?? DEFAULT_ADDRESS_PREFIX,\n rateLimit: {\n requestsPerSecond:\n input.rateLimit?.requestsPerSecond ?? DEFAULT_REQUESTS_PER_SECOND,\n },\n retry: {\n maxRetries: input.retry?.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries,\n baseDelayMs: input.retry?.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs,\n maxDelayMs: input.retry?.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs,\n },\n gasMultiplier: input.gasMultiplier ?? DEFAULT_GAS_MULTIPLIER,\n };\n}\n\n/**\n * Validation result\n */\nexport interface ValidationResult {\n valid: boolean;\n errors: string[];\n}\n\n/**\n * Validate a configuration object\n */\nexport function validateConfig(\n config: Partial<ManifestMCPConfig>,\n): ValidationResult {\n const errors: string[] = [];\n\n // Required fields\n if (!config.chainId) {\n errors.push('chainId is required');\n } else if (!isValidChainId(config.chainId)) {\n errors.push(\n 'chainId must be alphanumeric with hyphens (e.g., \"manifest-ledger-testnet\")',\n );\n }\n\n // At least one of rpcUrl or restUrl must be provided\n if (!config.rpcUrl && !config.restUrl) {\n errors.push('At least one of rpcUrl or restUrl is required');\n }\n\n if (config.rpcUrl) {\n const urlCheck = validateEndpointUrl(config.rpcUrl, 'rpcUrl');\n if (!urlCheck.valid) {\n errors.push(urlCheck.reason);\n }\n }\n\n if (config.restUrl) {\n const urlCheck = validateEndpointUrl(config.restUrl, 'restUrl');\n if (!urlCheck.valid) {\n errors.push(urlCheck.reason);\n }\n }\n\n // gasPrice required when rpcUrl is provided (needed for signing)\n if (config.rpcUrl && !config.gasPrice) {\n errors.push('gasPrice is required when rpcUrl is provided');\n } else if (config.gasPrice && !isValidGasPrice(config.gasPrice)) {\n errors.push(\n 'gasPrice must be a number followed by denomination (e.g., \"1.0umfx\", \"0.5factory/addr/udenom\", or \"0.25ibc/ABC123\")',\n );\n }\n\n // Optional fields\n if (config.addressPrefix !== undefined) {\n if (!/^[a-z]+$/.test(config.addressPrefix)) {\n errors.push('addressPrefix must be lowercase letters only');\n }\n }\n\n if (config.rateLimit !== undefined) {\n if (\n typeof config.rateLimit !== 'object' ||\n config.rateLimit === null ||\n Array.isArray(config.rateLimit)\n ) {\n errors.push('rateLimit must be a plain object');\n } else if (config.rateLimit.requestsPerSecond !== undefined) {\n if (\n typeof config.rateLimit.requestsPerSecond !== 'number' ||\n config.rateLimit.requestsPerSecond <= 0 ||\n !Number.isInteger(config.rateLimit.requestsPerSecond)\n ) {\n errors.push('rateLimit.requestsPerSecond must be a positive integer');\n }\n }\n }\n\n if (config.retry !== undefined) {\n if (\n typeof config.retry !== 'object' ||\n config.retry === null ||\n Array.isArray(config.retry)\n ) {\n errors.push('retry must be a plain object');\n } else {\n if (config.retry.maxRetries !== undefined) {\n if (\n typeof config.retry.maxRetries !== 'number' ||\n config.retry.maxRetries < 0 ||\n !Number.isInteger(config.retry.maxRetries)\n ) {\n errors.push('retry.maxRetries must be a non-negative integer');\n }\n }\n if (config.retry.baseDelayMs !== undefined) {\n if (\n typeof config.retry.baseDelayMs !== 'number' ||\n config.retry.baseDelayMs <= 0 ||\n !Number.isInteger(config.retry.baseDelayMs)\n ) {\n errors.push('retry.baseDelayMs must be a positive integer');\n }\n }\n if (config.retry.maxDelayMs !== undefined) {\n if (\n typeof config.retry.maxDelayMs !== 'number' ||\n config.retry.maxDelayMs <= 0 ||\n !Number.isInteger(config.retry.maxDelayMs)\n ) {\n errors.push('retry.maxDelayMs must be a positive integer');\n }\n }\n // Validate maxDelayMs >= baseDelayMs if both are provided\n if (\n config.retry.baseDelayMs !== undefined &&\n config.retry.maxDelayMs !== undefined &&\n config.retry.maxDelayMs < config.retry.baseDelayMs\n ) {\n errors.push(\n 'retry.maxDelayMs must be greater than or equal to retry.baseDelayMs',\n );\n }\n }\n }\n\n if (config.gasMultiplier !== undefined) {\n if (\n typeof config.gasMultiplier !== 'number' ||\n !Number.isFinite(config.gasMultiplier) ||\n config.gasMultiplier < 1\n ) {\n errors.push('gasMultiplier must be a finite number >= 1');\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n };\n}\n\n/**\n * Create and validate a configuration, throwing on invalid config\n */\nexport function createValidatedConfig(\n input: ManifestMCPConfig,\n): ManifestMCPConfig {\n const validation = validateConfig(input);\n\n if (!validation.valid) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n `Invalid configuration: ${validation.errors.join(', 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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"}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["import { DEFAULT_RETRY_CONFIG } from './retry.js';\nimport {\n type ManifestMCPConfig,\n ManifestMCPError,\n ManifestMCPErrorCode,\n} from './types.js';\n\n/**\n * Default address prefix for Manifest Network\n */\nconst DEFAULT_ADDRESS_PREFIX = 'manifest';\n\n/**\n * Default requests per second for rate limiting\n */\nexport const DEFAULT_REQUESTS_PER_SECOND = 10;\n\n/**\n * Default gas simulation multiplier. CosmJS defaults to 1.4 but billing module\n * transactions (close-lease in particular) can exceed that. 1.5 matches\n * the --gas-adjustment value used in this project's E2E scripts (e2e/scripts/init_billing.sh).\n */\nexport const DEFAULT_GAS_MULTIPLIER = 1.5;\n\n// Re-export for consumers\nexport { DEFAULT_RETRY_CONFIG };\n\n/**\n * Check if a hostname is localhost (IPv4, IPv6, or hostname)\n * Handles both bracketed and unbracketed IPv6 formats\n */\nfunction isLocalhostHostname(hostname: string): boolean {\n if (hostname === 'localhost' || hostname === '127.0.0.1') {\n return true;\n }\n // Handle IPv6 localhost - hostname may be '::1' or '[::1]' depending on environment\n const normalizedHostname = hostname.replace(/^\\[|\\]$/g, '');\n return normalizedHostname === '::1';\n}\n\n/**\n * Validate URL format and check if it uses HTTPS or is localhost (HTTP allowed for local dev)\n * Returns validation result with error reason if invalid\n */\nexport function validateEndpointUrl(\n url: string,\n label: string,\n): { valid: true } | { valid: false; reason: string } {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return { valid: false, reason: `${label} must be a valid URL` };\n }\n\n if (parsed.protocol === 'https:') {\n return { valid: true };\n }\n\n if (parsed.protocol === 'http:' && isLocalhostHostname(parsed.hostname)) {\n return { valid: true }; // HTTP allowed for localhost\n }\n\n return {\n valid: false,\n reason: `${label} must use HTTPS (got ${parsed.protocol}//). HTTP is only allowed for local development (localhost, 127.0.0.1, ::1).`,\n };\n}\n\n/**\n * Validate gas price format (e.g., \"1.0umfx\")\n */\nfunction isValidGasPrice(gasPrice: string): boolean {\n // Gas price should be a number followed by a denomination.\n // Denoms can be simple (umfx), IBC (ibc/ABC123...), or factory\n // (factory/manifest1.../utoken). Denoms are made of non-empty segments\n // separated by '/', with the first segment starting with a letter.\n // Each segment may contain letters, digits, dots, colons, underscores,\n // and hyphens. Denom length must be 3-128 chars per the Cosmos SDK spec.\n const match = gasPrice.match(\n /^(\\d+(?:\\.\\d+)?)([a-zA-Z][a-zA-Z0-9.:_-]*(?:\\/[a-zA-Z0-9.:_-]+)*)$/,\n );\n if (!match) {\n return false;\n }\n const denom = match[2];\n return denom.length >= 3 && denom.length <= 128;\n}\n\n/**\n * Validate chain ID format\n */\nfunction isValidChainId(chainId: string): boolean {\n // Chain ID should be alphanumeric with hyphens\n return /^[a-zA-Z0-9][\\w-]*$/.test(chainId);\n}\n\n/**\n * Create a configuration object with defaults applied\n */\nexport function createConfig(input: ManifestMCPConfig): ManifestMCPConfig {\n return {\n chainId: input.chainId,\n rpcUrl: input.rpcUrl,\n gasPrice: input.gasPrice,\n restUrl: input.restUrl,\n addressPrefix: input.addressPrefix ?? DEFAULT_ADDRESS_PREFIX,\n rateLimit: {\n requestsPerSecond:\n input.rateLimit?.requestsPerSecond ?? DEFAULT_REQUESTS_PER_SECOND,\n },\n retry: {\n maxRetries: input.retry?.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries,\n baseDelayMs: input.retry?.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs,\n maxDelayMs: input.retry?.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs,\n },\n gasMultiplier: input.gasMultiplier ?? DEFAULT_GAS_MULTIPLIER,\n };\n}\n\n/**\n * Validation result\n */\nexport interface ValidationResult {\n valid: boolean;\n errors: string[];\n}\n\n/**\n * Validate a configuration object\n */\nexport function validateConfig(\n config: Partial<ManifestMCPConfig>,\n): ValidationResult {\n const errors: string[] = [];\n\n // Required fields\n if (!config.chainId) {\n errors.push('chainId is required');\n } else if (!isValidChainId(config.chainId)) {\n errors.push(\n 'chainId must be alphanumeric with hyphens (e.g., \"manifest-ledger-testnet\")',\n );\n }\n\n // At least one of rpcUrl or restUrl must be provided\n if (!config.rpcUrl && !config.restUrl) {\n errors.push('At least one of rpcUrl or restUrl is required');\n }\n\n if (config.rpcUrl) {\n const urlCheck = validateEndpointUrl(config.rpcUrl, 'rpcUrl');\n if (!urlCheck.valid) {\n errors.push(urlCheck.reason);\n }\n }\n\n if (config.restUrl) {\n const urlCheck = validateEndpointUrl(config.restUrl, 'restUrl');\n if (!urlCheck.valid) {\n errors.push(urlCheck.reason);\n }\n }\n\n // gasPrice required when rpcUrl is provided (needed for signing)\n if (config.rpcUrl && !config.gasPrice) {\n errors.push('gasPrice is required when rpcUrl is provided');\n } else if (config.gasPrice && !isValidGasPrice(config.gasPrice)) {\n errors.push(\n 'gasPrice must be a number followed by denomination (e.g., \"1.0umfx\", \"0.5factory/addr/udenom\", or \"0.25ibc/ABC123\")',\n );\n }\n\n // Optional fields\n if (config.addressPrefix !== undefined) {\n if (!/^[a-z]+$/.test(config.addressPrefix)) {\n errors.push('addressPrefix must be lowercase letters only');\n }\n }\n\n if (config.rateLimit !== undefined) {\n if (\n typeof config.rateLimit !== 'object' ||\n config.rateLimit === null ||\n Array.isArray(config.rateLimit)\n ) {\n errors.push('rateLimit must be a plain object');\n } else if (config.rateLimit.requestsPerSecond !== undefined) {\n if (\n typeof config.rateLimit.requestsPerSecond !== 'number' ||\n config.rateLimit.requestsPerSecond <= 0 ||\n !Number.isInteger(config.rateLimit.requestsPerSecond)\n ) {\n errors.push('rateLimit.requestsPerSecond must be a positive integer');\n }\n }\n }\n\n if (config.retry !== undefined) {\n if (\n typeof config.retry !== 'object' ||\n config.retry === null ||\n Array.isArray(config.retry)\n ) {\n errors.push('retry must be a plain object');\n } else {\n if (config.retry.maxRetries !== undefined) {\n if (\n typeof config.retry.maxRetries !== 'number' ||\n config.retry.maxRetries < 0 ||\n !Number.isInteger(config.retry.maxRetries)\n ) {\n errors.push('retry.maxRetries must be a non-negative integer');\n }\n }\n if (config.retry.baseDelayMs !== undefined) {\n if (\n typeof config.retry.baseDelayMs !== 'number' ||\n config.retry.baseDelayMs <= 0 ||\n !Number.isInteger(config.retry.baseDelayMs)\n ) {\n errors.push('retry.baseDelayMs must be a positive integer');\n }\n }\n if (config.retry.maxDelayMs !== undefined) {\n if (\n typeof config.retry.maxDelayMs !== 'number' ||\n config.retry.maxDelayMs <= 0 ||\n !Number.isInteger(config.retry.maxDelayMs)\n ) {\n errors.push('retry.maxDelayMs must be a positive integer');\n }\n }\n // Validate maxDelayMs >= baseDelayMs if both are provided\n if (\n config.retry.baseDelayMs !== undefined &&\n config.retry.maxDelayMs !== undefined &&\n config.retry.maxDelayMs < config.retry.baseDelayMs\n ) {\n errors.push(\n 'retry.maxDelayMs must be greater than or equal to retry.baseDelayMs',\n );\n }\n }\n }\n\n if (config.gasMultiplier !== undefined) {\n if (\n typeof config.gasMultiplier !== 'number' ||\n !Number.isFinite(config.gasMultiplier) ||\n config.gasMultiplier < 1\n ) {\n errors.push('gasMultiplier must be a finite number >= 1');\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n };\n}\n\n/**\n * Create and validate a configuration, throwing on invalid config\n */\nexport function createValidatedConfig(\n input: ManifestMCPConfig,\n): ManifestMCPConfig {\n const validation = validateConfig(input);\n\n if (!validation.valid) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n `Invalid configuration: ${validation.errors.join(', ')}`,\n { errors: validation.errors },\n );\n }\n\n return createConfig(input);\n}\n"],"mappings":";;;;;;AAUA,MAAM,yBAAyB;;;;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,SAAgB,oBACd,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,uBA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,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"}
@@ -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,eAA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M,KACP;GAED,MAAM,MAAM,aADK,KAAK,KAAK,cAAc,cAAc,EACpB,SAAS;AAE5C,UAAO;IACL;IACA,YAAY,MAAM,uBAAuB;IACzC,aAAa,OAAO,YAAY;IAChC,KAAK;KAAE,QAAQ,IAAI;KAAQ,KAAK,IAAI;KAAK;IAC1C;WACM,OAAO;AACd,OAAI,iBAAiB,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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YAAY,MAAM,uBAAuB;IACzC,aAAa,OAAO,YAAY;IAChC,KAAK;KAAE,QAAQ,IAAI;KAAQ,KAAK,IAAI;KAAK;IAC1C;WACM,OAAO;AACd,OAAI,iBAAiB,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"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
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
- import { ValidationResult, createConfig, createValidatedConfig, validateConfig } from "./config.js";
4
+ import { ValidationResult, createConfig, createValidatedConfig, validateConfig, validateEndpointUrl } from "./config.js";
5
5
  import { cosmosEstimateFee, cosmosQuery, cosmosTx } from "./cosmos.js";
6
6
  import { createLCDQueryClient } from "./lcd-adapter.js";
7
7
  import { LogLevel, logger, parseLogLevel } from "./logger.js";
@@ -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, validateEndpointUrl, withErrorHandling, withRetry };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ManifestMCPError, ManifestMCPErrorCode } from "./types.js";
2
2
  import { DEFAULT_RETRY_CONFIG, calculateBackoff, isRetryableError, withRetry } from "./retry.js";
3
- import { createConfig, createValidatedConfig, validateConfig } from "./config.js";
3
+ import { createConfig, createValidatedConfig, validateConfig, validateEndpointUrl } from "./config.js";
4
4
  import { logger, parseLogLevel } from "./logger.js";
5
5
  import { createLCDQueryClient } from "./lcd-adapter.js";
6
6
  import { CosmosClientManager } from "./client.js";
@@ -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, validateEndpointUrl, 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;;;;;iBAgBc,kBAAA,CACd,IAAA,kBACA,MAAA,UACA,UAAA;AAv/BF;;;AAAA,iBAugCgB,mBAAA,CAAA;EACd,KAAA;IAAA,CAAU,MAAA;EAAA;EACV,EAAA;IAAA,CAAO,MAAA;EAAA;AAAA;;;;;iBAsBO,eAAA,CAAgB,MAAA,WAAiB,YAAA;;;;AA/GjD;iBA+HgB,YAAA,CAAa,MAAA,WAAiB,SAAA;;;;AAvG9C;iBAuHgB,eAAA,CAAgB,MAAA,WAAiB,YAAA"}
1
+ {"version":3,"file":"modules.d.ts","names":[],"sources":["../src/modules.ts"],"mappings":";;;;;;;AAmFA;KAAY,YAAA,IACV,WAAA,EAAa,mBAAA,EACb,UAAA,UACA,IAAA,eACG,OAAA,CAAQ,WAAA;;;;;;;;KASD,SAAA,IACV,aAAA,EAAe,qBAAA,EACf,aAAA,UACA,UAAA,UACA,IAAA,YACA,mBAAA,WACA,OAAA,GAAU,SAAA,EACV,OAAA,GAAU,cAAA,KACP,OAAA,CAAQ,cAAA;;;;;;;AARb;;;KAmBY,YAAA,IACV,aAAA,UACA,UAAA,UACA,IAAA,YACA,OAAA,GAAU,cAAA,KACP,aAAA;;;;;;;;;iBAUW,0BAAA,CACd,IAAA,kBACA,MAAA,UACA,UAAA;;;;;;KAuCU,oBAAA,IACV,WAAA,EAAa,mBAAA,KACV,OAAA,CAAQ,cAAA;;;;iBA65BG,mBAAA,CAAA,GAAuB,gBAAA;;AAx9BvC;;iBAg/BgB,oBAAA,CACd,IAAA,kBACA,MAAA,WACC,UAAA;;;;iBAsBa,qBAAA,CACd,IAAA,kBACA,MAAA,UACA,UAAA;;;;;iBAgBc,kBAAA,CACd,IAAA,kBACA,MAAA,UACA,UAAA;AAhhCF;;;AAAA,iBAgiCgB,mBAAA,CAAA;EACd,KAAA;IAAA,CAAU,MAAA;EAAA;EACV,EAAA;IAAA,CAAO,MAAA;EAAA;AAAA;;;;;iBAsBO,eAAA,CAAgB,MAAA,WAAiB,YAAA;;;;;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