@manifest-network/manifest-mcp-browser 0.1.7 → 0.1.9

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 (89) hide show
  1. package/README.md +5 -2
  2. package/dist/client.d.ts +5 -2
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +8 -2
  5. package/dist/client.js.map +1 -1
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js +0 -10
  8. package/dist/config.js.map +1 -1
  9. package/dist/index.d.ts +0 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +4 -8
  12. package/dist/index.js.map +1 -1
  13. package/dist/queries/index.d.ts +1 -0
  14. package/dist/queries/index.d.ts.map +1 -1
  15. package/dist/queries/index.js +1 -0
  16. package/dist/queries/index.js.map +1 -1
  17. package/dist/transactions/bank.d.ts.map +1 -1
  18. package/dist/transactions/bank.js +7 -5
  19. package/dist/transactions/bank.js.map +1 -1
  20. package/dist/transactions/gov.d.ts.map +1 -1
  21. package/dist/transactions/gov.js +7 -5
  22. package/dist/transactions/gov.js.map +1 -1
  23. package/dist/transactions/index.d.ts +1 -0
  24. package/dist/transactions/index.d.ts.map +1 -1
  25. package/dist/transactions/index.js +1 -0
  26. package/dist/transactions/index.js.map +1 -1
  27. package/dist/transactions/utils.d.ts.map +1 -1
  28. package/dist/transactions/utils.js +5 -6
  29. package/dist/transactions/utils.js.map +1 -1
  30. package/dist/types.d.ts +2 -4
  31. package/dist/types.d.ts.map +1 -1
  32. package/dist/types.js.map +1 -1
  33. package/dist/version.d.ts +2 -0
  34. package/dist/version.d.ts.map +1 -0
  35. package/dist/version.js +2 -0
  36. package/dist/version.js.map +1 -0
  37. package/package.json +13 -3
  38. package/.github/workflows/ci.yml +0 -37
  39. package/.github/workflows/publish.yml +0 -53
  40. package/CLAUDE.md +0 -113
  41. package/dist/config.test.d.ts +0 -2
  42. package/dist/config.test.d.ts.map +0 -1
  43. package/dist/config.test.js +0 -251
  44. package/dist/config.test.js.map +0 -1
  45. package/dist/modules.test.d.ts +0 -2
  46. package/dist/modules.test.d.ts.map +0 -1
  47. package/dist/modules.test.js +0 -161
  48. package/dist/modules.test.js.map +0 -1
  49. package/dist/queries/utils.test.d.ts +0 -2
  50. package/dist/queries/utils.test.d.ts.map +0 -1
  51. package/dist/queries/utils.test.js +0 -117
  52. package/dist/queries/utils.test.js.map +0 -1
  53. package/dist/transactions/utils.test.d.ts +0 -2
  54. package/dist/transactions/utils.test.d.ts.map +0 -1
  55. package/dist/transactions/utils.test.js +0 -567
  56. package/dist/transactions/utils.test.js.map +0 -1
  57. package/src/client.ts +0 -288
  58. package/src/config.test.ts +0 -299
  59. package/src/config.ts +0 -174
  60. package/src/cosmos.ts +0 -106
  61. package/src/index.ts +0 -478
  62. package/src/modules.test.ts +0 -191
  63. package/src/modules.ts +0 -470
  64. package/src/queries/auth.ts +0 -97
  65. package/src/queries/bank.ts +0 -99
  66. package/src/queries/billing.ts +0 -124
  67. package/src/queries/distribution.ts +0 -114
  68. package/src/queries/gov.ts +0 -104
  69. package/src/queries/group.ts +0 -146
  70. package/src/queries/index.ts +0 -17
  71. package/src/queries/sku.ts +0 -85
  72. package/src/queries/staking.ts +0 -154
  73. package/src/queries/utils.test.ts +0 -156
  74. package/src/queries/utils.ts +0 -121
  75. package/src/transactions/bank.ts +0 -86
  76. package/src/transactions/billing.ts +0 -286
  77. package/src/transactions/distribution.ts +0 -76
  78. package/src/transactions/gov.ts +0 -164
  79. package/src/transactions/group.ts +0 -458
  80. package/src/transactions/index.ts +0 -8
  81. package/src/transactions/manifest.ts +0 -67
  82. package/src/transactions/sku.ts +0 -232
  83. package/src/transactions/staking.ts +0 -85
  84. package/src/transactions/utils.test.ts +0 -626
  85. package/src/transactions/utils.ts +0 -417
  86. package/src/types.ts +0 -548
  87. package/src/wallet/index.ts +0 -2
  88. package/src/wallet/mnemonic.ts +0 -146
  89. package/tsconfig.json +0 -23
