1- import { SlimTrade } from '../types/float_market' ;
2- import { TradeHistoryStatus , TradeHistoryType } from '../bridge/handlers/trade_history_status' ;
3- import { AppId , TradeOfferState , TradeStatus } from '../types/steam_constants' ;
4- import { clearAccessTokenFromStorage , getAccessToken } from './access_token' ;
1+ import { SlimTrade } from '../types/float_market' ;
2+ import { TradeHistoryStatus , TradeHistoryType } from '../bridge/handlers/trade_history_status' ;
3+ import { AppId , TradeOfferState , TradeStatus } from '../types/steam_constants' ;
4+ import { clearAccessTokenFromStorage , getAccessToken } from './access_token' ;
55
66export async function pingTradeHistory (
77 pendingTrades : SlimTrade [ ] ,
88 steamID ?: string | null
99) : Promise < TradeHistoryStatus [ ] > {
10- const { history, type } = await getTradeHistory ( ) ;
10+ const { history, type} = await getTradeHistory ( ) ;
1111
1212 // premature optimization in case it's 100 trades
1313 const assetsToFind = pendingTrades . reduce (
1414 ( acc , e ) => {
1515 acc [ e . contract . item . asset_id ] = e ;
1616 return acc ;
1717 } ,
18- { } as { [ key : string ] : SlimTrade }
18+ { } as { [ key : string ] : SlimTrade }
1919 ) ;
2020
2121 // We only want to send history that is relevant to verifying trades on CSFloat
@@ -42,25 +42,25 @@ export async function pingTradeHistory(
4242 return history ;
4343 }
4444
45- await TradeHistoryStatus . handleRequest ( { history : historyForCSFloat , type } , { } ) ;
45+ await TradeHistoryStatus . handleRequest ( { history : historyForCSFloat , type} , { } ) ;
4646
4747 return history ;
4848}
4949
50- async function getTradeHistory ( ) : Promise < { history : TradeHistoryStatus [ ] ; type : TradeHistoryType } > {
50+ async function getTradeHistory ( ) : Promise < { history : TradeHistoryStatus [ ] ; type : TradeHistoryType } > {
5151 try {
5252 const history = await getTradeHistoryFromAPI ( 250 ) ;
5353 if ( history . length > 0 ) {
5454 // Hedge in case this endpoint gets killed, only return if there are results, fallback to HTML parser
55- return { history, type : TradeHistoryType . API } ;
55+ return { history, type : TradeHistoryType . API } ;
5656 } else {
5757 throw new Error ( 'failed to get trade history' ) ;
5858 }
5959 } catch ( e ) {
6060 await clearAccessTokenFromStorage ( ) ;
6161 // Fallback to HTML parsing
6262 const history = await getTradeHistoryFromHTML ( ) ;
63- return { history, type : TradeHistoryType . HTML } ;
63+ return { history, type : TradeHistoryType . HTML } ;
6464 }
6565}
6666
@@ -148,12 +148,12 @@ export async function getTradeHistoryFromAPI(
148148 received_assets : ( e . assets_received || [ ] )
149149 . filter ( ( e ) => e . appid === AppId . CSGO )
150150 . map ( ( e ) => {
151- return { asset_id : e . assetid , new_asset_id : e . new_assetid } ;
151+ return { asset_id : e . assetid , new_asset_id : e . new_assetid } ;
152152 } ) ,
153153 given_assets : ( e . assets_given || [ ] )
154154 . filter ( ( e ) => e . appid === AppId . CSGO )
155155 . map ( ( e ) => {
156- return { asset_id : e . assetid , new_asset_id : e . new_assetid } ;
156+ return { asset_id : e . assetid , new_asset_id : e . new_assetid } ;
157157 } ) ,
158158 trade_id : e . tradeid ,
159159 time_settlement : e . time_settlement ,
@@ -206,9 +206,9 @@ function parseTradeHistoryHTML(body: string): TradeHistoryStatus[] {
206206 const [ text , index , type , assetId ] = match ;
207207 const tradeIndex = parseInt ( index ) ;
208208 if ( type === 'received' ) {
209- statuses [ tradeIndex ] . received_assets . push ( { asset_id : assetId } ) ;
209+ statuses [ tradeIndex ] . received_assets . push ( { asset_id : assetId } ) ;
210210 } else if ( type === 'given' ) {
211- statuses [ tradeIndex ] . given_assets . push ( { asset_id : assetId } ) ;
211+ statuses [ tradeIndex ] . given_assets . push ( { asset_id : assetId } ) ;
212212 }
213213 }
214214
0 commit comments