diff --git a/biome.jsonc b/biome.jsonc index fbd293d..7523de7 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/2.3.9/schema.json", + "$schema": "https://biomejs.dev/schemas/2.3.11/schema.json", "files": { "includes": ["**", "!**/dist", "!**/graypaper-archive", "!**/public", "!**/tools/matrix-bot/messages.json"] }, diff --git a/package-lock.json b/package-lock.json index 0058d15..61732ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "@biomejs/biome": "^2.3.11", "@fluffylabs/shared-ui": "^0.4.5", "@tailwindcss/vite": "^4.1.17", - "@typeberry/lib": "^0.5.1-1dda9d6", + "@typeberry/lib": "^0.5.1-1534485f", "lucide-react": "^0.562.0", "react": "^19.0.0", "react-dom": "^19.2.3", @@ -1117,6 +1117,12 @@ "integrity": "sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==", "license": "MIT" }, + "node_modules/@fluffylabs/anan-as": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@fluffylabs/anan-as/-/anan-as-1.1.4.tgz", + "integrity": "sha512-cy23of0kdfcQ5c7VOi9qCBdn38WZagKMtApfvp/aaptDuKxvqrkoD3RXmj5kZJbiRi9iF/nfPMoY1dCWlPXOlg==", + "license": "MPL-2.0" + }, "node_modules/@fluffylabs/shared-ui": { "version": "0.4.5", "resolved": "https://registry.npmjs.org/@fluffylabs/shared-ui/-/shared-ui-0.4.5.tgz", @@ -1197,6 +1203,15 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@noble/ed25519": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/@noble/ed25519/-/ed25519-2.2.3.tgz", + "integrity": "sha512-iHV8eI2mRcUmOx159QNrU8vTpQ/Xm70yJ2cTk3Trc86++02usfqFoNl6x0p3JN81ZDS/1gx6xiK0OwrgqCT43g==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@radix-ui/number": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.1.1.tgz", @@ -3237,9 +3252,21 @@ } }, "node_modules/@typeberry/lib": { - "version": "0.5.1-1dda9d6", - "resolved": "https://registry.npmjs.org/@typeberry/lib/-/lib-0.5.1-1dda9d6.tgz", - "integrity": "sha512-/Wow+uEMaMpTD9cBZuJUVuZ7+kaaGmLxmiCF4LwP8y+pnUACSd/4aWI78I+kMasbChWL/wBrjZ3QzBXnRmO9Ug==", + "version": "0.5.1-1534485f", + "resolved": "https://registry.npmjs.org/@typeberry/lib/-/lib-0.5.1-1534485f.tgz", + "integrity": "sha512-QzL5plQvCxzogw034znhCIa0JrBuC4eHPwhLAeYP9GdSsaF3EiBujwDJIvfLvH3v6nwmmyOloVxqwPsDUZ3mYw==", + "license": "MPL-2.0", + "dependencies": { + "@fluffylabs/anan-as": "^1.1.3", + "@noble/ed25519": "2.2.3", + "@typeberry/native": "0.0.4-4c0cd28", + "hash-wasm": "4.12.0" + } + }, + "node_modules/@typeberry/native": { + "version": "0.0.4-4c0cd28", + "resolved": "https://registry.npmjs.org/@typeberry/native/-/native-0.0.4-4c0cd28.tgz", + "integrity": "sha512-VhZiiSYex3/jDk1I8PlcwPxiM9GslryGxdG+4sbbjNvpr1JxRkH0fAdUnKzxAxGYPNz2MOfwHTmTdVcrk1a5rA==", "license": "MPL-2.0" }, "node_modules/@types/aria-query": { @@ -4134,6 +4161,12 @@ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "license": "ISC" }, + "node_modules/hash-wasm": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/hash-wasm/-/hash-wasm-4.12.0.tgz", + "integrity": "sha512-+/2B2rYLb48I/evdOIhP+K/DD2ca2fgBjp6O+GBEnCDk2e4rpeXIK8GvIyRPjTezgmWn9gmKwkQjjx6BtqDHVQ==", + "license": "MIT" + }, "node_modules/html-encoding-sniffer": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-6.0.0.tgz", diff --git a/package.json b/package.json index 584f694..333ffb9 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@biomejs/biome": "^2.3.11", "@fluffylabs/shared-ui": "^0.4.5", "@tailwindcss/vite": "^4.1.17", - "@typeberry/lib": "^0.5.1-1dda9d6", + "@typeberry/lib": "^0.5.1-1534485f", "lucide-react": "^0.562.0", "react": "^19.0.0", "react-dom": "^19.2.3", diff --git a/src/App.tsx b/src/App.tsx index 754ec80..ea0bb9d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ import { AppsSidebar, Button, Header } from "@fluffylabs/shared-ui"; -import { utils } from "@typeberry/lib"; +import * as utils from "@typeberry/lib/utils"; import { Settings } from "lucide-react"; import { useState } from "react"; import logo from "./assets/logo.svg"; diff --git a/src/components/CodecInput.test.tsx b/src/components/CodecInput.test.tsx index 4c6c511..88ff099 100644 --- a/src/components/CodecInput.test.tsx +++ b/src/components/CodecInput.test.tsx @@ -34,11 +34,6 @@ vi.mock("@fluffylabs/shared-ui", () => ({ cn: (...classes: unknown[]) => classes.filter(Boolean).join(" "), })); -vi.mock("@typeberry/lib", async () => { - const actual = await vi.importActual("@typeberry/lib"); - return actual; -}); - // Mock child components vi.mock("./ChainSpecSelect", () => ({ ChainSpecSelect: ({ chainSpec }: { setChainSpec: (spec: string) => void; chainSpec: string }) => ( diff --git a/src/components/Controls.tsx b/src/components/Controls.tsx index d50c4a6..69d081c 100644 --- a/src/components/Controls.tsx +++ b/src/components/Controls.tsx @@ -1,5 +1,5 @@ import { Button } from "@fluffylabs/shared-ui"; -import { bytes } from "@typeberry/lib"; +import * as bytes from "@typeberry/lib/bytes"; import { UploadIcon } from "lucide-react"; import { useCallback } from "react"; import { ChainSpecSelect } from "./ChainSpecSelect"; diff --git a/src/components/KindFinder.test.tsx b/src/components/KindFinder.test.tsx index deb01a4..3fb7c2e 100644 --- a/src/components/KindFinder.test.tsx +++ b/src/components/KindFinder.test.tsx @@ -21,11 +21,6 @@ vi.mock("@fluffylabs/shared-ui", () => ({ ), })); -vi.mock("@typeberry/lib", async () => { - const actual = await vi.importActual("@typeberry/lib"); - return actual; -}); - describe("KindFinder", () => { const mockSetKind = vi.fn(); diff --git a/src/components/KindFinder.tsx b/src/components/KindFinder.tsx index 474a8c3..3088711 100644 --- a/src/components/KindFinder.tsx +++ b/src/components/KindFinder.tsx @@ -1,5 +1,5 @@ import { Button } from "@fluffylabs/shared-ui"; -import { bytes } from "@typeberry/lib"; +import * as bytes from "@typeberry/lib/bytes"; import { InfoIcon } from "lucide-react"; import { useMemo } from "react"; import { ALL_CHAIN_SPECS, kinds, tinyChainSpec } from "./constants"; diff --git a/src/components/SettingsDialog.test.tsx b/src/components/SettingsDialog.test.tsx index f9ada4d..0be44cd 100644 --- a/src/components/SettingsDialog.test.tsx +++ b/src/components/SettingsDialog.test.tsx @@ -19,25 +19,22 @@ vi.mock("@fluffylabs/shared-ui", () => ({ ), })); -vi.mock("@typeberry/lib", async () => { - const actual = await vi.importActual("@typeberry/lib"); +vi.mock("@typeberry/lib/utils", async () => { + const actual = await vi.importActual("@typeberry/lib/utils"); return { ...actual, - utils: { - ...actual.utils, - GpVersion: { - ...actual.utils.GpVersion, - V1: "V1", - V2: "V2", - }, - TestSuite: { - ...actual.utils.TestSuite, - Suite1: "Suite1", - Suite2: "Suite2", - }, - CURRENT_VERSION: "V1", - CURRENT_SUITE: "Suite1", + GpVersion: { + ...actual.GpVersion, + V1: "V1", + V2: "V2", }, + TestSuite: { + ...actual.TestSuite, + Suite1: "Suite1", + Suite2: "Suite2", + }, + CURRENT_VERSION: "V1", + CURRENT_SUITE: "Suite1", }; }); diff --git a/src/components/SettingsDialog.tsx b/src/components/SettingsDialog.tsx index e22548e..77bf61e 100644 --- a/src/components/SettingsDialog.tsx +++ b/src/components/SettingsDialog.tsx @@ -1,5 +1,5 @@ import { Button } from "@fluffylabs/shared-ui"; -import { utils } from "@typeberry/lib"; +import * as utils from "@typeberry/lib/utils"; import { X } from "lucide-react"; import { useEffect, useMemo, useState } from "react"; diff --git a/src/components/constants.ts b/src/components/constants.ts index 524a6fe..b4002da 100644 --- a/src/components/constants.ts +++ b/src/components/constants.ts @@ -1,13 +1,11 @@ -import { - block, - type bytes, - codec, - config, - jam_host_calls as jam, - state, - state_vectors, - state_merkleization as stateSer, -} from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import type * as bytes from "@typeberry/lib/bytes"; +import * as codec from "@typeberry/lib/codec"; +import * as config from "@typeberry/lib/config"; +import * as jam from "@typeberry/lib/jam-host-calls"; +import * as state from "@typeberry/lib/state"; +import * as stateSer from "@typeberry/lib/state-merkleization"; +import * as stateVectors from "@typeberry/lib/state-vectors"; import { hostCallInfoAccountExample } from "./examples/host/infoAccount"; import { assurancesExtrinsicExample } from "./examples/objects/assurancesExtrinsic"; import { availabilityAssuranceExample } from "./examples/objects/availabilityAssurance"; @@ -214,8 +212,8 @@ const clKind = newKind( "Lookup History Item", ); const hostInfoAccountKind = newKind("Host Call - Info: Account", jam.hostCallInfoAccount, hostCallInfoAccountExample); -const stfGenesisKind = newKind("STF Genesis", state_vectors.StateTransitionGenesis.Codec, stfGenesisExample); -const stfVectorKind = newKind("STF Vector", state_vectors.StateTransition.Codec, stfVectorExample); +const stfGenesisKind = newKind("STF Genesis", stateVectors.StateTransitionGenesis.Codec, stfGenesisExample); +const stfVectorKind = newKind("STF Vector", stateVectors.StateTransition.Codec, stfVectorExample); export const kinds = [ headerKind, diff --git a/src/components/examples/host/infoAccount.ts b/src/components/examples/host/infoAccount.ts index 1abec77..c661f75 100644 --- a/src/components/examples/host/infoAccount.ts +++ b/src/components/examples/host/infoAccount.ts @@ -1,4 +1,7 @@ -import { type codec, type config, type jam_host_calls as jam, state } from "@typeberry/lib"; +import type * as codec from "@typeberry/lib/codec"; +import type * as config from "@typeberry/lib/config"; +import type * as jam from "@typeberry/lib/jam-host-calls"; +import * as state from "@typeberry/lib/state"; import { filledHash, serviceGas, serviceId, timeSlot, u32, u64 } from "../objects/helpers"; diff --git a/src/components/examples/objects/assurancesExtrinsic.ts b/src/components/examples/objects/assurancesExtrinsic.ts index d08c4df..8de4697 100644 --- a/src/components/examples/objects/assurancesExtrinsic.ts +++ b/src/components/examples/objects/assurancesExtrinsic.ts @@ -1,4 +1,4 @@ -import { config } from "@typeberry/lib"; +import * as config from "@typeberry/lib/config"; import { availabilityAssuranceExample } from "./availabilityAssurance"; import { asKnownSize } from "./helpers"; diff --git a/src/components/examples/objects/availabilityAssurance.ts b/src/components/examples/objects/availabilityAssurance.ts index 7635dfb..467e7ec 100644 --- a/src/components/examples/objects/availabilityAssurance.ts +++ b/src/components/examples/objects/availabilityAssurance.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { bitVecFrom, ed25519Signature, resolveExampleSpec, validatorIndex, zeroHash } from "./helpers"; diff --git a/src/components/examples/objects/block.ts b/src/components/examples/objects/block.ts index bbf4d70..0f4468a 100644 --- a/src/components/examples/objects/block.ts +++ b/src/components/examples/objects/block.ts @@ -1,17 +1,14 @@ -import { block, config } from "@typeberry/lib"; - +import { Block } from "@typeberry/lib/block"; +import type { ChainSpec } from "@typeberry/lib/config"; +import { tinyChainSpec } from "@typeberry/lib/config"; import { extrinsicExample } from "./extrinsic"; import { headerExample } from "./header"; import { encodeWithExampleSpec } from "./helpers"; -export const blockExample = (spec: config.ChainSpec = config.tinyChainSpec): block.Block => - block.Block.create({ +export const blockExample = (spec: ChainSpec = tinyChainSpec): Block => + Block.create({ header: headerExample(spec), extrinsic: extrinsicExample(spec), }); -export const TEST_BLOCK = encodeWithExampleSpec( - block.Block.Codec, - blockExample(config.tinyChainSpec), - config.tinyChainSpec, -).toString(); +export const TEST_BLOCK = encodeWithExampleSpec(Block.Codec, blockExample(tinyChainSpec), tinyChainSpec).toString(); diff --git a/src/components/examples/objects/credential.ts b/src/components/examples/objects/credential.ts index 1c9e786..a17a1e0 100644 --- a/src/components/examples/objects/credential.ts +++ b/src/components/examples/objects/credential.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { ed25519Signature, validatorIndex } from "./helpers"; diff --git a/src/components/examples/objects/culprit.ts b/src/components/examples/objects/culprit.ts index 6dddcd0..552290d 100644 --- a/src/components/examples/objects/culprit.ts +++ b/src/components/examples/objects/culprit.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { ed25519Key, ed25519Signature, filledHash } from "./helpers"; diff --git a/src/components/examples/objects/disputesExtrinsic.ts b/src/components/examples/objects/disputesExtrinsic.ts index ea2203a..fd057dc 100644 --- a/src/components/examples/objects/disputesExtrinsic.ts +++ b/src/components/examples/objects/disputesExtrinsic.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { culpritExample } from "./culprit"; diff --git a/src/components/examples/objects/epochMarker.ts b/src/components/examples/objects/epochMarker.ts index 3c4b347..d6d67a5 100644 --- a/src/components/examples/objects/epochMarker.ts +++ b/src/components/examples/objects/epochMarker.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import { getStateDimensions } from "../state/common"; import type { ClassInstance } from "../types"; diff --git a/src/components/examples/objects/extrinsic.ts b/src/components/examples/objects/extrinsic.ts index e9951eb..6d1a099 100644 --- a/src/components/examples/objects/extrinsic.ts +++ b/src/components/examples/objects/extrinsic.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import { availabilityAssuranceExample } from "./availabilityAssurance"; import { disputesExtrinsicExample } from "./disputesExtrinsic"; diff --git a/src/components/examples/objects/fault.ts b/src/components/examples/objects/fault.ts index 9c29bec..1be8622 100644 --- a/src/components/examples/objects/fault.ts +++ b/src/components/examples/objects/fault.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { ed25519Key, ed25519Signature, filledHash } from "./helpers"; diff --git a/src/components/examples/objects/guaranteesExtrinsic.ts b/src/components/examples/objects/guaranteesExtrinsic.ts index 92b3202..eab30f1 100644 --- a/src/components/examples/objects/guaranteesExtrinsic.ts +++ b/src/components/examples/objects/guaranteesExtrinsic.ts @@ -1,4 +1,4 @@ -import { config } from "@typeberry/lib"; +import * as config from "@typeberry/lib/config"; import { asKnownSize } from "./helpers"; import { reportGuaranteeExample } from "./reportGuarantee"; diff --git a/src/components/examples/objects/header.ts b/src/components/examples/objects/header.ts index 380c338..8a9aaae 100644 --- a/src/components/examples/objects/header.ts +++ b/src/components/examples/objects/header.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import { bandersnatchSignature, encodeWithExampleSpec, zeroHash } from "./helpers"; diff --git a/src/components/examples/objects/helpers.ts b/src/components/examples/objects/helpers.ts index 68a5b21..12316f1 100644 --- a/src/components/examples/objects/helpers.ts +++ b/src/components/examples/objects/helpers.ts @@ -1,4 +1,10 @@ -import { block, bytes, codec, collections, config, type crypto, numbers } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as bytes from "@typeberry/lib/bytes"; +import * as codec from "@typeberry/lib/codec"; +import * as collections from "@typeberry/lib/collections"; +import * as config from "@typeberry/lib/config"; +import type * as crypto from "@typeberry/lib/crypto"; +import * as numbers from "@typeberry/lib/numbers"; export const asKnownSize = collections.asKnownSize; export const FixedSizeArray = collections.FixedSizeArray; diff --git a/src/components/examples/objects/importSpec.ts b/src/components/examples/objects/importSpec.ts index 1ad253e..35d11ea 100644 --- a/src/components/examples/objects/importSpec.ts +++ b/src/components/examples/objects/importSpec.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { filledHash } from "./helpers"; diff --git a/src/components/examples/objects/judgement.ts b/src/components/examples/objects/judgement.ts index f642054..cdd0167 100644 --- a/src/components/examples/objects/judgement.ts +++ b/src/components/examples/objects/judgement.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { ed25519Signature, validatorIndex } from "./helpers"; diff --git a/src/components/examples/objects/preimage.ts b/src/components/examples/objects/preimage.ts index 0fc6818..9ced9c1 100644 --- a/src/components/examples/objects/preimage.ts +++ b/src/components/examples/objects/preimage.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { bytesBlobFrom, serviceId } from "./helpers"; diff --git a/src/components/examples/objects/preimageExtrinsic.ts b/src/components/examples/objects/preimageExtrinsic.ts index 2dce59d..3112d35 100644 --- a/src/components/examples/objects/preimageExtrinsic.ts +++ b/src/components/examples/objects/preimageExtrinsic.ts @@ -1,4 +1,4 @@ -import { config } from "@typeberry/lib"; +import * as config from "@typeberry/lib/config"; import { preimageExample } from "./preimage"; export const preimageExtrinsicExample = ( diff --git a/src/components/examples/objects/refineContext.ts b/src/components/examples/objects/refineContext.ts index d207243..9f4c00a 100644 --- a/src/components/examples/objects/refineContext.ts +++ b/src/components/examples/objects/refineContext.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { filledHash, timeSlot } from "./helpers"; diff --git a/src/components/examples/objects/reportGuarantee.ts b/src/components/examples/objects/reportGuarantee.ts index d073496..65a00d6 100644 --- a/src/components/examples/objects/reportGuarantee.ts +++ b/src/components/examples/objects/reportGuarantee.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { credentialExample } from "./credential"; diff --git a/src/components/examples/objects/signedTicket.ts b/src/components/examples/objects/signedTicket.ts index 6e7cc4e..ec36cea 100644 --- a/src/components/examples/objects/signedTicket.ts +++ b/src/components/examples/objects/signedTicket.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { bandersnatchProof } from "./helpers"; diff --git a/src/components/examples/objects/ticket.ts b/src/components/examples/objects/ticket.ts index 21d7f20..dfb2c2c 100644 --- a/src/components/examples/objects/ticket.ts +++ b/src/components/examples/objects/ticket.ts @@ -1,4 +1,6 @@ -import { block, bytes, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as bytes from "@typeberry/lib/bytes"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; diff --git a/src/components/examples/objects/ticketExtrinsic.ts b/src/components/examples/objects/ticketExtrinsic.ts index 1f61c63..230e775 100644 --- a/src/components/examples/objects/ticketExtrinsic.ts +++ b/src/components/examples/objects/ticketExtrinsic.ts @@ -1,4 +1,4 @@ -import { config } from "@typeberry/lib"; +import * as config from "@typeberry/lib/config"; import { asKnownSize } from "./helpers"; import { signedTicketExample } from "./signedTicket"; diff --git a/src/components/examples/objects/validatorKeys.ts b/src/components/examples/objects/validatorKeys.ts index d9d1474..cf093f5 100644 --- a/src/components/examples/objects/validatorKeys.ts +++ b/src/components/examples/objects/validatorKeys.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { bandersnatchKey, ed25519Key } from "./helpers"; diff --git a/src/components/examples/objects/verdict.ts b/src/components/examples/objects/verdict.ts index 952b2b1..9d4f6fb 100644 --- a/src/components/examples/objects/verdict.ts +++ b/src/components/examples/objects/verdict.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { asKnownSize, ed25519Signature, filledHash, resolveExampleSpec, validatorIndex } from "./helpers"; diff --git a/src/components/examples/objects/workExecResult.ts b/src/components/examples/objects/workExecResult.ts index a410925..cee8bfb 100644 --- a/src/components/examples/objects/workExecResult.ts +++ b/src/components/examples/objects/workExecResult.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { bytesBlobFrom } from "./helpers"; diff --git a/src/components/examples/objects/workItem.ts b/src/components/examples/objects/workItem.ts index 1537a6b..d7b91d8 100644 --- a/src/components/examples/objects/workItem.ts +++ b/src/components/examples/objects/workItem.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { asKnownSize, bytesBlobFrom, filledHash, serviceGas, serviceId, u16 } from "./helpers"; diff --git a/src/components/examples/objects/workItemExtrinsicSpec.ts b/src/components/examples/objects/workItemExtrinsicSpec.ts index c71535f..0e7125d 100644 --- a/src/components/examples/objects/workItemExtrinsicSpec.ts +++ b/src/components/examples/objects/workItemExtrinsicSpec.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { filledHash, u32 } from "./helpers"; diff --git a/src/components/examples/objects/workPackage.ts b/src/components/examples/objects/workPackage.ts index 016c7d6..ae5ee20 100644 --- a/src/components/examples/objects/workPackage.ts +++ b/src/components/examples/objects/workPackage.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { bytesBlobFrom, FixedSizeArray, filledHash } from "./helpers"; diff --git a/src/components/examples/objects/workPackageSpec.ts b/src/components/examples/objects/workPackageSpec.ts index 0c16146..8292037 100644 --- a/src/components/examples/objects/workPackageSpec.ts +++ b/src/components/examples/objects/workPackageSpec.ts @@ -1,4 +1,6 @@ -import { block, bytes, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as bytes from "@typeberry/lib/bytes"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { filledHash, u16, u32 } from "./helpers"; diff --git a/src/components/examples/objects/workReport.ts b/src/components/examples/objects/workReport.ts index 38cf310..ff8ef21 100644 --- a/src/components/examples/objects/workReport.ts +++ b/src/components/examples/objects/workReport.ts @@ -1,4 +1,5 @@ -import { block, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { bytesBlobFrom, coreIndex, FixedSizeArray, filledHash, serviceGas } from "./helpers"; diff --git a/src/components/examples/objects/workResult.ts b/src/components/examples/objects/workResult.ts index f768a1b..7a9e3bd 100644 --- a/src/components/examples/objects/workResult.ts +++ b/src/components/examples/objects/workResult.ts @@ -1,4 +1,6 @@ -import { block, bytes, config } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as bytes from "@typeberry/lib/bytes"; +import * as config from "@typeberry/lib/config"; import type { ClassInstance } from "../types"; import { filledHash, serviceGas, serviceId, u32 } from "./helpers"; diff --git a/src/components/examples/primitives/data.ts b/src/components/examples/primitives/data.ts index b96f12b..d03660e 100644 --- a/src/components/examples/primitives/data.ts +++ b/src/components/examples/primitives/data.ts @@ -1,4 +1,5 @@ -import { bytes, type config } from "@typeberry/lib"; +import * as bytes from "@typeberry/lib/bytes"; +import type * as config from "@typeberry/lib/config"; import { bitVecFrom } from "../objects/helpers"; diff --git a/src/components/examples/primitives/numerics.ts b/src/components/examples/primitives/numerics.ts index 94633b9..a665def 100644 --- a/src/components/examples/primitives/numerics.ts +++ b/src/components/examples/primitives/numerics.ts @@ -1,4 +1,5 @@ -import { type config, numbers } from "@typeberry/lib"; +import type * as config from "@typeberry/lib/config"; +import * as numbers from "@typeberry/lib/numbers"; const { tryAsU8, tryAsU16, tryAsU32, tryAsU64 } = numbers; diff --git a/src/components/examples/state/accumulationOutputLog.ts b/src/components/examples/state/accumulationOutputLog.ts index 248f904..49bc5d3 100644 --- a/src/components/examples/state/accumulationOutputLog.ts +++ b/src/components/examples/state/accumulationOutputLog.ts @@ -1,4 +1,6 @@ -import { collections, type config, state } from "@typeberry/lib"; +import * as collections from "@typeberry/lib/collections"; +import type * as config from "@typeberry/lib/config"; +import * as state from "@typeberry/lib/state"; import { filledHash, serviceId } from "../objects/helpers"; diff --git a/src/components/examples/state/accumulationQueue.ts b/src/components/examples/state/accumulationQueue.ts index a35ed56..142ae4c 100644 --- a/src/components/examples/state/accumulationQueue.ts +++ b/src/components/examples/state/accumulationQueue.ts @@ -1,4 +1,6 @@ -import { block, type config, state } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import type * as config from "@typeberry/lib/config"; +import * as state from "@typeberry/lib/state"; import { asKnownSize, filledHash } from "../objects/helpers"; import { workReportExample } from "../objects/workReport"; diff --git a/src/components/examples/state/authPools.ts b/src/components/examples/state/authPools.ts index 27e270b..d1386f5 100644 --- a/src/components/examples/state/authPools.ts +++ b/src/components/examples/state/authPools.ts @@ -1,4 +1,6 @@ -import { collections, type config, state } from "@typeberry/lib"; +import * as collections from "@typeberry/lib/collections"; +import type * as config from "@typeberry/lib/config"; +import * as state from "@typeberry/lib/state"; import { filledHash } from "../objects/helpers"; import { getStateDimensions, resolveStateSpec } from "./common"; diff --git a/src/components/examples/state/authQueues.ts b/src/components/examples/state/authQueues.ts index 190d211..e5bdddd 100644 --- a/src/components/examples/state/authQueues.ts +++ b/src/components/examples/state/authQueues.ts @@ -1,4 +1,6 @@ -import { collections, type config, state } from "@typeberry/lib"; +import * as collections from "@typeberry/lib/collections"; +import type * as config from "@typeberry/lib/config"; +import * as state from "@typeberry/lib/state"; import { filledHash } from "../objects/helpers"; import { getStateDimensions, resolveStateSpec } from "./common"; diff --git a/src/components/examples/state/availabilityAssignment.ts b/src/components/examples/state/availabilityAssignment.ts index a8b4008..2956537 100644 --- a/src/components/examples/state/availabilityAssignment.ts +++ b/src/components/examples/state/availabilityAssignment.ts @@ -1,4 +1,5 @@ -import { type config, state } from "@typeberry/lib"; +import type * as config from "@typeberry/lib/config"; +import * as state from "@typeberry/lib/state"; import { timeSlot } from "../objects/helpers"; import { workReportExample } from "../objects/workReport"; diff --git a/src/components/examples/state/common.ts b/src/components/examples/state/common.ts index 3e330f4..0b0a562 100644 --- a/src/components/examples/state/common.ts +++ b/src/components/examples/state/common.ts @@ -1,4 +1,4 @@ -import { config } from "@typeberry/lib"; +import * as config from "@typeberry/lib/config"; export const resolveStateSpec = (spec?: config.ChainSpec): config.ChainSpec => spec ?? config.tinyChainSpec; diff --git a/src/components/examples/state/currentValidators.ts b/src/components/examples/state/currentValidators.ts index 8faf1c2..b94e3b6 100644 --- a/src/components/examples/state/currentValidators.ts +++ b/src/components/examples/state/currentValidators.ts @@ -1,4 +1,4 @@ -import type { config } from "@typeberry/lib"; +import type * as config from "@typeberry/lib/config"; import { createValidatorDataSet } from "./validatorSets"; diff --git a/src/components/examples/state/designatedValidators.ts b/src/components/examples/state/designatedValidators.ts index 7fc9d86..79c2ee3 100644 --- a/src/components/examples/state/designatedValidators.ts +++ b/src/components/examples/state/designatedValidators.ts @@ -1,4 +1,6 @@ -import type { block, config, state } from "@typeberry/lib"; +import type * as block from "@typeberry/lib/block"; +import type * as config from "@typeberry/lib/config"; +import type * as state from "@typeberry/lib/state"; import { createValidatorDataSet } from "./validatorSets"; diff --git a/src/components/examples/state/disputesRecords.ts b/src/components/examples/state/disputesRecords.ts index 1460c32..98788d1 100644 --- a/src/components/examples/state/disputesRecords.ts +++ b/src/components/examples/state/disputesRecords.ts @@ -1,4 +1,5 @@ -import { type config, state } from "@typeberry/lib"; +import type * as config from "@typeberry/lib/config"; +import * as state from "@typeberry/lib/state"; import { ed25519Key, filledHash } from "../objects/helpers"; diff --git a/src/components/examples/state/entropy.ts b/src/components/examples/state/entropy.ts index 46e4d59..3c66d0d 100644 --- a/src/components/examples/state/entropy.ts +++ b/src/components/examples/state/entropy.ts @@ -1,4 +1,6 @@ -import { collections, type config, type state } from "@typeberry/lib"; +import * as collections from "@typeberry/lib/collections"; +import type * as config from "@typeberry/lib/config"; +import type * as state from "@typeberry/lib/state"; import { filledHash } from "../objects/helpers"; diff --git a/src/components/examples/state/lookupHistoryItem.ts b/src/components/examples/state/lookupHistoryItem.ts index eb53501..0e5f3d3 100644 --- a/src/components/examples/state/lookupHistoryItem.ts +++ b/src/components/examples/state/lookupHistoryItem.ts @@ -1,4 +1,4 @@ -import type { config } from "@typeberry/lib"; +import type * as config from "@typeberry/lib/config"; import { u32 } from "../objects/helpers"; diff --git a/src/components/examples/state/previousValidators.ts b/src/components/examples/state/previousValidators.ts index ab28034..b6e739c 100644 --- a/src/components/examples/state/previousValidators.ts +++ b/src/components/examples/state/previousValidators.ts @@ -1,4 +1,4 @@ -import type { config } from "@typeberry/lib"; +import type * as config from "@typeberry/lib/config"; import { createValidatorDataSet } from "./validatorSets"; diff --git a/src/components/examples/state/privilegedServices.ts b/src/components/examples/state/privilegedServices.ts index e2980e4..6797219 100644 --- a/src/components/examples/state/privilegedServices.ts +++ b/src/components/examples/state/privilegedServices.ts @@ -1,4 +1,5 @@ -import { type config, state } from "@typeberry/lib"; +import type * as config from "@typeberry/lib/config"; +import * as state from "@typeberry/lib/state"; import { serviceGas, serviceId } from "../objects/helpers"; import { getStateDimensions, resolveStateSpec } from "./common"; diff --git a/src/components/examples/state/recentBlocks.ts b/src/components/examples/state/recentBlocks.ts index 42bf10f..a05b928 100644 --- a/src/components/examples/state/recentBlocks.ts +++ b/src/components/examples/state/recentBlocks.ts @@ -1,4 +1,7 @@ -import { block, collections, type config, state } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as collections from "@typeberry/lib/collections"; +import type * as config from "@typeberry/lib/config"; +import * as state from "@typeberry/lib/state"; import { filledHash } from "../objects/helpers"; import type { ClassInstance } from "../types"; diff --git a/src/components/examples/state/recentlyAccumulated.ts b/src/components/examples/state/recentlyAccumulated.ts index e3f3bd1..bfce82d 100644 --- a/src/components/examples/state/recentlyAccumulated.ts +++ b/src/components/examples/state/recentlyAccumulated.ts @@ -1,4 +1,7 @@ -import { block, collections, type config, type state } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as collections from "@typeberry/lib/collections"; +import type * as config from "@typeberry/lib/config"; +import type * as state from "@typeberry/lib/state"; import { filledHash } from "../objects/helpers"; import { getStateDimensions, resolveStateSpec } from "./common"; diff --git a/src/components/examples/state/safroleData.ts b/src/components/examples/state/safroleData.ts index e19e35c..3556825 100644 --- a/src/components/examples/state/safroleData.ts +++ b/src/components/examples/state/safroleData.ts @@ -1,4 +1,8 @@ -import { block, bytes, collections, type config, state } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as bytes from "@typeberry/lib/bytes"; +import * as collections from "@typeberry/lib/collections"; +import type * as config from "@typeberry/lib/config"; +import * as state from "@typeberry/lib/state"; import { bandersnatchKey, clampByte, ed25519Key } from "../objects/helpers"; import type { ClassInstance } from "../types"; diff --git a/src/components/examples/state/serviceAccount.ts b/src/components/examples/state/serviceAccount.ts index 67e54c2..6da586e 100644 --- a/src/components/examples/state/serviceAccount.ts +++ b/src/components/examples/state/serviceAccount.ts @@ -1,4 +1,5 @@ -import { type config, state } from "@typeberry/lib"; +import type * as config from "@typeberry/lib/config"; +import * as state from "@typeberry/lib/state"; import { filledHash, serviceGas, serviceId, timeSlot, u32, u64 } from "../objects/helpers"; diff --git a/src/components/examples/state/statistics.ts b/src/components/examples/state/statistics.ts index dc967ea..a34c489 100644 --- a/src/components/examples/state/statistics.ts +++ b/src/components/examples/state/statistics.ts @@ -1,4 +1,6 @@ -import { block, type config, state } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import type * as config from "@typeberry/lib/config"; +import * as state from "@typeberry/lib/state"; import { serviceGas, serviceId, u16, u32 } from "../objects/helpers"; import { getStateDimensions, resolveStateSpec } from "./common"; diff --git a/src/components/examples/state/timeslot.ts b/src/components/examples/state/timeslot.ts index 8bdf133..ca91696 100644 --- a/src/components/examples/state/timeslot.ts +++ b/src/components/examples/state/timeslot.ts @@ -1,4 +1,4 @@ -import type { config } from "@typeberry/lib"; +import type * as config from "@typeberry/lib/config"; import { timeSlot } from "../objects/helpers"; diff --git a/src/components/examples/state/validatorSets.ts b/src/components/examples/state/validatorSets.ts index cf34d39..ef7e094 100644 --- a/src/components/examples/state/validatorSets.ts +++ b/src/components/examples/state/validatorSets.ts @@ -1,4 +1,7 @@ -import { block, bytes, type config, state } from "@typeberry/lib"; +import * as block from "@typeberry/lib/block"; +import * as bytes from "@typeberry/lib/bytes"; +import type * as config from "@typeberry/lib/config"; +import * as state from "@typeberry/lib/state"; import { bandersnatchKey, clampByte, ed25519Key } from "../objects/helpers"; import { getStateDimensions, resolveStateSpec } from "./common"; diff --git a/src/components/examples/stf/genesis.ts b/src/components/examples/stf/genesis.ts index 3b7d678..325ff26 100644 --- a/src/components/examples/stf/genesis.ts +++ b/src/components/examples/stf/genesis.ts @@ -1,5 +1,6 @@ -import { bytes, config, type state_vectors } from "@typeberry/lib"; - +import * as bytes from "@typeberry/lib/bytes"; +import * as config from "@typeberry/lib/config"; +import type { StateTransitionGenesis } from "@typeberry/lib/state-vectors"; import { headerExample } from "../objects/header"; import { bytesBlobFrom, filledHash } from "../objects/helpers"; @@ -13,9 +14,7 @@ const genesisState = { ], }; -export const stfGenesisExample = ( - spec: config.ChainSpec = config.tinyChainSpec, -): state_vectors.StateTransitionGenesis => ({ +export const stfGenesisExample = (spec: config.ChainSpec = config.tinyChainSpec): StateTransitionGenesis => ({ header: headerExample(spec), state: genesisState, }); diff --git a/src/components/examples/stf/transition.ts b/src/components/examples/stf/transition.ts index d688b6a..075b931 100644 --- a/src/components/examples/stf/transition.ts +++ b/src/components/examples/stf/transition.ts @@ -1,4 +1,6 @@ -import { bytes, config, type state_vectors } from "@typeberry/lib"; +import * as bytes from "@typeberry/lib/bytes"; +import * as config from "@typeberry/lib/config"; +import type * as state_vectors from "@typeberry/lib/state-vectors"; import { blockExample } from "../objects/block"; import { bytesBlobFrom, filledHash } from "../objects/helpers"; diff --git a/src/pages/Codec.test.tsx b/src/pages/Codec.test.tsx index cd0c395..fe74a1a 100644 --- a/src/pages/Codec.test.tsx +++ b/src/pages/Codec.test.tsx @@ -70,11 +70,6 @@ vi.mock("@fluffylabs/shared-ui", () => ({ cn: (...classes: unknown[]) => classes.filter(Boolean).join(" "), })); -vi.mock("@typeberry/lib", async () => { - const actual = await vi.importActual("@typeberry/lib"); - return actual; -}); - describe("Codec", () => { it("renders the codec interface with main content", () => { render( diff --git a/src/pages/Codec.tsx b/src/pages/Codec.tsx index ff79ecc..f956c28 100644 --- a/src/pages/Codec.tsx +++ b/src/pages/Codec.tsx @@ -1,4 +1,4 @@ -import { bytes } from "@typeberry/lib"; +import * as bytes from "@typeberry/lib/bytes"; import { useEffect, useRef, useState } from "react"; import { useSearchParams } from "react-router-dom"; import { CodecInput } from "../components/CodecInput"; diff --git a/src/test/examples.test.ts b/src/test/examples.test.ts index 845e13b..9550774 100644 --- a/src/test/examples.test.ts +++ b/src/test/examples.test.ts @@ -1,4 +1,4 @@ -import { bytes } from "@typeberry/lib"; +import * as bytes from "@typeberry/lib/bytes"; import { describe, expect, it } from "vitest"; import { ALL_CHAIN_SPECS, kinds } from "../components/constants"; diff --git a/tsconfig.app.json b/tsconfig.app.json index 8eae289..440f334 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -2,9 +2,9 @@ "compilerOptions": { "composite": true, "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", - "target": "ES2020", + "target": "ES2023", "useDefineForClassFields": true, - "lib": ["ES2020", "DOM", "DOM.Iterable"], + "lib": ["ES2023", "DOM", "DOM.Iterable"], "module": "ESNext", "skipLibCheck": true,