add extrinsic, outerEnum and custom fields
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
import { V14, V15 } from "@polkadot-api/substrate-bindings"
|
||||
import { FC, useState } from "react"
|
||||
import { LookupLink } from "./Lookup"
|
||||
import { SearchableSelect } from "@/components/Select"
|
||||
|
||||
type ExtrinsicDescriptor = (V14 | V15)["extrinsic"]
|
||||
export const Extrinsic: FC<{ extrinsic: ExtrinsicDescriptor }> = ({
|
||||
extrinsic,
|
||||
}) => {
|
||||
return (
|
||||
<div className="border rounded p-2 flex flex-col gap-2">
|
||||
<h3 className="font-bold text-xl">Extrinsic</h3>
|
||||
<p>Version: {extrinsic.version}</p>
|
||||
{"type" in extrinsic && (
|
||||
<div>
|
||||
<h4>Type</h4>
|
||||
<LookupLink id={extrinsic.type} />
|
||||
</div>
|
||||
)}
|
||||
{"call" in extrinsic && (
|
||||
<div>
|
||||
<h4>Call</h4>
|
||||
<LookupLink id={extrinsic.call} />
|
||||
</div>
|
||||
)}
|
||||
{"extra" in extrinsic && (
|
||||
<div>
|
||||
<h4>Extra</h4>
|
||||
<LookupLink id={extrinsic.extra} />
|
||||
</div>
|
||||
)}
|
||||
{"signature" in extrinsic && (
|
||||
<div>
|
||||
<h4>Signature</h4>
|
||||
<LookupLink id={extrinsic.signature} />
|
||||
</div>
|
||||
)}
|
||||
{"address" in extrinsic && (
|
||||
<div>
|
||||
<h4>Address</h4>
|
||||
<LookupLink id={extrinsic.address} />
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<h4>Signed Extensions</h4>
|
||||
<SignedExtensions signedExtensions={extrinsic.signedExtensions} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
type SignedExtension =
|
||||
ExtrinsicDescriptor["signedExtensions"] extends Array<infer R> ? R : never
|
||||
const SignedExtensions: FC<{ signedExtensions: Array<SignedExtension> }> = ({
|
||||
signedExtensions,
|
||||
}) => {
|
||||
const [entry, setEntry] = useState<SignedExtension | null>(null)
|
||||
|
||||
return (
|
||||
<div className="flex flex-col p-2 gap-2">
|
||||
<label className="self-start">
|
||||
Identifier:{" "}
|
||||
<SearchableSelect
|
||||
value={entry}
|
||||
setValue={setEntry}
|
||||
options={signedExtensions.map((ext) => ({
|
||||
text: ext.identifier,
|
||||
value: ext,
|
||||
}))}
|
||||
/>
|
||||
</label>
|
||||
{entry && (
|
||||
<>
|
||||
<div>
|
||||
<h5>Type</h5>
|
||||
<LookupLink id={entry.type} />
|
||||
</div>
|
||||
<div>
|
||||
<h5>Additional Signed</h5>
|
||||
<LookupLink id={entry.additionalSigned} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -9,9 +9,11 @@ import { V14, V15 } from "@polkadot-api/substrate-bindings"
|
||||
import { useStateObservable } from "@react-rxjs/core"
|
||||
import { FC, useState } from "react"
|
||||
import { Route, Routes, useParams } from "react-router-dom"
|
||||
import { Extrinsic } from "./Extrinsic"
|
||||
import { Lookup, LookupContext } from "./Lookup"
|
||||
import { Pallets } from "./Pallets"
|
||||
import { RuntimeApis } from "./RuntimeApis"
|
||||
import { V15Fields } from "./V15Fields"
|
||||
|
||||
export const Metadata = withSubscribe(
|
||||
() => (
|
||||
@@ -61,6 +63,8 @@ const DecodedExplorer: FC<{ value: V14 | V15 }> = ({ value }) => {
|
||||
<Lookup />
|
||||
<Pallets pallets={value.pallets} />
|
||||
<RuntimeApis apis={value.apis} />
|
||||
<Extrinsic extrinsic={value.extrinsic} />
|
||||
{"outerEnums" in value && <V15Fields metadata={value} />}
|
||||
</LookupContext.Provider>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import { V15 } from "@polkadot-api/substrate-bindings"
|
||||
import { FC } from "react"
|
||||
import { LookupLink } from "./Lookup"
|
||||
import { CopyText } from "@/components/Copy"
|
||||
|
||||
export const V15Fields: FC<{ metadata: V15 }> = ({ metadata }) => {
|
||||
return (
|
||||
<>
|
||||
<div className="border rounded p-2 flex flex-col gap-2">
|
||||
<h3 className="font-bold text-xl">Outer Enums</h3>
|
||||
<div>
|
||||
<h4>Call</h4>
|
||||
<LookupLink id={metadata.outerEnums.call} />
|
||||
</div>
|
||||
<div>
|
||||
<h4>Event</h4>
|
||||
<LookupLink id={metadata.outerEnums.event} />
|
||||
</div>
|
||||
<div>
|
||||
<h4>Error</h4>
|
||||
<LookupLink id={metadata.outerEnums.error} />
|
||||
</div>
|
||||
</div>
|
||||
{metadata.custom.length > 0 && (
|
||||
<div className="border rounded p-2 flex flex-col gap-2">
|
||||
<h3 className="font-bold text-xl">Custom</h3>
|
||||
{Object.entries(
|
||||
metadata.custom.map(([key, { type, value }]) => (
|
||||
<div key={key}>
|
||||
<h4>{key}</h4>
|
||||
<LookupLink id={type} />
|
||||
<div className="whitespace-nowrap overflow-hidden text-ellipsis">
|
||||
<CopyText text={value} binary className="mr-2" />
|
||||
{value}
|
||||
</div>
|
||||
</div>
|
||||
)),
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user