diff --git a/apps/ecash-herald/config.js b/apps/ecash-herald/config.js --- a/apps/ecash-herald/config.js +++ b/apps/ecash-herald/config.js @@ -54,12 +54,17 @@ emojis: { alias: '๐พ', block: '๐ฆ', + miner: 'โ๏ธ', staker: '๐ฐ', xecSend: '๐ธ', arrowRight: 'โก๏ธ', tokenBurn: '๐ฅ', tokenGenesis: '๐งช', tokenSend: '๐', + gift: '๐', + bank: '๐ฆ', + app: '๐ฑ', + token: '๐ช', fusion: 'โ๏ธ', cashtabMsg: '๐', cashtabEncrypted: '๐', diff --git a/apps/ecash-herald/src/parse.js b/apps/ecash-herald/src/parse.js --- a/apps/ecash-herald/src/parse.js +++ b/apps/ecash-herald/src/parse.js @@ -2338,24 +2338,32 @@ const tgMsg = []; tgMsg.push( - `<b>${blockCount} blocks in 24 hours thru ${new Date( - now * 1000, - ).toLocaleTimeString('en-GB', { - year: 'numeric', - month: 'short', - day: 'numeric', - hour12: false, - hour: '2-digit', - minute: '2-digit', - timeZone: 'UTC', - })}</b>`, + `<b>24 hours thru ${new Date(now * 1000).toLocaleTimeString( + 'en-GB', + { + year: 'numeric', + month: 'short', + day: 'numeric', + hour12: false, + hour: '2-digit', + minute: '2-digit', + timeZone: 'UTC', + }, + )}</b>`, + ); + tgMsg.push(`${config.emojis.block}${blockCount} blocks`); + tgMsg.push( + `${config.emojis.arrowRight}${txs.length.toLocaleString( + 'en-US', + )} txs`, ); tgMsg.push(''); // Top miners const MINERS_TO_SHOW = 3; - tgMsg.push(`${sortedMinerMap.size} miners found blocks`); - tgMsg.push(`<u>Top ${MINERS_TO_SHOW}</u>`); + tgMsg.push( + `<b><i>${config.emojis.miner}${sortedMinerMap.size} miners found blocks</i></b>`, + ); const topMiners = [...sortedMinerMap.entries()].slice( 0, @@ -2364,7 +2372,9 @@ for (let i = 0; i < topMiners.length; i += 1) { const count = topMiners[i][1]; const pct = (100 * (count / blockCount)).toFixed(0); - tgMsg.push(`${i + 1}. ${topMiners[i][0]}, ${count} (${pct}%)`); + tgMsg.push( + `${i + 1}. ${topMiners[i][0]}, ${count} <i>(${pct}%)</i>`, + ); } tgMsg.push(''); @@ -2388,9 +2398,8 @@ // Top stakers const STAKERS_TO_SHOW = 3; tgMsg.push( - `${sortedStakerMap.size} stakers earned ${renderedTotalStakingRewards}`, + `<b><i>${config.emojis.staker}${sortedStakerMap.size} stakers earned ${renderedTotalStakingRewards}</i></b>`, ); - tgMsg.push(`<u>Top ${STAKERS_TO_SHOW}</u>`); const topStakers = [...sortedStakerMap.entries()].slice( 0, STAKERS_TO_SHOW, @@ -2405,65 +2414,70 @@ config.blockExplorer }/address/${addr}">${returnAddressPreview(addr)}</a>`}, ${ staker[1].count - } (${pct}%)`, + } <i>(${pct}%)</i>`, ); } - tgMsg.push(''); - // Txs - tgMsg.push(`${txs.length.toLocaleString('en-US')} txs`); - if (cashtabXecRewardCount > 0) { - const xecClaimed = cashtabXecRewardSats / SATOSHIS_PER_XEC; - tgMsg.push( - `${cashtabXecRewardCount.toLocaleString( - 'en-US', - )} new Cashtab user${ - cashtabXecRewardCount > 1 ? 's' : '' - } claimed ${xecClaimed.toLocaleString('en-US', { - minimumFractionDigits: 0, - maximumFractionDigits: 0, - })} free XEC`, - ); - } + // Tx breakdown - if (cashtabCachetRewardCount > 0) { - const CACHET_REWARD_SIZE = 100; - tgMsg.push( - `${cashtabCachetRewardCount.toLocaleString( - 'en-US', - )} Cashtab user${ - cashtabCachetRewardCount > 1 ? 's' : '' - } claimed ${( - cashtabCachetRewardCount * CACHET_REWARD_SIZE - ).toLocaleString('en-US', { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - })} CACHET`, - ); + // Cashtab rewards + if (cashtabXecRewardCount > 0 || cashtabCachetRewardCount > 0) { + tgMsg.push(''); + tgMsg.push(`<a href="https://cashtab.com/">Cashtab</a>`); + // Cashtab XEC rewards + if (cashtabXecRewardCount > 0) { + // 1 new user received 42 XEC + // or + // <n> new users received <...> + tgMsg.push( + `${ + config.emojis.gift + } <b>${cashtabXecRewardCount}</b> new user${ + cashtabXecRewardCount > 1 ? `s` : '' + } received <b>${satsToFormattedValue( + cashtabXecRewardSats, + )}</b>`, + ); + } + if (cashtabCachetRewardCount > 0) { + // 1 CACHET reward: + // or + // <n> CACHET rewards: + tgMsg.push( + `${ + config.emojis.tokenSend + } <b>${cashtabCachetRewardCount}</b> <a href="${ + config.blockExplorer + }/tx/aed861a31b96934b88c0252ede135cb9700d7649f69191235087a3030e553cb1">CACHET</a> reward${ + cashtabCachetRewardCount > 1 ? `s` : '' + }`, + ); + } + tgMsg.push(''); } const cashFusionTxs = opReturnMap.get('CashFusion'); if (typeof cashFusionTxs !== 'undefined') { tgMsg.push( - `${cashFusionTxs.toLocaleString('en-US')} CashFusion tx${ - cashtabXecRewardCount > 1 ? 's' : '' - }`, + `${config.emojis.fusion} <b>${cashFusionTxs.toLocaleString( + 'en-US', + )}</b> CashFusion tx${cashtabXecRewardCount > 1 ? 's' : ''}`, ); } if (tokenTxs > 0) { tgMsg.push( - `${tokenTxs.toLocaleString('en-US')} token tx${ - tokenTxs > 1 ? 's' : '' - }`, + `${config.emojis.token} <b>${tokenTxs.toLocaleString( + 'en-US', + )}</b> token tx${tokenTxs > 1 ? 's' : ''}`, ); } if (opReturnTxs > 0) { tgMsg.push( - `${opReturnTxs.toLocaleString('en-US')} app tx${ - opReturnTxs > 1 ? 's' : '' - }`, + `${config.emojis.app} <b>${opReturnTxs.toLocaleString( + 'en-US', + )}</b> app tx${opReturnTxs > 1 ? 's' : ''}`, ); } @@ -2486,9 +2500,11 @@ minimumFractionDigits: 0, maximumFractionDigits: 0, })} XEC`; - tgMsg.push('Binance Hot Wallet'); + tgMsg.push(`${config.emojis.bank} <b><i>Binance</i></b>`); tgMsg.push( - `${binanceWithdrawalCount} withdrawals totaling ${renderedBinanceWithdrawalSats}`, + `<b>${binanceWithdrawalCount}</b> withdrawal${ + binanceWithdrawalCount > 1 ? 's' : '' + }, ${renderedBinanceWithdrawalSats}`, ); } diff --git a/apps/ecash-herald/test/parse.test.js b/apps/ecash-herald/test/parse.test.js --- a/apps/ecash-herald/test/parse.test.js +++ b/apps/ecash-herald/test/parse.test.js @@ -358,29 +358,30 @@ 0.000033, ), [ - '<b>74 blocks in 24 hours thru 15 Oct 2024, 00:00</b>\n' + + '<b>24 hours thru 15 Oct 2024, 00:00</b>\n' + + '๐ฆ74 blocks\n' + + 'โก๏ธ8 txs\n' + '\n' + - '3 miners found blocks\n' + - '<u>Top 3</u>\n' + - '1. Mining-Dutch, 1 (1%)\n' + - '2. solopool.org, 1 (1%)\n' + - '3. ViaBTC, 1 (1%)\n' + + '<b><i>โ๏ธ3 miners found blocks</i></b>\n' + + '1. Mining-Dutch, 1 <i>(1%)</i>\n' + + '2. solopool.org, 1 <i>(1%)</i>\n' + + '3. ViaBTC, 1 <i>(1%)</i>\n' + '\n' + - '3 stakers earned $31\n' + - '<u>Top 3</u>\n' + - '1. <a href="https://explorer.e.cash/address/ecash:qzs8hq2pj4hu5j09fdr5uhha3986h2mthvfp7362nu">qzs...2nu</a>, 1 (1%)\n' + - '2. <a href="https://explorer.e.cash/address/ecash:qr42c8c04tqndscfrdnl0rzterg0qdaegyjzt8egyg">qr4...gyg</a>, 1 (1%)\n' + - '3. <a href="https://explorer.e.cash/address/ecash:qqvhatumna957qu0je78dnc9pc7c7hu89crkq6k0cd">qqv...0cd</a>, 1 (1%)\n' + + '<b><i>๐ฐ3 stakers earned $31</i></b>\n' + + '1. <a href="https://explorer.e.cash/address/ecash:qzs8hq2pj4hu5j09fdr5uhha3986h2mthvfp7362nu">qzs...2nu</a>, 1 <i>(1%)</i>\n' + + '2. <a href="https://explorer.e.cash/address/ecash:qr42c8c04tqndscfrdnl0rzterg0qdaegyjzt8egyg">qr4...gyg</a>, 1 <i>(1%)</i>\n' + + '3. <a href="https://explorer.e.cash/address/ecash:qqvhatumna957qu0je78dnc9pc7c7hu89crkq6k0cd">qqv...0cd</a>, 1 <i>(1%)</i>\n' + '\n' + - '8 txs\n' + - '1 new Cashtab user claimed 42 free XEC\n' + - '1 Cashtab user claimed 100.00 CACHET\n' + - '1 CashFusion tx\n' + - '1 token tx\n' + - '1 app tx\n' + + '<a href="https://cashtab.com/">Cashtab</a>\n' + + '๐ <b>1</b> new user received <b>42 XEC</b>\n' + + '๐ <b>1</b> <a href="https://explorer.e.cash/tx/aed861a31b96934b88c0252ede135cb9700d7649f69191235087a3030e553cb1">CACHET</a> reward\n' + '\n' + - 'Binance Hot Wallet\n' + - '1 withdrawals totaling $1', + 'โ๏ธ <b>1</b> CashFusion tx\n' + + '๐ช <b>1</b> token tx\n' + + '๐ฑ <b>1</b> app tx\n' + + '\n' + + '๐ฆ <b><i>Binance</i></b>\n' + + '<b>1</b> withdrawal, $1', ], ); }); @@ -389,29 +390,30 @@ assert.deepEqual( summarizeTxHistory(mockUtcNewDayTimestampSeconds, dailyTxs), [ - '<b>74 blocks in 24 hours thru 15 Oct 2024, 00:00</b>\n' + + '<b>24 hours thru 15 Oct 2024, 00:00</b>\n' + + '๐ฆ74 blocks\n' + + 'โก๏ธ8 txs\n' + + '\n' + + '<b><i>โ๏ธ3 miners found blocks</i></b>\n' + + '1. Mining-Dutch, 1 <i>(1%)</i>\n' + + '2. solopool.org, 1 <i>(1%)</i>\n' + + '3. ViaBTC, 1 <i>(1%)</i>\n' + '\n' + - '3 miners found blocks\n' + - '<u>Top 3</u>\n' + - '1. Mining-Dutch, 1 (1%)\n' + - '2. solopool.org, 1 (1%)\n' + - '3. ViaBTC, 1 (1%)\n' + + '<b><i>๐ฐ3 stakers earned 937,620 XEC</i></b>\n' + + '1. <a href="https://explorer.e.cash/address/ecash:qzs8hq2pj4hu5j09fdr5uhha3986h2mthvfp7362nu">qzs...2nu</a>, 1 <i>(1%)</i>\n' + + '2. <a href="https://explorer.e.cash/address/ecash:qr42c8c04tqndscfrdnl0rzterg0qdaegyjzt8egyg">qr4...gyg</a>, 1 <i>(1%)</i>\n' + + '3. <a href="https://explorer.e.cash/address/ecash:qqvhatumna957qu0je78dnc9pc7c7hu89crkq6k0cd">qqv...0cd</a>, 1 <i>(1%)</i>\n' + '\n' + - '3 stakers earned 937,620 XEC\n' + - '<u>Top 3</u>\n' + - '1. <a href="https://explorer.e.cash/address/ecash:qzs8hq2pj4hu5j09fdr5uhha3986h2mthvfp7362nu">qzs...2nu</a>, 1 (1%)\n' + - '2. <a href="https://explorer.e.cash/address/ecash:qr42c8c04tqndscfrdnl0rzterg0qdaegyjzt8egyg">qr4...gyg</a>, 1 (1%)\n' + - '3. <a href="https://explorer.e.cash/address/ecash:qqvhatumna957qu0je78dnc9pc7c7hu89crkq6k0cd">qqv...0cd</a>, 1 (1%)\n' + + '<a href="https://cashtab.com/">Cashtab</a>\n' + + '๐ <b>1</b> new user received <b>42 XEC</b>\n' + + '๐ <b>1</b> <a href="https://explorer.e.cash/tx/aed861a31b96934b88c0252ede135cb9700d7649f69191235087a3030e553cb1">CACHET</a> reward\n' + '\n' + - '8 txs\n' + - '1 new Cashtab user claimed 42 free XEC\n' + - '1 Cashtab user claimed 100.00 CACHET\n' + - '1 CashFusion tx\n' + - '1 token tx\n' + - '1 app tx\n' + + 'โ๏ธ <b>1</b> CashFusion tx\n' + + '๐ช <b>1</b> token tx\n' + + '๐ฑ <b>1</b> app tx\n' + '\n' + - 'Binance Hot Wallet\n' + - '1 withdrawals totaling 19,720 XEC', + '๐ฆ <b><i>Binance</i></b>\n' + + '<b>1</b> withdrawal, 19,720 XEC', ], ); });