Skip to content
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
29 changes: 29 additions & 0 deletions src/confirmation-window/components/GasEstimate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";
import { formatEther } from "@ethersproject/units";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import useTheme from "@mui/material/styles/useTheme";
import { DecodedTxInput } from "../../pointsdk/index.d";
import Label from "./Label";

type Props = Pick<DecodedTxInput, "gas">;

const GasEstimate = ({ gas }: Props) => {
const theme = useTheme();

const parsedAmount =
gas.currency.toUpperCase() === "POINT"
? formatEther(gas.value)
: gas.value;

return (
<Box mb={2}>
<Label>Gas (estimate)</Label>
<Typography fontWeight={600} color={theme.palette.primary.main}>
{parsedAmount}&nbsp;{gas.currency.toUpperCase()}
</Typography>
</Box>
);
};

export default GasEstimate;
4 changes: 4 additions & 0 deletions src/confirmation-window/components/TxDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Address from "./Address";
import Price from "./Price";
import RawData from "./RawData";
import DecodedData from "./DecodedData";
import GasEstimate from "./GasEstimate";

const TxDetails = () => {
const { search } = useLocation();
Expand Down Expand Up @@ -50,6 +51,9 @@ const TxDetails = () => {

return (
<>
{decodedTxData?.gas?.value && decodedTxData?.gas?.currency ? (
<GasEstimate gas={decodedTxData.gas} />
) : null}
{Object.entries(rawParams).map(([key, value], idx) => {
switch (key) {
case "from":
Expand Down
4 changes: 4 additions & 0 deletions src/pointsdk/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,8 @@ type Param = {
export type DecodedTxInput = {
name: string;
params: Param[];
gas: {
value: string;
currency: string;
};
};