Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: package_updates + dark_mode #424

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion packages/as-sha256/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"devDependencies": {
"@chainsafe/babel-plugin-inline-binary-import": "^1.0.3",
"assemblyscript": "^0.27.24",
"assemblyscript": "^0.27.31",
"benchmark": "^2.1.4"
}
}
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
"dependencies": {
"@chainsafe/as-sha256": "0.5.0",
"@chainsafe/hashtree": "1.0.1",
"@noble/hashes": "^1.3.0"
"@noble/hashes": "^1.6.1"
}
}
2 changes: 1 addition & 1 deletion packages/persistent-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"homepage": "https://github.com/cronokirby/persistent-ts#readme",
"devDependencies": {
"fast-check": "^1.15.1"
"fast-check": "^3.23.1"
},
"jest": {
"transform": {
Expand Down
58 changes: 29 additions & 29 deletions packages/simpleserialize.com/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,44 @@
"lint:fix": "eslint --ext .tsx src/ --fix"
},
"dependencies": {
"@babel/runtime": "^7.14.6",
"@babel/types": "^7.14.5",
"@chainsafe/ssz": "0.16.0",
"@lodestar/types": "^1.23.0",
"bn.js": "^5.2.0",
"bulma": "^0.9.3",
"core-js": "^3.15.2",
"@babel/runtime": "^7.26.0",
"@babel/types": "^7.26.0",
"@chainsafe/ssz": "0.18.0",
"@lodestar/types": "^1.23.1",
"bn.js": "^5.2.1",
"bulma": "^1.0.2",
"core-js": "^3.39.0",
"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": "^18.3.1",
"react-alert": "^7.0.3",
"react-alert-template-basic": "^1.0.2",
"react-dom": "^18.3.1",
"react-loading-overlay": "^1.0.1",
"react-spinners": "^0.8.3",
"threads": "^1.6.5"
"react-spinners": "^0.14.1",
"threads": "^1.7.0"
},
"devDependencies": {
"@types/bn.js": "^5.1.0",
"@types/deep-equal": "^1.0.1",
"@types/file-saver": "^2.0.2",
"@types/react": "^17.0.35",
"@types/react-alert": "^5.2.1",
"@types/react-dom": "^17.0.8",
"@types/react-loading-overlay": "^1.0.0",
"@types/bn.js": "^5.1.6",
"@types/deep-equal": "^1.0.4",
"@types/file-saver": "^2.0.7",
"@types/react": "^18.3.12",
"@types/react-alert": "^7.0.6",
"@types/react-dom": "^18.3.1",
"@types/react-loading-overlay": "^1.0.4",
"buffer": "^6.0.3",
"cross-env": "^7.0.3",
"css-loader": "^5.2.6",
"eslint-plugin-react": "^7.20.0",
"html-webpack-plugin": "^5.3.2",
"mini-css-extract-plugin": "^2.1.0",
"css-loader": "^7.1.2",
"eslint-plugin-react": "^7.37.2",
"html-webpack-plugin": "^5.6.3",
"mini-css-extract-plugin": "^2.9.2",
"process": "^0.11.10",
"sass": "^1.72.0",
"sass-loader": "^14.1.1",
"serve": "^12.0.0",
"style-loader": "^3.0.0",
"sass": "^1.81.0",
"sass-loader": "^16.0.3",
"serve": "^14.2.4",
"style-loader": "^4.0.0",
"threads-webpack-plugin": "^1.0.8",
"workerize-loader": "^1.3.0"
"workerize-loader": "^2.0.2"
}
}
17 changes: 14 additions & 3 deletions packages/simpleserialize.com/src/components/ForkMe.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import * as React from "react";
import DarkMode from "../util/darkMode";

