diff --git a/.babelrc b/.babelrc index 9865295..e338115 100644 --- a/.babelrc +++ b/.babelrc @@ -1,11 +1,14 @@ { - "presets": [ - ["@babel/env", { - "modules": false, - "useBuiltIns": "usage", - "corejs": "3" - }], - "@babel/react", - "@babel/typescript" - ] + "presets": [ + [ + "@babel/env", + { + "modules": false, + "useBuiltIns": "usage", + "corejs": "3" + } + ], + "@babel/react", + "@babel/typescript" + ] } diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index ff1d4c5..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,82 +0,0 @@ -const path = require('path'); - -module.exports = { - root: true, - env: { - browser: true, - es6: true, - node: true, - mocha: true - }, - globals: { - BigInt: true - }, - parser: "@typescript-eslint/parser", - parserOptions: { - ecmaVersion: 10, - project: "./tsconfig.json" - }, - plugins: [ - "@typescript-eslint", - "eslint-plugin-import", - "react" - ], - extends: [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:import/errors", - "plugin:import/warnings", - 'plugin:react/recommended', - "plugin:import/typescript", - "plugin:@typescript-eslint/recommended" - ], - rules: { - //doesnt work, it reports false errors - "constructor-super": "off", - "@typescript-eslint/explicit-function-return-type": ["error", { - "allowExpressions": true - }], - "@typescript-eslint/func-call-spacing": "error", - "@typescript-eslint/indent": ["error", 2], - "@typescript-eslint/member-ordering": "error", - "@typescript-eslint/no-explicit-any": "error", - "@typescript-eslint/no-require-imports": "error", - "@typescript-eslint/no-use-before-define": "off", - "@typescript-eslint/semi": "error", - "@typescript-eslint/type-annotation-spacing": "error", - "import/no-extraneous-dependencies": ["error", { - "devDependencies": false, - "optionalDependencies": false, - "peerDependencies": false - }], - "camelcase": "error", - "func-call-spacing": "off", - "max-len": ["error", { - "code": 120 - }], - "new-parens": "error", - "no-caller": "error", - "no-bitwise": "off", - "no-console": "warn", - "no-var": "error", - "object-curly-spacing": ["error", "never"], - "prefer-const": "error", - "quotes": ["error", "double"], - "semi": "off" - }, - "overrides": [ - { - "files": ["**/test/**/*.ts"], - "rules": { - "import/no-extraneous-dependencies": "off", - "@typescript-eslint/no-explicit-any": "off" - } - }, - { - "files": ["*.tsx"], - "rules": { - "no-undef": "off" - } - }, - ] -}; diff --git a/.github/workflows/cd-manual.yml b/.github/workflows/cd-manual.yml new file mode 100644 index 0000000..193b8c6 --- /dev/null +++ b/.github/workflows/cd-manual.yml @@ -0,0 +1,29 @@ +name: CloudFlare Pages Deploy +on: + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + steps: + - uses: actions/checkout@v3 + - run: corepack enable + - uses: actions/setup-node@v4 + with: + cache: yarn + node-version: '20' + - name: Bootstrap + run: yarn --immutable + - name: Build + run: yarn build + - name: Publish to Cloudflare Pages + uses: cloudflare/pages-action@1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: simpleserialize + directory: ./dist + gitHubToken: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml new file mode 100644 index 0000000..4d23644 --- /dev/null +++ b/.github/workflows/semantic-pr.yml @@ -0,0 +1,23 @@ +name: "Semantic PR" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: | + fix + feat + chore + revert \ No newline at end of file diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..18adddd --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,11 @@ +module.exports = { + printWidth: 120, + tabWidth: 2, + useTabs: false, + semi: true, + singleQuote: false, + quoteProps: "as-needed", + trailingComma: "es5", + bracketSpacing: false, + arrowParens: "always", +}; diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..68a1782 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,328 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.3.2](https://github.com/chainsafe/simpleserialize.com/compare/simpleserialize.com@0.3.1...simpleserialize.com@0.3.2) (2023-01-05) + +**Note:** Version bump only for package simpleserialize.com + + + + + +## [0.3.1](https://github.com/chainsafe/simpleserialize.com/compare/simpleserialize.com@0.3.0...simpleserialize.com@0.3.1) (2022-12-08) + +**Note:** Version bump only for package simpleserialize.com + + + + + +# [0.3.0](https://github.com/chainsafe/simpleserialize.com/compare/simpleserialize.com@0.1.0...simpleserialize.com@0.3.0) (2022-12-08) + + +* SSZ v2 (#223) ([9d167b7](https://github.com/chainsafe/simpleserialize.com/commit/9d167b703b1e974ee4943be15710aa9783183986)), closes [#223](https://github.com/chainsafe/simpleserialize.com/issues/223) [#227](https://github.com/chainsafe/simpleserialize.com/issues/227) + + +### BREAKING CHANGES + +* complete refactor, see packages/ssz/README.md for details + +Initial squashed v2 commit + +Replace lodestarTypes + +Update tests + +Add Union and None types + +Update spec tests + +Remove old src and lodestar dependencies + +Improve JSON parsing for tests + +Load YAML with lodestar utils schema + +Commit ArrayComposite before getAll + +Re-write toJson fromJson test + +Fix uint json conversions + +Print tree in valid test if requested + +Fix hashTreeRoot for ByteList + +Add RENDER_ROOTS option + +Fix typos + +Use numerical sort in array commit + +Fix value_serializedSizeArrayComposite + +Pass ssz_generic tests + +Allow to select tests to run in ssz_static + +Fix container bytes offset + +Rename fixedLen to fixedSize + +Sort deserailization methods + +Print json stringified in test + +Review logic + +Clean up tests + +Define JSON casing at constructor time only + +Add casing maps for merge types + +Update casing in unit tests + +Re-organize utils + +Fix merge casing + +FIx offset calculation + +Pass all spec test pre-merge + +Bump merge test + +Extend timeout for mainnet tests + +Pass all unit tests + +Return defaultValue in simpleserialize random + +Remove @chainsafe/lodestar-spec-test-util dependency + +Copy yaml schema from lodestar-utils + +Fix benchmark type issues + +Skip createProof benchmark + +Skip old benchmark without runner + +Remove postinstall script + +Re-add UintBigint optimization + +Fix set_exitEpoch_and_hashTreeRoot benchmark + +Add List of Number benchmark + +Use DataViews for faster deserialization + +Use DataViews for tree serialization too + +Update workflows build after install + +Update packedNode tests + +Review Tree API + +Validate length in ByteArrays + +FIx benchmarks in persistent-merkle-tree + +Simplify LeafNode constructor + +Refactor subtreeFillToContents + +Run struct <-> tree_backed benchmarks + +Update test types + +Fix Uint64 DataView benchmarks + +Add benchmarks for full state serialization + +Use consistent initialization in DataView + +Optimize toView for ByteArray + +Add clone method for safer ContainerTreeViewDU + +Add documentation to all public methods + +Update SSZ README + +Simplify testTypes + +Update persistent-merkle-tree README + +Add unit test push x5 + +Fix heigh typo + +Add note Supports index up to Number.MAX_SAFE_INTEGER. + +Address PR comments + + + + + +# [0.2.0](https://github.com/chainsafe/simpleserialize.com/compare/simpleserialize.com@0.1.0...simpleserialize.com@0.2.0) (2022-05-18) + + +* SSZ v2 (#223) ([9d167b7](https://github.com/chainsafe/simpleserialize.com/commit/9d167b703b1e974ee4943be15710aa9783183986)), closes [#223](https://github.com/chainsafe/simpleserialize.com/issues/223) [#227](https://github.com/chainsafe/simpleserialize.com/issues/227) + + +### BREAKING CHANGES + +* complete refactor, see packages/ssz/README.md for details + +Initial squashed v2 commit + +Replace lodestarTypes + +Update tests + +Add Union and None types + +Update spec tests + +Remove old src and lodestar dependencies + +Improve JSON parsing for tests + +Load YAML with lodestar utils schema + +Commit ArrayComposite before getAll + +Re-write toJson fromJson test + +Fix uint json conversions + +Print tree in valid test if requested + +Fix hashTreeRoot for ByteList + +Add RENDER_ROOTS option + +Fix typos + +Use numerical sort in array commit + +Fix value_serializedSizeArrayComposite + +Pass ssz_generic tests + +Allow to select tests to run in ssz_static + +Fix container bytes offset + +Rename fixedLen to fixedSize + +Sort deserailization methods + +Print json stringified in test + +Review logic + +Clean up tests + +Define JSON casing at constructor time only + +Add casing maps for merge types + +Update casing in unit tests + +Re-organize utils + +Fix merge casing + +FIx offset calculation + +Pass all spec test pre-merge + +Bump merge test + +Extend timeout for mainnet tests + +Pass all unit tests + +Return defaultValue in simpleserialize random + +Remove @chainsafe/lodestar-spec-test-util dependency + +Copy yaml schema from lodestar-utils + +Fix benchmark type issues + +Skip createProof benchmark + +Skip old benchmark without runner + +Remove postinstall script + +Re-add UintBigint optimization + +Fix set_exitEpoch_and_hashTreeRoot benchmark + +Add List of Number benchmark + +Use DataViews for faster deserialization + +Use DataViews for tree serialization too + +Update workflows build after install + +Update packedNode tests + +Review Tree API + +Validate length in ByteArrays + +FIx benchmarks in persistent-merkle-tree + +Simplify LeafNode constructor + +Refactor subtreeFillToContents + +Run struct <-> tree_backed benchmarks + +Update test types + +Fix Uint64 DataView benchmarks + +Add benchmarks for full state serialization + +Use consistent initialization in DataView + +Optimize toView for ByteArray + +Add clone method for safer ContainerTreeViewDU + +Add documentation to all public methods + +Update SSZ README + +Simplify testTypes + +Update persistent-merkle-tree README + +Add unit test push x5 + +Fix heigh typo + +Add note Supports index up to Number.MAX_SAFE_INTEGER. + +Address PR comments + + + + + +## [0.1.1](https://github.com/chainsafe/simpleserialize.com/compare/simpleserialize.com@0.1.0...simpleserialize.com@0.1.1) (2021-10-12) + +**Note:** Version bump only for package simpleserialize.com diff --git a/README.md b/README.md index 96bc357..31fa675 100644 --- a/README.md +++ b/README.md @@ -1,4 +1 @@ -This package is now maintained at https://github.com/ChainSafe/ssz/tree/master/packages/simpleserialize.com ---- - -![ETH2_Spec_Version v1.1.0-alpha.7](https://img.shields.io/badge/ETH2_Spec_Version-v1.1.0.alpha.7-2e86c1.svg) +[![Eth Consensus Spec v1.5.0](https://img.shields.io/badge/ETH%20consensus--spec-1.5.0-blue)](https://github.com/ethereum/consensus-specs/releases/tag/v1.5.0) \ No newline at end of file diff --git a/biome.jsonc b/biome.jsonc new file mode 100644 index 0000000..8044c29 --- /dev/null +++ b/biome.jsonc @@ -0,0 +1,67 @@ +{ + "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", + "vcs": { + "defaultBranch": "master" + }, + "extends": ["@chainsafe/biomejs-config", "@chainsafe/biomejs-config/recommended", "@chainsafe/biomejs-config/esm"], + "files": { + "include": ["src/**/*.tsx"] + }, + "linter": { + "rules": { + "suspicious": { + "noConsoleLog": "off" + }, + "style": { + // Our team does not like this syntax + // https://github.com/ChainSafe/ssz/pull/475#discussion_r1995814916 + "useNumberNamespace": "off", + // TODO: There are two many usages, will fix in separate PR + "noParameterAssign": "off", + // We use to export types and object without differentiating + "useExportType": "off", + // We use to import types and object without differentiating + "useImportType": "off", + // We have a lot of enum members in camelCase, so we have to update + // the base naming convention to allow camelCase in addition to PascalCase + "useNamingConvention": { + "level": "error", + "options": { + "requireAscii": true, + "strictCase": false, + "conventions": [ + { + "selector": { + "kind": "enumMember" + }, + "formats": ["camelCase", "PascalCase"] + } + ] + } + } + } + } + }, + "overrides": [ + { + "include": ["src/**/*.tsx"], + "linter": { + "rules": { + // Disable all accessibility rules for React files + "a11y": { + "useValidAnchor": "off", + "noLabelWithoutControl": "off", + "useButtonType": "off", + "useKeyWithClickEvents": "off", + "useAnchorContent": "off", + "useAltText": "off" + } + } + }, + // Add JSX support for React files + "javascript": { + "globals": ["JSX"] + } + } + ] +} diff --git a/package.json b/package.json index 64e0b07..474a3d5 100644 --- a/package.json +++ b/package.json @@ -1,72 +1,73 @@ { - "private": true, - "name": "simpleserialize.com", - "version": "0.1.0", - "repository": "https://github.com/chainsafe/simpleserialize.com", - "author": "Chainsafe Systems", - "license": "MIT", - "scripts": { - "check-types": "tsc", - "dev": "cross-env NODE_ENV=development webpack serve --color --progress", - "build": "cross-env NODE_ENV=production webpack --color --progress", - "start": "serve dist", - "lint": "eslint --ext .tsx src/", - "lint:fix": "eslint --ext .tsx src/ --fix" - }, - "dependencies": { - "@babel/runtime": "^7.14.6", - "@babel/types": "^7.14.5", - "@chainsafe/lodestar-types": "^0.26.0", - "@chainsafe/ssz": "^0.8.11", - "bn.js": "^5.2.0", - "bulma": "^0.9.3", - "core-js": "^3.15.2", - "eyzy-tree": "^0.2.2", - "file-saver": "^2.0.5", - "js-yaml": "^4.1.0", - "react": "^17.0.2", - "react-alert": "^7.0.1", - "react-alert-template-basic": "^1.0.0", - "react-dom": "^17.0.2", - "react-loading-overlay": "^1.0.1", - "react-spinners": "^0.8.3", - "threads": "^1.6.5" - }, - "devDependencies": { - "@babel/core": "^7.14.6", - "@babel/preset-env": "^7.14.7", - "@babel/preset-react": "^7.14.5", - "@babel/preset-typescript": "^7.14.5", - "@types/bn.js": "^5.1.0", - "@types/deep-equal": "^1.0.1", - "@types/file-saver": "^2.0.2", - "@types/node": "^16.0.0", - "@types/react": "^17.0.13", - "@types/react-alert": "^5.2.1", - "@types/react-dom": "^17.0.8", - "@types/react-loading-overlay": "^1.0.0", - "@typescript-eslint/eslint-plugin": "^4.28.2", - "@typescript-eslint/parser": "^4.28.2", - "babel-loader": "^8.2.2", - "babel-preset-env": "^1.7.0", - "buffer": "^6.0.3", - "cross-env": "^7.0.3", - "css-loader": "^5.2.6", - "eslint": "^7.30.0", - "eslint-plugin-import": "^2.23.4", - "eslint-plugin-react": "^7.20.0", - "html-webpack-plugin": "^5.3.2", - "mini-css-extract-plugin": "^2.1.0", - "node-sass": "^6.0.1", - "process": "^0.11.10", - "sass-loader": "^12.1.0", - "serve": "^12.0.0", - "style-loader": "^3.0.0", - "threads-webpack-plugin": "^1.0.8", - "typescript": "^4.3.5", - "webpack": "^5.43.0", - "webpack-cli": "^4.7.2", - "webpack-dev-server": "^3.11.2", - "workerize-loader": "^1.3.0" - } + "private": true, + "name": "simpleserialize.com", + "version": "0.3.2", + "repository": "https://github.com/chainsafe/simpleserialize.com", + "author": "Chainsafe Systems", + "license": "MIT", + "scripts": { + "clean": "rm -rf ./dist", + "check-types": "tsc", + "dev": "cross-env NODE_ENV=development webpack serve --color --progress", + "build": "cross-env NODE_ENV=production webpack --color --progress", + "start": "serve dist", + "lint": "biome check", + "lint:fix": "biome check --write" + }, + "dependencies": { + "@babel/runtime": "^7.14.6", + "@babel/types": "^7.14.5", + "@chainsafe/ssz": "1.2.1", + "@lodestar/types": "^1.29.0", + "bn.js": "^5.2.0", + "bulma": "^0.9.3", + "core-js": "^3.15.2", + "eyzy-tree": "^0.2.2", + "file-saver": "^2.0.5", + "js-yaml": "^4.1.0", + "react": "^17.0.2", + "react-alert": "^7.0.1", + "react-alert-template-basic": "^1.0.0", + "react-dom": "^17.0.2", + "react-loading-overlay": "^1.0.1", + "react-spinners": "^0.8.3", + "threads": "^1.6.5" + }, + "devDependencies": { + "@babel/cli": "^7.14.6", + "@babel/core": "^7.14.6", + "@babel/preset-env": "^7.14.7", + "@babel/preset-react": "^7.14.5", + "@babel/preset-typescript": "^7.14.5", + "@babel/register": "^7.15.3", + "@biomejs/biome": "^1.9.4", + "@chainsafe/biomejs-config": "^0.1.0", + "@types/bn.js": "^5.1.0", + "@types/deep-equal": "^1.0.1", + "@types/file-saver": "^2.0.2", + "@types/node": "^22.10.2", + "@types/react": "^17.0.35", + "@types/react-alert": "^5.2.1", + "@types/react-dom": "^17.0.25", + "@types/react-loading-overlay": "^1.0.0", + "babel-loader": "^8.2.2", + "buffer": "^6.0.3", + "cross-env": "^7.0.3", + "css-loader": "^5.2.6", + "html-webpack-plugin": "^5.3.2", + "mini-css-extract-plugin": "^2.1.0", + "process": "^0.11.10", + "sass": "^1.72.0", + "sass-loader": "^14.1.1", + "serve": "^12.0.0", + "style-loader": "^3.0.0", + "ts-loader": "^9.5.1", + "ts-node": "^10.9.2", + "typescript": "~5.8.3", + "threads-webpack-plugin": "^1.0.8", + "webpack": "^5.75.0", + "webpack-cli": "^5.0.1", + "webpack-dev-server": "^5.2.0", + "workerize-loader": "^1.3.0" + } } diff --git a/simpleserialize.Dockerfile b/simpleserialize.Dockerfile new file mode 100644 index 0000000..2395e41 --- /dev/null +++ b/simpleserialize.Dockerfile @@ -0,0 +1,17 @@ +FROM node:lts as build + +WORKDIR /usr/src/app +COPY package.json yarn.lock src .yarnrc.yml ./ + + +RUN corepack enable +RUN yarn install --immutable + +COPY . . +RUN npm rebuild node-sass +RUN cd ./ && yarn build + + +FROM nginx:alpine +COPY --from=build /usr/src/app/dist /usr/share/nginx/html +EXPOSE 80 diff --git a/src/App.tsx b/src/App.tsx index 444b156..c38ca31 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,9 +1,9 @@ import React from "react"; +import Footer from "./components/Footer"; import ForkMe from "./components/ForkMe"; import Header from "./components/Header"; import Tabs from "./components/Tabs"; -import Footer from "./components/Footer"; export default function App(): JSX.Element { return ( diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index a19ac4d..b173f2e 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -4,31 +4,30 @@ import pkg from "../../package.json"; export default function Footer(): JSX.Element { return ( -