@manifest-network/manifest-mcp-core 0.4.6 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cosmos.d.ts +14 -2
- package/dist/cosmos.d.ts.map +1 -1
- package/dist/cosmos.js +65 -2
- package/dist/cosmos.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/lcd-adapter.d.ts.map +1 -1
- package/dist/lcd-adapter.js +8 -3
- package/dist/lcd-adapter.js.map +1 -1
- package/dist/modules.d.ts +12 -2
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +28 -10
- package/dist/modules.js.map +1 -1
- package/dist/transactions/bank.d.ts +6 -2
- package/dist/transactions/bank.d.ts.map +1 -1
- package/dist/transactions/bank.js +37 -26
- package/dist/transactions/bank.js.map +1 -1
- package/dist/transactions/billing.d.ts +6 -2
- package/dist/transactions/billing.d.ts.map +1 -1
- package/dist/transactions/billing.js +111 -93
- package/dist/transactions/billing.js.map +1 -1
- package/dist/transactions/distribution.d.ts +6 -2
- package/dist/transactions/distribution.d.ts.map +1 -1
- package/dist/transactions/distribution.js +42 -30
- package/dist/transactions/distribution.js.map +1 -1
- package/dist/transactions/gov.d.ts +6 -2
- package/dist/transactions/gov.d.ts.map +1 -1
- package/dist/transactions/gov.js +47 -35
- package/dist/transactions/gov.js.map +1 -1
- package/dist/transactions/group.d.ts +6 -2
- package/dist/transactions/group.d.ts.map +1 -1
- package/dist/transactions/group.js +159 -136
- package/dist/transactions/group.js.map +1 -1
- package/dist/transactions/index.d.ts +10 -10
- package/dist/transactions/index.js +10 -10
- package/dist/transactions/manifest.d.ts +6 -2
- package/dist/transactions/manifest.d.ts.map +1 -1
- package/dist/transactions/manifest.js +30 -19
- package/dist/transactions/manifest.js.map +1 -1
- package/dist/transactions/sku.d.ts +6 -2
- package/dist/transactions/sku.d.ts.map +1 -1
- package/dist/transactions/sku.js +100 -85
- package/dist/transactions/sku.js.map +1 -1
- package/dist/transactions/staking.d.ts +6 -2
- package/dist/transactions/staking.d.ts.map +1 -1
- package/dist/transactions/staking.js +53 -40
- package/dist/transactions/staking.js.map +1 -1
- package/dist/transactions/wasm.d.ts +7 -3
- package/dist/transactions/wasm.d.ts.map +1 -1
- package/dist/transactions/wasm.js +92 -69
- package/dist/transactions/wasm.js.map +1 -1
- package/dist/types.d.ts +43 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/cosmos.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CosmosQueryResult, CosmosTxResult, TxOverrides } from "./types.js";
|
|
1
|
+
import { CosmosQueryResult, CosmosTxResult, FeeEstimateResult, TxOverrides } from "./types.js";
|
|
2
2
|
import { CosmosClientManager } from "./client.js";
|
|
3
3
|
|
|
4
4
|
//#region src/cosmos.d.ts
|
|
@@ -19,6 +19,18 @@ declare function cosmosQuery(clientManager: CosmosClientManager, module: string,
|
|
|
19
19
|
* (insufficient funds, invalid args, etc.) are not retried as they won't succeed.
|
|
20
20
|
*/
|
|
21
21
|
declare function cosmosTx(clientManager: CosmosClientManager, module: string, subcommand: string, args?: string[], waitForConfirmation?: boolean, overrides?: TxOverrides): Promise<CosmosTxResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Estimate the fee for a Cosmos transaction without broadcasting it.
|
|
24
|
+
*
|
|
25
|
+
* Looks up the message builder for the given module, builds the messages,
|
|
26
|
+
* and calls `client.simulate()` to get a gas estimate. Multiplies by the
|
|
27
|
+
* configured (or overridden) gas multiplier and computes the fee.
|
|
28
|
+
*
|
|
29
|
+
* Automatically retries on transient failures via `withRetry`.
|
|
30
|
+
*
|
|
31
|
+
* @returns FeeEstimateResult with raw gas estimate and computed fee
|
|
32
|
+
*/
|
|
33
|
+
declare function cosmosEstimateFee(clientManager: CosmosClientManager, module: string, subcommand: string, args?: string[], overrides?: TxOverrides): Promise<FeeEstimateResult>;
|
|
22
34
|
//#endregion
|
|
23
|
-
export { cosmosQuery, cosmosTx };
|
|
35
|
+
export { cosmosEstimateFee, cosmosQuery, cosmosTx };
|
|
24
36
|
//# sourceMappingURL=cosmos.d.ts.map
|
package/dist/cosmos.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmos.d.ts","names":[],"sources":["../src/cosmos.ts"],"mappings":";;;;;;
|
|
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"}
|
package/dist/cosmos.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ManifestMCPError, ManifestMCPErrorCode } from "./types.js";
|
|
2
2
|
import { withRetry } from "./retry.js";
|
|
3
|
-
import
|
|
3
|
+
import "./config.js";
|
|
4
|
+
import { getQueryHandler, getTxHandler, getTxMsgBuilder } from "./modules.js";
|
|
5
|
+
import { calculateFee } from "@cosmjs/stargate";
|
|
4
6
|
//#region src/cosmos.ts
|
|
5
7
|
const VALID_NAME_PATTERN = /^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/;
|
|
6
8
|
/**
|
|
@@ -89,7 +91,68 @@ async function cosmosTx(clientManager, module, subcommand, args = [], waitForCon
|
|
|
89
91
|
operationName: `tx ${module} ${subcommand}`
|
|
90
92
|
});
|
|
91
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Estimate the fee for a Cosmos transaction without broadcasting it.
|
|
96
|
+
*
|
|
97
|
+
* Looks up the message builder for the given module, builds the messages,
|
|
98
|
+
* and calls `client.simulate()` to get a gas estimate. Multiplies by the
|
|
99
|
+
* configured (or overridden) gas multiplier and computes the fee.
|
|
100
|
+
*
|
|
101
|
+
* Automatically retries on transient failures via `withRetry`.
|
|
102
|
+
*
|
|
103
|
+
* @returns FeeEstimateResult with raw gas estimate and computed fee
|
|
104
|
+
*/
|
|
105
|
+
async function cosmosEstimateFee(clientManager, module, subcommand, args = [], overrides) {
|
|
106
|
+
validateName(module, "module", ManifestMCPErrorCode.UNSUPPORTED_TX);
|
|
107
|
+
validateName(subcommand, "subcommand", ManifestMCPErrorCode.UNSUPPORTED_TX);
|
|
108
|
+
const config = clientManager.getConfig();
|
|
109
|
+
const gasPrice = config.gasPrice;
|
|
110
|
+
if (!gasPrice) throw new ManifestMCPError(ManifestMCPErrorCode.INVALID_CONFIG, "Fee estimation requires gasPrice configuration");
|
|
111
|
+
if (overrides?.gasMultiplier !== void 0) {
|
|
112
|
+
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
|
+
}
|
|
114
|
+
const builder = getTxMsgBuilder(module);
|
|
115
|
+
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
|
+
try {
|
|
122
|
+
const built = builder(senderAddress, subcommand, args);
|
|
123
|
+
const gasEstimate = await signingClient.simulate(senderAddress, built.messages, built.memo);
|
|
124
|
+
const fee = calculateFee(Math.ceil(gasEstimate * gasMultiplier), gasPrice);
|
|
125
|
+
return {
|
|
126
|
+
module,
|
|
127
|
+
subcommand: built.canonicalSubcommand ?? subcommand,
|
|
128
|
+
gasEstimate: String(gasEstimate),
|
|
129
|
+
fee: {
|
|
130
|
+
amount: fee.amount,
|
|
131
|
+
gas: fee.gas
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
} catch (error) {
|
|
135
|
+
if (error instanceof ManifestMCPError) {
|
|
136
|
+
if (!error.details?.module) throw new ManifestMCPError(error.code, error.message, {
|
|
137
|
+
...error.details,
|
|
138
|
+
module,
|
|
139
|
+
subcommand,
|
|
140
|
+
args
|
|
141
|
+
});
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
throw new ManifestMCPError(ManifestMCPErrorCode.SIMULATION_FAILED, `Fee estimation for ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`, {
|
|
145
|
+
module,
|
|
146
|
+
subcommand,
|
|
147
|
+
args
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
config: config.retry,
|
|
152
|
+
operationName: `estimate ${module} ${subcommand}`
|
|
153
|
+
});
|
|
154
|
+
}
|
|
92
155
|
//#endregion
|
|
93
|
-
export { cosmosQuery, cosmosTx };
|
|
156
|
+
export { cosmosEstimateFee, cosmosQuery, cosmosTx };
|
|
94
157
|
|
|
95
158
|
//# sourceMappingURL=cosmos.js.map
|
package/dist/cosmos.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmos.js","names":[],"sources":["../src/cosmos.ts"],"sourcesContent":["import type { CosmosClientManager } from './client.js';\nimport { getQueryHandler, getTxHandler } from './modules.js';\nimport { withRetry } from './retry.js';\nimport {\n type CosmosQueryResult,\n type CosmosTxResult,\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"],"mappings":";;;;AAcA,MAAM,qBAAqB;;;;;;AAO3B,SAAS,aACP,MACA,OACA,WACM;AACN,KAAI,CAAC,QAAQ,CAAC,mBAAmB,KAAK,KAAK,CACzC,OAAM,IAAI,iBACR,WACA,WAAW,MAAM,KAAK,KAAK,wEAC5B;;;;;;;;AAUL,eAAsB,YACpB,eACA,QACA,YACA,OAAiB,EAAE,EACS;AAC5B,cAAa,QAAQ,UAAU,qBAAqB,kBAAkB;AACtE,cACE,YACA,cACA,qBAAqB,kBACtB;CAGD,MAAM,UAAU,gBAAgB,OAAO;AAEvC,QAAO,UACL,YAAY;AAEV,QAAM,cAAc,kBAAkB;EAEtC,MAAM,cAAc,MAAM,cAAc,gBAAgB;AAExD,MAAI;AAGF,UAAO;IACL;IACA;IACA,QALa,MAAM,QAAQ,aAAa,YAAY,KAAK;IAM1D;WACM,OAAO;AACd,OAAI,iBAAiB,iBACnB,OAAM;AAER,SAAM,IAAI,iBACR,qBAAqB,cACrB,SAAS,OAAO,GAAG,WAAW,WAAW,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GAChG;;IAGL;EACE,QAAQ,cAAc,WAAW,CAAC;EAClC,eAAe,SAAS,OAAO,GAAG;EACnC,CACF;;;;;;;;;;;AAYH,eAAsB,SACpB,eACA,QACA,YACA,OAAiB,EAAE,EACnB,sBAA+B,OAC/B,WACyB;AACzB,cAAa,QAAQ,UAAU,qBAAqB,eAAe;AACnE,cAAa,YAAY,cAAc,qBAAqB,eAAe;CAG3E,IAAI;AACJ,KAAI,WAAW,kBAAkB,KAAA,GAAW;AAC1C,MACE,CAAC,OAAO,SAAS,UAAU,cAAc,IACzC,UAAU,gBAAgB,EAE1B,OAAM,IAAI,iBACR,qBAAqB,gBACrB,mDAAmD,UAAU,gBAC9D;EAEH,MAAM,WAAW,cAAc,WAAW,CAAC;AAC3C,MAAI,CAAC,SACH,OAAM,IAAI,iBACR,qBAAqB,gBACrB,yDACD;AAEH,cAAY;GAAE,eAAe,UAAU;GAAe;GAAU;;CAIlE,MAAM,UAAU,aAAa,OAAO;AAEpC,QAAO,UACL,YAAY;AAEV,QAAM,cAAc,kBAAkB;EAEtC,MAAM,gBAAgB,MAAM,cAAc,kBAAkB;EAC5D,MAAM,gBAAgB,MAAM,cAAc,YAAY;AAEtD,MAAI;AACF,UAAO,MAAM,QACX,eACA,eACA,YACA,MACA,qBACA,UACD;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;;AAER,SAAM,IAAI,iBACR,qBAAqB,WACrB,MAAM,OAAO,GAAG,WAAW,WAAW,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IAC5F;IAAE;IAAQ;IAAY;IAAM,CAC7B;;IAGL;EACE,QAAQ,cAAc,WAAW,CAAC;EAClC,eAAe,MAAM,OAAO,GAAG;EAChC,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 { getQueryHandler, getTxHandler, getTxMsgBuilder } from './modules.js';\nimport { withRetry } from './retry.js';\nimport {\n type CosmosQueryResult,\n type CosmosTxResult,\n type FeeEstimateResult,\n ManifestMCPError,\n ManifestMCPErrorCode,\n type TxOptions,\n type TxOverrides,\n} from './types.js';\n\n// Validation pattern for module/subcommand names (alphanumeric, hyphens, underscores)\n// First character must not be a hyphen to prevent potential issues\nconst VALID_NAME_PATTERN = /^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/;\n\n/**\n * Validate that a string is safe for use as a module or subcommand name.\n * Uses the appropriate UNSUPPORTED_QUERY or UNSUPPORTED_TX code so that\n * the error is immediately classified as non-retryable.\n */\nfunction validateName(\n name: string,\n field: string,\n errorCode: ManifestMCPErrorCode,\n): void {\n if (!name || !VALID_NAME_PATTERN.test(name)) {\n throw new ManifestMCPError(\n errorCode,\n `Invalid ${field}: \"${name}\". Only alphanumeric characters, hyphens, and underscores are allowed.`,\n );\n }\n}\n\n/**\n * Execute a Cosmos query via manifestjs RPC client\n *\n * Automatically retries on transient failures (network errors, timeouts, 5xx)\n * with exponential backoff. Configure retry behavior via `config.retry`.\n */\nexport async function cosmosQuery(\n clientManager: CosmosClientManager,\n module: string,\n subcommand: string,\n args: string[] = [],\n): Promise<CosmosQueryResult> {\n validateName(module, 'module', ManifestMCPErrorCode.UNSUPPORTED_QUERY);\n validateName(\n subcommand,\n 'subcommand',\n ManifestMCPErrorCode.UNSUPPORTED_QUERY,\n );\n\n // Get handler from registry (throws if module not found) - do this before retry loop\n const handler = getQueryHandler(module);\n\n return withRetry(\n async () => {\n // Apply rate limiting before making RPC request\n await clientManager.acquireRateLimit();\n\n const queryClient = await clientManager.getQueryClient();\n\n try {\n const result = await handler(queryClient, subcommand, args);\n\n return {\n module,\n subcommand,\n result,\n };\n } catch (error) {\n if (error instanceof ManifestMCPError) {\n throw error;\n }\n throw new ManifestMCPError(\n ManifestMCPErrorCode.QUERY_FAILED,\n `Query ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n {\n config: clientManager.getConfig().retry,\n operationName: `query ${module} ${subcommand}`,\n },\n );\n}\n\n/**\n * Execute a Cosmos transaction via manifestjs signing client\n *\n * Automatically retries on transient failures (network errors, timeouts, 5xx)\n * with exponential backoff. Configure retry behavior via `config.retry`.\n *\n * Note: Only network-level failures are retried. Transaction validation errors\n * (insufficient funds, invalid args, etc.) are not retried as they won't succeed.\n */\nexport async function cosmosTx(\n clientManager: CosmosClientManager,\n module: string,\n subcommand: string,\n args: string[] = [],\n waitForConfirmation: boolean = false,\n overrides?: TxOverrides,\n): Promise<CosmosTxResult> {\n validateName(module, 'module', ManifestMCPErrorCode.UNSUPPORTED_TX);\n validateName(subcommand, 'subcommand', ManifestMCPErrorCode.UNSUPPORTED_TX);\n\n // Build fully-resolved gas options from caller overrides + server config\n let txOptions: TxOptions | undefined;\n if (overrides?.gasMultiplier !== undefined) {\n if (\n !Number.isFinite(overrides.gasMultiplier) ||\n overrides.gasMultiplier < 1\n ) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n `gasMultiplier must be a finite number >= 1, got ${overrides.gasMultiplier}`,\n );\n }\n const gasPrice = clientManager.getConfig().gasPrice;\n if (!gasPrice) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n 'gasMultiplier override requires gasPrice configuration',\n );\n }\n txOptions = { gasMultiplier: overrides.gasMultiplier, gasPrice };\n }\n\n // Get handler from registry (throws if module not found) - do this before retry loop\n const handler = getTxHandler(module);\n\n return withRetry(\n async () => {\n // Apply rate limiting before making RPC request\n await clientManager.acquireRateLimit();\n\n const signingClient = await clientManager.getSigningClient();\n const senderAddress = await clientManager.getAddress();\n\n try {\n return await handler(\n signingClient,\n senderAddress,\n subcommand,\n args,\n waitForConfirmation,\n txOptions,\n );\n } catch (error) {\n if (error instanceof ManifestMCPError) {\n // Re-throw with enriched context if not already present\n if (!error.details?.module) {\n throw new ManifestMCPError(error.code, error.message, {\n ...error.details,\n module,\n subcommand,\n args,\n });\n }\n throw error;\n }\n throw new ManifestMCPError(\n ManifestMCPErrorCode.TX_FAILED,\n `Tx ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`,\n { module, subcommand, args },\n );\n }\n },\n {\n config: clientManager.getConfig().retry,\n operationName: `tx ${module} ${subcommand}`,\n },\n );\n}\n\n/**\n * Estimate the fee for a Cosmos transaction without broadcasting it.\n *\n * Looks up the message builder for the given module, builds the messages,\n * and calls `client.simulate()` to get a gas estimate. Multiplies by the\n * configured (or overridden) gas multiplier and computes the fee.\n *\n * Automatically retries on transient failures via `withRetry`.\n *\n * @returns FeeEstimateResult with raw gas estimate and computed fee\n */\nexport async function cosmosEstimateFee(\n clientManager: CosmosClientManager,\n module: string,\n subcommand: string,\n args: string[] = [],\n overrides?: TxOverrides,\n): Promise<FeeEstimateResult> {\n validateName(module, 'module', ManifestMCPErrorCode.UNSUPPORTED_TX);\n validateName(subcommand, 'subcommand', ManifestMCPErrorCode.UNSUPPORTED_TX);\n\n // Always need gasPrice for fee calculation (unlike cosmosTx which can use 'auto')\n const config = clientManager.getConfig();\n const gasPrice = config.gasPrice;\n if (!gasPrice) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n 'Fee estimation requires gasPrice configuration',\n );\n }\n\n // Validate the override eagerly (the resolved fallback values are always valid).\n if (overrides?.gasMultiplier !== undefined) {\n if (\n !Number.isFinite(overrides.gasMultiplier) ||\n overrides.gasMultiplier < 1\n ) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_CONFIG,\n `gasMultiplier must be a finite number >= 1, got ${overrides.gasMultiplier}`,\n );\n }\n }\n\n // Get builder from registry (throws if module not found) - do this before retry loop\n const builder = getTxMsgBuilder(module);\n\n return withRetry(\n async () => {\n // Apply rate limiting before making RPC request\n await clientManager.acquireRateLimit();\n\n const signingClient = await clientManager.getSigningClient();\n const senderAddress = await clientManager.getAddress();\n\n // Resolve gasMultiplier from the signing client when no override is provided.\n // This guarantees parity with cosmosTx's 'auto' path: client.ts patches the\n // signing client's defaultGasMultiplier to config.gasMultiplier; if that\n // patch fails (rare — only when CosmJS internals change), the client\n // falls back to CosmJS's built-in default. Reading from the client uses\n // the same value cosmosTx would.\n const clientMultiplier = (\n signingClient as unknown as { defaultGasMultiplier?: unknown }\n ).defaultGasMultiplier;\n const gasMultiplier =\n overrides?.gasMultiplier ??\n (typeof clientMultiplier === 'number'\n ? clientMultiplier\n : DEFAULT_GAS_MULTIPLIER);\n\n try {\n const built = builder(senderAddress, subcommand, args);\n const gasEstimate = await signingClient.simulate(\n senderAddress,\n built.messages,\n built.memo,\n );\n const gasLimit = Math.ceil(gasEstimate * gasMultiplier);\n const fee = calculateFee(gasLimit, gasPrice);\n\n return {\n module,\n subcommand: built.canonicalSubcommand ?? subcommand,\n gasEstimate: String(gasEstimate),\n fee: { amount: fee.amount, gas: fee.gas },\n };\n } catch (error) {\n if (error instanceof ManifestMCPError) {\n // Re-throw with enriched context if not already present (mirrors cosmosTx)\n if (!error.details?.module) {\n throw new ManifestMCPError(error.code, error.message, {\n ...error.details,\n module,\n subcommand,\n args,\n });\n }\n throw error;\n }\n // SIMULATION_FAILED is NOT in NON_RETRYABLE_ERROR_CODES, so withRetry\n // will fall through to isTransientErrorMessage for message-based\n // classification. Transient errors (network/5xx) get retried; real\n // simulation failures (insufficient funds, etc) fail fast.\n throw new ManifestMCPError(\n ManifestMCPErrorCode.SIMULATION_FAILED,\n `Fee estimation for ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`,\n { module, subcommand, args },\n );\n }\n },\n {\n config: config.retry,\n operationName: `estimate ${module} ${subcommand}`,\n },\n );\n}\n"],"mappings":";;;;;;AAiBA,MAAM,qBAAqB;;;;;;AAO3B,SAAS,aACP,MACA,OACA,WACM;AACN,KAAI,CAAC,QAAQ,CAAC,mBAAmB,KAAK,KAAK,CACzC,OAAM,IAAI,iBACR,WACA,WAAW,MAAM,KAAK,KAAK,wEAC5B;;;;;;;;AAUL,eAAsB,YACpB,eACA,QACA,YACA,OAAiB,EAAE,EACS;AAC5B,cAAa,QAAQ,UAAU,qBAAqB,kBAAkB;AACtE,cACE,YACA,cACA,qBAAqB,kBACtB;CAGD,MAAM,UAAU,gBAAgB,OAAO;AAEvC,QAAO,UACL,YAAY;AAEV,QAAM,cAAc,kBAAkB;EAEtC,MAAM,cAAc,MAAM,cAAc,gBAAgB;AAExD,MAAI;AAGF,UAAO;IACL;IACA;IACA,QALa,MAAM,QAAQ,aAAa,YAAY,KAAK;I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,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,8 +1,8 @@
|
|
|
1
|
-
import { AccountInfo, AccountInfoResult, AddressBytesToStringResult, AddressStringToBytesResult, Any, AuthAccountResult, AuthAccountsResult, AuthParams, AuthParamsResult, AvailableModules, BalanceResult, BalancesResult, BankMetadata, BankParams, BankParamsResult, BaseAccount, Bech32PrefixResult, BillingParams, BillingParamsResult, CodeInfoResponse, Coin, CommissionResult, CommunityPoolResult, ContractCodeHistoryEntry, ContractInfo, CosmosQueryResult, CosmosTxResult, CreditAccount, CreditAccountResult, CreditAccountsResult, CreditAddressResult, CreditEstimateResult, DecCoin, DelegationDelegatorReward, DelegationResponse, DelegationResult, DelegationsResult, DelegatorValidatorsResult, DelegatorWithdrawAddressResult, DenomMetadataResult, DenomsMetadataResult, DepositParams, DepositResult, DepositsResult, DistributionParams, DistributionParamsResult, GovDeposit, GovParams, GovParamsResult, GovProposal, GovTallyResult, GovVote, GroupInfo, GroupInfoResult, GroupMember, GroupMembersResult, GroupPoliciesResult, GroupPolicyInfo, GroupPolicyInfoResult, GroupProposal, GroupProposalResult, GroupProposalsResult, GroupTallyQueryResult, GroupTallyResult, GroupVote, GroupVoteResult, GroupVotesResult, GroupsResult, HistoricalInfo, HistoricalInfoResult, Lease, LeaseItemInput, LeaseResult, LeasesResult, ManifestMCPConfig, ManifestMCPError, ManifestMCPErrorCode, Model, ModuleAccount, ModuleAccountsResult, ModuleInfo, PaginatedResult, PaginationResponse, 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, 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, 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, DenomMetadataResult, DenomsMetadataResult, DepositParams, DepositResult, DepositsResult, DistributionParams, DistributionParamsResult, FeeEstimateResult, GovDeposit, GovParams, GovParamsResult, GovProposal, GovTallyResult, GovVote, GroupInfo, GroupInfoResult, GroupMember, GroupMembersResult, GroupPoliciesResult, GroupPolicyInfo, GroupPolicyInfoResult, GroupProposal, GroupProposalResult, GroupProposalsResult, GroupTallyQueryResult, GroupTallyResult, GroupVote, GroupVoteResult, GroupVotesResult, GroupsResult, HistoricalInfo, HistoricalInfoResult, Lease, LeaseItemInput, LeaseResult, LeasesResult, ManifestMCPConfig, ManifestMCPError, ManifestMCPErrorCode, Model, ModuleAccount, ModuleAccountsResult, ModuleInfo, PaginatedResult, PaginationResponse, 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, 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";
|
|
2
2
|
import { CosmosClientManager, ManifestQueryClient } from "./client.js";
|
|
3
3
|
import { DEFAULT_RETRY_CONFIG, RetryOptions, calculateBackoff, isRetryableError, withRetry } from "./retry.js";
|
|
4
4
|
import { ValidationResult, createConfig, createValidatedConfig, validateConfig } from "./config.js";
|
|
5
|
-
import { cosmosQuery, cosmosTx } from "./cosmos.js";
|
|
5
|
+
import { cosmosEstimateFee, cosmosQuery, cosmosTx } from "./cosmos.js";
|
|
6
6
|
import { createLCDQueryClient } from "./lcd-adapter.js";
|
|
7
7
|
import { LogLevel, logger } from "./logger.js";
|
|
8
8
|
import { getAvailableModules, getModuleSubcommands, getSubcommandUsage, getSupportedModules, isSubcommandSupported } from "./modules.js";
|
|
@@ -16,4 +16,4 @@ import { VERSION } from "./version.js";
|
|
|
16
16
|
import { MnemonicWalletProvider } from "./wallet/mnemonic.js";
|
|
17
17
|
import { signArbitraryWithAmino } from "./wallet/sign-arbitrary.js";
|
|
18
18
|
import { LeaseState, leaseStateFromJSON, leaseStateToJSON } from "@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js";
|
|
19
|
-
export { AccountInfo, AccountInfoResult, AddressBytesToStringResult, AddressStringToBytesResult, Any, AuthAccountResult, AuthAccountsResult, AuthParams, AuthParamsResult, AvailableModules, BalanceResult, BalancesResult, BankMetadata, BankParams, BankParamsResult, BaseAccount, Bech32PrefixResult, BillingParams, BillingParamsResult, 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, DenomMetadataResult, DenomsMetadataResult, DepositParams, DepositResult, DepositsResult, DistributionParams, DistributionParamsResult, 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, Lease, LeaseItemInput, LeaseResult, LeaseState, LeasesResult, type LogLevel, MAX_PAGE_LIMIT, ManifestMCPConfig, ManifestMCPError, ManifestMCPErrorCode, type ManifestMCPServerOptions, type ManifestQueryClient, type MnemonicServerConfig, MnemonicWalletProvider, Model, ModuleAccount, ModuleAccountsResult, ModuleInfo, PaginatedResult, PaginationResponse, 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, 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, cosmosQuery, cosmosTx, createConfig, createLCDQueryClient, createMnemonicServer, createPagination, createValidatedConfig, fundCredits, getAvailableModules, getBalance, getModuleSubcommands, getSubcommandUsage, getSupportedModules, isRetryableError, isSubcommandSupported, jsonResponse, leaseStateFromJSON, leaseStateToJSON, logger, optionalBoolean, parseArgs, requireString, requireStringEnum, requireUuid, sanitizeForLogging, signArbitraryWithAmino, stopApp, validateConfig, withErrorHandling, withRetry };
|
|
19
|
+
export { AccountInfo, AccountInfoResult, AddressBytesToStringResult, AddressStringToBytesResult, Any, AuthAccountResult, AuthAccountsResult, AuthParams, AuthParamsResult, 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, DenomMetadataResult, DenomsMetadataResult, DepositParams, DepositResult, DepositsResult, DistributionParams, DistributionParamsResult, FeeEstimateResult, 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, Lease, LeaseItemInput, LeaseResult, LeaseState, LeasesResult, type LogLevel, MAX_PAGE_LIMIT, ManifestMCPConfig, ManifestMCPError, ManifestMCPErrorCode, type ManifestMCPServerOptions, type ManifestQueryClient, type MnemonicServerConfig, MnemonicWalletProvider, Model, ModuleAccount, ModuleAccountsResult, ModuleInfo, PaginatedResult, PaginationResponse, 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, 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, optionalBoolean, parseArgs, requireString, requireStringEnum, requireUuid, sanitizeForLogging, signArbitraryWithAmino, stopApp, validateConfig, withErrorHandling, withRetry };
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { CosmosClientManager } from "./client.js";
|
|
|
7
7
|
import { DNS_LABEL_RE, optionalBoolean, parseArgs, requireString, requireStringEnum, requireUuid } from "./validation.js";
|
|
8
8
|
import { MAX_PAGE_LIMIT, createPagination } from "./queries/utils.js";
|
|
9
9
|
import { getAvailableModules, getModuleSubcommands, getSubcommandUsage, getSupportedModules, isSubcommandSupported } from "./modules.js";
|
|
10
|
-
import { cosmosQuery, cosmosTx } from "./cosmos.js";
|
|
10
|
+
import { cosmosEstimateFee, cosmosQuery, cosmosTx } from "./cosmos.js";
|
|
11
11
|
import { signArbitraryWithAmino } from "./wallet/sign-arbitrary.js";
|
|
12
12
|
import { MnemonicWalletProvider } from "./wallet/mnemonic.js";
|
|
13
13
|
import "./wallet/index.js";
|
|
@@ -17,4 +17,4 @@ import { getBalance } from "./tools/getBalance.js";
|
|
|
17
17
|
import { stopApp } from "./tools/stopApp.js";
|
|
18
18
|
import { VERSION } from "./version.js";
|
|
19
19
|
import { LeaseState, leaseStateFromJSON, leaseStateToJSON } from "@manifest-network/manifestjs/dist/codegen/liftedinit/billing/v1/types.js";
|
|
20
|
-
export { CosmosClientManager, DEFAULT_RETRY_CONFIG, DNS_LABEL_RE, INFRASTRUCTURE_ERROR_CODES, LeaseState, MAX_PAGE_LIMIT, ManifestMCPError, ManifestMCPErrorCode, MnemonicWalletProvider, SENSITIVE_FIELDS, VERSION, bigIntReplacer, calculateBackoff, cosmosQuery, cosmosTx, createConfig, createLCDQueryClient, createMnemonicServer, createPagination, createValidatedConfig, fundCredits, getAvailableModules, getBalance, getModuleSubcommands, getSubcommandUsage, getSupportedModules, isRetryableError, isSubcommandSupported, jsonResponse, leaseStateFromJSON, leaseStateToJSON, logger, optionalBoolean, parseArgs, requireString, requireStringEnum, requireUuid, sanitizeForLogging, signArbitraryWithAmino, stopApp, validateConfig, withErrorHandling, withRetry };
|
|
20
|
+
export { CosmosClientManager, DEFAULT_RETRY_CONFIG, DNS_LABEL_RE, INFRASTRUCTURE_ERROR_CODES, LeaseState, 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, optionalBoolean, parseArgs, requireString, requireStringEnum, requireUuid, sanitizeForLogging, signArbitraryWithAmino, stopApp, validateConfig, withErrorHandling, withRetry };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lcd-adapter.d.ts","names":[],"sources":["../src/lcd-adapter.ts"],"mappings":";;;iBAcS,gBAAA,CAAiB,GAAA;AAAA,UAwBhB,SAAA;EACR,QAAA,CAAS,MAAA;AAAA;AAAA,iBAGF,aAAA,CACP,SAAA,EAAW,MAAA,mBACX,UAAA,WACC,SAAA;AAAA,KAiBE,OAAA,OAAc,IAAA,gBAAoB,OAAA;AAAA,iBAE9B,WAAA,CACP,MAAA,WACA,WAAA,YACC,MAAA,SAAe,OAAA;AAAA,iBAqCT,iBAAA,CAAkB,UAAA;;;;;AAjED;;iBAwFjB,kBAAA,CAAmB,OAAA,YAAmB,MAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"lcd-adapter.d.ts","names":[],"sources":["../src/lcd-adapter.ts"],"mappings":";;;iBAcS,gBAAA,CAAiB,GAAA;AAAA,UAwBhB,SAAA;EACR,QAAA,CAAS,MAAA;AAAA;AAAA,iBAGF,aAAA,CACP,SAAA,EAAW,MAAA,mBACX,UAAA,WACC,SAAA;AAAA,KAiBE,OAAA,OAAc,IAAA,gBAAoB,OAAA;AAAA,iBAE9B,WAAA,CACP,MAAA,WACA,WAAA,YACC,MAAA,SAAe,OAAA;AAAA,iBAqCT,iBAAA,CAAkB,UAAA;;;;;AAjED;;iBAwFjB,kBAAA,CAAmB,OAAA,YAAmB,MAAA;AAAA,iBAqCzB,oBAAA,CACpB,YAAA,WACC,OAAA,CAAQ,mBAAA"}
|
package/dist/lcd-adapter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ManifestMCPError, ManifestMCPErrorCode } from "./types.js";
|
|
2
2
|
import { logger } from "./logger.js";
|
|
3
3
|
import { cosmos, cosmwasm, liftedinit } from "@manifest-network/manifestjs";
|
|
4
|
-
import { toBase64 } from "@cosmjs/encoding";
|
|
4
|
+
import { toBase64, toUtf8 } from "@cosmjs/encoding";
|
|
5
5
|
//#region src/lcd-adapter.ts
|
|
6
6
|
function snakeToCamel(s) {
|
|
7
7
|
return s.replace(/_(.)/g, (_, c) => c.toUpperCase());
|
|
@@ -68,12 +68,17 @@ function patchWasmQueryData(wasmLcd) {
|
|
|
68
68
|
logger.warn(`patchWasmQueryData: expected method "${method}" not found on wasm LCD module. Wasm queries may fail with malformed URLs.`);
|
|
69
69
|
continue;
|
|
70
70
|
}
|
|
71
|
-
patched[method] = (params) => {
|
|
71
|
+
patched[method] = async (params) => {
|
|
72
72
|
const queryData = params.queryData;
|
|
73
|
-
|
|
73
|
+
const result = await original.call(mod, {
|
|
74
74
|
...params,
|
|
75
75
|
queryData: queryData instanceof Uint8Array ? toBase64(queryData) : queryData
|
|
76
76
|
});
|
|
77
|
+
if (result.data != null && typeof result.data !== "string") return {
|
|
78
|
+
...result,
|
|
79
|
+
data: toBase64(toUtf8(JSON.stringify(result.data)))
|
|
80
|
+
};
|
|
81
|
+
return result;
|
|
77
82
|
};
|
|
78
83
|
}
|
|
79
84
|
return patched;
|
package/dist/lcd-adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lcd-adapter.js","names":["cosmwasmNs"],"sources":["../src/lcd-adapter.ts"],"sourcesContent":["import { toBase64 } from '@cosmjs/encoding';\nimport {\n cosmos,\n cosmwasm as cosmwasmNs,\n liftedinit,\n} from '@manifest-network/manifestjs';\nimport type { ManifestQueryClient } from './client.js';\nimport { logger } from './logger.js';\nimport { ManifestMCPError, ManifestMCPErrorCode } from './types.js';\n\nfunction snakeToCamel(s: string): string {\n return s.replace(/_(.)/g, (_, c: string) => c.toUpperCase());\n}\n\nfunction snakeToCamelDeep(obj: unknown): unknown {\n if (Array.isArray(obj)) {\n return obj.map(snakeToCamelDeep);\n }\n if (\n obj !== null &&\n typeof obj === 'object' &&\n !(obj instanceof Date) &&\n !(obj instanceof Uint8Array)\n ) {\n return Object.fromEntries(\n Object.entries(obj as Record<string, unknown>).map(([k, v]) => [\n snakeToCamel(k),\n snakeToCamelDeep(v),\n ]),\n );\n }\n return obj;\n}\n\nfunction ucFirst(s: string): string {\n return s.charAt(0).toUpperCase() + s.slice(1);\n}\n\ninterface Converter {\n fromJSON(object: unknown): unknown;\n}\n\nfunction findConverter(\n namespace: Record<string, unknown>,\n methodName: string,\n): Converter {\n const uc = ucFirst(methodName);\n const queryName = `Query${uc}Response`;\n const plainName = `${uc}Response`;\n\n const converter = (namespace[queryName] ?? namespace[plainName]) as\n | Converter\n | undefined;\n if (!converter?.fromJSON) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.QUERY_FAILED,\n `No response converter found for method \"${methodName}\" (tried \"${queryName}\" and \"${plainName}\")`,\n );\n }\n return converter;\n}\n\ntype AsyncFn = (...args: unknown[]) => Promise<unknown>;\n\nfunction adaptModule(\n lcdMod: unknown,\n converterNs: unknown,\n): Record<string, AsyncFn> {\n const lcdModule = lcdMod as Record<string, unknown>;\n const converterNamespace = converterNs as Record<string, unknown>;\n const adapted: Record<string, AsyncFn> = {};\n\n for (const key of Object.keys(lcdModule)) {\n if (key === 'req' || typeof lcdModule[key] !== 'function') continue;\n\n const originalFn = lcdModule[key] as AsyncFn;\n const converter = findConverter(converterNamespace, key);\n\n adapted[key] = async (...args: unknown[]) => {\n let sdkResult: unknown;\n try {\n sdkResult = await originalFn.call(lcdModule, ...args);\n } catch (error) {\n if (error instanceof ManifestMCPError) throw error;\n throw new ManifestMCPError(\n ManifestMCPErrorCode.QUERY_FAILED,\n `LCD query \"${key}\" failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const camelCased = snakeToCamelDeep(sdkResult);\n try {\n return converter.fromJSON(camelCased);\n } catch (error) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.QUERY_FAILED,\n `Failed to convert LCD response for \"${key}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n };\n }\n\n return adapted;\n}\n\nfunction unsupportedModule(modulePath: string): unknown {\n return new Proxy(\n {},\n {\n get(_target, prop) {\n if (typeof prop === 'string') {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.UNSUPPORTED_QUERY,\n `Module \"${modulePath}\" is not available via LCD/REST. Use an RPC endpoint instead.`,\n );\n }\n return undefined;\n },\n },\n );\n}\n\n/**\n * The generated LCD client interpolates `queryData` (Uint8Array) directly into\n * the URL path via template literal, producing comma-separated byte values\n * (e.g. `smart/123,34,99,...`) instead of base64. The REST API expects base64.\n * Patch the methods to convert queryData before the URL is constructed.\n */\nfunction patchWasmQueryData(wasmLcd: unknown): Record<string, unknown> {\n const mod = wasmLcd as Record<string, unknown>;\n const patched: Record<string, unknown> = { ...mod };\n for (const method of ['smartContractState', 'rawContractState']) {\n const original = mod[method] as (\n params: Record<string, unknown>,\n ) => Promise<unknown>;\n if (typeof original !== 'function') {\n logger.warn(\n `patchWasmQueryData: expected method \"${method}\" not found on wasm LCD module. Wasm queries may fail with malformed URLs.`,\n );\n continue;\n }\n patched[method] = (params: Record<string, unknown>) => {\n const queryData = params.queryData;\n return original.call(mod, {\n ...params,\n queryData:\n queryData instanceof Uint8Array ? toBase64(queryData) : queryData,\n });\n };\n }\n return patched;\n}\n\nexport async function createLCDQueryClient(\n restEndpoint: string,\n): Promise<ManifestQueryClient> {\n let lcd: Awaited<ReturnType<typeof liftedinit.ClientFactory.createLCDClient>>;\n let cosmwasmLcd: Awaited<\n ReturnType<typeof cosmwasmNs.ClientFactory.createLCDClient>\n >;\n try {\n [lcd, cosmwasmLcd] = await Promise.all([\n liftedinit.ClientFactory.createLCDClient({ restEndpoint }),\n cosmwasmNs.ClientFactory.createLCDClient({ restEndpoint }),\n ]);\n } catch (error) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.RPC_CONNECTION_FAILED,\n `Failed to create LCD client for ${restEndpoint}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n try {\n return {\n cosmos: {\n auth: {\n v1beta1: adaptModule(lcd.cosmos.auth.v1beta1, cosmos.auth.v1beta1),\n },\n authz: {\n v1beta1: adaptModule(lcd.cosmos.authz.v1beta1, cosmos.authz.v1beta1),\n },\n bank: {\n v1beta1: adaptModule(lcd.cosmos.bank.v1beta1, cosmos.bank.v1beta1),\n },\n base: {\n node: {\n v1beta1: adaptModule(\n lcd.cosmos.base.node.v1beta1,\n cosmos.base.node.v1beta1,\n ),\n },\n },\n circuit: { v1: adaptModule(lcd.cosmos.circuit.v1, cosmos.circuit.v1) },\n consensus: {\n v1: adaptModule(lcd.cosmos.consensus.v1, cosmos.consensus.v1),\n },\n distribution: {\n v1beta1: adaptModule(\n lcd.cosmos.distribution.v1beta1,\n cosmos.distribution.v1beta1,\n ),\n },\n feegrant: {\n v1beta1: adaptModule(\n lcd.cosmos.feegrant.v1beta1,\n cosmos.feegrant.v1beta1,\n ),\n },\n gov: {\n v1: adaptModule(lcd.cosmos.gov.v1, cosmos.gov.v1),\n v1beta1: adaptModule(lcd.cosmos.gov.v1beta1, cosmos.gov.v1beta1),\n },\n group: { v1: adaptModule(lcd.cosmos.group.v1, cosmos.group.v1) },\n mint: {\n v1beta1: adaptModule(lcd.cosmos.mint.v1beta1, cosmos.mint.v1beta1),\n },\n orm: {\n query: { v1alpha1: unsupportedModule('cosmos.orm.query.v1alpha1') },\n },\n params: {\n v1beta1: adaptModule(\n lcd.cosmos.params.v1beta1,\n cosmos.params.v1beta1,\n ),\n },\n staking: {\n v1beta1: adaptModule(\n lcd.cosmos.staking.v1beta1,\n cosmos.staking.v1beta1,\n ),\n },\n tx: { v1beta1: adaptModule(lcd.cosmos.tx.v1beta1, cosmos.tx.v1beta1) },\n upgrade: {\n v1beta1: adaptModule(\n lcd.cosmos.upgrade.v1beta1,\n cosmos.upgrade.v1beta1,\n ),\n },\n },\n liftedinit: {\n billing: {\n v1: adaptModule(lcd.liftedinit.billing.v1, liftedinit.billing.v1),\n },\n manifest: { v1: unsupportedModule('liftedinit.manifest.v1') },\n sku: { v1: adaptModule(lcd.liftedinit.sku.v1, liftedinit.sku.v1) },\n },\n cosmwasm: {\n wasm: {\n v1: adaptModule(\n patchWasmQueryData(cosmwasmLcd.cosmwasm.wasm.v1),\n cosmwasmNs.wasm.v1,\n ),\n },\n },\n } as ManifestQueryClient;\n } catch (error) {\n if (error instanceof ManifestMCPError) throw error;\n throw new ManifestMCPError(\n ManifestMCPErrorCode.RPC_CONNECTION_FAILED,\n `Failed to adapt LCD modules: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n\n// Re-export for testing\nexport {\n adaptModule as _adaptModule,\n findConverter as _findConverter,\n patchWasmQueryData as _patchWasmQueryData,\n snakeToCamelDeep as _snakeToCamelDeep,\n unsupportedModule as _unsupportedModule,\n};\n"],"mappings":";;;;;AAUA,SAAS,aAAa,GAAmB;AACvC,QAAO,EAAE,QAAQ,UAAU,GAAG,MAAc,EAAE,aAAa,CAAC;;AAG9D,SAAS,iBAAiB,KAAuB;AAC/C,KAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,IAAI,iBAAiB;AAElC,KACE,QAAQ,QACR,OAAO,QAAQ,YACf,EAAE,eAAe,SACjB,EAAE,eAAe,YAEjB,QAAO,OAAO,YACZ,OAAO,QAAQ,IAA+B,CAAC,KAAK,CAAC,GAAG,OAAO,CAC7D,aAAa,EAAE,EACf,iBAAiB,EAAE,CACpB,CAAC,CACH;AAEH,QAAO;;AAGT,SAAS,QAAQ,GAAmB;AAClC,QAAO,EAAE,OAAO,EAAE,CAAC,aAAa,GAAG,EAAE,MAAM,EAAE;;AAO/C,SAAS,cACP,WACA,YACW;CACX,MAAM,KAAK,QAAQ,WAAW;CAC9B,MAAM,YAAY,QAAQ,GAAG;CAC7B,MAAM,YAAY,GAAG,GAAG;CAExB,MAAM,YAAa,UAAU,cAAc,UAAU;AAGrD,KAAI,CAAC,WAAW,SACd,OAAM,IAAI,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GAAG;KACjD,SAAS,YAAY,IAAI,OAAO,IAAI,SAAS,OAAO,IAAI,QAAQ;KACjE;IACD,OAAO,EAAE,IAAI,YAAY,IAAI,OAAO,MAAM,IAAI,OAAO,MAAM,GAAG,EAAE;IAChE,MAAM,EACJ,SAAS,YAAY,IAAI,OAAO,KAAK,SAAS,OAAO,KAAK,QAAQ,EACnE;IACD,KAAK,EACH,OAAO,EAAE,UAAU,kBAAkB,4BAA4B,EAAE,EACpE;IACD,QAAQ,EACN,SAAS,YACP,IAAI,OAAO,OAAO,SAClB,OAAO,OAAO,QACf,EACF;IACD,SAAS,EACP,SAAS,YACP,IAAI,OAAO,QAAQ,SACnB,OAAO,QAAQ,QAChB,EACF;IACD,IAAI,EAAE,SAAS,YAAY,IAAI,OAAO,GAAG,SAAS,OAAO,GAAG,QAAQ,EAAE;IACtE,SAAS,EACP,SAAS,YACP,IAAI,OAAO,QAAQ,SACnB,OAAO,QAAQ,QAChB,EACF;IACF;GACD,YAAY;IACV,SAAS,EACP,IAAI,YAAY,IAAI,WAAW,QAAQ,IAAI,WAAW,QAAQ,GAAG,EAClE;IACD,UAAU,EAAE,IAAI,kBAAkB,yBAAyB,EAAE;IAC7D,KAAK,EAAE,IAAI,YAAY,IAAI,WAAW,IAAI,IAAI,WAAW,IAAI,GAAG,EAAE;IACnE;GACD,UAAU,EACR,MAAM,EACJ,IAAI,YACF,mBAAmB,YAAY,SAAS,KAAK,GAAG,EAChDA,SAAW,KAAK,GACjB,EACF,EACF;GACF;UACM,OAAO;AACd,MAAI,iBAAiB,iBAAkB,OAAM;AAC7C,QAAM,IAAI,iBACR,qBAAqB,uBACrB,gCAAgC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACvF"}
|
|
1
|
+
{"version":3,"file":"lcd-adapter.js","names":["cosmwasmNs"],"sources":["../src/lcd-adapter.ts"],"sourcesContent":["import { toBase64, toUtf8 } from '@cosmjs/encoding';\nimport {\n cosmos,\n cosmwasm as cosmwasmNs,\n liftedinit,\n} from '@manifest-network/manifestjs';\nimport type { ManifestQueryClient } from './client.js';\nimport { logger } from './logger.js';\nimport { ManifestMCPError, ManifestMCPErrorCode } from './types.js';\n\nfunction snakeToCamel(s: string): string {\n return s.replace(/_(.)/g, (_, c: string) => c.toUpperCase());\n}\n\nfunction snakeToCamelDeep(obj: unknown): unknown {\n if (Array.isArray(obj)) {\n return obj.map(snakeToCamelDeep);\n }\n if (\n obj !== null &&\n typeof obj === 'object' &&\n !(obj instanceof Date) &&\n !(obj instanceof Uint8Array)\n ) {\n return Object.fromEntries(\n Object.entries(obj as Record<string, unknown>).map(([k, v]) => [\n snakeToCamel(k),\n snakeToCamelDeep(v),\n ]),\n );\n }\n return obj;\n}\n\nfunction ucFirst(s: string): string {\n return s.charAt(0).toUpperCase() + s.slice(1);\n}\n\ninterface Converter {\n fromJSON(object: unknown): unknown;\n}\n\nfunction findConverter(\n namespace: Record<string, unknown>,\n methodName: string,\n): Converter {\n const uc = ucFirst(methodName);\n const queryName = `Query${uc}Response`;\n const plainName = `${uc}Response`;\n\n const converter = (namespace[queryName] ?? namespace[plainName]) as\n | Converter\n | undefined;\n if (!converter?.fromJSON) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.QUERY_FAILED,\n `No response converter found for method \"${methodName}\" (tried \"${queryName}\" and \"${plainName}\")`,\n );\n }\n return converter;\n}\n\ntype AsyncFn = (...args: unknown[]) => Promise<unknown>;\n\nfunction adaptModule(\n lcdMod: unknown,\n converterNs: unknown,\n): Record<string, AsyncFn> {\n const lcdModule = lcdMod as Record<string, unknown>;\n const converterNamespace = converterNs as Record<string, unknown>;\n const adapted: Record<string, AsyncFn> = {};\n\n for (const key of Object.keys(lcdModule)) {\n if (key === 'req' || typeof lcdModule[key] !== 'function') continue;\n\n const originalFn = lcdModule[key] as AsyncFn;\n const converter = findConverter(converterNamespace, key);\n\n adapted[key] = async (...args: unknown[]) => {\n let sdkResult: unknown;\n try {\n sdkResult = await originalFn.call(lcdModule, ...args);\n } catch (error) {\n if (error instanceof ManifestMCPError) throw error;\n throw new ManifestMCPError(\n ManifestMCPErrorCode.QUERY_FAILED,\n `LCD query \"${key}\" failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const camelCased = snakeToCamelDeep(sdkResult);\n try {\n return converter.fromJSON(camelCased);\n } catch (error) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.QUERY_FAILED,\n `Failed to convert LCD response for \"${key}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n };\n }\n\n return adapted;\n}\n\nfunction unsupportedModule(modulePath: string): unknown {\n return new Proxy(\n {},\n {\n get(_target, prop) {\n if (typeof prop === 'string') {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.UNSUPPORTED_QUERY,\n `Module \"${modulePath}\" is not available via LCD/REST. Use an RPC endpoint instead.`,\n );\n }\n return undefined;\n },\n },\n );\n}\n\n/**\n * The generated LCD client interpolates `queryData` (Uint8Array) directly into\n * the URL path via template literal, producing comma-separated byte values\n * (e.g. `smart/123,34,99,...`) instead of base64. The REST API expects base64.\n * Patch the methods to convert queryData before the URL is constructed.\n */\nfunction patchWasmQueryData(wasmLcd: unknown): Record<string, unknown> {\n const mod = wasmLcd as Record<string, unknown>;\n const patched: Record<string, unknown> = { ...mod };\n for (const method of ['smartContractState', 'rawContractState']) {\n const original = mod[method] as (\n params: Record<string, unknown>,\n ) => Promise<unknown>;\n if (typeof original !== 'function') {\n logger.warn(\n `patchWasmQueryData: expected method \"${method}\" not found on wasm LCD module. Wasm queries may fail with malformed URLs.`,\n );\n continue;\n }\n patched[method] = async (params: Record<string, unknown>) => {\n const queryData = params.queryData;\n const result = (await original.call(mod, {\n ...params,\n queryData:\n queryData instanceof Uint8Array ? toBase64(queryData) : queryData,\n })) as Record<string, unknown>;\n\n // The LCD REST API returns `data` as a parsed JSON object, but the\n // protobuf `fromJSON` converter expects a base64 string representing\n // the UTF-8 bytes of the JSON payload. Re-encode so the adapter's\n // normal snakeToCamel → fromJSON pipeline works correctly.\n if (result.data != null && typeof result.data !== 'string') {\n return {\n ...result,\n data: toBase64(toUtf8(JSON.stringify(result.data))),\n };\n }\n return result;\n };\n }\n return patched;\n}\n\nexport async function createLCDQueryClient(\n restEndpoint: string,\n): Promise<ManifestQueryClient> {\n let lcd: Awaited<ReturnType<typeof liftedinit.ClientFactory.createLCDClient>>;\n let cosmwasmLcd: Awaited<\n ReturnType<typeof cosmwasmNs.ClientFactory.createLCDClient>\n >;\n try {\n [lcd, cosmwasmLcd] = await Promise.all([\n liftedinit.ClientFactory.createLCDClient({ restEndpoint }),\n cosmwasmNs.ClientFactory.createLCDClient({ restEndpoint }),\n ]);\n } catch (error) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.RPC_CONNECTION_FAILED,\n `Failed to create LCD client for ${restEndpoint}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n try {\n return {\n cosmos: {\n auth: {\n v1beta1: adaptModule(lcd.cosmos.auth.v1beta1, cosmos.auth.v1beta1),\n },\n authz: {\n v1beta1: adaptModule(lcd.cosmos.authz.v1beta1, cosmos.authz.v1beta1),\n },\n bank: {\n v1beta1: adaptModule(lcd.cosmos.bank.v1beta1, cosmos.bank.v1beta1),\n },\n base: {\n node: {\n v1beta1: adaptModule(\n lcd.cosmos.base.node.v1beta1,\n cosmos.base.node.v1beta1,\n ),\n },\n },\n circuit: { v1: adaptModule(lcd.cosmos.circuit.v1, cosmos.circuit.v1) },\n consensus: {\n v1: adaptModule(lcd.cosmos.consensus.v1, cosmos.consensus.v1),\n },\n distribution: {\n v1beta1: adaptModule(\n lcd.cosmos.distribution.v1beta1,\n cosmos.distribution.v1beta1,\n ),\n },\n feegrant: {\n v1beta1: adaptModule(\n lcd.cosmos.feegrant.v1beta1,\n cosmos.feegrant.v1beta1,\n ),\n },\n gov: {\n v1: adaptModule(lcd.cosmos.gov.v1, cosmos.gov.v1),\n v1beta1: adaptModule(lcd.cosmos.gov.v1beta1, cosmos.gov.v1beta1),\n },\n group: { v1: adaptModule(lcd.cosmos.group.v1, cosmos.group.v1) },\n mint: {\n v1beta1: adaptModule(lcd.cosmos.mint.v1beta1, cosmos.mint.v1beta1),\n },\n orm: {\n query: { v1alpha1: unsupportedModule('cosmos.orm.query.v1alpha1') },\n },\n params: {\n v1beta1: adaptModule(\n lcd.cosmos.params.v1beta1,\n cosmos.params.v1beta1,\n ),\n },\n staking: {\n v1beta1: adaptModule(\n lcd.cosmos.staking.v1beta1,\n cosmos.staking.v1beta1,\n ),\n },\n tx: { v1beta1: adaptModule(lcd.cosmos.tx.v1beta1, cosmos.tx.v1beta1) },\n upgrade: {\n v1beta1: adaptModule(\n lcd.cosmos.upgrade.v1beta1,\n cosmos.upgrade.v1beta1,\n ),\n },\n },\n liftedinit: {\n billing: {\n v1: adaptModule(lcd.liftedinit.billing.v1, liftedinit.billing.v1),\n },\n manifest: { v1: unsupportedModule('liftedinit.manifest.v1') },\n sku: { v1: adaptModule(lcd.liftedinit.sku.v1, liftedinit.sku.v1) },\n },\n cosmwasm: {\n wasm: {\n v1: adaptModule(\n patchWasmQueryData(cosmwasmLcd.cosmwasm.wasm.v1),\n cosmwasmNs.wasm.v1,\n ),\n },\n },\n } as ManifestQueryClient;\n } catch (error) {\n if (error instanceof ManifestMCPError) throw error;\n throw new ManifestMCPError(\n ManifestMCPErrorCode.RPC_CONNECTION_FAILED,\n `Failed to adapt LCD modules: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n\n// Re-export for testing\nexport {\n adaptModule as _adaptModule,\n findConverter as _findConverter,\n patchWasmQueryData as _patchWasmQueryData,\n snakeToCamelDeep as _snakeToCamelDeep,\n unsupportedModule as _unsupportedModule,\n};\n"],"mappings":";;;;;AAUA,SAAS,aAAa,GAAmB;AACvC,QAAO,EAAE,QAAQ,UAAU,GAAG,MAAc,EAAE,aAAa,CAAC;;AAG9D,SAAS,iBAAiB,KAAuB;AAC/C,KAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,IAAI,iB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IAAI,OAAO,QAAQ,SACnB,OAAO,QAAQ,QAChB,EACF;IACF;GACD,YAAY;IACV,SAAS,EACP,IAAI,YAAY,IAAI,WAAW,QAAQ,IAAI,WAAW,QAAQ,GAAG,EAClE;IACD,UAAU,EAAE,IAAI,kBAAkB,yBAAyB,EAAE;IAC7D,KAAK,EAAE,IAAI,YAAY,IAAI,WAAW,IAAI,IAAI,WAAW,IAAI,GAAG,EAAE;IACnE;GACD,UAAU,EACR,MAAM,EACJ,IAAI,YACF,mBAAmB,YAAY,SAAS,KAAK,GAAG,EAChDA,SAAW,KAAK,GACjB,EACF,EACF;GACF;UACM,OAAO;AACd,MAAI,iBAAiB,iBAAkB,OAAM;AAC7C,QAAM,IAAI,iBACR,qBAAqB,uBACrB,gCAAgC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACvF"}
|
package/dist/modules.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AvailableModules, CosmosTxResult, ModuleInfo, QueryResult, TxOptions } from "./types.js";
|
|
1
|
+
import { AvailableModules, BuiltMessages, CosmosTxResult, ModuleInfo, QueryResult, TxOptions } from "./types.js";
|
|
2
2
|
import { ManifestQueryClient } from "./client.js";
|
|
3
3
|
import { SigningStargateClient } from "@cosmjs/stargate";
|
|
4
4
|
|
|
@@ -11,6 +11,11 @@ type QueryHandler = (queryClient: ManifestQueryClient, subcommand: string, args:
|
|
|
11
11
|
* Handler function type for transaction modules
|
|
12
12
|
*/
|
|
13
13
|
type TxHandler = (signingClient: SigningStargateClient, senderAddress: string, subcommand: string, args: string[], waitForConfirmation: boolean, options?: TxOptions) => Promise<CosmosTxResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Pure synchronous function type for building transaction messages.
|
|
16
|
+
* Used by `cosmosEstimateFee` to obtain `EncodeObject[]` without signing/broadcasting.
|
|
17
|
+
*/
|
|
18
|
+
type TxMsgBuilder = (senderAddress: string, subcommand: string, args: string[]) => BuiltMessages;
|
|
14
19
|
/**
|
|
15
20
|
* Throw an error for an unsupported subcommand.
|
|
16
21
|
* Automatically looks up available subcommands from the module registry.
|
|
@@ -58,6 +63,11 @@ declare function getQueryHandler(module: string): QueryHandler;
|
|
|
58
63
|
* @throws ManifestMCPError if module is not found
|
|
59
64
|
*/
|
|
60
65
|
declare function getTxHandler(module: string): TxHandler;
|
|
66
|
+
/**
|
|
67
|
+
* Get the message builder function for a transaction module
|
|
68
|
+
* @throws ManifestMCPError if module is not found
|
|
69
|
+
*/
|
|
70
|
+
declare function getTxMsgBuilder(module: string): TxMsgBuilder;
|
|
61
71
|
//#endregion
|
|
62
|
-
export { QueryHandler, TxHandler, getAvailableModules, getModuleSubcommands, getQueryHandler, getSubcommandUsage, getSupportedModules, getTxHandler, isSubcommandSupported, throwUnsupportedSubcommand };
|
|
72
|
+
export { QueryHandler, TxHandler, TxMsgBuilder, getAvailableModules, getModuleSubcommands, getQueryHandler, getSubcommandUsage, getSupportedModules, getTxHandler, getTxMsgBuilder, isSubcommandSupported, throwUnsupportedSubcommand };
|
|
63
73
|
//# sourceMappingURL=modules.d.ts.map
|
package/dist/modules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.d.ts","names":[],"sources":["../src/modules.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"modules.d.ts","names":[],"sources":["../src/modules.ts"],"mappings":";;;;;;;AA0DA;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;;;;iBAwqBc,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;AAhwBF;;;AAAA,iBAgxBgB,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"}
|
package/dist/modules.js
CHANGED
|
@@ -8,15 +8,15 @@ import { routeGroupQuery } from "./queries/group.js";
|
|
|
8
8
|
import { routeSkuQuery } from "./queries/sku.js";
|
|
9
9
|
import { routeStakingQuery } from "./queries/staking.js";
|
|
10
10
|
import { routeWasmQuery } from "./queries/wasm.js";
|
|
11
|
-
import { routeBankTransaction } from "./transactions/bank.js";
|
|
12
|
-
import { routeBillingTransaction } from "./transactions/billing.js";
|
|
13
|
-
import { routeDistributionTransaction } from "./transactions/distribution.js";
|
|
14
|
-
import { routeGovTransaction } from "./transactions/gov.js";
|
|
15
|
-
import { routeGroupTransaction } from "./transactions/group.js";
|
|
16
|
-
import { routeManifestTransaction } from "./transactions/manifest.js";
|
|
17
|
-
import { routeSkuTransaction } from "./transactions/sku.js";
|
|
18
|
-
import { routeStakingTransaction } from "./transactions/staking.js";
|
|
19
|
-
import { routeWasmTransaction } from "./transactions/wasm.js";
|
|
11
|
+
import { buildBankMessages, routeBankTransaction } from "./transactions/bank.js";
|
|
12
|
+
import { buildBillingMessages, routeBillingTransaction } from "./transactions/billing.js";
|
|
13
|
+
import { buildDistributionMessages, routeDistributionTransaction } from "./transactions/distribution.js";
|
|
14
|
+
import { buildGovMessages, routeGovTransaction } from "./transactions/gov.js";
|
|
15
|
+
import { buildGroupMessages, routeGroupTransaction } from "./transactions/group.js";
|
|
16
|
+
import { buildManifestMessages, routeManifestTransaction } from "./transactions/manifest.js";
|
|
17
|
+
import { buildSkuMessages, routeSkuTransaction } from "./transactions/sku.js";
|
|
18
|
+
import { buildStakingMessages, routeStakingTransaction } from "./transactions/staking.js";
|
|
19
|
+
import { buildWasmMessages, routeWasmTransaction } from "./transactions/wasm.js";
|
|
20
20
|
//#region src/modules.ts
|
|
21
21
|
/**
|
|
22
22
|
* Throw an error for an unsupported subcommand.
|
|
@@ -506,6 +506,7 @@ const TX_MODULES = {
|
|
|
506
506
|
bank: {
|
|
507
507
|
description: "Bank transaction subcommands",
|
|
508
508
|
handler: routeBankTransaction,
|
|
509
|
+
msgBuilder: buildBankMessages,
|
|
509
510
|
subcommands: [{
|
|
510
511
|
name: "send",
|
|
511
512
|
description: "Send tokens to another account",
|
|
@@ -519,6 +520,7 @@ const TX_MODULES = {
|
|
|
519
520
|
staking: {
|
|
520
521
|
description: "Staking transaction subcommands",
|
|
521
522
|
handler: routeStakingTransaction,
|
|
523
|
+
msgBuilder: buildStakingMessages,
|
|
522
524
|
subcommands: [
|
|
523
525
|
{
|
|
524
526
|
name: "delegate",
|
|
@@ -541,6 +543,7 @@ const TX_MODULES = {
|
|
|
541
543
|
distribution: {
|
|
542
544
|
description: "Distribution transaction subcommands",
|
|
543
545
|
handler: routeDistributionTransaction,
|
|
546
|
+
msgBuilder: buildDistributionMessages,
|
|
544
547
|
subcommands: [
|
|
545
548
|
{
|
|
546
549
|
name: "withdraw-rewards",
|
|
@@ -559,6 +562,7 @@ const TX_MODULES = {
|
|
|
559
562
|
gov: {
|
|
560
563
|
description: "Governance transaction subcommands",
|
|
561
564
|
handler: routeGovTransaction,
|
|
565
|
+
msgBuilder: buildGovMessages,
|
|
562
566
|
subcommands: [
|
|
563
567
|
{
|
|
564
568
|
name: "vote",
|
|
@@ -577,6 +581,7 @@ const TX_MODULES = {
|
|
|
577
581
|
billing: {
|
|
578
582
|
description: "Manifest billing transaction subcommands",
|
|
579
583
|
handler: routeBillingTransaction,
|
|
584
|
+
msgBuilder: buildBillingMessages,
|
|
580
585
|
subcommands: [
|
|
581
586
|
{
|
|
582
587
|
name: "fund-credit",
|
|
@@ -628,6 +633,7 @@ const TX_MODULES = {
|
|
|
628
633
|
manifest: {
|
|
629
634
|
description: "Manifest module transaction subcommands",
|
|
630
635
|
handler: routeManifestTransaction,
|
|
636
|
+
msgBuilder: buildManifestMessages,
|
|
631
637
|
subcommands: [{
|
|
632
638
|
name: "payout",
|
|
633
639
|
description: "Execute a payout to multiple addresses"
|
|
@@ -639,6 +645,7 @@ const TX_MODULES = {
|
|
|
639
645
|
sku: {
|
|
640
646
|
description: "Manifest SKU module transaction subcommands",
|
|
641
647
|
handler: routeSkuTransaction,
|
|
648
|
+
msgBuilder: buildSkuMessages,
|
|
642
649
|
subcommands: [
|
|
643
650
|
{
|
|
644
651
|
name: "create-provider",
|
|
@@ -680,6 +687,7 @@ const TX_MODULES = {
|
|
|
680
687
|
group: {
|
|
681
688
|
description: "Group module transaction subcommands",
|
|
682
689
|
handler: routeGroupTransaction,
|
|
690
|
+
msgBuilder: buildGroupMessages,
|
|
683
691
|
subcommands: [
|
|
684
692
|
{
|
|
685
693
|
name: "create-group",
|
|
@@ -756,6 +764,7 @@ const TX_MODULES = {
|
|
|
756
764
|
wasm: {
|
|
757
765
|
description: "CosmWasm wasm transaction subcommands",
|
|
758
766
|
handler: routeWasmTransaction,
|
|
767
|
+
msgBuilder: buildWasmMessages,
|
|
759
768
|
subcommands: [
|
|
760
769
|
{
|
|
761
770
|
name: "store-code",
|
|
@@ -870,7 +879,16 @@ function getTxHandler(module) {
|
|
|
870
879
|
if (!moduleInfo) throw new ManifestMCPError(ManifestMCPErrorCode.UNKNOWN_MODULE, `Unknown tx module: ${module}`, { availableModules: Object.keys(TX_MODULES) });
|
|
871
880
|
return moduleInfo.handler;
|
|
872
881
|
}
|
|
882
|
+
/**
|
|
883
|
+
* Get the message builder function for a transaction module
|
|
884
|
+
* @throws ManifestMCPError if module is not found
|
|
885
|
+
*/
|
|
886
|
+
function getTxMsgBuilder(module) {
|
|
887
|
+
const moduleInfo = TX_MODULES[module];
|
|
888
|
+
if (!moduleInfo) throw new ManifestMCPError(ManifestMCPErrorCode.UNKNOWN_MODULE, `Unknown tx module: ${module}`, { availableModules: Object.keys(TX_MODULES) });
|
|
889
|
+
return moduleInfo.msgBuilder;
|
|
890
|
+
}
|
|
873
891
|
//#endregion
|
|
874
|
-
export { getAvailableModules, getModuleSubcommands, getQueryHandler, getSubcommandUsage, getSupportedModules, getTxHandler, isSubcommandSupported, throwUnsupportedSubcommand };
|
|
892
|
+
export { getAvailableModules, getModuleSubcommands, getQueryHandler, getSubcommandUsage, getSupportedModules, getTxHandler, getTxMsgBuilder, isSubcommandSupported, throwUnsupportedSubcommand };
|
|
875
893
|
|
|
876
894
|
//# sourceMappingURL=modules.js.map
|