@manifest-network/manifest-mcp-browser 0.1.1 → 0.1.6

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 (131) hide show
  1. package/.github/workflows/publish.yml +4 -2
  2. package/CLAUDE.md +11 -6
  3. package/README.md +1 -1
  4. package/dist/client.d.ts +6 -1
  5. package/dist/client.d.ts.map +1 -1
  6. package/dist/client.js +77 -21
  7. package/dist/client.js.map +1 -1
  8. package/dist/cosmos.d.ts.map +1 -1
  9. package/dist/cosmos.js +7 -57
  10. package/dist/cosmos.js.map +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +16 -25
  13. package/dist/index.js.map +1 -1
  14. package/dist/modules.d.ts +30 -1
  15. package/dist/modules.d.ts.map +1 -1
  16. package/dist/modules.js +98 -1
  17. package/dist/modules.js.map +1 -1
  18. package/dist/modules.test.js +60 -1
  19. package/dist/modules.test.js.map +1 -1
  20. package/dist/queries/auth.d.ts +7 -1
  21. package/dist/queries/auth.d.ts.map +1 -1
  22. package/dist/queries/auth.js +18 -45
  23. package/dist/queries/auth.js.map +1 -1
  24. package/dist/queries/bank.d.ts +7 -1
  25. package/dist/queries/bank.d.ts.map +1 -1
  26. package/dist/queries/bank.js +24 -38
  27. package/dist/queries/bank.js.map +1 -1
  28. package/dist/queries/billing.d.ts +7 -1
  29. package/dist/queries/billing.d.ts.map +1 -1
  30. package/dist/queries/billing.js +28 -54
  31. package/dist/queries/billing.js.map +1 -1
  32. package/dist/queries/distribution.d.ts +7 -1
  33. package/dist/queries/distribution.d.ts.map +1 -1
  34. package/dist/queries/distribution.js +18 -36
  35. package/dist/queries/distribution.js.map +1 -1
  36. package/dist/queries/gov.d.ts +7 -1
  37. package/dist/queries/gov.d.ts.map +1 -1
  38. package/dist/queries/gov.js +24 -41
  39. package/dist/queries/gov.js.map +1 -1
  40. package/dist/queries/index.d.ts +2 -1
  41. package/dist/queries/index.d.ts.map +1 -1
  42. package/dist/queries/index.js +1 -1
  43. package/dist/queries/index.js.map +1 -1
  44. package/dist/queries/sku.d.ts +13 -0
  45. package/dist/queries/sku.d.ts.map +1 -0
  46. package/dist/queries/sku.js +60 -0
  47. package/dist/queries/sku.js.map +1 -0
  48. package/dist/queries/staking.d.ts +7 -1
  49. package/dist/queries/staking.d.ts.map +1 -1
  50. package/dist/queries/staking.js +36 -59
  51. package/dist/queries/staking.js.map +1 -1
  52. package/dist/queries/utils.d.ts +60 -10
  53. package/dist/queries/utils.d.ts.map +1 -1
  54. package/dist/queries/utils.js +80 -12
  55. package/dist/queries/utils.js.map +1 -1
  56. package/dist/queries/utils.test.js +68 -8
  57. package/dist/queries/utils.test.js.map +1 -1
  58. package/dist/transactions/bank.d.ts +2 -2
  59. package/dist/transactions/bank.d.ts.map +1 -1
  60. package/dist/transactions/bank.js +9 -18
  61. package/dist/transactions/bank.js.map +1 -1
  62. package/dist/transactions/billing.d.ts +2 -2
  63. package/dist/transactions/billing.d.ts.map +1 -1
  64. package/dist/transactions/billing.js +125 -89
  65. package/dist/transactions/billing.js.map +1 -1
  66. package/dist/transactions/distribution.d.ts +2 -2
  67. package/dist/transactions/distribution.d.ts.map +1 -1
  68. package/dist/transactions/distribution.js +7 -13
  69. package/dist/transactions/distribution.js.map +1 -1
  70. package/dist/transactions/gov.d.ts +2 -2
  71. package/dist/transactions/gov.d.ts.map +1 -1
  72. package/dist/transactions/gov.js +29 -20
  73. package/dist/transactions/gov.js.map +1 -1
  74. package/dist/transactions/index.d.ts +1 -1
  75. package/dist/transactions/index.d.ts.map +1 -1
  76. package/dist/transactions/index.js +1 -1
  77. package/dist/transactions/index.js.map +1 -1
  78. package/dist/transactions/manifest.d.ts +2 -2
  79. package/dist/transactions/manifest.d.ts.map +1 -1
  80. package/dist/transactions/manifest.js +7 -14
  81. package/dist/transactions/manifest.js.map +1 -1
  82. package/dist/transactions/sku.d.ts +7 -0
  83. package/dist/transactions/sku.d.ts.map +1 -0
  84. package/dist/transactions/sku.js +184 -0
  85. package/dist/transactions/sku.js.map +1 -0
  86. package/dist/transactions/staking.d.ts +2 -2
  87. package/dist/transactions/staking.d.ts.map +1 -1
  88. package/dist/transactions/staking.js +7 -13
  89. package/dist/transactions/staking.js.map +1 -1
  90. package/dist/transactions/utils.d.ts +65 -1
  91. package/dist/transactions/utils.d.ts.map +1 -1
  92. package/dist/transactions/utils.js +123 -2
  93. package/dist/transactions/utils.js.map +1 -1
  94. package/dist/transactions/utils.test.js +351 -1
  95. package/dist/transactions/utils.test.js.map +1 -1
  96. package/dist/types.d.ts +218 -8
  97. package/dist/types.d.ts.map +1 -1
  98. package/dist/types.js.map +1 -1
  99. package/dist/wallet/mnemonic.d.ts +1 -0
  100. package/dist/wallet/mnemonic.d.ts.map +1 -1
  101. package/dist/wallet/mnemonic.js +34 -13
  102. package/dist/wallet/mnemonic.js.map +1 -1
  103. package/package.json +5 -1
  104. package/src/client.ts +84 -21
  105. package/src/cosmos.ts +13 -109
  106. package/src/index.ts +17 -23
  107. package/src/modules.test.ts +62 -0
  108. package/src/modules.ts +155 -5
  109. package/src/queries/auth.ts +35 -74
  110. package/src/queries/bank.ts +40 -58
  111. package/src/queries/billing.ts +46 -86
  112. package/src/queries/distribution.ts +35 -59
  113. package/src/queries/gov.ts +40 -64
  114. package/src/queries/index.ts +10 -1
  115. package/src/queries/sku.ts +85 -0
  116. package/src/queries/staking.ts +55 -91
  117. package/src/queries/utils.test.ts +103 -8
  118. package/src/queries/utils.ts +119 -12
  119. package/src/transactions/bank.ts +9 -33
  120. package/src/transactions/billing.ts +155 -141
  121. package/src/transactions/distribution.ts +7 -29
  122. package/src/transactions/gov.ts +33 -37
  123. package/src/transactions/index.ts +1 -1
  124. package/src/transactions/manifest.ts +7 -29
  125. package/src/transactions/sku.ts +232 -0
  126. package/src/transactions/staking.ts +7 -29
  127. package/src/transactions/utils.test.ts +390 -1
  128. package/src/transactions/utils.ts +194 -2
  129. package/src/types.ts +344 -9
  130. package/src/wallet/mnemonic.ts +41 -17
  131. package/.claude/settings.local.json +0 -20
