Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
0195da4e
Commit
0195da4e
authored
May 16, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
call resources only if user is authenticated
parent
73f78457
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
15 deletions
+18
-15
AddressVerificationStepAddress.tsx
...ressVerification/steps/AddressVerificationStepAddress.tsx
+1
-1
TokenInfoMenuItem.tsx
ui/shared/AddressActions/TokenInfoMenuItem.tsx
+17
-14
No files found.
ui/addressVerification/steps/AddressVerificationStepAddress.tsx
View file @
0195da4e
...
...
@@ -74,7 +74,7 @@ const AddressVerificationStepAddress = ({ defaultAddress, onContinue }: Props) =
return
<
span
>
Specified address either does not exist or is EOA.
</
span
>;
}
case
'
IS_OWNER_ERROR
'
:
{
return
<
span
>
Ownership of this contract address
ownership
is already verified by this account.
</
span
>;
return
<
span
>
Ownership of this contract address is already verified by this account.
</
span
>;
}
case
'
OWNERSHIP_VERIFIED_ERROR
'
:
{
return
<
span
>
Ownership of this contract address is already verified by another account.
</
span
>;
...
...
ui/shared/AddressActions/TokenInfoMenuItem.tsx
View file @
0195da4e
import
{
MenuItem
,
Icon
,
chakra
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
{
useQueryClient
}
from
'
@tanstack/react-query
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
type
{
TokenVerifiedInfo
}
from
'
types/api/token
'
;
import
appConfig
from
'
configs/app/config
'
;
import
iconEdit
from
'
icons/edit.svg
'
;
import
useApiQuery
,
{
getResourceKey
}
from
'
lib/api/useApiQuery
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
useHasAccount
from
'
lib/hooks/useHasAccount
'
;
import
useRedirectIfNotAuth
from
'
lib/hooks/useRedirectIfNotAuth
'
;
import
AddressVerificationModal
from
'
ui/addressVerification/AddressVerificationModal
'
;
...
...
@@ -20,13 +18,25 @@ const TokenInfoMenuItem = ({ className, hash }: Props) => {
const
router
=
useRouter
();
const
modal
=
useDisclosure
();
const
redirectIfNotAuth
=
useRedirectIfNotAuth
();
const
queryClient
=
useQueryClie
nt
();
const
isAuth
=
useHasAccou
nt
();
const
verifiedAddressesQuery
=
useApiQuery
(
'
verified_addresses
'
,
{
pathParams
:
{
chainId
:
appConfig
.
network
.
id
},
queryOptions
:
{
enabled
:
isAuth
,
},
});
const
applicationsQuery
=
useApiQuery
(
'
token_info_applications
'
,
{
pathParams
:
{
chainId
:
appConfig
.
network
.
id
,
id
:
undefined
},
queryOptions
:
{
enabled
:
isAuth
,
},
});
const
tokenInfoQuery
=
useApiQuery
(
'
token_verified_info
'
,
{
pathParams
:
{
hash
,
chainId
:
appConfig
.
network
.
id
},
queryOptions
:
{
refetchOnMount
:
false
,
},
});
const
handleAddAddressClick
=
React
.
useCallback
(()
=>
{
...
...
@@ -52,18 +62,11 @@ const TokenInfoMenuItem = ({ className, hash }: Props) => {
const
icon
=
<
Icon
as=
{
iconEdit
}
boxSize=
{
6
}
mr=
{
2
}
p=
{
1
}
/>;
const
content
=
(()
=>
{
const
verifiedTokenInfo
=
queryClient
.
getQueryData
<
TokenVerifiedInfo
>
(
getResourceKey
(
'
token_verified_info
'
,
{
pathParams
:
{
hash
,
chainId
:
appConfig
.
network
.
id
}
},
),
);
if
(
!
verifiedAddressesQuery
.
data
?.
verifiedAddresses
.
find
(({
contractAddress
})
=>
contractAddress
.
toLowerCase
()
===
hash
.
toLowerCase
()))
{
return
(
<
MenuItem
className=
{
className
}
onClick=
{
handleAddAddressClick
}
>
{
icon
}
<
span
>
{
verifiedTokenInfo
?.
tokenAddress
?
'
Update token info
'
:
'
Add token info
'
}
</
span
>
<
span
>
{
tokenInfoQuery
.
data
?.
tokenAddress
?
'
Update token info
'
:
'
Add token info
'
}
</
span
>
</
MenuItem
>
);
}
...
...
@@ -75,7 +78,7 @@ const TokenInfoMenuItem = ({ className, hash }: Props) => {
{
icon
}
<
span
>
{
hasApplication
||
verifiedTokenInfo
?.
tokenAddress
?
hasApplication
||
tokenInfoQuery
.
data
?.
tokenAddress
?
'
Update token info
'
:
'
Add token info
'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment