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
fad3d706
Commit
fad3d706
authored
Oct 05, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
usd values
parent
f805ea10
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
17 deletions
+38
-17
tokenTransfer.ts
types/api/tokenTransfer.ts
+1
-1
transaction.ts
types/api/transaction.ts
+1
-1
CurrencyValue.tsx
ui/shared/CurrencyValue.tsx
+28
-0
TokenTransfer.tsx
ui/tx/TokenTransfer.tsx
+3
-5
TxDetails.tsx
ui/tx/TxDetails.tsx
+5
-10
No files found.
types/api/tokenTransfer.ts
View file @
fad3d706
...
...
@@ -11,5 +11,5 @@ export interface TokenTransfer {
total
:
{
value
:
string
;
};
exchange
Rate
:
number
;
exchange
_rate
:
string
;
}
types/api/transaction.ts
View file @
fad3d706
...
...
@@ -35,7 +35,7 @@ export interface Transaction {
decoded_input
?:
DecodedInput
;
token_transfers
?:
Array
<
TokenTransfer
>
;
token_transfers_overflow
:
boolean
;
exchange_rate
:
number
;
exchange_rate
:
string
;
}
export
interface
TransactionsResponse
{
...
...
ui/shared/CurrencyValue.tsx
0 → 100644
View file @
fad3d706
import
{
Box
,
Text
,
chakra
}
from
'
@chakra-ui/react
'
;
import
{
utils
,
constants
}
from
'
ethers
'
;
import
React
from
'
react
'
;
interface
Props
{
value
:
string
;
unit
?:
'
wei
'
|
'
gwei
'
|
'
ether
'
;
currency
?:
string
;
exchangeRate
?:
string
;
className
?:
string
;
}
const
CurrencyValue
=
({
value
,
currency
=
''
,
unit
=
'
wei
'
,
exchangeRate
,
className
}:
Props
)
=>
{
const
valueBn
=
utils
.
parseUnits
(
value
,
unit
);
const
exchangeRateBn
=
utils
.
parseUnits
(
exchangeRate
||
'
0
'
,
'
ether
'
);
const
usdBn
=
valueBn
.
mul
(
exchangeRateBn
).
div
(
constants
.
WeiPerEther
);
return
(
<
Box
as=
"span"
className=
{
className
}
>
<
Text
as=
"span"
>
{
Number
(
utils
.
formatUnits
(
valueBn
)).
toLocaleString
()
}{
currency
?
` ${ currency }`
:
''
}
</
Text
>
{
exchangeRate
!==
undefined
&&
exchangeRate
!==
null
&&
<
Text
as=
"span"
variant=
"secondary"
whiteSpace=
"pre"
fontWeight=
{
400
}
>
($
{
utils
.
formatUnits
(
usdBn
)
}
)
</
Text
>
}
</
Box
>
);
};
export
default
React
.
memo
(
chakra
(
CurrencyValue
));
ui/tx/TokenTransfer.tsx
View file @
fad3d706
...
...
@@ -6,13 +6,12 @@ import type { TokenTransfer as TTokenTransfer } from 'types/api/tokenTransfer';
import
rightArrowIcon
from
'
icons/arrows/east.svg
'
;
import
{
space
}
from
'
lib/html-entities
'
;
import
AddressLink
from
'
ui/shared/address/AddressLink
'
;
import
CurrencyValue
from
'
ui/shared/CurrencyValue
'
;
import
TokenSnippet
from
'
ui/shared/TokenSnippet
'
;
type
Props
=
TTokenTransfer
const
TokenTransfer
=
({
from
,
to
,
total
,
...
token
}:
Props
)
=>
{
// todo_tom API doesn't send exchange rate currently
// const usd = exchangeRate ? Number(total.value) / exchangeRate : 0;
const
TokenTransfer
=
({
from
,
to
,
total
,
exchange_rate
:
exchangeRate
,
...
token
}:
Props
)
=>
{
return
(
<
Flex
alignItems=
"center"
flexWrap=
"wrap"
columnGap=
{
3
}
rowGap=
{
3
}
>
<
Flex
alignItems=
"center"
>
...
...
@@ -21,8 +20,7 @@ const TokenTransfer = ({ from, to, total, ...token }: Props) => {
<
AddressLink
fontWeight=
"500"
hash=
{
to
.
hash
}
truncation=
"constant"
/>
</
Flex
>
<
Text
fontWeight=
{
500
}
as=
"span"
>
For:
{
space
}
<
Text
fontWeight=
{
600
}
as=
"span"
>
{
total
.
value
}
</
Text
>
{
space
}
{
/* { usd > 0 && <Text fontWeight={ 400 } variant="secondary" as="span">(${ usd.toFixed(2) })</Text> } */
}
<
CurrencyValue
value=
{
total
.
value
.
replaceAll
(
'
,
'
,
''
)
}
unit=
"ether"
exchangeRate=
{
exchangeRate
}
fontWeight=
{
600
}
/>
</
Text
>
<
TokenSnippet
symbol=
{
token
.
token_symbol
}
hash=
{
token
.
token_address
}
name=
"Foo"
/>
</
Flex
>
...
...
ui/tx/TxDetails.tsx
View file @
fad3d706
...
...
@@ -19,6 +19,7 @@ import Address from 'ui/shared/address/Address';
import
AddressIcon
from
'
ui/shared/address/AddressIcon
'
;
import
AddressLink
from
'
ui/shared/address/AddressLink
'
;
import
CopyToClipboard
from
'
ui/shared/CopyToClipboard
'
;
import
CurrencyValue
from
'
ui/shared/CurrencyValue
'
;
import
DataFetchAlert
from
'
ui/shared/DataFetchAlert
'
;
import
DetailsInfoItem
from
'
ui/shared/DetailsInfoItem
'
;
import
HashStringShortenDynamic
from
'
ui/shared/HashStringShortenDynamic
'
;
...
...
@@ -152,17 +153,13 @@ const TxDetails = () => {
title=
"Value"
hint=
"Value sent in the native token (and USD) if applicable."
>
<
Text
>
{
Number
(
utils
.
formatUnits
(
utils
.
parseUnits
(
String
(
data
.
value
),
'
wei
'
)))
}
{
selectedNetwork
?.
currency
}
</
Text
>
{
/* todo_tom API doesn't send exchange rate currently*/
}
{
/* <Text variant="secondary" ml={ 1 }>(${ usdValue.toFixed(2) })</Text> */
}
<
CurrencyValue
value=
{
String
(
data
.
value
)
}
currency=
{
selectedNetwork
?.
currency
}
exchangeRate=
{
data
.
exchange_rate
}
/>
</
DetailsInfoItem
>
<
DetailsInfoItem
title=
"Transaction fee"
hint=
"Total transaction fee."
>
<
Text
>
{
utils
.
formatUnits
(
utils
.
parseUnits
(
data
.
fee
.
value
,
'
wei
'
))
}
{
selectedNetwork
?.
currency
}
</
Text
>
{
/* todo_tom API doesn't send exchange rate currently*/
}
{
/* <Text variant="secondary" ml={ 1 }>(${ tx.fee.value_usd.toFixed(2) })</Text> */
}
<
CurrencyValue
value=
{
String
(
data
.
fee
.
value
)
}
currency=
{
selectedNetwork
?.
currency
}
exchangeRate=
{
data
.
exchange_rate
}
/>
</
DetailsInfoItem
>
<
DetailsInfoItem
title=
"Gas price"
...
...
@@ -213,10 +210,8 @@ const TxDetails = () => {
title=
"Burnt fees"
hint=
{
`Amount of ${ selectedNetwork?.currency } burned for this transaction. Equals Block Base Fee per Gas * Gas Used.`
}
>
<
Icon
as=
{
flameIcon
}
boxSize=
{
5
}
color=
"gray.500"
/>
<
Text
ml=
{
1
}
mr=
{
1
}
>
{
utils
.
formatUnits
(
utils
.
parseUnits
(
String
(
data
.
tx_burnt_fee
),
'
wei
'
))
}
{
selectedNetwork
?.
currency
}
</
Text
>
{
/* todo_tom API doesn't send exchange rate currently*/
}
{
/* <Text variant="secondary">(${ tx.burnt_fees.value_usd.toFixed(2) })</Text> */
}
<
Icon
as=
{
flameIcon
}
mr=
{
1
}
boxSize=
{
5
}
color=
"gray.500"
/>
<
CurrencyValue
value=
{
String
(
data
.
tx_burnt_fee
)
}
currency=
{
selectedNetwork
?.
currency
}
exchangeRate=
{
data
.
exchange_rate
}
/>
</
DetailsInfoItem
>
)
}
<
GridItem
colSpan=
{
{
base
:
undefined
,
lg
:
2
}
}
>
...
...
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