Revert "migrate to v2 (#118)"

This reverts commit d4fe0b546e.
This commit is contained in:
Josep M Sobrepere
2026-03-04 16:43:20 +01:00
parent d4fe0b546e
commit d9428a8d9c
43 changed files with 2444 additions and 2297 deletions
+12 -6
View File
@@ -5,6 +5,7 @@ import {
import { Modal } from "@/components/Modal"
import { useGenericSynchronizeInput } from "@/components/useSynchroniseInput"
import { NOTIN } from "@polkadot-api/react-builder"
import { Binary } from "@polkadot-api/substrate-bindings"
import { Download, FileUp } from "lucide-react"
import { ComponentProps, FC, useMemo, useState } from "react"
import { twMerge } from "tailwind-merge"
@@ -12,7 +13,6 @@ import { twMerge } from "tailwind-merge"
import { saveAs } from "save-as"
import { BinaryEdit } from "./Icons"
import { ActionButton } from "./ActionButton"
import { fromHex, toHex } from "polkadot-api/utils"
export interface BinaryEditProps {
initialValue?: Uint8Array
@@ -80,13 +80,17 @@ const BinaryEditModalContent: FC<
const [inputValue, setInputValue] = useGenericSynchronizeInput(
value,
setValue as any,
parseInput,
(input) => parseInput(input).asBytes(),
"" as string | Uint8Array,
(value) => {
if (value.length > MAX_DISPLAY_SIZE) return ""
return toHex(value)
return Binary.fromBytes(value).asHex()
},
(input, value) => checkEqualInputBinary(parseInput(input), value),
(input, value) =>
checkEqualInputBinary(
parseInput(input),
value === NOTIN ? NOTIN : Binary.fromBytes(value),
),
)
const placeholder =
@@ -154,7 +158,7 @@ const BinaryEditModalContent: FC<
<BinaryFileInput
validate={validateFile}
onError={() => setError("Error loading file")}
onLoaded={setValue}
onLoaded={(value) => setValue(value.asBytes())}
/>
</label>
</div>
@@ -182,4 +186,6 @@ const BinaryEditModalContent: FC<
}
const parseInput = (value: string | Uint8Array) =>
value instanceof Uint8Array ? value : fromHex(value)
value instanceof Uint8Array
? Binary.fromBytes(value)
: Binary.fromHex(value.startsWith("0x") ? value : `0x${value}`)