-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪄 [QA] Update stage environments (#631)
This is a pull request that upon merging will update stage environments with recent `main` changes. The environments that will be updated: * Stage live: https://stage-live--taho-development.netlify.app/ * Stage fork: https://stage-fork--taho-development.netlify.app/ Read more: [Deployment to Production Flow](https://github.com/tahowallet/dapp/blob/main/docs/testing-env.md)
- Loading branch information
Showing
21 changed files
with
419 additions
and
329 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createSelector } from "@reduxjs/toolkit" | ||
import { | ||
CreateIslandSelector, | ||
CreateClaimSelector, | ||
CreateWalletSelector, | ||
} from "shared/types/selectors" | ||
import { RootState } from "./reducers" | ||
|
||
export const selectIsland = (state: RootState) => state.island | ||
export const selectClaim = (state: RootState) => state.claim | ||
export const selectWallet = (state: RootState) => state.wallet | ||
|
||
export const createIslandSelector: CreateIslandSelector = (value) => | ||
createSelector(selectIsland, (island) => island[value]) | ||
|
||
export const createClaimSelector: CreateClaimSelector = (value) => | ||
createSelector(selectClaim, (claim) => claim[value]) | ||
|
||
export const createWalletSelector: CreateWalletSelector = (value) => | ||
createSelector(selectWallet, (wallet) => wallet[value]) |
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,31 +1,22 @@ | ||
import { createSelector } from "@reduxjs/toolkit" | ||
import { RootState } from "redux-state/reducers" | ||
import { truncateAddress } from "shared/utils" | ||
import { RealmData } from "shared/types" | ||
import { selectRealmById } from "./island" | ||
import { createClaimSelector } from "redux-state/selectors" | ||
|
||
export const selectClaimingUser = (state: RootState) => ({ | ||
name: state.claim.name || truncateAddress(state.claim.address), | ||
address: state.claim.address, | ||
}) | ||
|
||
export const selectHasClaimed = (state: RootState) => state.claim.hasClaimed | ||
|
||
export const selectEligibility = (state: RootState) => state.claim.eligibility | ||
|
||
export const selectUseConnectedWalletToClaim = (state: RootState) => | ||
state.claim.useConnectedWallet | ||
|
||
export const selectStakingData = createSelector( | ||
(state: RootState) => selectRealmById(state, state.claim.selectedRealmId), | ||
(state: RootState) => state.claim.stakeAmount, | ||
(realmData: RealmData | null, stakeAmount) => ({ | ||
realmContractAddress: realmData ? realmData.realmContractAddress : null, | ||
stakeAmount, | ||
}) | ||
export const selectHasClaimed = createClaimSelector("hasClaimed") | ||
export const selectEligibility = createClaimSelector("eligibility") | ||
export const selectRealmId = createClaimSelector("selectedRealmId") | ||
export const selectClaimingStakeAmount = createClaimSelector("stakeAmount") | ||
export const selectClaimAdress = createClaimSelector("address") | ||
export const selectClaimName = createClaimSelector("name") | ||
export const selectUseConnectedWalletToClaim = | ||
createClaimSelector("useConnectedWallet") | ||
export const selectRepresentativeAddress = createClaimSelector( | ||
"representativeAddress" | ||
) | ||
export const selectClaimingSelectedRealmId = | ||
createClaimSelector("selectedRealmId") | ||
|
||
export const selectRepresentativeAddress = (state: RootState) => | ||
state.claim.representativeAddress | ||
|
||
export const selectRealmId = (state: RootState) => state.claim.selectedRealmId | ||
export const selectClaimingUser = (state: RootState) => ({ | ||
name: selectClaimName(state) || truncateAddress(selectClaimAdress(state)), | ||
address: selectClaimAdress(state), | ||
}) |
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,211 +1,13 @@ | ||
import { createSelector } from "@reduxjs/toolkit" | ||
import { RootState } from "redux-state/reducers" | ||
import { DAY } from "shared/constants" | ||
import { isSameAddress } from "shared/utils" | ||
import { createIslandSelector } from "redux-state/selectors" | ||
import { IslandModeType } from "redux-state/slices/island" | ||
|
||
export const selectIslandMode = (state: RootState) => state.island.mode | ||
export const selectIslandMode = createIslandSelector("mode") | ||
export const selectIslandOverlay = createIslandSelector("overlay") | ||
export const selectIslandZoomLevel = createIslandSelector("zoomLevel") | ||
|
||
export const selectIsDefaultIslandMode = (state: RootState) => | ||
state.island.mode === "default" | ||
const checkIslandMode = (value: IslandModeType) => | ||
createSelector(selectIslandMode, (mode) => mode === value) | ||
|
||
export const selectIsJoinRealmIslandMode = (state: RootState) => | ||
state.island.mode === "join-realm" | ||
|
||
export const selectIslandOverlay = (state: RootState) => state.island.overlay | ||
|
||
export const selectRealms = (state: RootState) => state.island.realms | ||
|
||
export const selectRealmById = createSelector( | ||
[selectRealms, (_, realmId: string | null) => realmId], | ||
(realms, realmId) => (realmId ? realms[realmId] : null) | ||
) | ||
|
||
export const selectRealmNameById = createSelector( | ||
[selectRealms, (_, realmId: string | null) => realmId], | ||
(realms, realmId) => (realmId ? realms[realmId].name : null) | ||
) | ||
|
||
export const selectRealmWithIdByAddress = createSelector( | ||
[selectRealms, (_, realmAddress: string) => realmAddress], | ||
(realms, realmAddress) => | ||
Object.entries(realms).find(([_, { realmContractAddress }]) => | ||
isSameAddress(realmContractAddress, realmAddress) | ||
) | ||
) | ||
|
||
export const selectHasLoadedRealmData = createSelector( | ||
selectRealms, | ||
(realms) => Object.keys(realms).length !== 0 | ||
) | ||
|
||
export const selectHasLoadedSeasonInfo = createSelector( | ||
(state: RootState) => state.island.seasonInfo, | ||
(seasonInfo) => seasonInfo !== null | ||
) | ||
|
||
/* Season info - selectors */ | ||
export const selectSeasonStartTimestamp = (state: RootState) => | ||
state.island.seasonInfo?.seasonStartTimestamp | ||
|
||
export const selectSeasonEndTimestamp = (state: RootState) => | ||
state.island.seasonInfo?.seasonEndTimestamp | ||
|
||
export const selectSeasonDurationInWeeks = (state: RootState) => | ||
state.island.seasonInfo?.durationInWeeks | ||
|
||
export const selectIsEndOfSeason = createSelector( | ||
selectSeasonEndTimestamp, | ||
(seasonEndTimestamp) => { | ||
if (seasonEndTimestamp) { | ||
return Date.now() > seasonEndTimestamp | ||
} | ||
return null | ||
} | ||
) | ||
|
||
export const selectSeasonWeek = createSelector( | ||
selectSeasonStartTimestamp, | ||
selectIsEndOfSeason, | ||
selectSeasonDurationInWeeks, | ||
(seasonStartTimestamp, isEndOfSeason, durationInWeeks) => { | ||
if (isEndOfSeason) return durationInWeeks | ||
|
||
if (seasonStartTimestamp && durationInWeeks) { | ||
const hasSeasonStarted = seasonStartTimestamp < Date.now() | ||
if (!hasSeasonStarted) return 1 // if the start date is placed in the future, set season week to 1 | ||
|
||
return Math.trunc((Date.now() - seasonStartTimestamp) / (7 * DAY) + 1) | ||
} | ||
|
||
return null | ||
} | ||
) | ||
|
||
export const selectWeekStartDate = createSelector( | ||
selectSeasonStartTimestamp, | ||
selectSeasonWeek, | ||
(seasonStartTimestamp, seasonWeek) => { | ||
if (seasonStartTimestamp && seasonWeek) { | ||
const startDate = new Date(seasonStartTimestamp) | ||
startDate.setDate(startDate.getDate() + (seasonWeek - 1) * 7) | ||
return startDate | ||
} | ||
return null | ||
} | ||
) | ||
|
||
export const selectWeekEndDate = createSelector( | ||
selectWeekStartDate, | ||
(startDate) => { | ||
if (!startDate) return null | ||
|
||
const endDate = new Date(startDate) | ||
endDate.setDate(startDate.getDate() + 6) | ||
return endDate | ||
} | ||
) | ||
|
||
/* Displayed Realm - selectors */ | ||
export const selectDisplayedRealmId = (state: RootState) => | ||
state.island.displayedRealmId | ||
|
||
export const selectDisplayedRealmAddress = createSelector( | ||
selectRealms, | ||
selectDisplayedRealmId, | ||
(realms, realmId) => realmId && realms[realmId]?.realmContractAddress | ||
) | ||
|
||
export const selectDisplayedRealmVeTokenAddress = createSelector( | ||
selectRealms, | ||
selectDisplayedRealmId, | ||
(realms, realmId) => realmId && realms[realmId]?.veTokenContractAddress | ||
) | ||
|
||
/* Staking Realm - selectors */ | ||
export const selectStakingRealmId = (state: RootState) => | ||
state.island.stakingRealmId | ||
|
||
export const selectStakingRealmAddress = createSelector( | ||
selectRealms, | ||
selectStakingRealmId, | ||
(realms, stakingRealmId) => | ||
stakingRealmId && realms[stakingRealmId]?.realmContractAddress | ||
) | ||
|
||
/* Xp selectors */ | ||
export const selectLeaderboards = (state: RootState) => | ||
state.island.leaderboards | ||
|
||
export const selectUnclaimedXp = (state: RootState) => state.island.unclaimedXp | ||
|
||
const selectLeaderboardDataById = createSelector( | ||
[(_, realmId: string) => realmId, selectLeaderboards], | ||
(realmId, leaderboards) => leaderboards[realmId] | ||
) | ||
|
||
export const selectLeaderboardById = createSelector( | ||
selectLeaderboardDataById, | ||
(leaderboardData) => leaderboardData?.leaderboard ?? [] | ||
) | ||
|
||
export const selectUserLeaderboardRankById = createSelector( | ||
selectLeaderboardDataById, | ||
(leaderboardData) => leaderboardData?.currentUser ?? null | ||
) | ||
|
||
export const selectUnclaimedXpById = createSelector( | ||
[(_, realmId: string) => realmId, selectUnclaimedXp], | ||
(realmId, unclaimedXp) => unclaimedXp[realmId] | ||
) | ||
|
||
export const selectUnclaimedXpSumById = createSelector( | ||
[selectUnclaimedXpById], | ||
(unclaimedXp) => | ||
unclaimedXp?.reduce((acc, item) => acc + BigInt(item.claim.amount), 0n) ?? | ||
0n | ||
) | ||
/* Population - selectors */ | ||
export const selectSortedPopulation = createSelector(selectRealms, (realms) => { | ||
const realmsData = Object.entries(realms).map(([id, data]) => ({ | ||
id, | ||
...data, | ||
})) | ||
|
||
const sortedRealms = realmsData.sort((a, b) => a.population - b.population) | ||
return sortedRealms | ||
}) | ||
|
||
export const selectPopulationById = createSelector( | ||
selectRealmById, | ||
(realm) => realm?.population ?? 0 | ||
) | ||
|
||
export const selectTotalPopulation = createSelector( | ||
selectSortedPopulation, | ||
(realms) => | ||
realms.length | ||
? realms.map((realm) => realm.population).reduce((a, b) => a + b) | ||
: 0 | ||
) | ||
|
||
export const selectMaxPopulation = createSelector( | ||
selectSortedPopulation, | ||
(realms) => | ||
realms.length ? Math.max(...realms.map((realm) => realm.population)) : 0 | ||
) | ||
|
||
/* Helpful selectors */ | ||
export const selectIsStakingRealmDisplayed = createSelector( | ||
selectStakingRealmAddress, | ||
selectDisplayedRealmAddress, | ||
(stakingAddress, displayedAddress) => | ||
!!stakingAddress && | ||
!!displayedAddress && | ||
isSameAddress(stakingAddress, displayedAddress) | ||
) | ||
|
||
export const selectStakeUnlockTime = (state: RootState) => | ||
state.island.stakeUnlockTime | ||
|
||
export const selectIslandZoomLevel = (state: RootState) => | ||
state.island.zoomLevel | ||
export const selectIsDefaultIslandMode = checkIslandMode("default") | ||
export const selectIsJoinRealmIslandMode = checkIslandMode("join-realm") |
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,19 @@ | ||
import { createSelector } from "@reduxjs/toolkit" | ||
import { createIslandSelector } from "redux-state/selectors" | ||
|
||
export const selectLeaderboards = createIslandSelector("leaderboards") | ||
|
||
const selectLeaderboardDataById = createSelector( | ||
[(_, realmId: string) => realmId, selectLeaderboards], | ||
(realmId, leaderboards) => leaderboards[realmId] | ||
) | ||
|
||
export const selectLeaderboardById = createSelector( | ||
selectLeaderboardDataById, | ||
(leaderboardData) => leaderboardData?.leaderboard ?? [] | ||
) | ||
|
||
export const selectUserLeaderboardRankById = createSelector( | ||
selectLeaderboardDataById, | ||
(leaderboardData) => leaderboardData?.currentUser ?? null | ||
) |
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,31 @@ | ||
import { createSelector } from "@reduxjs/toolkit" | ||
import { RealmData } from "shared/types" | ||
import { selectRealmById, selectRealms } from "./realm" | ||
|
||
const getPopulationOfRealms = (realms: RealmData[]) => | ||
realms.map((realm) => realm.population) | ||
|
||
export const selectSortedPopulation = createSelector(selectRealms, (realms) => { | ||
const realmsData = Object.entries(realms).map(([id, data]) => ({ | ||
id, | ||
...data, | ||
})) | ||
|
||
return realmsData.sort((a, b) => a.population - b.population) | ||
}) | ||
|
||
export const selectPopulationById = createSelector( | ||
selectRealmById, | ||
(realm) => realm?.population ?? 0 | ||
) | ||
|
||
export const selectTotalPopulation = createSelector( | ||
selectSortedPopulation, | ||
(realms) => | ||
realms.length ? getPopulationOfRealms(realms).reduce((a, b) => a + b) : 0 | ||
) | ||
|
||
export const selectMaxPopulation = createSelector( | ||
selectSortedPopulation, | ||
(realms) => (realms.length ? Math.max(...getPopulationOfRealms(realms)) : 0) | ||
) |
Oops, something went wrong.