generated from proofoftom/buidler-waffle-typechain-quasar
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor to get data from static rounds if subgraph is not available
- Loading branch information
Showing
22 changed files
with
301 additions
and
424 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
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 |
---|---|---|
@@ -1,18 +1,31 @@ | ||
import leaderboardRounds from '@/rounds/rounds.json' | ||
import { isSameAddress } from '@/utils/accounts' | ||
|
||
type LeaderboardRecord = { | ||
address: string | ||
network: string | ||
} | ||
|
||
export async function getLeaderboardData(roundAddress: string, network: string) { | ||
function isSameNetwork(network1 = '', network2 = ''): boolean { | ||
return network1.toLowerCase() === network2.toLowerCase() | ||
} | ||
|
||
export async function getLeaderboardData(roundAddress: string, network?: string) { | ||
const rounds = leaderboardRounds as LeaderboardRecord[] | ||
const checkNetwork = Boolean(network) | ||
|
||
const lowercaseRoundAddress = (roundAddress || '').toLowerCase() | ||
const lowercaseNetwork = (network || '').toLowerCase() | ||
const found = rounds.find((r: LeaderboardRecord) => { | ||
return r.address.toLowerCase() === lowercaseRoundAddress && r.network.toLowerCase() === lowercaseNetwork | ||
return isSameAddress(r.address, roundAddress) && (!checkNetwork || isSameNetwork(network, r.network)) | ||
}) | ||
|
||
return found ? import(`../rounds/${found.network}/${found.address}.json`) : null | ||
if (!found) { | ||
return null | ||
} | ||
|
||
const data = await import(`../rounds/${found.network}/${found.address}.json`) | ||
if (!data.round) { | ||
data.round = {} | ||
} | ||
data.round.network = found.network | ||
return data | ||
} |
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
Oops, something went wrong.