fix BlockDetails signer

This commit is contained in:
Josep M Sobrepere
2024-11-09 17:10:03 +07:00
parent bea4499d57
commit cb8145a904
2 changed files with 23 additions and 9 deletions

View File

@@ -27,6 +27,22 @@ import { blockInfoState$, blocksByHeight$, BlockState } from "../block.state"
import { BlockStatusIcon, statusText } from "./BlockState"
import { createExtrinsicCodec, DecodedExtrinsic } from "./extrinsicDecoder"
import { CopyText } from "@/components/Copy"
import { Enum, HexString, SS58String } from "polkadot-api"
const Sender: React.FC<{
sender: Enum<{ Id: SS58String }> | SS58String | HexString
}> = ({ sender }) => {
const value: string | null =
typeof sender === "string" ? sender : "Id" in sender ? sender.value : null
return (
value && (
<div className="flex gap-2 items-center py-2">
Signer:
<AccountIdDisplay value={value} />
</div>
)
)
}
const blockExtrinsics$ = state((hash: string) => {
const decoder$ = runtimeCtx$.pipe(
@@ -311,12 +327,7 @@ const Extrinsic: FC<{
<div className="overflow-hidden">
{extrinsic.signed && (
<div>
{"type" in extrinsic.sender && extrinsic.sender.type === "Id" && (
<div className="flex gap-2 items-center py-2">
Signer:
<AccountIdDisplay value={extrinsic.sender.value} />
</div>
)}
<Sender sender={extrinsic.sender} />
<SignedExtensions extra={extrinsic.extra} />
</div>
)}

View File

@@ -9,6 +9,7 @@ import {
compact,
enhanceDecoder,
Enum,
HexString,
SS58String,
Struct,
u8,
@@ -31,9 +32,11 @@ export const createExtrinsicCodec = (
lookup.metadata.extrinsic.address,
) as Codec<
// TODO Assume MultiAddress, but can be anything really :/
Enum<{
Id: SS58String
}>
| Enum<{
Id: SS58String
}>
| SS58String
| HexString
>)
: AccountId()
const v14Signature = Variant({