Skip to content

Commit

Permalink
use parent block for wasm and metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Oct 30, 2023
1 parent 6191b00 commit 9c556a0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/core/src/blockchain/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ export class Block {
get wasm() {
if (!this.#wasm) {
this.#wasm = (async (): Promise<HexString> => {
const parent = (await this.parentBlock) ?? this
const wasmKey = stringToHex(':code')
const wasm = await this.get(wasmKey)
const wasm = await parent.get(wasmKey)
if (!wasm) {
throw new Error('No wasm found')
}
Expand Down Expand Up @@ -290,7 +291,9 @@ export class Block {

get metadata(): Promise<HexString> {
if (!this.#metadata) {
this.#metadata = this.call('Metadata_metadata', []).then((resp) => compactHex(hexToU8a(resp.result)))
this.#metadata = this.parentBlock
.then((p) => (p ?? this).call('Metadata_metadata', []))
.then((resp) => compactHex(hexToU8a(resp.result)))
}
return this.#metadata
}
Expand Down

0 comments on commit 9c556a0

Please sign in to comment.