package/src/modules.ts DELETED
@@ -1,470 +0,0 @@
1
- import { SigningStargateClient } from '@cosmjs/stargate';
2
- import { ModuleInfo, AvailableModules, ManifestMCPError, ManifestMCPErrorCode, CosmosTxResult, QueryResult } from './types.js';
3
- import { ManifestQueryClient } from './client.js';
4
-
5
- // Import query handlers
6
- import { routeBankQuery } from './queries/bank.js';
7
- import { routeStakingQuery } from './queries/staking.js';
8
- import { routeDistributionQuery } from './queries/distribution.js';
9
- import { routeGovQuery } from './queries/gov.js';
10
- import { routeAuthQuery } from './queries/auth.js';
11
- import { routeBillingQuery } from './queries/billing.js';
12
- import { routeSkuQuery } from './queries/sku.js';
13
- import { routeGroupQuery } from './queries/group.js';
14
-
15
- // Import transaction handlers
16
- import { routeBankTransaction } from './transactions/bank.js';
17
- import { routeStakingTransaction } from './transactions/staking.js';
18
- import { routeDistributionTransaction } from './transactions/distribution.js';
19
- import { routeGovTransaction } from './transactions/gov.js';
20
- import { routeBillingTransaction } from './transactions/billing.js';
21
- import { routeManifestTransaction } from './transactions/manifest.js';
22
- import { routeSkuTransaction } from './transactions/sku.js';
23
- import { routeGroupTransaction } from './transactions/group.js';
24
-
25
- /**
26
- * Handler function type for query modules
27
- */
28
- export type QueryHandler = (
29
- queryClient: ManifestQueryClient,
30
- subcommand: string,
31
- args: string[]
32
- ) => Promise<QueryResult>;
33
-
34
- /**
35
- * Handler function type for transaction modules
36
- */
37
- export type TxHandler = (
38
- signingClient: SigningStargateClient,
39
- senderAddress: string,
40
- subcommand: string,
41
- args: string[],
42
- waitForConfirmation: boolean
43
- ) => Promise<CosmosTxResult>;
44
-
45
- /**
46
- * Throw an error for an unsupported subcommand.
47
- * Automatically looks up available subcommands from the module registry.
48
- *
49
- * @param type - 'query' or 'tx'
50
- * @param module - The module name (e.g., 'bank', 'staking')
51
- * @param subcommand - The unsupported subcommand that was requested
52
- */
53
- export function throwUnsupportedSubcommand(
54
- type: 'query' | 'tx',
55
- module: string,
56
- subcommand: string
57
- ): never {
58
- const registry = type === 'query' ? QUERY_MODULES : TX_MODULES;
59
- const moduleInfo = registry[module];
60
- const availableSubcommands = moduleInfo?.subcommands.map(s => s.name) ?? [];
61
-
62
- throw new ManifestMCPError(
63
- type === 'query' ? ManifestMCPErrorCode.UNSUPPORTED_QUERY : ManifestMCPErrorCode.UNSUPPORTED_TX,
64
- `Unsupported ${module} ${type === 'query' ? 'query' : 'transaction'} subcommand: ${subcommand}`,
65
- { availableSubcommands }
66
- );
67
- }
68
-
69
- /**
70
- * Static module registry for browser-compatible module discovery
71
- * All modules use manifestjs for full protobuf support
72
- */
73
-
74
- interface SubcommandInfo {
75
- name: string;
76
- description: string;
77
- args?: string; // Usage hint for arguments
78
- }
79
-
80
- interface QueryModuleRegistry {
81
- [moduleName: string]: {
82
- description: string;
83
- subcommands: SubcommandInfo[];
84
- handler: QueryHandler;
85
- };
86
- }
87
-
88
- interface TxModuleRegistry {
89
- [moduleName: string]: {
90
- description: string;
91
- subcommands: SubcommandInfo[];
92
- handler: TxHandler;
93
- };
94
- }
95
-
96
- /**
97
- * Query modules registry
98
- * Each module includes metadata and its handler function
99
- */
100
- const QUERY_MODULES: QueryModuleRegistry = {
101
- bank: {
102
- description: 'Querying commands for the bank module',
103
- handler: routeBankQuery,
104
- subcommands: [
105
- { name: 'balance', description: 'Query account balance for a specific denom' },
106
- { name: 'balances', description: 'Query all balances for an account' },
107
- { name: 'spendable-balances', description: 'Query spendable balances for an account' },
108
- { name: 'total-supply', description: 'Query total supply of all tokens' },
109
- { name: 'total', description: 'Query total supply of all tokens (alias for total-supply)' },
110
- { name: 'supply-of', description: 'Query supply of a specific denom' },
111
- { name: 'params', description: 'Query bank parameters' },
112
- { name: 'denom-metadata', description: 'Query metadata for a specific denom' },
113
- { name: 'denoms-metadata', description: 'Query metadata for all denoms' },
114
- { name: 'send-enabled', description: 'Query send enabled status for denoms' },
115
- ],
116
- },
117
- staking: {
118
- description: 'Querying commands for the staking module',
119
- handler: routeStakingQuery,
120
- subcommands: [
121
- { name: 'delegation', description: 'Query a delegation' },
122
- { name: 'delegations', description: 'Query all delegations for a delegator' },
123
- { name: 'unbonding-delegation', description: 'Query an unbonding delegation' },
124
- { name: 'unbonding-delegations', description: 'Query all unbonding delegations for a delegator' },
125
- { name: 'redelegations', description: 'Query redelegations' },
126
- { name: 'validator', description: 'Query a validator' },
127
- { name: 'validators', description: 'Query all validators' },
128
- { name: 'validator-delegations', description: 'Query all delegations to a validator' },
129
- { name: 'validator-unbonding-delegations', description: 'Query all unbonding delegations from a validator' },
130
- { name: 'pool', description: 'Query staking pool' },
131
- { name: 'params', description: 'Query staking parameters' },
132
- { name: 'historical-info', description: 'Query historical info at a height' },
133
- ],
134
- },
135
- distribution: {
136
- description: 'Querying commands for the distribution module',
137
- handler: routeDistributionQuery,
138
- subcommands: [
139
- { name: 'rewards', description: 'Query distribution rewards for a delegator' },
140
- { name: 'commission', description: 'Query validator commission' },
141
- { name: 'community-pool', description: 'Query community pool coins' },
142
- { name: 'params', description: 'Query distribution parameters' },
143
- { name: 'validator-outstanding-rewards', description: 'Query validator outstanding rewards' },
144
- { name: 'slashes', description: 'Query slashes for a validator' },
145
- { name: 'delegator-validators', description: 'Query validators for a delegator' },
146
- { name: 'delegator-withdraw-address', description: 'Query delegator withdraw address' },
147
- ],
148
- },
149
- gov: {
150
- description: 'Querying commands for the governance module',
151
- handler: routeGovQuery,
152
- subcommands: [
153
- { name: 'proposal', description: 'Query a proposal by ID' },
154
- { name: 'proposals', description: 'Query all proposals' },
155
- { name: 'vote', description: 'Query a vote on a proposal' },
156
- { name: 'votes', description: 'Query all votes on a proposal' },
157
- { name: 'deposit', description: 'Query a deposit on a proposal' },
158
- { name: 'deposits', description: 'Query all deposits on a proposal' },
159
- { name: 'tally', description: 'Query tally of a proposal' },
160
- { name: 'params', description: 'Query governance parameters' },
161
- ],
162
- },
163
- auth: {
164
- description: 'Querying commands for the auth module',
165
- handler: routeAuthQuery,
166
- subcommands: [
167
- { name: 'account', description: 'Query account by address' },
168
- { name: 'accounts', description: 'Query all accounts' },
169
- { name: 'params', description: 'Query auth parameters' },
170
- { name: 'module-accounts', description: 'Query all module accounts' },
171
- { name: 'module-account-by-name', description: 'Query module account by name' },
172
- { name: 'address-bytes-to-string', description: 'Convert address bytes to string' },
173
- { name: 'address-string-to-bytes', description: 'Convert address string to bytes' },
174
- { name: 'bech32-prefix', description: 'Query bech32 prefix' },
175
- { name: 'account-info', description: 'Query account info' },
176
- ],
177
- },
178
- billing: {
179
- description: 'Querying commands for the Manifest billing module',
180
- handler: routeBillingQuery,
181
- subcommands: [
182
- { name: 'params', description: 'Query billing parameters' },
183
- { name: 'lease', description: 'Query a lease by UUID' },
184
- { name: 'leases', description: 'Query all leases' },
185
- { name: 'leases-by-tenant', description: 'Query leases by tenant address' },
186
- { name: 'leases-by-provider', description: 'Query leases by provider' },
187
- { name: 'leases-by-sku', description: 'Query leases by SKU UUID' },
188
- { name: 'credit-account', description: 'Query credit account for a tenant' },
189
- { name: 'credit-accounts', description: 'Query all credit accounts' },
190
- { name: 'credit-address', description: 'Query credit address for a tenant' },
191
- { name: 'withdrawable-amount', description: 'Query withdrawable amount for a lease' },
192
- { name: 'provider-withdrawable', description: 'Query withdrawable amount for a provider' },
193
- { name: 'credit-estimate', description: 'Query credit estimate for a tenant' },
194
- ],
195
- },
196
- sku: {
197
- description: 'Querying commands for the Manifest SKU module',
198
- handler: routeSkuQuery,
199
- subcommands: [
200
- { name: 'params', description: 'Query SKU module parameters' },
201
- { name: 'provider', description: 'Query a provider by UUID', args: '<provider-uuid>' },
202
- { name: 'providers', description: 'Query all providers', args: '[--active-only] [--limit N]' },
203
- { name: 'sku', description: 'Query a SKU by UUID', args: '<sku-uuid>' },
204
- { name: 'skus', description: 'Query all SKUs', args: '[--active-only] [--limit N]' },
205
- { name: 'skus-by-provider', description: 'Query SKUs by provider UUID', args: '<provider-uuid> [--active-only] [--limit N]' },
206
- { name: 'provider-by-address', description: 'Query providers by address', args: '<address> [--active-only] [--limit N]' },
207
- ],
208
- },
209
- group: {
210
- description: 'Querying commands for the group module',
211
- handler: routeGroupQuery,
212
- subcommands: [
213
- { name: 'group-info', description: 'Query group info by ID', args: '<group-id>' },
214
- { name: 'group-policy-info', description: 'Query group policy info by address', args: '<group-policy-address>' },
215
- { name: 'group-members', description: 'Query group members', args: '<group-id> [--limit N]' },
216
- { name: 'groups-by-admin', description: 'Query groups by admin address', args: '<admin-address> [--limit N]' },
217
- { name: 'group-policies-by-group', description: 'Query group policies by group ID', args: '<group-id> [--limit N]' },
218
- { name: 'group-policies-by-admin', description: 'Query group policies by admin address', args: '<admin-address> [--limit N]' },
219
- { name: 'proposal', description: 'Query a group proposal by ID', args: '<proposal-id>' },
220
- { name: 'proposals-by-group-policy', description: 'Query proposals by group policy address', args: '<group-policy-address> [--limit N]' },
221
- { name: 'vote', description: 'Query a vote by proposal ID and voter', args: '<proposal-id> <voter-address>' },
222
- { name: 'votes-by-proposal', description: 'Query votes by proposal ID', args: '<proposal-id> [--limit N]' },
223
- { name: 'votes-by-voter', description: 'Query votes by voter address', args: '<voter-address> [--limit N]' },
224
- { name: 'groups-by-member', description: 'Query groups by member address', args: '<member-address> [--limit N]' },
225
- { name: 'tally', description: 'Query tally result for a proposal', args: '<proposal-id>' },
226
- { name: 'groups', description: 'Query all groups', args: '[--limit N]' },
227
- ],
228
- },
229
- };
230
-
231
- /**
232
- * Transaction modules registry
233
- * Each module includes metadata and its handler function
234
- */
235
- const TX_MODULES: TxModuleRegistry = {
236
- bank: {
237
- description: 'Bank transaction subcommands',
238
- handler: routeBankTransaction,
239
- subcommands: [
240
- { name: 'send', description: 'Send tokens to another account', args: '<to-address> <amount> (e.g., manifest1abc... 1000000umfx)' },
241
- { name: 'multi-send', description: 'Send tokens to multiple accounts', args: '<to-address:amount>... (e.g., manifest1a:1000umfx manifest1b:2000umfx)' },
242
- ],
243
- },
244
- staking: {
245
- description: 'Staking transaction subcommands',
246
- handler: routeStakingTransaction,
247
- subcommands: [
248
- { name: 'delegate', description: 'Delegate tokens to a validator' },
249
- { name: 'unbond', description: 'Unbond tokens from a validator' },
250
- { name: 'undelegate', description: 'Unbond tokens from a validator (alias for unbond)' },
251
- { name: 'redelegate', description: 'Redelegate tokens from one validator to another' },
252
- ],
253
- },
254
- distribution: {
255
- description: 'Distribution transaction subcommands',
256
- handler: routeDistributionTransaction,
257
- subcommands: [
258
- { name: 'withdraw-rewards', description: 'Withdraw rewards from a validator' },
259
- { name: 'set-withdraw-addr', description: 'Set withdraw address' },
260
- { name: 'fund-community-pool', description: 'Fund the community pool' },
261
- ],
262
- },
263
- gov: {
264
- description: 'Governance transaction subcommands',
265
- handler: routeGovTransaction,
266
- subcommands: [
267
- { name: 'vote', description: 'Vote on a proposal' },
268
- { name: 'weighted-vote', description: 'Weighted vote on a proposal' },
269
- { name: 'deposit', description: 'Deposit tokens for a proposal' },
270
- ],
271
- },
272
- billing: {
273
- description: 'Manifest billing transaction subcommands',
274
- handler: routeBillingTransaction,
275
- subcommands: [
276
- { name: 'fund-credit', description: 'Fund credit for a tenant', args: '<tenant-address> <amount> (e.g., manifest1abc... 1000000umfx)' },
277
- { name: 'create-lease', description: 'Create a new lease', args: '[--meta-hash <hex>] <sku-uuid:quantity>... (e.g., sku-123:1 sku-456:2)' },
278
- { name: 'close-lease', description: 'Close one or more leases', args: '[--reason <text>] <lease-uuid>... (e.g., lease-123 lease-456)' },
279
- { name: 'withdraw', description: 'Withdraw earnings from leases', args: '<lease-uuid>... OR --provider <provider-uuid> [--limit <1-100>]' },
280
- { name: 'create-lease-for-tenant', description: 'Create a lease on behalf of a tenant', args: '<tenant-address> [--meta-hash <hex>] <sku-uuid:quantity>...' },
281
- { name: 'acknowledge-lease', description: 'Acknowledge one or more pending leases', args: '<lease-uuid>...' },
282
- { name: 'reject-lease', description: 'Reject one or more pending leases', args: '[--reason <text>] <lease-uuid>...' },
283
- { name: 'cancel-lease', description: 'Cancel one or more pending leases', args: '<lease-uuid>...' },
284
- { name: 'update-params', description: 'Update billing module parameters (governance)', args: '<max-leases-per-tenant> <max-items-per-lease> <min-lease-duration> <max-pending-leases-per-tenant> <pending-timeout> [<allowed-address>...]' },
285
- ],
286
- },
287
- manifest: {
288
- description: 'Manifest module transaction subcommands',
289
- handler: routeManifestTransaction,
290
- subcommands: [
291
- { name: 'payout', description: 'Execute a payout to multiple addresses' },
292
- { name: 'burn-held-balance', description: 'Burn held balance' },
293
- ],
294
- },
295
- sku: {
296
- description: 'Manifest SKU module transaction subcommands',
297
- handler: routeSkuTransaction,
298
- subcommands: [
299
- { name: 'create-provider', description: 'Create a new provider', args: '<address> <payout-address> <api-url> [--meta-hash <hex>]' },
300
- { name: 'update-provider', description: 'Update an existing provider', args: '<provider-uuid> <address> <payout-address> <api-url> [--meta-hash <hex>] [--active <true|false>]' },
301
- { name: 'deactivate-provider', description: 'Deactivate a provider', args: '<provider-uuid>' },
302
- { name: 'create-sku', description: 'Create a new SKU', args: '<provider-uuid> <name> <unit (per-hour|per-day)> <base-price> [--meta-hash <hex>]' },
303
- { name: 'update-sku', description: 'Update an existing SKU', args: '<sku-uuid> <provider-uuid> <name> <unit (per-hour|per-day)> <base-price> [--meta-hash <hex>] [--active <true|false>]' },
304
- { name: 'deactivate-sku', description: 'Deactivate a SKU', args: '<sku-uuid>' },
305
- { name: 'update-params', description: 'Update SKU module parameters (governance)', args: '<allowed-address>...' },
306
- ],
307
- },
308
- group: {
309
- description: 'Group module transaction subcommands',
310
- handler: routeGroupTransaction,
311
- subcommands: [
312
- { name: 'create-group', description: 'Create a new group', args: '<metadata> <address:weight>...' },
313
- { name: 'update-group-members', description: 'Update group members', args: '<group-id> <address:weight>...' },
314
- { name: 'update-group-admin', description: 'Update group admin', args: '<group-id> <new-admin-address>' },
315
- { name: 'update-group-metadata', description: 'Update group metadata', args: '<group-id> <metadata>' },
316
- { name: 'create-group-policy', description: 'Create a group policy', args: '<group-id> <metadata> <policy-type> <threshold-or-pct> <voting-period-secs> <min-execution-period-secs>' },
317
- { name: 'update-group-policy-admin', description: 'Update group policy admin', args: '<group-policy-address> <new-admin-address>' },
318
- { name: 'create-group-with-policy', description: 'Create a group with policy', args: '<group-metadata> <group-policy-metadata> <policy-type> <threshold-or-pct> <voting-period-secs> <min-execution-period-secs> [--group-policy-as-admin] <address:weight>...' },
319
- { name: 'update-group-policy-decision-policy', description: 'Update group policy decision policy', args: '<group-policy-address> <policy-type> <threshold-or-pct> <voting-period-secs> <min-execution-period-secs>' },
320
- { name: 'update-group-policy-metadata', description: 'Update group policy metadata', args: '<group-policy-address> <metadata>' },
321
- { name: 'submit-proposal', description: 'Submit a group proposal', args: '<group-policy-address> <title> <summary> [--exec try] [--metadata <text>] [<message-json>...]' },
322
- { name: 'withdraw-proposal', description: 'Withdraw a group proposal', args: '<proposal-id>' },
323
- { name: 'vote', description: 'Vote on a group proposal', args: '<proposal-id> <option (yes|no|abstain|no_with_veto)> [--metadata <text>] [--exec try]' },
324
- { name: 'exec', description: 'Execute a passed group proposal', args: '<proposal-id>' },
325
- { name: 'leave-group', description: 'Leave a group', args: '<group-id>' },
326
- ],
327
- },
328
- };
329
-
330
- /**
331
- * Get all available query and transaction modules
332
- */
333
- export function getAvailableModules(): AvailableModules {
334
- const queryModules: ModuleInfo[] = Object.entries(QUERY_MODULES).map(
335
- ([name, info]) => ({
336
- name,
337
- description: info.description,
338
- })
339
- );
340
-
341
- const txModules: ModuleInfo[] = Object.entries(TX_MODULES).map(
342
- ([name, info]) => ({
343
- name,
344
- description: info.description,
345
- })
346
- );
347
-
348
- return {
349
- queryModules,
350
- txModules,
351
- };
352
- }
353
-
354
- /**
355
- * Get available subcommands for a specific module
356
- */
357
- export function getModuleSubcommands(
358
- type: 'query' | 'tx',
359
- module: string
360
- ): ModuleInfo[] {
361
- const registry = type === 'query' ? QUERY_MODULES : TX_MODULES;
362
- const moduleInfo = registry[module];
363
-
364
- if (!moduleInfo) {
365
- throw new ManifestMCPError(
366
- ManifestMCPErrorCode.UNKNOWN_MODULE,
367
- `Unknown ${type} module: ${module}`,
368
- { availableModules: Object.keys(registry) }
369
- );
370
- }
371
-
372
- return moduleInfo.subcommands.map((sub) => ({
373
- name: sub.name,
374
- description: sub.description,
375
- args: sub.args,
376
- }));
377
- }
378
-
379
- /**
380
- * Check if a module/subcommand combination is supported
381
- */
382
- export function isSubcommandSupported(
383
- type: 'query' | 'tx',
384
- module: string,
385
- subcommand: string
386
- ): boolean {
387
- const registry = type === 'query' ? QUERY_MODULES : TX_MODULES;
388
- const moduleInfo = registry[module];
389
-
390
- if (!moduleInfo) {
391
- return false;
392
- }
393
-
394
- return moduleInfo.subcommands.some((s) => s.name === subcommand);
395
- }
396
-
397
- /**
398
- * Get usage help for a specific subcommand
399
- * Returns the args string if available, or undefined
400
- */
401
- export function getSubcommandUsage(
402
- type: 'query' | 'tx',
403
- module: string,
404
- subcommand: string
405
- ): string | undefined {
406
- const registry = type === 'query' ? QUERY_MODULES : TX_MODULES;
407
- const moduleInfo = registry[module];
408
-
409
- if (!moduleInfo) {
410
- return undefined;
411
- }
412
-
413
- const sub = moduleInfo.subcommands.find((s) => s.name === subcommand);
414
- return sub?.args;
415
- }
416
-
417
- /**
418
- * Get supported modules list
419
- */
420
- export function getSupportedModules(): {
421
- query: { [module: string]: string[] };
422
- tx: { [module: string]: string[] };
423
- } {
424
- const result = {
425
- query: {} as { [module: string]: string[] },
426
- tx: {} as { [module: string]: string[] },
427
- };
428
-
429
- for (const [module, info] of Object.entries(QUERY_MODULES)) {
430
- result.query[module] = info.subcommands.map((s) => s.name);
431
- }
432
-
433
- for (const [module, info] of Object.entries(TX_MODULES)) {
434
- result.tx[module] = info.subcommands.map((s) => s.name);
435
- }
436
-
437
- return result;
438
- }
439
-
440
- /**
441
- * Get the handler function for a query module
442
- * @throws ManifestMCPError if module is not found
443
- */
444
- export function getQueryHandler(module: string): QueryHandler {
445
- const moduleInfo = QUERY_MODULES[module];
446
- if (!moduleInfo) {
447
- throw new ManifestMCPError(
448
- ManifestMCPErrorCode.UNKNOWN_MODULE,
449
- `Unknown query module: ${module}`,
450
- { availableModules: Object.keys(QUERY_MODULES) }
451
- );
452
- }
453
- return moduleInfo.handler;
454
- }
455
-
456
- /**
457
- * Get the handler function for a transaction module
458
- * @throws ManifestMCPError if module is not found
459
- */
460
- export function getTxHandler(module: string): TxHandler {
461
- const moduleInfo = TX_MODULES[module];
462
- if (!moduleInfo) {
463
- throw new ManifestMCPError(
464
- ManifestMCPErrorCode.UNKNOWN_MODULE,
465
- `Unknown tx module: ${module}`,
466
- { availableModules: Object.keys(TX_MODULES) }
467
- );
468
- }
469
- return moduleInfo.handler;
470
- }
@@ -1,97 +0,0 @@
1
- import { ManifestQueryClient } from '../client.js';
2
- import {
3
- ManifestMCPErrorCode,
4
- AuthAccountResult, AuthAccountsResult, AuthParamsResult, ModuleAccountsResult,
5
- AddressBytesToStringResult, AddressStringToBytesResult, Bech32PrefixResult, AccountInfoResult
6
- } from '../types.js';
7
- import { requireArgs, extractPaginationArgs } from './utils.js';
8
- import { parseHexBytes, bytesToHex } from '../transactions/utils.js';
9
- import { throwUnsupportedSubcommand } from '../modules.js';
10
-
11
- /** Maximum address bytes length (256 bytes, more than enough for any address) */
12
- const MAX_ADDRESS_BYTES = 256;
13
-
14
- /** Auth query result union type */
15
- type AuthQueryResult =
16
- | AuthAccountResult
17
- | AuthAccountsResult
18
- | AuthParamsResult
19
- | ModuleAccountsResult
20
- | AddressBytesToStringResult
21
- | AddressStringToBytesResult
22
- | Bech32PrefixResult
23
- | AccountInfoResult;
24
-
25
- /**
26
- * Route auth query to manifestjs query client
27
- *
28
- * Paginated queries support --limit flag (default: 100, max: 1000)
29
- */
30
- export async function routeAuthQuery(
31
- queryClient: ManifestQueryClient,
32
- subcommand: string,
33
- args: string[]
34
- ): Promise<AuthQueryResult> {
35
- const auth = queryClient.cosmos.auth.v1beta1;
36
-
37
- switch (subcommand) {
38
- case 'account': {
39
- requireArgs(args, 1, ['address'], 'auth account');
40
- const [address] = args;
41
- const result = await auth.account({ address });
42
- return { account: result.account };
43
- }
44
-
45
- case 'accounts': {
46
- const { pagination } = extractPaginationArgs(args, 'auth accounts');
47
- const result = await auth.accounts({ pagination });
48
- return { accounts: result.accounts, pagination: result.pagination };
49
- }
50
-
51
- case 'params': {
52
- const result = await auth.params({});
53
- return { params: result.params };
54
- }
55
-
56
- case 'module-accounts': {
57
- const result = await auth.moduleAccounts({});
58
- return { accounts: result.accounts };
59
- }
60
-
61
- case 'module-account-by-name': {
62
- requireArgs(args, 1, ['name'], 'auth module-account-by-name');
63
- const [name] = args;
64
- const result = await auth.moduleAccountByName({ name });
65
- return { account: result.account };
66
- }
67
-
68
- case 'address-bytes-to-string': {
69
- requireArgs(args, 1, ['address-bytes'], 'auth address-bytes-to-string');
70
- const addressBytes = parseHexBytes(args[0], 'address-bytes', MAX_ADDRESS_BYTES, ManifestMCPErrorCode.QUERY_FAILED);
71
- const result = await auth.addressBytesToString({ addressBytes });
72
- return { addressString: result.addressString };
73
- }
74
-
75
- case 'address-string-to-bytes': {
76
- requireArgs(args, 1, ['address-string'], 'auth address-string-to-bytes');
77
- const [addressString] = args;
78
- const result = await auth.addressStringToBytes({ addressString });
79
- return { addressBytes: bytesToHex(result.addressBytes) };
80
- }
81
-
82
- case 'bech32-prefix': {
83
- const result = await auth.bech32Prefix({});
84
- return { bech32Prefix: result.bech32Prefix };
85
- }
86
-
87
- case 'account-info': {
88
- requireArgs(args, 1, ['address'], 'auth account-info');
89
- const [address] = args;
90
- const result = await auth.accountInfo({ address });
91
- return { info: result.info };
92
- }
93
-
94
- default:
95
- throwUnsupportedSubcommand('query', 'auth', subcommand);
96
- }
97
- }
@@ -1,99 +0,0 @@
1
- import { ManifestQueryClient } from '../client.js';
2
- import {
3
- BalanceResult, BalancesResult, TotalSupplyResult, SupplyOfResult,
4
- BankParamsResult, DenomMetadataResult, DenomsMetadataResult, SendEnabledResult
5
- } from '../types.js';
6
- import { requireArgs, extractPaginationArgs } from './utils.js';
7
- import { throwUnsupportedSubcommand } from '../modules.js';
8
-
9
- /** Bank query result union type */
10
- type BankQueryResult =
11
- | BalanceResult
12
- | BalancesResult
13
- | TotalSupplyResult
14
- | SupplyOfResult
15
- | BankParamsResult
16
- | DenomMetadataResult
17
- | DenomsMetadataResult
18
- | SendEnabledResult;
19
-
20
- /**
21
- * Route bank query to manifestjs query client
22
- *
23
- * Paginated queries support --limit flag (default: 100, max: 1000)
24
- */
25
- export async function routeBankQuery(
26
- queryClient: ManifestQueryClient,
27
- subcommand: string,
28
- args: string[]
29
- ): Promise<BankQueryResult> {
30
- const bank = queryClient.cosmos.bank.v1beta1;
31
-
32
- switch (subcommand) {
33
- case 'balance': {
34
- requireArgs(args, 2, ['address', 'denom'], 'bank balance');
35
- const [address, denom] = args;
36
- const result = await bank.balance({ address, denom });
37
- return { balance: result.balance };
38
- }
39
-
40
- case 'balances': {
41
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'bank balances');
42
- requireArgs(remainingArgs, 1, ['address'], 'bank balances');
43
- const [address] = remainingArgs;
44
- const result = await bank.allBalances({ address, resolveDenom: false, pagination });
45
- return { balances: result.balances, pagination: result.pagination };
46
- }
47
-
48
- case 'spendable-balances': {
49
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'bank spendable-balances');
50
- requireArgs(remainingArgs, 1, ['address'], 'bank spendable-balances');
51
- const [address] = remainingArgs;
52
- const result = await bank.spendableBalances({ address, pagination });
53
- return { balances: result.balances, pagination: result.pagination };
54
- }
55
-
56
- case 'total-supply':
57
- case 'total': {
58
- const { pagination } = extractPaginationArgs(args, 'bank total-supply');
59
- const result = await bank.totalSupply({ pagination });
60
- return { supply: result.supply, pagination: result.pagination };
61
- }
62
-
63
- case 'supply-of': {
64
- requireArgs(args, 1, ['denom'], 'bank supply-of');
65
- const [denom] = args;
66
- const result = await bank.supplyOf({ denom });
67
- return { amount: result.amount };
68
- }
69
-
70
- case 'params': {
71
- const result = await bank.params({});
72
- return { params: result.params };
73
- }
74
-
75
- case 'denom-metadata': {
76
- requireArgs(args, 1, ['denom'], 'bank denom-metadata');
77
- const [denom] = args;
78
- const result = await bank.denomMetadata({ denom });
79
- return { metadata: result.metadata };
80
- }
81
-
82
- case 'denoms-metadata': {
83
- const { pagination } = extractPaginationArgs(args, 'bank denoms-metadata');
84
- const result = await bank.denomsMetadata({ pagination });
85
- return { metadatas: result.metadatas, pagination: result.pagination };
86
- }
87
-
88
- case 'send-enabled': {
89
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'bank send-enabled');
90
- // Optional: denoms can be empty to query all
91
- const denoms = remainingArgs.length > 0 ? remainingArgs : [];
92
- const result = await bank.sendEnabled({ denoms, pagination });
93
- return { sendEnabled: result.sendEnabled, pagination: result.pagination };
94
- }
95
-
96
- default:
97
- throwUnsupportedSubcommand('query', 'bank', subcommand);
98
- }
99
- }