Skip to content

Commit

Permalink
biome check write
Browse files Browse the repository at this point in the history
  • Loading branch information
gluneau committed Jan 10, 2025
1 parent 57ea375 commit e96ebb5
Show file tree
Hide file tree
Showing 91 changed files with 269 additions and 262 deletions.
2 changes: 1 addition & 1 deletion packages/chopsticks/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { MiddlewareFunction } from 'yargs'
import { hideBin } from 'yargs/helpers'
import { z } from 'zod'

import { Blockchain, connectParachains, connectVertical, environment } from '@acala-network/chopsticks-core'
import { type Blockchain, connectParachains, connectVertical, environment } from '@acala-network/chopsticks-core'
import { setupWithServer } from './index.js'
import { loadRpcMethodsByScripts, pluginExtendCli } from './plugins/index.js'
import { configSchema, fetchConfig, getYargsOptions } from './schema/index.js'
Expand Down
13 changes: 10 additions & 3 deletions packages/chopsticks/src/context.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import './utils/tunnel.js'
import { BlockEntry, GenesisProvider, defaultLogger, isUrl, setup, timeTravel } from '@acala-network/chopsticks-core'
import {
type BlockEntry,
GenesisProvider,
defaultLogger,
isUrl,
setup,
timeTravel,
} from '@acala-network/chopsticks-core'
import { SqliteDatabase } from '@acala-network/chopsticks-db'
import { HexString } from '@polkadot/util/types'
import type { HexString } from '@polkadot/util/types'
import axios from 'axios'
import { apiFetching } from './logger.js'
import { Config } from './schema/index.js'
import type { Config } from './schema/index.js'
import { startFetchStorageWorker } from './utils/fetch-storages.js'
import { overrideStorage, overrideWasm } from './utils/override.js'

Expand Down
2 changes: 1 addition & 1 deletion packages/chopsticks/src/plugins/decode-key/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { decodeKey } from '@acala-network/chopsticks-core'
import { HexString } from '@polkadot/util/types'
import type { HexString } from '@polkadot/util/types'
import type { Argv } from 'yargs'
import { setupContext } from '../../context.js'
import { configSchema, getYargsOptions } from '../../schema/index.js'
Expand Down
4 changes: 2 additions & 2 deletions packages/chopsticks/src/plugins/dry-run/dry-run-extrinsic.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { writeFileSync } from 'node:fs'
import { blake2AsHex } from '@polkadot/util-crypto'
import { HexString } from '@polkadot/util/types'
import type { HexString } from '@polkadot/util/types'

import { setupContext } from '../../context.js'
import { defaultLogger } from '../../logger.js'
import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff.js'
import { openHtml } from '../../utils/open-html.js'
import { DryRunSchemaType } from './index.js'
import type { DryRunSchemaType } from './index.js'

