Skip to content

Commit 97ed105

Browse files
authored
Merge pull request #442 from nansen-ai/fix/research-reject-unsupported-flags
fix(research): reject --page/--limit and --sort on subcommands that don't support them
2 parents 8ad91ee + 6edbb68 commit 97ed105

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nansen-cli": patch
3+
---
4+
5+
`research historical-token-flow-summary` now errors immediately when `--page` or `--limit` are passed (the endpoint returns a single aggregated row and does not support pagination). `research historical-smart-money-balances` now errors when `--sort` or `--order-by` are passed (the endpoint does not support ordering). Previously both flags were silently dropped.

src/__tests__/research.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,4 +425,18 @@ describe('buildResearchCommands handler', () => {
425425
await expect(cmds.research(['historical-token-screener'], mockApi, {}, { chains: 'solana' }))
426426
.rejects.toThrow(/timeframe-days/);
427427
});
428+
429+
it('rejects --page/--limit on historical-token-flow-summary', async () => {
430+
mockApi = makeMockApi();
431+
await expect(cmds.research(['historical-token-flow-summary'], mockApi, {}, {
432+
'token-address': TOKENS.solana, 'from-date': FROM, 'to-date': TO, page: 2, limit: 5,
433+
})).rejects.toThrow(/does not support/);
434+
});
435+
436+
it('rejects --sort on historical-smart-money-balances', async () => {
437+
mockApi = makeMockApi();
438+
await expect(cmds.research(['historical-smart-money-balances'], mockApi, {}, {
439+
'as-of-date': AS_OF, sort: 'value_usd:desc',
440+
})).rejects.toThrow(/does not support/);
441+
});
428442
});

src/commands/research.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ COMMON OPTIONS:
9595
--to-date <YYYY-MM-DD> End of date range (for range-based subcommands)
9696
--as-of-date <YYYY-MM-DD> Snapshot date (for as-of-date subcommands)
9797
--chain <chain> Chain (default: solana for tokens, ethereum for wallets)
98-
--page <n> --limit <n> Pagination
99-
--sort <field[:asc|desc]> Sort order (default DESC)
98+
--page <n> --limit <n> Pagination (not supported by historical-token-flow-summary)
99+
--sort <field[:asc|desc]> Sort order (not supported by historical-smart-money-balances)
100100
--filters '<json>' Filters as JSON object
101101
102102
Run: nansen research <subcommand> --help`;
@@ -214,6 +214,12 @@ export function buildResearchCommands(deps = {}) {
214214
{ 'token-address': options['token-address'] || options.token, 'from-date': fromDate, 'to-date': toDate },
215215
['token-address', 'from-date', 'to-date'],
216216
);
217+
if (sub === 'historical-token-flow-summary' && (options.page || options.limit)) {
218+
throw new NansenError(
219+
'historical-token-flow-summary does not support --page or --limit (endpoint returns a single aggregated row)',
220+
ErrorCode.INVALID_PARAMS,
221+
);
222+
}
217223
return rangeTokenHandlers[sub]();
218224
}
219225

@@ -240,6 +246,12 @@ export function buildResearchCommands(deps = {}) {
240246
}
241247

242248
if (sub === 'historical-smart-money-balances') {
249+
if (options.sort || options['order-by']) {
250+
throw new NansenError(
251+
'historical-smart-money-balances does not support --sort or --order-by (endpoint does not support ordering)',
252+
ErrorCode.INVALID_PARAMS,
253+
);
254+
}
243255
requireOptions({ 'as-of-date': asOfDate }, ['as-of-date']);
244256
return apiInstance.researchSmartMoneyBalances({
245257
chains: parseChains(options),

0 commit comments

Comments
 (0)