Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪄 [QA] Update stage environments #625

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/shared/utils/xp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,20 @@ export async function getXpDataForRealmId(
// Addresses in the claim files are sorted in ascending order,
// we only know about the address that the file starts with and our `targetAddress`.
// * If `startAddress` < `targetAddress` then we don't know if the address
// is in the current claim file or the next one. We assume that it's in the one of the upcoming files.
// * If `startAddress` > `targetAddress` then we know that the address is in the previous file.
// Edge cases are:
// * `targetAddress` === `startAddress` - this is covered by the same logic as the regular case,
// because we will come back to the previous file, because while checking next claim file startAddress > targetAddress
// * `targetAddress` is in the first file - this is covered by defaulting to the first file is none of the files match
// * `targetAddress` is not in the drop at all - not a problem, we will return null
const suspectedNextClaimFileIndex = glossaryFile.glossary.findIndex(
({ startAddress }) => BigInt(startAddress ?? 0) > targetAddress
)
const claimFileIndex =
suspectedNextClaimFileIndex <= 0 ? 0 : suspectedNextClaimFileIndex - 1
const claimFile = glossaryFile.glossary[claimFileIndex]?.file
// is in the current claim file or the next one. We assume that it's
// in the one of the upcoming files.
// * If `startAddress` > `targetAddress` then we know that the address
// is in the previous file.
// * If this heuristic produces no matching entry, then the last file
// is the only one that could include the address.
const claimFileEntry =
glossaryFile.glossary.find(
(_, i, glossary) =>
// If the next glossary entry's start address > the target, this
// file will contain the claim or there is no claim.
BigInt(glossary[i + 1]?.startAddress ?? 0) > targetAddress
) ?? glossaryFile.glossary.slice(-1)[0] // default to the last entry if no other entry is found
const claimFile = claimFileEntry?.file

if (!claimFile) {
// No claim file found for the user
Expand Down
Loading