From b57518ba964bcfa7fbcab9e5df3bdd9d18814972 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Sat, 25 Sep 2021 14:29:09 -0300 Subject: [PATCH] Use common function --- src/components/MethodName.tsx | 4 ++-- src/use4Bytes.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/MethodName.tsx b/src/components/MethodName.tsx index 1ed596d..ff45cae 100644 --- a/src/components/MethodName.tsx +++ b/src/components/MethodName.tsx @@ -1,12 +1,12 @@ import React from "react"; -import { use4Bytes } from "../use4Bytes"; +import { rawInputTo4Bytes, use4Bytes } from "../use4Bytes"; type MethodNameProps = { data: string; }; const MethodName: React.FC = ({ data }) => { - const rawFourBytes = data.slice(0, 10); + const rawFourBytes = rawInputTo4Bytes(data); const methodName = use4Bytes(rawFourBytes); const isSimpleTransfer = data === "0x"; const methodTitle = isSimpleTransfer diff --git a/src/use4Bytes.ts b/src/use4Bytes.ts index 5f837e6..a1ab465 100644 --- a/src/use4Bytes.ts +++ b/src/use4Bytes.ts @@ -84,7 +84,7 @@ export const use4Bytes = (rawFourBytes: string) => { return name; }; -export const rawInputTo4Bytes = (rawInput: string) => rawInput.substr(0, 10); +export const rawInputTo4Bytes = (rawInput: string) => rawInput.slice(0, 10); /** * Extract 4bytes DB info