Skip to content

Commit

Permalink
🪄 [QA] Update stage environments (#647)
Browse files Browse the repository at this point in the history
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
andreachapman authored Nov 8, 2023
2 parents 6de8a48 + 909930f commit a7c463d
Show file tree
Hide file tree
Showing 32 changed files with 613 additions and 331 deletions.
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import web3Onboard from "shared/utils/web3Onboard"
// no-extraneous-dependencies.
// eslint-disable-next-line import/no-extraneous-dependencies
import { PostHogProvider } from "posthog-js/react"
import DApp from "shared/components/DApps"
import DApp from "ui/DApps"
import reduxStore from "./redux-state"

function DAppProviders() {
Expand Down
23 changes: 21 additions & 2 deletions src/redux-state/selectors/xp.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { createSelector } from "@reduxjs/toolkit"
import { createIslandSelector } from "redux-state/selectors"
import { createIslandSelector, selectWallet } from "redux-state/selectors"
import { UnclaimedXpData } from "shared/types"
import { getClaimXpTransactionID } from "shared/utils"
import { selectTransactionStatusById } from "./wallet"

export const selectUnclaimedXp = createIslandSelector("unclaimedXp")

export const selectUnclaimedXpById = createSelector(
[(_, realmId: string) => realmId, selectUnclaimedXp],
(realmId, unclaimedXp) => unclaimedXp[realmId]
(realmId, unclaimedXp) => unclaimedXp[realmId] ?? []
)

export const selectUnclaimedXpSumById = createSelector(
Expand All @@ -14,3 +17,19 @@ export const selectUnclaimedXpSumById = createSelector(
unclaimedXp?.reduce((acc, item) => acc + BigInt(item.claim.amount), 0n) ??
0n
)

// We need to use stable instance of unclaimed drops array to ensure they are not causing
// rerenders while claims transaction modal is visible
export const selectXpClaimTransactionStatuses = createSelector(
[
(_, savedUnclaimedDrops: UnclaimedXpData[]) => savedUnclaimedDrops,
selectWallet,
],
(unclaimedXp, walletState) =>
Object.fromEntries(
unclaimedXp.map((data) => {
const id = getClaimXpTransactionID(data)
return [id, selectTransactionStatusById({ wallet: walletState }, id)]
})
)
)
29 changes: 11 additions & 18 deletions src/redux-state/thunks/island.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
import {
RealmContractDataWithId,
TransactionProgressStatus,
UnclaimedXpData,
} from "shared/types"
import { updateTransactionStatus } from "redux-state/slices/wallet"
import { bigIntToUserAmount, getAllowanceTransactionID } from "shared/utils"
Expand Down Expand Up @@ -359,33 +360,25 @@ export const claimXp = createDappAsyncThunk(
async (
{
id,
realmId,
unclaimedXpData,
}: {
id: string
realmId: string
unclaimedXpData: UnclaimedXpData
},
{ dispatch, getState, extra: { transactionService } }
{ dispatch, extra: { transactionService } }
) => {
const {
island: { unclaimedXp },
} = getState()
const claims = unclaimedXp[realmId] ?? []
const { distributorContractAddress, claim } = unclaimedXpData

if (!claims.length) {
const receipt = await transactionService.send(id, claimXpTokens, {
distributorContractAddress,
claim,
})

if (!receipt) {
return false
}

await Promise.allSettled(
claims.map(async ({ distributorContractAddress, claim }) => {
await transactionService.send(id, claimXpTokens, {
distributorContractAddress,
claim,
})
})
)

dispatch(fetchUnclaimedXp())

return true
}
)
23 changes: 22 additions & 1 deletion src/redux-state/thunks/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { resolveAddressToWalletData } from "shared/utils"
import {
isClaimXpTransactionID,
resolveAddressToWalletData,
} from "shared/utils"
import {
updateBalances,
updateConnectedWallet,
resetWalletState,
stopTrackingTransactionStatus,
} from "redux-state/slices/wallet"
import { resetClaiming, setClaimingUser } from "redux-state/slices/claim"
import { getBalance, getStakeUnlockTime } from "shared/contracts"
Expand Down Expand Up @@ -207,3 +211,20 @@ export const fetchWalletBalances = createDappAsyncThunk(
return balances
}
)

export const stopTrackingClaimTransactions = createDappAsyncThunk(
"wallet/stopTrackingClaimTransactions",
async (_, { getState, dispatch }) => {
const {
wallet: { transactionStatus },
} = getState()

const claimTransactionIds = Object.keys(transactionStatus).filter(
isClaimXpTransactionID
)

claimTransactionIds.forEach((id) => {
dispatch(stopTrackingTransactionStatus(id))
})
}
)
7 changes: 7 additions & 0 deletions src/shared/assets/icons/cookies.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/shared/assets/icons/s/new-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/shared/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode } from "react"
import React, { CSSProperties, ReactNode } from "react"
import classnames from "classnames"

type ButtonProps = {
Expand All @@ -21,6 +21,7 @@ type ButtonProps = {
iconSrc?: string
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void
onMouseDown?: (event: React.MouseEvent<HTMLButtonElement>) => void
style?: CSSProperties
}

export default function Button({
Expand All @@ -34,6 +35,7 @@ export default function Button({
iconSrc,
onClick,
onMouseDown,
style,
}: ButtonProps) {
return (
<>
Expand All @@ -54,6 +56,7 @@ export default function Button({
disabled: isDisabled,
inactive: isInactive,
})}
style={style}
>
{children}
{iconSrc && (
Expand Down
94 changes: 0 additions & 94 deletions src/shared/components/DApps/DesktopDApp.tsx

This file was deleted.

88 changes: 88 additions & 0 deletions src/shared/components/Popup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import React, { ReactNode } from "react"
import { animated } from "@react-spring/web"
import { useVisibilityTransition } from "shared/hooks"
import Icon from "shared/components/Icon"
import closeIcon from "shared/assets/icons/s/close.svg"

export type PopupProps = {
children: ReactNode
isVisible: boolean
close: () => void
leftPosition?: string | number
bottomPosition: string | number
rightPosition?: string | number
width: string | number
hasPointer?: boolean
style?: React.CSSProperties
}

type XAxisPsition = {
left?: string | number
right?: string | number
}

export default function Popup({
children,
isVisible,
close,
bottomPosition,
leftPosition,
rightPosition,
width,
hasPointer = true,
style,
}: PopupProps) {
const transition = useVisibilityTransition(isVisible)
const xPosition: XAxisPsition = {}

if (leftPosition !== null) xPosition.left = leftPosition
if (rightPosition !== null) xPosition.right = rightPosition

return (
<>
<animated.div
style={{
position: "absolute",
bottom: bottomPosition,
background: "#043937",
borderRadius: 16,
padding: "24px 32px 32px",
width,
pointerEvents: isVisible ? "all" : "none",
...transition,
...xPosition,
...style,
}}
>
<button
type="button"
className="close_button button_reset"
onClick={close}
>
<Icon src={closeIcon} width="16px" height="16px" />
</button>
<div className="content">{children}</div>
</animated.div>
<style jsx>{`
.close_button {
position: absolute;
top: 14px;
right: 16px;
padding: 0;
}
.content::after {
display: ${hasPointer ? "block" : "none"};
content: "";
background: #043937;
height: 12px;
width: 12px;
position: absolute;
bottom: -4px;
right: 26px;
border-radius: 2px;
rotate: 45deg;
}
`}</style>
</>
)
}
Loading

0 comments on commit a7c463d

Please sign in to comment.