Skip to content

Commit

Permalink
Feat - New collection for Rewards script (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
DillonLin authored Oct 12, 2022
1 parent ec07966 commit 3d2e69c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sdk/src/constants/collections.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum FirebaseCollections {
AvalonGlobalRewardsEpoch = 'AVALON_GLOBAL_REWARDS_EPOCH',
AvalonAccountRewardsEpoch = 'AVALON_ACCOUNT_REWARDS_EPOCH',
AvalonAccountRewardsEpoch = 'AVALON_ACCOUNT_REWARDS_EPOCH_2',
}
6 changes: 3 additions & 3 deletions sdk/src/utils/fetchAccountRewardEpochData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getAddress } from '@ethersproject/address'
import { equalTo, get, orderByChild, query, ref } from 'firebase/database'
import { get, query, ref } from 'firebase/database'

import { FirebaseCollections } from '../constants/collections'
import Lyra, { Deployment } from '../lyra'
Expand Down Expand Up @@ -49,8 +49,8 @@ export default async function fetchAccountRewardEpochData(
const key = getAddress(account as string)
if (!ACCOUNT_EPOCH_CACHE[key] || blockTimestamp > ACCOUNT_EPOCH_CACHE[key].lastUpdated + ACCOUNT_EPOCH_CACHE_LIFE) {
const database = connectToFirebaseDatabase()
const collectionReference = ref(database, FirebaseCollections.AvalonAccountRewardsEpoch)
const queryReference = query(collectionReference, orderByChild('account'), equalTo(key))
const collectionReference = ref(database, `${FirebaseCollections.AvalonAccountRewardsEpoch}/${key}`)
const queryReference = query(collectionReference)
const epochPromise = async (): Promise<AccountRewardEpochData[]> => {
const snapshot = await get(queryReference)
return snapshot.val() ? Object.values(snapshot.val()) : []
Expand Down

0 comments on commit 3d2e69c

Please sign in to comment.