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

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
krboktv committed Feb 17, 2019
1 parent 59375f5 commit 1fa5958
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 28 deletions.
50 changes: 26 additions & 24 deletions api/handlers/handlers1.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,32 @@ async function updateRecipientAddress(req, res) {
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.amount = txValue;
}

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

console.log(value);

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

}).catch(e => {
res.send({
error: e.message,
result: null
});
});
getAsync(id)
.then(async value => {
value.currency = "BUFF";
value.toAddress = toAddress;
value.amount = txValue;
value.amountInUSD = txValue;
value.lifetime = Date.now() + (keyLifeTime * 1000),

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

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

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

async function getGuidLifetime(req, res) {
Expand Down
7 changes: 6 additions & 1 deletion telegram/handlers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ function sendTx(ctx) {
}

function scanQr(ctx) {
return ctx.reply("🔬Scan QR", Keyboard.inlinePay)
const key = guid.create().value;
utils.client.set(key, JSON.stringify({
fromAddress: ctx.message.from.id,
toNickname: '',
}), 'EX', utils.keyLifeTime);
return ctx.reply("🔬Scan QR", Keyboard.inlinePay(key));
}

function celerChange(ctx) {
Expand Down
5 changes: 2 additions & 3 deletions telegram/keyboard/keyboard.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
const Markup = require('telegraf/markup');
const Extra = require('telegraf/extra');
const Text = require('./../text.json');
const guid = require('guid');

const start = [
[Text.keyboard.start.button["0"], Text.keyboard.start.button["1"]],
[Text.keyboard.start.button["2"], "🐃 BUFF QR"],
[Text.keyboard.start.button["3"]]
];

const inlinePay = Markup.inlineKeyboard([
Markup.urlButton("🐃 BUFF QR", `https://dazzling-gates-70947e.netlify.com?tx=${guid.create().value}`)
const inlinePay = (guid) => Markup.inlineKeyboard([
Markup.urlButton("🐃 BUFF QR", `https://dazzling-gates-70947e.netlify.com?tx=${guid}`)
]).extra();

const account = [
Expand Down

0 comments on commit 1fa5958

Please sign in to comment.