From 332389ccd8ff9a54d8d5eccd4be54b8bf574c937 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 18 Jan 2025 07:07:37 +0100 Subject: [PATCH 1/3] fix: purchasing from client-side vendors --- src/services/purchaseService.ts | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index 816a0c68..25d48e4b 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -50,23 +50,24 @@ export const handlePurchase = async ( const inventoryChanges: IInventoryChanges = {}; if (purchaseRequest.PurchaseParams.Source == 7) { const manifest = getVendorManifestByOid(purchaseRequest.PurchaseParams.SourceId!); - if (!manifest) { - throw new Error(`unknown vendor id: ${purchaseRequest.PurchaseParams.SourceId!}`); + if (manifest) { + const ItemId = (JSON.parse(purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson!) as { ItemId: string }).ItemId; + const offer = manifest.VendorInfo.ItemManifest.find(x => x.Id.$oid == ItemId); + if (!offer) { + throw new Error(`unknown vendor offer: ${ItemId}`); + } + if (offer.ItemPrices) { + await handleItemPrices( + accountId, + offer.ItemPrices, + purchaseRequest.PurchaseParams.Quantity, + inventoryChanges + ); + } + purchaseRequest.PurchaseParams.Quantity *= offer.QuantityMultiplier; + } else if (!ExportVendors[purchaseRequest.PurchaseParams.SourceId!]) { + throw new Error(`unknown vendor: ${purchaseRequest.PurchaseParams.SourceId!}`); } - const ItemId = (JSON.parse(purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson!) as { ItemId: string }).ItemId; - const offer = manifest.VendorInfo.ItemManifest.find(x => x.Id.$oid == ItemId); - if (!offer) { - throw new Error(`unknown vendor offer: ${ItemId}`); - } - if (offer.ItemPrices) { - await handleItemPrices( - accountId, - offer.ItemPrices, - purchaseRequest.PurchaseParams.Quantity, - inventoryChanges - ); - } - purchaseRequest.PurchaseParams.Quantity *= offer.QuantityMultiplier; } const purchaseResponse = await handleStoreItemAcquisition( -- 2.47.2 From 92420a2d92bcd8b33228202216dba411b95de7da Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 18 Jan 2025 07:07:47 +0100 Subject: [PATCH 2/3] prettier --- src/services/purchaseService.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index 25d48e4b..b81481dd 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -51,7 +51,8 @@ export const handlePurchase = async ( if (purchaseRequest.PurchaseParams.Source == 7) { const manifest = getVendorManifestByOid(purchaseRequest.PurchaseParams.SourceId!); if (manifest) { - const ItemId = (JSON.parse(purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson!) as { ItemId: string }).ItemId; + const ItemId = (JSON.parse(purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson!) as { ItemId: string }) + .ItemId; const offer = manifest.VendorInfo.ItemManifest.find(x => x.Id.$oid == ItemId); if (!offer) { throw new Error(`unknown vendor offer: ${ItemId}`); -- 2.47.2 From 388d86896ef49631c273917c86866fe7ad7eff25 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 18 Jan 2025 07:08:30 +0100 Subject: [PATCH 3/3] chore: update PE+ --- package-lock.json | 8 ++++---- package.json | 2 +- src/services/purchaseService.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 95c6af63..492c6357 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "copyfiles": "^2.4.1", "express": "^5", "mongoose": "^8.9.4", - "warframe-public-export-plus": "^0.5.22", + "warframe-public-export-plus": "^0.5.23", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0" @@ -3778,9 +3778,9 @@ } }, "node_modules/warframe-public-export-plus": { - "version": "0.5.22", - "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.22.tgz", - "integrity": "sha512-IbOW7ndE17ceyd7IjRy1U1p3P0Q7Q1/E26N04+ha/gG5FIdLpZDR9kLzyHGlnBLDSl2Jro6rxgOq0wZ/0i0w3g==" + "version": "0.5.23", + "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.23.tgz", + "integrity": "sha512-AJLivzXpon+UDm+SYq3wIXiP4OXCDOgXvCG1VLawJrHW3VDff+NpsUJApBPA4S8oZ8N8NPyBVKBvuoF2Pplaeg==" }, "node_modules/warframe-riven-info": { "version": "0.1.2", diff --git a/package.json b/package.json index d831da5b..f0408d92 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "copyfiles": "^2.4.1", "express": "^5", "mongoose": "^8.9.4", - "warframe-public-export-plus": "^0.5.22", + "warframe-public-export-plus": "^0.5.23", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0" diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index b81481dd..dc2fadf4 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -128,7 +128,7 @@ export const handlePurchase = async ( if (purchaseRequest.PurchaseParams.SourceId! in ExportVendors) { const vendor = ExportVendors[purchaseRequest.PurchaseParams.SourceId!]; const offer = vendor.items.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem); - if (offer) { + if (offer && offer.itemPrices) { await handleItemPrices( accountId, offer.itemPrices, -- 2.47.2