@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/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
|
-
}
|