Skip to content

Commit

Permalink
Fix import paths for types
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Dec 19, 2024
1 parent b47f353 commit ef491d2
Show file tree
Hide file tree
Showing 163 changed files with 369 additions and 378 deletions.
2 changes: 1 addition & 1 deletion packages/as-sha256/test/perf/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {itBench, setBenchOpts} from "@dapplion/benchmark";
import * as sha256 from "../../src";
import * as sha256 from "../../src/index.js";

// Feb 2024 Mac M1
// digestTwoHashObjects vs digest64 vs digest
Expand Down
2 changes: 1 addition & 1 deletion packages/as-sha256/test/perf/simd.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {itBench, setBenchOpts} from "@dapplion/benchmark";
import * as sha256 from "../../src";
import * as sha256 from "../../src/index.js";
import {byteArrayToHashObject} from "../../src/hashObject";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/as-sha256/test/unit/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Buffer} from "buffer";
import * as sha256 from "../../src";
import * as sha256 from "../../src/index.js";
import {expect} from "chai";

describe("sha256", function () {
Expand Down
2 changes: 1 addition & 1 deletion packages/as-sha256/test/unit/simd.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {expect} from "chai";
import crypto from "crypto";
import {byteArrayToHashObject, hashObjectToByteArray} from "../../src/hashObject";
import * as sha256 from "../../src";
import * as sha256 from "../../src/index.js";

describe("Test SIMD implementation of as-sha256", () => {
it("testHash4UintArray64s", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/test/perf/gindex.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {itBench} from "@dapplion/benchmark";
import {getGindexBits, getGindicesAtDepth, gindexIterator, iterateAtDepth} from "../../src";
import {getGindexBits, getGindicesAtDepth, gindexIterator, iterateAtDepth} from "../../src/index.js";

describe("gindices at depth", () => {
const count = 100;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {itBench} from "@dapplion/benchmark";
import { HashComputation, HashComputationLevel, LeafNode, zeroHash } from "../../src";
import { HashComputation, HashComputationLevel, LeafNode, zeroHash } from "../../src/index.js";

/**
* HashComputationLevel push then loop is faster than HashComputation[] push then loop
Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/test/perf/hasher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {hasher as asShaHasher} from "../../src/hasher/as-sha256";
import {hasher as nobleHasher} from "../../src/hasher/noble";
import {hasher as hashtreeHasher} from "../../src/hasher/hashtree";
import {buildComparisonTrees} from "../utils/tree";
import {HashComputationLevel, getHashComputations} from "../../src";
import {HashComputationLevel, getHashComputations} from "../../src/index.js";

describe("hasher", function () {
this.timeout(0);
Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/test/perf/node.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {itBench} from "@dapplion/benchmark";
import {BranchNode, getNodeH, LeafNode} from "../../src/node";
import {countToDepth, getHashComputations, HashComputation, subtreeFillToContents} from "../../src";
import {countToDepth, getHashComputations, HashComputation, subtreeFillToContents} from "../../src/index.js";
import {batchHash} from "../utils/batchHash";

describe("HashObject LeafNode", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/test/perf/tree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
toGindex,
uint8ArrayToHashObject,
toGindexBitstring,
} from "../../src";
} from "../../src/index.js";

describe("Track the performance of different Tree methods", () => {
const VALIDATOR_REGISTRY_LIMIT = 1099511627776;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {itBench} from "@dapplion/benchmark";
import {getNodeAtDepth, getNodesAtDepth, setNodeAtDepth, setNodesAtDepth, zeroNode} from "../../../src";
import {getNodeAtDepth, getNodesAtDepth, setNodeAtDepth, setNodesAtDepth, zeroNode} from "../../../src/index.js";
import {linspace, fillArray} from "../../utils/misc";

describe("Tree opts with low depth", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {itBench} from "@dapplion/benchmark";
import {subtreeFillToContents, Tree, Node, LeafNode, getNodesAtDepth, zeroNode, BranchNode} from "../../../src";
import {subtreeFillToContents, Tree, Node, LeafNode, getNodesAtDepth, zeroNode, BranchNode} from "../../../src/index.js";

// Results in Linux Dec 2021
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {itBench} from "@dapplion/benchmark";
import {subtreeFillToContents, Tree, Node, LeafNode, toGindex, setNodesAtDepth} from "../../../src";
import {subtreeFillToContents, Tree, Node, LeafNode, toGindex, setNodesAtDepth} from "../../../src/index.js";

// Results in Linux Dec 2021
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {itBench} from "@dapplion/benchmark";
import {Tree, iterateAtDepth, LeafNode, subtreeFillToDepth} from "../../src";
import {Tree, iterateAtDepth, LeafNode, subtreeFillToDepth} from "../../src/index.js";

describe("Tree", () => {
for (const depth of [8, 16, 32]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
countToDepth,
zeroNode,
getHashComputations,
} from "../../src";
} from "../../src/index.js";
import {MemoryTracker} from "../utils/memTracker";
import {batchHash} from "../utils/batchHash";

Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/test/unit/backing.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {assert} from "chai";
import {describe, it} from "mocha";
import {Tree, LeafNode, subtreeFillToDepth} from "../../src";
import {Tree, LeafNode, subtreeFillToDepth} from "../../src/index.js";

describe("get", () => {
it("should return the right node", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/test/unit/gindex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Bit,
getGindicesAtDepth,
getGindexBits,
} from "../../src";
} from "../../src/index.js";

describe("countToDepth", () => {
const testCases = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { zeroNode, Node } from "../../src";
import { zeroNode, Node } from "../../src/index.js";
import {HashComputationLevel} from "../../src/hashComputation";

describe("HashComputationLevel", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/test/unit/hasher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {hasher as asSha256Hasher} from "../../src/hasher/as-sha256";
import {hasher as hashtreeHasher} from "../../src/hasher/hashtree";
import {linspace} from "../utils/misc";
import {buildComparisonTrees} from "../utils/tree";
import {HashComputationLevel, HashObject, LeafNode, getHashComputations, subtreeFillToContents} from "../../src";
import {HashComputationLevel, HashObject, LeafNode, getHashComputations, subtreeFillToContents} from "../../src/index.js";
import { expect } from "chai";
import { zeroHash } from "../../src/zeroHash";

Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/test/unit/node.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {HashObject} from "@chainsafe/as-sha256";
import {expect} from "chai";
import {BranchNode, LeafNode, countToDepth, subtreeFillToContents} from "../../src";
import {BranchNode, LeafNode, countToDepth, subtreeFillToContents} from "../../src/index.js";
import {HashComputation, HashComputationLevel, getHashComputations} from "../../src/hashComputation";

describe("LeafNode uint", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {HashObject} from "@chainsafe/as-sha256";
import {expect} from "chai";
import {LeafNode, Node} from "../../src";
import {LeafNode, Node} from "../../src/index.js";
import {packedNodeRootsToBytes, packedRootsBytesToLeafNodes, packedUintNum64sToLeafNodes} from "../../src/packedNode";

describe("subtree / packedNode single node", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/test/unit/snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {fromSnapshot, indexToFinalizedGindices, toSnapshot} from "../../src/snap
import {subtreeFillToContents} from "../../src/subtree";
import { LeafNode } from "../../src/node";
import { Tree, setNodesAtDepth } from "../../src/tree";
import { toGindex } from "../../src";
import { toGindex } from "../../src/index.js";

describe("toSnapshot and fromSnapshot", () => {
const depth = 4;
Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/test/unit/subtree.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import {subtreeFillToContents, LeafNode, getNodesAtDepth, executeHashComputations, BranchNode, Node, HashComputationLevel, zeroNode} from "../../src";
import {subtreeFillToContents, LeafNode, getNodesAtDepth, executeHashComputations, BranchNode, Node, HashComputationLevel, zeroNode} from "../../src/index.js";

describe("subtreeFillToContents", function () {
// the hash computation takes time
Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/test/unit/tree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
findDiffDepthi,
getHashComputations,
HashComputationLevel,
} from "../../src";
} from "../../src/index.js";
import {batchHash} from "../utils/batchHash";

describe("fixed-depth tree iteration", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expect} from "chai";
import {getNodesAtDepth, LeafNode, Node, subtreeFillToContents, Tree} from "../../../src";
import {getNodesAtDepth, LeafNode, Node, subtreeFillToContents, Tree} from "../../../src/index.js";

describe("tree / getNodes", () => {
const depth = 40;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expect} from "chai";
import {LeafNode, Node, toGindex, Tree, zeroNode, treeZeroAfterIndex, getNodesAtDepth} from "../../../src";
import {LeafNode, Node, toGindex, Tree, zeroNode, treeZeroAfterIndex, getNodesAtDepth} from "../../../src/index.js";

describe("tree / zeroAfterIndex", () => {
// Test all possible zeroAfterIndex operations for any tree with 0 <= depth < 6
Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/test/utils/tree.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {subtreeFillToContents} from "../../src";
import {subtreeFillToContents} from "../../src/index.js";
import {BranchNode, LeafNode, Node} from "../../src/node";
import {linspace} from "./misc";

Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"scripts": {
"clean": "rm -rf lib",
"build": "yarn build:cjs && yarn build:esm",
"build": "yarn build:cjs && yarn build:esm && yarn build:types",
"build:esm": "tsc -p tsconfig.build.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:cjs": "tsc -p tsconfig.build.cjs.json && echo '{\"type\": \"commonjs\"}' > ./lib/cjs/package.json",
"build:types": "tsc -p tsconfig.build.types.json",
Expand Down
4 changes: 2 additions & 2 deletions packages/simpleserialize.com/src/components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {ChangeEvent} from "react";
import {AlertManager, withAlert} from "react-alert";

import {inputTypes} from "../util/input_types";
import {ForkName, typeNames, forks} from "../util/types";
import {ForkName, typeNames, forks} from "../util/types.js";
import {SszWorker} from "./worker";

const initialType = "BeaconBlock";
Expand All @@ -33,7 +33,7 @@ type State = {
userHasEditedInput: boolean;
};

const DEFAULT_FORK = "deneb";
const DEFAULT_FORK = "deneb/index.js";

class Input extends React.Component<Props, State> {
worker: Worker;
Expand Down
2 changes: 1 addition & 1 deletion packages/simpleserialize.com/src/components/Serialize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Output from "./Output";
import Input from "./Input";
import LoadingOverlay from "react-loading-overlay";
import BounceLoader from "react-spinners/BounceLoader";
import {ForkName} from "../util/types";
import {ForkName} from "../util/types.js";
import {ModuleThread, spawn, Thread, Worker} from "threads";
import {SszWorker} from "./worker";

Expand Down
2 changes: 1 addition & 1 deletion packages/simpleserialize.com/src/components/TreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
isContainerType,
} from "@chainsafe/ssz";
import BN from "bn.js";
import { ForkName, forks } from "../util/types";
import { ForkName, forks } from "../util/types.js";

function getTypeName<T>(type: Type<T>, types: Record<string, Type<T>>, name: string): string | undefined {
if(isBooleanType(type)) return "bool";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Type} from "@chainsafe/ssz";
import {forks} from "../../util/types";
import {forks} from "../../util/types.js";

// type primitiveType = boolean | number | bigint | Uint8Array | Array<boolean> | object | undefined;

Expand Down
11 changes: 1 addition & 10 deletions packages/simpleserialize.com/src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,7 @@ import {
} from "@chainsafe/ssz";
import {ssz} from "@lodestar/types";

let {
phase0,
altair,
bellatrix,
capella,
deneb,
electra,
sszTypesFor,
...primitive
} = ssz;
let {phase0, altair, bellatrix, capella, deneb, electra, sszTypesFor, ...primitive} = ssz;

phase0 = patchSszTypes(phase0);
altair = patchSszTypes(altair);
Expand Down
6 changes: 3 additions & 3 deletions packages/ssz/test/lodestarTypes/allForks/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./types";
export * as ts from "./types";
export * as ssz from "./sszTypes";
export * from "./types.js";
export * as ts from "./types.js";
export * as ssz from "./sszTypes.js";
10 changes: 5 additions & 5 deletions packages/ssz/test/lodestarTypes/allForks/sszTypes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {ssz as phase0} from "../phase0";
import {ssz as altair} from "../altair";
import {ssz as bellatrix} from "../bellatrix";
import {ssz as capella} from "../capella";
import {ssz as deneb} from "../deneb";
import {ssz as phase0} from "../phase0/index.js";
import {ssz as altair} from "../altair/index.js";
import {ssz as bellatrix} from "../bellatrix/index.js";
import {ssz as capella} from "../capella/index.js";
import {ssz as deneb} from "../deneb/index.js";

/**
* Index the ssz types that differ by fork
Expand Down
22 changes: 11 additions & 11 deletions packages/ssz/test/lodestarTypes/allForks/types.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {CompositeType, ContainerType, ValueOf, CompositeView, CompositeViewDU} from "../../../src";
import {ts as phase0} from "../phase0";
import {ts as altair} from "../altair";
import {ts as bellatrix} from "../bellatrix";
import {ts as capella} from "../capella";
import {ts as deneb} from "../deneb";
import {CompositeType, ContainerType, ValueOf, CompositeView, CompositeViewDU} from "../../../src/index.js";
import {ts as phase0} from "../phase0/index.js";
import {ts as altair} from "../altair/index.js";
import {ts as bellatrix} from "../bellatrix/index.js";
import {ts as capella} from "../capella/index.js";
import {ts as deneb} from "../deneb/index.js";

import {ssz as phase0Ssz} from "../phase0";
import {ssz as altairSsz} from "../altair";
import {ssz as bellatrixSsz} from "../bellatrix";
import {ssz as capellaSsz} from "../capella";
import {ssz as denebSsz} from "../deneb";
import {ssz as phase0Ssz} from "../phase0/index.js";
import {ssz as altairSsz} from "../altair/index.js";
import {ssz as bellatrixSsz} from "../bellatrix/index.js";
import {ssz as capellaSsz} from "../capella/index.js";
import {ssz as denebSsz} from "../deneb/index.js";

// Re-export union types for types that are _known_ to differ

Expand Down
6 changes: 3 additions & 3 deletions packages/ssz/test/lodestarTypes/altair/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./types";
export * as ts from "./types";
export * as ssz from "./sszTypes";
export * from "./types.js";
export * as ts from "./types.js";
export * as ssz from "./sszTypes.js";
8 changes: 4 additions & 4 deletions packages/ssz/test/lodestarTypes/altair/sszTypes.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {BitVectorType, ContainerType, ListBasicType, ListCompositeType, VectorCompositeType} from "../../../src";
import {preset, FINALIZED_ROOT_DEPTH, NEXT_SYNC_COMMITTEE_DEPTH, SYNC_COMMITTEE_SUBNET_COUNT} from "../params";
import {BitVectorType, ContainerType, ListBasicType, ListCompositeType, VectorCompositeType} from "../../../src/index.js";
import {preset, FINALIZED_ROOT_DEPTH, NEXT_SYNC_COMMITTEE_DEPTH, SYNC_COMMITTEE_SUBNET_COUNT} from "../params.js";
const {
SYNC_COMMITTEE_SIZE,
HISTORICAL_ROOTS_LIMIT,
VALIDATOR_REGISTRY_LIMIT,
EPOCHS_PER_SYNC_COMMITTEE_PERIOD,
SLOTS_PER_EPOCH,
} = preset;
import * as phase0Ssz from "../phase0/sszTypes";
import * as primitiveSsz from "../primitive/sszTypes";
import * as phase0Ssz from "../phase0/sszTypes.js";
import * as primitiveSsz from "../primitive/sszTypes.js";

const {
Bytes32,
Expand Down
4 changes: 2 additions & 2 deletions packages/ssz/test/lodestarTypes/altair/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ValueOf} from "../../../src";
import * as ssz from "./sszTypes";
import {ValueOf} from "../../../src/index.js";
import * as ssz from "./sszTypes.js";

export type SyncSubnets = ValueOf<typeof ssz.SyncSubnets>;
export type Metadata = ValueOf<typeof ssz.Metadata>;
Expand Down
6 changes: 3 additions & 3 deletions packages/ssz/test/lodestarTypes/bellatrix/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./types";
export * as ts from "./types";
export * as ssz from "./sszTypes";
export * from "./types.js";
export * as ts from "./types.js";
export * as ssz from "./sszTypes.js";
12 changes: 6 additions & 6 deletions packages/ssz/test/lodestarTypes/bellatrix/sszTypes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {ByteListType, ByteVectorType, ContainerType, ListCompositeType} from "../../../src";
import {preset} from "../params";
import {ssz as primitiveSsz} from "../primitive";
import {ssz as phase0Ssz} from "../phase0";
import {ssz as altairSsz} from "../altair";
import {stringType} from "../utils/StringType";
import {ByteListType, ByteVectorType, ContainerType, ListCompositeType} from "../../../src/index.js";
import {preset} from "../params.js";
import {ssz as primitiveSsz} from "../primitive/index.js";
import {ssz as phase0Ssz} from "../phase0/index.js";
import {ssz as altairSsz} from "../altair/index.js";
import {stringType} from "../utils/StringType.js";
const {
BYTES_PER_LOGS_BLOOM,
HISTORICAL_ROOTS_LIMIT,
Expand Down
4 changes: 2 additions & 2 deletions packages/ssz/test/lodestarTypes/bellatrix/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ValueOf} from "../../../src";
import * as ssz from "./sszTypes";
import {ValueOf} from "../../../src/index.js";
import * as ssz from "./sszTypes.js";

export type Transaction = ValueOf<typeof ssz.Transaction>;
export type Transactions = ValueOf<typeof ssz.Transactions>;
Expand Down
6 changes: 3 additions & 3 deletions packages/ssz/test/lodestarTypes/capella/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./types";
export * as ts from "./types";
export * as ssz from "./sszTypes";
export * from "./types.js";
export * as ts from "./types.js";
export * as ssz from "./sszTypes.js";
Loading

0 comments on commit ef491d2

Please sign in to comment.