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 #701

Merged
merged 35 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1eadf1a
Add basic animation for population bubble
Nov 2, 2023
083bb5e
Use a hook to showing population bubble
Nov 2, 2023
ebf2052
Create a displayed population to handle bubbles
Nov 2, 2023
2473f31
Use interval for updating population
Nov 2, 2023
f3c32d8
Merge branch 'main' of github.com:tahowallet/dapp into population-bubble
Nov 3, 2023
3aa7f0f
Generate random intervals for bubbles
Nov 3, 2023
44669d1
Adding bubble to the modal window
Nov 3, 2023
fa2bd1c
Set correct bubble animation
xpaczka Nov 6, 2023
fd12599
Merge branch 'main' into population-bubble
xpaczka Nov 6, 2023
5817612
Animate `RealmBarIcon` component
xpaczka Nov 6, 2023
2fea5a9
Fix `RealmBarIcon` animation
xpaczka Nov 7, 2023
a3065c1
Animate `RealmBarIcon` using `displayedPopulation` property
xpaczka Nov 7, 2023
bd48a4f
Refactor `population` selectors
xpaczka Nov 8, 2023
1980c34
Type-o fixes and commented code removals
xpaczka Nov 8, 2023
b5fbf34
Remove dispatch awaiting
xpaczka Nov 8, 2023
60862e2
`setShowBubble` after dispatching event
xpaczka Nov 9, 2023
5bc5699
Change condition for `setRealmDisplayedPopulation`
xpaczka Nov 9, 2023
3c7df3e
Merge branch 'main' into population-bubble
xpaczka Nov 9, 2023
2ae7563
Merge branch 'main' into population-bubble
jagodarybacka Nov 9, 2023
8421908
Update displayed population if it is `null` in `redux`
xpaczka Nov 10, 2023
c2b2b81
Improve transition on onboarding `PopulationCount`
xpaczka Nov 10, 2023
edbf328
`useInterval` only when `population` and `displayedPopulation` is truthy
xpaczka Nov 10, 2023
a26c5c4
Remove transition from `RealmBar`
xpaczka Nov 10, 2023
396fe76
Create `useDisplayedPopulation` hook
xpaczka Nov 10, 2023
7e4f471
Merge branch 'main' into population-bubble
xpaczka Nov 15, 2023
4851cbe
Reduce interval time in fetching current realms population
xpaczka Nov 15, 2023
0a79f28
Handle bigints in the `TokenAmountInput`
jagodarybacka Nov 15, 2023
665b8ea
Gracefully handle amounts smaller than desired precision
jagodarybacka Nov 15, 2023
4840a78
Handle cases where input precision is not enough
jagodarybacka Nov 15, 2023
ea541f2
Add util to display bigints as strings with max precision
jagodarybacka Nov 15, 2023
64418ac
Get rid of browser tooltip for input
jagodarybacka Nov 15, 2023
28b01f4
Bubble of a growing population (#627)
jagodarybacka Nov 16, 2023
6fb86a2
Handle bigints in the `TokenAmountInput` (#699)
xpaczka Nov 16, 2023
ec665e4
Fix typos
xpaczka Nov 16, 2023
c42630a
Fix typos (#702)
jagodarybacka Nov 16, 2023
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
2 changes: 1 addition & 1 deletion docs/testing-env.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Branches

- `main`
- branch `main` is the base branch for current developement
- branch `main` is the base branch for current development
- every feature branch should be merged into `main` via pull request
- `stage-live`
- base for running the staging environment that is running on the live chain
Expand Down
56 changes: 42 additions & 14 deletions src/redux-state/selectors/population.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
import { createSelector } from "@reduxjs/toolkit"
import { RealmData } from "shared/types"
import {
getDisplayedPopulationOfRealms,
getPopulationOfRealms,
} from "redux-state/utils/population"
import { selectRealmById, selectRealms } from "./realm"

const getPopulationOfRealms = (realms: RealmData[]) =>
realms.map((realm) => realm.population)
type PopulationKey = "population" | "displayedPopulation"

export const selectSortedPopulation = createSelector(selectRealms, (realms) => {
const realmsData = Object.entries(realms).map(([id, data]) => ({
id,
...data,
}))
const getPopulationById = (key: PopulationKey) =>
createSelector(selectRealmById, (realm) => realm?.[key] ?? 0)

return realmsData.sort((a, b) => a.population - b.population)
})
const sortPopulation = (key: PopulationKey) =>
createSelector(selectRealms, (realms) => {
const realmsData = Object.entries(realms).map(([id, data]) => ({
id,
...data,
}))

export const selectPopulationById = createSelector(
selectRealmById,
(realm) => realm?.population ?? 0
return realmsData.sort((a, b) => a[key] - b[key])
})

export const selectSortedPopulation = sortPopulation("population")
export const selectSortedDisplayedPopulation = sortPopulation(
"displayedPopulation"
)

export const selectPopulationById = getPopulationById("population")
export const selectDisplayedPopulationById = getPopulationById(
"displayedPopulation"
)

export const selectTotalPopulation = createSelector(
Expand All @@ -25,7 +36,24 @@ export const selectTotalPopulation = createSelector(
realms.length ? getPopulationOfRealms(realms).reduce((a, b) => a + b) : 0
)

export const selectTotalDisplayedPopulation = createSelector(
selectSortedDisplayedPopulation,
(realms) =>
realms.length
? getDisplayedPopulationOfRealms(realms).reduce((a, b) => a + b)
: 0
)

export const selectMaxPopulation = createSelector(
selectSortedPopulation,
(realms) => (realms.length ? Math.max(...getPopulationOfRealms(realms)) : 0)
(realms) =>
realms.length ? getPopulationOfRealms(realms)[realms.length - 1] : 0
)

export const selectMaxDisplayedPopulation = createSelector(
selectSortedDisplayedPopulation,
(realms) =>
realms.length
? getDisplayedPopulationOfRealms(realms)[realms.length - 1]
: 0
)
14 changes: 12 additions & 2 deletions src/redux-state/slices/island.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import {
LeaderboardData,
UnclaimedXpData,
OverlayType,
RealmData,
RealmDataWithId,
SeasonInfo,
RealmDataById,
} from "shared/types"

export type IslandModeType = "default" | "join-realm"

export type IslandState = {
mode: IslandModeType
overlay: OverlayType
realms: { [id: string]: RealmData }
realms: RealmDataById
leaderboards: { [id: string]: LeaderboardData }
unclaimedXp: { [id: string]: UnclaimedXpData[] }
stakingRealmId: string | null
Expand Down Expand Up @@ -75,6 +75,15 @@ const islandSlice = createSlice({
immerState.realms[realmPopulation.id].population =
realmPopulation.population
},
setRealmDisplayedPopulation: (
immerState,
{
payload: realmPopulation,
}: { payload: { id: string; population: number } }
) => {
immerState.realms[realmPopulation.id].displayedPopulation =
realmPopulation.population
},
setRealmXpAllocatable: (
immerState,
{
Expand Down Expand Up @@ -139,6 +148,7 @@ export const {
resetIslandDisplay,
resetIslandAccount,
setRealmPopulation,
setRealmDisplayedPopulation,
setRealmXpAllocatable,
setRealmsData,
setDisplayedRealmId,
Expand Down
15 changes: 13 additions & 2 deletions src/redux-state/thunks/island.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
setRealmXpAllocatable,
setRealmsData,
setSeasonInfo,
setRealmDisplayedPopulation,
} from "redux-state/slices/island"
import {
REALMS_WITH_CONTRACT_NAME,
Expand All @@ -29,7 +30,11 @@ import {
UnclaimedXpData,
} from "shared/types"
import { updateTransactionStatus } from "redux-state/slices/wallet"
import { bigIntToUserAmount, getAllowanceTransactionID } from "shared/utils"
import {
bigIntToUserAmount,
getAllowanceTransactionID,
isDisplayedPopulationAvailable,
} from "shared/utils"
import {
getRealmLeaderboardData,
getUserLeaderboardRank,
Expand Down Expand Up @@ -107,8 +112,14 @@ export const fetchPopulation = createDappAsyncThunk(
realmsWithAddress,
})

const displayedPopulationAvailable = isDisplayedPopulationAvailable(realms)

if (result) {
result.forEach((data) => dispatch(setRealmPopulation(data)))
result.forEach((data) => {
dispatch(setRealmPopulation(data))
if (!displayedPopulationAvailable)
dispatch(setRealmDisplayedPopulation(data))
})
}

return !!result
Expand Down
7 changes: 7 additions & 0 deletions src/redux-state/utils/population.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { RealmData } from "shared/types"

export const getPopulationOfRealms = (realms: RealmData[]) =>
realms.map((realm) => realm.population)

export const getDisplayedPopulationOfRealms = (realms: RealmData[]) =>
realms.map((realm) => realm.displayedPopulation)
31 changes: 31 additions & 0 deletions src/shared/assets/partners/arbitrum-population.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions src/shared/assets/partners/cyberconnect-population.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions src/shared/assets/partners/frax-population.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions src/shared/assets/partners/galxe-population.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions src/shared/assets/partners/gitcoin-population.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/shared/components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default function SharedInput({
<div className="input_box">
<input
type={type}
step="any"
min={isTypeNumber ? "0" : undefined}
className={classNames({ input_number: isTypeNumber })}
value={value}
Expand Down
48 changes: 48 additions & 0 deletions src/shared/components/RealmCutout/Bubble.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { animated, easings, useSpring } from "@react-spring/web"
import React, { useEffect, useState } from "react"
import { getRealmPopulationIcon } from "shared/constants"
import { usePopulationBubble } from "shared/hooks"

export const STYLE = {
default: { opacity: 0, transform: "translateY(150px)" },
highlight: { opacity: 1, transform: "translateY(50px)" },
}

export const BUBBLE_CONFIG = {
precision: 0.1,
duration: 2000,
easing: easings.easeOutCubic,
}

export default function Bubble({ realmId }: { realmId: string }) {
const { showBubble, setShowBubble } = usePopulationBubble(realmId)

const [iconSrc, setIconSrc] = useState<string | null>(null)

useEffect(() => {
const icon = getRealmPopulationIcon(realmId)
setIconSrc(icon)
}, [realmId])

const [bubbleProps] = useSpring(
() => ({
from: STYLE.default,
to: showBubble ? STYLE.highlight : STYLE.default,
config: BUBBLE_CONFIG,
onRest: () => setShowBubble(false),
}),
[showBubble]
)

if (!iconSrc) return null

return (
<animated.div
style={{ ...bubbleProps, left: "220px", position: "absolute", zIndex: 2 }}
>
<div>
<img src={iconSrc} height={24} width={24} alt="Bubble" />
</div>
</animated.div>
)
}
Loading
Loading