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
f7aacab6
Commit
f7aacab6
authored
Nov 29, 2023
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove token info from instance
parent
3d3b2515
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
63 additions
and
38 deletions
+63
-38
tokenInstance.ts
mocks/tokens/tokenInstance.ts
+0
-2
token.ts
stubs/token.ts
+0
-1
token.ts
types/api/token.ts
+0
-1
Token.tsx
ui/pages/Token.tsx
+1
-1
TokenInstance.tsx
ui/pages/TokenInstance.tsx
+27
-15
TokenInventory.pw.tsx
ui/token/TokenInventory.pw.tsx
+6
-0
TokenInventory.tsx
ui/token/TokenInventory.tsx
+11
-4
TokenInventoryItem.tsx
ui/token/TokenInventoryItem.tsx
+5
-5
TokenInstanceDetails.pw.tsx
ui/tokenInstance/TokenInstanceDetails.pw.tsx
+6
-3
TokenInstanceDetails.tsx
ui/tokenInstance/TokenInstanceDetails.tsx
+7
-6
No files found.
mocks/tokens/tokenInstance.ts
View file @
f7aacab6
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
import
type
{
TokenInstance
}
from
'
types/api/token
'
;
import
type
{
TokenInstance
}
from
'
types/api/token
'
;
import
*
as
addressMock
from
'
../address/address
'
;
import
*
as
addressMock
from
'
../address/address
'
;
import
{
tokenInfoERC721a
}
from
'
./tokenInfo
'
;
export
const
base
:
TokenInstance
=
{
export
const
base
:
TokenInstance
=
{
animation_url
:
null
,
animation_url
:
null
,
...
@@ -74,7 +73,6 @@ export const base: TokenInstance = {
...
@@ -74,7 +73,6 @@ export const base: TokenInstance = {
name
:
'
GENESIS #188848, 22a5f8bbb1602995. Blockchain pixel PFP NFT + "on music video" trait inspired by God
'
,
name
:
'
GENESIS #188848, 22a5f8bbb1602995. Blockchain pixel PFP NFT + "on music video" trait inspired by God
'
,
},
},
owner
:
addressMock
.
withName
,
owner
:
addressMock
.
withName
,
token
:
tokenInfoERC721a
,
};
};
export
const
withRichMetadata
:
TokenInstance
=
{
export
const
withRichMetadata
:
TokenInstance
=
{
...
...
stubs/token.ts
View file @
f7aacab6
...
@@ -108,6 +108,5 @@ export const TOKEN_INSTANCE: TokenInstance = {
...
@@ -108,6 +108,5 @@ export const TOKEN_INSTANCE: TokenInstance = {
name
:
'
GENESIS #188882, 8a77ca1bcaa4036f. Blockchain pixel PFP NFT + "on music video" trait inspired by God
'
,
name
:
'
GENESIS #188882, 8a77ca1bcaa4036f. Blockchain pixel PFP NFT + "on music video" trait inspired by God
'
,
},
},
owner
:
ADDRESS_PARAMS
,
owner
:
ADDRESS_PARAMS
,
token
:
TOKEN_INFO_ERC_1155
,
holder_address_hash
:
ADDRESS_HASH
,
holder_address_hash
:
ADDRESS_HASH
,
};
};
types/api/token.ts
View file @
f7aacab6
...
@@ -61,7 +61,6 @@ export interface TokenInstance {
...
@@ -61,7 +61,6 @@ export interface TokenInstance {
external_app_url
:
string
|
null
;
external_app_url
:
string
|
null
;
metadata
:
Record
<
string
,
unknown
>
|
null
;
metadata
:
Record
<
string
,
unknown
>
|
null
;
owner
:
AddressParam
|
null
;
owner
:
AddressParam
|
null
;
token
:
TokenInfo
;
}
}
export
interface
TokenInstanceTransfersCount
{
export
interface
TokenInstanceTransfersCount
{
...
...
ui/pages/Token.tsx
View file @
f7aacab6
...
@@ -174,7 +174,7 @@ const TokenPageContent = () => {
...
@@ -174,7 +174,7 @@ const TokenPageContent = () => {
const tabs: Array<RoutedTab> = [
const tabs: Array<RoutedTab> = [
(tokenQuery.data?.type === 'ERC-1155' || tokenQuery.data?.type === 'ERC-721') ?
(tokenQuery.data?.type === 'ERC-1155' || tokenQuery.data?.type === 'ERC-721') ?
{ id: 'inventory', title: 'Inventory', component: <TokenInventory inventoryQuery={ inventoryQuery }/> } :
{ id: 'inventory', title: 'Inventory', component: <TokenInventory inventoryQuery={ inventoryQuery }
tokenQuery={ tokenQuery }
/> } :
undefined,
undefined,
{ id: 'token_transfers', title: 'Token transfers', component: <TokenTransfer transfersQuery={ transfersQuery } token={ tokenQuery.data }/> },
{ id: 'token_transfers', title: 'Token transfers', component: <TokenTransfer transfersQuery={ transfersQuery } token={ tokenQuery.data }/> },
{ id: 'holders', title: 'Holders', component: <TokenHolders token={ tokenQuery.data } holdersQuery={ holdersQuery }/> },
{ id: 'holders', title: 'Holders', component: <TokenHolders token={ tokenQuery.data } holdersQuery={ holdersQuery }/> },
...
...
ui/pages/TokenInstance.tsx
View file @
f7aacab6
...
@@ -10,7 +10,7 @@ import { useAppContext } from 'lib/contexts/app';
...
@@ -10,7 +10,7 @@ import { useAppContext } from 'lib/contexts/app';
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
*
as
metadata
from
'
lib/metadata
'
;
import
*
as
metadata
from
'
lib/metadata
'
;
import
*
as
regexp
from
'
lib/regexp
'
;
import
*
as
regexp
from
'
lib/regexp
'
;
import
{
TOKEN_INSTANCE
}
from
'
stubs/token
'
;
import
{
TOKEN_INSTANCE
,
TOKEN_INFO_ERC_1155
}
from
'
stubs/token
'
;
import
*
as
tokenStubs
from
'
stubs/token
'
;
import
*
as
tokenStubs
from
'
stubs/token
'
;
import
{
generateListStub
}
from
'
stubs/utils
'
;
import
{
generateListStub
}
from
'
stubs/utils
'
;
import
AddressQrCode
from
'
ui/address/details/AddressQrCode
'
;
import
AddressQrCode
from
'
ui/address/details/AddressQrCode
'
;
...
@@ -43,6 +43,14 @@ const TokenInstanceContent = () => {
...
@@ -43,6 +43,14 @@ const TokenInstanceContent = () => {
const
scrollRef
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
scrollRef
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
tokenQuery
=
useApiQuery
(
'
token
'
,
{
pathParams
:
{
hash
},
queryOptions
:
{
enabled
:
Boolean
(
hash
&&
id
),
placeholderData
:
TOKEN_INFO_ERC_1155
,
},
});
const
tokenInstanceQuery
=
useApiQuery
(
'
token_instance
'
,
{
const
tokenInstanceQuery
=
useApiQuery
(
'
token_instance
'
,
{
pathParams
:
{
hash
,
id
},
pathParams
:
{
hash
,
id
},
queryOptions
:
{
queryOptions
:
{
...
@@ -58,14 +66,18 @@ const TokenInstanceContent = () => {
...
@@ -58,14 +66,18 @@ const TokenInstanceContent = () => {
options
:
{
options
:
{
enabled
:
Boolean
(
hash
&&
id
&&
(
!
tab
||
tab
===
'
token_transfers
'
)
&&
!
tokenInstanceQuery
.
isPlaceholderData
&&
tokenInstanceQuery
.
data
),
enabled
:
Boolean
(
hash
&&
id
&&
(
!
tab
||
tab
===
'
token_transfers
'
)
&&
!
tokenInstanceQuery
.
isPlaceholderData
&&
tokenInstanceQuery
.
data
),
placeholderData
:
generateListStub
<
'
token_instance_transfers
'
>
(
placeholderData
:
generateListStub
<
'
token_instance_transfers
'
>
(
token
InstanceQuery
.
data
?.
token
.
type
===
'
ERC-1155
'
?
tokenStubs
.
TOKEN_TRANSFER_ERC_1155
:
tokenStubs
.
TOKEN_TRANSFER_ERC_721
,
token
Query
.
data
?
.
type
===
'
ERC-1155
'
?
tokenStubs
.
TOKEN_TRANSFER_ERC_1155
:
tokenStubs
.
TOKEN_TRANSFER_ERC_721
,
10
,
10
,
{
next_page_params
:
null
},
{
next_page_params
:
null
},
),
),
},
},
});
});
const
shouldFetchHolders
=
!
tokenInstanceQuery
.
isPlaceholderData
&&
tokenInstanceQuery
.
data
&&
!
tokenInstanceQuery
.
data
.
is_unique
;
const
shouldFetchHolders
=
!
tokenQuery
.
isPlaceholderData
&&
!
tokenInstanceQuery
.
isPlaceholderData
&&
tokenInstanceQuery
.
data
&&
!
tokenInstanceQuery
.
data
.
is_unique
;
const
holdersQuery
=
useQueryWithPages
({
const
holdersQuery
=
useQueryWithPages
({
resourceName
:
'
token_instance_holders
'
,
resourceName
:
'
token_instance_holders
'
,
...
@@ -74,18 +86,18 @@ const TokenInstanceContent = () => {
...
@@ -74,18 +86,18 @@ const TokenInstanceContent = () => {
options
:
{
options
:
{
enabled
:
Boolean
(
hash
&&
tab
===
'
holders
'
&&
shouldFetchHolders
),
enabled
:
Boolean
(
hash
&&
tab
===
'
holders
'
&&
shouldFetchHolders
),
placeholderData
:
generateListStub
<
'
token_instance_holders
'
>
(
placeholderData
:
generateListStub
<
'
token_instance_holders
'
>
(
token
InstanceQuery
.
data
?.
token
.
type
===
'
ERC-1155
'
?
tokenStubs
.
TOKEN_HOLDER_ERC_1155
:
tokenStubs
.
TOKEN_HOLDER_ERC_20
,
10
,
{
next_page_params
:
null
}),
token
Query
.
data
?
.
type
===
'
ERC-1155
'
?
tokenStubs
.
TOKEN_HOLDER_ERC_1155
:
tokenStubs
.
TOKEN_HOLDER_ERC_20
,
10
,
{
next_page_params
:
null
}),
},
},
});
});
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
tokenInstanceQuery
.
data
&&
!
tokenInstanceQuery
.
isPlaceholderData
)
{
if
(
tokenInstanceQuery
.
data
&&
!
tokenInstanceQuery
.
isPlaceholderData
&&
tokenQuery
.
data
&&
!
tokenQuery
.
isPlaceholderData
)
{
metadata
.
update
(
metadata
.
update
(
{
pathname
:
'
/token/[hash]/instance/[id]
'
,
query
:
{
hash
:
token
InstanceQuery
.
data
.
token
.
address
,
id
:
tokenInstanceQuery
.
data
.
id
}
},
{
pathname
:
'
/token/[hash]/instance/[id]
'
,
query
:
{
hash
:
token
Query
.
data
.
address
,
id
:
tokenInstanceQuery
.
data
.
id
}
},
{
symbol
:
token
InstanceQuery
.
data
.
token
.
symbol
??
''
},
{
symbol
:
token
Query
.
data
.
symbol
??
''
},
);
);
}
}
},
[
tokenInstanceQuery
.
data
,
tokenInstanceQuery
.
isPlaceholderData
]);
},
[
tokenInstanceQuery
.
data
,
tokenInstanceQuery
.
isPlaceholderData
,
tokenQuery
.
data
,
tokenQuery
.
isPlaceholderData
]);
const
backLink
=
React
.
useMemo
(()
=>
{
const
backLink
=
React
.
useMemo
(()
=>
{
const
hasGoBackLink
=
appProps
.
referrer
&&
appProps
.
referrer
.
includes
(
`/token/
${
hash
}
`
)
&&
!
appProps
.
referrer
.
includes
(
'
instance
'
);
const
hasGoBackLink
=
appProps
.
referrer
&&
appProps
.
referrer
.
includes
(
`/token/
${
hash
}
`
)
&&
!
appProps
.
referrer
.
includes
(
'
instance
'
);
...
@@ -104,10 +116,10 @@ const TokenInstanceContent = () => {
...
@@ -104,10 +116,10 @@ const TokenInstanceContent = () => {
{
{
id
:
'
token_transfers
'
,
id
:
'
token_transfers
'
,
title
:
'
Token transfers
'
,
title
:
'
Token transfers
'
,
component
:
<
TokenTransfer
transfersQuery=
{
transfersQuery
}
tokenId=
{
id
}
token=
{
token
InstanceQuery
.
data
?.
token
}
/>,
component
:
<
TokenTransfer
transfersQuery=
{
transfersQuery
}
tokenId=
{
id
}
token=
{
token
Query
.
data
}
/>,
},
},
shouldFetchHolders
?
shouldFetchHolders
?
{
id
:
'
holders
'
,
title
:
'
Holders
'
,
component
:
<
TokenHolders
holdersQuery=
{
holdersQuery
}
token=
{
token
InstanceQuery
.
data
?.
token
}
/>
}
:
{
id
:
'
holders
'
,
title
:
'
Holders
'
,
component
:
<
TokenHolders
holdersQuery=
{
holdersQuery
}
token=
{
token
Query
.
data
}
/>
}
:
undefined
,
undefined
,
{
id
:
'
metadata
'
,
title
:
'
Metadata
'
,
component
:
(
{
id
:
'
metadata
'
,
title
:
'
Metadata
'
,
component
:
(
<
TokenInstanceMetadata
<
TokenInstanceMetadata
...
@@ -121,7 +133,7 @@ const TokenInstanceContent = () => {
...
@@ -121,7 +133,7 @@ const TokenInstanceContent = () => {
throw
Error
(
'
Token instance fetch failed
'
,
{
cause
:
tokenInstanceQuery
.
error
});
throw
Error
(
'
Token instance fetch failed
'
,
{
cause
:
tokenInstanceQuery
.
error
});
}
}
const
tokenTag
=
<
Tag
isLoading=
{
tokenInstanceQuery
.
isPlaceholderData
}
>
{
token
InstanceQuery
.
data
?.
token
.
type
}
</
Tag
>;
const
tokenTag
=
<
Tag
isLoading=
{
tokenInstanceQuery
.
isPlaceholderData
}
>
{
token
Query
.
data
?
.
type
}
</
Tag
>;
const
address
=
{
const
address
=
{
hash
:
hash
||
''
,
hash
:
hash
||
''
,
...
@@ -131,7 +143,7 @@ const TokenInstanceContent = () => {
...
@@ -131,7 +143,7 @@ const TokenInstanceContent = () => {
watchlist_address_id
:
null
,
watchlist_address_id
:
null
,
};
};
const
isLoading
=
tokenInstanceQuery
.
isPlaceholderData
;
const
isLoading
=
tokenInstanceQuery
.
isPlaceholderData
||
tokenQuery
.
isPlaceholderData
;
const
appLink
=
(()
=>
{
const
appLink
=
(()
=>
{
if
(
!
tokenInstanceQuery
.
data
?.
external_app_url
)
{
if
(
!
tokenInstanceQuery
.
data
?.
external_app_url
)
{
...
@@ -168,7 +180,7 @@ const TokenInstanceContent = () => {
...
@@ -168,7 +180,7 @@ const TokenInstanceContent = () => {
const
titleSecondRow
=
(
const
titleSecondRow
=
(
<
Flex
alignItems=
"center"
w=
"100%"
minW=
{
0
}
columnGap=
{
2
}
rowGap=
{
2
}
flexWrap=
{
{
base
:
'
wrap
'
,
lg
:
'
nowrap
'
}
}
>
<
Flex
alignItems=
"center"
w=
"100%"
minW=
{
0
}
columnGap=
{
2
}
rowGap=
{
2
}
flexWrap=
{
{
base
:
'
wrap
'
,
lg
:
'
nowrap
'
}
}
>
<
TokenEntity
<
TokenEntity
token=
{
token
InstanceQuery
.
data
?.
token
}
token=
{
token
Query
.
data
}
isLoading=
{
isLoading
}
isLoading=
{
isLoading
}
noSymbol
noSymbol
noCopy
noCopy
...
@@ -179,7 +191,7 @@ const TokenInstanceContent = () => {
...
@@ -179,7 +191,7 @@ const TokenInstanceContent = () => {
w=
"auto"
w=
"auto"
maxW=
"700px"
maxW=
"700px"
/>
/>
{
!
isLoading
&&
tokenInstanceQuery
.
data
&&
<
AddressAddToWallet
token=
{
token
InstanceQuery
.
data
.
token
}
variant=
"button"
/>
}
{
!
isLoading
&&
tokenInstanceQuery
.
data
&&
<
AddressAddToWallet
token=
{
token
Query
.
data
}
variant=
"button"
/>
}
<
AddressQrCode
address=
{
address
}
isLoading=
{
isLoading
}
/>
<
AddressQrCode
address=
{
address
}
isLoading=
{
isLoading
}
/>
<
AccountActionsMenu
isLoading=
{
isLoading
}
/>
<
AccountActionsMenu
isLoading=
{
isLoading
}
/>
{
appLink
}
{
appLink
}
...
@@ -197,7 +209,7 @@ const TokenInstanceContent = () => {
...
@@ -197,7 +209,7 @@ const TokenInstanceContent = () => {
isLoading=
{
isLoading
}
isLoading=
{
isLoading
}
/>
/>
<
TokenInstanceDetails
data=
{
tokenInstanceQuery
?.
data
}
isLoading=
{
isLoading
}
scrollRef=
{
scrollRef
}
/>
<
TokenInstanceDetails
data=
{
tokenInstanceQuery
?.
data
}
isLoading=
{
isLoading
}
scrollRef=
{
scrollRef
}
token=
{
tokenQuery
.
data
}
/>
{
/* should stay before tabs to scroll up with pagination */
}
{
/* should stay before tabs to scroll up with pagination */
}
<
Box
ref=
{
scrollRef
}
></
Box
>
<
Box
ref=
{
scrollRef
}
></
Box
>
...
...
ui/token/TokenInventory.pw.tsx
View file @
f7aacab6
...
@@ -2,6 +2,7 @@ import { Box } from '@chakra-ui/react';
...
@@ -2,6 +2,7 @@ import { Box } from '@chakra-ui/react';
import
{
test
,
expect
}
from
'
@playwright/experimental-ct-react
'
;
import
{
test
,
expect
}
from
'
@playwright/experimental-ct-react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
tokenInfoERC721a
}
from
'
mocks/tokens/tokenInfo
'
;
import
{
base
as
tokenInstanse
}
from
'
mocks/tokens/tokenInstance
'
;
import
{
base
as
tokenInstanse
}
from
'
mocks/tokens/tokenInstance
'
;
import
TestApp
from
'
playwright/TestApp
'
;
import
TestApp
from
'
playwright/TestApp
'
;
...
@@ -23,6 +24,11 @@ test('base view +@mobile', async({ mount }) => {
...
@@ -23,6 +24,11 @@ test('base view +@mobile', async({ mount }) => {
// @ts-ignore:
// @ts-ignore:
pagination
:
{
page
:
1
,
isVisible
:
true
},
pagination
:
{
page
:
1
,
isVisible
:
true
},
}
}
}
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore:
tokenQuery=
{
{
data
:
tokenInfoERC721a
,
}
}
/>
/>
</
TestApp
>,
</
TestApp
>,
);
);
...
...
ui/token/TokenInventory.tsx
View file @
f7aacab6
import
{
Grid
}
from
'
@chakra-ui/react
'
;
import
{
Grid
}
from
'
@chakra-ui/react
'
;
import
type
{
UseQueryResult
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
TokenInfo
}
from
'
types/api/token
'
;
import
type
{
ResourceError
}
from
'
lib/api/resources
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
ActionBar
from
'
ui/shared/ActionBar
'
;
import
ActionBar
from
'
ui/shared/ActionBar
'
;
import
DataListDisplay
from
'
ui/shared/DataListDisplay
'
;
import
DataListDisplay
from
'
ui/shared/DataListDisplay
'
;
...
@@ -11,9 +15,10 @@ import TokenInventoryItem from './TokenInventoryItem';
...
@@ -11,9 +15,10 @@ import TokenInventoryItem from './TokenInventoryItem';
type
Props
=
{
type
Props
=
{
inventoryQuery
:
QueryWithPagesResult
<
'
token_inventory
'
>
;
inventoryQuery
:
QueryWithPagesResult
<
'
token_inventory
'
>
;
tokenQuery
:
UseQueryResult
<
TokenInfo
,
ResourceError
<
unknown
>>
;
}
}
const
TokenInventory
=
({
inventoryQuery
}:
Props
)
=>
{
const
TokenInventory
=
({
inventoryQuery
,
tokenQuery
}:
Props
)
=>
{
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
const
actionBar
=
isMobile
&&
inventoryQuery
.
pagination
.
isVisible
&&
(
const
actionBar
=
isMobile
&&
inventoryQuery
.
pagination
.
isVisible
&&
(
...
@@ -23,8 +28,9 @@ const TokenInventory = ({ inventoryQuery }: Props) => {
...
@@ -23,8 +28,9 @@ const TokenInventory = ({ inventoryQuery }: Props) => {
);
);
const
items
=
inventoryQuery
.
data
?.
items
;
const
items
=
inventoryQuery
.
data
?.
items
;
const
token
=
tokenQuery
.
data
;
const
content
=
items
?
(
const
content
=
items
&&
token
?
(
<
Grid
<
Grid
w=
"100%"
w=
"100%"
columnGap=
{
{
base
:
3
,
lg
:
6
}
}
columnGap=
{
{
base
:
3
,
lg
:
6
}
}
...
@@ -33,9 +39,10 @@ const TokenInventory = ({ inventoryQuery }: Props) => {
...
@@ -33,9 +39,10 @@ const TokenInventory = ({ inventoryQuery }: Props) => {
>
>
{
items
.
map
((
item
,
index
)
=>
(
{
items
.
map
((
item
,
index
)
=>
(
<
TokenInventoryItem
<
TokenInventoryItem
key=
{
item
.
token
.
address
+
'
_
'
+
item
.
id
+
(
inventoryQuery
.
isPlaceholderData
?
'
_
'
+
index
:
''
)
}
key=
{
token
.
address
+
'
_
'
+
item
.
id
+
(
inventoryQuery
.
isPlaceholderData
?
'
_
'
+
index
:
''
)
}
item=
{
item
}
item=
{
item
}
isLoading=
{
inventoryQuery
.
isPlaceholderData
}
isLoading=
{
inventoryQuery
.
isPlaceholderData
||
tokenQuery
.
isPlaceholderData
}
token=
{
token
}
/>
/>
))
}
))
}
</
Grid
>
</
Grid
>
...
...
ui/token/TokenInventoryItem.tsx
View file @
f7aacab6
import
{
Box
,
Flex
,
Text
,
Link
,
useColorModeValue
,
Skeleton
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
Flex
,
Text
,
Link
,
useColorModeValue
,
Skeleton
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
TokenInstance
}
from
'
types/api/token
'
;
import
type
{
TokenIn
fo
,
TokenIn
stance
}
from
'
types/api/token
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
{
route
}
from
'
nextjs-routes
'
;
...
@@ -11,9 +11,9 @@ import LinkInternal from 'ui/shared/LinkInternal';
...
@@ -11,9 +11,9 @@ import LinkInternal from 'ui/shared/LinkInternal';
import
NftMedia
from
'
ui/shared/nft/NftMedia
'
;
import
NftMedia
from
'
ui/shared/nft/NftMedia
'
;
import
TruncatedTextTooltip
from
'
ui/shared/TruncatedTextTooltip
'
;
import
TruncatedTextTooltip
from
'
ui/shared/TruncatedTextTooltip
'
;
type
Props
=
{
item
:
TokenInstance
;
isLoading
:
boolean
};
type
Props
=
{
item
:
TokenInstance
;
token
:
TokenInfo
;
isLoading
:
boolean
};
const
NFTItem
=
({
item
,
isLoading
}:
Props
)
=>
{
const
TokenInventoryItem
=
({
item
,
token
,
isLoading
}:
Props
)
=>
{
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
...
@@ -25,7 +25,7 @@ const NFTItem = ({ item, isLoading }: Props) => {
...
@@ -25,7 +25,7 @@ const NFTItem = ({ item, isLoading }: Props) => {
/>
/>
);
);
const
url
=
route
({
pathname
:
'
/token/[hash]/instance/[id]
'
,
query
:
{
hash
:
item
.
token
.
address
,
id
:
item
.
id
}
});
const
url
=
route
({
pathname
:
'
/token/[hash]/instance/[id]
'
,
query
:
{
hash
:
token
.
address
,
id
:
item
.
id
}
});
return
(
return
(
<
Box
<
Box
...
@@ -76,4 +76,4 @@ const NFTItem = ({ item, isLoading }: Props) => {
...
@@ -76,4 +76,4 @@ const NFTItem = ({ item, isLoading }: Props) => {
);
);
};
};
export
default
NFT
Item
;
export
default
TokenInventory
Item
;
ui/tokenInstance/TokenInstanceDetails.pw.tsx
View file @
f7aacab6
...
@@ -2,6 +2,7 @@ import { test, expect } from '@playwright/experimental-ct-react';
...
@@ -2,6 +2,7 @@ import { test, expect } from '@playwright/experimental-ct-react';
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
*
as
addressMock
from
'
mocks/address/address
'
;
import
*
as
addressMock
from
'
mocks/address/address
'
;
import
{
tokenInfoERC721a
}
from
'
mocks/tokens/tokenInfo
'
;
import
*
as
tokenInstanceMock
from
'
mocks/tokens/tokenInstance
'
;
import
*
as
tokenInstanceMock
from
'
mocks/tokens/tokenInstance
'
;
import
TestApp
from
'
playwright/TestApp
'
;
import
TestApp
from
'
playwright/TestApp
'
;
import
buildApiUrl
from
'
playwright/utils/buildApiUrl
'
;
import
buildApiUrl
from
'
playwright/utils/buildApiUrl
'
;
...
@@ -9,10 +10,12 @@ import * as configs from 'playwright/utils/configs';
...
@@ -9,10 +10,12 @@ import * as configs from 'playwright/utils/configs';
import
TokenInstanceDetails
from
'
./TokenInstanceDetails
'
;
import
TokenInstanceDetails
from
'
./TokenInstanceDetails
'
;
const
API_URL_ADDRESS
=
buildApiUrl
(
'
address
'
,
{
hash
:
tokenInstanceMock
.
base
.
token
.
address
});
const
hash
=
tokenInfoERC721a
.
address
;
const
API_URL_ADDRESS
=
buildApiUrl
(
'
address
'
,
{
hash
});
const
API_URL_TOKEN_TRANSFERS_COUNT
=
buildApiUrl
(
'
token_instance_transfers_count
'
,
{
const
API_URL_TOKEN_TRANSFERS_COUNT
=
buildApiUrl
(
'
token_instance_transfers_count
'
,
{
id
:
tokenInstanceMock
.
unique
.
id
,
id
:
tokenInstanceMock
.
unique
.
id
,
hash
:
tokenInstanceMock
.
unique
.
token
.
address
,
hash
,
});
});
test
(
'
base view +@dark-mode +@mobile
'
,
async
({
mount
,
page
})
=>
{
test
(
'
base view +@dark-mode +@mobile
'
,
async
({
mount
,
page
})
=>
{
...
@@ -31,7 +34,7 @@ test('base view +@dark-mode +@mobile', async({ mount, page }) => {
...
@@ -31,7 +34,7 @@ test('base view +@dark-mode +@mobile', async({ mount, page }) => {
const
component
=
await
mount
(
const
component
=
await
mount
(
<
TestApp
>
<
TestApp
>
<
TokenInstanceDetails
data=
{
tokenInstanceMock
.
unique
}
/>
<
TokenInstanceDetails
data=
{
tokenInstanceMock
.
unique
}
token=
{
tokenInfoERC721a
}
/>
</
TestApp
>,
</
TestApp
>,
);
);
...
...
ui/tokenInstance/TokenInstanceDetails.tsx
View file @
f7aacab6
import
{
Flex
,
Grid
,
Skeleton
}
from
'
@chakra-ui/react
'
;
import
{
Flex
,
Grid
,
Skeleton
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
TokenInstance
}
from
'
types/api/token
'
;
import
type
{
TokenIn
fo
,
TokenIn
stance
}
from
'
types/api/token
'
;
import
CopyToClipboard
from
'
ui/shared/CopyToClipboard
'
;
import
CopyToClipboard
from
'
ui/shared/CopyToClipboard
'
;
import
DetailsInfoItem
from
'
ui/shared/DetailsInfoItem
'
;
import
DetailsInfoItem
from
'
ui/shared/DetailsInfoItem
'
;
...
@@ -18,11 +18,12 @@ import TokenInstanceTransfersCount from './details/TokenInstanceTransfersCount';
...
@@ -18,11 +18,12 @@ import TokenInstanceTransfersCount from './details/TokenInstanceTransfersCount';
interface
Props
{
interface
Props
{
data
?:
TokenInstance
;
data
?:
TokenInstance
;
token
?:
TokenInfo
;
isLoading
?:
boolean
;
isLoading
?:
boolean
;
scrollRef
?:
React
.
RefObject
<
HTMLDivElement
>
;
scrollRef
?:
React
.
RefObject
<
HTMLDivElement
>
;
}
}
const
TokenInstanceDetails
=
({
data
,
scrollRef
,
isLoading
}:
Props
)
=>
{
const
TokenInstanceDetails
=
({
data
,
token
,
scrollRef
,
isLoading
}:
Props
)
=>
{
const
handleCounterItemClick
=
React
.
useCallback
(()
=>
{
const
handleCounterItemClick
=
React
.
useCallback
(()
=>
{
window
.
setTimeout
(()
=>
{
window
.
setTimeout
(()
=>
{
// cannot do scroll instantly, have to wait a little
// cannot do scroll instantly, have to wait a little
...
@@ -30,7 +31,7 @@ const TokenInstanceDetails = ({ data, scrollRef, isLoading }: Props) => {
...
@@ -30,7 +31,7 @@ const TokenInstanceDetails = ({ data, scrollRef, isLoading }: Props) => {
},
500
);
},
500
);
},
[
scrollRef
]);
},
[
scrollRef
]);
if
(
!
data
)
{
if
(
!
data
||
!
token
)
{
return
null
;
return
null
;
}
}
...
@@ -56,7 +57,7 @@ const TokenInstanceDetails = ({ data, scrollRef, isLoading }: Props) => {
...
@@ -56,7 +57,7 @@ const TokenInstanceDetails = ({ data, scrollRef, isLoading }: Props) => {
/>
/>
</
DetailsInfoItem
>
</
DetailsInfoItem
>
)
}
)
}
<
TokenInstanceCreatorAddress
hash=
{
isLoading
?
''
:
data
.
token
.
address
}
/>
<
TokenInstanceCreatorAddress
hash=
{
isLoading
?
''
:
token
.
address
}
/>
<
DetailsInfoItem
<
DetailsInfoItem
title=
"Token ID"
title=
"Token ID"
hint=
"This token instance unique token ID"
hint=
"This token instance unique token ID"
...
@@ -69,8 +70,8 @@ const TokenInstanceDetails = ({ data, scrollRef, isLoading }: Props) => {
...
@@ -69,8 +70,8 @@ const TokenInstanceDetails = ({ data, scrollRef, isLoading }: Props) => {
<
CopyToClipboard
text=
{
data
.
id
}
isLoading=
{
isLoading
}
/>
<
CopyToClipboard
text=
{
data
.
id
}
isLoading=
{
isLoading
}
/>
</
Flex
>
</
Flex
>
</
DetailsInfoItem
>
</
DetailsInfoItem
>
<
TokenInstanceTransfersCount
hash=
{
isLoading
?
''
:
data
.
token
.
address
}
id=
{
isLoading
?
''
:
data
.
id
}
onClick=
{
handleCounterItemClick
}
/>
<
TokenInstanceTransfersCount
hash=
{
isLoading
?
''
:
token
.
address
}
id=
{
isLoading
?
''
:
data
.
id
}
onClick=
{
handleCounterItemClick
}
/>
<
TokenNftMarketplaces
isLoading=
{
isLoading
}
hash=
{
data
.
token
.
address
}
id=
{
data
.
id
}
/>
<
TokenNftMarketplaces
isLoading=
{
isLoading
}
hash=
{
token
.
address
}
id=
{
data
.
id
}
/>
</
Grid
>
</
Grid
>
<
NftMedia
<
NftMedia
url=
{
data
.
animation_url
||
data
.
image_url
}
url=
{
data
.
animation_url
||
data
.
image_url
}
...
...
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