Skip to content

Commit

Permalink
Attempt to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Perronef5 committed Nov 20, 2024
1 parent aac617a commit f40db1b
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions packages/distributor-oracle/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export async function getRecipients(
entityKeys: string[],
encoding: BufferEncoding | "b58" = "b58",
forceRequery = false
): Promise<{ entityKey: string; recipientAcc: IdlAccounts<LazyDistributor>["recipientV0"] }[]> {
) {
const hemProgram = await init(program.provider as AnchorProvider);
const cache = await getSingleton(hemProgram.provider.connection);
const keyToAssetKs = entityKeys.map((entityKey) => {
Expand Down Expand Up @@ -178,7 +178,14 @@ export async function getPendingRewards(
entityKeys
);

const withRecipients = await getRecipients(program, lazyDistributor, dao, entityKeys, encoding, forceRequery);
const withRecipients = await getRecipients(
program,
lazyDistributor,
dao,
entityKeys,
encoding,
forceRequery
);

return withRecipients.reduce((acc, { entityKey, recipientAcc }) => {
const sortedOracleRewards = oracleRewards
Expand All @@ -203,17 +210,29 @@ export async function getPendingAndLifetimeRewards(
entityKeys: string[],
encoding: BufferEncoding | "b58" = "b58",
forceRequery = false
): Promise<Record<string, {
pendingRewards: string;
lifetimeRewards: string;
}>> {
): Promise<
Record<
string,
{
pendingRewards: string;
lifetimeRewards: string;
}
>
> {
const oracleRewards = await getBulkRewards(
program,
lazyDistributor,
entityKeys
);

const withRecipients = await getRecipients(program, lazyDistributor, dao, entityKeys, encoding, forceRequery);
const withRecipients = await getRecipients(
program,
lazyDistributor,
dao,
entityKeys,
encoding,
forceRequery
);

return withRecipients.reduce((acc, { entityKey, recipientAcc }) => {
const sortedOracleRewards = oracleRewards
Expand All @@ -227,7 +246,7 @@ export async function getPendingAndLifetimeRewards(
const subbed = oracleMedian.sub(recipientAcc?.totalRewards || new BN(0));
acc[entityKey] = {
pendingRewards: subbed.toString(),
lifetimeRewards: recipientAcc?.totalRewards?.toString() || '0',
lifetimeRewards: recipientAcc?.totalRewards?.toString() || "0",
};

return acc;
Expand Down

0 comments on commit f40db1b

Please sign in to comment.