@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.
- package/.github/workflows/publish.yml +4 -2
- package/CLAUDE.md +11 -6
- package/README.md +1 -1
- package/dist/client.d.ts +6 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +77 -21
- package/dist/client.js.map +1 -1
- package/dist/cosmos.d.ts.map +1 -1
- package/dist/cosmos.js +7 -57
- package/dist/cosmos.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -25
- package/dist/index.js.map +1 -1
- package/dist/modules.d.ts +30 -1
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +98 -1
- package/dist/modules.js.map +1 -1
- package/dist/modules.test.js +60 -1
- package/dist/modules.test.js.map +1 -1
- package/dist/queries/auth.d.ts +7 -1
- package/dist/queries/auth.d.ts.map +1 -1
- package/dist/queries/auth.js +18 -45
- package/dist/queries/auth.js.map +1 -1
- package/dist/queries/bank.d.ts +7 -1
- package/dist/queries/bank.d.ts.map +1 -1
- package/dist/queries/bank.js +24 -38
- package/dist/queries/bank.js.map +1 -1
- package/dist/queries/billing.d.ts +7 -1
- package/dist/queries/billing.d.ts.map +1 -1
- package/dist/queries/billing.js +28 -54
- package/dist/queries/billing.js.map +1 -1
- package/dist/queries/distribution.d.ts +7 -1
- package/dist/queries/distribution.d.ts.map +1 -1
- package/dist/queries/distribution.js +18 -36
- package/dist/queries/distribution.js.map +1 -1
- package/dist/queries/gov.d.ts +7 -1
- package/dist/queries/gov.d.ts.map +1 -1
- package/dist/queries/gov.js +24 -41
- package/dist/queries/gov.js.map +1 -1
- package/dist/queries/index.d.ts +2 -1
- package/dist/queries/index.d.ts.map +1 -1
- package/dist/queries/index.js +1 -1
- package/dist/queries/index.js.map +1 -1
- package/dist/queries/sku.d.ts +13 -0
- package/dist/queries/sku.d.ts.map +1 -0
- package/dist/queries/sku.js +60 -0
- package/dist/queries/sku.js.map +1 -0
- package/dist/queries/staking.d.ts +7 -1
- package/dist/queries/staking.d.ts.map +1 -1
- package/dist/queries/staking.js +36 -59
- package/dist/queries/staking.js.map +1 -1
- package/dist/queries/utils.d.ts +60 -10
- package/dist/queries/utils.d.ts.map +1 -1
- package/dist/queries/utils.js +80 -12
- package/dist/queries/utils.js.map +1 -1
- package/dist/queries/utils.test.js +68 -8
- package/dist/queries/utils.test.js.map +1 -1
- package/dist/transactions/bank.d.ts +2 -2
- package/dist/transactions/bank.d.ts.map +1 -1
- package/dist/transactions/bank.js +9 -18
- package/dist/transactions/bank.js.map +1 -1
- package/dist/transactions/billing.d.ts +2 -2
- package/dist/transactions/billing.d.ts.map +1 -1
- package/dist/transactions/billing.js +125 -89
- package/dist/transactions/billing.js.map +1 -1
- package/dist/transactions/distribution.d.ts +2 -2
- package/dist/transactions/distribution.d.ts.map +1 -1
- package/dist/transactions/distribution.js +7 -13
- package/dist/transactions/distribution.js.map +1 -1
- package/dist/transactions/gov.d.ts +2 -2
- package/dist/transactions/gov.d.ts.map +1 -1
- package/dist/transactions/gov.js +29 -20
- package/dist/transactions/gov.js.map +1 -1
- package/dist/transactions/index.d.ts +1 -1
- package/dist/transactions/index.d.ts.map +1 -1
- package/dist/transactions/index.js +1 -1
- package/dist/transactions/index.js.map +1 -1
- package/dist/transactions/manifest.d.ts +2 -2
- package/dist/transactions/manifest.d.ts.map +1 -1
- package/dist/transactions/manifest.js +7 -14
- package/dist/transactions/manifest.js.map +1 -1
- package/dist/transactions/sku.d.ts +7 -0
- package/dist/transactions/sku.d.ts.map +1 -0
- package/dist/transactions/sku.js +184 -0
- package/dist/transactions/sku.js.map +1 -0
- package/dist/transactions/staking.d.ts +2 -2
- package/dist/transactions/staking.d.ts.map +1 -1
- package/dist/transactions/staking.js +7 -13
- package/dist/transactions/staking.js.map +1 -1
- package/dist/transactions/utils.d.ts +65 -1
- package/dist/transactions/utils.d.ts.map +1 -1
- package/dist/transactions/utils.js +123 -2
- package/dist/transactions/utils.js.map +1 -1
- package/dist/transactions/utils.test.js +351 -1
- package/dist/transactions/utils.test.js.map +1 -1
- package/dist/types.d.ts +218 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/wallet/mnemonic.d.ts +1 -0
- package/dist/wallet/mnemonic.d.ts.map +1 -1
- package/dist/wallet/mnemonic.js +34 -13
- package/dist/wallet/mnemonic.js.map +1 -1
- package/package.json +5 -1
- package/src/client.ts +84 -21
- package/src/cosmos.ts +13 -109
- package/src/index.ts +17 -23
- package/src/modules.test.ts +62 -0
- package/src/modules.ts +155 -5
- package/src/queries/auth.ts +35 -74
- package/src/queries/bank.ts +40 -58
- package/src/queries/billing.ts +46 -86
- package/src/queries/distribution.ts +35 -59
- package/src/queries/gov.ts +40 -64
- package/src/queries/index.ts +10 -1
- package/src/queries/sku.ts +85 -0
- package/src/queries/staking.ts +55 -91
- package/src/queries/utils.test.ts +103 -8
- package/src/queries/utils.ts +119 -12
- package/src/transactions/bank.ts +9 -33
- package/src/transactions/billing.ts +155 -141
- package/src/transactions/distribution.ts +7 -29
- package/src/transactions/gov.ts +33 -37
- package/src/transactions/index.ts +1 -1
- package/src/transactions/manifest.ts +7 -29
- package/src/transactions/sku.ts +232 -0
- package/src/transactions/staking.ts +7 -29
- package/src/transactions/utils.test.ts +390 -1
- package/src/transactions/utils.ts +194 -2
- package/src/types.ts +344 -9
- package/src/wallet/mnemonic.ts +41 -17
- package/.claude/settings.local.json +0 -20
package/src/queries/auth.ts
CHANGED
|
@@ -1,32 +1,50 @@
|
|
|
1
1
|
import { ManifestQueryClient } from '../client.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
ManifestMCPErrorCode,
|
|
4
|
+
AuthAccountResult, AuthAccountsResult, AuthParamsResult, ModuleAccountsResult,
|
|
5
|
+
AddressBytesToStringResult, AddressStringToBytesResult, Bech32PrefixResult, AccountInfoResult
|
|
6
|
+
} from '../types.js';
|
|
7
|
+
import { requireArgs, extractPaginationArgs } from './utils.js';
|
|
8
|
+
import { parseHexBytes, bytesToHex } from '../transactions/utils.js';
|
|
9
|
+
import { throwUnsupportedSubcommand } from '../modules.js';
|
|
10
|
+
|
|
11
|
+
/** Maximum address bytes length (256 bytes, more than enough for any address) */
|
|
12
|
+
const MAX_ADDRESS_BYTES = 256;
|
|
13
|
+
|
|
14
|
+
/** Auth query result union type */
|
|
15
|
+
type AuthQueryResult =
|
|
16
|
+
| AuthAccountResult
|
|
17
|
+
| AuthAccountsResult
|
|
18
|
+
| AuthParamsResult
|
|
19
|
+
| ModuleAccountsResult
|
|
20
|
+
| AddressBytesToStringResult
|
|
21
|
+
| AddressStringToBytesResult
|
|
22
|
+
| Bech32PrefixResult
|
|
23
|
+
| AccountInfoResult;
|
|
4
24
|
|
|
5
25
|
/**
|
|
6
26
|
* Route auth query to manifestjs query client
|
|
27
|
+
*
|
|
28
|
+
* Paginated queries support --limit flag (default: 100, max: 1000)
|
|
7
29
|
*/
|
|
8
30
|
export async function routeAuthQuery(
|
|
9
31
|
queryClient: ManifestQueryClient,
|
|
10
32
|
subcommand: string,
|
|
11
33
|
args: string[]
|
|
12
|
-
): Promise<
|
|
34
|
+
): Promise<AuthQueryResult> {
|
|
13
35
|
const auth = queryClient.cosmos.auth.v1beta1;
|
|
14
36
|
|
|
15
37
|
switch (subcommand) {
|
|
16
38
|
case 'account': {
|
|
17
|
-
|
|
18
|
-
throw new ManifestMCPError(
|
|
19
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
20
|
-
'account requires address argument'
|
|
21
|
-
);
|
|
22
|
-
}
|
|
39
|
+
requireArgs(args, 1, ['address'], 'auth account');
|
|
23
40
|
const [address] = args;
|
|
24
41
|
const result = await auth.account({ address });
|
|
25
42
|
return { account: result.account };
|
|
26
43
|
}
|
|
27
44
|
|
|
28
45
|
case 'accounts': {
|
|
29
|
-
const
|
|
46
|
+
const { pagination } = extractPaginationArgs(args, 'auth accounts');
|
|
47
|
+
const result = await auth.accounts({ pagination });
|
|
30
48
|
return { accounts: result.accounts, pagination: result.pagination };
|
|
31
49
|
}
|
|
32
50
|
|
|
@@ -41,60 +59,24 @@ export async function routeAuthQuery(
|
|
|
41
59
|
}
|
|
42
60
|
|
|
43
61
|
case 'module-account-by-name': {
|
|
44
|
-
|
|
45
|
-
throw new ManifestMCPError(
|
|
46
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
47
|
-
'module-account-by-name requires name argument'
|
|
48
|
-
);
|
|
49
|
-
}
|
|
62
|
+
requireArgs(args, 1, ['name'], 'auth module-account-by-name');
|
|
50
63
|
const [name] = args;
|
|
51
64
|
const result = await auth.moduleAccountByName({ name });
|
|
52
65
|
return { account: result.account };
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
case 'address-bytes-to-string': {
|
|
56
|
-
|
|
57
|
-
|
|
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'));
|
|
69
|
+
requireArgs(args, 1, ['address-bytes'], 'auth address-bytes-to-string');
|
|
70
|
+
const addressBytes = parseHexBytes(args[0], 'address-bytes', MAX_ADDRESS_BYTES, ManifestMCPErrorCode.QUERY_FAILED);
|
|
84
71
|
const result = await auth.addressBytesToString({ addressBytes });
|
|
85
72
|
return { addressString: result.addressString };
|
|
86
73
|
}
|
|
87
74
|
|
|
88
75
|
case 'address-string-to-bytes': {
|
|
89
|
-
|
|
90
|
-
throw new ManifestMCPError(
|
|
91
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
92
|
-
'address-string-to-bytes requires address-string argument'
|
|
93
|
-
);
|
|
94
|
-
}
|
|
76
|
+
requireArgs(args, 1, ['address-string'], 'auth address-string-to-bytes');
|
|
95
77
|
const [addressString] = args;
|
|
96
78
|
const result = await auth.addressStringToBytes({ addressString });
|
|
97
|
-
return { addressBytes:
|
|
79
|
+
return { addressBytes: bytesToHex(result.addressBytes) };
|
|
98
80
|
}
|
|
99
81
|
|
|
100
82
|
case 'bech32-prefix': {
|
|
@@ -103,34 +85,13 @@ export async function routeAuthQuery(
|
|
|
103
85
|
}
|
|
104
86
|
|
|
105
87
|
case 'account-info': {
|
|
106
|
-
|
|
107
|
-
throw new ManifestMCPError(
|
|
108
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
109
|
-
'account-info requires address argument'
|
|
110
|
-
);
|
|
111
|
-
}
|
|
88
|
+
requireArgs(args, 1, ['address'], 'auth account-info');
|
|
112
89
|
const [address] = args;
|
|
113
90
|
const result = await auth.accountInfo({ address });
|
|
114
91
|
return { info: result.info };
|
|
115
92
|
}
|
|
116
93
|
|
|
117
94
|
default:
|
|
118
|
-
|
|
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
|
-
);
|
|
95
|
+
throwUnsupportedSubcommand('query', 'auth', subcommand);
|
|
135
96
|
}
|
|
136
97
|
}
|
package/src/queries/bank.ts
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
import { ManifestQueryClient } from '../client.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
BalanceResult, BalancesResult, TotalSupplyResult, SupplyOfResult,
|
|
4
|
+
BankParamsResult, DenomMetadataResult, DenomsMetadataResult, SendEnabledResult
|
|
5
|
+
} from '../types.js';
|
|
6
|
+
import { requireArgs, extractPaginationArgs } from './utils.js';
|
|
7
|
+
import { throwUnsupportedSubcommand } from '../modules.js';
|
|
8
|
+
|
|
9
|
+
/** Bank query result union type */
|
|
10
|
+
type BankQueryResult =
|
|
11
|
+
| BalanceResult
|
|
12
|
+
| BalancesResult
|
|
13
|
+
| TotalSupplyResult
|
|
14
|
+
| SupplyOfResult
|
|
15
|
+
| BankParamsResult
|
|
16
|
+
| DenomMetadataResult
|
|
17
|
+
| DenomsMetadataResult
|
|
18
|
+
| SendEnabledResult;
|
|
4
19
|
|
|
5
20
|
/**
|
|
6
21
|
* Route bank query to manifestjs query client
|
|
22
|
+
*
|
|
23
|
+
* Paginated queries support --limit flag (default: 100, max: 1000)
|
|
7
24
|
*/
|
|
8
25
|
export async function routeBankQuery(
|
|
9
26
|
queryClient: ManifestQueryClient,
|
|
10
27
|
subcommand: string,
|
|
11
28
|
args: string[]
|
|
12
|
-
): Promise<
|
|
29
|
+
): Promise<BankQueryResult> {
|
|
13
30
|
const bank = queryClient.cosmos.bank.v1beta1;
|
|
14
31
|
|
|
15
32
|
switch (subcommand) {
|
|
16
33
|
case 'balance': {
|
|
17
|
-
|
|
18
|
-
throw new ManifestMCPError(
|
|
19
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
20
|
-
'balance requires address and denom arguments'
|
|
21
|
-
);
|
|
22
|
-
}
|
|
34
|
+
requireArgs(args, 2, ['address', 'denom'], 'bank balance');
|
|
23
35
|
const [address, denom] = args;
|
|
24
36
|
const result = await bank.balance({ address, denom });
|
|
25
37
|
return { balance: result.balance };
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
case 'balances': {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
const [address] = args;
|
|
36
|
-
const result = await bank.allBalances({ address, resolveDenom: false, pagination: defaultPagination });
|
|
41
|
+
const { pagination, remainingArgs } = extractPaginationArgs(args, 'bank balances');
|
|
42
|
+
requireArgs(remainingArgs, 1, ['address'], 'bank balances');
|
|
43
|
+
const [address] = remainingArgs;
|
|
44
|
+
const result = await bank.allBalances({ address, resolveDenom: false, pagination });
|
|
37
45
|
return { balances: result.balances, pagination: result.pagination };
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
case 'spendable-balances': {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
const [address] = args;
|
|
48
|
-
const result = await bank.spendableBalances({ address, pagination: defaultPagination });
|
|
49
|
+
const { pagination, remainingArgs } = extractPaginationArgs(args, 'bank spendable-balances');
|
|
50
|
+
requireArgs(remainingArgs, 1, ['address'], 'bank spendable-balances');
|
|
51
|
+
const [address] = remainingArgs;
|
|
52
|
+
const result = await bank.spendableBalances({ address, pagination });
|
|
49
53
|
return { balances: result.balances, pagination: result.pagination };
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
case 'total-supply':
|
|
53
57
|
case 'total': {
|
|
54
|
-
const
|
|
58
|
+
const { pagination } = extractPaginationArgs(args, 'bank total-supply');
|
|
59
|
+
const result = await bank.totalSupply({ pagination });
|
|
55
60
|
return { supply: result.supply, pagination: result.pagination };
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
case 'supply-of': {
|
|
59
|
-
|
|
60
|
-
throw new ManifestMCPError(
|
|
61
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
62
|
-
'supply-of requires denom argument'
|
|
63
|
-
);
|
|
64
|
-
}
|
|
64
|
+
requireArgs(args, 1, ['denom'], 'bank supply-of');
|
|
65
65
|
const [denom] = args;
|
|
66
66
|
const result = await bank.supplyOf({ denom });
|
|
67
67
|
return { amount: result.amount };
|
|
@@ -73,45 +73,27 @@ export async function routeBankQuery(
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
case 'denom-metadata': {
|
|
76
|
-
|
|
77
|
-
throw new ManifestMCPError(
|
|
78
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
79
|
-
'denom-metadata requires denom argument'
|
|
80
|
-
);
|
|
81
|
-
}
|
|
76
|
+
requireArgs(args, 1, ['denom'], 'bank denom-metadata');
|
|
82
77
|
const [denom] = args;
|
|
83
78
|
const result = await bank.denomMetadata({ denom });
|
|
84
79
|
return { metadata: result.metadata };
|
|
85
80
|
}
|
|
86
81
|
|
|
87
82
|
case 'denoms-metadata': {
|
|
88
|
-
const
|
|
83
|
+
const { pagination } = extractPaginationArgs(args, 'bank denoms-metadata');
|
|
84
|
+
const result = await bank.denomsMetadata({ pagination });
|
|
89
85
|
return { metadatas: result.metadatas, pagination: result.pagination };
|
|
90
86
|
}
|
|
91
87
|
|
|
92
88
|
case 'send-enabled': {
|
|
93
|
-
const
|
|
94
|
-
|
|
89
|
+
const { pagination, remainingArgs } = extractPaginationArgs(args, 'bank send-enabled');
|
|
90
|
+
// Optional: denoms can be empty to query all
|
|
91
|
+
const denoms = remainingArgs.length > 0 ? remainingArgs : [];
|
|
92
|
+
const result = await bank.sendEnabled({ denoms, pagination });
|
|
95
93
|
return { sendEnabled: result.sendEnabled, pagination: result.pagination };
|
|
96
94
|
}
|
|
97
95
|
|
|
98
96
|
default:
|
|
99
|
-
|
|
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
|
-
);
|
|
97
|
+
throwUnsupportedSubcommand('query', 'bank', subcommand);
|
|
116
98
|
}
|
|
117
99
|
}
|
package/src/queries/billing.ts
CHANGED
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
import { ManifestQueryClient } from '../client.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
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;
|
|
4
21
|
|
|
5
22
|
/**
|
|
6
23
|
* Route billing module query to manifestjs query client
|
|
24
|
+
*
|
|
25
|
+
* Paginated queries support --limit flag (default: 100, max: 1000)
|
|
7
26
|
*/
|
|
8
27
|
export async function routeBillingQuery(
|
|
9
28
|
queryClient: ManifestQueryClient,
|
|
10
29
|
subcommand: string,
|
|
11
30
|
args: string[]
|
|
12
|
-
): Promise<
|
|
31
|
+
): Promise<BillingQueryResult> {
|
|
13
32
|
const billing = queryClient.liftedinit.billing.v1;
|
|
14
33
|
|
|
15
34
|
switch (subcommand) {
|
|
@@ -19,146 +38,87 @@ export async function routeBillingQuery(
|
|
|
19
38
|
}
|
|
20
39
|
|
|
21
40
|
case 'lease': {
|
|
22
|
-
|
|
23
|
-
throw new ManifestMCPError(
|
|
24
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
25
|
-
'lease requires lease-uuid argument'
|
|
26
|
-
);
|
|
27
|
-
}
|
|
41
|
+
requireArgs(args, 1, ['lease-uuid'], 'billing lease');
|
|
28
42
|
const [leaseUuid] = args;
|
|
29
43
|
const result = await billing.lease({ leaseUuid });
|
|
30
44
|
return { lease: result.lease };
|
|
31
45
|
}
|
|
32
46
|
|
|
33
47
|
case 'leases': {
|
|
48
|
+
const { pagination } = extractPaginationArgs(args, 'billing leases');
|
|
34
49
|
// stateFilter: 0 = LEASE_STATE_UNSPECIFIED (returns all)
|
|
35
|
-
const result = await billing.leases({ stateFilter: 0, pagination
|
|
50
|
+
const result = await billing.leases({ stateFilter: 0, pagination });
|
|
36
51
|
return { leases: result.leases, pagination: result.pagination };
|
|
37
52
|
}
|
|
38
53
|
|
|
39
54
|
case 'leases-by-tenant': {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
const [tenant] = args;
|
|
47
|
-
const result = await billing.leasesByTenant({ tenant, stateFilter: 0, pagination: defaultPagination });
|
|
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 });
|
|
48
59
|
return { leases: result.leases, pagination: result.pagination };
|
|
49
60
|
}
|
|
50
61
|
|
|
51
62
|
case 'leases-by-provider': {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
const [providerUuid] = args;
|
|
59
|
-
const result = await billing.leasesByProvider({ providerUuid, stateFilter: 0, pagination: defaultPagination });
|
|
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 });
|
|
60
67
|
return { leases: result.leases, pagination: result.pagination };
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
case 'leases-by-sku': {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
const [skuUuid] = args;
|
|
71
|
-
const result = await billing.leasesBySKU({ skuUuid, stateFilter: 0, pagination: defaultPagination });
|
|
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 });
|
|
72
75
|
return { leases: result.leases, pagination: result.pagination };
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
case 'credit-account': {
|
|
76
|
-
|
|
77
|
-
throw new ManifestMCPError(
|
|
78
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
79
|
-
'credit-account requires tenant-address argument'
|
|
80
|
-
);
|
|
81
|
-
}
|
|
79
|
+
requireArgs(args, 1, ['tenant-address'], 'billing credit-account');
|
|
82
80
|
const [tenant] = args;
|
|
83
81
|
const result = await billing.creditAccount({ tenant });
|
|
84
82
|
return { creditAccount: result.creditAccount };
|
|
85
83
|
}
|
|
86
84
|
|
|
87
85
|
case 'credit-accounts': {
|
|
88
|
-
const
|
|
86
|
+
const { pagination } = extractPaginationArgs(args, 'billing credit-accounts');
|
|
87
|
+
const result = await billing.creditAccounts({ pagination });
|
|
89
88
|
return { creditAccounts: result.creditAccounts, pagination: result.pagination };
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
case 'credit-address': {
|
|
93
|
-
|
|
94
|
-
throw new ManifestMCPError(
|
|
95
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
96
|
-
'credit-address requires tenant-address argument'
|
|
97
|
-
);
|
|
98
|
-
}
|
|
92
|
+
requireArgs(args, 1, ['tenant-address'], 'billing credit-address');
|
|
99
93
|
const [tenant] = args;
|
|
100
94
|
const result = await billing.creditAddress({ tenant });
|
|
101
95
|
return { creditAddress: result.creditAddress };
|
|
102
96
|
}
|
|
103
97
|
|
|
104
98
|
case 'withdrawable-amount': {
|
|
105
|
-
|
|
106
|
-
throw new ManifestMCPError(
|
|
107
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
108
|
-
'withdrawable-amount requires lease-uuid argument'
|
|
109
|
-
);
|
|
110
|
-
}
|
|
99
|
+
requireArgs(args, 1, ['lease-uuid'], 'billing withdrawable-amount');
|
|
111
100
|
const [leaseUuid] = args;
|
|
112
101
|
const result = await billing.withdrawableAmount({ leaseUuid });
|
|
113
102
|
return { amounts: result.amounts };
|
|
114
103
|
}
|
|
115
104
|
|
|
116
105
|
case 'provider-withdrawable': {
|
|
117
|
-
|
|
118
|
-
throw new ManifestMCPError(
|
|
119
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
120
|
-
'provider-withdrawable requires provider-uuid argument'
|
|
121
|
-
);
|
|
122
|
-
}
|
|
106
|
+
requireArgs(args, 1, ['provider-uuid'], 'billing provider-withdrawable');
|
|
123
107
|
const [providerUuid] = args;
|
|
124
|
-
//
|
|
108
|
+
// Optional: limit for max leases to process (default 100, max 1000)
|
|
125
109
|
const limit = args[1] ? parseBigInt(args[1], 'limit') : BigInt(100);
|
|
126
110
|
const result = await billing.providerWithdrawable({ providerUuid, limit });
|
|
127
111
|
return { amounts: result.amounts };
|
|
128
112
|
}
|
|
129
113
|
|
|
130
114
|
case 'credit-estimate': {
|
|
131
|
-
|
|
132
|
-
throw new ManifestMCPError(
|
|
133
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
134
|
-
'credit-estimate requires tenant-address argument'
|
|
135
|
-
);
|
|
136
|
-
}
|
|
115
|
+
requireArgs(args, 1, ['tenant-address'], 'billing credit-estimate');
|
|
137
116
|
const [tenant] = args;
|
|
138
117
|
const result = await billing.creditEstimate({ tenant });
|
|
139
118
|
return { estimate: result };
|
|
140
119
|
}
|
|
141
120
|
|
|
142
121
|
default:
|
|
143
|
-
|
|
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
|
-
);
|
|
122
|
+
throwUnsupportedSubcommand('query', 'billing', subcommand);
|
|
163
123
|
}
|
|
164
124
|
}
|
|
@@ -1,26 +1,40 @@
|
|
|
1
1
|
import { ManifestQueryClient } from '../client.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
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;
|
|
4
20
|
|
|
5
21
|
/**
|
|
6
22
|
* Route distribution query to manifestjs query client
|
|
23
|
+
*
|
|
24
|
+
* Paginated queries support --limit flag (default: 100, max: 1000)
|
|
7
25
|
*/
|
|
8
26
|
export async function routeDistributionQuery(
|
|
9
27
|
queryClient: ManifestQueryClient,
|
|
10
28
|
subcommand: string,
|
|
11
29
|
args: string[]
|
|
12
|
-
): Promise<
|
|
30
|
+
): Promise<DistributionQueryResult> {
|
|
13
31
|
const distribution = queryClient.cosmos.distribution.v1beta1;
|
|
14
32
|
|
|
15
33
|
switch (subcommand) {
|
|
16
34
|
case 'rewards': {
|
|
17
|
-
|
|
18
|
-
throw new ManifestMCPError(
|
|
19
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
20
|
-
'rewards requires delegator-address argument'
|
|
21
|
-
);
|
|
22
|
-
}
|
|
35
|
+
requireArgs(args, 1, ['delegator-address'], 'distribution rewards');
|
|
23
36
|
const [delegatorAddress] = args;
|
|
37
|
+
// Optional: validator address for specific validator rewards
|
|
24
38
|
const validatorAddress = args[1];
|
|
25
39
|
|
|
26
40
|
if (validatorAddress) {
|
|
@@ -41,12 +55,7 @@ export async function routeDistributionQuery(
|
|
|
41
55
|
}
|
|
42
56
|
|
|
43
57
|
case 'commission': {
|
|
44
|
-
|
|
45
|
-
throw new ManifestMCPError(
|
|
46
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
47
|
-
'commission requires validator-address argument'
|
|
48
|
-
);
|
|
49
|
-
}
|
|
58
|
+
requireArgs(args, 1, ['validator-address'], 'distribution commission');
|
|
50
59
|
const [validatorAddress] = args;
|
|
51
60
|
const result = await distribution.validatorCommission({ validatorAddress });
|
|
52
61
|
return { commission: result.commission };
|
|
@@ -63,76 +72,43 @@ export async function routeDistributionQuery(
|
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
case 'validator-outstanding-rewards': {
|
|
66
|
-
|
|
67
|
-
throw new ManifestMCPError(
|
|
68
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
69
|
-
'validator-outstanding-rewards requires validator-address argument'
|
|
70
|
-
);
|
|
71
|
-
}
|
|
75
|
+
requireArgs(args, 1, ['validator-address'], 'distribution validator-outstanding-rewards');
|
|
72
76
|
const [validatorAddress] = args;
|
|
73
77
|
const result = await distribution.validatorOutstandingRewards({ validatorAddress });
|
|
74
78
|
return { rewards: result.rewards };
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
case 'slashes': {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const [validatorAddress] = args;
|
|
85
|
-
const startingHeight = args[1] ? parseBigInt(args[1], 'starting-height') : BigInt(0);
|
|
86
|
-
const endingHeight = args[2] ? parseBigInt(args[2], 'ending-height') : BigInt(Number.MAX_SAFE_INTEGER);
|
|
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);
|
|
87
88
|
const result = await distribution.validatorSlashes({
|
|
88
89
|
validatorAddress,
|
|
89
90
|
startingHeight,
|
|
90
91
|
endingHeight,
|
|
91
|
-
pagination
|
|
92
|
+
pagination,
|
|
92
93
|
});
|
|
93
94
|
return { slashes: result.slashes, pagination: result.pagination };
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
case 'delegator-validators': {
|
|
97
|
-
|
|
98
|
-
throw new ManifestMCPError(
|
|
99
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
100
|
-
'delegator-validators requires delegator-address argument'
|
|
101
|
-
);
|
|
102
|
-
}
|
|
98
|
+
requireArgs(args, 1, ['delegator-address'], 'distribution delegator-validators');
|
|
103
99
|
const [delegatorAddress] = args;
|
|
104
100
|
const result = await distribution.delegatorValidators({ delegatorAddress });
|
|
105
101
|
return { validators: result.validators };
|
|
106
102
|
}
|
|
107
103
|
|
|
108
104
|
case 'delegator-withdraw-address': {
|
|
109
|
-
|
|
110
|
-
throw new ManifestMCPError(
|
|
111
|
-
ManifestMCPErrorCode.QUERY_FAILED,
|
|
112
|
-
'delegator-withdraw-address requires delegator-address argument'
|
|
113
|
-
);
|
|
114
|
-
}
|
|
105
|
+
requireArgs(args, 1, ['delegator-address'], 'distribution delegator-withdraw-address');
|
|
115
106
|
const [delegatorAddress] = args;
|
|
116
107
|
const result = await distribution.delegatorWithdrawAddress({ delegatorAddress });
|
|
117
108
|
return { withdrawAddress: result.withdrawAddress };
|
|
118
109
|
}
|
|
119
110
|
|
|
120
111
|
default:
|
|
121
|
-
|
|
122
|
-
ManifestMCPErrorCode.UNSUPPORTED_QUERY,
|
|
123
|
-
`Unsupported distribution query subcommand: ${subcommand}`,
|
|
124
|
-
{
|
|
125
|
-
availableSubcommands: [
|
|
126
|
-
'rewards',
|
|
127
|
-
'commission',
|
|
128
|
-
'community-pool',
|
|
129
|
-
'params',
|
|
130
|
-
'validator-outstanding-rewards',
|
|
131
|
-
'slashes',
|
|
132
|
-
'delegator-validators',
|
|
133
|
-
'delegator-withdraw-address',
|
|
134
|
-
],
|
|
135
|
-
}
|
|
136
|
-
);
|
|
112
|
+
throwUnsupportedSubcommand('query', 'distribution', subcommand);
|
|
137
113
|
}
|
|
138
114
|
}
|