From 3abd428a8942acab600517b6cfb2ac4fc823c403 Mon Sep 17 00:00:00 2001 From: Qiwei Yang Date: Fri, 8 Sep 2023 17:39:34 +0800 Subject: [PATCH 1/2] fix header.toJSON is not a function (#393) * fix header.toJSON undefined * fix BlockEntity Header type --- packages/chopsticks/src/rpc/substrate/chain.ts | 3 ++- packages/core/src/blockchain/index.ts | 9 +++++++-- packages/core/src/db/entities.ts | 3 +-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/chopsticks/src/rpc/substrate/chain.ts b/packages/chopsticks/src/rpc/substrate/chain.ts index 0119107a..7cefcf95 100644 --- a/packages/chopsticks/src/rpc/substrate/chain.ts +++ b/packages/chopsticks/src/rpc/substrate/chain.ts @@ -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 diff --git a/packages/core/src/blockchain/index.ts b/packages/core/src/blockchain/index.ts index c1868004..31184895 100644 --- a/packages/core/src/blockchain/index.ts +++ b/packages/core/src/blockchain/index.ts @@ -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' @@ -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), + extrinsics, + storageDiff, + }) this.#registerBlock(block) return block } diff --git a/packages/core/src/db/entities.ts b/packages/core/src/db/entities.ts index a07762f6..dfef578b 100644 --- a/packages/core/src/db/entities.ts +++ b/packages/core/src/db/entities.ts @@ -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<{ @@ -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 | null From 83fbb6c3749252dd789b6bd1d7792c0bd045223f Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Fri, 8 Sep 2023 12:33:56 +0200 Subject: [PATCH 2/2] release 0.8.0 (#394) --- executor/package.json | 5 ++--- packages/chopsticks/package.json | 5 ++--- packages/core/package.json | 5 ++--- packages/testing/package.json | 5 ++--- yarn.lock | 9 +-------- 5 files changed, 9 insertions(+), 20 deletions(-) diff --git a/executor/package.json b/executor/package.json index 16a640ad..531c5a08 100644 --- a/executor/package.json +++ b/executor/package.json @@ -1,7 +1,7 @@ { "name": "@acala-network/chopsticks-executor", "description": "Chopsticks executor", - "version": "0.8.0-6", + "version": "0.8.0", "license": "Apache-2.0", "repository": { "type": "git", @@ -26,6 +26,5 @@ ], "main": "node/chopsticks_executor.js", "types": "node/chopsticks_executor.d.ts", - "browser": "browser/index.js", - "stableVersion": "0.7.3" + "browser": "browser/index.js" } diff --git a/packages/chopsticks/package.json b/packages/chopsticks/package.json index 4b4cfa19..86aab894 100644 --- a/packages/chopsticks/package.json +++ b/packages/chopsticks/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks", - "version": "0.8.0-6", + "version": "0.8.0", "author": "Bryan Chen ", "license": "Apache-2.0", "bin": "./chopsticks.js", @@ -57,6 +57,5 @@ "default": "./lib/*.js" }, "./package.json": "./package.json" - }, - "stableVersion": "0.7.3" + } } diff --git a/packages/core/package.json b/packages/core/package.json index f19f3707..2b2c271a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks-core", - "version": "0.8.0-6", + "version": "0.8.0", "author": "Bryan Chen ", "license": "Apache-2.0", "scripts": { @@ -44,6 +44,5 @@ "default": "./lib/*.js" }, "./package.json": "./package.json" - }, - "stableVersion": "0.7.3" + } } diff --git a/packages/testing/package.json b/packages/testing/package.json index ce8358d9..c8ed3e62 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks-testing", - "version": "0.8.0-6", + "version": "0.8.0", "author": "Bryan Chen ", "license": "Apache-2.0", "scripts": { @@ -32,6 +32,5 @@ "default": "./lib/*.js" }, "./package.json": "./package.json" - }, - "stableVersion": "0.7.3" + } } diff --git a/yarn.lock b/yarn.lock index bbbd8b8b..de9aac2b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1249,14 +1249,7 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:*": - version: 20.5.1 - resolution: "@types/node@npm:20.5.1" - checksum: 3dbe611cd67afa987102c8558ee70f848949c5dcfee5f60abc073e55c0d7b048e391bf06bb1e0dc052cb7210ca97136ac496cbaf6e89123c989de6bd125fde82 - languageName: node - linkType: hard - -"@types/node@npm:^20.5.7": +"@types/node@npm:*, @types/node@npm:^20.5.7": version: 20.5.7 resolution: "@types/node@npm:20.5.7" checksum: fc284c8e16ddc04569730d58e87eae349eb1c3dd9020cb79a1862d9d9add6f04e7367a236f3252db8db2572f90278e250f4cd43d27d264972b54394eaba1ed76