export default function ForkMe(): JSX.Element {
return (
<a
<div style={{
position: "absolute",
right: 0,
top: 0,
display: "flex",
gap: "10px", // Add spacing between elements
}}>
<div style={{ marginTop: "8px", marginRight: "-10px" }}>
<DarkMode/>
</div>
<a
href="https://github.com/ChainSafe/ssz/tree/master/packages/simpleserialize.com"
style={{position: "absolute", right: 0, top: 0}}
>
<img
width="149"
Expand All @@ -14,6 +24,7 @@ export default function ForkMe(): JSX.Element {
alt="Fork me on GitHub"
data-recalc-dims="1"
/>
</a>
</a>
</div>
);
}
2 changes: 1 addition & 1 deletion packages/simpleserialize.com/src/styles.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@charset "utf-8";
@import "~bulma/bulma";
@use "~bulma/bulma";

.serialize-section textarea,
.serialize-section .submit {
Expand Down
60 changes: 60 additions & 0 deletions packages/simpleserialize.com/src/util/darkMode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React, { useState, useEffect } from "react";

const setDark = () => {
document.documentElement.setAttribute("data-theme", "dark");
};

const setLight = () => {
document.documentElement.setAttribute("data-theme", "light");
};

const prefersDark =
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches;

const DarkMode = () => {
const [darkMode, setDarkMode] = useState(prefersDark);

useEffect(() => {
if (darkMode) {
setDark();
} else {
setLight();
}
}, [darkMode]);

const toggleTheme = (isDarkMode: boolean) => {
setDarkMode(isDarkMode);
};

return (
<div className="toggle-theme-wrapper">
{darkMode ? (
<span onClick={() => toggleTheme(false)} style={{ cursor: "pointer" }}>
<svg fill="white" viewBox="0 0 24 24" height="20px" width="20px">
<path
fill="white"
fillRule="evenodd"
d="M12 16a4 4 0 100-8 4 4 0 000 8zm0 2a6 6 0 100-12 6 6 0 000 12zM11 0h2v4.062a8.079 8.079 0 00-2 0V0zM7.094 5.68L4.222 2.808 2.808 4.222 5.68 7.094A8.048 8.048 0 017.094 5.68zM4.062 11H0v2h4.062a8.079 8.079 0 010-2zm1.618 5.906l-2.872 2.872 1.414 1.414 2.872-2.872a8.048 8.048 0 01-1.414-1.414zM11 19.938V24h2v-4.062a8.069 8.069 0 01-2 0zm5.906-1.618l2.872 2.872 1.414-1.414-2.872-2.872a8.048 8.048 0 01-1.414 1.414zM19.938 13H24v-2h-4.062a8.069 8.069 0 010 2zM18.32 7.094l2.872-2.872-1.414-1.414-2.872 2.872c.528.41 1.003.886 1.414 1.414z"
clipRule="evenodd"
/>
</svg>
</span>
) : (
<span onClick={() => toggleTheme(true)} style={{ cursor: "pointer" }}>
<svg viewBox="0 0 21 21" fill="black" height="20px" width="20px">
<path
fill="black"
stroke="black"
strokeLinecap="round"
strokeLinejoin="round"
d="M11.5 3.5c1.328 0 2.57.37 3.628 1.012a6 6 0 00-.001 11.977A7 7 0 1111.5 3.5z"
/>
</svg>
</span>
)}
</div>
);
};

export default DarkMode;
6 changes: 3 additions & 3 deletions packages/ssz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"@chainsafe/persistent-merkle-tree": "0.8.0"
},
"devDependencies": {
"@types/js-yaml": "^4.0.5",
"js-yaml": "^3.13.1",
"snappyjs": "^0.6.1"
"@types/js-yaml": "^4.0.9",
"js-yaml": "^4.1.0",
"snappyjs": "^0.7.0"
},
"keywords": [
"ethereum",
Expand Down
4 changes: 2 additions & 2 deletions packages/ssz/src/type/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ export function precomputeJsonKey<Fields extends Record<string, Type<unknown>>>(
if (casingMap) {
const keyFromCaseMap = casingMap[fieldName];
if (keyFromCaseMap === undefined) {
throw Error(`casingMap[${fieldName}] not defined`);
throw Error(`casingMap[${String(fieldName)}] not defined`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this required? fieldName should be type string

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nflaig when I ran the build command this error was showing up "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'. " to overcome this I applied typecasting

}
return keyFromCaseMap as string;
} else if (jsonCase) {
Expand All @@ -569,6 +569,6 @@ export function renderContainerTypeName<Fields extends Record<string, Type<unkno
prefix = "Container"
): string {
const fieldNames = Object.keys(fields) as (keyof Fields)[];
const fieldTypeNames = fieldNames.map((fieldName) => `${fieldName}: ${fields[fieldName].typeName}`).join(", ");
const fieldTypeNames = fieldNames.map((fieldName) => `${String(fieldName)}: ${fields[fieldName].typeName}`).join(", ");
return `${prefix}({${fieldTypeNames}})`;
}
2 changes: 1 addition & 1 deletion packages/ssz/src/type/containerNodeStruct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class ContainerNodeStructType<Fields extends Record<string, Type<unknown>
// because the ListBasicViewDU in view.a will never propagate the changes upwards to its ContainerNodeStructType.
for (const {fieldName, fieldType} of this.fieldsEntries) {
if (isCompositeType(fieldType) && fieldType.isViewMutable) {
throw Error(`ContainerNodeStructType field '${fieldName}' ${fieldType.typeName} view is mutable`);
throw Error(`ContainerNodeStructType field '${String(fieldName)}' ${fieldType.typeName} view is mutable`);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/ssz/src/type/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ export function precomputeJsonKey<Fields extends Record<string, Type<unknown>>>(
if (casingMap) {
const keyFromCaseMap = casingMap[fieldName];
if (keyFromCaseMap === undefined) {
throw Error(`casingMap[${fieldName}] not defined`);
throw Error(`casingMap[${String(fieldName)}] not defined`);
}
return keyFromCaseMap as string;
} else if (jsonCase) {
Expand All @@ -665,6 +665,6 @@ export function renderContainerTypeName<Fields extends Record<string, Type<unkno
prefix = "Profile"
): string {
const fieldNames = Object.keys(fields) as (keyof Fields)[];
const fieldTypeNames = fieldNames.map((fieldName) => `${fieldName}: ${fields[fieldName].typeName}`).join(", ");
const fieldTypeNames = fieldNames.map((fieldName) => `${String(fieldName)}: ${fields[fieldName].typeName}`).join(", ");
return `${prefix}({${fieldTypeNames}})`;
}
4 changes: 2 additions & 2 deletions packages/ssz/src/type/stableContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ export function precomputeJsonKey<Fields extends Record<string, Type<unknown>>>(
if (casingMap) {
const keyFromCaseMap = casingMap[fieldName];
if (keyFromCaseMap === undefined) {
throw Error(`casingMap[${fieldName}] not defined`);
throw Error(`casingMap[${String(fieldName)}] not defined`);
}
return keyFromCaseMap as string;
} else if (jsonCase) {
Expand All @@ -728,7 +728,7 @@ export function renderContainerTypeName<Fields extends Record<string, Type<unkno
prefix = "StableContainer"
): string {
const fieldNames = Object.keys(fields) as (keyof Fields)[];
const fieldTypeNames = fieldNames.map((fieldName) => `${fieldName}: ${fields[fieldName].typeName}`).join(", ");
const fieldTypeNames = fieldNames.map((fieldName) => `${String(fieldName)}: ${fields[fieldName].typeName}`).join(", ");
return `${prefix}({${fieldTypeNames}})`;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ssz/src/view/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function getContainerTreeViewClass<Fields extends Record<string, Type<unk
// Should never happen
else {
/* istanbul ignore next - unreachable code */
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${fieldName}`);
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${String(fieldName)}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ssz/src/view/containerNodeStruct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function getContainerTreeViewClass<Fields extends Record<string, Type<unk
// Should never happen
else {
/* istanbul ignore next - unreachable code */
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${fieldName}`);
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${String(fieldName)}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ssz/src/view/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export function getProfileTreeViewClass<Fields extends Record<string, Type<unkno
// Should never happen
else {
/* istanbul ignore next - unreachable code */
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${fieldName}`);
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${String(fieldName)}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ssz/src/view/stableContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export function getContainerTreeViewClass<Fields extends Record<string, Type<unk
// Should never happen
else {
/* istanbul ignore next - unreachable code */
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${fieldName}`);
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${String(fieldName)}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ssz/src/viewDU/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export function getContainerTreeViewDUClass<Fields extends Record<string, Type<u
// Should never happen
else {
/* istanbul ignore next - unreachable code */
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${fieldName}`);
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${String(fieldName)}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ssz/src/viewDU/containerNodeStruct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function getContainerTreeViewDUClass<Fields extends Record<string, Type<u
// Should never happen
else {
/* istanbul ignore next - unreachable code */
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${fieldName}`);
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${String(fieldName)}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ssz/src/viewDU/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export function getProfileTreeViewDUClass<Fields extends Record<string, Type<unk
// Should never happen
else {
/* istanbul ignore next - unreachable code */
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${fieldName}`);
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${String(fieldName)}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ssz/src/viewDU/stableContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export function getContainerTreeViewDUClass<Fields extends Record<string, Type<u
// Should never happen
else {
/* istanbul ignore next - unreachable code */
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${fieldName}`);
throw Error(`Unknown fieldType ${fieldType.typeName} for fieldName ${String(fieldName)}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es2019",
"target": "es2022",
"module": "commonjs",
"pretty": true,
"lib": [
Expand Down
Loading
Loading