diff options
| author | Adam Soltys <[email protected]> | 2020-07-24 12:58:52 -0400 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-07-24 12:58:52 -0400 |
| commit | 78c07b0de0546d4a1d76377f7ecc11b1dc566f82 (patch) | |
| tree | a75add4f1b70fabd8efd745aa7e8427d609d53a0 | |
| parent | c69178f985db0f11ac106c64cc36608667717dab (diff) | |
| download | coinos-server-78c07b0de0546d4a1d76377f7ecc11b1dc566f82.tar.gz coinos-server-78c07b0de0546d4a1d76377f7ecc11b1dc566f82.zip | |
no need to write proposal to file
| -rw-r--r-- | routes/swaps.js | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/routes/swaps.js b/routes/swaps.js index 8e56ec68..cf1b9c6e 100644 --- a/routes/swaps.js +++ b/routes/swaps.js @@ -34,12 +34,6 @@ const createProposal = (a1, v1, a2, v2) => const proc = cli("propose", a1, v1, a2, v2); proc.stdout.on("data", (data) => { - fs.writeFile(swapsdir + "proposal.txt", data.toString(), function (err) { - if (err) { - return l.error(err); - } - l.info("proposal.txt file saved"); - }); resolve(data.toString()); }); @@ -49,7 +43,7 @@ const createProposal = (a1, v1, a2, v2) => }); }); -const getInfo = (filename = "proposal.txt") => +const getInfo = (filename) => new Promise((resolve, reject) => { const proc = cli("info", swapsdir + filename); @@ -106,13 +100,6 @@ app.get("/proposal", auth, async (req, res) => { let text = await createProposal(a1, v1, a2, v2); text = text.replace(/\s+/g, "").trim(); - const info = JSON.parse(await getInfo()); - const [fee, rate, asset] = parse(info); - - if (!rate) throw new Error("invalid asset pair"); - if (rate < 0) - throw new Error(`${assets[a1]} amount must be greater than ${fee}`); - const proposal = await db.Proposal.create({ a1, a2, @@ -122,7 +109,7 @@ app.get("/proposal", auth, async (req, res) => { text, }); - res.send({ proposal, info, rate, asset }); + res.send({ proposal }); } catch (e) { l.error(e.message); res.status(500).send({ error: e.message }); |
