-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
1,288 additions
and
673 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { isMainnet, toHexChainid } from "@/helpers/chainId" | ||
import { formatTruncatedAddress } from "@/helpers/formatAddress" | ||
import { useAccount, useBalance } from "@starknet-react/core" | ||
import { AvatarIcon } from "./icons/AvatarIcon" | ||
import { LogoIcon } from "./icons/LogoIcon" | ||
import { WalletIcon } from "./icons/WalletIcon" | ||
|
||
const Header = () => { | ||
const { address, isConnected, chainId } = useAccount() | ||
|
||
const { data: balance } = useBalance({ | ||
address: address, | ||
}) | ||
|
||
const hexChainId = toHexChainid(chainId) | ||
|
||
return ( | ||
<div className="flex header-container"> | ||
<div className="flex header-logo-container"> | ||
<LogoIcon /> | ||
<h1 className="header-title">Demo dapp</h1> | ||
<div className="flex full-flex" /> | ||
|
||
{isConnected && ( | ||
<div className="flex header-profile-container"> | ||
<div className="flex header-balance"> | ||
<WalletIcon /> | ||
{balance && balance?.formatted.length > 7 | ||
? `${balance.formatted.slice(0, 7)} ETH` | ||
: `${balance?.formatted} ETH`} | ||
</div> | ||
<div className="header-account-separator" /> | ||
<div | ||
className="flex header-address" | ||
onClick={() => | ||
window.open( | ||
isMainnet(hexChainId) | ||
? `https://voyager.online/contract/${address}` | ||
: `https://sepolia.voyager.online/contract/${address}`, | ||
"_blank", | ||
) | ||
} | ||
> | ||
<AvatarIcon /> | ||
{formatTruncatedAddress(address || "")} | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export { Header } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,81 @@ | ||
"use client" | ||
import { SignMessage } from "@/components/sections/SignMessage" | ||
import { Transactions } from "@/components/sections/Transactions/Transactions" | ||
import { useAccount } from "@starknet-react/core" | ||
import { useState } from "react" | ||
import { Connect } from "./connect/Connect" | ||
import { Flex } from "./ui/Flex" | ||
import { Header } from "./Header" | ||
import { AccountStatus } from "./sections/AccountStatus" | ||
import { AddToken } from "./sections/ERC20/AddToken" | ||
import { Network } from "./sections/Network/Network" | ||
import { SectionButton } from "./sections/SectionButton" | ||
import { Section } from "./sections/types" | ||
|
||
const StarknetDapp = () => ( | ||
<Flex | ||
flexDirection="column" | ||
maxWidth="500px" | ||
width="100%" | ||
margin="0 auto" | ||
gap="24px" | ||
> | ||
<AccountStatus /> | ||
<Connect /> | ||
<Transactions /> | ||
<SignMessage /> | ||
<Network /> | ||
<AddToken /> | ||
</Flex> | ||
) | ||
const StarknetDapp = () => { | ||
const [section, setSection] = useState<Section | undefined>(undefined) | ||
const { isConnected } = useAccount() | ||
|
||
return ( | ||
<div className="flex full column"> | ||
<Header /> | ||
|
||
<div className="flex get-started-container"> | ||
<div className="flex column"> | ||
<h1 className="get-started-title">your</h1> | ||
<span className="get-started-subtitle"> | ||
Starknet utilizes the power of STARK technology to ensure | ||
computational integrity. | ||
</span> | ||
</div> | ||
|
||
<div className="status-grid-container"> | ||
<AccountStatus /> | ||
</div> | ||
</div> | ||
|
||
<div className="flex sections-container"> | ||
<div className="flex full column sections-list"> | ||
<SectionButton | ||
section="Connection" | ||
setSection={setSection} | ||
selected={section === "Connection"} | ||
/> | ||
<SectionButton | ||
section="Transactions" | ||
setSection={setSection} | ||
selected={section === "Transactions"} | ||
disabled={!isConnected} | ||
/> | ||
<SectionButton | ||
section="Signing" | ||
setSection={setSection} | ||
selected={section === "Signing"} | ||
disabled={!isConnected} | ||
/> | ||
<SectionButton | ||
section="Network" | ||
setSection={setSection} | ||
selected={section === "Network"} | ||
disabled={!isConnected} | ||
/> | ||
<SectionButton | ||
section="ERC20" | ||
setSection={setSection} | ||
selected={section === "ERC20"} | ||
disabled={!isConnected} | ||
/> | ||
</div> | ||
|
||
<div className="flex full-flex"> | ||
{section === "Connection" && <Connect />} | ||
{section === "Transactions" && <Transactions />} | ||
{section === "Signing" && <SignMessage />} | ||
{section === "Network" && <Network />} | ||
{section === "ERC20" && <AddToken />} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export { StarknetDapp } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.