aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-09-16 23:43:07 -0700
committerAdam Soltys <[email protected]>2020-09-16 23:43:07 -0700
commit98d8dedfa1fe39039bf6beb2e1443770b29c6384 (patch)
tree0db0c75dc77dd423c2d1c2e990d7633ad965a6b1
parente17a16ed07868a012524869951ee956e95bdfc85 (diff)
downloadcoinos-server-98d8dedfa1fe39039bf6beb2e1443770b29c6384.tar.gz
coinos-server-98d8dedfa1fe39039bf6beb2e1443770b29c6384.zip
hoist params variable up a scope
-rw-r--r--routes/send.js31
1 files changed, 16 insertions, 15 deletions
diff --git a/routes/send.js b/routes/send.js
index 9080dc0c..44f71f06 100644
--- a/routes/send.js
+++ b/routes/send.js
@@ -67,22 +67,25 @@ module.exports = ah(async (req, res, next) => {
});
let a2;
+ let acc = {
+ user_id: recipient.id,
+ asset,
+ pubkey: null
+ };
+
if (recipient.account.asset === asset && !recipient.account.pubkey)
- ({ a2 } = recipient);
+ ({ account: a2 } = recipient);
else {
- let params = {
- user_id: recipient.id,
- asset,
- pubkey: null
- };
-
a2 = await db.Account.findOne({
- where: params,
+ where: acc,
lock: transaction.LOCK.UPDATE,
transaction
});
}
+ console.log("a2", a2.id);
+ console.log("acc", acc);
+
if (a2) {
a2.balance += amount;
await a2.save({ transaction });
@@ -105,18 +108,16 @@ module.exports = ah(async (req, res, next) => {
limit: 1
});
- l.info("existing", existing);
-
if (existing) {
({ domain, ticker, precision, name } = existing);
}
}
- params = { asset, ...params, ...{ domain, ticker, precision, name } };
- params.balance = amount;
- params.pending = 0;
- params.network = 'liquid';
- a2 = await db.Account.create(params, { transaction });
+ acc = { ...acc, ...{ domain, ticker, precision, name } };
+ acc.balance = amount;
+ acc.pending = 0;
+ acc.network = 'liquid';
+ a2 = await db.Account.create(acc, { transaction });
}
let p2 = await db.Payment.create(