-
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
1 parent
bb6124d
commit 788b92b
Showing
13 changed files
with
109 additions
and
6 deletions.
There are no files selected for viewing
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 @@ | ||
VITE_USE_TESTNET=true |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,33 @@ | ||
import React from "react" | ||
import { Box, Button, Image, Text } from "@chakra-ui/react" | ||
import { useRequestAccount } from "@ledgerhq/wallet-api-client-react" | ||
import BitcoinIcon from "../../assets/bitcoin.svg" | ||
import InfoIcon from "../../assets/info.svg" | ||
import { truncateAddress } from "../../utils" | ||
import { BITCOIN, CURRENCY_ID_BITCOIN } from "../../constants" | ||
|
||
export default function AccountInfo() { | ||
const { account, requestAccount } = useRequestAccount() | ||
|
||
const requestBitcoinAccount = async () => { | ||
await requestAccount({ currencyIds: [CURRENCY_ID_BITCOIN] }) | ||
} | ||
|
||
return ( | ||
<Box display="flex" alignItems="center" gap="4"> | ||
<Box display="flex" gap="2"> | ||
<Text>Balance</Text> | ||
<Text as="b">{!account ? "0.00" : account.balance.toString()}</Text> | ||
<Text>{BITCOIN.token}</Text> | ||
</Box> | ||
<Button | ||
variant="outline" | ||
leftIcon={<Image src={BitcoinIcon} />} | ||
rightIcon={!account ? <Image src={InfoIcon} /> : undefined} | ||
onClick={requestBitcoinAccount} | ||
> | ||
{account ? truncateAddress(account.address) : "Not connected"} | ||
</Button> | ||
</Box> | ||
) | ||
} |
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,11 @@ | ||
import React from "react" | ||
import { Box } from "@chakra-ui/react" | ||
import AccountInfo from "./AccountInfo" | ||
|
||
export default function Navbar() { | ||
return ( | ||
<Box p={4} display="flex" justifyContent="end"> | ||
<AccountInfo /> | ||
</Box> | ||
) | ||
} |
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,7 @@ | ||
export const BITCOIN = { | ||
name: "Bitcoin", | ||
token: "BTC", | ||
} | ||
|
||
export const CURRENCY_ID_BITCOIN = | ||
import.meta.env.VITE_USE_TESTNET === "true" ? "bitcoin_testnet" : "bitcoin" |
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 +1,2 @@ | ||
export * from "./local-storage" | ||
export * from "./chains" |
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 |
---|---|---|
|
@@ -5,4 +5,6 @@ export const colors = { | |
white: "#FFF", | ||
black: "#000", | ||
purple: "#7D00FF", | ||
grey: "#ECECEC", | ||
darkGrey: "#37393C", | ||
} |
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,4 @@ | ||
// eslint-disable-next-line import/prefer-default-export | ||
export function truncateAddress(address: string): string { | ||
return `${address.slice(0, 6)}…${address.slice(-5)}` | ||
} |