-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using connected name or addressBook or signers
- Loading branch information
1 parent
da46201
commit 3ebd849
Showing
17 changed files
with
318 additions
and
225 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
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,32 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
import { useNameAddressBookContext } from "@/context/NameInAddressBookContext"; | ||
import { truncateAddress } from "@/utils/formatString"; | ||
|
||
import { LoadingSkeleton } from "../common/LoadingSkeleton"; | ||
|
||
interface Props { | ||
recipient: string | undefined; | ||
} | ||
export function NameInAddressBook({ recipient }: Props) { | ||
const [nameInAddressBook, setNameInAddressBook] = useState< | ||
string | undefined | null | ||
>(); | ||
const { nameConnectedOrAddressBookOrSigners } = useNameAddressBookContext(); | ||
|
||
useEffect(() => { | ||
const _name = recipient | ||
? nameConnectedOrAddressBookOrSigners(recipient) | ||
: null; | ||
|
||
setNameInAddressBook(_name); | ||
}, [recipient, nameConnectedOrAddressBookOrSigners]); | ||
|
||
if (nameInAddressBook === undefined) { | ||
return <LoadingSkeleton />; | ||
} | ||
|
||
return nameInAddressBook | ||
? `${nameInAddressBook} (${truncateAddress(recipient, 3)})` | ||
: truncateAddress(recipient, 9); | ||
} |
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.