Skip to content

Commit

Permalink
Add a function to truncate address
Browse files Browse the repository at this point in the history
  • Loading branch information
kkosiorowska committed Nov 17, 2023
1 parent 0b6c887 commit 2325e13
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dapp/src/components/Navbar/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
useRequestEthereumAccount,
} from "../../hooks"
import { LedgerLiveAppContext } from "../../contexts/LedgerLiveAppContext"
import { formatSatoshiAmount } from "../../utils"
import { formatSatoshiAmount, truncateAddress } from "../../utils"

export type ConnectButtonsProps = {
leftIcon: string
Expand All @@ -32,7 +32,7 @@ function ConnectButton({
rightIcon={!account ? <Image src={rightIcon} /> : undefined}
onClick={requestAccount}
>
{account ? account.address : "Not connected"}
{account ? truncateAddress(account.address) : "Not connected"}
</Button>
)
}
Expand Down
3 changes: 3 additions & 0 deletions dapp/src/utils/address.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function truncateAddress(address: string): string {
return `${address.slice(0, 6)}${address.slice(-5)}`
}
1 change: 1 addition & 0 deletions dapp/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./numbers"
export * from "./address"

0 comments on commit 2325e13

Please sign in to comment.