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
c91f469d
Commit
c91f469d
authored
May 25, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
skeletons for coin balance history
parent
40109a61
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
36 deletions
+85
-36
address.ts
stubs/address.ts
+10
-1
AddressCoinBalance.tsx
ui/address/AddressCoinBalance.tsx
+15
-1
AddressCoinBalanceHistory.tsx
ui/address/coinBalance/AddressCoinBalanceHistory.tsx
+15
-5
AddressCoinBalanceListItem.tsx
ui/address/coinBalance/AddressCoinBalanceListItem.tsx
+23
-16
AddressCoinBalanceTableItem.tsx
ui/address/coinBalance/AddressCoinBalanceTableItem.tsx
+22
-13
No files found.
stubs/address.ts
View file @
c91f469d
import
type
{
Address
,
AddressCounters
}
from
'
types/api/address
'
;
import
type
{
Address
,
AddressCo
inBalanceHistoryItem
,
AddressCo
unters
}
from
'
types/api/address
'
;
import
type
{
AddressesItem
}
from
'
types/api/addresses
'
;
import
{
ADDRESS_HASH
}
from
'
./addressParams
'
;
import
{
TOKEN_INFO_ERC_20
}
from
'
./token
'
;
import
{
TX_HASH
}
from
'
./tx
'
;
export
const
ADDRESS_INFO
:
Address
=
{
block_number_balance_updated_at
:
8774377
,
...
...
@@ -53,3 +54,11 @@ export const TOP_ADDRESS: AddressesItem = {
public_tags
:
[
],
watchlist_names
:
[],
};
export
const
ADDRESS_COIN_BALANCE
:
AddressCoinBalanceHistoryItem
=
{
block_number
:
9004413
,
block_timestamp
:
'
2023-05-15T13:16:24Z
'
,
delta
:
'
1000000000000000000
'
,
transaction_hash
:
TX_HASH
,
value
:
'
953427250000000000000000
'
,
};
ui/address/AddressCoinBalance.tsx
View file @
c91f469d
...
...
@@ -10,6 +10,8 @@ import useQueryWithPages from 'lib/hooks/useQueryWithPages';
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
useSocketChannel
from
'
lib/socket/useSocketChannel
'
;
import
useSocketMessage
from
'
lib/socket/useSocketMessage
'
;
import
{
ADDRESS_COIN_BALANCE
}
from
'
stubs/address
'
;
import
{
generateListStub
}
from
'
stubs/utils
'
;
import
SocketAlert
from
'
ui/shared/SocketAlert
'
;
import
AddressCoinBalanceChart
from
'
./coinBalance/AddressCoinBalanceChart
'
;
...
...
@@ -26,6 +28,18 @@ const AddressCoinBalance = () => {
resourceName
:
'
address_coin_balance
'
,
pathParams
:
{
hash
:
addressHash
},
scrollRef
,
options
:
{
placeholderData
:
generateListStub
<
'
address_coin_balance
'
>
(
ADDRESS_COIN_BALANCE
,
50
,
{
next_page_params
:
{
block_number
:
8009880
,
items_count
:
50
,
},
},
),
},
});
const
handleSocketError
=
React
.
useCallback
(()
=>
{
...
...
@@ -56,7 +70,7 @@ const AddressCoinBalance = () => {
topic
:
`addresses:
${
addressHash
.
toLowerCase
()
}
`
,
onSocketClose
:
handleSocketError
,
onSocketError
:
handleSocketError
,
isDisabled
:
!
addressHash
||
coinBalanceQuery
.
pagination
.
page
!==
1
,
isDisabled
:
!
addressHash
||
coinBalanceQuery
.
isPlaceholderData
||
coinBalanceQuery
.
pagination
.
page
!==
1
,
});
useSocketMessage
({
channel
,
...
...
ui/address/coinBalance/AddressCoinBalanceHistory.tsx
View file @
c91f469d
...
...
@@ -37,15 +37,25 @@ const AddressCoinBalanceHistory = ({ query }: Props) => {
</
Tr
>
</
Thead
>
<
Tbody
>
{
query
.
data
.
items
.
map
((
item
)
=>
(
<
AddressCoinBalanceTableItem
key=
{
item
.
block_number
}
{
...
item
}
page=
{
query
.
pagination
.
page
}
/>
{
query
.
data
.
items
.
map
((
item
,
index
)
=>
(
<
AddressCoinBalanceTableItem
key=
{
item
.
block_number
+
(
query
.
isPlaceholderData
?
String
(
index
)
:
''
)
}
{
...
item
}
page=
{
query
.
pagination
.
page
}
isLoading=
{
query
.
isPlaceholderData
}
/>
))
}
</
Tbody
>
</
Table
>
</
Hide
>
<
Show
below=
"lg"
ssr=
{
false
}
>
{
query
.
data
.
items
.
map
((
item
)
=>
(
<
AddressCoinBalanceListItem
key=
{
item
.
block_number
}
{
...
item
}
page=
{
query
.
pagination
.
page
}
/>
{
query
.
data
.
items
.
map
((
item
,
index
)
=>
(
<
AddressCoinBalanceListItem
key=
{
item
.
block_number
+
(
query
.
isPlaceholderData
?
String
(
index
)
:
''
)
}
{
...
item
}
page=
{
query
.
pagination
.
page
}
isLoading=
{
query
.
isPlaceholderData
}
/>
))
}
</
Show
>
</>
...
...
@@ -61,7 +71,7 @@ const AddressCoinBalanceHistory = ({ query }: Props) => {
<
DataListDisplay
mt=
{
8
}
isError=
{
query
.
isError
}
isLoading=
{
query
.
isLoading
}
isLoading=
{
false
}
items=
{
query
.
data
?.
items
}
skeletonProps=
{
{
skeletonDesktopColumns
:
[
'
25%
'
,
'
25%
'
,
'
25%
'
,
'
25%
'
,
'
120px
'
]
}
}
emptyText=
"There is no coin balance history for this address."
...
...
ui/address/coinBalance/AddressCoinBalanceListItem.tsx
View file @
c91f469d
import
{
Text
,
Stat
,
StatHelpText
,
StatArrow
,
Flex
}
from
'
@chakra-ui/react
'
;
import
{
Text
,
Stat
,
StatHelpText
,
StatArrow
,
Flex
,
Skeleton
}
from
'
@chakra-ui/react
'
;
import
BigNumber
from
'
bignumber.js
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
React
from
'
react
'
;
...
...
@@ -15,6 +15,7 @@ import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
type
Props
=
AddressCoinBalanceHistoryItem
&
{
page
:
number
;
isLoading
:
boolean
;
};
const
AddressCoinBalanceListItem
=
(
props
:
Props
)
=>
{
...
...
@@ -26,7 +27,10 @@ const AddressCoinBalanceListItem = (props: Props) => {
return
(
<
ListItemMobile
rowGap=
{
2
}
isAnimated
>
<
Flex
justifyContent=
"space-between"
w=
"100%"
>
<
Text
fontWeight=
{
600
}
>
{
BigNumber
(
props
.
value
).
div
(
WEI
).
dp
(
8
).
toFormat
()
}
{
appConfig
.
network
.
currency
.
symbol
}
</
Text
>
<
Skeleton
isLoaded=
{
!
props
.
isLoading
}
fontWeight=
{
600
}
>
{
BigNumber
(
props
.
value
).
div
(
WEI
).
dp
(
8
).
toFormat
()
}
{
appConfig
.
network
.
currency
.
symbol
}
</
Skeleton
>
<
Skeleton
isLoaded=
{
!
props
.
isLoading
}
>
<
Stat
flexGrow=
"0"
>
<
StatHelpText
display=
"flex"
mb=
{
0
}
alignItems=
"center"
>
<
StatArrow
type=
{
isPositiveDelta
?
'
increase
'
:
'
decrease
'
}
/>
...
...
@@ -35,22 +39,25 @@ const AddressCoinBalanceListItem = (props: Props) => {
</
Text
>
</
StatHelpText
>
</
Stat
>
</
Skeleton
>
</
Flex
>
<
Flex
columnGap=
{
2
}
w=
"100%"
>
<
Text
fontWeight=
{
500
}
flexShrink=
{
0
}
>
Block
</
Text
>
<
Skeleton
isLoaded=
{
!
props
.
isLoading
}
fontWeight=
{
500
}
flexShrink=
{
0
}
>
Block
</
Skeleton
>
<
Skeleton
isLoaded=
{
!
props
.
isLoading
}
>
<
LinkInternal
href=
{
blockUrl
}
fontWeight=
"700"
>
{
props
.
block_number
}
</
LinkInternal
>
</
Skeleton
>
</
Flex
>
{
props
.
transaction_hash
&&
(
<
Flex
columnGap=
{
2
}
w=
"100%"
>
<
Text
fontWeight=
{
500
}
flexShrink=
{
0
}
>
Txs
</
Text
>
<
Skeleton
isLoaded=
{
!
props
.
isLoading
}
fontWeight=
{
500
}
flexShrink=
{
0
}
>
Txs
</
Skeleton
>
<
Address
maxW=
"150px"
fontWeight=
"700"
>
<
AddressLink
hash=
{
props
.
transaction_hash
}
type=
"transaction"
/>
<
AddressLink
hash=
{
props
.
transaction_hash
}
type=
"transaction"
isLoading=
{
props
.
isLoading
}
/>
</
Address
>
</
Flex
>
)
}
<
Flex
columnGap=
{
2
}
w=
"100%"
>
<
Text
fontWeight=
{
500
}
flexShrink=
{
0
}
>
Age
</
Text
>
<
Text
variant=
"secondary"
>
{
timeAgo
}
</
Text
>
<
Skeleton
isLoaded=
{
!
props
.
isLoading
}
fontWeight=
{
500
}
flexShrink=
{
0
}
>
Age
</
Skeleton
>
<
Skeleton
isLoaded=
{
!
props
.
isLoading
}
variant=
"secondary"
>
{
timeAgo
}
</
Skeleton
>
</
Flex
>
</
ListItemMobile
>
);
...
...
ui/address/coinBalance/AddressCoinBalanceTableItem.tsx
View file @
c91f469d
import
{
Td
,
Tr
,
Text
,
Stat
,
StatHelpText
,
StatArrow
}
from
'
@chakra-ui/react
'
;
import
{
Td
,
Tr
,
Text
,
Stat
,
StatHelpText
,
StatArrow
,
Skeleton
}
from
'
@chakra-ui/react
'
;
import
BigNumber
from
'
bignumber.js
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
React
from
'
react
'
;
...
...
@@ -13,6 +13,7 @@ import LinkInternal from 'ui/shared/LinkInternal';
type
Props
=
AddressCoinBalanceHistoryItem
&
{
page
:
number
;
isLoading
:
boolean
;
};
const
AddressCoinBalanceTableItem
=
(
props
:
Props
)
=>
{
...
...
@@ -24,24 +25,31 @@ const AddressCoinBalanceTableItem = (props: Props) => {
return
(
<
Tr
>
<
Td
>
<
Skeleton
isLoaded=
{
!
props
.
isLoading
}
display=
"inline-block"
>
<
LinkInternal
href=
{
blockUrl
}
fontWeight=
"700"
>
{
props
.
block_number
}
</
LinkInternal
>
</
Skeleton
>
</
Td
>
<
Td
>
{
props
.
transaction_hash
&&
(
<
Address
w=
"150px"
fontWeight=
"700"
>
<
AddressLink
hash=
{
props
.
transaction_hash
}
type=
"transaction"
/>
<
AddressLink
hash=
{
props
.
transaction_hash
}
type=
"transaction"
isLoading=
{
props
.
isLoading
}
/>
</
Address
>
)
}
</
Td
>
<
Td
>
<
Text
variant=
"secondary"
>
{
timeAgo
}
</
Text
>
<
Skeleton
isLoaded=
{
!
props
.
isLoading
}
color=
"text_secondary"
display=
"inline-block"
>
<
span
>
{
timeAgo
}
</
span
>
</
Skeleton
>
</
Td
>
<
Td
isNumeric
pr=
{
1
}
>
<
Text
>
{
BigNumber
(
props
.
value
).
div
(
WEI
).
dp
(
8
).
toFormat
()
}
</
Text
>
<
Skeleton
isLoaded=
{
!
props
.
isLoading
}
color=
"text_secondary"
display=
"inline-block"
>
<
span
>
{
BigNumber
(
props
.
value
).
div
(
WEI
).
dp
(
8
).
toFormat
()
}
</
span
>
</
Skeleton
>
</
Td
>
<
Td
isNumeric
display=
"flex"
justifyContent=
"end"
>
<
Skeleton
isLoaded=
{
!
props
.
isLoading
}
>
<
Stat
flexGrow=
"0"
>
<
StatHelpText
display=
"flex"
mb=
{
0
}
alignItems=
"center"
>
<
StatArrow
type=
{
isPositiveDelta
?
'
increase
'
:
'
decrease
'
}
/>
...
...
@@ -50,6 +58,7 @@ const AddressCoinBalanceTableItem = (props: Props) => {
</
Text
>
</
StatHelpText
>
</
Stat
>
</
Skeleton
>
</
Td
>
</
Tr
>
);
...
...
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