Skip to content

Commit

Permalink
fix: display non-ascii values as hex (#1757)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKheops authored Dec 18, 2024
1 parent 6636d02 commit 1c9c680
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LoaderIcon } from "@talismn/icons"
import { classNames, encodeAnyAddress } from "@talismn/util"
import { classNames, encodeAnyAddress, isAscii } from "@talismn/util"
import DOMPurify from "dompurify"
import { SignerPayloadJSON } from "extension-core"
import { log } from "extension-shared"
Expand Down Expand Up @@ -129,8 +129,10 @@ const formatArgs = (args: unknown): unknown => {
if (typeof args === "bigint") return args.toString() + "n"
if (Array.isArray(args)) return args.map(formatArgs)

// TODO fallback to asHex if any weird characters are present
if (args instanceof Binary) return args.asText()
if (args instanceof Binary) {
const text = args.asText()
return isAscii(text) ? text : args.asHex()
}

if (typeof args === "object") {
// workaround for AccountId32 - asText() returns glyphs so we need to decode it manually
Expand Down

0 comments on commit 1c9c680

Please sign in to comment.