Skip to content

Commit

Permalink
fix context issues
Browse files Browse the repository at this point in the history
  • Loading branch information
chuckbergeron committed May 8, 2023
1 parent 1d8cb1e commit 4ca4c25
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/compute/computeDrawWinners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Provider } from "@ethersproject/providers";

import { getSubgraphVaults } from "../utils/getSubgraphVaults";
import { getWinnersClaims } from "../utils/getWinnersClaims";
import { ContractsBlob, ClaimPrizeContext, Claim } from "../types";
import { ContractsBlob, ClaimContext, Claim } from "../types";

/**
* Finds out which of the accounts in each vault are winners for the last draw and formats
Expand All @@ -14,7 +14,7 @@ export async function computeDrawWinners(
provider: Provider,
contracts: ContractsBlob,
chainId: number,
context: ClaimPrizeContext
context: ClaimContext
): Promise<Claim[]> {
const vaults = await getSubgraphVaults(chainId);
if (vaults.length === 0) {
Expand Down
6 changes: 1 addition & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface TiersContext {
rangeArray: number[];
}

export interface ClaimPrizeContext {
export interface ClaimContext {
drawId: string;
tiers: TiersContext;
}
Expand All @@ -67,10 +67,6 @@ export interface Claim {
tier: number;
}

export interface PrizeClaimerConfigParams {
chainId: number;
}

export interface MulticallResults {
[contractAddress: string]: {
[reference: string]: any[];
Expand Down
12 changes: 4 additions & 8 deletions src/utils/getWinnersClaims.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Provider } from "@ethersproject/providers";
import { ContractCallContext } from "ethereum-multicall";

import { MulticallResults, Claim, ClaimPrizeContext, ContractsBlob, Vault } from "../types";
import { MulticallResults, Claim, ClaimContext, ContractsBlob, Vault } from "../types";
import { getComplexMulticallResults } from "./multicall";

/**
Expand All @@ -16,7 +16,7 @@ export const getWinnersClaims = async (
readProvider: Provider,
contracts: ContractsBlob,
vaults: Vault[],
context: ClaimPrizeContext
context: ClaimContext
): Promise<Claim[]> => {
const tiersArray = context.tiers.rangeArray;

Expand Down Expand Up @@ -58,14 +58,10 @@ export const getWinnersClaims = async (
);

// Builds the array of claims
return getClaims(prizePoolAddress, multicallResults, context);
return getClaims(prizePoolAddress, multicallResults);
};

const getClaims = (
prizePoolAddress: string,
multicallResults: MulticallResults,
context: ClaimPrizeContext
): Claim[] => {
const getClaims = (prizePoolAddress: string, multicallResults: MulticallResults): Claim[] => {
const claims: Claim[] = [];

Object.entries(multicallResults[prizePoolAddress]).forEach(vaultUserTierResult => {
Expand Down

0 comments on commit 4ca4c25

Please sign in to comment.