Skip to content
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Commit 54bca16

Browse files
BrianBrian
authored andcommitted
Added static strings to constants file and translations file.
Code cleanup
1 parent 1617802 commit 54bca16

File tree

4 files changed

+38
-30
lines changed

4 files changed

+38
-30
lines changed

frontend/_tests_/pages/mint.test.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@ describe('Positive Interactions', () => {
4646
name: /connectWalletText/,
4747
});
4848

49+
const disconnectWalletButton = screen.getByRole('button', {
50+
name: /disconnectWallet/,
51+
});
52+
4953
// - [Button] - Connect Wallet
5054
expect(connectWalletButton).toBeInTheDocument();
55+
expect(disconnectWalletButton).toBeInTheDocument();
5156
});
5257
});
5358

frontend/public/locales/en/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@
4242
"transactionSending": "Transaction Being Sent",
4343
"here": "here",
4444
"errorMinting": "Unable to Mint NFT",
45-
"disconnectWallet": "Disconnect Wallet"
45+
"disconnectWallet": "Disconnect Wallet",
46+
"etherscanMessage": "View your TX on Etherscan"
4647
}

frontend/src/components/DirectMint/DirectMint.tsx

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
DEVELOPER_DAO_CONTRACT,
3131
ERROR_CODE_TX_REJECTED_BY_USER,
3232
MAINNET_NETWORK_ID,
33+
ETHERSCAN_TX_URL,
3334
} from '../../utils/DeveloperDaoConstants';
3435

3536
import MINT_CONTRACT from '../../artifacts/ddao.json';
@@ -125,6 +126,8 @@ const DirectMint = ({ developerId }: DirectMintProps) => {
125126
_provider.on('disconnect', (error: { code: number; message: string }) => {
126127
web3Modal?.clearCachedProvider();
127128
setUserWallet('');
129+
setTxInProgress(false);
130+
setTxReceipt('');
128131
});
129132

130133
await fetchAccountData();
@@ -133,6 +136,8 @@ const DirectMint = ({ developerId }: DirectMintProps) => {
133136
const disconnectWallet = async () => {
134137
await web3Modal?.clearCachedProvider();
135138
setUserWallet('');
139+
setTxInProgress(false);
140+
setTxReceipt('');
136141
};
137142

138143
const tokenNameHandler: ChangeEventHandler<HTMLInputElement> = (event) => {
@@ -218,26 +223,29 @@ const DirectMint = ({ developerId }: DirectMintProps) => {
218223
{t('mintTokenText')}
219224
</Button>
220225

221-
{userWallet && (
222-
<Button
223-
w="100%"
224-
colorScheme="orange"
225-
onClick={disconnectWallet}
226-
mt="10"
227-
fontSize={{ base: 's', sm: 'xl' }}
228-
>
229-
{t('disconnectWallet')}
230-
</Button>
231-
)}
226+
<Button
227+
w="100%"
228+
colorScheme="orange"
229+
onClick={disconnectWallet}
230+
mt="10"
231+
fontSize={{ base: 's', sm: 'xl' }}
232+
>
233+
{t('disconnectWallet')}
234+
</Button>
232235
</>
233236
)}
234237

235238
{txInProgress && (
236-
<Modal isOpen={isOpen} onClose={modalCloseHandler} isCentered>
239+
<Modal
240+
isOpen={isOpen}
241+
onClose={modalCloseHandler}
242+
closeOnOverlayClick={false}
243+
isCentered
244+
>
237245
<ModalOverlay />
238246
<ModalContent>
239-
<ModalHeader>Minting your NFT...</ModalHeader>
240-
<ModalCloseButton />
247+
<ModalHeader>Processing transaction...</ModalHeader>
248+
{txReceipt && <ModalCloseButton />}
241249
<ModalBody>
242250
<Center h="160px">
243251
{!txReceipt && (
@@ -248,21 +256,14 @@ const DirectMint = ({ developerId }: DirectMintProps) => {
248256
/>
249257
)}
250258
{txReceipt && (
251-
<>
252-
<Stack spacing={6}>
253-
<Text color="green.500" fontSize="lg">
254-
Your NFT has been minted!
255-
</Text>
256-
<Link
257-
fontSize="lg"
258-
color="#3182ce"
259-
href={`https://rinkeby.etherscan.io/tx/${txReceipt}`}
260-
isExternal
261-
>
262-
View your TX on Etherscan <ExternalLinkIcon mx="2px" />
263-
</Link>
264-
</Stack>
265-
</>
259+
<Link
260+
fontSize="lg"
261+
color="#3182ce"
262+
href={`${ETHERSCAN_TX_URL}${txReceipt}`}
263+
isExternal
264+
>
265+
{t('etherscanMessage')} <ExternalLinkIcon mx="2px" />
266+
</Link>
266267
)}
267268
</Center>
268269
</ModalBody>

frontend/src/utils/DeveloperDaoConstants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const SITE_URL = 'https://developerdao.com';
77
export const ERROR_CODE_TX_REJECTED_BY_USER = 4001;
88
export const MAINNET_NETWORK_ID = 1;
99
export const TOKEN_FINDER_URL = 'http://ddao.ibby.dev';
10+
export const ETHERSCAN_TX_URL = 'https://rinkeby.etherscan.io/tx/';
1011

1112
export const DEVELOPER_DAO_CONTRACT_ABI = [
1213
{ inputs: [], stateMutability: 'nonpayable', type: 'constructor' },

0 commit comments

Comments
 (0)