@chainsafe/ssz
Advanced tools
Comparing version 0.8.16 to 0.8.17
235
CHANGELOG.md
@@ -1,237 +0,8 @@ | ||
## 0.8.16 | ||
# Changelog | ||
## Features | ||
## [v0.8.17](https://github.com/ChainSafe/ssz/tree/v0.8.17) (2021-08-30) | ||
- 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) | ||
[Full Changelog](https://github.com/ChainSafe/ssz/compare/v0.8.15...v0.8.17) | ||
## 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)) |
@@ -114,2 +114,24 @@ import { Proof, Tree } from "@chainsafe/persistent-merkle-tree"; | ||
} | ||
/** | ||
* Custom TreeValue to be used in `ContainerLeafNodeStructType`. | ||
* | ||
* It skips extra work done in `ContainerTreeValue` since all data is represented as struct and should be returned | ||
* as struct, not as TreeBacked. | ||
*/ | ||
export declare class ContainerLeafNodeStructTreeValue<T extends CompositeValue> extends TreeValue<T> { | ||
type: ContainerType<T>; | ||
constructor(type: ContainerType<T>, tree: Tree); | ||
getProperty<P extends keyof T>(property: P): ValueOf<T, P>; | ||
setProperty<P extends keyof T>(property: P, value: ValueOf<T, P>): boolean; | ||
keys(): IterableIterator<string>; | ||
values(): IterableIterator<ValueOf<T>>; | ||
entries(): IterableIterator<[string, ValueOf<T>]>; | ||
readonlyValues(): IterableIterator<ValueOf<T>>; | ||
readonlyEntries(): IterableIterator<[string, ValueOf<T>]>; | ||
keysArray(): string[]; | ||
valuesArray(): ValueOf<T>[]; | ||
entriesArray(): [string, ValueOf<T>][]; | ||
readonlyValuesArray(): ValueOf<T>[]; | ||
readonlyEntriesArray(): [string, ValueOf<T>][]; | ||
} | ||
export declare class UnionTreeValue<T extends Union<unknown>> extends TreeValue<T> { | ||
@@ -116,0 +138,0 @@ type: UnionType<T>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.UnionTreeValue = exports.ContainerTreeValue = exports.CompositeListTreeValue = exports.BasicListTreeValue = exports.CompositeArrayTreeValue = exports.BasicArrayTreeValue = exports.TreeValue = exports.TreeProxyHandler = exports.proxyWrapTreeValue = exports.getTreeValueClass = exports.createTreeBacked = exports.isTreeBacked = void 0; | ||
exports.UnionTreeValue = exports.ContainerLeafNodeStructTreeValue = exports.ContainerTreeValue = exports.CompositeListTreeValue = exports.BasicListTreeValue = exports.CompositeArrayTreeValue = exports.BasicArrayTreeValue = exports.TreeValue = exports.TreeProxyHandler = exports.proxyWrapTreeValue = exports.getTreeValueClass = exports.createTreeBacked = exports.isTreeBacked = void 0; | ||
const types_1 = require("../../types"); | ||
@@ -38,3 +38,8 @@ const byteArray_1 = require("../../util/byteArray"); | ||
else if (types_1.isContainerType(type)) { | ||
return ContainerTreeValue; | ||
if (types_1.isContainerLeafNodeStructType(type)) { | ||
return ContainerLeafNodeStructTreeValue; | ||
} | ||
else { | ||
return ContainerTreeValue; | ||
} | ||
} | ||
@@ -466,2 +471,62 @@ else if (types_1.isUnionType(type)) { | ||
exports.ContainerTreeValue = ContainerTreeValue; | ||
/** | ||
* Custom TreeValue to be used in `ContainerLeafNodeStructType`. | ||
* | ||
* It skips extra work done in `ContainerTreeValue` since all data is represented as struct and should be returned | ||
* as struct, not as TreeBacked. | ||
*/ | ||
class ContainerLeafNodeStructTreeValue extends TreeValue { | ||
type; | ||
constructor(type, tree) { | ||
super(type, tree); | ||
this.type = type; | ||
} | ||
getProperty(property) { | ||
return this.type.tree_getProperty(this.tree, property); | ||
} | ||
setProperty(property, value) { | ||
return this.type.tree_setProperty(this.tree, property, value); | ||
} | ||
*keys() { | ||
yield* this.getPropertyNames(); | ||
} | ||
*values() { | ||
for (const [_key, value] of this.entries()) { | ||
yield value; | ||
} | ||
} | ||
*entries() { | ||
const keys = this.getPropertyNames(); | ||
let i = 0; | ||
for (const value of this.type.tree_iterateValues(this.tree)) { | ||
const propName = keys[i]; | ||
yield [propName, value]; | ||
i++; | ||
} | ||
} | ||
*readonlyValues() { | ||
return yield* this.values(); | ||
} | ||
*readonlyEntries() { | ||
return yield* this.entries(); | ||
} | ||
keysArray() { | ||
return this.getPropertyNames(); | ||
} | ||
valuesArray() { | ||
return this.type.tree_getValues(this.tree); | ||
} | ||
entriesArray() { | ||
const keys = this.getPropertyNames(); | ||
const values = this.type.tree_getValues(this.tree); | ||
return keys.map((key, i) => [key, values[i]]); | ||
} | ||
readonlyValuesArray() { | ||
return this.valuesArray(); | ||
} | ||
readonlyEntriesArray() { | ||
return this.entriesArray(); | ||
} | ||
} | ||
exports.ContainerLeafNodeStructTreeValue = ContainerLeafNodeStructTreeValue; | ||
class UnionTreeValue extends TreeValue { | ||
@@ -468,0 +533,0 @@ type; |
import { CompositeValue, List, ObjectLike } from "../../interface"; | ||
import { Node, Tree } from "@chainsafe/persistent-merkle-tree"; | ||
import { TreeValue } from "../../backings/tree/treeValue"; | ||
import { TreeBacked, ValueOf } from "../../backings"; | ||
import { TreeBacked } from "../../backings"; | ||
import { HashObject } from "@chainsafe/as-sha256"; | ||
import { ContainerType } from "./container"; | ||
import { ContainerType, IContainerOptions } from "./container"; | ||
import { Type } from "../type"; | ||
export declare const CONTAINER_LEAF_NODE_STRUCT_TYPE: unique symbol; | ||
export declare function isContainerLeafNodeStructType<T extends ObjectLike = ObjectLike>(type: Type<unknown>): type is ContainerLeafNodeStructType<T>; | ||
/** | ||
@@ -15,2 +17,3 @@ * Container that when represented as a Tree its children's data is represented as a struct, not a tree. | ||
export declare class ContainerLeafNodeStructType<T extends ObjectLike = ObjectLike> extends ContainerType<T> { | ||
constructor(options: IContainerOptions); | ||
/** Method to allow the Node to merkelize the struct */ | ||
@@ -53,24 +56,2 @@ toFullTree(value: T): Tree; | ||
/** | ||
* Custom TreeValue to be used in `ContainerLeafNodeStructType`. | ||
* | ||
* It skips extra work done in `ContainerTreeValue` since all data is represented as struct and should be returned | ||
* as struct, not as TreeBacked. | ||
*/ | ||
export declare class ContainerLeafNodeStructTreeValue<T extends CompositeValue> extends TreeValue<T> { | ||
type: ContainerType<T>; | ||
constructor(type: ContainerType<T>, tree: Tree); | ||
getProperty<P extends keyof T>(property: P): ValueOf<T, P>; | ||
setProperty<P extends keyof T>(property: P, value: ValueOf<T, P>): boolean; | ||
keys(): IterableIterator<string>; | ||
values(): IterableIterator<ValueOf<T>>; | ||
entries(): IterableIterator<[string, ValueOf<T>]>; | ||
readonlyValues(): IterableIterator<ValueOf<T>>; | ||
readonlyEntries(): IterableIterator<[string, ValueOf<T>]>; | ||
keysArray(): string[]; | ||
valuesArray(): ValueOf<T>[]; | ||
entriesArray(): [string, ValueOf<T>][]; | ||
readonlyValuesArray(): ValueOf<T>[]; | ||
readonlyEntriesArray(): [string, ValueOf<T>][]; | ||
} | ||
/** | ||
* Custom readonlyValues to return non-tree backed values, but the raw struct inside BranchNodeStruct nodes. | ||
@@ -77,0 +58,0 @@ * |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.readonlyValuesListOfLeafNodeStruct = exports.ContainerLeafNodeStructTreeValue = exports.BranchNodeStruct = exports.ContainerLeafNodeStructType = void 0; | ||
exports.readonlyValuesListOfLeafNodeStruct = exports.BranchNodeStruct = exports.ContainerLeafNodeStructType = exports.isContainerLeafNodeStructType = exports.CONTAINER_LEAF_NODE_STRUCT_TYPE = void 0; | ||
const persistent_merkle_tree_1 = require("@chainsafe/persistent-merkle-tree"); | ||
const treeValue_1 = require("../../backings/tree/treeValue"); | ||
const container_1 = require("./container"); | ||
const type_1 = require("../type"); | ||
exports.CONTAINER_LEAF_NODE_STRUCT_TYPE = Symbol.for("ssz/ContainerLeafNodeStructType"); | ||
function isContainerLeafNodeStructType(type) { | ||
return type_1.isTypeOf(type, exports.CONTAINER_LEAF_NODE_STRUCT_TYPE); | ||
} | ||
exports.isContainerLeafNodeStructType = isContainerLeafNodeStructType; | ||
/** | ||
@@ -15,2 +21,6 @@ * Container that when represented as a Tree its children's data is represented as a struct, not a tree. | ||
class ContainerLeafNodeStructType extends container_1.ContainerType { | ||
constructor(options) { | ||
super(options); | ||
this._typeSymbols.add(exports.CONTAINER_LEAF_NODE_STRUCT_TYPE); | ||
} | ||
/** Method to allow the Node to merkelize the struct */ | ||
@@ -22,3 +32,3 @@ toFullTree(value) { | ||
createTreeBacked(tree) { | ||
const value = new ContainerLeafNodeStructTreeValue(this, tree); | ||
const value = new treeValue_1.ContainerLeafNodeStructTreeValue(this, tree); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -142,62 +152,2 @@ return new Proxy(value, treeValue_1.TreeProxyHandler); | ||
/** | ||
* Custom TreeValue to be used in `ContainerLeafNodeStructType`. | ||
* | ||
* It skips extra work done in `ContainerTreeValue` since all data is represented as struct and should be returned | ||
* as struct, not as TreeBacked. | ||
*/ | ||
class ContainerLeafNodeStructTreeValue extends treeValue_1.TreeValue { | ||
type; | ||
constructor(type, tree) { | ||
super(type, tree); | ||
this.type = type; | ||
} | ||
getProperty(property) { | ||
return this.type.tree_getProperty(this.tree, property); | ||
} | ||
setProperty(property, value) { | ||
return this.type.tree_setProperty(this.tree, property, value); | ||
} | ||
*keys() { | ||
yield* this.getPropertyNames(); | ||
} | ||
*values() { | ||
for (const [_key, value] of this.entries()) { | ||
yield value; | ||
} | ||
} | ||
*entries() { | ||
const keys = this.getPropertyNames(); | ||
let i = 0; | ||
for (const value of this.type.tree_iterateValues(this.tree)) { | ||
const propName = keys[i]; | ||
yield [propName, value]; | ||
i++; | ||
} | ||
} | ||
*readonlyValues() { | ||
return yield* this.values(); | ||
} | ||
*readonlyEntries() { | ||
return yield* this.entries(); | ||
} | ||
keysArray() { | ||
return this.getPropertyNames(); | ||
} | ||
valuesArray() { | ||
return this.type.tree_getValues(this.tree); | ||
} | ||
entriesArray() { | ||
const keys = this.getPropertyNames(); | ||
const values = this.type.tree_getValues(this.tree); | ||
return keys.map((key, i) => [key, values[i]]); | ||
} | ||
readonlyValuesArray() { | ||
return this.valuesArray(); | ||
} | ||
readonlyEntriesArray() { | ||
return this.entriesArray(); | ||
} | ||
} | ||
exports.ContainerLeafNodeStructTreeValue = ContainerLeafNodeStructTreeValue; | ||
/** | ||
* Custom readonlyValues to return non-tree backed values, but the raw struct inside BranchNodeStruct nodes. | ||
@@ -204,0 +154,0 @@ * |
@@ -7,3 +7,3 @@ { | ||
"homepage": "https://github.com/chainsafe/ssz", | ||
"version": "0.8.16", | ||
"version": "0.8.17", | ||
"main": "lib/index.js", | ||
@@ -27,3 +27,3 @@ "files": [ | ||
"test": "yarn test:unit", | ||
"benchmark": "node --max-old-space-size=4096 --expose-gc -r ts-node/register ./node_modules/.bin/benchmark 'test/perf/*.test.ts'", | ||
"benchmark": "node --max-old-space-size=4096 --expose-gc ./node_modules/.bin/benchmark 'test/perf/*.test.ts'", | ||
"benchmark:local": "yarn benchmark --local", | ||
@@ -44,3 +44,3 @@ "test:perf": "mocha \"test/perf/**/*.test.ts\"", | ||
"@chainsafe/lodestar-spec-test-util": "^0.28.1", | ||
"@dapplion/benchmark": "^0.1.6", | ||
"@dapplion/benchmark": "^0.2.2", | ||
"@types/chai": "^4.2.9", | ||
@@ -47,0 +47,0 @@ "@types/mocha": "^9.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6171
0
403105
127