Nick/fix topmakers error (#362)
* add fallback account fetch to topMakers * remove accidental inclusion
This commit is contained in:
@@ -410,7 +410,8 @@ const main = async (): Promise<void> => {
|
|||||||
if (accountFlag) {
|
if (accountFlag) {
|
||||||
const topAccounts = await getRawAccountFromId(
|
const topAccounts = await getRawAccountFromId(
|
||||||
userMapClient,
|
userMapClient,
|
||||||
topMakers
|
topMakers,
|
||||||
|
driftClient.connection
|
||||||
);
|
);
|
||||||
res.end(JSON.stringify(topAccounts));
|
res.end(JSON.stringify(topAccounts));
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { RedisClient } from '@drift/common/clients';
|
|||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
import { NextFunction, Request, Response } from 'express';
|
import { NextFunction, Request, Response } from 'express';
|
||||||
import FEATURE_FLAGS from './featureFlags';
|
import FEATURE_FLAGS from './featureFlags';
|
||||||
|
import { Connection } from '@solana/web3.js';
|
||||||
|
|
||||||
export const l2WithBNToStrings = (l2: L2OrderBook): any => {
|
export const l2WithBNToStrings = (l2: L2OrderBook): any => {
|
||||||
for (const key of Object.keys(l2)) {
|
for (const key of Object.keys(l2)) {
|
||||||
@@ -380,7 +381,8 @@ export const getAccountFromId = async (
|
|||||||
|
|
||||||
export const getRawAccountFromId = async (
|
export const getRawAccountFromId = async (
|
||||||
userMapClient: RedisClient,
|
userMapClient: RedisClient,
|
||||||
topMakers: string[]
|
topMakers: string[],
|
||||||
|
connection: Connection
|
||||||
): Promise<
|
): Promise<
|
||||||
{
|
{
|
||||||
userAccountPubKey: string;
|
userAccountPubKey: string;
|
||||||
@@ -395,7 +397,19 @@ export const getRawAccountFromId = async (
|
|||||||
userAccountPubKey,
|
userAccountPubKey,
|
||||||
accountBase64: userAccountEncoded.split('::')[1],
|
accountBase64: userAccountEncoded.split('::')[1],
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
// user is not in the userMap, try to fetch from the connection
|
||||||
|
const account = await connection.getAccountInfo(
|
||||||
|
new PublicKey(userAccountPubKey)
|
||||||
|
);
|
||||||
|
if (account) {
|
||||||
|
return {
|
||||||
|
userAccountPubKey,
|
||||||
|
accountBase64: account.data.toString('base64'),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
userAccountPubKey,
|
userAccountPubKey,
|
||||||
accountBase64: null,
|
accountBase64: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user