Skip to content

Commit efcbdf0

Browse files
authored
Merge pull request #7 from violetprotocol/fix/styling-updates
Styling updates
2 parents baf2cfc + 75b9641 commit efcbdf0

2 files changed

Lines changed: 71 additions & 38 deletions

File tree

erc20-wrapper-registry/frontend/pages/index.tsx

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
useConnectionStatus,
55
useContract,
66
useContractWrite,
7+
useNetwork,
78
useSigner,
89
} from '@thirdweb-dev/react'
910
import styles from '../styles/Home.module.css'
@@ -15,24 +16,32 @@ import { ethers } from 'ethers'
1516
import { CompliantERC20Abi } from '../abis/CompliantERC20'
1617
import { ERC20Abi } from '../abis/ERC20'
1718

19+
const COMPLIANT_FACTORY_ADDRESS = '0x94930faD31Eec31f21d406C5c650cc5925822B45'
20+
const VIOLET_ID_ADDRESS = '0x2a0988b07C538a097Ad8b693369f6e42991591F5'
21+
1822
const Home: NextPage = () => {
1923
const chain = useChain()
2024
const status = useConnectionStatus()
2125
const signer = useSigner()
22-
const compliantFactoryAddress = '0x94930faD31Eec31f21d406C5c650cc5925822B45'
23-
const violetIdAddress = '0x2a0988b07C538a097Ad8b693369f6e42991591F5'
26+
const [, switchNetwork] = useNetwork()
2427
const { contract: compliantFactoryContract, isLoading: isContractLoading } =
25-
useContract(compliantFactoryAddress, CompliantFactoryAbi)
26-
const [isPageLoading, setIsPageLoading] = useState<boolean>(true)
27-
const [isWrongChain, setIsWrongChain] = useState<boolean>()
28+
useContract(COMPLIANT_FACTORY_ADDRESS, CompliantFactoryAbi)
29+
const [isPageLoading, setIsPageLoading] = useState(true)
30+
const [isWrongChain, setIsWrongChain] = useState(false)
2831
const [tokenInput, setTokenInput] = useState<string>()
2932
const [nonCompliantERC20, setNonCompliantERC20] = useState<string>()
3033
const [foundDeployedWrappedErc20, setFoundDeployedWrappedErc20] = useState()
31-
const [erc20NotWrapped, setErc20NotWrapped] = useState<boolean>(false)
32-
const [compliantErc20, setCompliantErc20] = useState<any>()
34+
const [erc20NotWrapped, setErc20NotWrapped] = useState(false)
35+
const [compliantErc20, setCompliantErc20] = useState<{
36+
symbol: string
37+
name: string
38+
}>()
3339
const [erc20InstanceError, setErc20InstanceError] = useState<string>()
34-
const [readyToWrap, setReadyToWrap] = useState<boolean>()
35-
const [erc20ToBeWrapped, setErc20ToBeWrapped] = useState<any>()
40+
const [readyToWrap, setReadyToWrap] = useState(false)
41+
const [erc20ToBeWrapped, setErc20ToBeWrapped] = useState<{
42+
symbol: string
43+
name: string
44+
}>()
3645
const [wrapTransaction, setWrapTransaction] = useState<string>()
3746
const {
3847
mutateAsync,
@@ -47,6 +56,7 @@ const Home: NextPage = () => {
4756
CompliantERC20Abi,
4857
signer,
4958
)
59+
5060
if (compliantErc20) {
5161
compliantErc20.callStatic
5262
.symbol()
@@ -70,6 +80,7 @@ const Home: NextPage = () => {
7080
ERC20Abi,
7181
signer,
7282
)
83+
7384
if (nonCompliantErc20Contract) {
7485
nonCompliantErc20Contract.callStatic
7586
.name()
@@ -97,10 +108,11 @@ const Home: NextPage = () => {
97108
signer
98109
) {
99110
const compliantFactory = new ethers.Contract(
100-
compliantFactoryAddress,
111+
COMPLIANT_FACTORY_ADDRESS,
101112
CompliantFactoryAbi,
102113
signer,
103114
)
115+
104116
if (compliantFactory) {
105117
compliantFactory.callStatic
106118
.erc20ToCompliantWrapped(nonCompliantERC20)
@@ -121,12 +133,6 @@ const Home: NextPage = () => {
121133
}
122134
}, [isContractLoading, isWriteLoading])
123135

124-
useEffect(() => {
125-
if (wrapTransaction) {
126-
setIsPageLoading(false);
127-
}
128-
}, [wrapTransaction])
129-
130136
/**
131137
* Aux hook to make sure user connected in optimismGoerli
132138
* */
@@ -144,15 +150,15 @@ const Home: NextPage = () => {
144150
<div className={styles.header}>
145151
<h1 className={styles.title}>
146152
<span className={styles.gradientText0}>
147-
<a href="https://docs.violet.co">Violet ID {''}</a>
153+
<a href="https://docs.violet.co">VioletID </a>
148154
</span>
149155
Compliant Token Wrapper Demo
150156
</h1>
151157

152158
<p className={styles.description}>
153159
Wrap your ERC20 token and make it compliant with{' '}
154160
<span className={styles.gradientText0}>
155-
<a>Violet ID</a>
161+
<a>VioletID</a>
156162
</span>
157163
</p>
158164

@@ -164,13 +170,18 @@ const Home: NextPage = () => {
164170
}}
165171
/>
166172
</div>
173+
167174
{isWrongChain && status == 'connected' ? (
168175
<p className={styles.description}>
169-
Unsupported network, please connect to optimism goerli
176+
Unsupported network, please{' '}
177+
<span
178+
className={styles.switchNetwork}
179+
onClick={() => switchNetwork?.(420)}
180+
>
181+
connect to Optimism Goerli (420)
182+
</span>
170183
</p>
171-
) : (
172-
<div></div>
173-
)}
184+
) : null}
174185

175186
{isPageLoading ? (
176187
<div>
@@ -184,8 +195,10 @@ const Home: NextPage = () => {
184195
/>
185196
</div>
186197
</div>
187-
) : (
188-
<div>
198+
) : null}
199+
200+
{!isPageLoading ? (
201+
<>
189202
{wrapTransaction ? (
190203
<div>
191204
<p className={styles.description}>
@@ -211,7 +224,6 @@ const Home: NextPage = () => {
211224
!nonCompliantERC20 ? (
212225
<div>
213226
<div>
214-
{' '}
215227
<p className={styles.description}>
216228
Enter the address of an ERC20 token to wrap it
217229
</p>
@@ -236,32 +248,38 @@ const Home: NextPage = () => {
236248
</div>
237249
) : (
238250
<div>
239-
{erc20NotWrapped && readyToWrap ? (
251+
{erc20NotWrapped && readyToWrap && erc20ToBeWrapped ? (
240252
<div>
241253
<div className={styles.connect}>
242254
<a className={styles.gradientText3}>
243255
Symbol: {erc20ToBeWrapped.symbol}{' '}
244256
</a>
245257
</div>
258+
246259
<div className={styles.connect}>
247260
<a className={styles.gradientText3}>
248261
Name: {erc20ToBeWrapped.name}{' '}
249262
</a>
250263
</div>
264+
251265
<button
252266
className={styles.buttonRound}
253267
onClick={async () => {
254268
setIsPageLoading(true)
255269
mutateAsync({
256-
args: [nonCompliantERC20, violetIdAddress],
257-
}).then((sentTransaction) => {
258-
setWrapTransaction(
259-
sentTransaction.receipt.transactionHash,
260-
)
261-
console.log(
262-
sentTransaction.receipt.transactionHash,
263-
)
270+
args: [nonCompliantERC20, VIOLET_ID_ADDRESS],
264271
})
272+
.then((sentTransaction) => {
273+
setWrapTransaction(
274+
sentTransaction.receipt.transactionHash,
275+
)
276+
console.log(
277+
sentTransaction.receipt.transactionHash,
278+
)
279+
})
280+
.finally(() => {
281+
setIsPageLoading(false)
282+
})
265283
}}
266284
>
267285
<a className={styles.gradientText0}>Wrap</a>
@@ -280,6 +298,7 @@ const Home: NextPage = () => {
280298
)}
281299
</div>
282300
)}
301+
283302
{compliantErc20 ? (
284303
<div>
285304
<div className={styles.connect}>
@@ -316,8 +335,8 @@ const Home: NextPage = () => {
316335
)}
317336
</div>
318337
)}
319-
</div>
320-
)}
338+
</>
339+
) : null}
321340
</div>
322341
</div>
323342
</main>

erc20-wrapper-registry/frontend/styles/Home.module.css

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
.container {
2-
width: 100%;
3-
max-width: 1440px;
42
padding: 0 1rem;
53
text-align: center;
4+
display: flex;
5+
align-items: center;
6+
justify-content: center;
7+
height: 100dvh;
8+
max-width: 1440px;
69
margin: 0 auto;
710
}
811

@@ -39,6 +42,7 @@
3942
.title a:active {
4043
text-decoration: underline;
4144
text-decoration-color: #84309c;
45+
transition: all 0.2s ease;
4246
}
4347

4448
.title {
@@ -189,6 +193,16 @@
189193
margin-left: 0.5rem;
190194
}
191195

196+
.switchNetwork {
197+
cursor: pointer;
198+
}
199+
.switchNetwork:hover {
200+
text-decoration: underline;
201+
text-decoration-color: #84309c;
202+
color: #84309c;
203+
transition: all 0.2s ease;
204+
}
205+
192206
@media (max-width: 768px) {
193207
.header {
194208
text-align: center;

0 commit comments

Comments
 (0)