diff --git a/db/migrations/20250110194443-increase-network-size.js b/db/migrations/20250110194443-increase-network-size.js new file mode 100644 index 00000000..70155912 --- /dev/null +++ b/db/migrations/20250110194443-increase-network-size.js @@ -0,0 +1,18 @@ +'use strict'; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up (queryInterface, Sequelize) { + await queryInterface.changeColumn('version_data', 'network', { + type: Sequelize.STRING(32), + allowNull: false, + }); + }, + + async down (queryInterface, Sequelize) { + await queryInterface.changeColumn('version_data', 'network', { + type: Sequelize.STRING(8), + allowNull: false, + }); + } +}; diff --git a/package.json b/package.json index 41ca141d..9c1931ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hathor-wallet-service", - "version": "1.6.3", + "version": "1.6.4", "workspaces": [ "packages/common", "packages/daemon", diff --git a/packages/daemon/src/services/index.ts b/packages/daemon/src/services/index.ts index 77e5fc69..2a00280a 100644 --- a/packages/daemon/src/services/index.ts +++ b/packages/daemon/src/services/index.ts @@ -45,6 +45,7 @@ import { getFullnodeHttpUrl, sendMessageSQS, generateAddresses, + sendRealtimeTx, } from '../utils'; import { getDbConnection, @@ -169,7 +170,6 @@ export const handleVertexAccepted = async (context: Context, _event: Event) => { NETWORK, STAGE, PUSH_NOTIFICATION_ENABLED, - NEW_TX_SQS, } = getConfig(); try { @@ -381,15 +381,10 @@ export const handleVertexAccepted = async (context: Context, _event: Event) => { try { if (seenWallets.length > 0) { - const queueUrl = NEW_TX_SQS; - if (!queueUrl) { - throw new Error('Queue URL is invalid'); - } - - await sendMessageSQS(JSON.stringify({ - wallets: Array.from(seenWallets), + await sendRealtimeTx( + Array.from(seenWallets), txData, - }), queueUrl); + ); } } catch (e) { logger.error('Failed to send transaction to SQS queue'); diff --git a/packages/daemon/src/utils/aws.ts b/packages/daemon/src/utils/aws.ts index 7c0a60b8..7a35927b 100644 --- a/packages/daemon/src/utils/aws.ts +++ b/packages/daemon/src/utils/aws.ts @@ -4,7 +4,7 @@ import { SendMessageCommand, SendMessageCommandOutput, SQSClient, MessageAttribu import { StringMap } from '../types'; import getConfig from '../config'; import logger from '../logger'; -import { addAlert } from '@wallet-service/common'; +import { addAlert, Transaction } from '@wallet-service/common'; export function buildFunctionName(functionName: string): string { const { STAGE } = getConfig(); @@ -56,6 +56,25 @@ export const invokeOnTxPushNotificationRequestedLambda = async (walletBalanceVal } } +/** + * Sends a message to the real-time wallet-service SQS queue. + * + * @param wallets - A list of wallets to notify + * @param tx - The transaction details to send to the clients + */ +export const sendRealtimeTx = async (wallets: string[], tx: Transaction): Promise => { + const { NEW_TX_SQS } = getConfig(); + + if (!NEW_TX_SQS) { + throw new Error('Queue URL is invalid'); + } + + await sendMessageSQS(JSON.stringify({ + wallets, + tx, + }), NEW_TX_SQS); +} + /** * Sends a message to a specific SQS queue *