Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,36 @@
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-empty-object-type": "off",
"no-console": "warn",
"require-yield": "off"
"require-yield": "off",
"no-restricted-imports": [
"error",
{
"patterns": [
{
"group": ["../types/*/index*", "../types/*/index"],
"message": "Use #types/* alias instead of relative imports"
},
{
"group": [
"../materials/*",
"../data/*",
"../pointer/*",
"../program/*",
"../type/*"
],
"message": "Use #types/* alias instead of relative imports"
},
{
"group": ["../../test/*", "../../../test/*"],
"message": "Use #test/* alias instead of relative imports"
},
{
"group": ["../describe*"],
"message": "Use #describe alias instead of relative imports"
}
]
}
]
},
"env": {
"node": true,
Expand Down
35 changes: 35 additions & 0 deletions packages/format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,41 @@
"files": [
"dist"
],
"imports": {
"#describe": {
"types": "./src/describe.ts",
"default": "./dist/src/describe.js"
},
"#schemas": {
"types": "./src/schemas/index.ts",
"default": "./dist/src/schemas/index.js"
},
"#types": {
"types": "./src/types/index.ts",
"default": "./dist/src/types/index.js"
},
"#types/data": {
"types": "./src/types/data/index.ts",
"default": "./dist/src/types/data/index.js"
},
"#types/materials": {
"types": "./src/types/materials/index.ts",
"default": "./dist/src/types/materials/index.js"
},
"#types/pointer": {
"types": "./src/types/pointer/index.ts",
"default": "./dist/src/types/pointer/index.js"
},
"#types/program": {
"types": "./src/types/program/index.ts",
"default": "./dist/src/types/program/index.js"
},
"#types/type": {
"types": "./src/types/type/index.ts",
"default": "./dist/src/types/type/index.js"
},
"#test/*": "./test/*.ts"
},
"scripts": {
"prepare:yamls": "node ./bin/generate-schema-yamls.js",
"prepare": "yarn prepare:yamls && tsc",
Expand Down
6 changes: 3 additions & 3 deletions packages/format/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./describe.js";
export { schemas, schemaIds, type Schema } from "./schemas/index.js";
export * from "#describe";
export { schemas, schemaIds, type Schema } from "#schemas";

export * from "./types/index.js";
export * from "#types";
6 changes: 3 additions & 3 deletions packages/format/src/schemas/examples.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { expect, describe, it } from "vitest";

import { schemaExtensions } from "../../test/extensions.js";
import { schemaExtensions } from "#test/extensions";
import { schemas } from "./index.js";
import type { JSONSchema } from "../describe.js";
import type { JSONSchema } from "#describe";

// loads schemas into global hyperjump json schema validator
import "../../test/hyperjump.js";
import "#test/hyperjump";

const idsOfSchemasAllowedToOmitExamples = new Set([
"schema:ethdebug/format/type",
Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describeSchema } from "../describe.js";
import { describeSchema } from "#describe";
import { schemaYamls } from "./yamls.js";
export type { Schema } from "./yamls.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/schemas/validity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { schemas } from "./index.js";

// loads schemas into global hyperjump json schema validator
import "../../test/hyperjump.js";
import "#test/hyperjump";

const printErrors = (output: { errors?: OutputUnit[] }): string =>
output
Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/types/data/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { testSchemaGuards } from "../../../test/guards.js";
import { testSchemaGuards } from "#test/guards";

import { Data } from "./index.js";

Expand Down
10 changes: 5 additions & 5 deletions packages/format/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from "./data/index.js";
export * from "./materials/index.js";
export * from "./type/index.js";
export * from "./pointer/index.js";
export * from "./program/index.js";
export * from "#types/data";
export * from "#types/materials";
export * from "#types/type";
export * from "#types/pointer";
export * from "#types/program";
2 changes: 1 addition & 1 deletion packages/format/src/types/materials/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { testSchemaGuards } from "../../../test/guards.js";
import { testSchemaGuards } from "#test/guards";
import { Materials } from "./index.js";

testSchemaGuards("ethdebug/format/materials", [
Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/types/materials/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Data } from "../data/index.js";
import { Data } from "#types/data";

export namespace Materials {
export type Id = number | string;
Expand Down Expand Up @@ -57,7 +57,7 @@
name: string;
version: string;
};
settings?: any;

Check warning on line 60 in packages/format/src/types/materials/index.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Unexpected any. Specify a different type
sources: Source[];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/types/pointer/pointer.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { testSchemaGuards } from "../../../test/guards.js";
import { testSchemaGuards } from "#test/guards";

import { Pointer, isPointer } from "./pointer.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/types/program/context.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { testSchemaGuards } from "../../../test/guards.js";
import { testSchemaGuards } from "#test/guards";
import { Context, isContext } from "./context.js";

testSchemaGuards("ethdebug/format/program/context", [
Expand Down
6 changes: 3 additions & 3 deletions packages/format/src/types/program/context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Materials } from "../materials/index.js";
import { Type, isType } from "../type/index.js";
import { Pointer, isPointer } from "../pointer/index.js";
import { Materials } from "#types/materials";
import { Type, isType } from "#types/type";
import { Pointer, isPointer } from "#types/pointer";

export type Context =
| Context.Code
Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/types/program/instruction.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { testSchemaGuards } from "../../../test/guards.js";
import { testSchemaGuards } from "#test/guards";
import { isInstruction } from "./instruction.js";

testSchemaGuards("ethdebug/format/program/instruction", [
Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/types/program/instruction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Data } from "../data/index.js";
import { Data } from "#types/data";

import { Context, isContext } from "./context.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/types/program/program.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { testSchemaGuards } from "../../../test/guards.js";
import { testSchemaGuards } from "#test/guards";
import { isProgram } from "./program.js";

testSchemaGuards("ethdebug/format/program", [
Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/types/program/program.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Materials } from "../materials/index.js";
import { Materials } from "#types/materials";

import { Context as _Context, isContext as _isContext } from "./context.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/types/type/base.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { testSchemaGuards } from "../../../test/guards.js";
import { testSchemaGuards } from "#test/guards";
import * as Base from "./base.js";

testSchemaGuards("ethdebug/format/type/base", [
Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/types/type/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { testSchemaGuards } from "../../../test/guards.js";
import { testSchemaGuards } from "#test/guards";
import { Type, isType } from "./index.js";

testSchemaGuards("ethdebug/format/type", [
Expand Down
4 changes: 2 additions & 2 deletions packages/format/src/types/type/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Data } from "../data/index.js";
import { Materials } from "../materials/index.js";
import { Data } from "#types/data";
import { Materials } from "#types/materials";

import * as _Base from "./base.js";

Expand Down Expand Up @@ -33,7 +33,7 @@
Object.values(value.contains).every(Type.isWrapper)));

export interface Wrapper {
type: Type | { id: any };

Check warning on line 36 in packages/format/src/types/type/index.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Unexpected any. Specify a different type
}

export const isWrapper = (value: unknown): value is Wrapper =>
Expand Down Expand Up @@ -238,7 +238,7 @@
export interface Enum {
class?: "elementary";
kind: "enum";
values: any[];

Check warning on line 241 in packages/format/src/types/type/index.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Unexpected any. Specify a different type
definition?: Definition;
}

Expand Down
14 changes: 13 additions & 1 deletion packages/format/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@
"moduleResolution": "nodenext",
"exactOptionalPropertyTypes": true,
"rootDir": "./",
"outDir": "./dist/"
"outDir": "./dist/",
"baseUrl": "./",
"paths": {
"#describe": ["./src/describe"],
"#schemas": ["./src/schemas/index"],
"#types": ["./src/types/index"],
"#types/data": ["./src/types/data/index"],
"#types/materials": ["./src/types/materials/index"],
"#types/pointer": ["./src/types/pointer/index"],
"#types/program": ["./src/types/program/index"],
"#types/type": ["./src/types/type/index"],
"#test/*": ["./test/*"]
}
},
"include": ["./src/**/*.ts", "./test/**/*.ts", "./*.ts"]
}
31 changes: 31 additions & 0 deletions packages/pointers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,37 @@
"main": "dist/src/index.js",
"type": "module",
"license": "MIT",
"imports": {
"#cursor": {
"types": "./src/cursor.ts",
"default": "./dist/src/cursor.js"
},
"#data": {
"types": "./src/data.ts",
"default": "./dist/src/data.js"
},
"#evaluate": {
"types": "./src/evaluate.ts",
"default": "./dist/src/evaluate.js"
},
"#machine": {
"types": "./src/machine.ts",
"default": "./dist/src/machine.js"
},
"#read": {
"types": "./src/read.ts",
"default": "./dist/src/read.js"
},
"#dereference": {
"types": "./src/dereference/index.ts",
"default": "./dist/src/dereference/index.js"
},
"#dereference/*": {
"types": "./src/dereference/*.ts",
"default": "./dist/src/dereference/*.js"
},
"#test/*": "./test/*.ts"
},
"scripts": {
"run-example": "node ./dist/bin/run-example.js",
"prepare": "tsc --build",
Expand Down
4 changes: 2 additions & 2 deletions packages/pointers/src/cursor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Pointer } from "@ethdebug/format";
import type { Machine } from "./machine.js";
import type { Data } from "./data.js";
import type { Machine } from "#machine";
import type { Data } from "#data";

/**
* The result of dereferencing a pointer
Expand Down
6 changes: 3 additions & 3 deletions packages/pointers/src/dereference/cursor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Machine } from "../machine.js";
import type { Cursor } from "../cursor.js";
import { read } from "../read.js";
import type { Machine } from "#machine";
import type { Cursor } from "#cursor";
import { read } from "#read";

export function createCursor(
simpleCursor: (state: Machine.State) => AsyncIterable<Cursor.Region>,
Expand Down
6 changes: 3 additions & 3 deletions packages/pointers/src/dereference/generate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Pointer } from "@ethdebug/format";
import type { Machine } from "../machine.js";
import type { Cursor } from "../cursor.js";
import type { Data } from "../data.js";
import type { Machine } from "#machine";
import type { Cursor } from "#cursor";
import type { Data } from "#data";

import { Memo } from "./memo.js";
import { processPointer, type ProcessOptions } from "./process.js";
Expand Down
4 changes: 2 additions & 2 deletions packages/pointers/src/dereference/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { vitest, expect, describe, it, beforeEach } from "vitest";
import { Pointer } from "@ethdebug/format";
import { Machine } from "../machine.js";
import { Data } from "../data.js";
import { Machine } from "#machine";
import { Data } from "#data";
import { dereference } from "./index.js";

describe("dereference", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/pointers/src/dereference/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Pointer } from "@ethdebug/format";
import type { Machine } from "../machine.js";
import type { Cursor } from "../cursor.js";
import type { Machine } from "#machine";
import type { Cursor } from "#cursor";

import { generateRegions, type GenerateRegionsOptions } from "./generate.js";
import { createCursor } from "./cursor.js";
Expand Down
4 changes: 2 additions & 2 deletions packages/pointers/src/dereference/memo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Pointer } from "@ethdebug/format";
import type { Cursor } from "../cursor.js";
import type { Data } from "../data.js";
import type { Cursor } from "#cursor";
import type { Data } from "#data";

/**
* A single state transition for processing on a stack
Expand Down
8 changes: 4 additions & 4 deletions packages/pointers/src/dereference/process.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Pointer } from "@ethdebug/format";
import type { Machine } from "../machine.js";
import type { Cursor } from "../cursor.js";
import { Data } from "../data.js";
import { evaluate } from "../evaluate.js";
import type { Machine } from "#machine";
import type { Cursor } from "#cursor";
import { Data } from "#data";
import { evaluate } from "#evaluate";

import { Memo } from "./memo.js";
import { adjustStackLength, evaluateRegion } from "./region.js";
Expand Down
6 changes: 3 additions & 3 deletions packages/pointers/src/dereference/region.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Pointer } from "@ethdebug/format";
import type { Cursor } from "../cursor.js";
import type { Data } from "../data.js";
import { evaluate, type EvaluateOptions } from "../evaluate.js";
import type { Cursor } from "#cursor";
import type { Data } from "#data";
import { evaluate, type EvaluateOptions } from "#evaluate";

/**
* Evaluate all Pointer.Expression-value properties on a given region
Expand Down
6 changes: 3 additions & 3 deletions packages/pointers/src/evaluate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { toHex } from "ethereum-cryptography/utils";

import { Pointer } from "@ethdebug/format";

import { Machine } from "./machine.js";
import { Data } from "./data.js";
import { Cursor } from "./cursor.js";
import { Machine } from "#machine";
import { Data } from "#data";
import { Cursor } from "#cursor";
import { evaluate, type EvaluateOptions } from "./evaluate.js";

// Create a stub for the Machine.State interface
Expand Down
8 changes: 4 additions & 4 deletions packages/pointers/src/evaluate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Pointer } from "@ethdebug/format";
import { Machine } from "./machine.js";
import { Data } from "./data.js";
import type { Cursor } from "./cursor.js";
import { read } from "./read.js";
import { Machine } from "#machine";
import { Data } from "#data";
import type { Cursor } from "#cursor";
import { read } from "#read";
import { keccak256 } from "ethereum-cryptography/keccak";

export interface EvaluateOptions {
Expand Down
8 changes: 4 additions & 4 deletions packages/pointers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { dereference, DereferenceOptions } from "./dereference/index.js";
export { Cursor } from "./cursor.js";
export { dereference, DereferenceOptions } from "#dereference";
export { Cursor } from "#cursor";

export type { Machine } from "./machine.js";
export { Data } from "./data.js";
export type { Machine } from "#machine";
export { Data } from "#data";
2 changes: 1 addition & 1 deletion packages/pointers/src/machine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Data } from "./data.js";
import type { Data } from "#data";

export interface Machine {
trace(): AsyncIterable<Machine.State>;
Expand Down
Loading
Loading