Skip to content

Commit a779887

Browse files
fix: harden Adanos crypto source routing
1 parent ba05df8 commit a779887

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

apps/sim/blocks/blocks/adanos.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export const AdanosBlock: BlockConfig = {
8585
condition: {
8686
field: 'operation',
8787
value: ['stock_sentiment', 'trending', 'market_sentiment'],
88+
and: { field: 'assetType', value: 'crypto', not: true },
8889
},
8990
},
9091
{

apps/sim/tools/adanos/adanos.test.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,16 @@ describe('Adanos request configuration', () => {
5555
it('builds a crypto trending URL with a bounded result limit', () => {
5656
const buildUrl = adanosTrendingTool.request.url as (params: {
5757
apiKey: string
58-
assetType: 'crypto'
58+
assetType: 'crypto' | ' Crypto '
5959
source: 'polymarket'
6060
limit: number
6161
}) => string
6262

63-
expect(buildUrl({ apiKey: 'key', assetType: 'crypto', source: 'polymarket', limit: 25 })).toBe(
64-
'https://api.adanos.org/reddit/crypto/v1/trending?limit=25'
65-
)
63+
for (const assetType of ['crypto', ' Crypto '] as const) {
64+
expect(buildUrl({ apiKey: 'key', assetType, source: 'polymarket', limit: 25 })).toBe(
65+
'https://api.adanos.org/reddit/crypto/v1/trending?limit=25'
66+
)
67+
}
6668
})
6769

6870
it('rejects unsupported stock sources and out-of-range limits', () => {
@@ -210,4 +212,14 @@ describe('Adanos block configuration', () => {
210212
})
211213
).toMatchObject({ limit: 20, source: undefined, startDate: undefined, endDate: undefined })
212214
})
215+
216+
it('hides stock source selection for crypto operations', () => {
217+
const sourceBlock = AdanosBlock.subBlocks.find((subBlock) => subBlock.id === 'source')
218+
219+
expect(sourceBlock?.condition).toEqual({
220+
field: 'operation',
221+
value: ['stock_sentiment', 'trending', 'market_sentiment'],
222+
and: { field: 'assetType', value: 'crypto', not: true },
223+
})
224+
})
213225
})

apps/sim/tools/adanos/utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ const STOCK_SOURCE_PATHS: Record<AdanosStockSource, string> = {
1616
polymarket: '/polymarket/stocks/v1',
1717
}
1818

19+
function isCryptoAssetType(assetType: AdanosAssetType) {
20+
return assetType.trim().toLowerCase() === 'crypto'
21+
}
22+
1923
export function getAdanosSource(assetType: AdanosAssetType, source?: AdanosStockSource) {
20-
return assetType === 'crypto' ? 'reddit' : (source ?? 'reddit')
24+
return isCryptoAssetType(assetType) ? 'reddit' : (source ?? 'reddit')
2125
}
2226

2327
export function getAdanosBasePath(assetType: AdanosAssetType, source?: AdanosStockSource) {
24-
if (assetType === 'crypto') {
28+
if (isCryptoAssetType(assetType)) {
2529
return '/reddit/crypto/v1'
2630
}
2731

0 commit comments

Comments
 (0)