trufflesuite/truffle

View on GitHub
packages/codec-components/src/react/components/codec/format.values.ufixed-value.tsx

Summary

Maintainability
B
5 hrs
Test Coverage
import React from "react";
import type { Format } from "@truffle/codec";
import { createCodecComponent } from "../../utils/create-codec-component";
import { useInjectedNode } from "../../contexts/injected-node";
import { Code } from "../common/code";
import { typeStringWithoutLocation } from "../../../utils";

export const { UfixedValue } = createCodecComponent(
  "UfixedValue",
  ({ value, type }: Format.Values.UfixedValue) => {
    const { prefix, content } = useInjectedNode();
    return (
      <Code type="number" title={`type: ${typeStringWithoutLocation(type)}`}>
        {prefix?.prefix}
        {value.asBig.toString()}
        {content?.suffix}
      </Code>
    );
  }
);