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 release environment #676

Merged
merged 5 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/redux-state/selectors/realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export const selectHasLoadedRealmData = createSelector(
(realms) => Object.keys(realms).length !== 0
)

export const selectDisplayedRealmName = selectDisplayedRealmProperty("name")

export const selectDisplayedRealmAddress = selectDisplayedRealmProperty(
"realmContractAddress"
)
Expand Down
17 changes: 15 additions & 2 deletions src/ui/Island/RealmDetails/RealmBanners/BannerRewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ClaimCongratulations from "ui/Claim/modals/ClaimCongratulations"
import Tooltip from "shared/components/Tooltip"
import { bigIntToDisplayUserAmount } from "shared/utils"
import { LINKS } from "shared/constants"
import { usePostHog } from "posthog-js/react"
import XpClaimModal from "../XpClaim/XpClaimModal"

export default function BannerRewards({
Expand All @@ -20,6 +21,8 @@ export default function BannerRewards({
amount: bigint
setJustClaimed: (hasClaimed: boolean) => void
}) {
const posthog = usePostHog()

const realmId = useDappSelector(selectDisplayedRealmId)
const realm = useDappSelector((state) => selectRealmById(state, realmId))

Expand All @@ -34,12 +37,22 @@ export default function BannerRewards({
const onClaim = useCallback(() => {
setJustClaimed(true) // to keep the banner + congratulation modal open
setCongratulationsModalOpen(true)
}, [setJustClaimed])
posthog?.capture("Realm XP claim completed", {
realmName: realm?.name,
})
}, [setJustClaimed, realm?.name, posthog])

const onClose = useCallback(() => {
setIsClaimTransactionModalOpen(false)
}, [])

const onOpen = useCallback(() => {
posthog?.capture("Realm XP claim started", {
realmName: realm?.name,
})
setIsClaimTransactionModalOpen(true)
}, [posthog, realm?.name])

if (!realmId || !realm) return null

return (
Expand Down Expand Up @@ -72,7 +85,7 @@ export default function BannerRewards({
<Button
size="medium"
type="secondary"
onClick={() => setIsClaimTransactionModalOpen(true)}
onClick={onOpen}
isDisabled={amount === 0n}
>
Claim XP
Expand Down
15 changes: 5 additions & 10 deletions src/ui/Island/RealmDetails/StakingForms/StakeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ import {
stopTrackingTransactionStatus,
selectStakingRealmAddress,
selectStakingRealmId,
selectRealmNameById,
selectDisplayedRealmName,
} from "redux-state"
import { isValidInputAmount, userAmountToBigInt } from "shared/utils"
import classNames from "classnames"
import { TAHO_ADDRESS } from "shared/constants"
import { TransactionProgressStatus } from "shared/types"
import TransactionProgress from "shared/components/Transactions/TransactionProgress"
import { useAssistant, useTransactionSuccessCallback } from "shared/hooks"
// Unfortunately the PostHog React package structure does not play nice with
// no-extraneous-dependencies.
// eslint-disable-next-line import/no-extraneous-dependencies
import { usePostHog } from "posthog-js/react"
import StakeCongratulationsModal from "./StakeCongratulationsModal"

Expand All @@ -30,11 +27,9 @@ export default function StakeForm({ isDisabled }: { isDisabled: boolean }) {
const dispatch = useDappDispatch()

const displayedRealmAddress = useDappSelector(selectDisplayedRealmAddress)
const displayedRealmName = useDappSelector(selectDisplayedRealmName)
const stakingRealmAddress = useDappSelector(selectStakingRealmAddress)
const stakingRealmId = useDappSelector(selectStakingRealmId)
const realmName = useDappSelector((state) =>
selectRealmNameById(state, stakingRealmId)
)

const [stakeAmount, setStakeAmount] = useState("")
const [isStakeAmountValid, setIsStakeAmountValid] = useState(false)
Expand Down Expand Up @@ -64,7 +59,7 @@ export default function StakeForm({ isDisabled }: { isDisabled: boolean }) {
})
)
posthog?.capture("Realm stake started", {
realmName,
realmName: displayedRealmName,
})
}
}
Expand All @@ -85,7 +80,7 @@ export default function StakeForm({ isDisabled }: { isDisabled: boolean }) {

const stakeTransactionSuccessCallback = useCallback(() => {
posthog?.capture("Realm stake completed", {
realmName,
realmName: displayedRealmName,
})

setIsStakeTransactionModalOpen(false)
Expand All @@ -94,7 +89,7 @@ export default function StakeForm({ isDisabled }: { isDisabled: boolean }) {
if (!stakingRealmId) {
updateAssistant({ visible: true, type: "quests" })
}
}, [posthog, realmName, dispatch, stakingRealmId, updateAssistant])
}, [posthog, displayedRealmName, dispatch, stakingRealmId, updateAssistant])

const onInputChange = (value: string) => {
setStakeAmount(value)
Expand Down
15 changes: 5 additions & 10 deletions src/ui/Island/RealmDetails/StakingForms/UnstakeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
selectTransactionStatusById,
stopTrackingTransactionStatus,
selectTokenBalanceByAddress,
selectRealmNameById,
selectDisplayedRealmName,
} from "redux-state"
import { isValidInputAmount, userAmountToBigInt } from "shared/utils"
import classNames from "classnames"
Expand All @@ -24,9 +24,6 @@ import {
useStakeCooldownPeriod,
useTransactionSuccessCallback,
} from "shared/hooks"
// Unfortunately the PostHog React package structure does not play nice with
// no-extraneous-dependencies.
// eslint-disable-next-line import/no-extraneous-dependencies
import { usePostHog } from "posthog-js/react"

const UNSTAKE_TX_ID = "unstake"
Expand All @@ -39,9 +36,7 @@ export default function UnstakeForm({ isDisabled }: { isDisabled: boolean }) {
selectDisplayedRealmVeTokenAddress
)
const displayedRealmId = useDappSelector(selectDisplayedRealmId)
const realmName = useDappSelector((state) =>
selectRealmNameById(state, displayedRealmId)
)
const displayedRealmName = useDappSelector(selectDisplayedRealmName)

const veTahoBalance = useDappSelector((state) =>
selectTokenBalanceByAddress(state, displayedRealmVeTokenAddress)
Expand Down Expand Up @@ -78,7 +73,7 @@ export default function UnstakeForm({ isDisabled }: { isDisabled: boolean }) {
)
}
posthog?.capture("Realm unstake started", {
realmName,
realmName: displayedRealmName,
})
}

Expand All @@ -92,15 +87,15 @@ export default function UnstakeForm({ isDisabled }: { isDisabled: boolean }) {

const unstakeTransactionSuccessCallback = useCallback(() => {
posthog?.capture("Realm unstake completed", {
realmName,
realmName: displayedRealmName,
})

setIsUnstakeTransactionModalOpen(false)
setIsLeavingRealmModalOpen(false)
setUnstakeAmount("")
dispatch(stopTrackingTransactionStatus(UNSTAKE_TX_ID))
updateAssistant({ visible: false, type: "default" })
}, [dispatch, realmName, posthog, updateAssistant])
}, [dispatch, displayedRealmName, posthog, updateAssistant])

useTransactionSuccessCallback(
unstakeTransactionStatus,
Expand Down
3 changes: 0 additions & 3 deletions src/ui/Island/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ import {
useDappSelector,
} from "redux-state"
import FullPageLoader from "shared/components/FullPageLoader"
// Unfortunately the PostHog React package structure does not play nice with
// no-extraneous-dependencies.
// eslint-disable-next-line import/no-extraneous-dependencies
import { usePostHog } from "posthog-js/react"
import InteractiveIsland from "./InteractiveIsland"
import RealmDetails from "./RealmDetails"
Expand Down
Loading