Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
krboktv committed Feb 17, 2019
2 parents ad8a53b + 0555d7c commit e8f209d
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions api/handlers/handlers1.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const {promisify} = require('util');
const getAsync = promisify(client.get).bind(client);
const Keyboard = require('./../keyboard/keyboard');

const keyLifeTime = 600; // in seconds

async function createAccount(req, res) {
const id = req.params.guid;
const ethereumAddress = req.body.ethereumAddress;
Expand Down Expand Up @@ -72,48 +74,33 @@ async function createTransaction(req, res) {
const setAsync = promisify(client.set).bind(client);
async function updateRecipientAddress(req, res) {
const id = req.params.guid;
const toAddress = req.body.toAddress;
const toAddress = req.body.toAddress || "";
const txValue = req.body.value;



// get existing Redis value by current key
getAsync(id).then(async value => {
value = (value && JSON.parse(value));
console.log(value);
value.toAddress = toAddress;
if (txValue) {
value.amoun = txValue;
value.amount = txValue;
}

setAsync(id, )
client.set(id, value, 'EX', keyLifeTime);

console.log(value);

res.send({
result: "OK",
error: null
})

}).catch(e => {
res.send({
error: e.message,
result: null
});
});


const value = JSON.stringify({
currency: currency,
fromUserID: ctx.message.from.id,
toUserID: toUserID ? toUserID : 'null',
fromAddress: fromAddress,
toNickname: checker ? ctx.session.to : '',
toAddress: toAddress,
amount: amount,
amountInUSD: ctx.session.isToken ? '0.000002' : amountInUsd,
lifetime: Date.now() + (utils.keyLifeTime * 1000),
});

utils.client.set(key, value, 'EX', utils.keyLifeTime);
console.log(value);
ctx.reply(Text.inline_keyboard.send_transaction.text, Extra.markup(Keyboard.create_transaction(key)));

return ctx.scene.leave();

}

async function getGuidLifetime(req, res) {
Expand Down Expand Up @@ -168,4 +155,5 @@ module.exports = {
createTransaction: createTransaction,
getGuidLifetime: getGuidLifetime,
getTransaction: getTransaction,
updateRecipientAddress: updateRecipientAddress
};

0 comments on commit e8f209d

Please sign in to comment.