@lodestar/types
Version:
Typescript types required for lodestar
52 lines • 1.42 kB
JavaScript
import { BasicType } from "@chainsafe/ssz";
export class StringType extends BasicType {
constructor() {
super(...arguments);
this.typeName = "string";
this.byteLength = 0;
this.fixedSize = 0;
this.minSize = 0;
this.maxSize = 0;
}
defaultValue() {
return "";
}
// Serialization + deserialization
value_serializeToBytes() {
throw Error("Not supported in String type");
}
value_deserializeFromBytes() {
throw Error("Not supported in String type");
}
tree_serializeToBytes() {
throw Error("Not supported in String type");
}
tree_deserializeFromBytes() {
throw Error("Not supported in String type");
}
// Fast tree opts
tree_getFromNode() {
throw Error("Not supported in String type");
}
tree_setToNode() {
throw Error("Not supported in String type");
}
tree_getFromPackedNode() {
throw Error("Not supported in String type");
}
tree_setToPackedNode() {
throw Error("Not supported in String type");
}
// JSON
fromJson(json) {
if (typeof json !== "string") {
throw Error(`JSON invalid type ${typeof json} expected string`);
}
return json;
}
toJson(value) {
return value;
}
}
export const stringType = new StringType();
//# sourceMappingURL=stringType.js.map