diff options
| author | Adam Soltys <[email protected]> | 2020-07-27 15:20:46 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-07-27 15:20:46 -0700 |
| commit | 72f3bc93357e74b71be0e3f1e621fb556f7fd088 (patch) | |
| tree | be9b51a0e4227a3e324e0723ab540e3aaf959ebe | |
| parent | 3d7b27aa81165c15658f46687a2748d126c17adb (diff) | |
| download | coinos-server-72f3bc93357e74b71be0e3f1e621fb556f7fd088.tar.gz coinos-server-72f3bc93357e74b71be0e3f1e621fb556f7fd088.zip | |
take precision into account when issuing
| -rw-r--r-- | routes/assets.js | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/routes/assets.js b/routes/assets.js index c9acf245..8c39a12f 100644 --- a/routes/assets.js +++ b/routes/assets.js @@ -46,7 +46,6 @@ app.post("/assets", auth, async (req, res) => { const contract = { entity: { domain }, issuer_pubkey, - domain, name, precision, ticker, @@ -68,8 +67,9 @@ app.post("/assets", auth, async (req, res) => { contract_hash, }; - params.asset_amount = parseInt(params.asset_amount); + params.asset_amount = asset_amount / (SATS / 10 ** precision); + l.info("asset_amount", params.asset_amount); if (token_amount) { params.token_amount = token_amount; params.token_address = token_address; @@ -131,7 +131,7 @@ app.post("/assets", auth, async (req, res) => { precision, name, balance: 0, - pending: asset_amount * SATS, + pending: params.asset_amount * SATS, }, { transaction } ); @@ -143,7 +143,7 @@ app.post("/assets", auth, async (req, res) => { account_id: account.id, user_id, hash: txid, - amount: asset_amount * SATS, + amount: params.asset_amount * SATS, received: true, confirmed: false, address: asset_address, @@ -156,7 +156,7 @@ app.post("/assets", auth, async (req, res) => { issuances[txid] = { user_id, asset, - asset_amount, + asset_amount: params.asset_amount, asset_payment_id: asset_payment.id, }; @@ -215,11 +215,17 @@ app.post("/assets/register", auth, async (req, res) => { }); try { - const { data: result } = await axios.post("https://assets.blockstream.info/", { asset_id: asset, contract: account.contract }); + const { data: result } = await axios.post( + "https://assets.blockstream.info/", + { + asset_id: asset, + contract: account.contract, + } + ); l.info("register asset result", req.user.username, result); res.send(result); - } catch(e) { + } catch (e) { l.error("asset registration failed", e.message); res.status(500).send(e.message); - } + } }); |
