-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent "no multisig" from being displayed before we checked (#390)
Co-authored-by: Anton Lykhoyda <[email protected]>
- Loading branch information
Showing
18 changed files
with
195 additions
and
108 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export const landingPage = { | ||
watchAccountButton: () => cy.get('[data-cy=button-watch-address]'), | ||
accountsOrRpcLoader: () => cy.get('[data-cy="loader-accounts-rpc-connection"]'), | ||
accountsLoader: () => cy.get('[data-cy="loader-accounts-connection"]'), | ||
noAccountFoundError: () => cy.get('[data-cy="text-no-account-found"]') | ||
} |
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
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,2 @@ | ||
export const waitForAuthRequest = () => | ||
cy.waitUntil(() => cy.getAuthRequests().then((req) => Object.entries(req).length > 0)) |
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,2 @@ | ||
export const waitForTxRequest = () => | ||
cy.waitUntil(() => cy.getTxRequests().then((req) => Object.entries(req).length > 0)) |
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
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
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
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,70 @@ | ||
import { | ||
HiOutlineArrowTopRightOnSquare as LaunchIcon, | ||
HiOutlineExclamationCircle as ErrorOutlineIcon | ||
} from 'react-icons/hi2' | ||
|
||
import { styled } from '@mui/material/styles' | ||
import { useAccounts } from '../contexts/AccountsContext' | ||
import { Link } from '../components/library' | ||
import { Center } from '../components/layout/Center' | ||
import { useWatchedAddresses } from '../contexts/WatchedAddressesContext' | ||
import { useMultiProxy } from '../contexts/MultiProxyContext' | ||
|
||
export const useDisplayError = () => { | ||
const { isExtensionError, isAccountLoading } = useAccounts() | ||
const { watchedAddresses } = useWatchedAddresses() | ||
const { error: multisigQueryError } = useMultiProxy() | ||
|
||
if (isExtensionError && watchedAddresses.length === 0 && !isAccountLoading) { | ||
return ( | ||
<CenterStyled> | ||
<h3 data-cy="text-no-account-found"> | ||
No account found. Please connect at least one in a wallet extension. More info at{' '} | ||
<Linkstyled | ||
href="https://wiki.polkadot.network/docs/wallets-and-extensions" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
wiki.polkadot.network | ||
<LaunchIcon | ||
className="launchIcon" | ||
size={20} | ||
/> | ||
</Linkstyled> | ||
</h3> | ||
</CenterStyled> | ||
) | ||
} | ||
|
||
if (multisigQueryError) { | ||
return ( | ||
<CenterStyled> | ||
<ErrorMessageStyled> | ||
<ErrorOutlineIcon size={64} /> | ||
<div>An error occurred.</div> | ||
</ErrorMessageStyled> | ||
</CenterStyled> | ||
) | ||
} | ||
|
||
return null | ||
} | ||
|
||
const Linkstyled = styled(Link)` | ||
display: inline-flex; | ||
padding-left: 0.2rem; | ||
align-items: center; | ||
.launchIcon { | ||
margin-left: 0.5rem; | ||
} | ||
` | ||
|
||
const CenterStyled = styled(Center)` | ||
text-align: center; | ||
` | ||
|
||
const ErrorMessageStyled = styled('div')` | ||
text-align: center; | ||
margin-top: 1rem; | ||
` |
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,62 @@ | ||
import { styled } from '@mui/material/styles' | ||
import { useMultiProxy } from '../contexts/MultiProxyContext' | ||
import { useApi } from '../contexts/ApiContext' | ||
import { Box, CircularProgress } from '@mui/material' | ||
import { useNetwork } from '../contexts/NetworkContext' | ||
import { useAccounts } from '../contexts/AccountsContext' | ||
import { useWatchedAddresses } from '../contexts/WatchedAddressesContext' | ||
|
||
export const useDisplayLoader = () => { | ||
const { isLoading: isLoadingMultisigs } = useMultiProxy() | ||
const { api } = useApi() | ||
const { selectedNetworkInfo } = useNetwork() | ||
const { isAccountLoading, isLocalStorageSetupDone } = useAccounts() | ||
const { isInitialized: isWatchAddressInitialized } = useWatchedAddresses() | ||
|
||
if (!isWatchAddressInitialized || !isLocalStorageSetupDone) { | ||
return ( | ||
<LoaderBoxStyled data-cy="loader-initialization"> | ||
<CircularProgress /> | ||
Initialization... | ||
</LoaderBoxStyled> | ||
) | ||
} | ||
|
||
if (!api) { | ||
return ( | ||
<LoaderBoxStyled data-cy="loader-rpc-connection"> | ||
<CircularProgress /> | ||
{`Connecting to the node at ${selectedNetworkInfo?.rpcUrl}`} | ||
</LoaderBoxStyled> | ||
) | ||
} | ||
|
||
if (isAccountLoading) { | ||
return ( | ||
<LoaderBoxStyled data-cy="loader-accounts-connection"> | ||
<CircularProgress /> | ||
Loading accounts... | ||
</LoaderBoxStyled> | ||
) | ||
} | ||
|
||
if (isLoadingMultisigs) { | ||
return ( | ||
<LoaderBoxStyled data-cy="loader-accounts-connection"> | ||
<CircularProgress /> | ||
<div>Loading your multisigs...</div> | ||
</LoaderBoxStyled> | ||
) | ||
} | ||
|
||
return null | ||
} | ||
|
||
const LoaderBoxStyled = styled(Box)` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
flex-direction: column; | ||
width: 100%; | ||
padding: 1rem; | ||
` |
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
Oops, something went wrong.