diff --git a/.env.testnet.local b/.env.testnet.local index 142c0ba2..f9da89bc 100644 --- a/.env.testnet.local +++ b/.env.testnet.local @@ -18,9 +18,9 @@ NEXT_PUBLIC_CHAIN_ID=31 # CR-related env variables NEXT_PUBLIC_SIMPLIFIED_REWARD_DISTRIBUTOR_ADDRESS=0x4e84FCc953dE129C6C47c5B0AD7E57B226093Ae1 -NEXT_PUBLIC_BACKERS_MANAGER_ADDRESS=0xC2857F402096BfF24E8E05C2E047F8461d1af927 -NEXT_PUBLIC_REWARD_DISTRIBUTOR_ADDRESS=0x21534EaE65041b85cA309C3258E967f305917F8F -NEXT_PUBLIC_GOVERNANCE_MANAGER_ADDRESS=0xAEdD29bebb0dd8e29702DD1e32346365F96aA016 +NEXT_PUBLIC_BACKERS_MANAGER_ADDRESS=0x6E587f9DdEB9640713a0D735A78ac36cA4a763ea +NEXT_PUBLIC_REWARD_DISTRIBUTOR_ADDRESS=0x6F6Be08782bc671041cF240f84a5Ca671774BECc +NEXT_PUBLIC_GOVERNANCE_MANAGER_ADDRESS=0x732C2468163F16Dfc109bb68a5F87CC04bC729EF NEXT_PUBLIC_CYCLE_DURATION_IN_DAYS=2 NEXT_PUBLIC_FIRST_CYCLE_START_DATE_ISO="1970-01-01T00:00:00Z" diff --git a/src/app/collective-rewards/allocations/AllocationAmount.tsx b/src/app/collective-rewards/allocations/components/AllocationAmount.tsx similarity index 100% rename from src/app/collective-rewards/allocations/AllocationAmount.tsx rename to src/app/collective-rewards/allocations/components/AllocationAmount.tsx diff --git a/src/app/collective-rewards/allocations/AllocationMetrics.tsx b/src/app/collective-rewards/allocations/components/AllocationMetrics.tsx similarity index 96% rename from src/app/collective-rewards/allocations/AllocationMetrics.tsx rename to src/app/collective-rewards/allocations/components/AllocationMetrics.tsx index 9e3694f9..33f05d4a 100644 --- a/src/app/collective-rewards/allocations/AllocationMetrics.tsx +++ b/src/app/collective-rewards/allocations/components/AllocationMetrics.tsx @@ -6,8 +6,8 @@ import { withSpinner } from '@/components/LoadingSpinner/withLoadingSpinner' import { Paragraph } from '@/components/Typography' import { ethers } from 'ethers' import { useAccount } from 'wagmi' -import { useHandleErrors } from '../utils' -import { useBackerTotalAllocation } from './useBackerTotalAllocation' +import { useHandleErrors } from '../../utils' +import { useBackerTotalAllocation } from '../useBackerTotalAllocation' type ValueProps = { value: string diff --git a/src/app/collective-rewards/allocations/BuilderAllocation.tsx b/src/app/collective-rewards/allocations/components/BuilderAllocation.tsx similarity index 96% rename from src/app/collective-rewards/allocations/BuilderAllocation.tsx rename to src/app/collective-rewards/allocations/components/BuilderAllocation.tsx index 6fe5eaed..c1df752d 100644 --- a/src/app/collective-rewards/allocations/BuilderAllocation.tsx +++ b/src/app/collective-rewards/allocations/components/BuilderAllocation.tsx @@ -4,7 +4,7 @@ import { Slider } from '@/components/Slider' import { Label } from '@/components/Typography' import { useState } from 'react' import { BuilderAllocationHeader } from './BuilderAllocationHeader' -import { BuilderAllocationProps } from './types' +import { BuilderAllocationProps } from '../types' export const BuilderAllocation = (builder: BuilderAllocationProps) => { const [sliderValue, setSliderValue] = useState(builder.currentAllocation) diff --git a/src/app/collective-rewards/allocations/BuilderAllocationHeader.tsx b/src/app/collective-rewards/allocations/components/BuilderAllocationHeader.tsx similarity index 88% rename from src/app/collective-rewards/allocations/BuilderAllocationHeader.tsx rename to src/app/collective-rewards/allocations/components/BuilderAllocationHeader.tsx index 9437f299..18cefc60 100644 --- a/src/app/collective-rewards/allocations/BuilderAllocationHeader.tsx +++ b/src/app/collective-rewards/allocations/components/BuilderAllocationHeader.tsx @@ -2,9 +2,9 @@ import { AddressOrAlias } from '@/components/Address' import { Badge } from '@/components/Badge' import { Jdenticon } from '@/components/Header/Jdenticon' import { Paragraph, Typography } from '@/components/Typography' -import { BuilderStatusActive } from '../types' -import { crStatusColorClasses } from '../user' -import { BuilderAllocationProps } from './types' +import { BuilderStatusActive } from '../../types' +import { crStatusColorClasses } from '../../user' +import { BuilderAllocationProps } from '../types' export const BuilderAllocationHeader = ({ address, diff --git a/src/app/collective-rewards/allocations/Header.tsx b/src/app/collective-rewards/allocations/components/Header.tsx similarity index 100% rename from src/app/collective-rewards/allocations/Header.tsx rename to src/app/collective-rewards/allocations/components/Header.tsx diff --git a/src/app/collective-rewards/allocations/StakeHint.tsx b/src/app/collective-rewards/allocations/components/StakeHint.tsx similarity index 100% rename from src/app/collective-rewards/allocations/StakeHint.tsx rename to src/app/collective-rewards/allocations/components/StakeHint.tsx diff --git a/src/app/collective-rewards/allocations/context/AllocationsContext.tsx b/src/app/collective-rewards/allocations/context/AllocationsContext.tsx new file mode 100644 index 00000000..17fe271b --- /dev/null +++ b/src/app/collective-rewards/allocations/context/AllocationsContext.tsx @@ -0,0 +1,165 @@ +import { createContext, FC, ReactNode, useContext, useEffect, useMemo, useState } from 'react' +import { Address } from 'viem' +import { useAccount } from 'wagmi' +import { BuilderProposal, useGetActiveBuilders, useGetBuilders } from '@/app/collective-rewards/user' +import { readContract } from 'wagmi/actions' +import { config } from '@/config' +import { BackersManagerAddress } from '@/lib/contracts' +import { BuilderRegistryAbi } from '@/lib/abis/v2/BuilderRegistryAbi' +import { GaugeAbi } from '@/lib/abis/v2/GaugeAbi' +import { BuilderStateStruct } from '@/app/collective-rewards/utils/getBuilderGauge' +import { useGetAllAllocationOf } from '@/app/collective-rewards/allocations/hooks' +import { withPagination } from '@/app/collective-rewards/context/PaginatedDataContext' + +type AllocationsContextValue = { + // buildersByAddress: Record + // isLoading: boolean + // user: { + // address: Address + // backees: Address[] + // isBacker: boolean + // } + // actions: { + // updateBacking: (address: Address, value: bigint) => unknown + // } +} + +export const AllocationsContext = createContext(null) + +export const useAllocationsContext = () => { + const context = useContext(AllocationsContext) + if (!context) { + throw new Error('useAllocationsContext must be used within a AllocationsContextProvider') + } + return context +} + +type SelectedBuilder = { + index: number + hasAllocationsByUser: boolean + isSelected: boolean + // allocate: (value: bigint) => void +} + +type BuildersByAddress = Record + +export const AllocationsContextProvider: FC<{ children: ReactNode }> = ({ children }) => { + const { address: backerAddress } = useAccount() + if (!backerAddress) { + throw new Error('Provider must be used with a defined account') + } + const { + data: activeBuilders, + isLoading: isLoadingActiveBuilders, + error: activeBuildersError, + } = useGetActiveBuilders() + + const [selectedBuilders, setSelectedBuilders] = useState({}) + + const { + data: onchianAllocations, + isLoading: isOnchianAllocationsLoading, + error: OnchianAllocationsError, + } = useGetAllAllocationOf( + backerAddress!, + Object.values(selectedBuilders).map(builder => activeBuilders[builder.index].gauge), + ) + + // useEffect(() => { + // if (!backer) {return} + + // const getBuilderGauge = async (builderAddress: Address): Promise
=> { + // return readContract(config, { + // address: BackersManagerAddress, + // abi: BuilderRegistryAbi, + // functionName: 'builderToGauge', + // args: [builderAddress], + // }) + // } + // const getBuilderState = async (gauge: Address): Promise => { + // return readContract(config, { + // address: gauge, + // abi: GaugeAbi, + // functionName: 'builderState', + // }) + // } + // const getBuilderStatus = async (builderAddress: Address): Promise => { + // const gauge = await getBuilderGauge(builderAddress) + // const builderState = await getBuilderState(gauge) + // return getCombinedBuilderStatus(builderState) + // } + // const getBuilders = async () => { + // const builders = await Promise.all( + // whitelistedBuilders.map(async builder => { + // const status = await getBuilderStatus(builder.address) + // return { + // ...builder, + // status, + // } + // }), + // ) + // setBuilders(builders) + // } + // getBuilders() + // }, [builders]) + + function addSelectedBuilder(builderAddress: Address, isSelected: boolean) { + const index = activeBuilders.findIndex(builder => builder.address === builderAddress) + + setSelectedBuilders({ + ...selectedBuilders, + [builderAddress]: { + index, + hasAllocationsByUser: (onchianAllocations && onchianAllocations[index]) ?? false, + isSelected, + }, + }) + } + + const configActions = { + toggleSelectedBuilder: (builderAddress: Address, isSelected: boolean) => { + const existingSelection = selectedBuilders[builderAddress] + if (existingSelection) { + return setSelectedBuilders({ + ...selectedBuilders, + [builderAddress]: { + ...existingSelection, + isSelected, + }, + }) + } + + addSelectedBuilder(builderAddress, isSelected) + }, + } + + const configA = { + selectedBuilders, + ...configActions, + } + + const value: AllocationsContextValue = { + // buildersByAddress: whitelistedBuilders.reduce( + // (acc, builder) => { + // acc[builder.address] = builder + // return acc + // }, + // {} as Record, + // ), + // isLoading, + // user: { + // address, + // backees: [], + // isBacker: false, + // }, + // actions: { + // updateBacking: () => {}, + // }, + } + return withPagination(AllocationsContext.Provider)({ + data: activeBuilders, + pageSize: 10, + currentPage: 0, + props: { value, children }, + }) +} diff --git a/src/app/collective-rewards/allocations/context/index.ts b/src/app/collective-rewards/allocations/context/index.ts new file mode 100644 index 00000000..0697bbaa --- /dev/null +++ b/src/app/collective-rewards/allocations/context/index.ts @@ -0,0 +1 @@ +export * from './AllocationsContext' diff --git a/src/app/collective-rewards/allocations/hooks/index.ts b/src/app/collective-rewards/allocations/hooks/index.ts new file mode 100644 index 00000000..e8d9fbda --- /dev/null +++ b/src/app/collective-rewards/allocations/hooks/index.ts @@ -0,0 +1 @@ +export * from './useBackerTotalAllocation' diff --git a/src/app/collective-rewards/allocations/hooks/useBackerTotalAllocation.ts b/src/app/collective-rewards/allocations/hooks/useBackerTotalAllocation.ts new file mode 100644 index 00000000..479388ea --- /dev/null +++ b/src/app/collective-rewards/allocations/hooks/useBackerTotalAllocation.ts @@ -0,0 +1,45 @@ +import { BackersManagerAbi } from '@/lib/abis/v2/BackersManagerAbi' +import { GaugeAbi } from '@/lib/abis/v2/GaugeAbi' +import { AVERAGE_BLOCKTIME } from '@/lib/constants' +import { BackersManagerAddress } from '@/lib/contracts' +import { Address } from 'viem' +import { useReadContract, useReadContracts } from 'wagmi' + +export const useBackerTotalAllocation = (backer: Address) => { + const { data, isLoading, error } = useReadContract({ + abi: BackersManagerAbi, + address: BackersManagerAddress, + functionName: 'backerTotalAllocation', + args: [backer], + query: { + refetchInterval: AVERAGE_BLOCKTIME, + initialData: 0n, + }, + }) + + return { + data, + isLoading, + error, + } +} + +export const useGetAllAllocationOf = (backer: Address, gauges: Address[]) => { + const { data, isLoading, error } = useReadContracts({ + contracts: gauges.map(gauge => ({ + abi: GaugeAbi, + address: gauge, + functionName: 'allocationOf', + args: [backer], + })), + query: { + refetchInterval: AVERAGE_BLOCKTIME, + }, + }) + + return { + data, + isLoading, + error, + } +} diff --git a/src/app/collective-rewards/allocations/useBackerTotalAllocation.tsx b/src/app/collective-rewards/allocations/hooks/useBackerTotalAllocation.tsx similarity index 100% rename from src/app/collective-rewards/allocations/useBackerTotalAllocation.tsx rename to src/app/collective-rewards/allocations/hooks/useBackerTotalAllocation.tsx diff --git a/src/app/collective-rewards/allocations/index.ts b/src/app/collective-rewards/allocations/index.ts new file mode 100644 index 00000000..1db759f2 --- /dev/null +++ b/src/app/collective-rewards/allocations/index.ts @@ -0,0 +1,2 @@ +export * from './context' +export * from './hooks' diff --git a/src/app/collective-rewards/allocations/page.tsx b/src/app/collective-rewards/allocations/page.tsx index 6323acda..e83abb9e 100644 --- a/src/app/collective-rewards/allocations/page.tsx +++ b/src/app/collective-rewards/allocations/page.tsx @@ -2,9 +2,9 @@ import { MainContainer } from '@/components/MainContainer/MainContainer' import { Typography } from '@/components/Typography' -import { AllocationAmount } from './AllocationAmount' -import { AllocationMetrics } from './AllocationMetrics' -import { BuilderAllocation } from './BuilderAllocation' +import { AllocationAmount } from './components/AllocationAmount' +import { AllocationMetrics } from './components/AllocationMetrics' +import { BuilderAllocation } from './components/BuilderAllocation' import { Header } from './Header' import { BuilderAllocationProps } from './types' import { useState } from 'react' diff --git a/src/app/collective-rewards/context/PaginatedDataContext.tsx b/src/app/collective-rewards/context/PaginatedDataContext.tsx new file mode 100644 index 00000000..bc66238d --- /dev/null +++ b/src/app/collective-rewards/context/PaginatedDataContext.tsx @@ -0,0 +1,72 @@ +import { Context, createContext, FC, useContext, useEffect, useState } from 'react' + +type PaginationConfig = { + data: T[] + pageSize: number + currentPage: number +} + +type PaginatedData = PaginationConfig & { + getDataIndex: (index: number) => number + updateData: (data: T[]) => void + updatePageSize: (pageSize: number) => void + updateCurrentPage: (currentPage: number) => void +} + +export const PaginatedDataContext = createContext>({ + data: [], + pageSize: 0, + currentPage: 0, + getDataIndex: () => 0, + updateData: () => {}, + updatePageSize: () => {}, + updateCurrentPage: () => {}, +}) + +export const usePaginatedDataContext = () => { + const context = useContext>(PaginatedDataContext) + if (!context) { + throw new Error('usePaginatedDataContext must be used within a PaginatedDataContextProvider') + } + return context +} + +type PaginatedDataContextProviderProps = { + children: React.ReactNode + config: PaginationConfig +} + +export const PaginatedDataContextProvider: FC = ({ children, config }) => { + const [data, setData] = useState(config.data) + const [pageSize, setPageSize] = useState(config.pageSize) + const [currentPage, setCurrentPage] = useState(config.currentPage) + + const contextMethods = { + getDataIndex: (pagedIndex: number) => pagedIndex + pageSize * currentPage, + updateData: (newData: typeof data) => setData(newData), + updatePageSize: (newPageSize: number) => setPageSize(newPageSize), + updateCurrentPage: (newCurrentPage: number) => setCurrentPage(newCurrentPage), + } + + return ( + + {children} + + ) +} + +export const withPagination = ( + Component: FC, +): FC< + PaginationConfig & { + props: TProps + } +> => { + return ({ props, ...rest }) => { + return ( + + + + ) + } +} diff --git a/src/app/collective-rewards/leaderboard/LeaderBoard.tsx b/src/app/collective-rewards/leaderboard/LeaderBoard.tsx index abc1d6c0..6dfdbb4f 100644 --- a/src/app/collective-rewards/leaderboard/LeaderBoard.tsx +++ b/src/app/collective-rewards/leaderboard/LeaderBoard.tsx @@ -11,6 +11,8 @@ import { Jdenticon } from '@/components/Header/Jdenticon' import { BuilderContextProviderWithPrices } from '@/app/collective-rewards/user' import { Address, isAddress } from 'viem' import { Popover } from '@/components/Popover' +import { AllocationsContextProvider } from '../allocations' +import { PaginatedDataContextProvider } from '../context/PaginatedDataContext' type Currency = { value: number @@ -189,36 +191,46 @@ const LeaderBoardTable = () => { } return ( - - - - {tableHeaders.map(header => ( - - {header.label} - - ))} - - - - {Object.entries(tableData).map( - ([address, { builderName, lastCycleReward, projectedReward, share }]) => ( - - - - - + + + + + + {tableHeaders.map(header => ( + + {header.label} + + ))} - ), - )} - - + + + {Object.entries(tableData).map( + ([address, { builderName, lastCycleReward, projectedReward, share }]) => ( + + + + + + + ), + )} + + + + ) } diff --git a/src/app/collective-rewards/types.ts b/src/app/collective-rewards/types.ts index fe435078..24d879cd 100644 --- a/src/app/collective-rewards/types.ts +++ b/src/app/collective-rewards/types.ts @@ -18,6 +18,7 @@ export type BuilderInfo = { address: Address status: BuilderStatus proposals: CreateBuilderProposalEventLog[] + gauge: Address } export type ProposalsToState = Record diff --git a/src/app/collective-rewards/user/context/BuilderContext.tsx b/src/app/collective-rewards/user/context/BuilderContext.tsx index f29c6392..d646cedc 100644 --- a/src/app/collective-rewards/user/context/BuilderContext.tsx +++ b/src/app/collective-rewards/user/context/BuilderContext.tsx @@ -12,6 +12,7 @@ import { DateTime } from 'luxon' import { splitCombinedName } from '@/app/proposals/shared/utils' import { withPricesContextProvider } from '@/shared/context/PricesContext' +// TODO: rename BuilderProposal and perhaps rewrite the type to Modify export type BuilderProposal = { builderName: string status: BuilderStatusShown @@ -56,6 +57,7 @@ export const BuilderContextProvider: FC = ({ children }) = error: proposalsStateMapError, } = useGetProposalsState(buildersProposals) + // FIXME: rename to builderdsWithProposals const filteredBuilders = useMemo(() => { return builders.reduce((acc, builder) => { const { status, address } = builder diff --git a/src/app/collective-rewards/user/hooks/useGetBuilders.ts b/src/app/collective-rewards/user/hooks/useGetBuilders.ts index fd791b8e..7aca7d40 100644 --- a/src/app/collective-rewards/user/hooks/useGetBuilders.ts +++ b/src/app/collective-rewards/user/hooks/useGetBuilders.ts @@ -9,7 +9,7 @@ import { useFetchCreateBuilderProposals } from '@/app/proposals/hooks/useFetchLa import { BuilderRegistryAbi } from '@/lib/abis/v2/BuilderRegistryAbi' import { AVERAGE_BLOCKTIME } from '@/lib/constants' import { BackersManagerAddress } from '@/lib/contracts' -import { useMemo } from 'react' +import { useEffect, useMemo } from 'react' import { Address, getAddress } from 'viem' import { useReadContracts } from 'wagmi' import { useGetGaugesArray } from '@/app/collective-rewards/user/hooks/useGetGaugesArray' @@ -61,6 +61,7 @@ export const useGetBuilders = (): BuildersLoader => { */ // get the gauges const { data: gauges, isLoading: gaugesLoading, error: gaugesError } = useGetGaugesArray('active') + // get the builders for each gauge const gaugeToBuilderCalls = gauges?.map( gauge => @@ -83,6 +84,14 @@ export const useGetBuilders = (): BuildersLoader => { }) const builders = buildersResult?.map(builder => builder.result) as Address[] + let builderToGauge = builders?.reduce( + (acc, builder, index) => { + acc[builder] = gauges![index] + return acc + }, + {} as Record, + ) + // get the builder state for each builder const builderStatesCalls = builders?.map( builder => @@ -124,6 +133,7 @@ export const useGetBuilders = (): BuildersLoader => { ? builderStatusMap[builder as Address] // V2 : BuilderStatusProposalCreatedMVP, // MVP proposals: Object.values(proposals), + gauge: builderToGauge?.[builder as Address], })) }, [builderStatusMap, buildersProposalsMap]) @@ -136,3 +146,13 @@ export const useGetBuilders = (): BuildersLoader => { error, } } + +export const useGetActiveBuilders = (): BuildersLoader => { + const { data, isLoading, error } = useGetBuilders() + + return { + data: data.filter(builder => builder.status === BuilderStatusActive), + isLoading, + error, + } +} diff --git a/src/app/collective-rewards/whitelist/components/Grid/WhitelistGrid.tsx b/src/app/collective-rewards/whitelist/components/Grid/WhitelistGrid.tsx index 4415a213..d8cd5824 100644 --- a/src/app/collective-rewards/whitelist/components/Grid/WhitelistGrid.tsx +++ b/src/app/collective-rewards/whitelist/components/Grid/WhitelistGrid.tsx @@ -1,9 +1,9 @@ import { FC } from 'react' import { WhitelistGridItem } from './WhitelistGridItem' -import { BuilderProposal } from '@/app/collective-rewards/user' +import { BuilderInfoWithProposal } from '@/app/collective-rewards/user' interface WhitelistGridProps { - items: BuilderProposal[] + items: BuilderInfoWithProposal[] } export const WhitelistGrid: FC = ({ items }) => { diff --git a/src/app/collective-rewards/whitelist/components/Grid/WhitelistGridItem.tsx b/src/app/collective-rewards/whitelist/components/Grid/WhitelistGridItem.tsx index 175d19cd..a490086c 100644 --- a/src/app/collective-rewards/whitelist/components/Grid/WhitelistGridItem.tsx +++ b/src/app/collective-rewards/whitelist/components/Grid/WhitelistGridItem.tsx @@ -1,4 +1,4 @@ -import { crStatusColorClasses, BuilderProposal } from '@/app/collective-rewards/user' +import { crStatusColorClasses, BuilderInfoWithProposal } from '@/app/collective-rewards/user' import { AddressOrAliasWithCopy } from '@/components/Address' import { Badge } from '@/components/Badge' import { Popover } from '@/components/Popover' @@ -10,7 +10,7 @@ import { shortAddress } from '@/lib/utils' import { isAddress, Address } from 'viem' import { BuilderStatusActive, BuilderStatusShown } from '@/app/collective-rewards/types' -type WhitelistGridItemProps = BuilderProposal & { status: BuilderStatusShown } +type WhitelistGridItemProps = BuilderInfoWithProposal & { status: BuilderStatusShown } const Card = ({ header, body }: { header: ReactNode; body: ReactNode }) => { return ( diff --git a/src/app/collective-rewards/whitelist/context/WhitelistContext.tsx b/src/app/collective-rewards/whitelist/context/WhitelistContext.tsx index 0441f7bb..3a07ae30 100644 --- a/src/app/collective-rewards/whitelist/context/WhitelistContext.tsx +++ b/src/app/collective-rewards/whitelist/context/WhitelistContext.tsx @@ -1,4 +1,4 @@ -import { BuilderProposal, withBuilderContextProvider } from '@/app/collective-rewards/user' +import { BuilderInfoWithProposal, withBuilderContextProvider } from '@/app/collective-rewards/user' import { BuilderStatus } from '@/app/collective-rewards/types' import { useGetFilteredBuilders } from '@/app/collective-rewards/whitelist' import { createContext, Dispatch, FC, ReactNode, SetStateAction, useContext, useState } from 'react' @@ -11,7 +11,7 @@ type StateWithUpdate = { } interface WhitelistContextValue { - builders: BuilderProposal[] + builders: BuilderInfoWithProposal[] isLoading: boolean error?: Error | null search: StateWithUpdate diff --git a/src/app/collective-rewards/whitelist/hooks/useGetFilteredBuilders.ts b/src/app/collective-rewards/whitelist/hooks/useGetFilteredBuilders.ts index eff84149..38289a60 100644 --- a/src/app/collective-rewards/whitelist/hooks/useGetFilteredBuilders.ts +++ b/src/app/collective-rewards/whitelist/hooks/useGetFilteredBuilders.ts @@ -3,14 +3,14 @@ import { BuilderStatusFilter } from '@/app/collective-rewards/whitelist' import { BuilderProposal, useBuilderContext } from '@/app/collective-rewards/user' type FetchWhitelistedBuildersFilter = { - builderName: string + builderName?: string status: BuilderStatusFilter } const lowerCaseCompare = (a: string, b: string) => a?.toLowerCase().includes(b?.toLowerCase()) export const useGetFilteredBuilders = ({ - builderName: filterBuilderName, + builderName: filterBuilderName = '', status: filterStatus, }: FetchWhitelistedBuildersFilter) => { const [data, setData] = useState([]) diff --git a/src/app/providers/ContextProviders.tsx b/src/app/providers/ContextProviders.tsx index 17519f95..b0868c88 100644 --- a/src/app/providers/ContextProviders.tsx +++ b/src/app/providers/ContextProviders.tsx @@ -5,6 +5,7 @@ import { ReactNode } from 'react' import { WagmiProvider } from 'wagmi' import { AlertProvider } from './AlertProvider' import ErrorBoundary from '@/components/ErrorPage/ErrorBoundary' +import { AllocationsContextProvider } from '../collective-rewards/allocations' interface Props { children: ReactNode @@ -16,7 +17,11 @@ export const ContextProviders = ({ children }: Props) => { - {children} + + + {children} {} + +