Skip to content

Commit

Permalink
fix(activity.js): add null check for 'from' parameter in getTradeType…
Browse files Browse the repository at this point in the history
… function to prevent errors

fix(activity.js): store and use symbolFrom variable to ensure correct trade type is returned in the default export function
  • Loading branch information
Dan Cryptoscan committed Dec 31, 2024
1 parent 2aa34fb commit 22d0de0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function getExchangeUrl(exchange, to, from) {

function getTradeType(from) {
const baseCoins = ['USDT', 'USDC', 'WETH', 'ETH']
if (baseCoins.includes(from)) {
if (from && baseCoins.includes(from)) {
return 'selling 🧨'
}

Expand Down Expand Up @@ -132,6 +132,7 @@ export function getAgo(date) {

export default function(data) {
const symbol = data.symbol.replace('#', '').toUpperCase();
const symbolFrom = data.symbolFrom?.replace('#', '')?.toUpperCase();
const contract = data.contract ? '#' + data.contract.slice(0, 5) : '';
return `⚖️ #${symbolFrom} ${getTradeType(symbolFrom)} for ${data.amount} #${symbol} ${getBigNumber(data.amount)} #${symbol} ${contract}\n${getAgo(new Date(data.createdAt))}`
return `⚖️ #${symbolFrom} ${getTradeType()} for ${data.amount} #${symbol} ${getBigNumber(data.amount)} #${symbol} ${contract}\n${getAgo(new Date(data.createdAt))}`
}

0 comments on commit 22d0de0

Please sign in to comment.