diff --git a/src/index.ts b/src/index.ts index b3857af..1bf41a2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -45,6 +45,7 @@ import { sleep, validateDlobQuery, getAccountFromId, + getRawAccountFromId, } from './utils/utils'; import FEATURE_FLAGS from './utils/featureFlags'; import { getDLOBProviderFromOrderSubscriber } from './dlobProvider'; @@ -572,7 +573,10 @@ const main = async (): Promise => { res.writeHead(200); if (accountFlag) { - const topAccounts = await getAccountFromId(userMapClient, topMakers); + const topAccounts = await getRawAccountFromId( + userMapClient, + topMakers + ); res.end(JSON.stringify(topAccounts)); return; } diff --git a/src/utils/utils.ts b/src/utils/utils.ts index b82d743..1a7c16a 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -364,6 +364,32 @@ export const getAccountFromId = async ( ).then((results) => results.filter((user) => !!user)); }; +export const getRawAccountFromId = async ( + userMapClient: RedisClient, + topMakers: string[] +): Promise< + { + userAccountPubKey: string; + accountBase64: string; + }[] +> => { + return Promise.all( + topMakers.map(async (userAccountPubKey) => { + const userAccountEncoded = await userMapClient.getRaw(userAccountPubKey); + if (userAccountEncoded) { + return { + userAccountPubKey, + accountBase64: userAccountEncoded.split('::')[1], + }; + } + return { + userAccountPubKey, + accountBase64: null, + }; + }) + ).then((results) => results.filter((user) => !!user)); +}; + export function errorHandler( err: Error, _req: Request,