Skip to content

Commit

Permalink
Updates New Offer Ping Req Format
Browse files Browse the repository at this point in the history
  • Loading branch information
Step7750 committed Apr 10, 2024
1 parent 037cef6 commit 5843a57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/lib/bridge/handlers/annotate_offer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {SimpleHandler} from './main';
import {RequestType} from './types';

export interface AnnotateOfferRequest {
assets_to_send: string[];
assets_to_receive: string[];
given_asset_ids: string[];
received_asset_ids: string[];
offer_id: string;
}

Expand All @@ -12,7 +12,7 @@ export interface AnnotateOfferResponse {}
export const AnnotateOffer = new SimpleHandler<AnnotateOfferRequest, AnnotateOfferResponse>(
RequestType.ANNOTATE_OFFER,
async (req) => {
const resp = await fetch(`https://csfloat.com/api/v1/trades/annotate-offer`, {
const resp = await fetch(`https://csfloat.com/api/v1/trades/steam-status/new-offer`, {
credentials: 'include',
method: 'POST',
headers: {
Expand Down
12 changes: 6 additions & 6 deletions src/lib/page_scripts/trade_offer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,24 @@ function injectAnnotateOffer() {
return;
}

let assets_to_send: string[] = [];
let assets_to_receive: string[] = [];
let given_asset_ids: string[] = [];
let received_asset_ids: string[] = [];
const deserialized = deserializeForm(settings.data) as {json_tradeoffer?: string};

if (deserialized && deserialized.json_tradeoffer) {
try {
const parsed = JSON.parse(deserialized.json_tradeoffer) as JsonTradeoffer;
assets_to_send = parsed.me.assets.filter((e) => e.appid === AppId.CSGO).map((e) => e.assetid);
assets_to_receive = parsed.them.assets.filter((e) => e.appid === AppId.CSGO).map((e) => e.assetid);
given_asset_ids = parsed.me.assets.filter((e) => e.appid === AppId.CSGO).map((e) => e.assetid);
received_asset_ids = parsed.them.assets.filter((e) => e.appid === AppId.CSGO).map((e) => e.assetid);
} catch (e) {
console.error('failed to parse json tradeoffer', e, deserialized.json_tradeoffer);
// Still proceed with annotating the offer id on a best-effort
}
}

await ClientSend(AnnotateOffer, {
assets_to_send,
assets_to_receive,
given_asset_ids,
received_asset_ids,
offer_id: offer_id,
});
});
Expand Down

0 comments on commit 5843a57

Please sign in to comment.