Merge pull request #109 from polkadot-api/vo/storage-sub

fix(storage): showing wrong block hash when querying at block
This commit is contained in:
Victor Oliva
2025-11-18 18:00:53 +01:00
committed by GitHub
4 changed files with 16 additions and 9 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ export const StorageDecode: FC = () => {
type: entry!.value,
payload: decoded,
ctx: ctx!,
hash: null,
blockHash: null,
}),
})
}
+6 -1
View File
@@ -130,7 +130,12 @@ export const StorageQuery: FC = () => {
args,
single,
keyCodec,
value: at(hash),
value: at(hash).pipe(
map((r) => ({
...r,
blockHash: hash,
})),
),
})
} else {
addStorageSubscription({
+5 -5
View File
@@ -79,17 +79,17 @@ const ValueSubscriptionBox: FC<{ subscription: string }> = ({
if (!storageSubscription) return null
const status = storageSubscription.status
if (status.type !== "value") return null
const { ctx, payload, type, hash } = status.value
const { ctx, payload, type, blockHash } = status.value
return (
<SubscriptionBox
subscription={subscription}
actions={
hash ? (
blockHash ? (
<div className="text-center">
<p className="text-sm">Hash</p>
<Link to={`/explorer/${hash}`} className="underline">
<p className="font-mono text-xs">{shortStr(hash, 6)}</p>
<p className="text-sm">Block Hash</p>
<Link to={`/explorer/${blockHash}`} className="underline">
<p className="font-mono text-xs">{shortStr(blockHash, 6)}</p>
</Link>
</div>
) : null
+4 -2
View File
@@ -183,7 +183,7 @@ export const [newStorageSubscription$, addStorageSubscription] = createSignal<{
value?: Observable<{
type: number
ctx: Pick<RuntimeContext, "lookup" | "dynamicBuilder">
hash: string | null
blockHash: HexString | null
payload: unknown
}>
}>()
@@ -214,12 +214,14 @@ export type StorageSubscription = {
completed: boolean
status: Enum<{
loading: undefined
// Non-subscription: fetches/decodes one value, then done
value: {
hash: string | null
blockHash: HexString | null
ctx: Pick<RuntimeContext, "lookup" | "dynamicBuilder">
type: number
payload: unknown
}
// For subscriptions, adds one new value on every change
values: Array<StorageSubscriptionValue>
}>
}