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
34 changes: 33 additions & 1 deletion packages/next-common/components/papiCallTreeView/valuePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,28 @@ import AddressUser from "../user/addressUser";
import { useCallContext } from "./callContext";
import interlay from "next-common/utils/consts/settings/interlay";
import kintsugi from "next-common/utils/consts/settings/kintsugi";
import { isNil } from "lodash-es";
import { isNil, omit } from "lodash-es";
import EnumPanel from "./enumPanel";
import { isPolkadotAddress } from "next-common/utils/viewfuncs";

const LongText = dynamic(() => import("next-common/components/longText"), {
ssr: false,
});

function u64ArrayToU256(arr) {
if (arr.length !== 4) {
throw new Error("Expected array of 4 u64 values");
}

const n =
BigInt(arr[0]) |
(BigInt(arr[1]) << 64n) |
(BigInt(arr[2]) << 128n) |
(BigInt(arr[3]) << 192n);

return "0x" + n.toString(16).padStart(64, "0");
}

export function safeHexToString(hex) {
if (!hex.startsWith("0x")) {
hex = "0x" + hex;
Expand Down Expand Up @@ -193,6 +207,24 @@ export function ValuePanel({ node }) {
}

if (rawType === "array") {
if (
type === "[u64; 4]" &&
Array.isArray(node.children) &&
node.children.length === 4
) {
const value = u64ArrayToU256(node.children.map((child) => child.value));
return (
<ValuePanel
node={{
...omit(node, ["children"]),
rawType: "primitive",
type: "U256",
value,
}}
/>
);
}

return <ArrayPanel node={node} />;
}

Expand Down
7 changes: 0 additions & 7 deletions packages/next-common/utils/callDecoder/typeName.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ export function getTypeName(lookupEntry, metadata, typeId) {
) {
return "H160";
}
if (
lookupEntry.len === 4 &&
lookupEntry.value.type === "primitive" &&
lookupEntry.value.value === "u64"
) {
return "U256";
}

const innerType = getTypeName(
lookupEntry.value,
Expand Down
Loading