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
5ad36226
Commit
5ad36226
authored
Oct 11, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate to big-number-js
parent
ca44548c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
consts.ts
lib/consts.ts
+1
-0
TxDetails.tsx
ui/tx/TxDetails.tsx
+10
-9
No files found.
lib/consts.ts
View file @
5ad36226
...
...
@@ -2,3 +2,4 @@ import BigNumber from 'bignumber.js';
export
const
WEI
=
new
BigNumber
(
10
**
18
);
export
const
GWEI
=
new
BigNumber
(
10
**
9
);
export
const
WEI_IN_GWEI
=
WEI
.
dividedBy
(
GWEI
);
ui/tx/TxDetails.tsx
View file @
5ad36226
import
{
Grid
,
GridItem
,
Text
,
Box
,
Icon
,
Link
,
Flex
}
from
'
@chakra-ui/react
'
;
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
{
utils
}
from
'
ether
s
'
;
import
BigNumber
from
'
bignumber.j
s
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
{
scroller
,
Element
}
from
'
react-scroll
'
;
...
...
@@ -9,6 +9,7 @@ import type { Transaction } from 'types/api/transaction';
import
clockIcon
from
'
icons/clock.svg
'
;
import
flameIcon
from
'
icons/flame.svg
'
;
import
{
WEI
,
WEI_IN_GWEI
}
from
'
lib/consts
'
;
// import errorIcon from 'icons/status/error.svg';
// import successIcon from 'icons/status/success.svg';
import
dayjs
from
'
lib/date/dayjs
'
;
...
...
@@ -165,17 +166,17 @@ const TxDetails = () => {
title=
"Gas price"
hint=
"Price per unit of gas specified by the sender. Higher gas prices can prioritize transaction inclusion during times of high usage."
>
<
Text
mr=
{
1
}
>
{
utils
.
formatUnits
(
utils
.
parseUnits
(
String
(
data
.
gas_price
),
'
wei
'
)
)
}
{
selectedNetwork
?.
currency
}
</
Text
>
<
Text
variant=
"secondary"
>
(
{
Number
(
utils
.
formatUnits
(
utils
.
parseUnits
(
String
(
data
.
gas_price
),
'
wei
'
),
'
gwei
'
)
)
}
Gwei)
</
Text
>
<
Text
mr=
{
1
}
>
{
BigNumber
(
data
.
gas_price
).
dividedBy
(
WEI
).
toFixed
(
)
}
{
selectedNetwork
?.
currency
}
</
Text
>
<
Text
variant=
"secondary"
>
(
{
BigNumber
(
data
.
gas_price
).
dividedBy
(
WEI_IN_GWEI
).
toFixed
(
)
}
Gwei)
</
Text
>
</
DetailsInfoItem
>
<
DetailsInfoItem
title=
"Gas limit & usage by txn"
hint=
"Actual gas amount used by the transaction."
>
<
Text
>
{
utils
.
commify
(
data
.
gas_used
)
}
</
Text
>
<
Text
>
{
BigNumber
(
data
.
gas_used
).
toFormat
(
)
}
</
Text
>
<
TextSeparator
/>
<
Text
>
{
utils
.
commify
(
data
.
gas_limit
)
}
</
Text
>
<
Utilization
ml=
{
4
}
value=
{
utils
.
parseUnits
(
data
.
gas_used
).
mul
(
10
_000
).
div
(
utils
.
parseUnits
(
data
.
gas_limit
)).
toNumber
()
/
10
_000
}
/>
<
Text
>
{
BigNumber
(
data
.
gas_limit
).
toFormat
(
)
}
</
Text
>
<
Utilization
ml=
{
4
}
value=
{
BigNumber
(
data
.
gas_used
).
dividedBy
(
BigNumber
(
data
.
gas_limit
)).
toNumber
()
}
/>
</
DetailsInfoItem
>
{
(
data
.
base_fee_per_gas
||
data
.
max_fee_per_gas
||
data
.
max_priority_fee_per_gas
)
&&
(
<
DetailsInfoItem
...
...
@@ -186,21 +187,21 @@ const TxDetails = () => {
{
data
.
base_fee_per_gas
&&
(
<
Box
>
<
Text
as=
"span"
fontWeight=
"500"
>
Base:
</
Text
>
<
Text
fontWeight=
"600"
as=
"span"
>
{
utils
.
formatUnits
(
utils
.
parseUnits
(
String
(
data
.
base_fee_per_gas
),
'
wei
'
),
'
gwei
'
)
}
</
Text
>
<
Text
fontWeight=
"600"
as=
"span"
>
{
BigNumber
(
data
.
base_fee_per_gas
).
dividedBy
(
WEI_IN_GWEI
).
toFixed
(
)
}
</
Text
>
</
Box
>
)
}
{
data
.
max_fee_per_gas
&&
(
<
Box
>
<
TextSeparator
/>
<
Text
as=
"span"
fontWeight=
"500"
>
Max:
</
Text
>
<
Text
fontWeight=
"600"
as=
"span"
>
{
utils
.
formatUnits
(
utils
.
parseUnits
(
String
(
data
.
max_fee_per_gas
),
'
wei
'
),
'
gwei
'
)
}
</
Text
>
<
Text
fontWeight=
"600"
as=
"span"
>
{
BigNumber
(
data
.
max_fee_per_gas
).
dividedBy
(
WEI_IN_GWEI
).
toFixed
(
)
}
</
Text
>
</
Box
>
)
}
{
data
.
max_priority_fee_per_gas
&&
(
<
Box
>
<
TextSeparator
/>
<
Text
as=
"span"
fontWeight=
"500"
>
Max priority:
</
Text
>
<
Text
fontWeight=
"600"
as=
"span"
>
{
utils
.
formatUnits
(
utils
.
parseUnits
(
String
(
data
.
max_priority_fee_per_gas
),
'
wei
'
),
'
gwei
'
)
}
</
Text
>
<
Text
fontWeight=
"600"
as=
"span"
>
{
BigNumber
(
data
.
max_priority_fee_per_gas
).
dividedBy
(
WEI_IN_GWEI
).
toFixed
(
)
}
</
Text
>
</
Box
>
)
}
</
DetailsInfoItem
>
...
...
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