File tree Expand file tree Collapse file tree
apps/sim/tools/polymarket Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,4 +122,16 @@ describe('Polymarket Data API v2', () => {
122122 } )
123123 expect ( fromString . searchParams . get ( 'start' ) ) . toBe ( '1700000000' )
124124 } )
125+
126+ it ( 'rejects a non-numeric start and reads start=0 as the full history' , ( ) => {
127+ expect ( ( ) =>
128+ requestUrl ( polymarketGetActivityTool , {
129+ user : '0xabc' ,
130+ start : 'yesterday' as unknown as number ,
131+ } )
132+ ) . toThrow ( 'Unix timestamp' )
133+ expect (
134+ requestUrl ( polymarketGetActivityTool , { user : '0xabc' , start : 0 } ) . searchParams . get ( 'start' )
135+ ) . toBe ( '1' )
136+ } )
125137} )
Original file line number Diff line number Diff line change @@ -132,7 +132,11 @@ export const polymarketGetActivityTool: ToolConfig<
132132 const value = params [ key ]
133133 if ( value == null || String ( value ) . trim ( ) === '' ) continue
134134 const seconds = Number ( value )
135- if ( Number . isFinite ( seconds ) ) query . append ( key , String ( seconds ) )
135+ if ( ! Number . isFinite ( seconds ) ) {
136+ throw new Error ( `${ key } must be a Unix timestamp in seconds, got "${ value } ".` )
137+ }
138+ // v2 reads start=0 as "three years back"; 1 keeps the full history that 0 asked for.
139+ query . append ( key , String ( key === 'start' && seconds === 0 ? 1 : seconds ) )
136140 }
137141 if ( params . sortBy ) query . append ( 'sort_by' , params . sortBy )
138142 if ( params . sortDirection ) query . append ( 'sort_direction' , params . sortDirection )
You can’t perform that action at this time.
0 commit comments