export const dryRunExtrinsic = async (argv: DryRunSchemaType) => {
const context = await setupContext(argv)
Expand Down
4 changes: 2 additions & 2 deletions packages/chopsticks/src/plugins/dry-run/dry-run-preimage.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { compactAddLength, hexToU8a } from '@polkadot/util'
import { blake2AsHex } from '@polkadot/util-crypto'
import { HexString } from '@polkadot/util/types'
import type { HexString } from '@polkadot/util/types'

import { Block, newHeader, runTask, setStorage, taskHandler } from '@acala-network/chopsticks-core'
import { setupContext } from '../../context.js'
import { defaultLogger } from '../../logger.js'
import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff.js'
import { openHtml } from '../../utils/open-html.js'
import { DryRunSchemaType } from './index.js'
import type { DryRunSchemaType } from './index.js'

export const dryRunPreimage = async (argv: DryRunSchemaType) => {
const context = await setupContext(argv)
Expand Down
2 changes: 1 addition & 1 deletion packages/chopsticks/src/plugins/dry-run/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from 'zod'

import { Context, ResponseError } from '@acala-network/chopsticks-core'
import { type Context, ResponseError } from '@acala-network/chopsticks-core'
import { zHash, zHex } from '../../schema/index.js'
import { decodeStorageDiff } from '../../utils/decoder.js'
import { generateHtmlDiff } from '../../utils/generate-html-diff.js'
Expand Down
4 changes: 2 additions & 2 deletions packages/chopsticks/src/plugins/follow-chain/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Block, defaultLogger, runTask, taskHandler } from '@acala-network/chopsticks-core'
import { Header } from '@polkadot/types/interfaces'
import { HexString } from '@polkadot/util/types'
import type { Header } from '@polkadot/types/interfaces'
import type { HexString } from '@polkadot/util/types'
import _ from 'lodash'
import type { Argv } from 'yargs'
import { z } from 'zod'
Expand Down
2 changes: 1 addition & 1 deletion packages/chopsticks/src/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { lstatSync, readFileSync, readdirSync } from 'node:fs'
import { Handlers, environment } from '@acala-network/chopsticks-core'
import { type Handlers, environment } from '@acala-network/chopsticks-core'
import _ from 'lodash'
import type { Argv } from 'yargs'

Expand Down
2 changes: 1 addition & 1 deletion packages/chopsticks/src/plugins/run-block/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { writeFileSync } from 'node:fs'
import { HexString } from '@polkadot/util/types'
import type { HexString } from '@polkadot/util/types'
import _ from 'lodash'
import type { Argv } from 'yargs'
import { z } from 'zod'
Expand Down
10 changes: 5 additions & 5 deletions packages/chopsticks/src/plugins/run-block/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { GenericExtrinsic } from '@polkadot/types'
import { Header } from '@polkadot/types/interfaces'
import type { GenericExtrinsic } from '@polkadot/types'
import type { Header } from '@polkadot/types/interfaces'
import { u8aToHex } from '@polkadot/util'
import { HexString } from '@polkadot/util/types'
import type { HexString } from '@polkadot/util/types'
import _ from 'lodash'
import { z } from 'zod'

import {
Block,
Context,
RuntimeLog,
type Context,
type RuntimeLog,
compactHex,
decodeKeyValue,
runTask,
Expand Down
2 changes: 1 addition & 1 deletion packages/chopsticks/src/plugins/trace-transaction/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { writeFileSync } from 'node:fs'
import { pinoLogger } from '@acala-network/chopsticks-core'
import _ from 'lodash'
import { Argv } from 'yargs'
import type { Argv } from 'yargs'
import { z } from 'zod'

import { setupContext } from '../../context.js'
Expand Down
4 changes: 2 additions & 2 deletions packages/chopsticks/src/plugins/trace-transaction/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Registry } from '@polkadot/types/types'
import { HexString } from '@polkadot/util/types'
import type { Registry } from '@polkadot/types/types'
import type { HexString } from '@polkadot/util/types'

export type CallTrace = {
type: 'CALL' | 'CALLCODE' | 'STATICCALL' | 'DELEGATECALL' | 'CREATE' | 'SUICIDE'
Expand Down
6 changes: 3 additions & 3 deletions packages/chopsticks/src/plugins/trace-transaction/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Block, Blockchain, RuntimeVersion, pinoLogger } from '@acala-network/chopsticks-core'
import { Block, type Blockchain, type RuntimeVersion, pinoLogger } from '@acala-network/chopsticks-core'
import { blake2AsHex } from '@polkadot/util-crypto'
import { HexString } from '@polkadot/util/types'
import type { HexString } from '@polkadot/util/types'
import _ from 'lodash'

import { overrideWasm } from '../../utils/override.js'
import { opName } from './table.js'
import { Step, TraceOutcome, registerTypes } from './types.js'
import { type Step, type TraceOutcome, registerTypes } from './types.js'

/**
* Fetches the runtime with tracing feature from Github releases.
Expand Down
6 changes: 3 additions & 3 deletions packages/chopsticks/src/rpc/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
Context,
Handlers,
type Context,
type Handlers,
ResponseError,
SubscriptionManager,
type SubscriptionManager,
allHandlers as coreHandlers,
defaultLogger,
} from '@acala-network/chopsticks-core'
Expand Down
6 changes: 3 additions & 3 deletions packages/chopsticks/src/schema/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { readFileSync } from 'node:fs'
import { basename, extname } from 'node:path'
import { BuildBlockMode, defaultLogger, genesisSchema, isUrl } from '@acala-network/chopsticks-core'
import { HexString } from '@polkadot/util/types'
import type { HexString } from '@polkadot/util/types'
import axios from 'axios'
import yaml from 'js-yaml'
import _ from 'lodash'
import { Options } from 'yargs'
import { ZodNativeEnum, ZodRawShape, ZodTypeAny, z } from 'zod'
import type { Options } from 'yargs'
import { ZodNativeEnum, type ZodRawShape, type ZodTypeAny, z } from 'zod'

export const zHex = z.custom<HexString>((val: any) => /^0x\w+$/.test(val))
export const zHash = z.string().length(66).and(zHex)
Expand Down
2 changes: 1 addition & 1 deletion packages/chopsticks/src/schema/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { configSchema, fetchConfig } from './index.js'
function getAllFiles(dirPath: string) {
const files = readdirSync(dirPath)
const arrayOfFiles: string[] = []
files.forEach(function (file) {
files.forEach((file) => {
arrayOfFiles.push(path.join(dirPath, '/', file))
})

Expand Down
4 changes: 2 additions & 2 deletions packages/chopsticks/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import http from 'node:http'
import { ResponseError, SubscriptionManager } from '@acala-network/chopsticks-core'
import { AddressInfo, WebSocket, WebSocketServer } from 'ws'
import { ResponseError, type SubscriptionManager } from '@acala-network/chopsticks-core'
import { type AddressInfo, WebSocket, WebSocketServer } from 'ws'
import { z } from 'zod'

import { defaultLogger, truncate } from './logger.js'
Expand Down
2 changes: 1 addition & 1 deletion packages/chopsticks/src/setup-with-server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defaultLogger } from '@acala-network/chopsticks-core'
import { setupContext } from './context.js'
import { handler } from './rpc/index.js'
import { Config } from './schema/index.js'
import type { Config } from './schema/index.js'
import { createServer } from './server.js'

export const setupWithServer = async (argv: Config) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/chopsticks/src/utils/decoder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Block, decodeBlockStorageDiff } from '@acala-network/chopsticks-core'
import { HexString } from '@polkadot/util/types'
import { type Block, decodeBlockStorageDiff } from '@acala-network/chopsticks-core'
import type { HexString } from '@polkadot/util/types'
import { create } from 'jsondiffpatch'
import _ from 'lodash'

Expand Down
6 changes: 3 additions & 3 deletions packages/chopsticks/src/utils/fetch-storages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { resolve } from 'node:path'
import { SqliteDatabase } from '@acala-network/chopsticks-db'
import { ApiPromise } from '@polkadot/api'
import { WsProvider } from '@polkadot/rpc-provider'
import { ProviderInterface } from '@polkadot/rpc-provider/types'
import type { ProviderInterface } from '@polkadot/rpc-provider/types'
import { xxhashAsHex } from '@polkadot/util-crypto'
import { HexString } from '@polkadot/util/types'
import type { HexString } from '@polkadot/util/types'
import { Like } from 'typeorm'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'

import { FetchStorageConfig, fetchStorages, getPrefixesFromConfig } from './fetch-storages.js'
import { type FetchStorageConfig, fetchStorages, getPrefixesFromConfig } from './fetch-storages.js'

describe('fetch-storages', () => {
let api: ApiPromise
Expand Down
8 changes: 4 additions & 4 deletions packages/chopsticks/src/utils/fetch-storages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { SqliteDatabase } from '@acala-network/chopsticks-db'
import { ApiPromise } from '@polkadot/api'
import { WsProvider } from '@polkadot/rpc-provider'
import { expandMetadata } from '@polkadot/types'
import { StorageEntryMetadataLatest } from '@polkadot/types/interfaces'
import { DecoratedMeta, ModuleStorage } from '@polkadot/types/metadata/decorate/types'
import { StorageEntry } from '@polkadot/types/primitive/types'
import type { StorageEntryMetadataLatest } from '@polkadot/types/interfaces'
import type { DecoratedMeta, ModuleStorage } from '@polkadot/types/metadata/decorate/types'
import type { StorageEntry } from '@polkadot/types/primitive/types'
import { compactStripLength, stringCamelCase, u8aToHex } from '@polkadot/util'
import { xxhashAsHex } from '@polkadot/util-crypto'
import { HexString } from '@polkadot/util/types'
import type { HexString } from '@polkadot/util/types'
import { releaseProxy, wrap } from 'comlink'
import nodeEndpoint from 'comlink/dist/umd/node-adapter.js'
import _ from 'lodash'
Expand Down
4 changes: 2 additions & 2 deletions packages/chopsticks/src/utils/generate-html-diff.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
import { Block } from '@acala-network/chopsticks-core'
import { HexString } from '@polkadot/util/types'
import type { Block } from '@acala-network/chopsticks-core'
import type { HexString } from '@polkadot/util/types'
import _ from 'lodash'
import { decodeStorageDiff } from './decoder.js'

Expand Down
4 changes: 2 additions & 2 deletions packages/chopsticks/src/utils/override.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { existsSync, readFileSync } from 'node:fs'
import { Blockchain, StorageValues, isUrl, setStorage } from '@acala-network/chopsticks-core'
import { HexString } from '@polkadot/util/types'
import { type Blockchain, type StorageValues, isUrl, setStorage } from '@acala-network/chopsticks-core'
import type { HexString } from '@polkadot/util/types'
import axios from 'axios'
import yaml from 'js-yaml'

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ProviderInterface, ProviderInterfaceCallback } from '@polkadot/rpc-provider/types'
import { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types'
import { HexString } from '@polkadot/util/types'
import type { ProviderInterface, ProviderInterfaceCallback } from '@polkadot/rpc-provider/types'
import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types'
import type { HexString } from '@polkadot/util/types'
import _ from 'lodash'

import { ChainProperties, Header, SignedBlock } from './index.js'
import type { ChainProperties, Header, SignedBlock } from './index.js'
import { prefixedChildKey, splitChildKey, stripChildPrefix } from './utils/index.js'

/**
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/blockchain/block-builder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GenericExtrinsic } from '@polkadot/types'
import {
import type { GenericExtrinsic } from '@polkadot/types'
import type {
AccountInfo,
ApplyExtrinsicResult,
Call,
Expand All @@ -11,14 +11,14 @@ import {
} from '@polkadot/types/interfaces'
import { compactAddLength, hexToU8a, stringToHex, u8aConcat } from '@polkadot/util'
import { blake2AsU8a } from '@polkadot/util-crypto'
import { HexString } from '@polkadot/util/types'
import type { HexString } from '@polkadot/util/types'
import { defaultLogger, truncate } from '../logger.js'
import { compactHex, getCurrentSlot } from '../utils/index.js'
import { TaskCallResponse } from '../wasm-executor/index.js'
import type { TaskCallResponse } from '../wasm-executor/index.js'
import { Block } from './block.js'
import { InherentProvider } from './inherent/index.js'
import type { InherentProvider } from './inherent/index.js'
import { StorageLayer, StorageValueKind } from './storage-layer.js'
import { BuildBlockParams } from './txpool.js'
import type { BuildBlockParams } from './txpool.js'

const logger = defaultLogger.child({ name: 'block-builder' })

Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/blockchain/block.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Metadata, TypeRegistry } from '@polkadot/types'
import { Header } from '@polkadot/types/interfaces'
import { Metadata, type TypeRegistry } from '@polkadot/types'
import type { Header } from '@polkadot/types/interfaces'
import { expandMetadata } from '@polkadot/types/metadata'
import { DecoratedMeta } from '@polkadot/types/metadata/decorate/types'
import { StorageEntry } from '@polkadot/types/primitive/types'
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types'
import type { StorageEntry } from '@polkadot/types/primitive/types'
import { hexToU8a, stringToHex } from '@polkadot/util'
import type { HexString } from '@polkadot/util/types'

import { compactHex } from '../utils/index.js'
import { getRuntimeVersion, runTask, taskHandler } from '../wasm-executor/index.js'
import type { RuntimeVersion, TaskCallResponse } from '../wasm-executor/index.js'
import { Blockchain } from './index.js'
import type { Blockchain } from './index.js'
import {
RemoteStorageLayer,
StorageLayer,
StorageLayerProvider,
StorageValue,
type StorageLayerProvider,
type StorageValue,
StorageValueKind,
} from './storage-layer.js'

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/blockchain/get-keys-paged.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash'
import { describe, expect, it, vi } from 'vitest'
import { Api } from '../api.js'
import { RemoteStorageLayer, StorageLayer, StorageValue, StorageValueKind } from './storage-layer.js'
import { RemoteStorageLayer, StorageLayer, type StorageValue, StorageValueKind } from './storage-layer.js'

describe('getKeysPaged', () => {
const hash = '0x1111111111111111111111111111111111111111111111111111111111111111'
Expand Down Expand Up @@ -462,7 +462,7 @@ describe('getKeysPaged', () => {
}

const allKeys = pages
.flatMap((x) => x)
.flat()
.reduce((acc, x) => {
if (acc.includes(x)) {
return acc
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/blockchain/head-state.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defaultLogger } from '../logger.js'
import { Block } from './block.js'
import type { Block } from './block.js'

type Callback = (block: Block, pairs: [string, string | null][]) => void | Promise<void>

Expand Down
Loading

0 comments on commit e96ebb5

Please sign in to comment.