Skip to content

Commit

Permalink
Merge branch 'master' of github.com:AcalaNetwork/chopsticks into rele…
Browse files Browse the repository at this point in the history
…ase-0.8.0
  • Loading branch information
ermalkaleci committed Sep 8, 2023
2 parents d4142db + 3abd428 commit 1c2adb7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/chopsticks/src/rpc/substrate/chain.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Handlers, ResponseError } from '../shared'
import { Header } from '@polkadot/types/interfaces'

const processHeader = (header: any) => {
const processHeader = (header: Header) => {
const res = header.toJSON() as any
res.number = '0x' + res.number.toString(16) // number is hex format
return res
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/blockchain/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApplyExtrinsicResult } from '@polkadot/types/interfaces'
import { ApplyExtrinsicResult, Header } from '@polkadot/types/interfaces'
import { DataSource } from 'typeorm'
import { HexString } from '@polkadot/util/types'
import { RegisteredTypes } from '@polkadot/types/types'
Expand Down Expand Up @@ -152,7 +152,12 @@ export class Blockchain {
const { hash, number, header, extrinsics, parentHash } = blockData
const parentBlock = parentHash ? this.#blocksByHash[parentHash] : undefined
const storageDiff = blockData.storageDiff ?? undefined
const block = new Block(this, number, hash, parentBlock, { header, extrinsics, storageDiff })
const registry = await this.head.registry
const block = new Block(this, number, hash, parentBlock, {
header: registry.createType<Header>('Header', header),
extrinsics,
storageDiff,
})
this.#registerBlock(block)
return block
}
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/db/entities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { EntitySchema } from 'typeorm'
import { Header } from '@polkadot/types/interfaces'
import { HexString } from '@polkadot/util/types'

export const KeyValuePair = new EntitySchema<{
Expand Down Expand Up @@ -29,7 +28,7 @@ export const KeyValuePair = new EntitySchema<{
export const BlockEntity = new EntitySchema<{
hash: HexString
number: number
header: Header
header: object
parentHash: HexString | null
extrinsics: HexString[]
storageDiff: Record<HexString, HexString | null> | null
Expand Down

0 comments on commit 1c2adb7

Please sign in to comment.