Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui-ux): fix displayed amount in transaction list #342

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pages/block/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ export default function Block({
GWEI_DECIMAL
).toString()}
decimalScale={9}
suffix=" Gwei" // TODO: Confirm if this is Gwei, DFI or ETH
suffix=" Gwei"
/>
<DetailRow
testId="burnt-fee"
label="Burnt fee"
value={formatEther(BigInt(block.burnt_fees ?? "0"))}
decimalScale={10}
suffix=" DFI" // TODO: Confirm if this is DFI or ETH
suffix=" DFI"
/>
<DetailRow
testId="gas-limit"
Expand Down
13 changes: 1 addition & 12 deletions src/shared/transactionDataHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ import { getTimeAgo } from "./durationHelper";
* @returns formatted tx data
*/
export const transformTransactionData = (tx: RawTransactionI): TransactionI => {
// TODO: Revisit the amount/value format once actual tx data is available
const amountIndex = tx.decoded_input?.parameters?.findIndex(
(p) => p.name === "amount"
);
let dfiAmount = "0";
if (amountIndex && amountIndex > -1) {
dfiAmount = formatEther(
BigInt((tx.decoded_input?.parameters[amountIndex].value as string) ?? "0")
);
}

const fromHash = tx.from.hash ?? BURN_ADDRESS_HASH;
const toHash = tx.to?.hash ?? tx.created_contract?.hash ?? BURN_ADDRESS_HASH;
const isFromContract = tx.from.is_contract;
Expand All @@ -53,7 +42,7 @@ export const transformTransactionData = (tx: RawTransactionI): TransactionI => {
transactionType,
type: tx.type,
hash: tx.hash,
amount: dfiAmount,
amount: formatEther(BigInt(tx.value ?? "0")),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for diff coin decimal value will be different, I guess we should get decimal value and then format

Copy link
Contributor Author

@lykalabrada lykalabrada Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this amount is only for "DFI value" so should always 18 decimals

symbol: DFI_TOKEN_SYMBOL, // TODO: Revisit tx symbol
from: fromHash,
to: toHash,
Expand Down
Loading