Skip to content

Commit

Permalink
Release Candidate v1.6.4 (#206)
Browse files Browse the repository at this point in the history
* refactor: increase network size to 32 characters in the database (#204)

* chore: bumped to v1.6.4 (#205)

* fix: invalid parameter being sent to sendMessageSQS (#209)

* fix: invalid parameter being sent to sendMessageSQS

* refactor: added helper method to send realtime tx

* docs: added docstring to sendRealtimeTx

* refactor: removed unused import
  • Loading branch information
andreabadesso authored Jan 24, 2025
2 parents 94e6871 + f15d8e1 commit 85c935e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 11 deletions.
18 changes: 18 additions & 0 deletions db/migrations/20250110194443-increase-network-size.js
Original file line number Diff line number Diff line change
@@ -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,
});
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hathor-wallet-service",
"version": "1.6.3",
"version": "1.6.4",
"workspaces": [
"packages/common",
"packages/daemon",
Expand Down
13 changes: 4 additions & 9 deletions packages/daemon/src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
getFullnodeHttpUrl,
sendMessageSQS,
generateAddresses,
sendRealtimeTx,
} from '../utils';
import {
getDbConnection,
Expand Down Expand Up @@ -169,7 +170,6 @@ export const handleVertexAccepted = async (context: Context, _event: Event) => {
NETWORK,
STAGE,
PUSH_NOTIFICATION_ENABLED,
NEW_TX_SQS,
} = getConfig();

try {
Expand Down Expand Up @@ -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');
Expand Down
21 changes: 20 additions & 1 deletion packages/daemon/src/utils/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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<void> => {
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
*
Expand Down

0 comments on commit 85c935e

Please sign in to comment.