Socket
Socket
Sign inDemoInstall

@chainsafe/ssz

Package Overview
Dependencies
Maintainers
6
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chainsafe/ssz - npm Package Compare versions

Comparing version 0.8.17 to 0.8.18

250

CHANGELOG.md

@@ -1,8 +0,252 @@

# Changelog
## 0.8.18 (2021-09-25)
## [v0.8.17](https://github.com/ChainSafe/ssz/tree/v0.8.17) (2021-08-30)
## Features
[Full Changelog](https://github.com/ChainSafe/ssz/compare/v0.8.15...v0.8.17)
- Ability to specify casingMap declaration time for Container's toJson/fromJson [#198](https://github.com/ChainSafe/ssz/pull/198)
- Extending case matching in Container's toJson/fromJson with a range of case types [#184](https://github.com/ChainSafe/ssz/pull/184)
- Ability to provide casingMap in toJson/fromJson interface for aiding case matching [#184](https://github.com/ChainSafe/ssz/pull/184)
## 0.8.17 (2021-08-30)
## Bug fixes
- Fix ContainerLeafNodeStructTreeValue [#179](https://github.com/ChainSafe/ssz/pull/179)
## 0.8.16 (2021-08-30)
## Features
- Implement Number64UintType and Number64ListType [#159](https://github.com/ChainSafe/ssz/pull/159)
- Add ContainerLeafNodeStructType for memory efficiency [#168](https://github.com/ChainSafe/ssz/pull/168)
- Union type [#145](https://github.com/ChainSafe/ssz/pull/145)
- Add alternative to iterator interface [#171](https://github.com/ChainSafe/ssz/pull/171)
## 0.8.15 (2021-08-23)
## Features
- Avoid iterateNodesAtDepth [#167](https://github.com/ChainSafe/ssz/pull/167)
## 0.8.14 (2021-08-19)
## Features
- Add getFixedSerializedLength() [#148](https://github.com/ChainSafe/ssz/pull/148)
- Cache field information for Container type [#146](https://github.com/ChainSafe/ssz/pull/146)
- Use persistent-merkle-tree 0.3.5 and as-sha256 0.2.4 [#165](https://github.com/ChainSafe/ssz/pull/165)
## 0.8.13 (2021-08-04)
## Features
- Use utility function for bigint exponentiation ([c2d3a7](https://github.com/chainsafe/ssz/commit/c2d3a7))
## 0.8.12 (2021-07-30)
## Features
- Use utility function for bigint exponentiation ([fbb671](https://github.com/chainsafe/ssz/commit/fbb671))
## 0.8.11 (2021-06-18)
## Chores
- Update persistent-merkle-tree ([f88f15](https://github.com/chainsafe/ssz/commit/f88f15))
## 0.8.10 (2021-06-16)
## Features
- Add fast struct_equals impl for RootType ([a3f4b4](https://github.com/chainsafe/ssz/commit/a3f4b4))
## 0.8.9 (2021-06-11)
## Bug Fixes
- Fix tree_serializeToBytes offset in BitList ([7cd2c1](https://github.com/chainsafe/ssz/commit/7cd2c1))
## 0.8.8 (2021-06-10)
## Bug Fixes
- Fix tree serialize/deserialize in BitList ([ee47a0](https://github.com/chainsafe/ssz/commit/ee47a0))
- Fix struct_getRootAtChunkIndex for BitVectorType ([ee47a0](https://github.com/chainsafe/ssz/commit/ee47a0))
## 0.8.7 (2021-06-01)
## Bug Fixes
- Fix BitVector tree_deserializeFromBytes() ([fd2c7d](https://github.com/chainsafe/ssz/commit/fd2c7d))
## 0.8.6 (2021-05-25)
## Bug Fixes
- Fix basic vector struct_convertFromJson ([05e7c2](https://github.com/chainsafe/ssz/commit/05e7c2))
## 0.8.5 (2021-05-19)
## Features
- Add composite type leaves to proof ([3f1cfd](https://github.com/chainsafe/ssz/commit/3f1cfd))
## 0.8.4 (2021-05-07)
## Bug Fixes
- Update as-sha256 ([8d497b](https://github.com/chainsafe/ssz/commit/8d497b))
## 0.8.3 (2021-05-04)
## Features
- Improve hexToString performance ([106991](https://github.com/chainsafe/ssz/commit/106991))
## Chores
- Update as-sha256 & persistent-merkle-tree ([212927](https://github.com/chainsafe/ssz/commit/212927))
- Use for of instead of forEach ([e195df](https://github.com/chainsafe/ssz/commit/e195df))
- Add whitespace ([516421](https://github.com/chainsafe/ssz/commit/516421))
## 0.8.2 (2021-04-05)
## Features
- Add tree_createFromProof ([b804f4](https://github.com/chainsafe/ssz/commit/b804f4))
## 0.8.1 (2021-04-02)
## Bug Fixes
- Fix bit array struct->tree ([8b08ea](https://github.com/chainsafe/ssz/commit/8b08ea))
## Features
- Improve convertToTree ([776b63](https://github.com/chainsafe/ssz/commit/776b63))
## 0.8.0 (2021-03-29)
## BREAKING CHANGES
- Refactor codebase ([c86871](https://github.com/chainsafe/ssz/commit/c86871))
## 0.7.1 (2021-03-29)
## Bug Fixes
- Bug fix in @chainsafe/persistent-merkle-tree ([d31f82](https://github.com/chainsafe/ssz/commit/d31f82))
## 0.7.0 (2021-03-01)
## BREAKING CHANGES
- Use abstract class Type/BasicType/CompositeType ([c91b19](https://github.com/chainsafe/ssz/commit/c91b19))
- Remove TreeBacked<T>#gindexOfProperty ([d4b141](https://github.com/chainsafe/ssz/commit/d4b141))
## Features
- Optimize byte array equals ([7639b2](https://github.com/chainsafe/ssz/commit/7639b2))
- Restrict the use of BigInt whenever possible ([22e8c4](https://github.com/chainsafe/ssz/commit/22e8c4))
- Initial multiproof support ([9e758a](https://github.com/chainsafe/ssz/commit/9e758a))
## 0.6.13 (2020-08-05)
## Bug Fixes
- Add length check to array structural equality ([c7782a](https://github.com/chainsafe/ssz/commit/c7782a))
## 0.6.12 (2020-08-05)
## Features
- Add readOnlyEntries ([211e6d](https://github.com/chainsafe/ssz/commit/211e6d))
## 0.6.11 (2020-08-01)
## Features
- Optimize fromStructural ([ff388a](https://github.com/chainsafe/ssz/commit/ff388a))
## 0.6.10 (2020-07-27)
## Features
- Add readOnlyForEach and readOnlyMap functions ([356d70](https://github.com/chainsafe/ssz/commit/356d70))
## Chores
- Use readonly tree iteration in tree-backed toBytes ([356d70](https://github.com/chainsafe/ssz/commit/356d70))
## 0.6.9 (2020-07-09)
### Bug Fixes
- Fix bitlist/bitvector validation ([030784](https://github.com/chainsafe/ssz/commit/030784))
## 0.6.8 (2020-07-09)
### Features
- Track error JSON path location with try / catch ([4ff92d](https://github.com/chainsafe/ssz/commit/4ff92d))
- Add validation for fromBytes ([64b757](https://github.com/chainsafe/ssz/commit/64b757))
### Chores
- Add prettier as an eslint plugin ([c606a0](https://github.com/chainsafe/ssz/commit/c606a0))
- Add es and node badges ([b25c39](https://github.com/chainsafe/ssz/commit/b25c39))
- Standardize uint toJson ([4dbc6f](https://github.com/chainsafe/ssz/commit/4dbc6f))
### Bug Fixes
- Fix structural bitlist/bitvector hashtreeroot ([5ed8e0](https://github.com/chainsafe/ssz/commit/5ed8e0))
- Fix start param validation case ([5fd207](https://github.com/chainsafe/ssz/commit/5fd207))
## 0.6.7 (2020-06-08)
### Features
- Implement minSize and mazSize api ([fb14bd](https://github.com/chainsafe/ssz/commit/fb14bd))
### Chores
- Don't use BigInt in NumberUintType ([7abe06](https://github.com/chainsafe/ssz/commit/7abe06))
## 0.6.6 (2020-06-07)
### Chores
- Update persistent-merkle-tree dependency ([b54ea0](https://github.com/chainsafe/ssz/commit/b54ea0))
## 0.6.5 (2020-06-01)
### Bug Fixes
- Fix Infinity serialization to/fromJson ([9a68c3](https://github.com/chainsafe/ssz/commit/9a68c3))
## 0.6.4 (2020-05-04)
### Features
- Add ObjBacked wrapper type ([1cf4ac](https://github.com/chainsafe/ssz/commit/1cf4ac))
## 0.6.3 (2020-04-30)
### Features
- Add isFooType functions ([a577e3](https://github.com/chainsafe/ssz/commit/a577e3))
- Add json case option ([0f8566](https://github.com/chainsafe/ssz/commit/0f8566))
### Bug Fixes
- Fix far future deserialization ([63d6cd](https://github.com/chainsafe/ssz/commit/63d6cd))
## 0.6.2 (2020-04-20)
### Chores
- Update persistent-merkle-tree dependency ([e05265](https://github.com/chainsafe/ssz/commit/e05265))
### Bug Fixes
- Fix composite vector defaultValue ([facf47](https://github.com/chainsafe/ssz/commit/facf47))

24

lib/backings/tree/treeValue.js

@@ -8,3 +8,3 @@ "use strict";

function isTreeBacked(value) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
return value && value.type && value.tree && tree_1.isTree(value.tree);

@@ -95,4 +95,2 @@ }

class TreeValue {
type;
tree;
constructor(type, tree) {

@@ -103,2 +101,3 @@ this.type = type;

clone() {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const TreeValueClass = Object.getPrototypeOf(this).constructor;

@@ -147,3 +146,2 @@ return proxyWrapTreeValue(new TreeValueClass(this.type, this.tree.clone()));

class BasicArrayTreeValue extends TreeValue {
type;
constructor(type, tree) {

@@ -220,3 +218,2 @@ super(type, tree);

class CompositeArrayTreeValue extends TreeValue {
type;
constructor(type, tree) {

@@ -233,5 +230,3 @@ super(type, tree);

setProperty(property, value) {
return this.type.tree_setProperty(this.tree, property, isTreeBacked(value)
? value.tree
: this.type.elementType.struct_convertToTree(value));
return this.type.tree_setProperty(this.tree, property, isTreeBacked(value) ? value.tree : this.type.elementType.struct_convertToTree(value));
}

@@ -313,3 +308,2 @@ *keys() {

class BasicListTreeValue extends BasicArrayTreeValue {
type;
constructor(type, tree) {

@@ -328,3 +322,2 @@ super(type, tree);

class CompositeListTreeValue extends CompositeArrayTreeValue {
type;
constructor(type, tree) {

@@ -335,5 +328,3 @@ super(type, tree);

push(...values) {
const convertedValues = values.map((value) => isTreeBacked(value)
? value.tree
: this.type.elementType.struct_convertToTree(value));
const convertedValues = values.map((value) => isTreeBacked(value) ? value.tree : this.type.elementType.struct_convertToTree(value));
return this.type.tree_push(this.tree, ...convertedValues);

@@ -347,3 +338,2 @@ }

class ContainerTreeValue extends TreeValue {
type;
constructor(type, tree) {

@@ -487,3 +477,2 @@ super(type, tree);

class ContainerLeafNodeStructTreeValue extends TreeValue {
type;
constructor(type, tree) {

@@ -517,6 +506,6 @@ super(type, tree);

*readonlyValues() {
return yield* this.values();
yield* this.values();
}
*readonlyEntries() {
return yield* this.entries();
yield* this.entries();
}

@@ -543,3 +532,2 @@ keysArray() {

class UnionTreeValue extends TreeValue {
type;
constructor(type, tree) {

@@ -546,0 +534,0 @@ super(type, tree);

@@ -14,4 +14,2 @@ "use strict";

class UintType extends abstract_1.BasicType {
byteLength;
infinityWhenBig;
constructor(options) {

@@ -40,3 +38,2 @@ super();

class NumberUintType extends UintType {
_maxBigInt;
constructor(options) {

@@ -43,0 +40,0 @@ super(options);

@@ -19,4 +19,2 @@ "use strict";

class CompositeType extends type_1.Type {
_chunkDepth;
_defaultNode;
constructor() {

@@ -23,0 +21,0 @@ super();

@@ -10,3 +10,2 @@ "use strict";

class BasicArrayType extends abstract_1.CompositeType {
elementType;
constructor(options) {

@@ -256,3 +255,2 @@ super();

class CompositeArrayType extends abstract_1.CompositeType {
elementType;
constructor(options) {

@@ -259,0 +257,0 @@ super();

@@ -7,2 +7,3 @@ import { Json, ObjectLike } from "../../interface";

fields: Record<string, Type<any>>;
casingMap?: Record<string, string>;
}

@@ -18,2 +19,3 @@ export declare const CONTAINER_TYPE: unique symbol;

fields: Record<string, Type<any>>;
casingMap?: Record<string, string>;
/**

@@ -20,0 +22,0 @@ * This caches FieldInfo by field name so that we don't have to query this same data in a lot of apis.

@@ -18,14 +18,6 @@ "use strict";

class ContainerType extends abstract_1.CompositeType {
// ES6 ensures key order is chronological
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fields;
/**
* This caches FieldInfo by field name so that we don't have to query this same data in a lot of apis.
* This helps speed up 30% with a simple test of increasing state.slot from 0 to 1_000_000 as shown in the
* performance test of uint.test.ts.
**/
fieldInfos;
constructor(options) {
super();
this.fields = { ...options.fields };
this.casingMap = options.casingMap;
this._typeSymbols.add(exports.CONTAINER_TYPE);

@@ -94,2 +86,3 @@ this.fieldInfos = new Map();

try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
fieldType.struct_assertValidValue(value[fieldName]);

@@ -112,2 +105,3 @@ }

for (const [fieldName, fieldType] of Object.entries(this.fields)) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
newValue[fieldName] = fieldType.struct_clone(value[fieldName]);

@@ -161,2 +155,3 @@ }

nextIndex = currentIndex + fieldSize;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
value[fieldName] = fieldType.struct_deserializeFromBytes(data, currentIndex, nextIndex);

@@ -217,8 +212,10 @@ currentIndex = nextIndex;

const value = {};
const expectedCase = options && options.case;
const customCasingMap = this.casingMap || (options && options.casingMap);
for (const [fieldName, fieldType] of Object.entries(this.fields)) {
const expectedCase = options && options.case;
const expectedFieldName = json_1.toExpectedCase(fieldName, expectedCase);
const expectedFieldName = json_1.toExpectedCase(fieldName, expectedCase, customCasingMap);
if (data[expectedFieldName] === undefined) {
throw new Error(`Invalid JSON container field: expected field ${expectedFieldName} is undefined`);
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
value[fieldName] = fieldType.fromJson(data[expectedFieldName], options);

@@ -231,4 +228,5 @@ }

const expectedCase = options && options.case;
const customCasingMap = this.casingMap || (options && options.casingMap);
for (const [fieldName, fieldType] of Object.entries(this.fields)) {
data[json_1.toExpectedCase(fieldName, expectedCase)] = fieldType.toJson(value[fieldName], options);
data[json_1.toExpectedCase(fieldName, expectedCase, customCasingMap)] = fieldType.toJson(value[fieldName], options);
}

@@ -315,2 +313,3 @@ return data;

const chunk = target.getRoot(fieldInfo.gIndexBitString);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
value[fieldName] = fieldType.struct_deserializeFromBytes(chunk, 0);

@@ -472,2 +471,3 @@ }

for (const propType of Object.values(this.fields)) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { value, done } = gindexIterator.next();

@@ -479,2 +479,3 @@ if (done) {

if (!abstract_1.isCompositeType(propType)) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
yield propType.struct_deserializeFromBytes(value.root, 0);

@@ -481,0 +482,0 @@ }

@@ -95,3 +95,3 @@ "use strict";

*tree_readonlyIterateValues(target) {
return yield* this.tree_iterateValues(target);
yield* this.tree_iterateValues(target);
}

@@ -114,4 +114,2 @@ tree_getValues(target) {

class BranchNodeStruct extends persistent_merkle_tree_1.Node {
type;
value;
constructor(type, value) {

@@ -118,0 +116,0 @@ super();

@@ -42,3 +42,2 @@ "use strict";

class BasicListType extends array_1.BasicArrayType {
limit;
constructor(options) {

@@ -298,3 +297,2 @@ super(options);

class CompositeListType extends array_1.CompositeArrayType {
limit;
constructor(options) {

@@ -301,0 +299,0 @@ super(options);

@@ -28,3 +28,2 @@ "use strict";

class RootType extends byteVector_1.ByteVectorType {
_expandedType;
constructor(options) {

@@ -31,0 +30,0 @@ super({ length: 32 });

@@ -36,4 +36,2 @@ "use strict";

class UnionType extends abstract_1.CompositeType {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
types;
constructor(options) {

@@ -60,2 +58,3 @@ super();

try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
this.types[selector].struct_assertValidValue(value);

@@ -109,2 +108,3 @@ }

selector,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
value: this.types[selector].struct_convertFromJson(value, options),

@@ -168,2 +168,3 @@ };

// remainning bytes are for value
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const value = type.struct_deserializeFromBytes(data, start + 1, end);

@@ -170,0 +171,0 @@ return { selector, value };

@@ -26,3 +26,2 @@ "use strict";

class BasicVectorType extends array_1.BasicArrayType {
length;
constructor(options) {

@@ -115,3 +114,2 @@ super(options);

class CompositeVectorType extends array_1.CompositeArrayType {
length;
constructor(options) {

@@ -118,0 +116,0 @@ super(options);

import { Json } from "../interface";
export interface IJsonOptions {
case: "camel" | "snake";
case: "snake" | "constant" | "camel" | "param" | "header" | "pascal" | "dot" | "notransform";
casingMap?: Record<string, string>;
}

@@ -5,0 +6,0 @@ /**

@@ -18,8 +18,2 @@ "use strict";

class Type {
/**
* Symbols used to track the identity of a type
*
* Used by various isFooType functions
*/
_typeSymbols;
constructor() {

@@ -26,0 +20,0 @@ this._typeSymbols = new Set();

@@ -8,4 +8,2 @@ "use strict";

class SszErrorPath extends Error {
jsonPath;
rawMessage;
constructor(e, keyOrIndex) {

@@ -12,0 +10,0 @@ const prevJsonPath = e instanceof SszErrorPath ? e.jsonPath : [];

import { IJsonOptions } from "../types";
export declare function toExpectedCase(value: string, expectedCase?: IJsonOptions["case"]): string;
export declare function toExpectedCase(value: string, expectedCase?: IJsonOptions["case"], customCasingMap?: Record<string, string>): string;
//# sourceMappingURL=json.d.ts.map

@@ -8,10 +8,14 @@ "use strict";

const case_1 = __importDefault(require("case"));
function toExpectedCase(value, expectedCase = "camel") {
function toExpectedCase(value, expectedCase = "camel", customCasingMap) {
if (customCasingMap && customCasingMap[value])
return customCasingMap[value];
switch (expectedCase) {
case "camel":
return case_1.default.camel(value);
case "snake":
return case_1.default.snake(value);
case "notransform":
return value;
case "param":
return case_1.default.kebab(value);
case "dot":
return case_1.default.lower(value, ".", true);
default:
return value;
return case_1.default[expectedCase](value);
}

@@ -18,0 +22,0 @@ }

@@ -26,4 +26,5 @@ "use strict";

(function (window) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
window.ssz = ssz;
})(window);
//# sourceMappingURL=web.js.map

@@ -7,3 +7,3 @@ {

"homepage": "https://github.com/chainsafe/ssz",
"version": "0.8.17",
"version": "0.8.18",
"main": "lib/index.js",

@@ -42,18 +42,3 @@ "files": [

"@chainsafe/lodestar-params": "^0.28.1",
"@chainsafe/lodestar-spec-test-util": "^0.28.1",
"@dapplion/benchmark": "^0.2.2",
"@types/chai": "^4.2.9",
"@types/mocha": "^9.0.0",
"@types/node": "^14.14.17",
"@typescript-eslint/eslint-plugin": "4.9.0",
"@typescript-eslint/parser": "4.9.0",
"chai": "^4.2.0",
"eslint": "^7.14.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-prettier": "^3.1.4",
"mocha": "^8.3.0",
"nyc": "^15.0.0",
"prettier": "^2.0.5",
"ts-node": "^9.1.1",
"typescript": "^4.2.0"
"@chainsafe/lodestar-spec-test-util": "^0.28.1"
},

@@ -65,3 +50,4 @@ "keywords": [

"ssz"
]
],
"gitHead": "ceb636a617a2e36325f960916d79e9d5c082e3cc"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc