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
741e498f
Commit
741e498f
authored
Nov 07, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pagination and tx info hide
parent
78a95507
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
129 additions
and
84 deletions
+129
-84
useQueryWithPages.ts
lib/hooks/useQueryWithPages.ts
+12
-7
token-transfers.ts
pages/api/transactions/[id]/token-transfers.ts
+3
-1
BlocksContent.tsx
ui/blocks/BlocksContent.tsx
+5
-1
TokenTransfer.tsx
ui/shared/TokenTransfer/TokenTransfer.tsx
+48
-34
TokenTransferList.tsx
ui/shared/TokenTransfer/TokenTransferList.tsx
+3
-2
TokenTransferListItem.tsx
ui/shared/TokenTransfer/TokenTransferListItem.tsx
+11
-8
TokenTransferSkeletonMobile.tsx
ui/shared/TokenTransfer/TokenTransferSkeletonMobile.tsx
+8
-6
TokenTransferTable.tsx
ui/shared/TokenTransfer/TokenTransferTable.tsx
+8
-7
TokenTransferTableItem.tsx
ui/shared/TokenTransfer/TokenTransferTableItem.tsx
+14
-9
TxTokenTransfer.tsx
ui/tx/TxTokenTransfer.tsx
+12
-8
TxsContent.tsx
ui/txs/TxsContent.tsx
+5
-1
No files found.
lib/hooks/useQueryWithPages.ts
View file @
741e498f
import
type
{
UseQueryOptions
}
from
'
@tanstack/react-query
'
;
import
{
useQuery
,
useQueryClient
}
from
'
@tanstack/react-query
'
;
import
{
useQuery
,
useQueryClient
}
from
'
@tanstack/react-query
'
;
import
{
pick
,
omit
}
from
'
lodash
'
;
import
{
pick
,
omit
}
from
'
lodash
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
...
@@ -17,11 +18,15 @@ interface ResponseWithPagination {
...
@@ -17,11 +18,15 @@ interface ResponseWithPagination {
next_page_params
:
PaginationParams
|
null
;
next_page_params
:
PaginationParams
|
null
;
}
}
export
default
function
useQueryWithPages
<
Response
extends
ResponseWithPagination
>
(
interface
Params
<
Response
>
{
apiPath
:
string
,
apiPath
:
string
;
queryName
:
QueryKeys
,
queryName
:
QueryKeys
;
filters
?:
TTxsFilters
|
BlockFilters
,
queryIds
?:
Array
<
string
>
;
)
{
filters
?:
TTxsFilters
|
BlockFilters
;
options
?:
Omit
<
UseQueryOptions
<
unknown
,
unknown
,
Response
>
,
'
queryKey
'
|
'
queryFn
'
>
;
}
export
default
function
useQueryWithPages
<
Response
extends
ResponseWithPagination
>
({
queryName
,
filters
,
options
,
apiPath
,
queryIds
}:
Params
<
Response
>
)
{
const
queryClient
=
useQueryClient
();
const
queryClient
=
useQueryClient
();
const
router
=
useRouter
();
const
router
=
useRouter
();
const
[
page
,
setPage
]
=
React
.
useState
(
1
);
const
[
page
,
setPage
]
=
React
.
useState
(
1
);
...
@@ -30,7 +35,7 @@ export default function useQueryWithPages<Response extends ResponseWithPaginatio
...
@@ -30,7 +35,7 @@ export default function useQueryWithPages<Response extends ResponseWithPaginatio
const
fetch
=
useFetch
();
const
fetch
=
useFetch
();
const
queryResult
=
useQuery
<
unknown
,
unknown
,
Response
>
(
const
queryResult
=
useQuery
<
unknown
,
unknown
,
Response
>
(
[
queryName
,
{
page
,
filters
}
],
[
queryName
,
...(
queryIds
||
[]),
{
page
,
filters
}
],
async
()
=>
{
async
()
=>
{
const
params
:
Array
<
string
>
=
[];
const
params
:
Array
<
string
>
=
[];
...
@@ -44,7 +49,7 @@ export default function useQueryWithPages<Response extends ResponseWithPaginatio
...
@@ -44,7 +49,7 @@ export default function useQueryWithPages<Response extends ResponseWithPaginatio
return
fetch
(
`
${
apiPath
}${
params
.
length
?
'
?
'
+
params
.
join
(
'
&
'
)
:
''
}
`
);
return
fetch
(
`
${
apiPath
}${
params
.
length
?
'
?
'
+
params
.
join
(
'
&
'
)
:
''
}
`
);
},
},
{
staleTime
:
Infinity
},
{
staleTime
:
Infinity
,
...
options
},
);
);
const
{
data
}
=
queryResult
;
const
{
data
}
=
queryResult
;
...
...
pages/api/transactions/[id]/token-transfers.ts
View file @
741e498f
import
type
{
NextApiRequest
}
from
'
next
'
;
import
type
{
NextApiRequest
}
from
'
next
'
;
import
getSearchParams
from
'
lib/api/getSearchParams
'
;
import
handler
from
'
lib/api/handler
'
;
import
handler
from
'
lib/api/handler
'
;
const
getUrl
=
(
req
:
NextApiRequest
)
=>
{
const
getUrl
=
(
req
:
NextApiRequest
)
=>
{
return
`/v2/transactions/
${
req
.
query
.
id
}
/token-transfers`
;
const
searchParamsStr
=
getSearchParams
(
req
);
return
`/v2/transactions/
${
req
.
query
.
id
}
/token-transfers
${
searchParamsStr
?
'
?
'
+
searchParamsStr
:
''
}
`
;
};
};
const
requestHandler
=
handler
(
getUrl
,
[
'
GET
'
]);
const
requestHandler
=
handler
(
getUrl
,
[
'
GET
'
]);
...
...
ui/blocks/BlocksContent.tsx
View file @
741e498f
...
@@ -25,7 +25,11 @@ const BlocksContent = ({ type }: Props) => {
...
@@ -25,7 +25,11 @@ const BlocksContent = ({ type }: Props) => {
const
queryClient
=
useQueryClient
();
const
queryClient
=
useQueryClient
();
const
[
socketAlert
,
setSocketAlert
]
=
React
.
useState
(
''
);
const
[
socketAlert
,
setSocketAlert
]
=
React
.
useState
(
''
);
const
{
data
,
isLoading
,
isError
,
pagination
}
=
useQueryWithPages
<
BlocksResponse
>
(
'
/node-api/blocks
'
,
QueryKeys
.
blocks
,
{
type
});
const
{
data
,
isLoading
,
isError
,
pagination
}
=
useQueryWithPages
<
BlocksResponse
>
({
apiPath
:
'
/node-api/blocks
'
,
queryName
:
QueryKeys
.
blocks
,
filters
:
{
type
},
});
const
handleNewBlockMessage
:
SocketMessage
.
NewBlock
[
'
handler
'
]
=
React
.
useCallback
((
payload
)
=>
{
const
handleNewBlockMessage
:
SocketMessage
.
NewBlock
[
'
handler
'
]
=
React
.
useCallback
((
payload
)
=>
{
queryClient
.
setQueryData
([
QueryKeys
.
blocks
,
{
page
:
pagination
.
page
,
filters
:
{
type
}
}
],
(
prevData
:
BlocksResponse
|
undefined
)
=>
{
queryClient
.
setQueryData
([
QueryKeys
.
blocks
,
{
page
:
pagination
.
page
,
filters
:
{
type
}
}
],
(
prevData
:
BlocksResponse
|
undefined
)
=>
{
...
...
ui/shared/TokenTransfer/TokenTransfer.tsx
View file @
741e498f
import
{
Alert
,
Hide
,
Show
}
from
'
@chakra-ui/react
'
;
import
{
Hide
,
Show
,
Text
}
from
'
@chakra-ui/react
'
;
import
type
{
QueryKey
}
from
'
@tanstack/react-query
'
;
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
TokenTransferResponse
}
from
'
types/api/tokenTransfer
'
;
import
type
{
TokenTransferResponse
}
from
'
types/api/tokenTransfer
'
;
import
type
{
QueryKeys
}
from
'
types/client/queries
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
useQueryWithPages
from
'
lib/hooks/useQueryWithPages
'
;
import
ActionBar
from
'
ui/shared/ActionBar
'
;
import
DataFetchAlert
from
'
ui/shared/DataFetchAlert
'
;
import
DataFetchAlert
from
'
ui/shared/DataFetchAlert
'
;
import
Pagination
from
'
ui/shared/Pagination
'
;
import
SkeletonTable
from
'
ui/shared/SkeletonTable
'
;
import
SkeletonTable
from
'
ui/shared/SkeletonTable
'
;
import
{
flattenTotal
}
from
'
ui/shared/TokenTransfer/helpers
'
;
import
{
flattenTotal
}
from
'
ui/shared/TokenTransfer/helpers
'
;
import
TokenTransferList
from
'
ui/shared/TokenTransfer/TokenTransferList
'
;
import
TokenTransferList
from
'
ui/shared/TokenTransfer/TokenTransferList
'
;
...
@@ -17,51 +18,64 @@ interface Props {
...
@@ -17,51 +18,64 @@ interface Props {
isLoading
?:
boolean
;
isLoading
?:
boolean
;
isDisabled
?:
boolean
;
isDisabled
?:
boolean
;
path
:
string
;
path
:
string
;
queryKey
:
QueryKey
;
queryName
:
QueryKeys
;
queryIds
?:
Array
<
string
>
;
baseAddress
?:
string
;
baseAddress
?:
string
;
showTxInfo
?:
boolean
;
}
}
const
TokenTransfer
=
({
isLoading
:
isLoadingProp
,
isDisabled
,
queryKey
,
path
,
baseAddress
}:
Props
)
=>
{
const
TokenTransfer
=
({
isLoading
:
isLoadingProp
,
isDisabled
,
queryName
,
queryIds
,
path
,
baseAddress
,
showTxInfo
=
true
}:
Props
)
=>
{
const
fetch
=
useFetch
();
const
{
isError
,
isLoading
,
data
,
pagination
}
=
useQueryWithPages
<
TokenTransferResponse
>
({
const
{
isError
,
isLoading
,
data
}
=
useQuery
<
unknown
,
unknown
,
TokenTransferResponse
>
(
apiPath
:
path
,
queryKey
,
queryName
,
async
()
=>
await
fetch
(
path
),
queryIds
,
{
options
:
{
enabled
:
!
isDisabled
},
enabled
:
!
isDisabled
,
});
},
);
const
content
=
(()
=>
{
if
(
isLoading
||
isLoadingProp
)
{
return
(
<>
<
Hide
below=
"lg"
>
<
SkeletonTable
columns=
{
showTxInfo
?
[
'
44px
'
,
'
185px
'
,
'
160px
'
,
'
25%
'
,
'
25%
'
,
'
25%
'
,
'
25%
'
]
:
[
'
185px
'
,
'
25%
'
,
'
25%
'
,
'
25%
'
,
'
25%
'
]
}
/>
</
Hide
>
<
Show
below=
"lg"
>
<
TokenTransferSkeletonMobile
showTxInfo=
{
showTxInfo
}
/>
</
Show
>
</>
);
}
if
(
isError
)
{
return
<
DataFetchAlert
/>;
}
if
(
!
data
.
items
?.
length
)
{
return
<
Text
as=
"span"
>
There are no token transfers
</
Text
>;
}
if
(
isLoading
||
isLoadingProp
)
{
const
items
=
data
.
items
.
reduce
(
flattenTotal
,
[]);
return
(
return
(
<>
<>
<
Hide
below=
"lg"
>
<
Hide
below=
"lg"
>
<
SkeletonTable
columns=
{
[
'
44px
'
,
'
185px
'
,
'
160px
'
,
'
25%
'
,
'
25%
'
,
'
25%
'
,
'
25%
'
]
}
/>
<
TokenTransferTable
data=
{
items
}
baseAddress=
{
baseAddress
}
showTxInfo=
{
showTxInfo
}
/>
</
Hide
>
</
Hide
>
<
Show
below=
"lg"
>
<
Show
below=
"lg"
>
<
TokenTransfer
SkeletonMobile
/>
<
TokenTransfer
List
data=
{
items
}
baseAddress=
{
baseAddress
}
showTxInfo=
{
showTxInfo
}
/>
</
Show
>
</
Show
>
</>
</>
);
);
}
})();
if
(
isError
)
{
return
<
DataFetchAlert
/>;
}
if
(
!
data
.
items
?.
length
)
{
return
<
Alert
>
There are no token transfers
</
Alert
>;
}
const
items
=
data
.
items
.
reduce
(
flattenTotal
,
[]);
return
(
return
(
<>
<>
<
Hide
below=
"lg"
>
<
ActionBar
>
<
TokenTransferTable
data=
{
items
}
baseAddress=
{
baseAddress
}
/>
<
Pagination
ml=
"auto"
{
...
pagination
}
/>
</
Hide
>
</
ActionBar
>
<
Show
below=
"lg"
>
{
content
}
<
TokenTransferList
data=
{
items
}
baseAddress=
{
baseAddress
}
/>
</
Show
>
</>
</>
);
);
};
};
...
...
ui/shared/TokenTransfer/TokenTransferList.tsx
View file @
741e498f
...
@@ -8,12 +8,13 @@ import TokenTransferListItem from 'ui/shared/TokenTransfer/TokenTransferListItem
...
@@ -8,12 +8,13 @@ import TokenTransferListItem from 'ui/shared/TokenTransfer/TokenTransferListItem
interface
Props
{
interface
Props
{
data
:
Array
<
TokenTransfer
>
;
data
:
Array
<
TokenTransfer
>
;
baseAddress
?:
string
;
baseAddress
?:
string
;
showTxInfo
?:
boolean
;
}
}
const
TokenTransferList
=
({
data
,
baseAddress
}:
Props
)
=>
{
const
TokenTransferList
=
({
data
,
baseAddress
,
showTxInfo
}:
Props
)
=>
{
return
(
return
(
<
Box
>
<
Box
>
{
data
.
map
((
item
,
index
)
=>
<
TokenTransferListItem
key=
{
index
}
{
...
item
}
baseAddress=
{
baseAddress
}
/>)
}
{
data
.
map
((
item
,
index
)
=>
<
TokenTransferListItem
key=
{
index
}
{
...
item
}
baseAddress=
{
baseAddress
}
showTxInfo=
{
showTxInfo
}
/>)
}
</
Box
>
</
Box
>
);
);
};
};
...
...
ui/shared/TokenTransfer/TokenTransferListItem.tsx
View file @
741e498f
...
@@ -16,9 +16,10 @@ import TokenSnippet from 'ui/shared/TokenSnippet';
...
@@ -16,9 +16,10 @@ import TokenSnippet from 'ui/shared/TokenSnippet';
type
Props
=
TokenTransfer
&
{
type
Props
=
TokenTransfer
&
{
baseAddress
?:
string
;
baseAddress
?:
string
;
showTxInfo
?:
boolean
;
}
}
const
TokenTransferListItem
=
({
token
,
total
,
tx_hash
:
txHash
,
from
,
to
,
baseAddress
}:
Props
)
=>
{
const
TokenTransferListItem
=
({
token
,
total
,
tx_hash
:
txHash
,
from
,
to
,
baseAddress
,
showTxInfo
}:
Props
)
=>
{
const
value
=
(()
=>
{
const
value
=
(()
=>
{
if
(
!
(
'
value
'
in
total
))
{
if
(
!
(
'
value
'
in
total
))
{
return
null
;
return
null
;
...
@@ -33,7 +34,7 @@ const TokenTransferListItem = ({ token, total, tx_hash: txHash, from, to, baseAd
...
@@ -33,7 +34,7 @@ const TokenTransferListItem = ({ token, total, tx_hash: txHash, from, to, baseAd
<
Flex
w=
"100%"
>
<
Flex
w=
"100%"
>
<
TokenSnippet
hash=
{
token
.
address
}
w=
"auto"
maxW=
"calc(100% - 140px)"
name=
{
token
.
name
||
'
Unnamed token
'
}
/>
<
TokenSnippet
hash=
{
token
.
address
}
w=
"auto"
maxW=
"calc(100% - 140px)"
name=
{
token
.
name
||
'
Unnamed token
'
}
/>
<
Tag
flexShrink=
{
0
}
ml=
{
2
}
mr=
"auto"
>
{
token
.
type
}
</
Tag
>
<
Tag
flexShrink=
{
0
}
ml=
{
2
}
mr=
"auto"
>
{
token
.
type
}
</
Tag
>
<
AdditionalInfoButton
/>
{
showTxInfo
&&
<
AdditionalInfoButton
/>
}
</
Flex
>
</
Flex
>
{
'
token_id
'
in
total
&&
(
{
'
token_id
'
in
total
&&
(
<
Flex
alignItems=
"center"
>
<
Flex
alignItems=
"center"
>
...
@@ -42,12 +43,14 @@ const TokenTransferListItem = ({ token, total, tx_hash: txHash, from, to, baseAd
...
@@ -42,12 +43,14 @@ const TokenTransferListItem = ({ token, total, tx_hash: txHash, from, to, baseAd
<
AddressLink
hash=
{
token
.
address
}
id=
{
total
.
token_id
}
type=
"token_instance_item"
/>
<
AddressLink
hash=
{
token
.
address
}
id=
{
total
.
token_id
}
type=
"token_instance_item"
/>
</
Flex
>
</
Flex
>
)
}
)
}
<
Flex
columnGap=
{
2
}
w=
"100%"
>
{
showTxInfo
&&
(
<
Text
fontWeight=
{
500
}
flexShrink=
{
0
}
>
Txn hash
</
Text
>
<
Flex
columnGap=
{
2
}
w=
"100%"
>
<
Address
display=
"inline-flex"
maxW=
"100%"
>
<
Text
fontWeight=
{
500
}
flexShrink=
{
0
}
>
Txn hash
</
Text
>
<
AddressLink
type=
"transaction"
hash=
{
txHash
}
/>
<
Address
display=
"inline-flex"
maxW=
"100%"
>
</
Address
>
<
AddressLink
type=
"transaction"
hash=
{
txHash
}
/>
</
Flex
>
</
Address
>
</
Flex
>
)
}
<
Flex
w=
"100%"
columnGap=
{
3
}
>
<
Flex
w=
"100%"
columnGap=
{
3
}
>
<
Address
width=
{
addressWidth
}
>
<
Address
width=
{
addressWidth
}
>
<
AddressIcon
hash=
{
from
.
hash
}
/>
<
AddressIcon
hash=
{
from
.
hash
}
/>
...
...
ui/shared/TokenTransfer/TokenTransferSkeletonMobile.tsx
View file @
741e498f
import
{
Skeleton
,
SkeletonCircle
,
Flex
,
Box
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
Skeleton
,
SkeletonCircle
,
Flex
,
Box
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
const
TokenTransferSkeletonMobile
=
()
=>
{
const
TokenTransferSkeletonMobile
=
(
{
showTxInfo
}:
{
showTxInfo
?:
boolean
}
)
=>
{
const
borderColor
=
useColorModeValue
(
'
blackAlpha.200
'
,
'
whiteAlpha.200
'
);
const
borderColor
=
useColorModeValue
(
'
blackAlpha.200
'
,
'
whiteAlpha.200
'
);
return
(
return
(
...
@@ -22,17 +22,19 @@ const TokenTransferSkeletonMobile = () => {
...
@@ -22,17 +22,19 @@ const TokenTransferSkeletonMobile = () => {
<
SkeletonCircle
size=
"6"
mr=
{
2
}
flexShrink=
{
0
}
/>
<
SkeletonCircle
size=
"6"
mr=
{
2
}
flexShrink=
{
0
}
/>
<
Skeleton
w=
"100px"
mr=
{
2
}
/>
<
Skeleton
w=
"100px"
mr=
{
2
}
/>
<
Skeleton
w=
"50px"
/>
<
Skeleton
w=
"50px"
/>
<
Skeleton
w=
"24px"
ml=
"auto"
/>
{
showTxInfo
&&
<
Skeleton
w=
"24px"
ml=
"auto"
/>
}
</
Flex
>
</
Flex
>
<
Flex
h=
{
6
}
columnGap=
{
2
}
>
<
Flex
h=
{
6
}
columnGap=
{
2
}
>
<
Skeleton
w=
"70px"
/>
<
Skeleton
w=
"70px"
/>
<
Skeleton
w=
"24px"
/>
<
Skeleton
w=
"24px"
/>
<
Skeleton
w=
"90px"
/>
<
Skeleton
w=
"90px"
/>
</
Flex
>
</
Flex
>
<
Flex
h=
{
6
}
columnGap=
{
2
}
>
{
showTxInfo
&&
(
<
Skeleton
w=
"70px"
flexShrink=
{
0
}
/>
<
Flex
h=
{
6
}
columnGap=
{
2
}
>
<
Skeleton
w=
"100%"
/>
<
Skeleton
w=
"70px"
flexShrink=
{
0
}
/>
</
Flex
>
<
Skeleton
w=
"100%"
/>
</
Flex
>
)
}
<
Flex
h=
{
6
}
>
<
Flex
h=
{
6
}
>
<
SkeletonCircle
size=
"6"
mr=
{
2
}
flexShrink=
{
0
}
/>
<
SkeletonCircle
size=
"6"
mr=
{
2
}
flexShrink=
{
0
}
/>
<
Skeleton
flexGrow=
{
1
}
mr=
{
3
}
/>
<
Skeleton
flexGrow=
{
1
}
mr=
{
3
}
/>
...
...
ui/shared/TokenTransfer/TokenTransferTable.tsx
View file @
741e498f
...
@@ -9,27 +9,28 @@ import TokenTransferTableItem from 'ui/shared/TokenTransfer/TokenTransferTableIt
...
@@ -9,27 +9,28 @@ import TokenTransferTableItem from 'ui/shared/TokenTransfer/TokenTransferTableIt
interface
Props
{
interface
Props
{
data
:
Array
<
TokenTransfer
>
;
data
:
Array
<
TokenTransfer
>
;
baseAddress
?:
string
;
baseAddress
?:
string
;
showTxInfo
?:
boolean
;
}
}
const
TxInternalsTable
=
({
data
,
baseAddress
}:
Props
)
=>
{
const
TxInternalsTable
=
({
data
,
baseAddress
,
showTxInfo
}:
Props
)
=>
{
return
(
return
(
<
Table
variant=
"simple"
size=
"sm"
mt=
{
6
}
>
<
Table
variant=
"simple"
size=
"sm"
>
<
Thead
top=
{
0
}
>
<
Thead
top=
{
8
0
}
>
<
Tr
>
<
Tr
>
<
Th
width=
"44px"
></
Th
>
{
showTxInfo
&&
<
Th
width=
"44px"
></
Th
>
}
<
Th
width=
"185px"
>
Token
</
Th
>
<
Th
width=
"185px"
>
Token
</
Th
>
<
Th
width=
"160px"
>
Token ID
</
Th
>
<
Th
width=
"160px"
>
Token ID
</
Th
>
<
Th
width=
"25%"
>
Txn hash
</
Th
>
{
showTxInfo
&&
<
Th
width=
"25%"
>
Txn hash
</
Th
>
}
<
Th
width=
"25%"
>
From
</
Th
>
<
Th
width=
"25%"
>
From
</
Th
>
{
baseAddress
&&
<
Th
width=
"50px"
px=
{
0
}
/>
}
{
baseAddress
&&
<
Th
width=
"50px"
px=
{
0
}
/>
}
<
Th
width=
"25%"
>
To
</
Th
>
<
Th
width=
"25%"
>
To
</
Th
>
<
Th
width=
"25%"
>
Value
</
Th
>
<
Th
width=
"25%"
isNumeric
>
Value
</
Th
>
</
Tr
>
</
Tr
>
</
Thead
>
</
Thead
>
<
Tbody
>
<
Tbody
>
{
data
.
map
((
item
,
index
)
=>
(
{
data
.
map
((
item
,
index
)
=>
(
<
TokenTransferTableItem
key=
{
index
}
{
...
item
}
baseAddress=
{
baseAddress
}
/>
<
TokenTransferTableItem
key=
{
index
}
{
...
item
}
baseAddress=
{
baseAddress
}
showTxInfo=
{
showTxInfo
}
/>
))
}
))
}
</
Tbody
>
</
Tbody
>
</
Table
>
</
Table
>
...
...
ui/shared/TokenTransfer/TokenTransferTableItem.tsx
View file @
741e498f
...
@@ -14,9 +14,10 @@ import TokenSnippet from 'ui/shared/TokenSnippet';
...
@@ -14,9 +14,10 @@ import TokenSnippet from 'ui/shared/TokenSnippet';
type
Props
=
TokenTransfer
&
{
type
Props
=
TokenTransfer
&
{
baseAddress
?:
string
;
baseAddress
?:
string
;
showTxInfo
?:
boolean
;
}
}
const
TxInternalTableItem
=
({
token
,
total
,
tx_hash
:
txHash
,
from
,
to
,
baseAddress
}:
Props
)
=>
{
const
TxInternalTableItem
=
({
token
,
total
,
tx_hash
:
txHash
,
from
,
to
,
baseAddress
,
showTxInfo
}:
Props
)
=>
{
const
value
=
(()
=>
{
const
value
=
(()
=>
{
if
(
!
(
'
value
'
in
total
))
{
if
(
!
(
'
value
'
in
total
))
{
return
'
-
'
;
return
'
-
'
;
...
@@ -27,9 +28,11 @@ const TxInternalTableItem = ({ token, total, tx_hash: txHash, from, to, baseAddr
...
@@ -27,9 +28,11 @@ const TxInternalTableItem = ({ token, total, tx_hash: txHash, from, to, baseAddr
return
(
return
(
<
Tr
alignItems=
"top"
>
<
Tr
alignItems=
"top"
>
<
Td
>
{
showTxInfo
&&
(
<
AdditionalInfoButton
/>
<
Td
>
</
Td
>
<
AdditionalInfoButton
/>
</
Td
>
)
}
<
Td
>
<
Td
>
<
Flex
flexDir=
"column"
alignItems=
"flex-start"
>
<
Flex
flexDir=
"column"
alignItems=
"flex-start"
>
<
TokenSnippet
hash=
{
token
.
address
}
name=
{
token
.
name
||
'
Unnamed token
'
}
lineHeight=
"30px"
/>
<
TokenSnippet
hash=
{
token
.
address
}
name=
{
token
.
name
||
'
Unnamed token
'
}
lineHeight=
"30px"
/>
...
@@ -44,11 +47,13 @@ const TxInternalTableItem = ({ token, total, tx_hash: txHash, from, to, baseAddr
...
@@ -44,11 +47,13 @@ const TxInternalTableItem = ({ token, total, tx_hash: txHash, from, to, baseAddr
</
Flex
>
</
Flex
>
)
:
'
-
'
}
)
:
'
-
'
}
</
Td
>
</
Td
>
<
Td
>
{
showTxInfo
&&
(
<
Address
display=
"inline-flex"
maxW=
"100%"
fontWeight=
{
600
}
lineHeight=
"30px"
>
<
Td
>
<
AddressLink
type=
"transaction"
hash=
{
txHash
}
/>
<
Address
display=
"inline-flex"
maxW=
"100%"
fontWeight=
{
600
}
lineHeight=
"30px"
>
</
Address
>
<
AddressLink
type=
"transaction"
hash=
{
txHash
}
/>
</
Td
>
</
Address
>
</
Td
>
)
}
<
Td
>
<
Td
>
<
Address
display=
"inline-flex"
maxW=
"100%"
lineHeight=
"30px"
>
<
Address
display=
"inline-flex"
maxW=
"100%"
lineHeight=
"30px"
>
<
AddressIcon
hash=
{
from
.
hash
}
/>
<
AddressIcon
hash=
{
from
.
hash
}
/>
...
...
ui/tx/TxTokenTransfer.tsx
View file @
741e498f
import
{
Text
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
{
QueryKeys
}
from
'
types/client/queries
'
;
...
@@ -20,17 +21,20 @@ const TxTokenTransfer = () => {
...
@@ -20,17 +21,20 @@ const TxTokenTransfer = () => {
return
<
DataFetchAlert
/>;
return
<
DataFetchAlert
/>;
}
}
const
queryKey
=
[
QueryKeys
.
txTokenTransfers
,
data
?.
hash
];
const
path
=
`/node-api/transactions/
${
data
?.
hash
}
/token-transfers`
;
const
path
=
`/node-api/transactions/
${
data
?.
hash
}
/token-transfers`
;
return
(
return
(
<
TokenTransfer
<>
isLoading=
{
isLoading
}
<
Text
>
Token transfers for transaction
{
data
?.
hash
}
</
Text
>
isDisabled=
{
!
data
?.
status
||
!
data
?.
hash
}
<
TokenTransfer
path=
{
path
}
isLoading=
{
isLoading
}
queryKey=
{
queryKey
}
isDisabled=
{
!
data
?.
status
||
!
data
?.
hash
}
// todo_tom delete me
path=
{
path
}
baseAddress=
"0xd789a607CEac2f0E14867de4EB15b15C9FFB5859"
/>
queryName=
{
QueryKeys
.
txTokenTransfers
}
queryIds=
{
data
?.
hash
?
[
data
.
hash
]
:
undefined
}
showTxInfo=
{
false
}
/>
</>
);
);
};
};
...
...
ui/txs/TxsContent.tsx
View file @
741e498f
...
@@ -62,7 +62,11 @@ const TxsContent = ({
...
@@ -62,7 +62,11 @@ const TxsContent = ({
isLoading
,
isLoading
,
isError
,
isError
,
pagination
,
pagination
,
}
=
useQueryWithPages
<
TransactionsResponse
>
(
apiPath
,
queryName
,
stateFilter
&&
{
filter
:
stateFilter
});
}
=
useQueryWithPages
<
TransactionsResponse
>
({
apiPath
,
queryName
,
filters
:
stateFilter
?
{
filter
:
stateFilter
}
:
undefined
,
});
// } = useQueryWithPages({ ...filters, filter: stateFilter, apiPath });
// } = useQueryWithPages({ ...filters, filter: stateFilter, apiPath });
const
content
=
(()
=>
{
const
content
=
(()
=>
{
...
...
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