File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
components/engine/permissions Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 8
8
} from "@/components/ui/hover-card" ;
9
9
import { Check , Copy , ExternalLinkIcon } from "lucide-react" ;
10
10
import { useMemo , useState } from "react" ;
11
+ import { isAddress } from "thirdweb" ;
11
12
import { ZERO_ADDRESS } from "thirdweb" ;
12
13
import {
13
14
Blobbie ,
@@ -28,6 +29,7 @@ export function WalletAddress(props: {
28
29
} ) {
29
30
// default back to zero address if no address provided
30
31
const address = useMemo ( ( ) => props . address || ZERO_ADDRESS , [ props . address ] ) ;
32
+
31
33
const [ shortenedAddress , lessShortenedAddress ] = useMemo ( ( ) => {
32
34
return [
33
35
props . shortenAddress !== false
@@ -44,6 +46,10 @@ export function WalletAddress(props: {
44
46
45
47
const [ isCopied , setIsCopied ] = useState ( false ) ;
46
48
49
+ if ( ! isAddress ( address ) ) {
50
+ return < span > Invalid Address ({ address } )</ span > ;
51
+ }
52
+
47
53
const copyToClipboard = async ( ) => {
48
54
try {
49
55
await navigator . clipboard . writeText ( address ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import { useTrack } from "hooks/analytics/useTrack";
21
21
import { useTxNotifications } from "hooks/useTxNotifications" ;
22
22
import { useForm } from "react-hook-form" ;
23
23
import { AiOutlinePlusCircle } from "react-icons/ai" ;
24
+ import { isAddress } from "thirdweb" ;
24
25
import { Button , FormLabel } from "tw-components" ;
25
26
26
27
interface AddAdminButtonProps {
@@ -62,6 +63,9 @@ export const AddAdminButton: React.FC<AddAdminButtonProps> = ({
62
63
className = "!bg-background border border-border rounded-lg"
63
64
as = "form"
64
65
onSubmit = { form . handleSubmit ( ( data ) => {
66
+ if ( ! isAddress ( data . walletAddress ) ) {
67
+ onError ( new Error ( "Invalid wallet address" ) ) ;
68
+ }
65
69
grantPermissions ( data , {
66
70
onSuccess : ( ) => {
67
71
onSuccess ( ) ;
You can’t perform that action at this time.
0 commit comments