Skip to content

Commit

Permalink
fix balance sender if publicKey is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
olton committed May 13, 2021
1 parent 857670d commit 133dfa0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions server/balance-sender.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ import {TELEGRAM_BOT_URL} from "./telegram.mjs"
import {parseTelegramChatIDs} from "./helpers.mjs";

export const processBalanceSend = async (config) => {
const {balanceSendInterval, telegramChatID, telegramToken} = config
const {balanceSendInterval, telegramChatID, telegramToken, publicKey} = config
const TELEGRAM_URL = TELEGRAM_BOT_URL.replace("%TOKEN%", telegramToken)

if (!config.publicKey) return
if (!balanceSendInterval) return
if (!config || !telegramToken || !telegramChatID || !balanceSendInterval || !publicKey) return

let status = await nodeInfo('balance', config)

if (!config || !telegramToken || !telegramChatID) return

if (status && status.data && status.data.account && status.data.account.balance) {
const {total, liquid, locked, unknown, blockHeight} = status.data.account.balance
const message =
Expand Down
2 changes: 1 addition & 1 deletion server/node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const nodeInfo = async (obj, config) => {

switch (obj) {
case 'node-status': return await fetchGraphQL(graphql, queryNodeStatus)
case 'balance': return await fetchGraphQL(graphql, queryBalance.replace("%PUBLIC_KEY%", publicKey))
case 'balance': return publicKey ? await fetchGraphQL(graphql, queryBalance.replace("%PUBLIC_KEY%", publicKey)) : 0
case 'blockchain': return await fetchGraphQL(graphql, queryBlockChain)
case 'consensus': return await fetchGraphQL(graphql, queryConsensus)
}
Expand Down

0 comments on commit 133dfa0

Please sign in to comment.