-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
933 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { ContractHome } from 'components/contract/ContractsHome'; | ||
import { aggregateProtocolData } from 'lib/contract/aggregateProtocolData'; | ||
import { getContractData } from 'lib/contract/getContractData'; | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
export default async function Dashboard() { | ||
const data = await getContractData(); | ||
return <ContractHome seasonOne={data} />; | ||
const seasonOneData = await getContractData(); | ||
const protocolData = await aggregateProtocolData(); | ||
return <ContractHome seasonOne={seasonOneData} protocol={protocolData} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { getAllISOWeeksFromSeasonStart } from '@packages/scoutgame/dates'; | ||
import { | ||
protocolImplementationReadonlyApiClient, | ||
protocolProxyReadonlyApiClient | ||
} from '@packages/scoutgame/protocol/clients/protocolReadClients'; | ||
import { getScoutProtocolAddress } from '@packages/scoutgame/protocol/constants'; | ||
import type { Address } from 'viem'; | ||
|
||
type MerkleRoot = { | ||
week: string; | ||
root: string; | ||
}; | ||
|
||
export type ProtocolData = { | ||
admin: Address; | ||
proxy: Address; | ||
implementation: Address; | ||
claimsManager: Address; | ||
merkleRoots: MerkleRoot[]; | ||
}; | ||
|
||
export async function aggregateProtocolData(): Promise<ProtocolData> { | ||
const [implementation, admin, claimsManager] = await Promise.all([ | ||
protocolProxyReadonlyApiClient.implementation(), | ||
protocolProxyReadonlyApiClient.admin(), | ||
protocolProxyReadonlyApiClient.claimsManager() | ||
]); | ||
|
||
const weeks = getAllISOWeeksFromSeasonStart(); | ||
|
||
const merkleRoots = await Promise.all( | ||
weeks.map((week) => | ||
protocolImplementationReadonlyApiClient | ||
.getMerkleRoot({ args: { week } }) | ||
.then((root) => ({ week, root })) | ||
.catch(() => { | ||
return { week, root: 'No root found' }; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
merkleRoots, | ||
admin: admin as Address, | ||
proxy: getScoutProtocolAddress(), | ||
implementation: implementation as Address, | ||
claimsManager: claimsManager as Address | ||
}; | ||
} |
Oops, something went wrong.