@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.
Files changed (95) hide show
  1. package/README.md +5 -2
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +0 -10
  4. package/dist/config.js.map +1 -1
  5. package/dist/index.d.ts +0 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +3 -7
  8. package/dist/index.js.map +1 -1
  9. package/dist/modules.d.ts.map +1 -1
  10. package/dist/modules.js +42 -0
  11. package/dist/modules.js.map +1 -1
  12. package/dist/queries/group.d.ts +12 -0
  13. package/dist/queries/group.d.ts.map +1 -0
  14. package/dist/queries/group.js +107 -0
  15. package/dist/queries/group.js.map +1 -0
  16. package/dist/queries/index.d.ts +2 -0
  17. package/dist/queries/index.d.ts.map +1 -1
  18. package/dist/queries/index.js +2 -0
  19. package/dist/queries/index.js.map +1 -1
  20. package/dist/queries/utils.d.ts +3 -18
  21. package/dist/queries/utils.d.ts.map +1 -1
  22. package/dist/queries/utils.js +2 -17
  23. package/dist/queries/utils.js.map +1 -1
  24. package/dist/transactions/bank.d.ts.map +1 -1
  25. package/dist/transactions/bank.js +7 -5
  26. package/dist/transactions/bank.js.map +1 -1
  27. package/dist/transactions/gov.d.ts.map +1 -1
  28. package/dist/transactions/gov.js +9 -30
  29. package/dist/transactions/gov.js.map +1 -1
  30. package/dist/transactions/group.d.ts +7 -0
  31. package/dist/transactions/group.d.ts.map +1 -0
  32. package/dist/transactions/group.js +339 -0
  33. package/dist/transactions/group.js.map +1 -0
  34. package/dist/transactions/index.d.ts +2 -0
  35. package/dist/transactions/index.d.ts.map +1 -1
  36. package/dist/transactions/index.js +2 -0
  37. package/dist/transactions/index.js.map +1 -1
  38. package/dist/transactions/utils.d.ts +37 -0
  39. package/dist/transactions/utils.d.ts.map +1 -1
  40. package/dist/transactions/utils.js +43 -0
  41. package/dist/transactions/utils.js.map +1 -1
  42. package/dist/types.d.ts +31 -3
  43. package/dist/types.d.ts.map +1 -1
  44. package/dist/types.js.map +1 -1
  45. package/package.json +5 -2
  46. package/.github/workflows/ci.yml +0 -37
  47. package/.github/workflows/publish.yml +0 -53
  48. package/CLAUDE.md +0 -111
  49. package/dist/config.test.d.ts +0 -2
  50. package/dist/config.test.d.ts.map +0 -1
  51. package/dist/config.test.js +0 -251
  52. package/dist/config.test.js.map +0 -1
  53. package/dist/modules.test.d.ts +0 -2
  54. package/dist/modules.test.d.ts.map +0 -1
  55. package/dist/modules.test.js +0 -159
  56. package/dist/modules.test.js.map +0 -1
  57. package/dist/queries/utils.test.d.ts +0 -2
  58. package/dist/queries/utils.test.d.ts.map +0 -1
  59. package/dist/queries/utils.test.js +0 -117
  60. package/dist/queries/utils.test.js.map +0 -1
  61. package/dist/transactions/utils.test.d.ts +0 -2
  62. package/dist/transactions/utils.test.d.ts.map +0 -1
  63. package/dist/transactions/utils.test.js +0 -471
  64. package/dist/transactions/utils.test.js.map +0 -1
  65. package/src/client.ts +0 -288
  66. package/src/config.test.ts +0 -299
  67. package/src/config.ts +0 -174
  68. package/src/cosmos.ts +0 -106
  69. package/src/index.ts +0 -478
  70. package/src/modules.test.ts +0 -189
  71. package/src/modules.ts +0 -428
  72. package/src/queries/auth.ts +0 -97
  73. package/src/queries/bank.ts +0 -99
  74. package/src/queries/billing.ts +0 -124
  75. package/src/queries/distribution.ts +0 -114
  76. package/src/queries/gov.ts +0 -104
  77. package/src/queries/index.ts +0 -16
  78. package/src/queries/sku.ts +0 -85
  79. package/src/queries/staking.ts +0 -154
  80. package/src/queries/utils.test.ts +0 -156
  81. package/src/queries/utils.ts +0 -145
  82. package/src/transactions/bank.ts +0 -86
  83. package/src/transactions/billing.ts +0 -286
  84. package/src/transactions/distribution.ts +0 -76
  85. package/src/transactions/gov.ts +0 -191
  86. package/src/transactions/index.ts +0 -7
  87. package/src/transactions/manifest.ts +0 -67
  88. package/src/transactions/sku.ts +0 -232
  89. package/src/transactions/staking.ts +0 -85
  90. package/src/transactions/utils.test.ts +0 -518
  91. package/src/transactions/utils.ts +0 -348
  92. package/src/types.ts +0 -497
  93. package/src/wallet/index.ts +0 -2
  94. package/src/wallet/mnemonic.ts +0 -146
  95. package/tsconfig.json +0 -23
