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