@manifest-network/manifest-mcp-browser 0.1.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/.claude/settings.local.json +17 -0
- package/.github/workflows/ci.yml +37 -0
- package/.github/workflows/publish.yml +51 -0
- package/CLAUDE.md +104 -0
- package/LICENSE +21 -0
- package/README.md +298 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js.map +1 -0
- package/dist/client.d.ts +44 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +131 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +21 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +98 -0
- package/dist/config.js.map +1 -0
- package/dist/config.test.d.ts +2 -0
- package/dist/config.test.d.ts.map +1 -0
- package/dist/config.test.js +123 -0
- package/dist/config.test.js.map +1 -0
- package/dist/cosmos.d.ts +11 -0
- package/dist/cosmos.d.ts.map +1 -0
- package/dist/cosmos.js +112 -0
- package/dist/cosmos.js.map +1 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +382 -0
- package/dist/index.js.map +1 -0
- package/dist/modules.d.ts +30 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +221 -0
- package/dist/modules.js.map +1 -0
- package/dist/modules.test.d.ts +2 -0
- package/dist/modules.test.d.ts.map +1 -0
- package/dist/modules.test.js +100 -0
- package/dist/modules.test.js.map +1 -0
- package/dist/queries/auth.d.ts +6 -0
- package/dist/queries/auth.d.ts.map +1 -0
- package/dist/queries/auth.js +93 -0
- package/dist/queries/auth.js.map +1 -0
- package/dist/queries/bank.d.ts +6 -0
- package/dist/queries/bank.d.ts.map +1 -0
- package/dist/queries/bank.js +83 -0
- package/dist/queries/bank.js.map +1 -0
- package/dist/queries/billing.d.ts +6 -0
- package/dist/queries/billing.d.ts.map +1 -0
- package/dist/queries/billing.js +115 -0
- package/dist/queries/billing.js.map +1 -0
- package/dist/queries/distribution.d.ts +6 -0
- package/dist/queries/distribution.d.ts.map +1 -0
- package/dist/queries/distribution.js +102 -0
- package/dist/queries/distribution.js.map +1 -0
- package/dist/queries/gov.d.ts +6 -0
- package/dist/queries/gov.d.ts.map +1 -0
- package/dist/queries/gov.js +92 -0
- package/dist/queries/gov.js.map +1 -0
- package/dist/queries/index.d.ts +8 -0
- package/dist/queries/index.d.ts.map +1 -0
- package/dist/queries/index.js +8 -0
- package/dist/queries/index.js.map +1 -0
- package/dist/queries/manifest.d.ts +10 -0
- package/dist/queries/manifest.d.ts.map +1 -0
- package/dist/queries/manifest.js +14 -0
- package/dist/queries/manifest.js.map +1 -0
- package/dist/queries/staking.d.ts +6 -0
- package/dist/queries/staking.d.ts.map +1 -0
- package/dist/queries/staking.js +141 -0
- package/dist/queries/staking.js.map +1 -0
- package/dist/queries/utils.d.ts +22 -0
- package/dist/queries/utils.d.ts.map +1 -0
- package/dist/queries/utils.js +32 -0
- package/dist/queries/utils.js.map +1 -0
- package/dist/queries/utils.test.d.ts +2 -0
- package/dist/queries/utils.test.d.ts.map +1 -0
- package/dist/queries/utils.test.js +57 -0
- package/dist/queries/utils.test.js.map +1 -0
- package/dist/transactions/bank.d.ts +7 -0
- package/dist/transactions/bank.d.ts.map +1 -0
- package/dist/transactions/bank.js +76 -0
- package/dist/transactions/bank.js.map +1 -0
- package/dist/transactions/billing.d.ts +7 -0
- package/dist/transactions/billing.d.ts.map +1 -0
- package/dist/transactions/billing.js +108 -0
- package/dist/transactions/billing.js.map +1 -0
- package/dist/transactions/distribution.d.ts +7 -0
- package/dist/transactions/distribution.d.ts.map +1 -0
- package/dist/transactions/distribution.js +63 -0
- package/dist/transactions/distribution.js.map +1 -0
- package/dist/transactions/gov.d.ts +7 -0
- package/dist/transactions/gov.d.ts.map +1 -0
- package/dist/transactions/gov.js +132 -0
- package/dist/transactions/gov.js.map +1 -0
- package/dist/transactions/index.d.ts +8 -0
- package/dist/transactions/index.d.ts.map +1 -0
- package/dist/transactions/index.js +8 -0
- package/dist/transactions/index.js.map +1 -0
- package/dist/transactions/manifest.d.ts +7 -0
- package/dist/transactions/manifest.d.ts.map +1 -0
- package/dist/transactions/manifest.js +58 -0
- package/dist/transactions/manifest.js.map +1 -0
- package/dist/transactions/staking.d.ts +7 -0
- package/dist/transactions/staking.d.ts.map +1 -0
- package/dist/transactions/staking.js +72 -0
- package/dist/transactions/staking.js.map +1 -0
- package/dist/transactions/utils.d.ts +40 -0
- package/dist/transactions/utils.d.ts.map +1 -0
- package/dist/transactions/utils.js +114 -0
- package/dist/transactions/utils.js.map +1 -0
- package/dist/transactions/utils.test.d.ts +2 -0
- package/dist/transactions/utils.test.d.ts.map +1 -0
- package/dist/transactions/utils.test.js +121 -0
- package/dist/transactions/utils.test.js.map +1 -0
- package/dist/types.d.ts +110 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +55 -0
- package/dist/types.js.map +1 -0
- package/dist/wallet/index.d.ts +3 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/index.js +2 -0
- package/dist/wallet/index.js.map +1 -0
- package/dist/wallet/keplr.d.ts.map +1 -0
- package/dist/wallet/keplr.js.map +1 -0
- package/dist/wallet/mnemonic.d.ts +40 -0
- package/dist/wallet/mnemonic.d.ts.map +1 -0
- package/dist/wallet/mnemonic.js +87 -0
- package/dist/wallet/mnemonic.js.map +1 -0
- package/package.json +40 -0
- package/src/client.ts +178 -0
- package/src/config.test.ts +143 -0
- package/src/config.ts +122 -0
- package/src/cosmos.ts +196 -0
- package/src/index.ts +484 -0
- package/src/modules.test.ts +127 -0
- package/src/modules.ts +278 -0
- package/src/queries/auth.ts +136 -0
- package/src/queries/bank.ts +117 -0
- package/src/queries/billing.ts +164 -0
- package/src/queries/distribution.ts +138 -0
- package/src/queries/gov.ts +128 -0
- package/src/queries/index.ts +7 -0
- package/src/queries/staking.ts +190 -0
- package/src/queries/utils.test.ts +61 -0
- package/src/queries/utils.ts +38 -0
- package/src/transactions/bank.ts +110 -0
- package/src/transactions/billing.ts +160 -0
- package/src/transactions/distribution.ts +98 -0
- package/src/transactions/gov.ts +185 -0
- package/src/transactions/index.ts +7 -0
- package/src/transactions/manifest.ts +89 -0
- package/src/transactions/staking.ts +107 -0
- package/src/transactions/utils.test.ts +129 -0
- package/src/transactions/utils.ts +156 -0
- package/src/types.ts +152 -0
- package/src/wallet/index.ts +2 -0
- package/src/wallet/mnemonic.ts +122 -0
- package/tsconfig.json +23 -0
package/src/modules.ts
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { ModuleInfo, AvailableModules, ManifestMCPError, ManifestMCPErrorCode } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Static module registry for browser-compatible module discovery
|
|
5
|
+
* All modules use manifestjs for full protobuf support
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface SubcommandInfo {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
args?: string; // Usage hint for arguments
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface ModuleRegistry {
|
|
15
|
+
[moduleName: string]: {
|
|
16
|
+
description: string;
|
|
17
|
+
subcommands: SubcommandInfo[];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Query modules registry
|
|
23
|
+
*/
|
|
24
|
+
const QUERY_MODULES: ModuleRegistry = {
|
|
25
|
+
bank: {
|
|
26
|
+
description: 'Querying commands for the bank module',
|
|
27
|
+
subcommands: [
|
|
28
|
+
{ name: 'balance', description: 'Query account balance for a specific denom' },
|
|
29
|
+
{ name: 'balances', description: 'Query all balances for an account' },
|
|
30
|
+
{ name: 'spendable-balances', description: 'Query spendable balances for an account' },
|
|
31
|
+
{ name: 'total-supply', description: 'Query total supply of all tokens' },
|
|
32
|
+
{ name: 'total', description: 'Query total supply of all tokens (alias for total-supply)' },
|
|
33
|
+
{ name: 'supply-of', description: 'Query supply of a specific denom' },
|
|
34
|
+
{ name: 'params', description: 'Query bank parameters' },
|
|
35
|
+
{ name: 'denom-metadata', description: 'Query metadata for a specific denom' },
|
|
36
|
+
{ name: 'denoms-metadata', description: 'Query metadata for all denoms' },
|
|
37
|
+
{ name: 'send-enabled', description: 'Query send enabled status for denoms' },
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
staking: {
|
|
41
|
+
description: 'Querying commands for the staking module',
|
|
42
|
+
subcommands: [
|
|
43
|
+
{ name: 'delegation', description: 'Query a delegation' },
|
|
44
|
+
{ name: 'delegations', description: 'Query all delegations for a delegator' },
|
|
45
|
+
{ name: 'unbonding-delegation', description: 'Query an unbonding delegation' },
|
|
46
|
+
{ name: 'unbonding-delegations', description: 'Query all unbonding delegations for a delegator' },
|
|
47
|
+
{ name: 'redelegations', description: 'Query redelegations' },
|
|
48
|
+
{ name: 'validator', description: 'Query a validator' },
|
|
49
|
+
{ name: 'validators', description: 'Query all validators' },
|
|
50
|
+
{ name: 'validator-delegations', description: 'Query all delegations to a validator' },
|
|
51
|
+
{ name: 'validator-unbonding-delegations', description: 'Query all unbonding delegations from a validator' },
|
|
52
|
+
{ name: 'pool', description: 'Query staking pool' },
|
|
53
|
+
{ name: 'params', description: 'Query staking parameters' },
|
|
54
|
+
{ name: 'historical-info', description: 'Query historical info at a height' },
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
distribution: {
|
|
58
|
+
description: 'Querying commands for the distribution module',
|
|
59
|
+
subcommands: [
|
|
60
|
+
{ name: 'rewards', description: 'Query distribution rewards for a delegator' },
|
|
61
|
+
{ name: 'commission', description: 'Query validator commission' },
|
|
62
|
+
{ name: 'community-pool', description: 'Query community pool coins' },
|
|
63
|
+
{ name: 'params', description: 'Query distribution parameters' },
|
|
64
|
+
{ name: 'validator-outstanding-rewards', description: 'Query validator outstanding rewards' },
|
|
65
|
+
{ name: 'slashes', description: 'Query slashes for a validator' },
|
|
66
|
+
{ name: 'delegator-validators', description: 'Query validators for a delegator' },
|
|
67
|
+
{ name: 'delegator-withdraw-address', description: 'Query delegator withdraw address' },
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
gov: {
|
|
71
|
+
description: 'Querying commands for the governance module',
|
|
72
|
+
subcommands: [
|
|
73
|
+
{ name: 'proposal', description: 'Query a proposal by ID' },
|
|
74
|
+
{ name: 'proposals', description: 'Query all proposals' },
|
|
75
|
+
{ name: 'vote', description: 'Query a vote on a proposal' },
|
|
76
|
+
{ name: 'votes', description: 'Query all votes on a proposal' },
|
|
77
|
+
{ name: 'deposit', description: 'Query a deposit on a proposal' },
|
|
78
|
+
{ name: 'deposits', description: 'Query all deposits on a proposal' },
|
|
79
|
+
{ name: 'tally', description: 'Query tally of a proposal' },
|
|
80
|
+
{ name: 'params', description: 'Query governance parameters' },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
auth: {
|
|
84
|
+
description: 'Querying commands for the auth module',
|
|
85
|
+
subcommands: [
|
|
86
|
+
{ name: 'account', description: 'Query account by address' },
|
|
87
|
+
{ name: 'accounts', description: 'Query all accounts' },
|
|
88
|
+
{ name: 'params', description: 'Query auth parameters' },
|
|
89
|
+
{ name: 'module-accounts', description: 'Query all module accounts' },
|
|
90
|
+
{ name: 'module-account-by-name', description: 'Query module account by name' },
|
|
91
|
+
{ name: 'address-bytes-to-string', description: 'Convert address bytes to string' },
|
|
92
|
+
{ name: 'address-string-to-bytes', description: 'Convert address string to bytes' },
|
|
93
|
+
{ name: 'bech32-prefix', description: 'Query bech32 prefix' },
|
|
94
|
+
{ name: 'account-info', description: 'Query account info' },
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
billing: {
|
|
98
|
+
description: 'Querying commands for the Manifest billing module',
|
|
99
|
+
subcommands: [
|
|
100
|
+
{ name: 'params', description: 'Query billing parameters' },
|
|
101
|
+
{ name: 'lease', description: 'Query a lease by UUID' },
|
|
102
|
+
{ name: 'leases', description: 'Query all leases' },
|
|
103
|
+
{ name: 'leases-by-tenant', description: 'Query leases by tenant address' },
|
|
104
|
+
{ name: 'leases-by-provider', description: 'Query leases by provider' },
|
|
105
|
+
{ name: 'leases-by-sku', description: 'Query leases by SKU UUID' },
|
|
106
|
+
{ name: 'credit-account', description: 'Query credit account for a tenant' },
|
|
107
|
+
{ name: 'credit-accounts', description: 'Query all credit accounts' },
|
|
108
|
+
{ name: 'credit-address', description: 'Query credit address for a tenant' },
|
|
109
|
+
{ name: 'withdrawable-amount', description: 'Query withdrawable amount for a lease' },
|
|
110
|
+
{ name: 'provider-withdrawable', description: 'Query withdrawable amount for a provider' },
|
|
111
|
+
{ name: 'credit-estimate', description: 'Query credit estimate for a tenant' },
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Transaction modules registry
|
|
118
|
+
*/
|
|
119
|
+
const TX_MODULES: ModuleRegistry = {
|
|
120
|
+
bank: {
|
|
121
|
+
description: 'Bank transaction subcommands',
|
|
122
|
+
subcommands: [
|
|
123
|
+
{ name: 'send', description: 'Send tokens to another account', args: '<to-address> <amount> (e.g., manifest1abc... 1000000umfx)' },
|
|
124
|
+
{ name: 'multi-send', description: 'Send tokens to multiple accounts', args: '<to-address:amount>... (e.g., manifest1a:1000umfx manifest1b:2000umfx)' },
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
staking: {
|
|
128
|
+
description: 'Staking transaction subcommands',
|
|
129
|
+
subcommands: [
|
|
130
|
+
{ name: 'delegate', description: 'Delegate tokens to a validator' },
|
|
131
|
+
{ name: 'unbond', description: 'Unbond tokens from a validator' },
|
|
132
|
+
{ name: 'undelegate', description: 'Unbond tokens from a validator (alias for unbond)' },
|
|
133
|
+
{ name: 'redelegate', description: 'Redelegate tokens from one validator to another' },
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
distribution: {
|
|
137
|
+
description: 'Distribution transaction subcommands',
|
|
138
|
+
subcommands: [
|
|
139
|
+
{ name: 'withdraw-rewards', description: 'Withdraw rewards from a validator' },
|
|
140
|
+
{ name: 'set-withdraw-addr', description: 'Set withdraw address' },
|
|
141
|
+
{ name: 'fund-community-pool', description: 'Fund the community pool' },
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
gov: {
|
|
145
|
+
description: 'Governance transaction subcommands',
|
|
146
|
+
subcommands: [
|
|
147
|
+
{ name: 'vote', description: 'Vote on a proposal' },
|
|
148
|
+
{ name: 'weighted-vote', description: 'Weighted vote on a proposal' },
|
|
149
|
+
{ name: 'deposit', description: 'Deposit tokens for a proposal' },
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
billing: {
|
|
153
|
+
description: 'Manifest billing transaction subcommands',
|
|
154
|
+
subcommands: [
|
|
155
|
+
{ name: 'fund-credit', description: 'Fund credit for a tenant', args: '<tenant-address> <amount> (e.g., manifest1abc... 1000000umfx)' },
|
|
156
|
+
{ name: 'create-lease', description: 'Create a new lease', args: '<sku-uuid:quantity>... (e.g., sku-123:1 sku-456:2)' },
|
|
157
|
+
{ name: 'close-lease', description: 'Close one or more leases', args: '<lease-uuid>... (e.g., lease-123 lease-456)' },
|
|
158
|
+
{ name: 'withdraw', description: 'Withdraw earnings from leases', args: '<lease-uuid>... OR --provider <provider-uuid>' },
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
manifest: {
|
|
162
|
+
description: 'Manifest module transaction subcommands',
|
|
163
|
+
subcommands: [
|
|
164
|
+
{ name: 'payout', description: 'Execute a payout to multiple addresses' },
|
|
165
|
+
{ name: 'burn-held-balance', description: 'Burn held balance' },
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Get all available query and transaction modules
|
|
172
|
+
*/
|
|
173
|
+
export function getAvailableModules(): AvailableModules {
|
|
174
|
+
const queryModules: ModuleInfo[] = Object.entries(QUERY_MODULES).map(
|
|
175
|
+
([name, info]) => ({
|
|
176
|
+
name,
|
|
177
|
+
description: info.description,
|
|
178
|
+
})
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
const txModules: ModuleInfo[] = Object.entries(TX_MODULES).map(
|
|
182
|
+
([name, info]) => ({
|
|
183
|
+
name,
|
|
184
|
+
description: info.description,
|
|
185
|
+
})
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
queryModules,
|
|
190
|
+
txModules,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Get available subcommands for a specific module
|
|
196
|
+
*/
|
|
197
|
+
export function getModuleSubcommands(
|
|
198
|
+
type: 'query' | 'tx',
|
|
199
|
+
module: string
|
|
200
|
+
): ModuleInfo[] {
|
|
201
|
+
const registry = type === 'query' ? QUERY_MODULES : TX_MODULES;
|
|
202
|
+
const moduleInfo = registry[module];
|
|
203
|
+
|
|
204
|
+
if (!moduleInfo) {
|
|
205
|
+
throw new ManifestMCPError(
|
|
206
|
+
ManifestMCPErrorCode.UNKNOWN_MODULE,
|
|
207
|
+
`Unknown ${type} module: ${module}`,
|
|
208
|
+
{ availableModules: Object.keys(registry) }
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return moduleInfo.subcommands.map((sub) => ({
|
|
213
|
+
name: sub.name,
|
|
214
|
+
description: sub.description,
|
|
215
|
+
args: sub.args,
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Check if a module/subcommand combination is supported
|
|
221
|
+
*/
|
|
222
|
+
export function isSubcommandSupported(
|
|
223
|
+
type: 'query' | 'tx',
|
|
224
|
+
module: string,
|
|
225
|
+
subcommand: string
|
|
226
|
+
): boolean {
|
|
227
|
+
const registry = type === 'query' ? QUERY_MODULES : TX_MODULES;
|
|
228
|
+
const moduleInfo = registry[module];
|
|
229
|
+
|
|
230
|
+
if (!moduleInfo) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return moduleInfo.subcommands.some((s) => s.name === subcommand);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Get usage help for a specific subcommand
|
|
239
|
+
* Returns the args string if available, or undefined
|
|
240
|
+
*/
|
|
241
|
+
export function getSubcommandUsage(
|
|
242
|
+
type: 'query' | 'tx',
|
|
243
|
+
module: string,
|
|
244
|
+
subcommand: string
|
|
245
|
+
): string | undefined {
|
|
246
|
+
const registry = type === 'query' ? QUERY_MODULES : TX_MODULES;
|
|
247
|
+
const moduleInfo = registry[module];
|
|
248
|
+
|
|
249
|
+
if (!moduleInfo) {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const sub = moduleInfo.subcommands.find((s) => s.name === subcommand);
|
|
254
|
+
return sub?.args;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Get supported modules list
|
|
259
|
+
*/
|
|
260
|
+
export function getSupportedModules(): {
|
|
261
|
+
query: { [module: string]: string[] };
|
|
262
|
+
tx: { [module: string]: string[] };
|
|
263
|
+
} {
|
|
264
|
+
const result = {
|
|
265
|
+
query: {} as { [module: string]: string[] },
|
|
266
|
+
tx: {} as { [module: string]: string[] },
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
for (const [module, info] of Object.entries(QUERY_MODULES)) {
|
|
270
|
+
result.query[module] = info.subcommands.map((s) => s.name);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
for (const [module, info] of Object.entries(TX_MODULES)) {
|
|
274
|
+
result.tx[module] = info.subcommands.map((s) => s.name);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { ManifestQueryClient } from '../client.js';
|
|
2
|
+
import { ManifestMCPError, ManifestMCPErrorCode } from '../types.js';
|
|
3
|
+
import { defaultPagination } from './utils.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Route auth query to manifestjs query client
|
|
7
|
+
*/
|
|
8
|
+
export async function routeAuthQuery(
|
|
9
|
+
queryClient: ManifestQueryClient,
|
|
10
|
+
subcommand: string,
|
|
11
|
+
args: string[]
|
|
12
|
+
): Promise<Record<string, unknown>> {
|
|
13
|
+
const auth = queryClient.cosmos.auth.v1beta1;
|
|
14
|
+
|
|
15
|
+
switch (subcommand) {
|
|
16
|
+
case 'account': {
|
|
17
|
+
if (args.length < 1) {
|
|
18
|
+
throw new ManifestMCPError(
|
|
19
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
20
|
+
'account requires address argument'
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
const [address] = args;
|
|
24
|
+
const result = await auth.account({ address });
|
|
25
|
+
return { account: result.account };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
case 'accounts': {
|
|
29
|
+
const result = await auth.accounts({ pagination: defaultPagination });
|
|
30
|
+
return { accounts: result.accounts, pagination: result.pagination };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
case 'params': {
|
|
34
|
+
const result = await auth.params({});
|
|
35
|
+
return { params: result.params };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
case 'module-accounts': {
|
|
39
|
+
const result = await auth.moduleAccounts({});
|
|
40
|
+
return { accounts: result.accounts };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
case 'module-account-by-name': {
|
|
44
|
+
if (args.length < 1) {
|
|
45
|
+
throw new ManifestMCPError(
|
|
46
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
47
|
+
'module-account-by-name requires name argument'
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const [name] = args;
|
|
51
|
+
const result = await auth.moduleAccountByName({ name });
|
|
52
|
+
return { account: result.account };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
case 'address-bytes-to-string': {
|
|
56
|
+
if (args.length < 1) {
|
|
57
|
+
throw new ManifestMCPError(
|
|
58
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
59
|
+
'address-bytes-to-string requires address-bytes argument'
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
const hexString = args[0];
|
|
63
|
+
// Validate hex format: must be valid hex characters with even length
|
|
64
|
+
if (!/^[0-9a-fA-F]*$/.test(hexString)) {
|
|
65
|
+
throw new ManifestMCPError(
|
|
66
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
67
|
+
`Invalid hex string: "${hexString}". Must contain only hexadecimal characters (0-9, a-f, A-F)`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
if (hexString.length % 2 !== 0) {
|
|
71
|
+
throw new ManifestMCPError(
|
|
72
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
73
|
+
`Invalid hex string length: ${hexString.length}. Must have an even number of characters`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
// Limit size to prevent DoS (256 bytes = 512 hex chars, more than enough for any address)
|
|
77
|
+
if (hexString.length > 512) {
|
|
78
|
+
throw new ManifestMCPError(
|
|
79
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
80
|
+
`Hex string too long: ${hexString.length} characters. Maximum allowed: 512`
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
const addressBytes = new Uint8Array(Buffer.from(hexString, 'hex'));
|
|
84
|
+
const result = await auth.addressBytesToString({ addressBytes });
|
|
85
|
+
return { addressString: result.addressString };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
case 'address-string-to-bytes': {
|
|
89
|
+
if (args.length < 1) {
|
|
90
|
+
throw new ManifestMCPError(
|
|
91
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
92
|
+
'address-string-to-bytes requires address-string argument'
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
const [addressString] = args;
|
|
96
|
+
const result = await auth.addressStringToBytes({ addressString });
|
|
97
|
+
return { addressBytes: Buffer.from(result.addressBytes).toString('hex') };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
case 'bech32-prefix': {
|
|
101
|
+
const result = await auth.bech32Prefix({});
|
|
102
|
+
return { bech32Prefix: result.bech32Prefix };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
case 'account-info': {
|
|
106
|
+
if (args.length < 1) {
|
|
107
|
+
throw new ManifestMCPError(
|
|
108
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
109
|
+
'account-info requires address argument'
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
const [address] = args;
|
|
113
|
+
const result = await auth.accountInfo({ address });
|
|
114
|
+
return { info: result.info };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
default:
|
|
118
|
+
throw new ManifestMCPError(
|
|
119
|
+
ManifestMCPErrorCode.UNSUPPORTED_QUERY,
|
|
120
|
+
`Unsupported auth query subcommand: ${subcommand}`,
|
|
121
|
+
{
|
|
122
|
+
availableSubcommands: [
|
|
123
|
+
'account',
|
|
124
|
+
'accounts',
|
|
125
|
+
'params',
|
|
126
|
+
'module-accounts',
|
|
127
|
+
'module-account-by-name',
|
|
128
|
+
'address-bytes-to-string',
|
|
129
|
+
'address-string-to-bytes',
|
|
130
|
+
'bech32-prefix',
|
|
131
|
+
'account-info',
|
|
132
|
+
],
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ManifestQueryClient } from '../client.js';
|
|
2
|
+
import { ManifestMCPError, ManifestMCPErrorCode } from '../types.js';
|
|
3
|
+
import { defaultPagination } from './utils.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Route bank query to manifestjs query client
|
|
7
|
+
*/
|
|
8
|
+
export async function routeBankQuery(
|
|
9
|
+
queryClient: ManifestQueryClient,
|
|
10
|
+
subcommand: string,
|
|
11
|
+
args: string[]
|
|
12
|
+
): Promise<Record<string, unknown>> {
|
|
13
|
+
const bank = queryClient.cosmos.bank.v1beta1;
|
|
14
|
+
|
|
15
|
+
switch (subcommand) {
|
|
16
|
+
case 'balance': {
|
|
17
|
+
if (args.length < 2) {
|
|
18
|
+
throw new ManifestMCPError(
|
|
19
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
20
|
+
'balance requires address and denom arguments'
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
const [address, denom] = args;
|
|
24
|
+
const result = await bank.balance({ address, denom });
|
|
25
|
+
return { balance: result.balance };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
case 'balances': {
|
|
29
|
+
if (args.length < 1) {
|
|
30
|
+
throw new ManifestMCPError(
|
|
31
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
32
|
+
'balances requires address argument'
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const [address] = args;
|
|
36
|
+
const result = await bank.allBalances({ address, resolveDenom: false, pagination: defaultPagination });
|
|
37
|
+
return { balances: result.balances, pagination: result.pagination };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
case 'spendable-balances': {
|
|
41
|
+
if (args.length < 1) {
|
|
42
|
+
throw new ManifestMCPError(
|
|
43
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
44
|
+
'spendable-balances requires address argument'
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
const [address] = args;
|
|
48
|
+
const result = await bank.spendableBalances({ address, pagination: defaultPagination });
|
|
49
|
+
return { balances: result.balances, pagination: result.pagination };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
case 'total-supply':
|
|
53
|
+
case 'total': {
|
|
54
|
+
const result = await bank.totalSupply({ pagination: defaultPagination });
|
|
55
|
+
return { supply: result.supply, pagination: result.pagination };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
case 'supply-of': {
|
|
59
|
+
if (args.length < 1) {
|
|
60
|
+
throw new ManifestMCPError(
|
|
61
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
62
|
+
'supply-of requires denom argument'
|
|
63
|
+
);
|
|
64
|
+
}
|
|
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
|
+
if (args.length < 1) {
|
|
77
|
+
throw new ManifestMCPError(
|
|
78
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
79
|
+
'denom-metadata requires denom argument'
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
const [denom] = args;
|
|
83
|
+
const result = await bank.denomMetadata({ denom });
|
|
84
|
+
return { metadata: result.metadata };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
case 'denoms-metadata': {
|
|
88
|
+
const result = await bank.denomsMetadata({ pagination: defaultPagination });
|
|
89
|
+
return { metadatas: result.metadatas, pagination: result.pagination };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
case 'send-enabled': {
|
|
93
|
+
const denoms = args.length > 0 ? args : [];
|
|
94
|
+
const result = await bank.sendEnabled({ denoms, pagination: defaultPagination });
|
|
95
|
+
return { sendEnabled: result.sendEnabled, pagination: result.pagination };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
default:
|
|
99
|
+
throw new ManifestMCPError(
|
|
100
|
+
ManifestMCPErrorCode.UNSUPPORTED_QUERY,
|
|
101
|
+
`Unsupported bank query subcommand: ${subcommand}`,
|
|
102
|
+
{
|
|
103
|
+
availableSubcommands: [
|
|
104
|
+
'balance',
|
|
105
|
+
'balances',
|
|
106
|
+
'spendable-balances',
|
|
107
|
+
'total-supply',
|
|
108
|
+
'supply-of',
|
|
109
|
+
'params',
|
|
110
|
+
'denom-metadata',
|
|
111
|
+
'denoms-metadata',
|
|
112
|
+
'send-enabled',
|
|
113
|
+
],
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { ManifestQueryClient } from '../client.js';
|
|
2
|
+
import { ManifestMCPError, ManifestMCPErrorCode } from '../types.js';
|
|
3
|
+
import { parseBigInt, defaultPagination } from './utils.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Route billing module query to manifestjs query client
|
|
7
|
+
*/
|
|
8
|
+
export async function routeBillingQuery(
|
|
9
|
+
queryClient: ManifestQueryClient,
|
|
10
|
+
subcommand: string,
|
|
11
|
+
args: string[]
|
|
12
|
+
): Promise<Record<string, unknown>> {
|
|
13
|
+
const billing = queryClient.liftedinit.billing.v1;
|
|
14
|
+
|
|
15
|
+
switch (subcommand) {
|
|
16
|
+
case 'params': {
|
|
17
|
+
const result = await billing.params({});
|
|
18
|
+
return { params: result.params };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
case 'lease': {
|
|
22
|
+
if (args.length < 1) {
|
|
23
|
+
throw new ManifestMCPError(
|
|
24
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
25
|
+
'lease requires lease-uuid argument'
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
const [leaseUuid] = args;
|
|
29
|
+
const result = await billing.lease({ leaseUuid });
|
|
30
|
+
return { lease: result.lease };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
case 'leases': {
|
|
34
|
+
// stateFilter: 0 = LEASE_STATE_UNSPECIFIED (returns all)
|
|
35
|
+
const result = await billing.leases({ stateFilter: 0, pagination: defaultPagination });
|
|
36
|
+
return { leases: result.leases, pagination: result.pagination };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
case 'leases-by-tenant': {
|
|
40
|
+
if (args.length < 1) {
|
|
41
|
+
throw new ManifestMCPError(
|
|
42
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
43
|
+
'leases-by-tenant requires tenant-address argument'
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
const [tenant] = args;
|
|
47
|
+
const result = await billing.leasesByTenant({ tenant, stateFilter: 0, pagination: defaultPagination });
|
|
48
|
+
return { leases: result.leases, pagination: result.pagination };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
case 'leases-by-provider': {
|
|
52
|
+
if (args.length < 1) {
|
|
53
|
+
throw new ManifestMCPError(
|
|
54
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
55
|
+
'leases-by-provider requires provider-uuid argument'
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
const [providerUuid] = args;
|
|
59
|
+
const result = await billing.leasesByProvider({ providerUuid, stateFilter: 0, pagination: defaultPagination });
|
|
60
|
+
return { leases: result.leases, pagination: result.pagination };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
case 'leases-by-sku': {
|
|
64
|
+
if (args.length < 1) {
|
|
65
|
+
throw new ManifestMCPError(
|
|
66
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
67
|
+
'leases-by-sku requires sku-uuid argument'
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
const [skuUuid] = args;
|
|
71
|
+
const result = await billing.leasesBySKU({ skuUuid, stateFilter: 0, pagination: defaultPagination });
|
|
72
|
+
return { leases: result.leases, pagination: result.pagination };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
case 'credit-account': {
|
|
76
|
+
if (args.length < 1) {
|
|
77
|
+
throw new ManifestMCPError(
|
|
78
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
79
|
+
'credit-account requires tenant-address argument'
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
const [tenant] = args;
|
|
83
|
+
const result = await billing.creditAccount({ tenant });
|
|
84
|
+
return { creditAccount: result.creditAccount };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
case 'credit-accounts': {
|
|
88
|
+
const result = await billing.creditAccounts({ pagination: defaultPagination });
|
|
89
|
+
return { creditAccounts: result.creditAccounts, pagination: result.pagination };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
case 'credit-address': {
|
|
93
|
+
if (args.length < 1) {
|
|
94
|
+
throw new ManifestMCPError(
|
|
95
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
96
|
+
'credit-address requires tenant-address argument'
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
const [tenant] = args;
|
|
100
|
+
const result = await billing.creditAddress({ tenant });
|
|
101
|
+
return { creditAddress: result.creditAddress };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
case 'withdrawable-amount': {
|
|
105
|
+
if (args.length < 1) {
|
|
106
|
+
throw new ManifestMCPError(
|
|
107
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
108
|
+
'withdrawable-amount requires lease-uuid argument'
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
const [leaseUuid] = args;
|
|
112
|
+
const result = await billing.withdrawableAmount({ leaseUuid });
|
|
113
|
+
return { amounts: result.amounts };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
case 'provider-withdrawable': {
|
|
117
|
+
if (args.length < 1) {
|
|
118
|
+
throw new ManifestMCPError(
|
|
119
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
120
|
+
'provider-withdrawable requires provider-uuid argument'
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
const [providerUuid] = args;
|
|
124
|
+
// limit: max leases to process (default 100, max 1000)
|
|
125
|
+
const limit = args[1] ? parseBigInt(args[1], 'limit') : BigInt(100);
|
|
126
|
+
const result = await billing.providerWithdrawable({ providerUuid, limit });
|
|
127
|
+
return { amounts: result.amounts };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
case 'credit-estimate': {
|
|
131
|
+
if (args.length < 1) {
|
|
132
|
+
throw new ManifestMCPError(
|
|
133
|
+
ManifestMCPErrorCode.QUERY_FAILED,
|
|
134
|
+
'credit-estimate requires tenant-address argument'
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
const [tenant] = args;
|
|
138
|
+
const result = await billing.creditEstimate({ tenant });
|
|
139
|
+
return { estimate: result };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
default:
|
|
143
|
+
throw new ManifestMCPError(
|
|
144
|
+
ManifestMCPErrorCode.UNSUPPORTED_QUERY,
|
|
145
|
+
`Unsupported billing query subcommand: ${subcommand}`,
|
|
146
|
+
{
|
|
147
|
+
availableSubcommands: [
|
|
148
|
+
'params',
|
|
149
|
+
'lease',
|
|
150
|
+
'leases',
|
|
151
|
+
'leases-by-tenant',
|
|
152
|
+
'leases-by-provider',
|
|
153
|
+
'leases-by-sku',
|
|
154
|
+
'credit-account',
|
|
155
|
+
'credit-accounts',
|
|
156
|
+
'credit-address',
|
|
157
|
+
'withdrawable-amount',
|
|
158
|
+
'provider-withdrawable',
|
|
159
|
+
'credit-estimate',
|
|
160
|
+
],
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|