Skip to content

Commit 85c935e

Browse files
Release Candidate v1.6.4 (#206)
* 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
2 parents 94e6871 + f15d8e1 commit 85c935e

File tree

4 files changed

+43
-11
lines changed

4 files changed

+43
-11
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
/** @type {import('sequelize-cli').Migration} */
4+
module.exports = {
5+
async up (queryInterface, Sequelize) {
6+
await queryInterface.changeColumn('version_data', 'network', {
7+
type: Sequelize.STRING(32),
8+
allowNull: false,
9+
});
10+
},
11+
12+
async down (queryInterface, Sequelize) {
13+
await queryInterface.changeColumn('version_data', 'network', {
14+
type: Sequelize.STRING(8),
15+
allowNull: false,
16+
});
17+
}
18+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hathor-wallet-service",
3-
"version": "1.6.3",
3+
"version": "1.6.4",
44
"workspaces": [
55
"packages/common",
66
"packages/daemon",

packages/daemon/src/services/index.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
getFullnodeHttpUrl,
4646
sendMessageSQS,
4747
generateAddresses,
48+
sendRealtimeTx,
4849
} from '../utils';
4950
import {
5051
getDbConnection,
@@ -169,7 +170,6 @@ export const handleVertexAccepted = async (context: Context, _event: Event) => {
169170
NETWORK,
170171
STAGE,
171172
PUSH_NOTIFICATION_ENABLED,
172-
NEW_TX_SQS,
173173
} = getConfig();
174174

175175
try {
@@ -381,15 +381,10 @@ export const handleVertexAccepted = async (context: Context, _event: Event) => {
381381

382382
try {
383383
if (seenWallets.length > 0) {
384-
const queueUrl = NEW_TX_SQS;
385-
if (!queueUrl) {
386-
throw new Error('Queue URL is invalid');
387-
}
388-
389-
await sendMessageSQS(JSON.stringify({
390-
wallets: Array.from(seenWallets),
384+
await sendRealtimeTx(
385+
Array.from(seenWallets),
391386
txData,
392-
}), queueUrl);
387+
);
393388
}
394389
} catch (e) {
395390
logger.error('Failed to send transaction to SQS queue');

packages/daemon/src/utils/aws.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { SendMessageCommand, SendMessageCommandOutput, SQSClient, MessageAttribu
44
import { StringMap } from '../types';
55
import getConfig from '../config';
66
import logger from '../logger';
7-
import { addAlert } from '@wallet-service/common';
7+
import { addAlert, Transaction } from '@wallet-service/common';
88

99
export function buildFunctionName(functionName: string): string {
1010
const { STAGE } = getConfig();
@@ -56,6 +56,25 @@ export const invokeOnTxPushNotificationRequestedLambda = async (walletBalanceVal
5656
}
5757
}
5858

59+
/**
60+
* Sends a message to the real-time wallet-service SQS queue.
61+
*
62+
* @param wallets - A list of wallets to notify
63+
* @param tx - The transaction details to send to the clients
64+
*/
65+
export const sendRealtimeTx = async (wallets: string[], tx: Transaction): Promise<void> => {
66+
const { NEW_TX_SQS } = getConfig();
67+
68+
if (!NEW_TX_SQS) {
69+
throw new Error('Queue URL is invalid');
70+
}
71+
72+
await sendMessageSQS(JSON.stringify({
73+
wallets,
74+
tx,
75+
}), NEW_TX_SQS);
76+
}
77+
5978
/**
6079
* Sends a message to a specific SQS queue
6180
*

0 commit comments

Comments
 (0)