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
54b63a3e
Commit
54b63a3e
authored
Aug 27, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use bens api for domain query
parent
981f1fce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
10 deletions
+35
-10
resources.ts
lib/api/resources.ts
+7
-0
WalletMenuDesktop.tsx
ui/snippets/walletMenu/WalletMenuDesktop.tsx
+15
-6
WalletMenuMobile.tsx
ui/snippets/walletMenu/WalletMenuMobile.tsx
+13
-4
No files found.
lib/api/resources.ts
View file @
54b63a3e
...
...
@@ -231,6 +231,12 @@ export const RESOURCES = {
basePath
:
getFeaturePayload
(
config
.
features
.
nameService
)?.
api
.
basePath
,
filterFields
:
[
'
address
'
as
const
,
'
resolved_to
'
as
const
,
'
owned_by
'
as
const
,
'
only_active
'
as
const
,
'
protocols
'
as
const
],
},
address_domain
:
{
path
:
'
/api/v1/:chainId/addresses/:address
'
,
pathParams
:
[
'
chainId
'
as
const
,
'
address
'
as
const
],
endpoint
:
getFeaturePayload
(
config
.
features
.
nameService
)?.
api
.
endpoint
,
basePath
:
getFeaturePayload
(
config
.
features
.
nameService
)?.
api
.
basePath
,
},
domain_info
:
{
path
:
'
/api/v1/:chainId/domains/:name
'
,
pathParams
:
[
'
chainId
'
as
const
,
'
name
'
as
const
],
...
...
@@ -1081,6 +1087,7 @@ Q extends 'zksync_l2_txn_batch' ? ZkSyncBatch :
Q
extends
'
zksync_l2_txn_batch_txs
'
?
ZkSyncBatchTxs
:
Q
extends
'
contract_security_audits
'
?
SmartContractSecurityAudits
:
Q
extends
'
addresses_lookup
'
?
bens
.
LookupAddressResponse
:
Q
extends
'
address_domain
'
?
bens
.
GetAddressResponse
:
Q
extends
'
domain_info
'
?
bens
.
DetailedDomain
:
Q
extends
'
domain_events
'
?
bens
.
ListDomainEventsResponse
:
Q
extends
'
domains_lookup
'
?
bens
.
LookupDomainNameResponse
:
...
...
ui/snippets/walletMenu/WalletMenuDesktop.tsx
View file @
54b63a3e
...
...
@@ -2,10 +2,11 @@ import type { ButtonProps } from '@chakra-ui/react';
import
{
PopoverContent
,
PopoverBody
,
PopoverTrigger
,
Button
,
Box
,
useBoolean
,
chakra
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
config
from
'
configs/app
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
{
useMarketplaceContext
}
from
'
lib/contexts/marketplace
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
*
as
mixpanel
from
'
lib/mixpanel/index
'
;
import
useAddressQuery
from
'
ui/address/utils/useAddressQuery
'
;
import
Popover
from
'
ui/shared/chakra/Popover
'
;
import
HashStringShorten
from
'
ui/shared/HashStringShorten
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
...
...
@@ -40,7 +41,15 @@ export const WalletMenuDesktopComponent = ({
const
[
isPopoverOpen
,
setIsPopoverOpen
]
=
useBoolean
(
false
);
const
isMobile
=
useIsMobile
();
const
{
isAutoConnectDisabled
}
=
useMarketplaceContext
();
const
addressQuery
=
useAddressQuery
({
hash
:
address
});
const
addressDomainQuery
=
useApiQuery
(
'
address_domain
'
,
{
pathParams
:
{
chainId
:
config
.
chain
.
id
,
address
,
},
queryOptions
:
{
enabled
:
config
.
features
.
nameService
.
isEnabled
,
},
});
const
variant
=
React
.
useMemo
(()
=>
{
if
(
isWalletConnected
)
{
...
...
@@ -99,7 +108,7 @@ export const WalletMenuDesktopComponent = ({
flexShrink=
{
0
}
isLoading=
{
((
isModalOpening
||
isModalOpen
)
&&
!
isWalletConnected
)
||
(
address
Query
.
isPlaceholderData
&&
isWalletConnected
)
(
address
DomainQuery
.
isLoading
&&
isWalletConnected
)
}
loadingText=
"Connect wallet"
onClick=
{
isWalletConnected
?
openPopover
:
connect
}
...
...
@@ -111,8 +120,8 @@ export const WalletMenuDesktopComponent = ({
{
isWalletConnected
?
(
<>
<
WalletIdenticon
address=
{
address
}
isAutoConnectDisabled=
{
isAutoConnectDisabled
}
mr=
{
2
}
/>
{
address
Query
.
data
?.
ens_domain_
name
?
(
<
chakra
.
span
>
{
address
Query
.
data
.
ens_domain_
name
}
</
chakra
.
span
>
{
address
DomainQuery
.
data
?.
domain
?.
name
?
(
<
chakra
.
span
>
{
address
DomainQuery
.
data
.
domain
?.
name
}
</
chakra
.
span
>
)
:
(
<
HashStringShorten
hash=
{
address
}
isTooltipDisabled
/>
)
}
...
...
@@ -132,7 +141,7 @@ export const WalletMenuDesktopComponent = ({
<
PopoverBody
padding=
"24px 16px 16px 16px"
>
<
WalletMenuContent
address=
{
address
}
ensDomainName=
{
address
Query
.
data
?.
ens_domain_
name
}
ensDomainName=
{
address
DomainQuery
.
data
?.
domain
?.
name
}
disconnect=
{
disconnect
}
isAutoConnectDisabled=
{
isAutoConnectDisabled
}
openWeb3Modal=
{
openModal
}
...
...
ui/snippets/walletMenu/WalletMenuMobile.tsx
View file @
54b63a3e
import
{
Drawer
,
DrawerOverlay
,
DrawerContent
,
DrawerBody
,
useDisclosure
,
IconButton
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
config
from
'
configs/app
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
{
useMarketplaceContext
}
from
'
lib/contexts/marketplace
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
*
as
mixpanel
from
'
lib/mixpanel/index
'
;
import
useAddressQuery
from
'
ui/address/utils/useAddressQuery
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
useWallet
from
'
ui/snippets/walletMenu/useWallet
'
;
import
WalletMenuContent
from
'
ui/snippets/walletMenu/WalletMenuContent
'
;
...
...
@@ -30,7 +31,15 @@ export const WalletMenuMobileComponent = (
const
{
themedBackground
,
themedBackgroundOrange
,
themedBorderColor
,
themedColor
}
=
useMenuButtonColors
();
const
isMobile
=
useIsMobile
();
const
{
isAutoConnectDisabled
}
=
useMarketplaceContext
();
const
addressQuery
=
useAddressQuery
({
hash
:
address
});
const
addressDomainQuery
=
useApiQuery
(
'
address_domain
'
,
{
pathParams
:
{
chainId
:
config
.
chain
.
id
,
address
,
},
queryOptions
:
{
enabled
:
config
.
features
.
nameService
.
isEnabled
,
},
});
const
openPopover
=
React
.
useCallback
(()
=>
{
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
WALLET_ACTION
,
{
Action
:
'
Open
'
});
...
...
@@ -63,7 +72,7 @@ export const WalletMenuMobileComponent = (
onClick=
{
isWalletConnected
?
openPopover
:
connect
}
isLoading=
{
((
isModalOpening
||
isModalOpen
)
&&
!
isWalletConnected
)
||
(
address
Query
.
isPlaceholderData
&&
isWalletConnected
)
(
address
DomainQuery
.
isLoading
&&
isWalletConnected
)
}
/>
</
WalletTooltip
>
...
...
@@ -79,7 +88,7 @@ export const WalletMenuMobileComponent = (
<
DrawerBody
p=
{
6
}
>
<
WalletMenuContent
address=
{
address
}
ensDomainName=
{
address
Query
.
data
?.
ens_domain_
name
}
ensDomainName=
{
address
DomainQuery
.
data
?.
domain
?.
name
}
disconnect=
{
disconnect
}
isAutoConnectDisabled=
{
isAutoConnectDisabled
}
openWeb3Modal=
{
openModal
}
...
...
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