diff --git a/src/api/rpc.ts b/src/api/rpc.ts index 50e377b..599001a 100644 --- a/src/api/rpc.ts +++ b/src/api/rpc.ts @@ -28,7 +28,7 @@ export const hmyv2_getTransactionReceipt = ( params: [string], shardNumber: number ) => { - return rpcAdapter>( + return rpcAdapter>( process.env[`REACT_APP_RPC_URL_SHARD${shardNumber}`] as string, { method: "POST", diff --git a/src/components/transaction/TransactionDetails.tsx b/src/components/transaction/TransactionDetails.tsx index 67f4083..1b3e92c 100644 --- a/src/components/transaction/TransactionDetails.tsx +++ b/src/components/transaction/TransactionDetails.tsx @@ -113,6 +113,9 @@ export const TransactionDetails: FunctionComponent = ({ transactionFee: ( {CalculateTransactionFee(transaction)} ), + gasUsed: ( + {transaction.gas} + ), gasPrice: {CalculateFee(transaction)}, }; diff --git a/src/components/transaction/helpers.tsx b/src/components/transaction/helpers.tsx index 4788c66..f5e98cf 100644 --- a/src/components/transaction/helpers.tsx +++ b/src/components/transaction/helpers.tsx @@ -45,6 +45,7 @@ export const transactionPropertyDisplayNames: Record = { blockNumber: "Block Number", from: "From", txnFee: "Txn fee", + gasUsed: "Gas Used", gasPrice: "Gas Price", transactionFee: "Transaction Fee", input: "Input", @@ -91,6 +92,7 @@ export const transactionPropertySort: Record = { to: 650, txnFee: 560, transactionFee: 550, + gasUsed: 540, gasPrice: 500, input: 300, nonce: 350, @@ -112,6 +114,7 @@ export const transactionPropertyDescriptions: Record = { to: "The receiving party of the transaction (could be a contract address).", value: "The value being transacted in ONE and fiat value.", txnFee: "Transaction fee", + transactionFee: "Transaction fee", // gas: "The exact units of gas that was used for the transaction.", transactionIndex: "Transaction's number in the block", gasUsed: "The exact units of gas that was used for the transaction.", @@ -172,7 +175,8 @@ export const transactionPropertyDisplayValues: any = { timestamp: (value: any) => , gasUsed: (value: any, tx: RPCTransactionHarmony) => ( - {value} ({+value / +tx.gas}%){" "} + {value} + {/* {value} ({+value / +tx.gas}%){" "} */} ), shardID: (value: any, tx: RPCTransactionHarmony) => ( diff --git a/src/pages/TransactionPage/index.tsx b/src/pages/TransactionPage/index.tsx index e00dcfe..a4a9745 100644 --- a/src/pages/TransactionPage/index.tsx +++ b/src/pages/TransactionPage/index.tsx @@ -15,6 +15,7 @@ import { } from "src/api/client"; import { AllBlocksTable } from "../AllBlocksPage/AllBlocksTable"; import { revertErrorMessage } from "src/web3/parseByteCode"; +import { hmyv2_getTransactionReceipt } from "src/api/rpc"; const extractError = (err: any) => { const errorMessages = err!.split(":"); @@ -58,22 +59,33 @@ export const TransactionPage = () => { useEffect(() => { const getTx = async () => { let trx; + let shard = 0; if (id.length === 66) { trx = await getTransactionByField([0, "hash", id]); } if (!trx && availableShards.find((i) => i === 1)) { trx = await getTransactionByField([1, "hash", id]); + shard = 1; } if (!trx && availableShards.find((i) => i === 2)) { trx = await getTransactionByField([2, "hash", id]); + shard = 2; } if (!trx && availableShards.find((i) => i === 3)) { trx = await getTransactionByField([3, "hash", id]); + shard = 3; } + if (trx) { + const txnReceipt = await hmyv2_getTransactionReceipt([id], shard); + if (txnReceipt && txnReceipt.result && txnReceipt.result.gasUsed) { + trx.gas = parseInt(txnReceipt.result.gasUsed, 16).toString(); + } + } + setTx((trx || {}) as RPCStakingTransactionHarmony); };