@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/config.ts DELETED
@@ -1,174 +0,0 @@
1
- import { ManifestMCPConfig, ManifestMCPError, ManifestMCPErrorCode } from './types.js';
2
-
3
- /**
4
- * Default gas adjustment multiplier
5
- */
6
- const DEFAULT_GAS_ADJUSTMENT = 1.3;
7
-
8
- /**
9
- * Default address prefix for Manifest Network
10
- */
11
- const DEFAULT_ADDRESS_PREFIX = 'manifest';
12
-
13
- /**
14
- * Default requests per second for rate limiting
15
- */
16
- export const DEFAULT_REQUESTS_PER_SECOND = 10;
17
-
18
- /**
19
- * Check if a hostname is localhost (IPv4, IPv6, or hostname)
20
- * Handles both bracketed and unbracketed IPv6 formats
21
- */
22
- function isLocalhostHostname(hostname: string): boolean {
23
- if (hostname === 'localhost' || hostname === '127.0.0.1') {
24
- return true;
25
- }
26
- // Handle IPv6 localhost - hostname may be '::1' or '[::1]' depending on environment
27
- const normalizedHostname = hostname.replace(/^\[|\]$/g, '');
28
- return normalizedHostname === '::1';
29
- }
30
-
31
- /**
32
- * Validate URL format and check if it uses HTTPS or is localhost (HTTP allowed for local dev)
33
- * Returns validation result with error reason if invalid
34
- */
35
- function validateRpcUrl(url: string): { valid: boolean; reason?: string } {
36
- let parsed: URL;
37
- try {
38
- parsed = new URL(url);
39
- } catch {
40
- return { valid: false, reason: 'rpcUrl must be a valid URL' };
41
- }
42
-
43
- if (parsed.protocol === 'https:') {
44
- return { valid: true };
45
- }
46
-
47
- if (parsed.protocol === 'http:' && isLocalhostHostname(parsed.hostname)) {
48
- return { valid: true }; // HTTP allowed for localhost
49
- }
50
-
51
- return {
52
- valid: false,
53
- reason: `RPC URL must use HTTPS (got ${parsed.protocol}//). HTTP is only allowed for local development (localhost, 127.0.0.1, ::1).`,
54
- };
55
- }
56
-
57
- /**
58
- * Validate gas price format (e.g., "1.0umfx")
59
- */
60
- function isValidGasPrice(gasPrice: string): boolean {
61
- // Gas price should be a number followed by a denomination
62
- return /^\d+(\.\d+)?[a-zA-Z]+$/.test(gasPrice);
63
- }
64
-
65
- /**
66
- * Validate chain ID format
67
- */
68
- function isValidChainId(chainId: string): boolean {
69
- // Chain ID should be alphanumeric with hyphens
70
- return /^[a-zA-Z0-9][\w-]*$/.test(chainId);
71
- }
72
-
73
- /**
74
- * Create a configuration object with defaults applied
75
- */
76
- export function createConfig(input: ManifestMCPConfig): ManifestMCPConfig {
77
- return {
78
- chainId: input.chainId,
79
- rpcUrl: input.rpcUrl,
80
- gasPrice: input.gasPrice,
81
- gasAdjustment: input.gasAdjustment ?? DEFAULT_GAS_ADJUSTMENT,
82
- addressPrefix: input.addressPrefix ?? DEFAULT_ADDRESS_PREFIX,
83
- rateLimit: {
84
- requestsPerSecond: input.rateLimit?.requestsPerSecond ?? DEFAULT_REQUESTS_PER_SECOND,
85
- },
86
- };
87
- }
88
-
89
- /**
90
- * Validation result
91
- */
92
- export interface ValidationResult {
93
- valid: boolean;
94
- errors: string[];
95
- }
96
-
97
- /**
98
- * Validate a configuration object
99
- */
100
- export function validateConfig(config: Partial<ManifestMCPConfig>): ValidationResult {
101
- const errors: string[] = [];
102
-
103
- // Required fields
104
- if (!config.chainId) {
105
- errors.push('chainId is required');
106
- } else if (!isValidChainId(config.chainId)) {
107
- errors.push('chainId must be alphanumeric with hyphens (e.g., "manifest-ledger-testnet")');
108
- }
109
-
110
- if (!config.rpcUrl) {
111
- errors.push('rpcUrl is required');
112
- } else {
113
- const urlCheck = validateRpcUrl(config.rpcUrl);
114
- if (!urlCheck.valid) {
115
- errors.push(urlCheck.reason!);
116
- }
117
- }
118
-
119
- if (!config.gasPrice) {
120
- errors.push('gasPrice is required');
121
- } else if (!isValidGasPrice(config.gasPrice)) {
122
- errors.push('gasPrice must be a number followed by denomination (e.g., "1.0umfx")');
123
- }
124
-
125
- // Optional fields
126
- if (config.gasAdjustment !== undefined) {
127
- if (typeof config.gasAdjustment !== 'number' || config.gasAdjustment <= 0) {
128
- errors.push('gasAdjustment must be a positive number');
129
- }
130
- }
131
-
132
- if (config.addressPrefix !== undefined) {
133
- if (!/^[a-z]+$/.test(config.addressPrefix)) {
134
- errors.push('addressPrefix must be lowercase letters only');
135
- }
136
- }
137
-
138
- if (config.rateLimit !== undefined) {
139
- if (typeof config.rateLimit !== 'object' || config.rateLimit === null || Array.isArray(config.rateLimit)) {
140
- errors.push('rateLimit must be a plain object');
141
- } else if (config.rateLimit.requestsPerSecond !== undefined) {
142
- if (
143
- typeof config.rateLimit.requestsPerSecond !== 'number' ||
144
- config.rateLimit.requestsPerSecond <= 0 ||
145
- !Number.isInteger(config.rateLimit.requestsPerSecond)
146
- ) {
147
- errors.push('rateLimit.requestsPerSecond must be a positive integer');
148
- }
149
- }
150
- }
151
-
152
- return {
153
- valid: errors.length === 0,
154
- errors,
155
- };
156
- }
157
-
158
- /**
159
- * Create and validate a configuration, throwing on invalid config
160
- */
161
- export function createValidatedConfig(input: ManifestMCPConfig): ManifestMCPConfig {
162
- const validation = validateConfig(input);
163
-
164
- if (!validation.valid) {
165
- throw new ManifestMCPError(
166
- ManifestMCPErrorCode.INVALID_CONFIG,
167
- `Invalid configuration: ${validation.errors.join(', ')}`,
168
- { errors: validation.errors }
169
- );
170
- }
171
-
172
- return createConfig(input);
173
- }
174
-
package/src/cosmos.ts DELETED
@@ -1,106 +0,0 @@
1
- import { CosmosClientManager } from './client.js';
2
- import { CosmosQueryResult, CosmosTxResult, ManifestMCPError, ManifestMCPErrorCode } from './types.js';
3
- import { getQueryHandler, getTxHandler } from './modules.js';
4
-
5
- // Validation pattern for module/subcommand names (alphanumeric, hyphens, underscores)
6
- // First character must not be a hyphen to prevent potential issues
7
- const VALID_NAME_PATTERN = /^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/;
8
-
9
- /**
10
- * Validate that a string is safe for use as a module or subcommand name
11
- */
12
- function validateName(name: string, field: string): void {
13
- if (!name || !VALID_NAME_PATTERN.test(name)) {
14
- throw new ManifestMCPError(
15
- ManifestMCPErrorCode.QUERY_FAILED,
16
- `Invalid ${field}: "${name}". Only alphanumeric characters, hyphens, and underscores are allowed.`
17
- );
18
- }
19
- }
20
-
21
- /**
22
- * Execute a Cosmos query via manifestjs RPC client
23
- */
24
- export async function cosmosQuery(
25
- clientManager: CosmosClientManager,
26
- module: string,
27
- subcommand: string,
28
- args: string[] = []
29
- ): Promise<CosmosQueryResult> {
30
- validateName(module, 'module');
31
- validateName(subcommand, 'subcommand');
32
-
33
- // Apply rate limiting before making RPC request
34
- await clientManager.acquireRateLimit();
35
-
36
- const queryClient = await clientManager.getQueryClient();
37
-
38
- try {
39
- // Get handler from registry (throws if module not found)
40
- const handler = getQueryHandler(module);
41
- const result = await handler(queryClient, subcommand, args);
42
-
43
- return {
44
- module,
45
- subcommand,
46
- result,
47
- };
48
- } catch (error) {
49
- if (error instanceof ManifestMCPError) {
50
- throw error;
51
- }
52
- throw new ManifestMCPError(
53
- ManifestMCPErrorCode.QUERY_FAILED,
54
- `Query ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`
55
- );
56
- }
57
- }
58
-
59
- /**
60
- * Execute a Cosmos transaction via manifestjs signing client
61
- */
62
- export async function cosmosTx(
63
- clientManager: CosmosClientManager,
64
- module: string,
65
- subcommand: string,
66
- args: string[] = [],
67
- waitForConfirmation: boolean = false
68
- ): Promise<CosmosTxResult> {
69
- validateName(module, 'module');
70
- validateName(subcommand, 'subcommand');
71
-
72
- // Apply rate limiting before making RPC request
73
- await clientManager.acquireRateLimit();
74
-
75
- const signingClient = await clientManager.getSigningClient();
76
- const senderAddress = await clientManager.getAddress();
77
-
78
- try {
79
- // Get handler from registry (throws if module not found)
80
- const handler = getTxHandler(module);
81
- return await handler(
82
- signingClient,
83
- senderAddress,
84
- subcommand,
85
- args,
86
- waitForConfirmation
87
- );
88
- } catch (error) {
89
- if (error instanceof ManifestMCPError) {
90
- // Re-throw with enriched context if not already present
91
- if (!error.details?.module) {
92
- throw new ManifestMCPError(
93
- error.code,
94
- error.message,
95
- { ...error.details, module, subcommand, args }
96
- );
97
- }
98
- throw error;
99
- }
100
- throw new ManifestMCPError(
101
- ManifestMCPErrorCode.TX_FAILED,
102
- `Tx ${module} ${subcommand} failed: ${error instanceof Error ? error.message : String(error)}`,
103
- { module, subcommand, args }
104
- );
105
- }
106
- }