Skip to content

Commit 7e7e54c

Browse files
committed
feat: show private key in home
1 parent 949412a commit 7e7e54c

File tree

1 file changed

+62
-31
lines changed

1 file changed

+62
-31
lines changed

src/pages/Home/index.tsx

Lines changed: 62 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const Home = () => {
1818
const [isConnectionLoading, setIsConnectionLoading] = useState<boolean>(false)
1919
const [isMenuVisible, setIsMenuVisible] = useState<boolean>(false)
2020
const [isWalletCopied, setIsWalletCopied] = useState<boolean>(false);
21+
const [isPrivateKeyCopied, setIsPrivateKeyCopied] = useState<boolean>(false);
2122

2223
const navigate = useNavigate();
2324

@@ -192,47 +193,47 @@ const Home = () => {
192193

193194
{
194195
power
195-
? isRandom
196-
? (
197-
<div className="auto-rs-power">
196+
? isRandom
197+
? (
198+
<div className="auto-rs-power">
199+
<div>
200+
<p>Auto Select</p>
201+
<p>{allRegions[sRegion].country}</p>
202+
</div>
203+
<img src="/assets/auto.png" width={48} height={48} alt="" />
204+
</div>
205+
) : (
198206
<div>
199-
<p>Auto Select</p>
200-
<p>{allRegions[sRegion].country}</p>
207+
<ReactCountryFlag
208+
countryCode={allRegions[sRegion].code}
209+
svg
210+
aria-label="United States"
211+
style={{
212+
fontSize: "2em",
213+
lineHeight: "2em",
214+
marginRight: ".5em",
215+
}}
216+
/>
217+
{allRegions[sRegion].country}
201218
</div>
202-
<img src="/assets/auto.png" width={48} height={48} alt="" />
203-
</div>
204-
) : (
205-
<div>
206-
<ReactCountryFlag
207-
countryCode={allRegions[sRegion].code}
208-
svg
209-
aria-label="United States"
210-
style={{
211-
fontSize: "2em",
212-
lineHeight: "2em",
213-
marginRight: ".5em",
214-
}}
215-
/>
216-
{allRegions[sRegion].country}
217-
</div>
219+
)
220+
: (
221+
<button className="region-btn" onClick={() => navigate("/regions")}>
222+
<div>
223+
<img src="/assets/global.png" width={22} height={22} alt="" />
224+
<p>Select Region</p>
225+
</div>
226+
<img src="/assets/right.png" width={4} height={8} alt="" />
227+
</button>
218228
)
219-
: (
220-
<button className="region-btn" onClick={() => navigate("/regions")}>
221-
<div>
222-
<img src="/assets/global.png" width={22} height={22} alt="" />
223-
<p>Select Region</p>
224-
</div>
225-
<img src="/assets/right.png" width={4} height={8} alt="" />
226-
</button>
227-
)
228229
}
229230
</div>
230231
</div>
231232
)
232233
}
233234

234235
const copyWallet = () => {
235-
navigator.clipboard.writeText("S");
236+
navigator.clipboard.writeText(profile.keyID);
236237

237238
setIsWalletCopied(true);
238239

@@ -241,6 +242,16 @@ const Home = () => {
241242
}, 2000);
242243
}
243244

245+
const copyPrivateKey = () => {
246+
navigator.clipboard.writeText(profile.privateKeyArmor);
247+
248+
setIsPrivateKeyCopied(true);
249+
250+
setTimeout(() => {
251+
setIsPrivateKeyCopied(false);
252+
}, 2000);
253+
}
254+
244255
return (
245256
<>
246257
<div className="header">
@@ -297,6 +308,26 @@ const Home = () => {
297308
)
298309
}
299310
</div>
311+
312+
<div className="current-wallet">
313+
<p>Private Key</p>
314+
{
315+
profile?.privateKeyArmor ? (
316+
<button onClick={copyPrivateKey}>
317+
<p>{profile?.privateKeyArmor.slice(0, 4)}...{profile?.privateKeyArmor.slice(-4)}</p>
318+
{
319+
isPrivateKeyCopied ? (
320+
<img src="/assets/check.svg" alt="Copy icon" />
321+
) : (
322+
<img src="/assets/copy.svg" alt="Copy icon" />
323+
)
324+
}
325+
</button>
326+
) : (
327+
<Skeleton width="100px" height="24px" />
328+
)
329+
}
330+
</div>
300331
</>
301332
)}
302333
</div >

0 commit comments

Comments
 (0)