Skip to content

Commit

Permalink
Merge branch 'refs/heads/develop' into node-v20lts-bump
Browse files Browse the repository at this point in the history
  • Loading branch information
wwills2 committed Jul 30, 2024
2 parents 96a3294 + 173e560 commit 3ead285
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/controllers/offer.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,17 @@ export const commitImportedOfferFile = async (req, res) => {

const response = await datalayer.takeOffer(JSON.parse(offerFile.metaValue));

res.json({
message: 'Offer Accepted.',
tradeId: response.trade_id,
success: true,
});

await Meta.destroy({
where: {
metaKey: 'activeOffer',
},
});

res.json({
message: 'Offer Accepted.',
tradeId: response.trade_id,
success: true,
});
} catch (error) {
res.status(400).json({
message: 'Can not commit offer.',
Expand All @@ -163,6 +163,11 @@ export const cancelImportedOfferFile = async (req, res) => {
metaKey: 'activeOffer',
},
});

res.json({
message: 'Offer Cancelled',
success: true,
});
} catch (error) {
res.status(400).json({
message: 'Can not cancel offer.',
Expand All @@ -174,6 +179,19 @@ export const cancelImportedOfferFile = async (req, res) => {

export const getCurrentOfferInfo = async (req, res) => {
try {
/* fix for when old cadt-ui is no longer supported
try {
await assertActiveOfferFile();
} catch (error) {
res.status(200).json({
message: 'No offer to accept',
success: true,
});
return;
}
*/

// replace with above
await assertActiveOfferFile();

const offerFileJson = await Meta.findOne({
Expand Down Expand Up @@ -234,9 +252,9 @@ export const getCurrentOfferInfo = async (req, res) => {
maker,
taker,
},
success: true,
});
} catch (error) {
console.trace(error);
res.status(400).json({
message: 'Can not get offer.',
error: error.message,
Expand Down

0 comments on commit 3ead285

Please sign in to comment.