8000 Switch StakingRequestProvider to Redux by eric-zero-dev · Pull Request #407 · zer0-os/zNS-dapp · GitHub
[go: up one dir, main page]

Skip to content
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
9 changes: 3 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import backgroundImage from 'assets/background.jpg';
//- Page Imports
import { ZNS, Staking } from 'pages';
import PageContainer from 'containers/PageContainer';
import StakingRequestProvider from 'lib/providers/StakingRequestProvider';
import { ZNSDomainsProvider } from 'lib/providers/ZNSDomainProvider';

// Web3 library to query
Expand Down Expand Up @@ -98,11 +97,9 @@ function wrappedApp() {
{/* Our Hooks */}
<MvpVersionProvider>
<ZNSDomainsProvider>
<StakingRequestProvider>
<EnlistProvider>
<App />
</EnlistProvider>
</StakingRequestProvider>
<EnlistProvider>
<App />
</EnlistProvider>
</ZNSDomainsProvider>
</MvpVersionProvider>
</Web3ReactProvider>
Expand Down
17 changes: 5 additions & 12 deletions src/components/MintPreview/MintPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useMint from 'lib/hooks/useMint';
import styles from './MintPreview.module.scss';
import { Maybe, NftStatusCard } from 'lib/types';
import { zNAToLink } from 'lib/utils';
import { useStakingProvider } from 'lib/providers/StakingRequestProvider';
import { useStaking } from 'lib/hooks/useStaking';
import { chainIdToNetworkType, getEtherscanUri } from 'lib/network';
import { useWeb3React } from '@web3-react/core';
import { Web3Provider } from '@ethersproject/providers';
Expand All @@ -29,7 +29,7 @@ const MintPreview = (props: MintPreviewProps) => {
const baseEtherscanUri = getEtherscanUri(networkType);

const { minting, minted } = useMint();
const stakingProvider = useStakingProvider();
const { requesting, requested } = useStaking();

const statusCard = (
nft: NftStatusCard,
Expand Down Expand Up @@ -139,19 +139,12 @@ const MintPreview = (props: MintPreviewProps) => {
}

let requestSection: Maybe<React.ReactFragment>;
if (
stakingProvider.requesting.length > 0 ||
stakingProvider.requested.length > 0
) {
if (requesting.length > 0 || requested.length > 0) {
requestSection = (
<>
<h4 className="glow-text-white">Requests</h4>
{stakingProvider.requesting.map((n: NftStatusCard) =>
requestingStatusCard(n, false),
)}
{stakingProvider.requested.map((n: NftStatusCard) =>
requestingStatusCard(n, true),
)}
{requesting.map((n: NftStatusCard) => requestingStatusCard(n, false))}
{requested.map((n: NftStatusCard) => requestingStatusCard(n, true))}
</>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Tables/RequestTable/RequestTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
8000 useRequestsForOwnedDomains,
} from 'lib/hooks/useDomainRequestsSubgraph';
import { ethers } from 'ethers';
import { useStakingProvider } from 'lib/providers/StakingRequestProvider';
import { useStaking } from 'lib/hooks/useStaking';

//- Type Imports
import { DomainRequestAndContents } from 'lib/types';
Expand Down Expand Up @@ -55,7 +55,7 @@ const RequestTable: React.FC<RequestTableProps> = ({
// Custom Hooks //
//////////////////
const { account } = useWeb3React();
const staking = useStakingProvider();
const staking = useStaking();
const znsContracts = useZnsContracts()!;
const yourRequests = useRequestsMadeByAccount(userId);
const requestsForYou = useRequestsForOwnedDomains(userId);
Expand Down
6 changes: 3 additions & 3 deletions src/containers/PageContainer/elements/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import classnames from 'classnames';
import { useStakingProvider } from 'lib/providers/StakingRequestProvider';
import useMint from 'lib/hooks/useMint';
import { useStaking } from 'lib/hooks/useStaking';
import { useMint } from 'lib/hooks/useMint';
import { useTransfer } from 'lib/hooks/useTransfer';
import { useNavbar } from 'lib/hooks/useNavbar';
import useMvpVersion from 'lib/hooks/useMvpVersion';
Expand Down Expand Up @@ -41,7 +41,7 @@ export const Header: React.FC<HeaderProps> = ({
const { mvpVersion } = useMvpVersion();

const { requesting: stakeRequesting, requested: stakeRequested } =
useStakingProvider();
useStaking();

const { minting, minted } = useMint();
const { transferring } = useTransfer();
Expand Down
4 changes: 2 additions & 2 deletions src/containers/PageContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { ProfileModal } from 'containers';

//- Library Imports
import { MintNewNFT } from 'containers';
import { useStakingProvider } from 'lib/providers/StakingRequestProvider';
import { useStaking } from 'lib/hooks/useStaking';
import { useCurrentDomain } from 'lib/providers/CurrentDomainProvider';

//- Constants Imports
Expand Down Expand Up @@ -86,7 +86,7 @@ const PageContainer: FC = ({ children }) => {

//- Minting State
const { minted } = useMint();
const { fulfilled: stakingFulFilled } = useStakingProvider();
const { fulfilled: stakingFulFilled } = useStaking();

//- Notification State
const { addNotification } = useNotification();
Expand Down
4 changes: 2 additions & 2 deletions src/containers/flows/MintNewNFT/MintNewNFT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { Web3Provider } from '@ethersproject/providers';
import { ethers } from 'ethers';

//- Providers
import { useStakingProvider } from 'lib/providers/StakingRequestProvider';
import { useZnsContracts } from 'lib/contracts';
import { useStaking } from 'lib/hooks/useStaking';
import useMint from 'lib/hooks/useMint';

//- Type Imports
Expand Down Expand Up @@ -65,7 +65,7 @@ const MintNewNFT: React.FC<MintNewNFTProps> = ({

// Mint/Staking Hooks
const { mint } = useMint();
const staking = useStakingProvider();
const staking = useStaking();

// @todo refactor into useEffect so we don't have to calculate each render
let isOwner = account && account.toLowerCase() === domainOwner.toLowerCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const RaffleRegistration = (props: RaffleRegistrationProps) => {
setStatus(status);
};

const () => { };
const () => {};

const aboutRaffle = () => {
return (
Expand Down Expand Up @@ -226,9 +226,9 @@ const RaffleRegistration = (props: RaffleRegistrationProps) => {
if (!hasSufficientBalance[key]) {
messages.push(
validationCriteria[key] +
' ' +
key.toUpperCase() +
(key === 'nft' && validationCriteria[key] > 1 ? 's' : ''),
' ' +
key.toUpperCase() +
(key === 'nft' && validationCriteria[key] > 1 ? 's' : ''),
);
}
}
Expand All @@ -248,8 +248,9 @@ const RaffleRegistration = (props: RaffleRegistrationProps) => {
<div className={styles.eachBalances}>
<div>WILD</div>
<div
className={`${!hasSufficientBalance.wild ? styles.ErrorColor : ''
} ${styles.amount}`}
className={`${
!hasSufficientBalance.wild ? styles.ErrorColor : ''
} ${styles.amount}`}
>
{formatByDecimalPlace(balances?.wildBalance || 0, 2)}
</div>
Expand All @@ -262,8 +263,9 @@ const RaffleRegistration = (props: RaffleRegistrationProps) => {
<div className={styles.eachBalances}>
<div> ETH</div>
<div
className={`${!hasSufficientBalance.eth ? styles.ErrorColor : ''
} ${styles.amount}`}
className={`${
!hasSufficientBalance.eth ? styles.ErrorColor : ''
} ${styles.amount}`}
>
{formatByDecimalPlace(balances?.ethBalance || 0, 2)}
</div>
Expand All @@ -277,8 +279,9 @@ const RaffleRegistration = (props: RaffleRegistrationProps) => {
<div className={styles.eachBalances}>
<div>Wilder NFT</div>
<div
className={`${!hasSufficientBalance.nft ? styles.ErrorColor : ''
} ${styles.amount}`}
className={`${
!hasSufficientBalance.nft ? styles.ErrorColor : ''
} ${styles.amount}`}
>
{balances?.nftsCount || 0}
</div>
Expand All @@ -287,8 +290,8 @@ const RaffleRegistration = (props: RaffleRegistrationProps) => {
</div>

{hasSufficientBalance.eth &&
hasSufficientBalance.wild &&
hasSufficientBalance.nft ? (
hasSufficientBalance.wild &&
hasSufficientBalance.nft ? (
<p className={styles.Success}>
Your balances meet the requirements for entry!
</p>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/hooks/useMint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const useMintRedux = () => {
return { reduxState, reduxActions };
};

const useMint = (): UseMintReturn => {
export const useMint = (): UseMintReturn => {
////////////////////////
// Hooks From Out //
////////////////////////
Expand Down
Loading
0