Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

feat: use entryReadRaw in entryRead #489

Merged
merged 1 commit into from
Dec 30, 2022
Merged
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
6 changes: 2 additions & 4 deletions effects/entryRead.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as Z from "../deps/zones.ts"
import * as rpc from "../rpc/mod.ts"
import * as U from "../util/mod.ts"
import { entryReadRaw } from "./entryReadRaw.ts"
import { entryMetadata, metadata, palletMetadata } from "./metadata.ts"
import { state } from "./rpc_known_methods.ts"
import * as scale from "./scale.ts"

export function entryRead<Client extends Z.$<rpc.Client>>(client: Client) {
Expand All @@ -21,9 +21,7 @@ export function entryRead<Client extends Z.$<rpc.Client>>(client: Client) {
const deriveCodec_ = scale.deriveCodec(metadata_)
const palletMetadata_ = palletMetadata(metadata_, palletName)
const entryMetadata_ = entryMetadata(palletMetadata_, entryName)
const $storageKey_ = scale.$storageKey(deriveCodec_, palletMetadata_, entryMetadata_)
const storageKey = scale.scaleEncoded($storageKey_, Z.ls(...keys)).next(U.hex.encode)
const storageBytesHex = state.getStorage(client)(storageKey, blockHash)
const storageBytesHex = entryReadRaw(client)(palletName, entryName, keys, blockHash)
const storageBytes = storageBytesHex.next(U.hex.decode)
const entryValueTypeI = entryMetadata_.access("value")
const $entry = scale.codec(deriveCodec_, entryValueTypeI)
Expand Down