package/src/types.ts CHANGED
@@ -42,15 +42,6 @@ export interface WalletProvider {
42
42
  disconnect?(): Promise<void>;
43
43
  }
44
44
 
45
- /**
46
- * Result from a Cosmos query
47
- */
48
- export interface CosmosQueryResult {
49
- readonly module: string;
50
- readonly subcommand: string;
51
- readonly result: Record<string, unknown>;
52
- }
53
-
54
45
  /**
55
46
  * Result from a Cosmos transaction
56
47
  */
@@ -65,6 +56,10 @@ export interface CosmosTxResult {
65
56
  confirmationHeight?: string;
66
57
  readonly gasUsed?: string;
67
58
  readonly gasWanted?: string;
59
+ readonly events?: readonly {
60
+ readonly type: string;
61
+ readonly attributes: readonly { readonly key: string; readonly value: string }[];
62
+ }[];
68
63
  }
69
64
 
70
65
  /**
@@ -160,3 +155,343 @@ export class ManifestMCPError extends Error {
160
155
  export interface AccountInfo {
161
156
  readonly address: string;
162
157
  }
158
+
159
+ // ============================================================================
160
+ // Query Result Types
161
+ // ============================================================================
162
+
163
+ /**
164
+ * Pagination response from Cosmos SDK queries
165
+ */
166
+ export interface PaginationResponse {
167
+ readonly nextKey?: Uint8Array;
168
+ readonly total?: bigint;
169
+ }
170
+
171
+ /**
172
+ * Base interface for paginated query results
173
+ */
174
+ export interface PaginatedResult {
175
+ readonly pagination?: PaginationResponse;
176
+ }
177
+
178
+ /**
179
+ * Coin type from Cosmos SDK
180
+ */
181
+ export interface Coin {
182
+ readonly denom: string;
183
+ readonly amount: string;
184
+ }
185
+
186
+ /**
187
+ * DecCoin type from Cosmos SDK (for rewards, etc.)
188
+ */
189
+ export interface DecCoin {
190
+ readonly denom: string;
191
+ readonly amount: string;
192
+ }
193
+
194
+ // Bank query results
195
+ export interface BalanceResult {
196
+ readonly balance?: Coin;
197
+ }
198
+
199
+ export interface BalancesResult extends PaginatedResult {
200
+ readonly balances: readonly Coin[];
201
+ }
202
+
203
+ export interface TotalSupplyResult extends PaginatedResult {
204
+ readonly supply: readonly Coin[];
205
+ }
206
+
207
+ export interface SupplyOfResult {
208
+ readonly amount?: Coin;
209
+ }
210
+
211
+ export interface DenomMetadataResult {
212
+ readonly metadata?: unknown;
213
+ }
214
+
215
+ export interface DenomsMetadataResult extends PaginatedResult {
216
+ readonly metadatas: readonly unknown[];
217
+ }
218
+
219
+ export interface SendEnabledResult extends PaginatedResult {
220
+ readonly sendEnabled: readonly unknown[];
221
+ }
222
+
223
+ export interface BankParamsResult {
224
+ readonly params?: unknown;
225
+ }
226
+
227
+ // Staking query results
228
+ export interface DelegationResult {
229
+ readonly delegationResponse?: unknown;
230
+ }
231
+
232
+ export interface DelegationsResult extends PaginatedResult {
233
+ readonly delegationResponses: readonly unknown[];
234
+ }
235
+
236
+ export interface UnbondingDelegationResult {
237
+ readonly unbond?: unknown;
238
+ }
239
+
240
+ export interface UnbondingDelegationsResult extends PaginatedResult {
241
+ readonly unbondingResponses: readonly unknown[];
242
+ }
243
+
244
+ export interface RedelegationsResult extends PaginatedResult {
245
+ readonly redelegationResponses: readonly unknown[];
246
+ }
247
+
248
+ export interface ValidatorResult {
249
+ readonly validator?: unknown;
250
+ }
251
+
252
+ export interface ValidatorsResult extends PaginatedResult {
253
+ readonly validators: readonly unknown[];
254
+ }
255
+
256
+ export interface StakingPoolResult {
257
+ readonly pool?: unknown;
258
+ }
259
+
260
+ export interface StakingParamsResult {
261
+ readonly params?: unknown;
262
+ }
263
+
264
+ export interface HistoricalInfoResult {
265
+ readonly hist?: unknown;
266
+ }
267
+
268
+ // Distribution query results
269
+ export interface RewardsResult {
270
+ readonly rewards: readonly DecCoin[];
271
+ readonly total?: readonly DecCoin[];
272
+ }
273
+
274
+ export interface CommissionResult {
275
+ readonly commission?: unknown;
276
+ }
277
+
278
+ export interface CommunityPoolResult {
279
+ readonly pool: readonly DecCoin[];
280
+ }
281
+
282
+ export interface DistributionParamsResult {
283
+ readonly params?: unknown;
284
+ }
285
+
286
+ export interface ValidatorOutstandingRewardsResult {
287
+ readonly rewards?: unknown;
288
+ }
289
+
290
+ export interface SlashesResult extends PaginatedResult {
291
+ readonly slashes: readonly unknown[];
292
+ }
293
+
294
+ export interface DelegatorValidatorsResult {
295
+ readonly validators: readonly string[];
296
+ }
297
+
298
+ export interface DelegatorWithdrawAddressResult {
299
+ readonly withdrawAddress: string;
300
+ }
301
+
302
+ // Gov query results
303
+ export interface ProposalResult {
304
+ readonly proposal?: unknown;
305
+ }
306
+
307
+ export interface ProposalsResult extends PaginatedResult {
308
+ readonly proposals: readonly unknown[];
309
+ }
310
+
311
+ export interface VoteResult {
312
+ readonly vote?: unknown;
313
+ }
314
+
315
+ export interface VotesResult extends PaginatedResult {
316
+ readonly votes: readonly unknown[];
317
+ }
318
+
319
+ export interface DepositResult {
320
+ readonly deposit?: unknown;
321
+ }
322
+
323
+ export interface DepositsResult extends PaginatedResult {
324
+ readonly deposits: readonly unknown[];
325
+ }
326
+
327
+ export interface TallyResult {
328
+ readonly tally?: unknown;
329
+ }
330
+
331
+ export interface GovParamsResult {
332
+ readonly votingParams?: unknown;
333
+ readonly depositParams?: unknown;
334
+ readonly tallyParams?: unknown;
335
+ readonly params?: unknown;
336
+ }
337
+
338
+ // Auth query results
339
+ export interface AuthAccountResult {
340
+ readonly account?: unknown;
341
+ }
342
+
343
+ export interface AuthAccountsResult extends PaginatedResult {
344
+ readonly accounts: readonly unknown[];
345
+ }
346
+
347
+ export interface AuthParamsResult {
348
+ readonly params?: unknown;
349
+ }
350
+
351
+ export interface ModuleAccountsResult {
352
+ readonly accounts: readonly unknown[];
353
+ }
354
+
355
+ export interface AddressBytesToStringResult {
356
+ readonly addressString: string;
357
+ }
358
+
359
+ export interface AddressStringToBytesResult {
360
+ readonly addressBytes: string;
361
+ }
362
+
363
+ export interface Bech32PrefixResult {
364
+ readonly bech32Prefix: string;
365
+ }
366
+
367
+ export interface AccountInfoResult {
368
+ readonly info?: unknown;
369
+ }
370
+
371
+ // Billing query results
372
+ export interface BillingParamsResult {
373
+ readonly params?: unknown;
374
+ }
375
+
376
+ export interface LeaseResult {
377
+ readonly lease?: unknown;
378
+ }
379
+
380
+ export interface LeasesResult extends PaginatedResult {
381
+ readonly leases: readonly unknown[];
382
+ }
383
+
384
+ export interface CreditAccountResult {
385
+ readonly creditAccount?: unknown;
386
+ }
387
+
388
+ export interface CreditAccountsResult extends PaginatedResult {
389
+ readonly creditAccounts: readonly unknown[];
390
+ }
391
+
392
+ export interface CreditAddressResult {
393
+ readonly creditAddress: string;
394
+ }
395
+
396
+ export interface WithdrawableAmountResult {
397
+ readonly amounts: readonly Coin[];
398
+ }
399
+
400
+ export interface ProviderWithdrawableResult {
401
+ readonly amounts: readonly Coin[];
402
+ }
403
+
404
+ export interface CreditEstimateResult {
405
+ readonly estimate: unknown;
406
+ }
407
+
408
+ // SKU query results
409
+ export interface SkuParamsResult {
410
+ readonly params?: unknown;
411
+ }
412
+
413
+ export interface ProviderResult {
414
+ readonly provider?: unknown;
415
+ }
416
+
417
+ export interface ProvidersResult extends PaginatedResult {
418
+ readonly providers: readonly unknown[];
419
+ }
420
+
421
+ export interface SkuResult {
422
+ readonly sku?: unknown;
423
+ }
424
+
425
+ export interface SkusResult extends PaginatedResult {
426
+ readonly skus: readonly unknown[];
427
+ }
428
+
429
+ /**
430
+ * Union type of all query results for type-safe handling
431
+ */
432
+ export type QueryResult =
433
+ | BalanceResult
434
+ | BalancesResult
435
+ | TotalSupplyResult
436
+ | SupplyOfResult
437
+ | DenomMetadataResult
438
+ | DenomsMetadataResult
439
+ | SendEnabledResult
440
+ | BankParamsResult
441
+ | DelegationResult
442
+ | DelegationsResult
443
+ | UnbondingDelegationResult
444
+ | UnbondingDelegationsResult
445
+ | RedelegationsResult
446
+ | ValidatorResult
447
+ | ValidatorsResult
448
+ | StakingPoolResult
449
+ | StakingParamsResult
450
+ | HistoricalInfoResult
451
+ | RewardsResult
452
+ | CommissionResult
453
+ | CommunityPoolResult
454
+ | DistributionParamsResult
455
+ | ValidatorOutstandingRewardsResult
456
+ | SlashesResult
457
+ | DelegatorValidatorsResult
458
+ | DelegatorWithdrawAddressResult
459
+ | ProposalResult
460
+ | ProposalsResult
461
+ | VoteResult
462
+ | VotesResult
463
+ | DepositResult
464
+ | DepositsResult
465
+ | TallyResult
466
+ | GovParamsResult
467
+ | AuthAccountResult
468
+ | AuthAccountsResult
469
+ | AuthParamsResult
470
+ | ModuleAccountsResult
471
+ | AddressBytesToStringResult
472
+ | AddressStringToBytesResult
473
+ | Bech32PrefixResult
474
+ | AccountInfoResult
475
+ | BillingParamsResult
476
+ | LeaseResult
477
+ | LeasesResult
478
+ | CreditAccountResult
479
+ | CreditAccountsResult
480
+ | CreditAddressResult
481
+ | WithdrawableAmountResult
482
+ | ProviderWithdrawableResult
483
+ | CreditEstimateResult
484
+ | SkuParamsResult
485
+ | ProviderResult
486
+ | ProvidersResult
487
+ | SkuResult
488
+ | SkusResult;
489
+
490
+ /**
491
+ * Result from a Cosmos query
492
+ */
493
+ export interface CosmosQueryResult {
494
+ readonly module: string;
495
+ readonly subcommand: string;
496
+ readonly result: QueryResult;
497
+ }
@@ -14,6 +14,9 @@ export class MnemonicWalletProvider implements WalletProvider {
14
14
  private address: string | null = null;
15
15
  private disconnected: boolean = false;
16
16
 
17
+ // Promise to prevent concurrent wallet initialization (lazy init race condition)
18
+ private initPromise: Promise<void> | null = null;
19
+
17
20
  constructor(config: ManifestMCPConfig, mnemonic: string) {
18
21
  this.config = config;
19
22
  this.mnemonic = mnemonic;
@@ -30,10 +33,16 @@ export class MnemonicWalletProvider implements WalletProvider {
30
33
  );
31
34
  }
32
35
 
36
+ // Return if already initialized
33
37
  if (this.wallet) {
34
38
  return;
35
39
  }
36
40
 
41
+ // If initialization is already in progress, wait for it
42
+ if (this.initPromise) {
43
+ return this.initPromise;
44
+ }
45
+
37
46
  if (!this.mnemonic) {
38
47
  throw new ManifestMCPError(
39
48
  ManifestMCPErrorCode.WALLET_NOT_CONNECTED,
@@ -41,28 +50,42 @@ export class MnemonicWalletProvider implements WalletProvider {
41
50
  );
42
51
  }
43
52
 
44
- const prefix = this.config.addressPrefix ?? 'manifest';
45
-
46
- try {
47
- this.wallet = await DirectSecp256k1HdWallet.fromMnemonic(this.mnemonic, {
48
- prefix,
49
- });
50
-
51
- const accounts = await this.wallet.getAccounts();
52
- if (accounts.length === 0) {
53
+ // Start initialization and cache the promise to prevent concurrent init
54
+ this.initPromise = (async () => {
55
+ const prefix = this.config.addressPrefix ?? 'manifest';
56
+
57
+ try {
58
+ this.wallet = await DirectSecp256k1HdWallet.fromMnemonic(this.mnemonic!, {
59
+ prefix,
60
+ });
61
+
62
+ const accounts = await this.wallet.getAccounts();
63
+ if (accounts.length === 0) {
64
+ throw new ManifestMCPError(
65
+ ManifestMCPErrorCode.INVALID_MNEMONIC,
66
+ 'No accounts derived from mnemonic'
67
+ );
68
+ }
69
+
70
+ this.address = accounts[0].address;
71
+ // Clear promise after successful init - wallet check will short-circuit future calls
72
+ this.initPromise = null;
73
+ } catch (error) {
74
+ // Clear state on failure so retry is possible
75
+ this.initPromise = null;
76
+ this.wallet = null;
77
+ this.address = null;
78
+ if (error instanceof ManifestMCPError) {
79
+ throw error;
80
+ }
53
81
  throw new ManifestMCPError(
54
82
  ManifestMCPErrorCode.INVALID_MNEMONIC,
55
- 'No accounts derived from mnemonic'
83
+ `Failed to create wallet from mnemonic: ${error instanceof Error ? error.message : String(error)}`
56
84
  );
57
85
  }
86
+ })();
58
87
 
59
- this.address = accounts[0].address;
60
- } catch (error) {
61
- throw new ManifestMCPError(
62
- ManifestMCPErrorCode.INVALID_MNEMONIC,
63
- `Failed to create wallet from mnemonic: ${error instanceof Error ? error.message : String(error)}`
64
- );
65
- }
88
+ return this.initPromise;
66
89
  }
67
90
 
68
91
  /**
@@ -85,6 +108,7 @@ export class MnemonicWalletProvider implements WalletProvider {
85
108
  this.mnemonic = null;
86
109
  this.wallet = null;
87
110
  this.address = null;
111
+ this.initPromise = null;
88
112
  this.disconnected = true;
89
113
  }
90
114
 
@@ -1,20 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(npm run lint)",
5
- "Bash(npm install:*)",
6
- "Bash(npm test:*)",
7
- "Bash(git init:*)",
8
- "Bash(npm run build:*)",
9
- "Bash(find:*)",
10
- "Bash(node -e:*)",
11
- "Bash(ls:*)",
12
- "Bash(git config:*)",
13
- "WebFetch(domain:docs.npmjs.com)",
14
- "WebSearch",
15
- "Bash(npm ls:*)",
16
- "WebFetch(domain:www.npmjs.com)",
17
- "WebFetch(domain:github.com)"
18
- ]
19
- }
20
- }