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
ecd41ca9
Commit
ecd41ca9
authored
Mar 20, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
column for token id
parent
f624bbc9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
59 deletions
+55
-59
txStateChanges.ts
types/api/txStateChanges.ts
+1
-1
HashStringShorten.tsx
ui/shared/HashStringShorten.tsx
+4
-0
TokenTransferNft.tsx
ui/shared/TokenTransfer/TokenTransferNft.tsx
+4
-2
TxStateListItem.tsx
ui/tx/state/TxStateListItem.tsx
+7
-1
TxStateTable.tsx
ui/tx/state/TxStateTable.tsx
+1
-0
TxStateTableItem.tsx
ui/tx/state/TxStateTableItem.tsx
+2
-1
utils.tsx
ui/tx/state/utils.tsx
+36
-54
No files found.
types/api/txStateChanges.ts
View file @
ecd41ca9
...
@@ -38,7 +38,7 @@ export interface TxStateChangeTokenErc721 {
...
@@ -38,7 +38,7 @@ export interface TxStateChangeTokenErc721 {
export
interface
TxStateChangeTokenErc1155
{
export
interface
TxStateChangeTokenErc1155
{
type
:
'
token
'
;
type
:
'
token
'
;
token
:
TokenInfo
<
'
ERC-1155
'
>
;
token
:
TokenInfo
<
'
ERC-1155
'
>
;
change
:
Array
<
NftTokenChange
<
Erc1155TotalPayload
|
Array
<
Erc1155TotalPayload
>
>>
;
change
:
Array
<
NftTokenChange
<
Erc1155TotalPayload
>>
;
}
}
export
type
TxStateChanges
=
Array
<
TxStateChange
>
;
export
type
TxStateChanges
=
Array
<
TxStateChange
>
;
ui/shared/HashStringShorten.tsx
View file @
ecd41ca9
...
@@ -7,6 +7,10 @@ interface Props {
...
@@ -7,6 +7,10 @@ interface Props {
}
}
const
HashStringShorten
=
({
hash
,
isTooltipDisabled
}:
Props
)
=>
{
const
HashStringShorten
=
({
hash
,
isTooltipDisabled
}:
Props
)
=>
{
if
(
hash
.
length
<=
8
)
{
return
<
span
>
{
hash
}
</
span
>;
}
return
(
return
(
<
Tooltip
label=
{
hash
}
isDisabled=
{
isTooltipDisabled
}
>
<
Tooltip
label=
{
hash
}
isDisabled=
{
isTooltipDisabled
}
>
{
hash
.
slice
(
0
,
4
)
+
'
...
'
+
hash
.
slice
(
-
4
)
}
{
hash
.
slice
(
0
,
4
)
+
'
...
'
+
hash
.
slice
(
-
4
)
}
...
...
ui/shared/TokenTransfer/TokenTransferNft.tsx
View file @
ecd41ca9
...
@@ -3,6 +3,7 @@ import { route } from 'nextjs-routes';
...
@@ -3,6 +3,7 @@ import { route } from 'nextjs-routes';
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
nftPlaceholder
from
'
icons/nft_shield.svg
'
;
import
nftPlaceholder
from
'
icons/nft_shield.svg
'
;
import
HashStringShorten
from
'
ui/shared/HashStringShorten
'
;
import
HashStringShortenDynamic
from
'
ui/shared/HashStringShortenDynamic
'
;
import
HashStringShortenDynamic
from
'
ui/shared/HashStringShortenDynamic
'
;
import
LinkInternal
from
'
ui/shared/LinkInternal
'
;
import
LinkInternal
from
'
ui/shared/LinkInternal
'
;
...
@@ -11,9 +12,10 @@ interface Props {
...
@@ -11,9 +12,10 @@ interface Props {
id
:
string
;
id
:
string
;
className
?:
string
;
className
?:
string
;
isDisabled
?:
boolean
;
isDisabled
?:
boolean
;
truncation
?:
'
dynamic
'
|
'
constant
'
;
}
}
const
TokenTransferNft
=
({
hash
,
id
,
className
,
isDisabled
}:
Props
)
=>
{
const
TokenTransferNft
=
({
hash
,
id
,
className
,
isDisabled
,
truncation
=
'
dynamic
'
}:
Props
)
=>
{
const
Component
=
isDisabled
?
Box
:
LinkInternal
;
const
Component
=
isDisabled
?
Box
:
LinkInternal
;
return
(
return
(
...
@@ -28,7 +30,7 @@ const TokenTransferNft = ({ hash, id, className, isDisabled }: Props) => {
...
@@ -28,7 +30,7 @@ const TokenTransferNft = ({ hash, id, className, isDisabled }: Props) => {
>
>
<
Icon
as=
{
nftPlaceholder
}
boxSize=
"30px"
mr=
{
1
}
color=
"inherit"
/>
<
Icon
as=
{
nftPlaceholder
}
boxSize=
"30px"
mr=
{
1
}
color=
"inherit"
/>
<
Box
maxW=
"calc(100% - 34px)"
>
<
Box
maxW=
"calc(100% - 34px)"
>
<
HashStringShortenDynamic
hash=
{
id
}
fontWeight=
{
500
}
/>
{
truncation
===
'
constant
'
?
<
HashStringShorten
hash=
{
id
}
/>
:
<
HashStringShortenDynamic
hash=
{
id
}
fontWeight=
{
500
}
/>
}
</
Box
>
</
Box
>
</
Component
>
</
Component
>
);
);
...
...
ui/tx/state/TxStateListItem.tsx
View file @
ecd41ca9
...
@@ -16,7 +16,7 @@ interface Props {
...
@@ -16,7 +16,7 @@ interface Props {
const
TxStateListItem
=
({
data
}:
Props
)
=>
{
const
TxStateListItem
=
({
data
}:
Props
)
=>
{
const
{
before
,
after
,
change
,
hint
}
=
getStateElements
(
data
);
const
{
before
,
after
,
change
,
hint
,
tokenId
}
=
getStateElements
(
data
);
return
(
return
(
<
ListItemMobile
>
<
ListItemMobile
>
...
@@ -40,6 +40,12 @@ const TxStateListItem = ({ data }: Props) => {
...
@@ -40,6 +40,12 @@ const TxStateListItem = ({ data }: Props) => {
)
}
)
}
<
GridItem
fontWeight=
{
500
}
>
Change
</
GridItem
>
<
GridItem
fontWeight=
{
500
}
>
Change
</
GridItem
>
<
GridItem
>
{
change
}
</
GridItem
>
<
GridItem
>
{
change
}
</
GridItem
>
{
tokenId
&&
(
<>
<
GridItem
fontWeight=
{
500
}
>
Token ID
</
GridItem
>
<
GridItem
>
{
tokenId
}
</
GridItem
>
</>
)
}
</
Grid
>
</
Grid
>
</
ListItemMobile
>
</
ListItemMobile
>
);
);
...
...
ui/tx/state/TxStateTable.tsx
View file @
ecd41ca9
...
@@ -25,6 +25,7 @@ const TxStateTable = ({ data }: Props) => {
...
@@ -25,6 +25,7 @@ const TxStateTable = ({ data }: Props) => {
<
Th
width=
"33%"
isNumeric
>
Before
</
Th
>
<
Th
width=
"33%"
isNumeric
>
Before
</
Th
>
<
Th
width=
"33%"
isNumeric
>
After
</
Th
>
<
Th
width=
"33%"
isNumeric
>
After
</
Th
>
<
Th
width=
"33%"
isNumeric
>
Change
</
Th
>
<
Th
width=
"33%"
isNumeric
>
Change
</
Th
>
<
Th
width=
"150px"
minW=
"80px"
maxW=
"150px"
>
Token ID
</
Th
>
</
Tr
>
</
Tr
>
</
Thead
>
</
Thead
>
<
Tbody
>
<
Tbody
>
...
...
ui/tx/state/TxStateTableItem.tsx
View file @
ecd41ca9
...
@@ -14,7 +14,7 @@ interface Props {
...
@@ -14,7 +14,7 @@ interface Props {
}
}
const
TxStateTableItem
=
({
data
}:
Props
)
=>
{
const
TxStateTableItem
=
({
data
}:
Props
)
=>
{
const
{
before
,
after
,
change
,
hint
}
=
getStateElements
(
data
);
const
{
before
,
after
,
change
,
hint
,
tokenId
}
=
getStateElements
(
data
);
return
(
return
(
<
Tr
>
<
Tr
>
...
@@ -30,6 +30,7 @@ const TxStateTableItem = ({ data }: Props) => {
...
@@ -30,6 +30,7 @@ const TxStateTableItem = ({ data }: Props) => {
<
Td
isNumeric
lineHeight=
"30px"
>
{
before
}
</
Td
>
<
Td
isNumeric
lineHeight=
"30px"
>
{
before
}
</
Td
>
<
Td
isNumeric
lineHeight=
"30px"
>
{
after
}
</
Td
>
<
Td
isNumeric
lineHeight=
"30px"
>
{
after
}
</
Td
>
<
Td
isNumeric
lineHeight=
"30px"
>
{
change
}
</
Td
>
<
Td
isNumeric
lineHeight=
"30px"
>
{
change
}
</
Td
>
<
Td
lineHeight=
"30px"
>
{
tokenId
||
'
-
'
}
</
Td
>
</
Tr
>
</
Tr
>
);
);
};
};
...
...
ui/tx/state/utils.tsx
View file @
ecd41ca9
import
{
Box
,
Flex
,
Stat
,
StatArrow
,
StatHelpText
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
Flex
}
from
'
@chakra-ui/react
'
;
import
BigNumber
from
'
bignumber.js
'
;
import
BigNumber
from
'
bignumber.js
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -25,12 +25,16 @@ export function getStateElements(data: TxStateChange) {
...
@@ -25,12 +25,16 @@ export function getStateElements(data: TxStateChange) {
}
}
if
(
data
.
address
.
hash
===
ZERO_ADDRESS
)
{
if
(
data
.
address
.
hash
===
ZERO_ADDRESS
)
{
return
(
const
changeDirection
=
Array
.
isArray
(
data
.
change
)
?
data
.
change
[
0
].
direction
:
null
;
<
Flex
align=
"center"
columnGap=
{
1
}
>
if
(
changeDirection
)
{
<
Hint
label=
"Address used in tokens mintings and burnings"
/>
const
text
=
changeDirection
===
'
from
'
?
'
Mint
'
:
'
Burn
'
;
<
Box
color=
"text_secondary"
whiteSpace=
"nowrap"
>
Burn address
</
Box
>
return
(
</
Flex
>
<
Flex
align=
"center"
columnGap=
{
1
}
>
);
<
Hint
label=
"Address used in tokens mintings and burnings"
/>
<
Box
color=
"text_secondary"
whiteSpace=
"nowrap"
>
{
text
}
address
</
Box
>
</
Flex
>
);
}
}
}
return
null
;
return
null
;
...
@@ -41,85 +45,63 @@ export function getStateElements(data: TxStateChange) {
...
@@ -41,85 +45,63 @@ export function getStateElements(data: TxStateChange) {
const
beforeBn
=
BigNumber
(
data
.
balance_before
||
'
0
'
).
div
(
10
**
appConfig
.
network
.
currency
.
decimals
);
const
beforeBn
=
BigNumber
(
data
.
balance_before
||
'
0
'
).
div
(
10
**
appConfig
.
network
.
currency
.
decimals
);
const
afterBn
=
BigNumber
(
data
.
balance_after
||
'
0
'
).
div
(
10
**
appConfig
.
network
.
currency
.
decimals
);
const
afterBn
=
BigNumber
(
data
.
balance_after
||
'
0
'
).
div
(
10
**
appConfig
.
network
.
currency
.
decimals
);
const
differenceBn
=
afterBn
.
minus
(
beforeBn
);
const
differenceBn
=
afterBn
.
minus
(
beforeBn
);
const
changeColor
=
beforeBn
.
lte
(
afterBn
)
?
'
green.500
'
:
'
red.500
'
;
const
changeSign
=
beforeBn
.
lte
(
afterBn
)
?
'
+
'
:
'
-
'
;
return
{
return
{
before
:
<
Box
>
{
beforeBn
.
toFormat
()
}
{
appConfig
.
network
.
currency
.
symbol
}
</
Box
>,
before
:
<
Box
>
{
beforeBn
.
toFormat
()
}
{
appConfig
.
network
.
currency
.
symbol
}
</
Box
>,
after
:
<
Box
>
{
afterBn
.
toFormat
()
}
{
appConfig
.
network
.
currency
.
symbol
}
</
Box
>,
after
:
<
Box
>
{
afterBn
.
toFormat
()
}
{
appConfig
.
network
.
currency
.
symbol
}
</
Box
>,
change
:
(
change
:
<
Box
color=
{
changeColor
}
>
{
changeSign
}{
nbsp
}{
differenceBn
.
abs
().
toFormat
()
}
</
Box
>,
<
Stat
>
{
differenceBn
.
toFormat
()
}
<
StatArrow
ml=
{
2
}
type=
{
beforeBn
.
lte
(
afterBn
)
?
'
increase
'
:
'
decrease
'
}
/>
</
Stat
>
),
hint
,
hint
,
};
};
}
}
case
'
token
'
:
{
case
'
token
'
:
{
const
tokenLink
=
<
AddressLink
type=
"token"
hash=
{
data
.
token
.
address
}
alias=
{
trimTokenSymbol
(
data
.
token
?.
symbol
||
data
.
token
.
address
)
}
/>;
const
tokenLink
=
<
AddressLink
type=
"token"
hash=
{
data
.
token
.
address
}
alias=
{
trimTokenSymbol
(
data
.
token
?.
symbol
||
data
.
token
.
address
)
}
/>;
const
before
=
Number
(
data
.
balance_before
);
const
after
=
Number
(
data
.
balance_after
);
const
difference
=
after
-
before
;
const
changeColor
=
difference
>=
0
?
'
green.500
'
:
'
red.500
'
;
const
changeSign
=
difference
>=
0
?
'
+
'
:
'
-
'
;
const
tokenIdValue
=
Array
.
isArray
(
data
.
change
)
?
data
.
change
[
0
].
total
.
token_id
:
null
;
const
change
=
(()
=>
{
const
change
=
(()
=>
{
const
difference
=
Number
(
data
.
balance_after
)
-
Number
(
data
.
balance_before
);
if
(
!
before
&&
!
after
&&
data
.
address
.
hash
===
ZERO_ADDRESS
)
{
const
changeDirection
=
Array
.
isArray
(
data
.
change
)
?
data
.
change
[
0
].
direction
:
null
;
switch
(
data
.
token
.
type
)
{
if
(
changeDirection
)
{
case
'
ERC-20
'
:
{
return
(
return
(
<
Stat
>
<
Box
color=
{
changeDirection
===
'
from
'
?
'
green.500
'
:
'
red.500
'
}
>
<
StatHelpText
display=
"flex"
justifyContent=
{
{
base
:
'
flex-start
'
,
lg
:
'
flex-end
'
}
}
alignItems=
"center"
flexWrap=
"nowrap"
>
{
changeDirection
===
'
from
'
?
'
Mint
'
:
'
Burn
'
}
{
difference
}{
nbsp
}
</
Box
>
{
tokenLink
}
<
StatArrow
ml=
{
2
}
type=
{
difference
>
0
?
'
increase
'
:
'
decrease
'
}
/>
</
StatHelpText
>
</
Stat
>
);
);
}
}
case
'
ERC-721
'
:
}
case
'
ERC-1155
'
:
{
if
(
typeof
data
.
change
===
'
string
'
)
{
return
null
;
}
return
data
.
change
.
map
((
item
,
index
)
=>
{
if
(
Array
.
isArray
(
item
.
total
))
{
return
item
.
total
.
map
((
element
,
index
)
=>
{
return
(
<
Stat
key=
{
index
}
>
<
StatHelpText
display=
"flex"
justifyContent=
{
{
base
:
'
flex-start
'
,
lg
:
'
flex-end
'
}
}
alignItems=
"center"
flexWrap=
"nowrap"
>
<
TokenTransferNft
hash=
{
data
.
token
.
address
}
id=
{
element
.
token_id
}
w=
"auto"
/>
<
StatArrow
ml=
{
2
}
type=
{
item
.
direction
===
'
to
'
?
'
increase
'
:
'
decrease
'
}
/>
</
StatHelpText
>
</
Stat
>
);
});
}
return
(
if
(
!
difference
)
{
<
Stat
key=
{
index
}
>
return
<
Box
>
0
</
Box
>;
<
StatHelpText
display=
"flex"
justifyContent=
{
{
base
:
'
flex-start
'
,
lg
:
'
flex-end
'
}
}
alignItems=
"center"
flexWrap=
"nowrap"
>
<
TokenTransferNft
hash=
{
data
.
token
.
address
}
id=
{
item
.
total
.
token_id
}
w=
"auto"
/>
<
StatArrow
ml=
{
2
}
type=
{
item
.
direction
===
'
to
'
?
'
increase
'
:
'
decrease
'
}
/>
</
StatHelpText
>
</
Stat
>
);
});
}
}
}
return
<
Box
color=
{
changeColor
}
>
{
changeSign
}{
nbsp
}{
Math
.
abs
(
difference
).
toLocaleString
()
}
</
Box
>;
})();
})();
return
{
return
{
before
:
data
.
balance_before
?
(
before
:
data
.
balance_before
?
(
<
Flex
whiteSpace=
"pre-wrap"
justifyContent=
{
{
base
:
'
flex-start
'
,
lg
:
'
flex-end
'
}
}
>
<
Flex
whiteSpace=
"pre-wrap"
justifyContent=
{
{
base
:
'
flex-start
'
,
lg
:
'
flex-end
'
}
}
>
<
span
>
{
Number
(
data
.
balance_before
)
.
toLocaleString
()
}
</
span
>
<
span
>
{
before
.
toLocaleString
()
}
</
span
>
{
tokenLink
}
{
tokenLink
}
</
Flex
>
</
Flex
>
)
:
null
,
)
:
null
,
after
:
data
.
balance_after
?
(
after
:
data
.
balance_after
?
(
<
Flex
whiteSpace=
"pre-wrap"
justifyContent=
{
{
base
:
'
flex-start
'
,
lg
:
'
flex-end
'
}
}
>
<
Flex
whiteSpace=
"pre-wrap"
justifyContent=
{
{
base
:
'
flex-start
'
,
lg
:
'
flex-end
'
}
}
>
<
span
>
{
Number
(
data
.
balance_after
)
.
toLocaleString
()
}
</
span
>
<
span
>
{
after
.
toLocaleString
()
}
</
span
>
{
tokenLink
}
{
tokenLink
}
</
Flex
>
</
Flex
>
)
:
null
,
)
:
null
,
change
,
change
,
hint
,
hint
,
tokenId
:
tokenIdValue
?
<
TokenTransferNft
hash=
{
data
.
token
.
address
}
id=
{
tokenIdValue
}
w=
"auto"
truncation=
"constant"
my=
{
{
base
:
'
-3px
'
,
lg
:
0
}
}
/>
:
null
,
};
};
}
}
}
}
...
...
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