@@ -1,124 +0,0 @@
1
- import { ManifestQueryClient } from '../client.js';
2
- import {
3
- BillingParamsResult, LeaseResult, LeasesResult, CreditAccountResult,
4
- CreditAccountsResult, CreditAddressResult, WithdrawableAmountResult,
5
- ProviderWithdrawableResult, CreditEstimateResult
6
- } from '../types.js';
7
- import { parseBigInt, requireArgs, extractPaginationArgs } from './utils.js';
8
- import { throwUnsupportedSubcommand } from '../modules.js';
9
-
10
- /** Billing query result union type */
11
- type BillingQueryResult =
12
- | BillingParamsResult
13
- | LeaseResult
14
- | LeasesResult
15
- | CreditAccountResult
16
- | CreditAccountsResult
17
- | CreditAddressResult
18
- | WithdrawableAmountResult
19
- | ProviderWithdrawableResult
20
- | CreditEstimateResult;
21
-
22
- /**
23
- * Route billing module query to manifestjs query client
24
- *
25
- * Paginated queries support --limit flag (default: 100, max: 1000)
26
- */
27
- export async function routeBillingQuery(
28
- queryClient: ManifestQueryClient,
29
- subcommand: string,
30
- args: string[]
31
- ): Promise<BillingQueryResult> {
32
- const billing = queryClient.liftedinit.billing.v1;
33
-
34
- switch (subcommand) {
35
- case 'params': {
36
- const result = await billing.params({});
37
- return { params: result.params };
38
- }
39
-
40
- case 'lease': {
41
- requireArgs(args, 1, ['lease-uuid'], 'billing lease');
42
- const [leaseUuid] = args;
43
- const result = await billing.lease({ leaseUuid });
44
- return { lease: result.lease };
45
- }
46
-
47
- case 'leases': {
48
- const { pagination } = extractPaginationArgs(args, 'billing leases');
49
- // stateFilter: 0 = LEASE_STATE_UNSPECIFIED (returns all)
50
- const result = await billing.leases({ stateFilter: 0, pagination });
51
- return { leases: result.leases, pagination: result.pagination };
52
- }
53
-
54
- case 'leases-by-tenant': {
55
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'billing leases-by-tenant');
56
- requireArgs(remainingArgs, 1, ['tenant-address'], 'billing leases-by-tenant');
57
- const [tenant] = remainingArgs;
58
- const result = await billing.leasesByTenant({ tenant, stateFilter: 0, pagination });
59
- return { leases: result.leases, pagination: result.pagination };
60
- }
61
-
62
- case 'leases-by-provider': {
63
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'billing leases-by-provider');
64
- requireArgs(remainingArgs, 1, ['provider-uuid'], 'billing leases-by-provider');
65
- const [providerUuid] = remainingArgs;
66
- const result = await billing.leasesByProvider({ providerUuid, stateFilter: 0, pagination });
67
- return { leases: result.leases, pagination: result.pagination };
68
- }
69
-
70
- case 'leases-by-sku': {
71
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'billing leases-by-sku');
72
- requireArgs(remainingArgs, 1, ['sku-uuid'], 'billing leases-by-sku');
73
- const [skuUuid] = remainingArgs;
74
- const result = await billing.leasesBySKU({ skuUuid, stateFilter: 0, pagination });
75
- return { leases: result.leases, pagination: result.pagination };
76
- }
77
-
78
- case 'credit-account': {
79
- requireArgs(args, 1, ['tenant-address'], 'billing credit-account');
80
- const [tenant] = args;
81
- const result = await billing.creditAccount({ tenant });
82
- return { creditAccount: result.creditAccount };
83
- }
84
-
85
- case 'credit-accounts': {
86
- const { pagination } = extractPaginationArgs(args, 'billing credit-accounts');
87
- const result = await billing.creditAccounts({ pagination });
88
- return { creditAccounts: result.creditAccounts, pagination: result.pagination };
89
- }
90
-
91
- case 'credit-address': {
92
- requireArgs(args, 1, ['tenant-address'], 'billing credit-address');
93
- const [tenant] = args;
94
- const result = await billing.creditAddress({ tenant });
95
- return { creditAddress: result.creditAddress };
96
- }
97
-
98
- case 'withdrawable-amount': {
99
- requireArgs(args, 1, ['lease-uuid'], 'billing withdrawable-amount');
100
- const [leaseUuid] = args;
101
- const result = await billing.withdrawableAmount({ leaseUuid });
102
- return { amounts: result.amounts };
103
- }
104
-
105
- case 'provider-withdrawable': {
106
- requireArgs(args, 1, ['provider-uuid'], 'billing provider-withdrawable');
107
- const [providerUuid] = args;
108
- // Optional: limit for max leases to process (default 100, max 1000)
109
- const limit = args[1] ? parseBigInt(args[1], 'limit') : BigInt(100);
110
- const result = await billing.providerWithdrawable({ providerUuid, limit });
111
- return { amounts: result.amounts };
112
- }
113
-
114
- case 'credit-estimate': {
115
- requireArgs(args, 1, ['tenant-address'], 'billing credit-estimate');
116
- const [tenant] = args;
117
- const result = await billing.creditEstimate({ tenant });
118
- return { estimate: result };
119
- }
120
-
121
- default:
122
- throwUnsupportedSubcommand('query', 'billing', subcommand);
123
- }
124
- }
@@ -1,114 +0,0 @@
1
- import { ManifestQueryClient } from '../client.js';
2
- import {
3
- RewardsResult, CommissionResult, CommunityPoolResult, DistributionParamsResult,
4
- ValidatorOutstandingRewardsResult, SlashesResult, DelegatorValidatorsResult,
5
- DelegatorWithdrawAddressResult
6
- } from '../types.js';
7
- import { parseBigInt, requireArgs, extractPaginationArgs } from './utils.js';
8
- import { throwUnsupportedSubcommand } from '../modules.js';
9
-
10
- /** Distribution query result union type */
11
- type DistributionQueryResult =
12
- | RewardsResult
13
- | CommissionResult
14
- | CommunityPoolResult
15
- | DistributionParamsResult
16
- | ValidatorOutstandingRewardsResult
17
- | SlashesResult
18
- | DelegatorValidatorsResult
19
- | DelegatorWithdrawAddressResult;
20
-
21
- /**
22
- * Route distribution query to manifestjs query client
23
- *
24
- * Paginated queries support --limit flag (default: 100, max: 1000)
25
- */
26
- export async function routeDistributionQuery(
27
- queryClient: ManifestQueryClient,
28
- subcommand: string,
29
- args: string[]
30
- ): Promise<DistributionQueryResult> {
31
- const distribution = queryClient.cosmos.distribution.v1beta1;
32
-
33
- switch (subcommand) {
34
- case 'rewards': {
35
- requireArgs(args, 1, ['delegator-address'], 'distribution rewards');
36
- const [delegatorAddress] = args;
37
- // Optional: validator address for specific validator rewards
38
- const validatorAddress = args[1];
39
-
40
- if (validatorAddress) {
41
- // Get rewards from specific validator
42
- const result = await distribution.delegationRewards({
43
- delegatorAddress,
44
- validatorAddress,
45
- });
46
- return { rewards: result.rewards };
47
- } else {
48
- // Get rewards from all validators
49
- const result = await distribution.delegationTotalRewards({ delegatorAddress });
50
- return {
51
- rewards: result.rewards,
52
- total: result.total,
53
- };
54
- }
55
- }
56
-
57
- case 'commission': {
58
- requireArgs(args, 1, ['validator-address'], 'distribution commission');
59
- const [validatorAddress] = args;
60
- const result = await distribution.validatorCommission({ validatorAddress });
61
- return { commission: result.commission };
62
- }
63
-
64
- case 'community-pool': {
65
- const result = await distribution.communityPool({});
66
- return { pool: result.pool };
67
- }
68
-
69
- case 'params': {
70
- const result = await distribution.params({});
71
- return { params: result.params };
72
- }
73
-
74
- case 'validator-outstanding-rewards': {
75
- requireArgs(args, 1, ['validator-address'], 'distribution validator-outstanding-rewards');
76
- const [validatorAddress] = args;
77
- const result = await distribution.validatorOutstandingRewards({ validatorAddress });
78
- return { rewards: result.rewards };
79
- }
80
-
81
- case 'slashes': {
82
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'distribution slashes');
83
- requireArgs(remainingArgs, 1, ['validator-address'], 'distribution slashes');
84
- const [validatorAddress] = remainingArgs;
85
- // Optional: starting and ending height for filtering
86
- const startingHeight = remainingArgs[1] ? parseBigInt(remainingArgs[1], 'starting-height') : BigInt(0);
87
- const endingHeight = remainingArgs[2] ? parseBigInt(remainingArgs[2], 'ending-height') : BigInt(Number.MAX_SAFE_INTEGER);
88
- const result = await distribution.validatorSlashes({
89
- validatorAddress,
90
- startingHeight,
91
- endingHeight,
92
- pagination,
93
- });
94
- return { slashes: result.slashes, pagination: result.pagination };
95
- }
96
-
97
- case 'delegator-validators': {
98
- requireArgs(args, 1, ['delegator-address'], 'distribution delegator-validators');
99
- const [delegatorAddress] = args;
100
- const result = await distribution.delegatorValidators({ delegatorAddress });
101
- return { validators: result.validators };
102
- }
103
-
104
- case 'delegator-withdraw-address': {
105
- requireArgs(args, 1, ['delegator-address'], 'distribution delegator-withdraw-address');
106
- const [delegatorAddress] = args;
107
- const result = await distribution.delegatorWithdrawAddress({ delegatorAddress });
108
- return { withdrawAddress: result.withdrawAddress };
109
- }
110
-
111
- default:
112
- throwUnsupportedSubcommand('query', 'distribution', subcommand);
113
- }
114
- }
@@ -1,104 +0,0 @@
1
- import { ManifestQueryClient } from '../client.js';
2
- import {
3
- ProposalResult, ProposalsResult, VoteResult, VotesResult,
4
- DepositResult, DepositsResult, TallyResult, GovParamsResult
5
- } from '../types.js';
6
- import { parseBigInt, parseInteger, requireArgs, extractPaginationArgs } from './utils.js';
7
- import { throwUnsupportedSubcommand } from '../modules.js';
8
-
9
- /** Gov query result union type */
10
- type GovQueryResult =
11
- | ProposalResult
12
- | ProposalsResult
13
- | VoteResult
14
- | VotesResult
15
- | DepositResult
16
- | DepositsResult
17
- | TallyResult
18
- | GovParamsResult;
19
-
20
- /**
21
- * Route gov query to manifestjs query client
22
- *
23
- * Paginated queries support --limit flag (default: 100, max: 1000)
24
- */
25
- export async function routeGovQuery(
26
- queryClient: ManifestQueryClient,
27
- subcommand: string,
28
- args: string[]
29
- ): Promise<GovQueryResult> {
30
- const gov = queryClient.cosmos.gov.v1;
31
-
32
- switch (subcommand) {
33
- case 'proposal': {
34
- requireArgs(args, 1, ['proposal-id'], 'gov proposal');
35
- const proposalId = parseBigInt(args[0], 'proposal-id');
36
- const result = await gov.proposal({ proposalId });
37
- return { proposal: result.proposal };
38
- }
39
-
40
- case 'proposals': {
41
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'gov proposals');
42
- // All optional: status filter, voter, depositor
43
- const proposalStatus = remainingArgs[0] ? parseInteger(remainingArgs[0], 'status') : 0;
44
- const voter = remainingArgs[1] || '';
45
- const depositor = remainingArgs[2] || '';
46
- const result = await gov.proposals({ proposalStatus, voter, depositor, pagination });
47
- return { proposals: result.proposals, pagination: result.pagination };
48
- }
49
-
50
- case 'vote': {
51
- requireArgs(args, 2, ['proposal-id', 'voter-address'], 'gov vote');
52
- const proposalId = parseBigInt(args[0], 'proposal-id');
53
- const voter = args[1];
54
- const result = await gov.vote({ proposalId, voter });
55
- return { vote: result.vote };
56
- }
57
-
58
- case 'votes': {
59
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'gov votes');
60
- requireArgs(remainingArgs, 1, ['proposal-id'], 'gov votes');
61
- const proposalId = parseBigInt(remainingArgs[0], 'proposal-id');
62
- const result = await gov.votes({ proposalId, pagination });
63
- return { votes: result.votes, pagination: result.pagination };
64
- }
65
-
66
- case 'deposit': {
67
- requireArgs(args, 2, ['proposal-id', 'depositor-address'], 'gov deposit');
68
- const proposalId = parseBigInt(args[0], 'proposal-id');
69
- const depositor = args[1];
70
- const result = await gov.deposit({ proposalId, depositor });
71
- return { deposit: result.deposit };
72
- }
73
-
74
- case 'deposits': {
75
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'gov deposits');
76
- requireArgs(remainingArgs, 1, ['proposal-id'], 'gov deposits');
77
- const proposalId = parseBigInt(remainingArgs[0], 'proposal-id');
78
- const result = await gov.deposits({ proposalId, pagination });
79
- return { deposits: result.deposits, pagination: result.pagination };
80
- }
81
-
82
- case 'tally': {
83
- requireArgs(args, 1, ['proposal-id'], 'gov tally');
84
- const proposalId = parseBigInt(args[0], 'proposal-id');
85
- const result = await gov.tallyResult({ proposalId });
86
- return { tally: result.tally };
87
- }
88
-
89
- case 'params': {
90
- // Optional: params type (defaults to 'tallying')
91
- const paramsType = args[0] || 'tallying';
92
- const result = await gov.params({ paramsType });
93
- return {
94
- votingParams: result.votingParams,
95
- depositParams: result.depositParams,
96
- tallyParams: result.tallyParams,
97
- params: result.params,
98
- };
99
- }
100
-
101
- default:
102
- throwUnsupportedSubcommand('query', 'gov', subcommand);
103
- }
104
- }
@@ -1,16 +0,0 @@
1
- export {
2
- parseBigInt,
3
- parseInteger,
4
- createPagination,
5
- extractPaginationArgs,
6
- DEFAULT_PAGE_LIMIT,
7
- MAX_PAGE_LIMIT,
8
- defaultPagination,
9
- } from './utils.js';
10
- export type { PaginationConfig } from './utils.js';
11
- export { routeBankQuery } from './bank.js';
12
- export { routeStakingQuery } from './staking.js';
13
- export { routeDistributionQuery } from './distribution.js';
14
- export { routeGovQuery } from './gov.js';
15
- export { routeAuthQuery } from './auth.js';
16
- export { routeBillingQuery } from './billing.js';
@@ -1,85 +0,0 @@
1
- import { ManifestQueryClient } from '../client.js';
2
- import {
3
- SkuParamsResult, ProviderResult, ProvidersResult,
4
- SkuResult, SkusResult
5
- } from '../types.js';
6
- import { requireArgs, extractPaginationArgs, extractBooleanFlag } from './utils.js';
7
- import { throwUnsupportedSubcommand } from '../modules.js';
8
-
9
- /** SKU query result union type */
10
- type SkuQueryResult =
11
- | SkuParamsResult
12
- | ProviderResult
13
- | ProvidersResult
14
- | SkuResult
15
- | SkusResult;
16
-
17
- /**
18
- * Route SKU module query to manifestjs query client
19
- *
20
- * Paginated queries support --limit flag (default: 100, max: 1000)
21
- * Filterable queries support --active-only flag
22
- */
23
- export async function routeSkuQuery(
24
- queryClient: ManifestQueryClient,
25
- subcommand: string,
26
- args: string[]
27
- ): Promise<SkuQueryResult> {
28
- const sku = queryClient.liftedinit.sku.v1;
29
-
30
- switch (subcommand) {
31
- case 'params': {
32
- const result = await sku.params({});
33
- return { params: result.params };
34
- }
35
-
36
- case 'provider': {
37
- requireArgs(args, 1, ['provider-uuid'], 'sku provider');
38
- const [uuid] = args;
39
- const result = await sku.provider({ uuid });
40
- return { provider: result.provider };
41
- }
42
-
43
- case 'providers': {
44
- const { value: activeOnly, remainingArgs: afterBool } = extractBooleanFlag(args, '--active-only');
45
- const { pagination } = extractPaginationArgs(afterBool, 'sku providers');
46
- const result = await sku.providers({ pagination, activeOnly });
47
- return { providers: result.providers, pagination: result.pagination };
48
- }
49
-
50
- case 'sku': {
51
- requireArgs(args, 1, ['sku-uuid'], 'sku sku');
52
- const [uuid] = args;
53
- const result = await sku.sKU({ uuid });
54
- return { sku: result.sku };
55
- }
56
-
57
- case 'skus': {
58
- const { value: activeOnly, remainingArgs: afterBool } = extractBooleanFlag(args, '--active-only');
59
- const { pagination } = extractPaginationArgs(afterBool, 'sku skus');
60
- const result = await sku.sKUs({ pagination, activeOnly });
61
- return { skus: result.skus, pagination: result.pagination };
62
- }
63
-
64
- case 'skus-by-provider': {
65
- const { value: activeOnly, remainingArgs: afterBool } = extractBooleanFlag(args, '--active-only');
66
- const { pagination, remainingArgs } = extractPaginationArgs(afterBool, 'sku skus-by-provider');
67
- requireArgs(remainingArgs, 1, ['provider-uuid'], 'sku skus-by-provider');
68
- const [providerUuid] = remainingArgs;
69
- const result = await sku.sKUsByProvider({ providerUuid, pagination, activeOnly });
70
- return { skus: result.skus, pagination: result.pagination };
71
- }
72
-
73
- case 'provider-by-address': {
74
- const { value: activeOnly, remainingArgs: afterBool } = extractBooleanFlag(args, '--active-only');
75
- const { pagination, remainingArgs } = extractPaginationArgs(afterBool, 'sku provider-by-address');
76
- requireArgs(remainingArgs, 1, ['address'], 'sku provider-by-address');
77
- const [address] = remainingArgs;
78
- const result = await sku.providerByAddress({ address, pagination, activeOnly });
79
- return { providers: result.providers, pagination: result.pagination };
80
- }
81
-
82
- default:
83
- throwUnsupportedSubcommand('query', 'sku', subcommand);
84
- }
85
- }
@@ -1,154 +0,0 @@
1
- import { ManifestQueryClient } from '../client.js';
2
- import {
3
- DelegationResult, DelegationsResult, UnbondingDelegationResult, UnbondingDelegationsResult,
4
- RedelegationsResult, ValidatorResult, ValidatorsResult, StakingPoolResult,
5
- StakingParamsResult, HistoricalInfoResult
6
- } from '../types.js';
7
- import { parseBigInt, requireArgs, extractPaginationArgs } from './utils.js';
8
- import { throwUnsupportedSubcommand } from '../modules.js';
9
-
10
- /** Staking query result union type */
11
- type StakingQueryResult =
12
- | DelegationResult
13
- | DelegationsResult
14
- | UnbondingDelegationResult
15
- | UnbondingDelegationsResult
16
- | RedelegationsResult
17
- | ValidatorResult
18
- | ValidatorsResult
19
- | StakingPoolResult
20
- | StakingParamsResult
21
- | HistoricalInfoResult;
22
-
23
- /**
24
- * Route staking query to manifestjs query client
25
- *
26
- * Paginated queries support --limit flag (default: 100, max: 1000)
27
- */
28
- export async function routeStakingQuery(
29
- queryClient: ManifestQueryClient,
30
- subcommand: string,
31
- args: string[]
32
- ): Promise<StakingQueryResult> {
33
- const staking = queryClient.cosmos.staking.v1beta1;
34
-
35
- switch (subcommand) {
36
- case 'delegation': {
37
- requireArgs(args, 2, ['delegator-address', 'validator-address'], 'staking delegation');
38
- const [delegatorAddr, validatorAddr] = args;
39
- const result = await staking.delegation({
40
- delegatorAddr,
41
- validatorAddr,
42
- });
43
- return { delegationResponse: result.delegationResponse };
44
- }
45
-
46
- case 'delegations': {
47
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'staking delegations');
48
- requireArgs(remainingArgs, 1, ['delegator-address'], 'staking delegations');
49
- const [delegatorAddr] = remainingArgs;
50
- const result = await staking.delegatorDelegations({ delegatorAddr, pagination });
51
- return {
52
- delegationResponses: result.delegationResponses,
53
- pagination: result.pagination,
54
- };
55
- }
56
-
57
- case 'unbonding-delegation': {
58
- requireArgs(args, 2, ['delegator-address', 'validator-address'], 'staking unbonding-delegation');
59
- const [delegatorAddr, validatorAddr] = args;
60
- const result = await staking.unbondingDelegation({
61
- delegatorAddr,
62
- validatorAddr,
63
- });
64
- return { unbond: result.unbond };
65
- }
66
-
67
- case 'unbonding-delegations': {
68
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'staking unbonding-delegations');
69
- requireArgs(remainingArgs, 1, ['delegator-address'], 'staking unbonding-delegations');
70
- const [delegatorAddr] = remainingArgs;
71
- const result = await staking.delegatorUnbondingDelegations({ delegatorAddr, pagination });
72
- return {
73
- unbondingResponses: result.unbondingResponses,
74
- pagination: result.pagination,
75
- };
76
- }
77
-
78
- case 'redelegations': {
79
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'staking redelegations');
80
- requireArgs(remainingArgs, 1, ['delegator-address'], 'staking redelegations');
81
- const [delegatorAddr] = remainingArgs;
82
- // Optional: src and dst validator addresses for filtering
83
- const srcValidatorAddr = remainingArgs[1] || '';
84
- const dstValidatorAddr = remainingArgs[2] || '';
85
- const result = await staking.redelegations({
86
- delegatorAddr,
87
- srcValidatorAddr,
88
- dstValidatorAddr,
89
- pagination,
90
- });
91
- return {
92
- redelegationResponses: result.redelegationResponses,
93
- pagination: result.pagination,
94
- };
95
- }
96
-
97
- case 'validator': {
98
- requireArgs(args, 1, ['validator-address'], 'staking validator');
99
- const [validatorAddr] = args;
100
- const result = await staking.validator({ validatorAddr });
101
- return { validator: result.validator };
102
- }
103
-
104
- case 'validators': {
105
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'staking validators');
106
- // Optional: status filter
107
- const status = remainingArgs[0] || '';
108
- const result = await staking.validators({ status, pagination });
109
- return { validators: result.validators, pagination: result.pagination };
110
- }
111
-
112
- case 'validator-delegations': {
113
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'staking validator-delegations');
114
- requireArgs(remainingArgs, 1, ['validator-address'], 'staking validator-delegations');
115
- const [validatorAddr] = remainingArgs;
116
- const result = await staking.validatorDelegations({ validatorAddr, pagination });
117
- return {
118
- delegationResponses: result.delegationResponses,
119
- pagination: result.pagination,
120
- };
121
- }
122
-
123
- case 'validator-unbonding-delegations': {
124
- const { pagination, remainingArgs } = extractPaginationArgs(args, 'staking validator-unbonding-delegations');
125
- requireArgs(remainingArgs, 1, ['validator-address'], 'staking validator-unbonding-delegations');
126
- const [validatorAddr] = remainingArgs;
127
- const result = await staking.validatorUnbondingDelegations({ validatorAddr, pagination });
128
- return {
129
- unbondingResponses: result.unbondingResponses,
130
- pagination: result.pagination,
131
- };
132
- }
133
-
134
- case 'pool': {
135
- const result = await staking.pool({});
136
- return { pool: result.pool };
137
- }
138
-
139
- case 'params': {
140
- const result = await staking.params({});
141
- return { params: result.params };
142
- }
143
-
144
- case 'historical-info': {
145
- requireArgs(args, 1, ['height'], 'staking historical-info');
146
- const height = parseBigInt(args[0], 'height');
147
- const result = await staking.historicalInfo({ height });
148
- return { hist: result.hist };
149
- }
150
-
151
- default:
152
- throwUnsupportedSubcommand('query', 'staking', subcommand);
153
- }
154
- }