diff --git a/executor/Cargo.lock b/executor/Cargo.lock index b44acfb2..168b5b62 100644 --- a/executor/Cargo.lock +++ b/executor/Cargo.lock @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "chopsticks-executor" -version = "0.9.1-3" +version = "0.9.1-4" dependencies = [ "arrayvec 0.7.4", "console_error_panic_hook", diff --git a/executor/Cargo.toml b/executor/Cargo.toml index 94fa1e8b..3e97ec3f 100644 --- a/executor/Cargo.toml +++ b/executor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chopsticks-executor" -version = "0.9.1-3" +version = "0.9.1-4" description = "Chopsticks executor" repository = "https://github.com/AcalaNetwork/chopsticks" license = "Apache-2.0" diff --git a/executor/package.json b/executor/package.json index b05740cb..be5a1950 100644 --- a/executor/package.json +++ b/executor/package.json @@ -1,7 +1,7 @@ { "name": "@acala-network/chopsticks-executor", "description": "Chopsticks executor", - "version": "0.9.1-3", + "version": "0.9.1-4", "license": "Apache-2.0", "repository": { "type": "git", diff --git a/executor/src/lib.rs b/executor/src/lib.rs index 4db121e9..222092d3 100644 --- a/executor/src/lib.rs +++ b/executor/src/lib.rs @@ -18,7 +18,7 @@ fn setup_console(level: Option) { #[wasm_bindgen(typescript_custom_section)] const _: &'static str = r#" -import { HexString } from '@polkadot/util/types'; +type HexString = `0x${string}`; export interface JsCallback { getStorage: (key: HexString) => Promise getStateRoot: () => Promise diff --git a/packages/chopsticks/package.json b/packages/chopsticks/package.json index 1485b8f3..dadd3c00 100644 --- a/packages/chopsticks/package.json +++ b/packages/chopsticks/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks", - "version": "0.9.1-3", + "version": "0.9.1-4", "author": "Acala Developers ", "license": "Apache-2.0", "bin": "./chopsticks.cjs", @@ -55,10 +55,10 @@ "default": "./dist/esm/index.js" }, "./*": { - "types": "./dist/types/index.d.ts", - "require": "./dist/cjs/index.js", - "import": "./dist/esm/index.js", - "default": "./dist/esm/index.js" + "types": "./dist/types/*.d.ts", + "require": "./dist/cjs/*.js", + "import": "./dist/esm/*.js", + "default": "./dist/esm/*.js" }, "./plugins/*": { "types": "./dist/types/plugins/*.d.ts", diff --git a/packages/chopsticks/src/cli.ts b/packages/chopsticks/src/cli.ts index fc90a569..f1a9efb4 100644 --- a/packages/chopsticks/src/cli.ts +++ b/packages/chopsticks/src/cli.ts @@ -5,10 +5,10 @@ import yargs from 'yargs' import type { MiddlewareFunction } from 'yargs' import { Blockchain, BuildBlockMode, connectParachains, connectVertical } from '@acala-network/chopsticks-core' -import { Config, fetchConfig } from './schema' -import { defaultOptions, mockOptions } from './cli-options' -import { pluginExtendCli } from './plugins' -import { setupWithServer } from '.' +import { Config, fetchConfig } from './schema/index.js' +import { defaultOptions, mockOptions } from './cli-options.js' +import { pluginExtendCli } from './plugins/index.js' +import { setupWithServer } from './index.js' dotenvConfig() diff --git a/packages/chopsticks/src/context.ts b/packages/chopsticks/src/context.ts index 06492c46..2b8872c7 100644 --- a/packages/chopsticks/src/context.ts +++ b/packages/chopsticks/src/context.ts @@ -1,9 +1,9 @@ -import './utils/tunnel' +import './utils/tunnel.js' import { BlockEntry, GenesisProvider, defaultLogger, isUrl, setup, timeTravel } from '@acala-network/chopsticks-core' -import { Config } from './schema' +import { Config } from './schema/index.js' import { HexString } from '@polkadot/util/types' import { SqliteDatabase } from '@acala-network/chopsticks-db' -import { overrideStorage, overrideWasm } from './utils/override' +import { overrideStorage, overrideWasm } from './utils/override.js' import axios from 'axios' const logger = defaultLogger.child({ name: 'setup-context' }) diff --git a/packages/chopsticks/src/index.ts b/packages/chopsticks/src/index.ts index 8e2dbeea..55dfc792 100644 --- a/packages/chopsticks/src/index.ts +++ b/packages/chopsticks/src/index.ts @@ -1,5 +1,5 @@ import '@polkadot/api-augment' export * from '@acala-network/chopsticks-core' -export { setupWithServer } from './setup-with-server' -export { fetchConfig } from './schema' +export { setupWithServer } from './setup-with-server.js' +export { fetchConfig } from './schema/index.js' diff --git a/packages/chopsticks/src/plugins/decode-key/index.ts b/packages/chopsticks/src/plugins/decode-key/index.ts index 805ce2fb..7832d690 100644 --- a/packages/chopsticks/src/plugins/decode-key/index.ts +++ b/packages/chopsticks/src/plugins/decode-key/index.ts @@ -1,8 +1,8 @@ -import { Config } from '../../schema' +import { Config } from '../../schema/index.js' import { HexString } from '@polkadot/util/types' import { decodeKey } from '@acala-network/chopsticks-core' -import { defaultOptions } from '../../cli-options' -import { setupContext } from '../../context' +import { defaultOptions } from '../../cli-options.js' +import { setupContext } from '../../context.js' import type { Argv } from 'yargs' export const cli = (y: Argv) => { diff --git a/packages/chopsticks/src/plugins/dry-run/cli.ts b/packages/chopsticks/src/plugins/dry-run/cli.ts index 06d47003..44f849d2 100644 --- a/packages/chopsticks/src/plugins/dry-run/cli.ts +++ b/packages/chopsticks/src/plugins/dry-run/cli.ts @@ -1,7 +1,7 @@ -import { Config } from '../../schema' -import { defaultOptions, mockOptions } from '../../cli-options' -import { dryRunExtrinsic } from './dry-run-extrinsic' -import { dryRunPreimage } from './dry-run-preimage' +import { Config } from '../../schema/index.js' +import { defaultOptions, mockOptions } from '../../cli-options.js' +import { dryRunExtrinsic } from './dry-run-extrinsic.js' +import { dryRunPreimage } from './dry-run-preimage.js' import type { Argv } from 'yargs' export const cli = (y: Argv) => { diff --git a/packages/chopsticks/src/plugins/dry-run/dry-run-extrinsic.ts b/packages/chopsticks/src/plugins/dry-run/dry-run-extrinsic.ts index 0e36b75c..2e1c4476 100644 --- a/packages/chopsticks/src/plugins/dry-run/dry-run-extrinsic.ts +++ b/packages/chopsticks/src/plugins/dry-run/dry-run-extrinsic.ts @@ -1,11 +1,11 @@ import { blake2AsHex } from '@polkadot/util-crypto' import { writeFileSync } from 'node:fs' -import { Config } from '../../schema' -import { defaultLogger } from '../../logger' -import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff' -import { openHtml } from '../../utils/open-html' -import { setupContext } from '../../context' +import { Config } from '../../schema/index.js' +import { defaultLogger } from '../../logger.js' +import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff.js' +import { openHtml } from '../../utils/open-html.js' +import { setupContext } from '../../context.js' export const dryRunExtrinsic = async (argv: Config) => { const context = await setupContext(argv) diff --git a/packages/chopsticks/src/plugins/dry-run/dry-run-preimage.ts b/packages/chopsticks/src/plugins/dry-run/dry-run-preimage.ts index 20bb0bbd..57b24ddb 100644 --- a/packages/chopsticks/src/plugins/dry-run/dry-run-preimage.ts +++ b/packages/chopsticks/src/plugins/dry-run/dry-run-preimage.ts @@ -2,12 +2,12 @@ import { HexString } from '@polkadot/util/types' import { blake2AsHex } from '@polkadot/util-crypto' import { hexToU8a } from '@polkadot/util' -import { Config } from '../../schema' -import { defaultLogger } from '../../logger' -import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff' +import { Config } from '../../schema/index.js' +import { defaultLogger } from '../../logger.js' +import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff.js' import { newHeader, printRuntimeLogs, runTask, setStorage, taskHandler } from '@acala-network/chopsticks-core' -import { openHtml } from '../../utils/open-html' -import { setupContext } from '../../context' +import { openHtml } from '../../utils/open-html.js' +import { setupContext } from '../../context.js' export const dryRunPreimage = async (argv: Config) => { const context = await setupContext(argv) diff --git a/packages/chopsticks/src/plugins/dry-run/index.ts b/packages/chopsticks/src/plugins/dry-run/index.ts index 133b11a9..643a40b0 100644 --- a/packages/chopsticks/src/plugins/dry-run/index.ts +++ b/packages/chopsticks/src/plugins/dry-run/index.ts @@ -1,2 +1,2 @@ -export * from './cli' -export * from './rpc' +export * from './cli.js' +export * from './rpc.js' diff --git a/packages/chopsticks/src/plugins/dry-run/rpc.ts b/packages/chopsticks/src/plugins/dry-run/rpc.ts index cf7df473..e9808d33 100644 --- a/packages/chopsticks/src/plugins/dry-run/rpc.ts +++ b/packages/chopsticks/src/plugins/dry-run/rpc.ts @@ -2,8 +2,8 @@ import { HexString } from '@polkadot/util/types' import { z } from 'zod' import { Context, ResponseError } from '@acala-network/chopsticks-core' -import { decodeStorageDiff } from '../../utils/decoder' -import { generateHtmlDiff } from '../../utils/generate-html-diff' +import { decodeStorageDiff } from '../../utils/decoder.js' +import { generateHtmlDiff } from '../../utils/generate-html-diff.js' const zHex = z.custom((val: any) => /^0x\w+$/.test(val)) const zHash = z.string().length(66).and(zHex) diff --git a/packages/chopsticks/src/plugins/follow-chain/index.ts b/packages/chopsticks/src/plugins/follow-chain/index.ts index 090a0229..f6a9d28c 100644 --- a/packages/chopsticks/src/plugins/follow-chain/index.ts +++ b/packages/chopsticks/src/plugins/follow-chain/index.ts @@ -4,11 +4,11 @@ import { HexString } from '@polkadot/util/types' import _ from 'lodash' import type { Argv } from 'yargs' -import { createServer } from '../../server' -import { defaultOptions } from '../../cli-options' -import { handler } from '../../rpc' -import { setupContext } from '../../context' -import type { Config } from '../../schema' +import { createServer } from '../../server.js' +import { defaultOptions } from '../../cli-options.js' +import { handler } from '../../rpc/index.js' +import { setupContext } from '../../context.js' +import type { Config } from '../../schema/index.js' const logger = defaultLogger.child({ name: 'follow-chain' }) const options = _.pick(defaultOptions, ['endpoint', 'wasm-override', 'runtime-log-level', 'offchain-worker']) diff --git a/packages/chopsticks/src/plugins/index.ts b/packages/chopsticks/src/plugins/index.ts index 02cf8dc6..deef849c 100644 --- a/packages/chopsticks/src/plugins/index.ts +++ b/packages/chopsticks/src/plugins/index.ts @@ -2,7 +2,7 @@ import { Handlers } from '@acala-network/chopsticks-core' import _ from 'lodash' import type { Argv } from 'yargs' -import { defaultLogger } from '../logger' +import { defaultLogger } from '../logger.js' const logger = defaultLogger.child({ name: 'plugin' }) diff --git a/packages/chopsticks/src/plugins/new-block/index.ts b/packages/chopsticks/src/plugins/new-block/index.ts index c7ecb343..9193f3ce 100644 --- a/packages/chopsticks/src/plugins/new-block/index.ts +++ b/packages/chopsticks/src/plugins/new-block/index.ts @@ -1,6 +1,6 @@ import { Context, DownwardMessage, HorizontalMessage, ResponseError } from '@acala-network/chopsticks-core' import { HexString } from '@polkadot/util/types' -import { defaultLogger } from '../../logger' +import { defaultLogger } from '../../logger.js' export interface NewBlockParams { /** diff --git a/packages/chopsticks/src/plugins/run-block/index.test.ts b/packages/chopsticks/src/plugins/run-block/index.test.ts index 4e69cf4b..1d9426c9 100644 --- a/packages/chopsticks/src/plugins/run-block/index.test.ts +++ b/packages/chopsticks/src/plugins/run-block/index.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest' import { setup } from '@acala-network/chopsticks-core' -import { rpc } from '.' +import { rpc } from './index.js' describe('run-block', () => { it('should work', async () => { diff --git a/packages/chopsticks/src/plugins/run-block/index.ts b/packages/chopsticks/src/plugins/run-block/index.ts index 0f3dabe8..3ac05d94 100644 --- a/packages/chopsticks/src/plugins/run-block/index.ts +++ b/packages/chopsticks/src/plugins/run-block/index.ts @@ -18,11 +18,11 @@ import { taskHandler, } from '@acala-network/chopsticks-core' -import { Config } from '../../schema' -import { defaultOptions, mockOptions } from '../../cli-options' -import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff' -import { openHtml } from '../../utils/open-html' -import { setupContext } from '../../context' +import { Config } from '../../schema/index.js' +import { defaultOptions, mockOptions } from '../../cli-options.js' +import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff.js' +import { openHtml } from '../../utils/open-html.js' +import { setupContext } from '../../context.js' export const cli = (y: Argv) => { y.command( diff --git a/packages/chopsticks/src/plugins/set-block-build-mode/index.ts b/packages/chopsticks/src/plugins/set-block-build-mode/index.ts index 72f662c4..e5bbed6e 100644 --- a/packages/chopsticks/src/plugins/set-block-build-mode/index.ts +++ b/packages/chopsticks/src/plugins/set-block-build-mode/index.ts @@ -1,5 +1,5 @@ import { BuildBlockMode, Context, ResponseError } from '@acala-network/chopsticks-core' -import { defaultLogger } from '../../logger' +import { defaultLogger } from '../../logger.js' /** * Set a build block mode. See [BuildBlockMode](../core/enums/BuildBlockMode). diff --git a/packages/chopsticks/src/plugins/set-runtime-log-level/index.ts b/packages/chopsticks/src/plugins/set-runtime-log-level/index.ts index 0e0daf13..3c22b983 100644 --- a/packages/chopsticks/src/plugins/set-runtime-log-level/index.ts +++ b/packages/chopsticks/src/plugins/set-runtime-log-level/index.ts @@ -1,5 +1,5 @@ import { Context, ResponseError } from '@acala-network/chopsticks-core' -import { defaultLogger } from '../../logger' +import { defaultLogger } from '../../logger.js' /** * Set runtime log level. diff --git a/packages/chopsticks/src/plugins/set-storage/index.ts b/packages/chopsticks/src/plugins/set-storage/index.ts index a291c3bb..2e39aff4 100644 --- a/packages/chopsticks/src/plugins/set-storage/index.ts +++ b/packages/chopsticks/src/plugins/set-storage/index.ts @@ -1,7 +1,7 @@ import { Context, ResponseError, StorageValues, setStorage } from '@acala-network/chopsticks-core' import { HexString } from '@polkadot/util/types' -import { defaultLogger } from '../../logger' +import { defaultLogger } from '../../logger.js' /** * Set storage values. diff --git a/packages/chopsticks/src/plugins/try-runtime/index.ts b/packages/chopsticks/src/plugins/try-runtime/index.ts index 6e2384c7..a1098e8b 100644 --- a/packages/chopsticks/src/plugins/try-runtime/index.ts +++ b/packages/chopsticks/src/plugins/try-runtime/index.ts @@ -1,11 +1,11 @@ import { writeFileSync } from 'node:fs' import type { Argv } from 'yargs' -import { Config } from '../../schema' -import { defaultOptions } from '../../cli-options' -import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff' -import { openHtml } from '../../utils/open-html' -import { setupContext } from '../../context' +import { Config } from '../../schema/index.js' +import { defaultOptions } from '../../cli-options.js' +import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff.js' +import { openHtml } from '../../utils/open-html.js' +import { setupContext } from '../../context.js' export const cli = (y: Argv) => { y.command( diff --git a/packages/chopsticks/src/plugins/types.ts b/packages/chopsticks/src/plugins/types.ts index d36ce340..6723c4bb 100644 --- a/packages/chopsticks/src/plugins/types.ts +++ b/packages/chopsticks/src/plugins/types.ts @@ -1,12 +1,12 @@ -export { rpc as newBlock } from './new-block' -export { rpc as dryRun } from './dry-run' -export { rpc as setBlockBuildMode } from './set-block-build-mode' -export { rpc as setHead } from './set-head' -export { rpc as setRuntimeLogLevel } from './set-runtime-log-level' -export { rpc as setStorage } from './set-storage' -export { rpc as timeTravel } from './time-travel' -export { rpc as runBlock } from './run-block' +export { rpc as newBlock } from './new-block/index.js' +export { rpc as dryRun } from './dry-run/index.js' +export { rpc as setBlockBuildMode } from './set-block-build-mode/index.js' +export { rpc as setHead } from './set-head/index.js' +export { rpc as setRuntimeLogLevel } from './set-runtime-log-level/index.js' +export { rpc as setStorage } from './set-storage/index.js' +export { rpc as timeTravel } from './time-travel/index.js' +export { rpc as runBlock } from './run-block/index.js' -export type { NewBlockParams } from './new-block' -export type { DryRunParams } from './dry-run' -export type { RunBlockParams } from './run-block' +export type { NewBlockParams } from './new-block/index.js' +export type { DryRunParams } from './dry-run/index.js' +export type { RunBlockParams } from './run-block/index.js' diff --git a/packages/chopsticks/src/rpc/index.ts b/packages/chopsticks/src/rpc/index.ts index abfd4374..fb5066cc 100644 --- a/packages/chopsticks/src/rpc/index.ts +++ b/packages/chopsticks/src/rpc/index.ts @@ -7,7 +7,7 @@ import { substrate, } from '@acala-network/chopsticks-core' -import { pluginHandlers } from '../plugins' +import { pluginHandlers } from '../plugins/index.js' const allHandlers: Handlers = { ...substrate, diff --git a/packages/chopsticks/src/server.ts b/packages/chopsticks/src/server.ts index 901ce44e..bd498777 100644 --- a/packages/chopsticks/src/server.ts +++ b/packages/chopsticks/src/server.ts @@ -2,7 +2,7 @@ import { AddressInfo, WebSocket, WebSocketServer } from 'ws' import { ResponseError, SubscriptionManager } from '@acala-network/chopsticks-core' import { z } from 'zod' -import { defaultLogger, truncate } from './logger' +import { defaultLogger, truncate } from './logger.js' const logger = defaultLogger.child({ name: 'ws' }) diff --git a/packages/chopsticks/src/setup-with-server.ts b/packages/chopsticks/src/setup-with-server.ts index 5e2e83ac..2ef329ae 100644 --- a/packages/chopsticks/src/setup-with-server.ts +++ b/packages/chopsticks/src/setup-with-server.ts @@ -1,8 +1,8 @@ -import { Config } from './schema' -import { createServer } from './server' -import { handler } from './rpc' +import { Config } from './schema/index.js' +import { createServer } from './server.js' +import { handler } from './rpc/index.js' import { logger } from '@acala-network/chopsticks-core' -import { setupContext } from './context' +import { setupContext } from './context.js' export const setupWithServer = async (argv: Config) => { const context = await setupContext(argv) diff --git a/packages/chopsticks/src/types.ts b/packages/chopsticks/src/types.ts index 756a1844..519812a2 100644 --- a/packages/chopsticks/src/types.ts +++ b/packages/chopsticks/src/types.ts @@ -17,5 +17,5 @@ export type { SubscriptionManager, Handler, } from '@acala-network/chopsticks-core' -export * from '@acala-network/chopsticks-core/src/rpc/substrate' -export * from './plugins/types' +export * from '@acala-network/chopsticks-core/rpc/substrate/index.js' +export * from './plugins/types.js' diff --git a/packages/chopsticks/src/utils/generate-html-diff.ts b/packages/chopsticks/src/utils/generate-html-diff.ts index d33d340c..33ba1a5f 100644 --- a/packages/chopsticks/src/utils/generate-html-diff.ts +++ b/packages/chopsticks/src/utils/generate-html-diff.ts @@ -1,6 +1,6 @@ import { Block } from '@acala-network/chopsticks-core' import { HexString } from '@polkadot/util/types' -import { decodeStorageDiff } from './decoder' +import { decodeStorageDiff } from './decoder.js' import { mkdirSync, readFileSync, writeFileSync } from 'node:fs' import _ from 'lodash' diff --git a/packages/chopsticks/src/utils/index.ts b/packages/chopsticks/src/utils/index.ts index 9c5468de..80f81f69 100644 --- a/packages/chopsticks/src/utils/index.ts +++ b/packages/chopsticks/src/utils/index.ts @@ -1,4 +1,4 @@ -export * from './decoder' -export * from './generate-html-diff' -export * from './open-html' -export * from './override' +export * from './decoder.js' +export * from './generate-html-diff.js' +export * from './open-html.js' +export * from './override.js' diff --git a/packages/chopsticks/src/utils/override.ts b/packages/chopsticks/src/utils/override.ts index 3e06be06..34e4e5c1 100644 --- a/packages/chopsticks/src/utils/override.ts +++ b/packages/chopsticks/src/utils/override.ts @@ -3,7 +3,7 @@ import { HexString } from '@polkadot/util/types' import { existsSync, readFileSync } from 'node:fs' import yaml from 'js-yaml' -import { defaultLogger } from '../logger' +import { defaultLogger } from '../logger.js' export const overrideStorage = async (chain: Blockchain, storage?: string | StorageValues, at?: HexString) => { if (storage == null) { diff --git a/packages/core/package.json b/packages/core/package.json index 6729eba6..734d3927 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks-core", - "version": "0.9.1-3", + "version": "0.9.1-4", "author": "Acala Developers ", "license": "Apache-2.0", "type": "module", @@ -45,10 +45,10 @@ "default": "./dist/esm/index.js" }, "./*": { - "types": "./dist/esm/index.d.ts", - "require": "./dist/cjs/index.js", - "import": "./dist/esm/index.js", - "default": "./dist/esm/index.js" + "types": "./dist/types/*.d.ts", + "require": "./dist/cjs/*.js", + "import": "./dist/esm/*.js", + "default": "./dist/esm/*.js" }, "./package.json": "./package.json", "./package.cjs.json": "./dist/cjs/package.json" diff --git a/packages/core/src/api.test.ts b/packages/core/src/api.test.ts index db969248..93b48d66 100644 --- a/packages/core/src/api.test.ts +++ b/packages/core/src/api.test.ts @@ -1,4 +1,4 @@ -import { Api } from './api' +import { Api } from './api.js' import { WsProvider } from '@polkadot/rpc-provider' import { expect, test } from 'vitest' diff --git a/packages/core/src/api.ts b/packages/core/src/api.ts index 55d12080..ab6c402b 100644 --- a/packages/core/src/api.ts +++ b/packages/core/src/api.ts @@ -1,7 +1,7 @@ import { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types' import { HexString } from '@polkadot/util/types' import { ProviderInterface, ProviderInterfaceCallback } from '@polkadot/rpc-provider/types' -import { prefixedChildKey, splitChildKey, stripChildPrefix } from './utils' +import { prefixedChildKey, splitChildKey, stripChildPrefix } from './utils/index.js' export type ChainProperties = { ss58Format?: number diff --git a/packages/core/src/blockchain/block-builder.ts b/packages/core/src/blockchain/block-builder.ts index 46cc65e4..eeefe6a6 100644 --- a/packages/core/src/blockchain/block-builder.ts +++ b/packages/core/src/blockchain/block-builder.ts @@ -6,15 +6,15 @@ import { RawBabePreDigest, TransactionValidityError, } from '@polkadot/types/interfaces' -import { Block } from './block' +import { Block } from './block.js' import { GenericExtrinsic } from '@polkadot/types' import { HexString } from '@polkadot/util/types' -import { StorageLayer, StorageValueKind } from './storage-layer' -import { TaskCallResponse } from '../wasm-executor' +import { StorageLayer, StorageValueKind } from './storage-layer.js' +import { TaskCallResponse } from '../wasm-executor/index.js' import { compactAddLength, hexToU8a, stringToHex, u8aConcat } from '@polkadot/util' -import { compactHex } from '../utils' -import { defaultLogger, truncate } from '../logger' -import { getCurrentSlot } from '../utils/time-travel' +import { compactHex } from '../utils/index.js' +import { defaultLogger, truncate } from '../logger.js' +import { getCurrentSlot } from '../utils/time-travel.js' const logger = defaultLogger.child({ name: 'block-builder' }) diff --git a/packages/core/src/blockchain/block.ts b/packages/core/src/blockchain/block.ts index 42664716..0bc3c8e7 100644 --- a/packages/core/src/blockchain/block.ts +++ b/packages/core/src/blockchain/block.ts @@ -8,11 +8,17 @@ import { hexToU8a, objectSpread, stringToHex } from '@polkadot/util' import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types' import type { HexString } from '@polkadot/util/types' -import { Blockchain } from '.' -import { RemoteStorageLayer, StorageLayer, StorageLayerProvider, StorageValue, StorageValueKind } from './storage-layer' -import { compactHex, printRuntimeLogs } from '../utils' -import { getRuntimeVersion, runTask, taskHandler } from '../wasm-executor' -import type { RuntimeVersion, TaskCallResponse } from '../wasm-executor' +import { Blockchain } from './index.js' +import { + RemoteStorageLayer, + StorageLayer, + StorageLayerProvider, + StorageValue, + StorageValueKind, +} from './storage-layer.js' +import { compactHex, printRuntimeLogs } from '../utils/index.js' +import { getRuntimeVersion, runTask, taskHandler } from '../wasm-executor/index.js' +import type { RuntimeVersion, TaskCallResponse } from '../wasm-executor/index.js' /** * Block class. diff --git a/packages/core/src/blockchain/head-state.ts b/packages/core/src/blockchain/head-state.ts index 306661ca..815f4c4c 100644 --- a/packages/core/src/blockchain/head-state.ts +++ b/packages/core/src/blockchain/head-state.ts @@ -1,7 +1,7 @@ import { stringToHex } from '@polkadot/util' -import { Block } from './block' -import { defaultLogger } from '../logger' +import { Block } from './block.js' +import { defaultLogger } from '../logger.js' type Callback = (block: Block, pairs: [string, string | null][]) => void | Promise diff --git a/packages/core/src/blockchain/index.ts b/packages/core/src/blockchain/index.ts index 26721391..32939818 100644 --- a/packages/core/src/blockchain/index.ts +++ b/packages/core/src/blockchain/index.ts @@ -5,18 +5,18 @@ import { blake2AsHex } from '@polkadot/util-crypto' import { u8aConcat, u8aToHex } from '@polkadot/util' import type { TransactionValidity } from '@polkadot/types/interfaces/txqueue' -import { Api } from '../api' -import { Block } from './block' -import { BuildBlockMode, BuildBlockParams, DownwardMessage, HorizontalMessage, TxPool } from './txpool' -import { Database } from '../database' -import { HeadState } from './head-state' -import { InherentProvider } from './inherent' -import { OffchainWorker } from '../offchain' -import { StorageValue } from './storage-layer' -import { compactHex } from '../utils' -import { defaultLogger } from '../logger' -import { dryRunExtrinsic, dryRunInherents } from './block-builder' -import { releaseWorker } from '../wasm-executor' +import { Api } from '../api.js' +import { Block } from './block.js' +import { BuildBlockMode, BuildBlockParams, DownwardMessage, HorizontalMessage, TxPool } from './txpool.js' +import { Database } from '../database.js' +import { HeadState } from './head-state.js' +import { InherentProvider } from './inherent/index.js' +import { OffchainWorker } from '../offchain.js' +import { StorageValue } from './storage-layer.js' +import { compactHex } from '../utils/index.js' +import { defaultLogger } from '../logger.js' +import { dryRunExtrinsic, dryRunInherents } from './block-builder.js' +import { releaseWorker } from '../wasm-executor/index.js' const logger = defaultLogger.child({ name: 'blockchain' }) diff --git a/packages/core/src/blockchain/inherent/index.ts b/packages/core/src/blockchain/inherent/index.ts index 32f265a0..6bc6856c 100644 --- a/packages/core/src/blockchain/inherent/index.ts +++ b/packages/core/src/blockchain/inherent/index.ts @@ -1,13 +1,13 @@ -import { Block } from '../block' -import { BuildBlockParams } from '../txpool' +import { Block } from '../block.js' +import { BuildBlockParams } from '../txpool.js' import { GenericExtrinsic } from '@polkadot/types' import { HexString } from '@polkadot/util/types' -import { getCurrentTimestamp, getSlotDuration } from '../../utils/time-travel' +import { getCurrentTimestamp, getSlotDuration } from '../../utils/time-travel.js' -export { SetValidationData } from './parachain/validation-data' -export { ParaInherentEnter } from './para-enter' -export { SetBabeRandomness } from './parachain/babe-randomness' -export { SetNimbusAuthorInherent } from './parachain/nimbus-author-inherent' +export { SetValidationData } from './parachain/validation-data.js' +export { ParaInherentEnter } from './para-enter.js' +export { SetBabeRandomness } from './parachain/babe-randomness.js' +export { SetNimbusAuthorInherent } from './parachain/nimbus-author-inherent.js' export interface CreateInherents { createInherents(parent: Block, params: BuildBlockParams): Promise diff --git a/packages/core/src/blockchain/inherent/para-enter.ts b/packages/core/src/blockchain/inherent/para-enter.ts index a5cf1a4c..75345991 100644 --- a/packages/core/src/blockchain/inherent/para-enter.ts +++ b/packages/core/src/blockchain/inherent/para-enter.ts @@ -1,9 +1,9 @@ import { GenericExtrinsic } from '@polkadot/types' import { HexString } from '@polkadot/util/types' -import { Block } from '../block' -import { BuildBlockParams } from '../txpool' -import { CreateInherents } from '.' +import { Block } from '../block.js' +import { BuildBlockParams } from '../txpool.js' +import { CreateInherents } from './index.js' export class ParaInherentEnter implements CreateInherents { async createInherents(parent: Block, _params: BuildBlockParams): Promise { diff --git a/packages/core/src/blockchain/inherent/parachain/babe-randomness.ts b/packages/core/src/blockchain/inherent/parachain/babe-randomness.ts index 4e3c35d2..e883dc11 100644 --- a/packages/core/src/blockchain/inherent/parachain/babe-randomness.ts +++ b/packages/core/src/blockchain/inherent/parachain/babe-randomness.ts @@ -1,9 +1,9 @@ import { GenericExtrinsic } from '@polkadot/types' import { HexString } from '@polkadot/util/types' -import { Block } from '../../block' -import { BuildBlockParams } from '../../txpool' -import { CreateInherents } from '..' +import { Block } from '../../block.js' +import { BuildBlockParams } from '../../txpool.js' +import { CreateInherents } from '../index.js' // Support for Moonbeam pallet-randomness mandatory inherent export class SetBabeRandomness implements CreateInherents { diff --git a/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts b/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts index d6684cb9..ff5d8e31 100644 --- a/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts +++ b/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts @@ -1,9 +1,9 @@ import { GenericExtrinsic } from '@polkadot/types' import { HexString } from '@polkadot/util/types' -import { Block } from '../../block' -import { BuildBlockParams } from '../../txpool' -import { CreateInherents } from '..' +import { Block } from '../../block.js' +import { BuildBlockParams } from '../../txpool.js' +import { CreateInherents } from '../index.js' // Support for Nimbus Author Inherent export class SetNimbusAuthorInherent implements CreateInherents { diff --git a/packages/core/src/blockchain/inherent/parachain/validation-data.ts b/packages/core/src/blockchain/inherent/parachain/validation-data.ts index f8d56947..a953257c 100644 --- a/packages/core/src/blockchain/inherent/parachain/validation-data.ts +++ b/packages/core/src/blockchain/inherent/parachain/validation-data.ts @@ -4,9 +4,9 @@ import { HexString } from '@polkadot/util/types' import { hexToU8a, u8aConcat } from '@polkadot/util' import _ from 'lodash' -import { Block } from '../../block' -import { BuildBlockParams, DownwardMessage, HorizontalMessage } from '../../txpool' -import { CreateInherents } from '..' +import { Block } from '../../block.js' +import { BuildBlockParams, DownwardMessage, HorizontalMessage } from '../../txpool.js' +import { CreateInherents } from '../index.js' import { WELL_KNOWN_KEYS, dmqMqcHead, @@ -14,10 +14,10 @@ import { hrmpEgressChannelIndex, hrmpIngressChannelIndex, upgradeGoAheadSignal, -} from '../../../utils/proof' +} from '../../../utils/proof.js' import { blake2AsHex, blake2AsU8a } from '@polkadot/util-crypto' -import { compactHex, getParaId } from '../../../utils' -import { createProof, decodeProof } from '../../../wasm-executor' +import { compactHex, getParaId } from '../../../utils/index.js' +import { createProof, decodeProof } from '../../../wasm-executor/index.js' const MOCK_VALIDATION_DATA = { validationData: { diff --git a/packages/core/src/blockchain/storage-layer.ts b/packages/core/src/blockchain/storage-layer.ts index 5c75b553..3d1848ed 100644 --- a/packages/core/src/blockchain/storage-layer.ts +++ b/packages/core/src/blockchain/storage-layer.ts @@ -1,10 +1,10 @@ import { HexString } from '@polkadot/util/types' import _ from 'lodash' -import { Api } from '../api' -import { Database } from '../database' -import { defaultLogger } from '../logger' -import KeyCache, { PREFIX_LENGTH } from '../utils/key-cache' +import { Api } from '../api.js' +import { Database } from '../database.js' +import { defaultLogger } from '../logger.js' +import KeyCache, { PREFIX_LENGTH } from '../utils/key-cache.js' const logger = defaultLogger.child({ name: 'layer' }) diff --git a/packages/core/src/blockchain/txpool.ts b/packages/core/src/blockchain/txpool.ts index 3f07e49a..740c065c 100644 --- a/packages/core/src/blockchain/txpool.ts +++ b/packages/core/src/blockchain/txpool.ts @@ -1,13 +1,13 @@ -import { default as EventEmitter } from 'eventemitter3' +import { EventEmitter } from 'eventemitter3' import { GenericExtrinsic } from '@polkadot/types' import { HexString } from '@polkadot/util/types' import _ from 'lodash' -import { Blockchain } from '.' -import { Deferred, defer } from '../utils' -import { InherentProvider } from './inherent' -import { buildBlock } from './block-builder' -import { defaultLogger, truncate } from '../logger' +import { Blockchain } from './index.js' +import { Deferred, defer } from '../utils/index.js' +import { InherentProvider } from './inherent/index.js' +import { buildBlock } from './block-builder.js' +import { defaultLogger, truncate } from '../logger.js' const logger = defaultLogger.child({ name: 'txpool' }) diff --git a/packages/core/src/chopsticks-provider.ts b/packages/core/src/chopsticks-provider.ts index f0baa589..4252cecf 100644 --- a/packages/core/src/chopsticks-provider.ts +++ b/packages/core/src/chopsticks-provider.ts @@ -1,4 +1,4 @@ -import { default as EventEmitter } from 'eventemitter3' +import { EventEmitter } from 'eventemitter3' import { ProviderInterface, ProviderInterfaceCallback, @@ -6,11 +6,11 @@ import { ProviderInterfaceEmitted, } from '@polkadot/rpc-provider/types' -import { Blockchain } from './blockchain' -import { Context, Handlers, allHandlers } from './rpc' -import { Database } from './database' -import { defaultLogger } from './logger' -import { setup } from './setup' +import { Blockchain } from './blockchain/index.js' +import { Context, Handlers, allHandlers } from './rpc/index.js' +import { Database } from './database.js' +import { defaultLogger } from './logger.js' +import { setup } from './setup.js' const providerHandlers: Handlers = { ...allHandlers, @@ -39,13 +39,11 @@ interface Subscription extends SubscriptionHandler { */ export class ChopsticksProvider implements ProviderInterface { #isConnected = false - #eventemitter: EventEmitter + #eventemitter = new EventEmitter() #isReadyPromise: Promise #subscriptions: Record = {} constructor(public readonly chain: Blockchain) { - this.#eventemitter = new EventEmitter() - this.#isReadyPromise = new Promise((resolve, reject): void => { this.#eventemitter.once('connected', resolve) this.#eventemitter.once('error', reject) diff --git a/packages/core/src/genesis-provider.ts b/packages/core/src/genesis-provider.ts index 0ad9b1b4..519a17a3 100644 --- a/packages/core/src/genesis-provider.ts +++ b/packages/core/src/genesis-provider.ts @@ -1,4 +1,3 @@ -import { default as EventEmitter } from 'eventemitter3' import { HexString } from '@polkadot/util/types' import { ProviderInterface, @@ -7,16 +6,16 @@ import { ProviderInterfaceEmitted, } from '@polkadot/rpc-provider/types' -import { Genesis, genesisSchema } from './schema' -import { JsCallback, calculateStateRoot, emptyTaskHandler } from './wasm-executor' - +import { EventEmitter } from 'eventemitter3' +import { Genesis, genesisSchema } from './schema/index.js' +import { JsCallback, calculateStateRoot, emptyTaskHandler } from './wasm-executor/index.js' /** * Provider to start a chain from genesis */ export class GenesisProvider implements ProviderInterface { #isConnected = false - #eventemitter: EventEmitter + #eventemitter = new EventEmitter() #isReadyPromise: Promise #genesis: Genesis @@ -42,8 +41,6 @@ export class GenesisProvider implements ProviderInterface { 1, ) - this.#eventemitter = new EventEmitter() - this.#isReadyPromise = new Promise((resolve, reject): void => { this.#eventemitter.once('connected', (): void => { resolve() diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 8240aef6..3966a325 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -7,22 +7,22 @@ * * @packageDocumentation */ -export * from './api' -export * from './blockchain' -export * from './blockchain/block' -export * from './blockchain/block-builder' -export * from './blockchain/txpool' -export * from './blockchain/storage-layer' -export * from './blockchain/head-state' -export * from './utils' -export * from './wasm-executor' -export * from './schema' -export * from './xcm' -export * from './setup' -export * from './database' -export * from './blockchain/inherent' -export * from './logger' -export * from './offchain' -export * from './chopsticks-provider' -export * from './genesis-provider' -export * from './rpc' +export * from './api.js' +export * from './blockchain/index.js' +export * from './blockchain/block.js' +export * from './blockchain/block-builder.js' +export * from './blockchain/txpool.js' +export * from './blockchain/storage-layer.js' +export * from './blockchain/head-state.js' +export * from './utils/index.js' +export * from './wasm-executor/index.js' +export * from './schema/index.js' +export * from './xcm/index.js' +export * from './setup.js' +export * from './database.js' +export * from './blockchain/inherent/index.js' +export * from './logger.js' +export * from './offchain.js' +export * from './chopsticks-provider.js' +export * from './genesis-provider.js' +export * from './rpc/index.js' diff --git a/packages/core/src/logger.ts b/packages/core/src/logger.ts index b531e4f6..b8a1f0c4 100644 --- a/packages/core/src/logger.ts +++ b/packages/core/src/logger.ts @@ -1,6 +1,6 @@ -import createLogger from 'pino' +import { pino } from 'pino' -export const defaultLogger = createLogger({ +export const defaultLogger = pino({ level: (typeof process === 'object' && process.env.LOG_LEVEL) || 'info', transport: { target: 'pino-pretty', diff --git a/packages/core/src/offchain.ts b/packages/core/src/offchain.ts index 65af3c2f..75a78f02 100644 --- a/packages/core/src/offchain.ts +++ b/packages/core/src/offchain.ts @@ -1,7 +1,7 @@ -import { Block } from './blockchain/block' +import { Block } from './blockchain/block.js' import { HexString } from '@polkadot/util/types' import { blake2AsHex } from '@polkadot/util-crypto' -import { defaultLogger } from './logger' +import { defaultLogger } from './logger.js' import { queueScheduler } from 'rxjs' const logger = defaultLogger.child({ name: 'offchain' }) diff --git a/packages/core/src/rpc/index.ts b/packages/core/src/rpc/index.ts index 6735914c..72c57008 100644 --- a/packages/core/src/rpc/index.ts +++ b/packages/core/src/rpc/index.ts @@ -1,5 +1,5 @@ -import { Handlers } from './shared' -import substrate from './substrate' +import { Handlers } from './shared.js' +import substrate from './substrate/index.js' export const allHandlers: Handlers = { ...substrate, @@ -10,6 +10,6 @@ export const allHandlers: Handlers = { }), } -export { default as substrate } from './substrate' -export { ResponseError } from './shared' -export type { Context, SubscriptionManager, Handler, Handlers } from './shared' +export { default as substrate } from './substrate/index.js' +export { ResponseError } from './shared.js' +export type { Context, SubscriptionManager, Handler, Handlers } from './shared.js' diff --git a/packages/core/src/rpc/shared.ts b/packages/core/src/rpc/shared.ts index fb037b6e..634e7a0e 100644 --- a/packages/core/src/rpc/shared.ts +++ b/packages/core/src/rpc/shared.ts @@ -1,5 +1,5 @@ -import { Blockchain } from '@acala-network/chopsticks-core' -import { defaultLogger } from '../logger' +import { Blockchain } from '../blockchain/index.js' +import { defaultLogger } from '../logger.js' export const logger = defaultLogger.child({ name: 'rpc' }) diff --git a/packages/core/src/rpc/substrate/author.ts b/packages/core/src/rpc/substrate/author.ts index 67ecfce2..a6242974 100644 --- a/packages/core/src/rpc/substrate/author.ts +++ b/packages/core/src/rpc/substrate/author.ts @@ -1,10 +1,10 @@ import { HexString } from '@polkadot/util/types' import { TransactionValidityError } from '@polkadot/types/interfaces' -import { APPLY_EXTRINSIC_ERROR } from '../../blockchain/txpool' -import { Block } from '../../blockchain/block' -import { Handler, ResponseError, SubscriptionManager } from '../shared' -import { defaultLogger } from '../../logger' +import { APPLY_EXTRINSIC_ERROR } from '../../blockchain/txpool.js' +import { Block } from '../../blockchain/block.js' +import { Handler, ResponseError, SubscriptionManager } from '../shared.js' +import { defaultLogger } from '../../logger.js' const logger = defaultLogger.child({ name: 'rpc-author' }) diff --git a/packages/core/src/rpc/substrate/chain.ts b/packages/core/src/rpc/substrate/chain.ts index 1aac14a6..4d418ac9 100644 --- a/packages/core/src/rpc/substrate/chain.ts +++ b/packages/core/src/rpc/substrate/chain.ts @@ -1,7 +1,7 @@ import { Header } from '@polkadot/types/interfaces' import { HexString } from '@polkadot/util/types' -import { Handler, ResponseError } from '../shared' +import { Handler, ResponseError } from '../shared.js' const processHeader = (header: Header) => { const res = header.toJSON() as any diff --git a/packages/core/src/rpc/substrate/index.ts b/packages/core/src/rpc/substrate/index.ts index 0a79de2d..4db882e6 100644 --- a/packages/core/src/rpc/substrate/index.ts +++ b/packages/core/src/rpc/substrate/index.ts @@ -1,8 +1,8 @@ -import * as AuthorRPC from './author' -import * as ChainRPC from './chain' -import * as PaymentRPC from './payment' -import * as StateRPC from './state' -import * as SystemRPC from './system' +import * as AuthorRPC from './author.js' +import * as ChainRPC from './chain.js' +import * as PaymentRPC from './payment.js' +import * as StateRPC from './state.js' +import * as SystemRPC from './system.js' export { AuthorRPC } export { ChainRPC } diff --git a/packages/core/src/rpc/substrate/payment.ts b/packages/core/src/rpc/substrate/payment.ts index 5d35ee29..780f6930 100644 --- a/packages/core/src/rpc/substrate/payment.ts +++ b/packages/core/src/rpc/substrate/payment.ts @@ -1,7 +1,7 @@ import { HexString } from '@polkadot/util/types' import { hexToU8a } from '@polkadot/util' -import { Handler, ResponseError } from '../shared' +import { Handler, ResponseError } from '../shared.js' /** * @param context diff --git a/packages/core/src/rpc/substrate/state.ts b/packages/core/src/rpc/substrate/state.ts index 3ff2a55f..2f1ce230 100644 --- a/packages/core/src/rpc/substrate/state.ts +++ b/packages/core/src/rpc/substrate/state.ts @@ -1,10 +1,10 @@ -import { Block } from '../../blockchain/block' +import { Block } from '../../blockchain/block.js' import { HexString } from '@polkadot/util/types' -import { Handler, ResponseError } from '../shared' -import { RuntimeVersion } from '../../wasm-executor' -import { defaultLogger } from '../../logger' -import { isPrefixedChildKey, prefixedChildKey, stripChildPrefix } from '../../utils' +import { Handler, ResponseError } from '../shared.js' +import { RuntimeVersion } from '../../wasm-executor/index.js' +import { defaultLogger } from '../../logger.js' +import { isPrefixedChildKey, prefixedChildKey, stripChildPrefix } from '../../utils/index.js' const logger = defaultLogger.child({ name: 'rpc-state' }) diff --git a/packages/core/src/rpc/substrate/system.ts b/packages/core/src/rpc/substrate/system.ts index 40dcc65a..e8875f76 100644 --- a/packages/core/src/rpc/substrate/system.ts +++ b/packages/core/src/rpc/substrate/system.ts @@ -2,8 +2,8 @@ import { HexString } from '@polkadot/util/types' import { Index } from '@polkadot/types/interfaces' import { hexToU8a } from '@polkadot/util' -import { ChainProperties } from '../../api' -import { Handler } from '../shared' +import { ChainProperties } from '../../api.js' +import { Handler } from '../shared.js' export const system_localPeerId = async () => '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY' export const system_nodeRoles = async () => ['Full'] diff --git a/packages/core/src/setup.test.ts b/packages/core/src/setup.test.ts index 42fd2cfc..d9c46a00 100644 --- a/packages/core/src/setup.test.ts +++ b/packages/core/src/setup.test.ts @@ -1,5 +1,5 @@ import { expect, test } from 'vitest' -import { setup } from './setup' +import { setup } from './setup.js' test('handle invalid block ', async () => { await expect(setup({ endpoint: 'wss://acala-rpc-0.aca-api.network', block: '0x' })).rejects.toThrow('invalid length') diff --git a/packages/core/src/setup.ts b/packages/core/src/setup.ts index dae2ed2d..c64a9206 100644 --- a/packages/core/src/setup.ts +++ b/packages/core/src/setup.ts @@ -4,11 +4,11 @@ import { HttpProvider, WsProvider } from '@polkadot/rpc-provider' import { ProviderInterface } from '@polkadot/rpc-provider/types' import { RegisteredTypes } from '@polkadot/types/types' -import { Api } from './api' -import { Blockchain } from './blockchain' -import { BuildBlockMode } from './blockchain/txpool' -import { Database } from './database' -import { GenesisProvider } from './genesis-provider' +import { Api } from './api.js' +import { Blockchain } from './blockchain/index.js' +import { BuildBlockMode } from './blockchain/txpool.js' +import { Database } from './database.js' +import { GenesisProvider } from './genesis-provider.js' import { InherentProviders, ParaInherentEnter, @@ -16,8 +16,8 @@ import { SetNimbusAuthorInherent, SetTimestamp, SetValidationData, -} from './blockchain/inherent' -import { defaultLogger } from './logger' +} from './blockchain/inherent/index.js' +import { defaultLogger } from './logger.js' export type SetupOptions = { endpoint?: string diff --git a/packages/core/src/utils/decoder.ts b/packages/core/src/utils/decoder.ts index f80bc2c7..c279f048 100644 --- a/packages/core/src/utils/decoder.ts +++ b/packages/core/src/utils/decoder.ts @@ -1,5 +1,5 @@ import '@polkadot/types-codec' -import { Block } from '../blockchain/block' +import { Block } from '../blockchain/block.js' import { DecoratedMeta } from '@polkadot/types/metadata/decorate/types' import { HexString } from '@polkadot/util/types' import { StorageEntry } from '@polkadot/types/primitive/types' @@ -7,7 +7,7 @@ import { StorageKey } from '@polkadot/types' import { hexToU8a, u8aToHex } from '@polkadot/util' import _ from 'lodash' -import { decodeWellKnownKey } from './well-known-keys' +import { decodeWellKnownKey } from './well-known-keys.js' const _CACHE: Record> = {} diff --git a/packages/core/src/utils/index.ts b/packages/core/src/utils/index.ts index 82e0888e..0c55b953 100644 --- a/packages/core/src/utils/index.ts +++ b/packages/core/src/utils/index.ts @@ -3,12 +3,12 @@ import { StorageKey } from '@polkadot/types' import { compactStripLength, u8aToHex } from '@polkadot/util' import { hexAddPrefix, hexStripPrefix } from '@polkadot/util/hex' -import { Blockchain } from '../blockchain' -import { RuntimeLog } from '../wasm-executor' +import { Blockchain } from '../blockchain/index.js' +import { RuntimeLog } from '../wasm-executor/index.js' -export * from './set-storage' -export * from './time-travel' -export * from './decoder' +export * from './set-storage.js' +export * from './time-travel.js' +export * from './decoder.js' export type GetKeys = (startKey?: string) => Promise[]> diff --git a/packages/core/src/utils/key-cache.test.ts b/packages/core/src/utils/key-cache.test.ts index 9b0bc953..8a9eff7d 100644 --- a/packages/core/src/utils/key-cache.test.ts +++ b/packages/core/src/utils/key-cache.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import KeyCache from './key-cache' +import KeyCache from './key-cache.js' const KEY_0 = '0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9_00' const KEY_1 = '0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9_01' diff --git a/packages/core/src/utils/set-storage.ts b/packages/core/src/utils/set-storage.ts index af3fbe15..2f1315d5 100644 --- a/packages/core/src/utils/set-storage.ts +++ b/packages/core/src/utils/set-storage.ts @@ -4,8 +4,8 @@ import { StorageKey } from '@polkadot/types' import { stringCamelCase } from '@polkadot/util/string' import { u8aToHex } from '@polkadot/util' -import { Blockchain } from '../blockchain' -import { StorageValueKind } from '../blockchain/storage-layer' +import { Blockchain } from '../blockchain/index.js' +import { StorageValueKind } from '../blockchain/storage-layer.js' type RawStorageValues = [string, string | null][] type StorageConfig = Record> diff --git a/packages/core/src/utils/time-travel.ts b/packages/core/src/utils/time-travel.ts index 91b3b0c9..178dcee8 100644 --- a/packages/core/src/utils/time-travel.ts +++ b/packages/core/src/utils/time-travel.ts @@ -2,10 +2,10 @@ import { BN, hexToU8a, u8aToHex } from '@polkadot/util' import { HexString } from '@polkadot/util/types' import { Slot } from '@polkadot/types/interfaces' -import { Blockchain } from '../blockchain' -import { compactHex } from '.' -import { getAuraSlotDuration } from '../wasm-executor' -import { setStorage } from './set-storage' +import { Blockchain } from '../blockchain/index.js' +import { compactHex } from './index.js' +import { getAuraSlotDuration } from '../wasm-executor/index.js' +import { setStorage } from './set-storage.js' export const getCurrentSlot = async (chain: Blockchain) => { const meta = await chain.head.meta diff --git a/packages/core/src/wasm-executor/executor.test.ts b/packages/core/src/wasm-executor/executor.test.ts index 34d27b39..ff14038b 100644 --- a/packages/core/src/wasm-executor/executor.test.ts +++ b/packages/core/src/wasm-executor/executor.test.ts @@ -10,8 +10,8 @@ import { hrmpEgressChannelIndex, hrmpIngressChannelIndex, upgradeGoAheadSignal, -} from '../utils/proof' -import { calculateStateRoot, createProof, decodeProof, getAuraSlotDuration, getRuntimeVersion } from '.' +} from '../utils/proof.js' +import { calculateStateRoot, createProof, decodeProof, getAuraSlotDuration, getRuntimeVersion } from './index.js' const getCode = () => { const code = String(readFileSync(path.join(__dirname, '../../../e2e/blobs/acala-runtime-2101.txt'))).trim() diff --git a/packages/core/src/wasm-executor/index.ts b/packages/core/src/wasm-executor/index.ts index 37c554d9..a52b68dd 100644 --- a/packages/core/src/wasm-executor/index.ts +++ b/packages/core/src/wasm-executor/index.ts @@ -5,10 +5,10 @@ import { hexToString, hexToU8a } from '@polkadot/util' import { randomAsHex } from '@polkadot/util-crypto' import _ from 'lodash' -import { Block } from '../blockchain/block' -import { PREFIX_LENGTH } from '../utils/key-cache' -import { defaultLogger, truncate } from '../logger' -import { stripChildPrefix } from '../utils' +import { Block } from '../blockchain/block.js' +import { PREFIX_LENGTH } from '../utils/key-cache.js' +import { defaultLogger, truncate } from '../logger.js' +import { stripChildPrefix } from '../utils/index.js' import type { JsCallback } from '@acala-network/chopsticks-executor' export { JsCallback } @@ -75,9 +75,9 @@ const getWorker = async () => { const isNode = typeof process !== 'undefined' && process?.versions?.node // true for node or bun if (isNode) { - __executor_worker = import('./node-worker').then(({ startWorker }) => startWorker()) + __executor_worker = import('./node-worker.js').then(({ startWorker }) => startWorker()) } else { - __executor_worker = import('./browser-worker').then(({ startWorker }) => startWorker()) + __executor_worker = import('./browser-worker.js').then(({ startWorker }) => startWorker()) } return __executor_worker } diff --git a/packages/core/src/wasm-executor/node-worker.ts b/packages/core/src/wasm-executor/node-worker.ts index ee8b0590..89dabc59 100644 --- a/packages/core/src/wasm-executor/node-worker.ts +++ b/packages/core/src/wasm-executor/node-worker.ts @@ -7,7 +7,7 @@ export const startWorker = async () => { name: 'chopsticks-wasm-executor', }) return { - remote: wrap(nodeEndpoint(worker)), + remote: wrap((nodeEndpoint as any)(worker)), terminate: async () => { await worker.terminate() }, diff --git a/packages/core/src/xcm/downward.ts b/packages/core/src/xcm/downward.ts index e5f3ab3d..772d6a72 100644 --- a/packages/core/src/xcm/downward.ts +++ b/packages/core/src/xcm/downward.ts @@ -1,10 +1,10 @@ import { hexToU8a } from '@polkadot/util' -import { Blockchain } from '../blockchain' -import { DownwardMessage } from '../blockchain/txpool' -import { compactHex, getParaId } from '../utils' -import { logger } from '.' -import { setStorage } from '../utils/set-storage' +import { Blockchain } from '../blockchain/index.js' +import { DownwardMessage } from '../blockchain/txpool.js' +import { compactHex, getParaId } from '../utils/index.js' +import { logger } from './index.js' +import { setStorage } from '../utils/set-storage.js' export const connectDownward = async (relaychain: Blockchain, parachain: Blockchain) => { const meta = await relaychain.head.meta diff --git a/packages/core/src/xcm/horizontal.ts b/packages/core/src/xcm/horizontal.ts index 89aff7d6..a5f35fa9 100644 --- a/packages/core/src/xcm/horizontal.ts +++ b/packages/core/src/xcm/horizontal.ts @@ -1,9 +1,9 @@ import { HexString } from '@polkadot/util/types' import { hexToU8a } from '@polkadot/util' -import { Blockchain } from '../blockchain' -import { compactHex } from '../utils' -import { logger } from '.' +import { Blockchain } from '../blockchain/index.js' +import { compactHex } from '../utils/index.js' +import { logger } from './index.js' export const connectHorizontal = async (parachains: Record) => { for (const [id, chain] of Object.entries(parachains)) { diff --git a/packages/core/src/xcm/index.ts b/packages/core/src/xcm/index.ts index 26302525..cfe2cb18 100644 --- a/packages/core/src/xcm/index.ts +++ b/packages/core/src/xcm/index.ts @@ -1,9 +1,9 @@ -import { Blockchain } from '../blockchain' -import { connectDownward } from './downward' -import { connectHorizontal } from './horizontal' -import { connectUpward } from './upward' -import { defaultLogger } from '../logger' -import { getParaId } from '../utils' +import { Blockchain } from '../blockchain/index.js' +import { connectDownward } from './downward.js' +import { connectHorizontal } from './horizontal.js' +import { connectUpward } from './upward.js' +import { defaultLogger } from '../logger.js' +import { getParaId } from '../utils/index.js' export const logger = defaultLogger.child({ name: 'xcm' }) diff --git a/packages/core/src/xcm/upward.ts b/packages/core/src/xcm/upward.ts index cb4a12fe..668496ac 100644 --- a/packages/core/src/xcm/upward.ts +++ b/packages/core/src/xcm/upward.ts @@ -1,7 +1,7 @@ import { hexToU8a } from '@polkadot/util' -import { Blockchain } from '../blockchain' -import { compactHex, getParaId } from '../utils' +import { Blockchain } from '../blockchain/index.js' +import { compactHex, getParaId } from '../utils/index.js' export const connectUpward = async (parachain: Blockchain, relaychain: Blockchain) => { const meta = await parachain.head.meta diff --git a/packages/db/package.json b/packages/db/package.json index d17f9f22..c36c4101 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks-db", - "version": "0.9.1-3", + "version": "0.9.1-4", "author": "Acala Developers ", "license": "Apache-2.0", "type": "module", @@ -38,10 +38,10 @@ "default": "./dist/esm/index.js" }, "./*": { - "types": "./dist/types/index.d.ts", - "require": "./dist/cjs/index.js", - "import": "./dist/esm/index.js", - "default": "./dist/esm/index.js" + "types": "./dist/types/*.d.ts", + "require": "./dist/cjs/*.js", + "import": "./dist/esm/*.js", + "default": "./dist/esm/*.js" }, "./package.json": "./package.json", "./package.cjs.json": "./dist/cjs/package.json" diff --git a/packages/db/src/base-sql.ts b/packages/db/src/base-sql.ts index cbfea5fb..3549852b 100644 --- a/packages/db/src/base-sql.ts +++ b/packages/db/src/base-sql.ts @@ -2,7 +2,7 @@ import { BlockEntry, Database, KeyValueEntry } from '@acala-network/chopsticks-c import { DataSource } from 'typeorm' import { HexString } from '@polkadot/util/types' -import { BlockEntity, KeyValuePair } from './db/entities' +import { BlockEntity, KeyValuePair } from './db/entities.js' export abstract class BaseSqlDatabase implements Database { abstract datasource: Promise diff --git a/packages/db/src/db/index.ts b/packages/db/src/db/index.ts index 0bc8f4c2..3d3f0ab2 100644 --- a/packages/db/src/db/index.ts +++ b/packages/db/src/db/index.ts @@ -1,6 +1,6 @@ import { DataSource } from 'typeorm' -import * as entities from './entities' +import * as entities from './entities.js' export const openDb = async (dbPath: string): Promise => { const source = new DataSource({ diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index 56b24e1f..6714c622 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -1,7 +1,7 @@ import { DataSource } from 'typeorm' -import { BaseSqlDatabase } from './base-sql' -import { openDb } from './db' +import { BaseSqlDatabase } from './base-sql.js' +import { openDb } from './db/index.js' export class SqliteDatabase extends BaseSqlDatabase { datasource: Promise diff --git a/packages/e2e/src/author.test.ts b/packages/e2e/src/author.test.ts index fe44764c..69e92816 100644 --- a/packages/e2e/src/author.test.ts +++ b/packages/e2e/src/author.test.ts @@ -1,8 +1,8 @@ import { SubmittableResult } from '@polkadot/api' import { afterAll, describe, expect, it } from 'vitest' -import { defer, expectJson, mockCallback, testingPairs } from './helper' -import networks from './networks' +import { defer, expectJson, mockCallback, testingPairs } from './helper.js' +import networks from './networks.js' describe('author rpc', async () => { const { alice, bob } = testingPairs() diff --git a/packages/e2e/src/batch-request.test.ts b/packages/e2e/src/batch-request.test.ts index b499fd80..9dc35d44 100644 --- a/packages/e2e/src/batch-request.test.ts +++ b/packages/e2e/src/batch-request.test.ts @@ -1,7 +1,7 @@ import { WebSocket } from 'ws' import { afterAll, beforeAll, describe, expect, it } from 'vitest' -import networks from './networks' +import networks from './networks.js' describe('Batch request', async () => { const { chain, url, teardown } = await networks.acala() diff --git a/packages/e2e/src/block.test.ts b/packages/e2e/src/block.test.ts index e0c893e8..5e0372f5 100644 --- a/packages/e2e/src/block.test.ts +++ b/packages/e2e/src/block.test.ts @@ -1,7 +1,7 @@ import { afterAll, describe, expect, it } from 'vitest' -import { delay } from './helper' -import networks from './networks' +import { delay } from './helper.js' +import networks from './networks.js' describe('block', async () => { const { chain, dev, teardown } = await networks.acala() diff --git a/packages/e2e/src/build-block.test.ts b/packages/e2e/src/build-block.test.ts index c6bc5175..99565d75 100644 --- a/packages/e2e/src/build-block.test.ts +++ b/packages/e2e/src/build-block.test.ts @@ -1,6 +1,6 @@ import { afterAll, describe, expect, it } from 'vitest' -import { setupAll } from './helper' +import { setupAll } from './helper.js' const KUSAMA_STORAGE = { FellowshipCollective: { diff --git a/packages/e2e/src/chain.test.ts b/packages/e2e/src/chain.test.ts index 62c9e703..a0c8a138 100644 --- a/packages/e2e/src/chain.test.ts +++ b/packages/e2e/src/chain.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { api, delay, dev, env, expectHex, expectJson, mockCallback, setupApi } from './helper' +import { api, delay, dev, env, expectHex, expectJson, mockCallback, setupApi } from './helper.js' setupApi(env.acala) diff --git a/packages/e2e/src/chopsticks-provider.test.ts b/packages/e2e/src/chopsticks-provider.test.ts index 6cbc4dda..49fb938e 100644 --- a/packages/e2e/src/chopsticks-provider.test.ts +++ b/packages/e2e/src/chopsticks-provider.test.ts @@ -2,8 +2,8 @@ import { ApiPromise } from '@polkadot/api' import { BuildBlockMode, ChopsticksProvider, setStorage } from '@acala-network/chopsticks-core' import { afterAll, beforeAll, describe, expect, it } from 'vitest' -import { env, expectHex, expectJson, testingPairs } from './helper' -import networks from './networks' +import { env, expectHex, expectJson, testingPairs } from './helper.js' +import networks from './networks.js' const { alice, bob } = testingPairs() diff --git a/packages/e2e/src/crowdloan.redeem.test.ts b/packages/e2e/src/crowdloan.redeem.test.ts index b059f9a5..e3aa951c 100644 --- a/packages/e2e/src/crowdloan.redeem.test.ts +++ b/packages/e2e/src/crowdloan.redeem.test.ts @@ -1,7 +1,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest' import { testingPairs } from '@acala-network/chopsticks-testing' -import networks from './networks' +import networks from './networks.js' describe('Polkadot Crowdloan Refund', async () => { const { alice } = testingPairs() diff --git a/packages/e2e/src/decoder.test.ts b/packages/e2e/src/decoder.test.ts index 26a2780b..e7e77140 100644 --- a/packages/e2e/src/decoder.test.ts +++ b/packages/e2e/src/decoder.test.ts @@ -1,7 +1,7 @@ import { afterAll, describe, expect, it } from 'vitest' -import { decodeKey, decodeKeyValue, toStorageObject } from '@acala-network/chopsticks-core/utils/decoder' +import { decodeKey, decodeKeyValue, toStorageObject } from '@acala-network/chopsticks-core/utils/decoder.js' -import networks from './networks' +import networks from './networks.js' const SYSTEM_ACCOUNT = '0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9de1e86a9a8c739864cf3cc5ec2bea59fd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' diff --git a/packages/e2e/src/dev-dry-run-dmp.test.ts b/packages/e2e/src/dev-dry-run-dmp.test.ts index 929faa05..7fba923b 100644 --- a/packages/e2e/src/dev-dry-run-dmp.test.ts +++ b/packages/e2e/src/dev-dry-run-dmp.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import networks from './networks' +import networks from './networks.js' describe('dev_dryRun dmp', () => { it('works', async () => { diff --git a/packages/e2e/src/dev-dry-run-ump.test.ts b/packages/e2e/src/dev-dry-run-ump.test.ts index 81c318af..f5c52aa0 100644 --- a/packages/e2e/src/dev-dry-run-ump.test.ts +++ b/packages/e2e/src/dev-dry-run-ump.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { setupApi, ws } from './helper' +import { setupApi, ws } from './helper.js' setupApi({ endpoint: 'wss://rpc.polkadot.io', diff --git a/packages/e2e/src/dev.test.ts b/packages/e2e/src/dev.test.ts index d4ddc86e..4ec17c9f 100644 --- a/packages/e2e/src/dev.test.ts +++ b/packages/e2e/src/dev.test.ts @@ -1,8 +1,8 @@ import { afterAll, describe, expect, it } from 'vitest' import { u8aToHex } from '@polkadot/util' -import { expectJson, testingPairs } from './helper' -import networks from './networks' +import { expectJson, testingPairs } from './helper.js' +import networks from './networks.js' describe('dev rpc', async () => { const { alice, bob } = testingPairs() diff --git a/packages/e2e/src/dry-run-extrinsic.test.ts b/packages/e2e/src/dry-run-extrinsic.test.ts index 944412cc..dab278ef 100644 --- a/packages/e2e/src/dry-run-extrinsic.test.ts +++ b/packages/e2e/src/dry-run-extrinsic.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { api, chain, dev, env, setupApi, testingPairs } from './helper' +import { api, chain, dev, env, setupApi, testingPairs } from './helper.js' setupApi({ ...env.acala, diff --git a/packages/e2e/src/failed-tx-reverts.test.ts b/packages/e2e/src/failed-tx-reverts.test.ts index 63353800..8532a90e 100644 --- a/packages/e2e/src/failed-tx-reverts.test.ts +++ b/packages/e2e/src/failed-tx-reverts.test.ts @@ -1,6 +1,6 @@ import { afterAll, describe, expect, it } from 'vitest' -import { testingPairs } from './helper' -import networks from './networks' +import { testingPairs } from './helper.js' +import networks from './networks.js' // SPECIAL TEST CASE. DO NOT CHANGE describe('failed tx should revert storage changes', async () => { diff --git a/packages/e2e/src/genesis-provider.test.ts b/packages/e2e/src/genesis-provider.test.ts index fc3b5021..49df4543 100644 --- a/packages/e2e/src/genesis-provider.test.ts +++ b/packages/e2e/src/genesis-provider.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { api, chain, dev, env, expectJson, setupApi, testingPairs } from './helper' +import { api, chain, dev, env, expectJson, setupApi, testingPairs } from './helper.js' setupApi(env.mandalaGenesis) diff --git a/packages/e2e/src/helper.ts b/packages/e2e/src/helper.ts index 2f9cc645..235ace83 100644 --- a/packages/e2e/src/helper.ts +++ b/packages/e2e/src/helper.ts @@ -5,8 +5,7 @@ import { ProviderInterface } from '@polkadot/rpc-provider/types' import { beforeAll, beforeEach, expect, vi } from 'vitest' import { Api } from '@acala-network/chopsticks' -import { Blockchain } from '@acala-network/chopsticks-core/blockchain' -import { BuildBlockMode } from '@acala-network/chopsticks-core/blockchain/txpool' +import { Blockchain, BuildBlockMode, StorageValues } from '@acala-network/chopsticks-core' import { InherentProviders, ParaInherentEnter, @@ -14,13 +13,12 @@ import { SetNimbusAuthorInherent, SetTimestamp, SetValidationData, -} from '@acala-network/chopsticks-core/blockchain/inherent' +} from '@acala-network/chopsticks-core/blockchain/inherent/index.js' import { SqliteDatabase } from '@acala-network/chopsticks-db' -import { StorageValues } from '@acala-network/chopsticks-core/utils/set-storage' -import { createServer } from '@acala-network/chopsticks/server' -import { defer } from '@acala-network/chopsticks-core/utils' -import { genesisFromUrl } from '@acala-network/chopsticks/context' -import { handler } from '@acala-network/chopsticks/rpc' +import { createServer } from '@acala-network/chopsticks/server.js' +import { defer } from '@acala-network/chopsticks-core/utils/index.js' +import { genesisFromUrl } from '@acala-network/chopsticks/context.js' +import { handler } from '@acala-network/chopsticks/rpc/index.js' export { expectJson, expectHex, testingPairs } from '@acala-network/chopsticks-testing' diff --git a/packages/e2e/src/import-storage/index.test.ts b/packages/e2e/src/import-storage/index.test.ts index a4b414d0..94765467 100644 --- a/packages/e2e/src/import-storage/index.test.ts +++ b/packages/e2e/src/import-storage/index.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from 'vitest' import path from 'path' -import { api, chain, setupApi } from '../helper' -import { overrideStorage, overrideWasm } from '@acala-network/chopsticks/utils/override' +import { api, chain, setupApi } from '../helper.js' +import { overrideStorage, overrideWasm } from '@acala-network/chopsticks/utils/override.js' setupApi({ endpoint: 'wss://acala-rpc-1.aca-api.network', diff --git a/packages/e2e/src/max-memory-block-count.test.ts b/packages/e2e/src/max-memory-block-count.test.ts index ea54261f..7b5b6e2c 100644 --- a/packages/e2e/src/max-memory-block-count.test.ts +++ b/packages/e2e/src/max-memory-block-count.test.ts @@ -1,5 +1,5 @@ import { afterAll, describe, expect, it } from 'vitest' -import networks from './networks' +import networks from './networks.js' describe('max-memory-block-count', async () => { const acala = await networks.acala({ maxMemoryBlockCount: 2 }) diff --git a/packages/e2e/src/metadata.test.ts b/packages/e2e/src/metadata.test.ts index a44d2d4a..db576b49 100644 --- a/packages/e2e/src/metadata.test.ts +++ b/packages/e2e/src/metadata.test.ts @@ -1,4 +1,4 @@ -import { chain, setupApi } from './helper' +import { chain, setupApi } from './helper.js' import { describe, expect, it } from 'vitest' setupApi({ diff --git a/packages/e2e/src/mock-signature.test.ts b/packages/e2e/src/mock-signature.test.ts index dcf72c6b..23a5f29a 100644 --- a/packages/e2e/src/mock-signature.test.ts +++ b/packages/e2e/src/mock-signature.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' import { signFake, signFakeWithApi } from '@acala-network/chopsticks-testing' -import { api, dev, env, setupApi, testingPairs } from './helper' +import { api, dev, env, setupApi, testingPairs } from './helper.js' setupApi({ ...env.acala, diff --git a/packages/e2e/src/relaychain.test.ts b/packages/e2e/src/relaychain.test.ts index 6f4b13cc..eef8968d 100644 --- a/packages/e2e/src/relaychain.test.ts +++ b/packages/e2e/src/relaychain.test.ts @@ -1,6 +1,6 @@ import { afterAll, describe, expect, it } from 'vitest' -import networks from './networks' +import networks from './networks.js' describe('relaychain dev rpc', async () => { const { dev, teardown } = await networks.polkadot() diff --git a/packages/e2e/src/resume.test.ts b/packages/e2e/src/resume.test.ts index 30e311f2..ca094195 100644 --- a/packages/e2e/src/resume.test.ts +++ b/packages/e2e/src/resume.test.ts @@ -1,11 +1,11 @@ import { assert, describe, expect, it } from 'vitest' -import { connectUpward } from '@acala-network/chopsticks-core/xcm/upward' -import { matchSnapshot } from './helper' +import { connectUpward } from '@acala-network/chopsticks-core/xcm/upward.js' +import { matchSnapshot } from './helper.js' import { matchSystemEvents, testingPairs } from '@acala-network/chopsticks-testing' import { resolve } from 'node:path' import { setStorage } from '@acala-network/chopsticks' import { tmpdir } from 'node:os' -import networks from './networks' +import networks from './networks.js' describe('resume', async () => { const buildBlocksAndTeardown = async (network = 'acala', dbName = 'db.sqlite') => { diff --git a/packages/e2e/src/state.test.ts b/packages/e2e/src/state.test.ts index 117bdf80..799531e0 100644 --- a/packages/e2e/src/state.test.ts +++ b/packages/e2e/src/state.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { api, env, expectHex, expectJson, setupApi } from './helper' +import { api, env, expectHex, expectJson, setupApi } from './helper.js' setupApi(env.acala) diff --git a/packages/e2e/src/storage-migrate.test.ts b/packages/e2e/src/storage-migrate.test.ts index 111833a6..52785047 100644 --- a/packages/e2e/src/storage-migrate.test.ts +++ b/packages/e2e/src/storage-migrate.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { api, dev, setupApi } from './helper' +import { api, dev, setupApi } from './helper.js' setupApi({ endpoint: 'wss://kusama-archive.mangata.online', diff --git a/packages/e2e/src/storage.test.ts b/packages/e2e/src/storage.test.ts index 018018dc..c14f8127 100644 --- a/packages/e2e/src/storage.test.ts +++ b/packages/e2e/src/storage.test.ts @@ -1,7 +1,7 @@ import '@polkadot/api-augment' import { describe, expect, it } from 'vitest' -import { api, delay, dev, env, expectJson, mockCallback, setupApi } from './helper' +import { api, delay, dev, env, expectJson, mockCallback, setupApi } from './helper.js' setupApi(env.acala) diff --git a/packages/e2e/src/system.test.ts b/packages/e2e/src/system.test.ts index 4a125160..ba47dc0e 100644 --- a/packages/e2e/src/system.test.ts +++ b/packages/e2e/src/system.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { api, dev, env, expectJson, setupApi, testingPairs } from './helper' +import { api, dev, env, expectJson, setupApi, testingPairs } from './helper.js' setupApi(env.acala) diff --git a/packages/e2e/src/time-travel.test.ts b/packages/e2e/src/time-travel.test.ts index 032acb79..1857215b 100644 --- a/packages/e2e/src/time-travel.test.ts +++ b/packages/e2e/src/time-travel.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' -import { getCurrentTimestamp, getSlotDuration, timeTravel } from '@acala-network/chopsticks-core/utils/time-travel' +import { getCurrentTimestamp, getSlotDuration, timeTravel } from '@acala-network/chopsticks-core/utils/time-travel.js' -import networks from './networks' +import networks from './networks.js' describe.each(['polkadot', 'acala'])('Can time-travel on %s', async (name) => { const { chain, ws } = await networks[name as keyof typeof networks]() diff --git a/packages/e2e/src/upgrade.test.ts b/packages/e2e/src/upgrade.test.ts index dbc39700..4d8c84ba 100644 --- a/packages/e2e/src/upgrade.test.ts +++ b/packages/e2e/src/upgrade.test.ts @@ -2,9 +2,9 @@ import { afterAll, describe, expect, it } from 'vitest' import { readFileSync } from 'node:fs' import path from 'node:path' -import { expectJson, testingPairs } from './helper' +import { expectJson, testingPairs } from './helper.js' -import networks from './networks' +import networks from './networks.js' describe('upgrade', async () => { const { alice, bob } = testingPairs() diff --git a/packages/e2e/src/xcm.test.ts b/packages/e2e/src/xcm.test.ts index b3844651..36618ca2 100644 --- a/packages/e2e/src/xcm.test.ts +++ b/packages/e2e/src/xcm.test.ts @@ -1,13 +1,13 @@ import { beforeEach, describe, it } from 'vitest' -import { DownwardMessage, HorizontalMessage } from '@acala-network/chopsticks-core/blockchain/txpool' -import { connectDownward } from '@acala-network/chopsticks-core/xcm/downward' -import { connectUpward } from '@acala-network/chopsticks-core/xcm/upward' +import { DownwardMessage, HorizontalMessage } from '@acala-network/chopsticks-core/blockchain/txpool.js' +import { connectDownward } from '@acala-network/chopsticks-core/xcm/downward.js' +import { connectUpward } from '@acala-network/chopsticks-core/xcm/upward.js' import { matchSystemEvents, testingPairs } from '@acala-network/chopsticks-testing' -import { setStorage } from '@acala-network/chopsticks-core/utils/set-storage' +import { setStorage } from '@acala-network/chopsticks-core' -import { matchSnapshot } from './helper' -import networks, { Network } from './networks' +import { matchSnapshot } from './helper.js' +import networks, { Network } from './networks.js' const downwardMessages: DownwardMessage[] = [ { diff --git a/packages/testing/package.json b/packages/testing/package.json index 74c7b9a3..6a746115 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks-testing", - "version": "0.9.1-3", + "version": "0.9.1-4", "author": "Acala Developers ", "license": "Apache-2.0", "type": "module", @@ -39,10 +39,10 @@ "default": "./dist/esm/index.js" }, "./*": { - "types": "./dist/types/index.d.ts", - "require": "./dist/cjs/index.js", - "import": "./dist/esm/index.js", - "default": "./dist/esm/index.js" + "types": "./dist/types/*.d.ts", + "require": "./dist/cjs/*.js", + "import": "./dist/esm/*.js", + "default": "./dist/esm/*.js" }, "./package.json": "./package.json", "./package.cjs.json": "./dist/cjs/package.json" diff --git a/packages/testing/src/index.ts b/packages/testing/src/index.ts index 2786dde5..eadfa833 100644 --- a/packages/testing/src/index.ts +++ b/packages/testing/src/index.ts @@ -8,14 +8,14 @@ import { setupWithServer, } from '@acala-network/chopsticks' import { Codec } from '@polkadot/types/types' -import { Config } from '@acala-network/chopsticks/schema' +import { Config } from '@acala-network/chopsticks/schema/index.js' import { HexString } from '@polkadot/util/types' import { Keyring, createTestKeyring } from '@polkadot/keyring' import { SubmittableExtrinsic } from '@polkadot/api-base/types' import { expect } from 'vitest' -export * from './check' -export * from './signFake' +export * from './check.js' +export * from './signFake.js' export type SetupOption = { endpoint: string diff --git a/packages/web-test/src/App.tsx b/packages/web-test/src/App.tsx index 4c026b15..deefab26 100644 --- a/packages/web-test/src/App.tsx +++ b/packages/web-test/src/App.tsx @@ -15,7 +15,7 @@ import { ApiPromise } from '@polkadot/api' import { Buffer } from 'buffer' import { ChopsticksProvider, setStorage, setup } from '@acala-network/chopsticks-core' import { HexString } from '@polkadot/util/types' -import { IdbDatabase } from '@acala-network/chopsticks-db/browser' +import { IdbDatabase } from '@acala-network/chopsticks-db/browser.js' import { createTestPairs } from '@polkadot/keyring' import { styled } from '@mui/system' import { useEffect, useState } from 'react' diff --git a/packages/web-test/src/index.tsx b/packages/web-test/src/index.tsx index 96e30d0e..b1d8078c 100644 --- a/packages/web-test/src/index.tsx +++ b/packages/web-test/src/index.tsx @@ -2,7 +2,7 @@ import { createRoot } from 'react-dom/client' import React from 'react' import './index.css' -import App from './App' +import App from './App.js' createRoot(document.getElementById('root')!).render( diff --git a/tsconfig.base.json b/tsconfig.base.json index 78bfdb31..3b66eea8 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -5,28 +5,27 @@ "lib": ["esnext", "dom", "dom.iterable"], "isolatedModules": true, "module": "esnext", - "moduleResolution": "node", + "moduleResolution": "nodenext", "noUnusedLocals": true, "noUnusedParameters": true, "noImplicitAny": false, "target": "esnext", - "skipLibCheck": true, + "skipLibCheck": false, "strict": true, "declaration": true, "resolveJsonModule": true, + "forceConsistentCasingInFileNames": true, "baseUrl": ".", "composite": true, "paths": { - "@acala-network/chopsticks": ["packages/chopsticks/src"], + "@acala-network/chopsticks": ["packages/chopsticks/src/index.ts"], "@acala-network/chopsticks/*": ["packages/chopsticks/src/*"], - "@acala-network/chopsticks-core": ["packages/core/src"], + "@acala-network/chopsticks-core": ["packages/core/src/index.ts"], "@acala-network/chopsticks-core/*": ["packages/core/src/*"], - "@acala-network/chopsticks-db": ["packages/db/src"], + "@acala-network/chopsticks-db": ["packages/db/src/index.ts"], "@acala-network/chopsticks-db/*": ["packages/db/src/*"], - "@acala-network/chopsticks-testing": ["packages/testing/src"], - "@acala-network/chopsticks-testing/*": ["packages/testing/src/*"], - "@acala-network/web-test": ["packages/web/src"], - "@acala-network/web-test/*": ["packages/web/src/*"] + "@acala-network/chopsticks-testing": ["packages/testing/src/index.ts"], + "@acala-network/chopsticks-testing/*": ["packages/testing/src/*"] } } } diff --git a/tsconfig.lint.json b/tsconfig.lint.json index 5c90ad30..0d8e189d 100644 --- a/tsconfig.lint.json +++ b/tsconfig.lint.json @@ -1,7 +1,6 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "jsx": "react-jsx", - "lib": ["es2021", "dom", "dom.iterable"] + "jsx": "react-jsx" } }