Skip to content

Commit 483bca8

Browse files
committed
🔀Merge branch '942-feature-algodex-launchpad-for-creating-and-listing-asas' of https://github.com/algodex/algodex-react into 985-modify-the-choose-asset-input-field-on-token-sale-page
2 parents 9b9dcf6 + 98b8b1f commit 483bca8

File tree

6 files changed

+309
-68
lines changed

6 files changed

+309
-68
lines changed

components/LaunchPad/CreatorAddress.tsx

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,26 @@ import React from 'react'
33
//MUI Components
44
import Typography from '@mui/material/Typography'
55
import Box from '@mui/material/Box'
6+
import Button from '@mui/material/Button'
67

78
// Custom coponent
89
import { CopyIcon } from './copyIcon'
910
import { truncatedWalletAddress } from 'components/helpers'
11+
import { styles } from './styles.css'
12+
import useWallets from '@/hooks/useWallets'
1013

1114
type creatorAddressTypes = {
12-
address?: string
15+
activeWallet?: any
1316
}
1417

15-
export const CreatorAddress = ({ address }: creatorAddressTypes) => {
16-
const isConnected = typeof address !== 'undefined'
18+
export const CreatorAddress = ({ activeWallet }: creatorAddressTypes) => {
19+
const { peraDisconnect, myAlgoDisconnect } = useWallets(null)
20+
const walletDisconnectMap = {
21+
'my-algo-wallet': myAlgoDisconnect,
22+
'wallet-connect': peraDisconnect
23+
}
24+
25+
const isConnected = typeof activeWallet !== 'undefined'
1726
return (
1827
<>
1928
<Box
@@ -38,9 +47,9 @@ export const CreatorAddress = ({ address }: creatorAddressTypes) => {
3847
fontWeight: 500
3948
}}
4049
>
41-
{truncatedWalletAddress(address, 4)}
50+
{truncatedWalletAddress(activeWallet.address, 4)}
4251
</Typography>
43-
<CopyIcon content={address} />
52+
<CopyIcon content={activeWallet.address} />
4453
</>
4554
) : (
4655
<Typography
@@ -55,6 +64,29 @@ export const CreatorAddress = ({ address }: creatorAddressTypes) => {
5564
</Typography>
5665
)}
5766
</Box>
67+
{isConnected && (
68+
<Button
69+
type="button"
70+
onClick={() => {
71+
walletDisconnectMap[activeWallet.type](activeWallet)
72+
}}
73+
sx={{
74+
color: 'white',
75+
backgroundColor: 'gray.150',
76+
px: '10px',
77+
py: '1px',
78+
fontWeight: 500,
79+
fontSize: '12px',
80+
border: '2px solid',
81+
transition: 'all ease .3s',
82+
'&:hover': {
83+
color: 'white'
84+
}
85+
}}
86+
>
87+
DISCONNECT
88+
</Button>
89+
)}
5890
</>
5991
)
6092
}

components/LaunchPad/Sale/CreateTokenSale.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const CreateTokenSale = () => {
150150
<Typography variant="body1" sx={{ fontWeight: 600, color: 'white', lineHeight: 1.2 }}>
151151
Creator/Reserve Address:
152152
</Typography>
153-
<CreatorAddress address={activeWallet?.address} />
153+
<CreatorAddress activeWallet={activeWallet ? activeWallet : undefined} />
154154
</Box>
155155
<Typography variant="body1" sx={{ ...styles.body1, marginBottom: '24px' }}>
156156
A sale must be started from either the Creator or the Reserve wallet of the ASA. Ensure the

components/LaunchPad/Sale/ManageTokenSale.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const initialValues = {
3636
pricePerToken: 0.75,
3737
showPricePerToken: false,
3838
totalForSale: 14600,
39-
showTotalForSale: false,
39+
showTotalForSale: false
4040
}
4141

4242
export const ManageTokenSale = () => {
@@ -78,7 +78,7 @@ export const ManageTokenSale = () => {
7878
<Typography variant="body1" sx={{ fontWeight: 600, color: 'white', lineHeight: 1.2 }}>
7979
Creator Address:
8080
</Typography>
81-
<CreatorAddress address={activeWallet?.address} />
81+
<CreatorAddress activeWallet={activeWallet ? activeWallet : undefined} />
8282
</Box>
8383
<Typography variant="body1" sx={{ ...styles.body1, marginBottom: '30px' }}>
8484
You can only manage sales that have been created with the connected wallet. If you do not

components/LaunchPad/Token/CreateToken.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import CircularProgress from '@mui/material/CircularProgress'
3838
import OutlinedInput from '@/components/Input/OutlinedInput'
3939
import { styles } from '../styles.css'
4040
import { ErrorMessage } from '../ErrorMessage'
41-
import { algodClient } from '@/components/helpers'
41+
import { isValidAddr } from '@/components/helpers'
4242
import { NumberFormatCustom } from '@/components/Wallet/PlaceOrder/Form/TradeInputs'
4343
import { Tip } from '../Tip'
4444

@@ -135,16 +135,6 @@ export const CreateToken = () => {
135135
return pattern.test(url)
136136
}
137137

138-
const isValidAddr = async (addr: string) => {
139-
//Check your if account exist on Algorand
140-
try {
141-
await algodClient().accountInformation(addr).do()
142-
return true
143-
} catch (error) {
144-
return false
145-
}
146-
}
147-
148138
const onSubmit = async (e: ChangeEvent<HTMLFormElement>) => {
149139
e.preventDefault()
150140
let _error = false
@@ -269,7 +259,7 @@ export const CreateToken = () => {
269259
<Typography variant="body1" sx={{ fontWeight: 600, color: 'white', lineHeight: 1.2 }}>
270260
Creator Address:
271261
</Typography>
272-
<CreatorAddress address={activeWallet?.address} />
262+
<CreatorAddress activeWallet={activeWallet ? activeWallet : undefined} />
273263
</Box>
274264
<Typography variant="body1" sx={{ ...styles.body1, marginBottom: '24px' }}>
275265
Creator Address defaults to the wallet that’s currently connected. If you want to create an

0 commit comments

Comments
 (0)