Skip to content

Commit

Permalink
Refactor after review
Browse files Browse the repository at this point in the history
  • Loading branch information
samchuk-vlad committed Jan 12, 2024
1 parent d5cc3bc commit 9f4faba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/services/txHistory/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from 'graphql-request'
import { u8aToHex } from '@polkadot/util'
import { decodeAddress } from '@polkadot/util-crypto'
import { decodeAddress, isEthereumAddress } from '@polkadot/util-crypto'
import { getOrCreateQueue } from './queue'
import { txAggregatorGraphQlClient } from '../../constant/graphQlClients'

Expand Down Expand Up @@ -88,16 +88,16 @@ export const getAccountTxHistoryWithQueue = async (props: GetAccountTransactions
const jobState = await jobByAddress.getState()

if (jobState === 'completed') {
await jobByAddress.remove()
jobByAddress.remove()

actualData = true
}
} else {
const taskPayload = {
publicKey: u8aToHex(decodeAddress(address))
publicKey: isEthereumAddress(address) ? address : u8aToHex(decodeAddress(address))
}

await queue.add(ADD_QUEUE_JOB_NAME, taskPayload, {
queue.add(ADD_QUEUE_JOB_NAME, taskPayload, {
attempts: 5,
jobId,
removeOnComplete: false,
Expand Down
10 changes: 7 additions & 3 deletions src/services/txHistory/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ let queue = null

export const getOrCreateQueue = () => {
if (!queue) {
const host = process.env.AGGREGATOR_REDIS_HOST
const password = process.env.AGGREGATOR_REDIS_PASSWORD
const port = process.env.AGGREGATOR_REDIS_PORT as unknown as number

const aggregatorRedisConfig = {
host: process.env.AGGREGATOR_REDIS_HOST || '',
password: process.env.AGGREGATOR_REDIS_PASSWORD || '',
port: (process.env.AGGREGATOR_REDIS_PORT as unknown as number) || 0
host,
password,
port
}

queue = new Queue('ACCOUNT_AGGREGATION_FLOW', {
Expand Down

0 comments on commit 9f4faba

Please sign in to comment.