Optional opts: { argumentsTypeName?: string; bytesConversion?: boolean; defaultTypeName?: string; returnTypeName?: string }Optional argumentsType name for arguments when using Provider.invokeSystemCall
Optional bytesBytes conversion. Option to preformat bytes when "(koinos_bytes_type)" is defined in the type definitions. By default it is true.
Optional defaultDefault type name. Use this option when you always want to serialize/deserialize the same type
Optional returnType name for the output when using Provider.invokeSystemCall
Optional argumentsType name for arguments when using Provider.invokeSystemCall
Preformat bytes for base64url, base58 or hex string
Optional defaultDefault type for all serializations
Optional returnType name for the output when using Provider.invokeSystemCall
Protobuffer definitions
Protobuffers descriptor in JSON format. See https://www.npmjs.com/package/protobufjs#using-json-descriptors
Verify checksum in addresses during serialization or deserialization
Function to decode bytes using the protobuffer definitions It also encodes the bytes for special cases (base58, hex string) when bytesConversion param is true.
Optional typeName: stringOptional opts: { bytesConversion?: boolean; verifyChecksum?: boolean }Optional bytesOptional verifyFunction to encode a type using the protobuffer definitions It also prepares the bytes for special cases (base58, hex string) when bytesConversion param is true.
Optional typeName: stringOptional opts: { bytesConversion?: boolean; verifyChecksum?: boolean }Optional bytesOptional verifyGenerated using TypeDoc
The serializer class serialize and deserialize data using protocol buffers. It accepts the descriptor in JSON or binary format
NOTE: This class uses the protobufjs library internally, which uses reflection (use of eval and new Function) for the construction of the types. This could cause issues in environments where eval is not allowed, like in browser extensions. In such cases, this class must be confined in a sandbox environment where eval is allowed. This is the principal reason of having the serializer in a separate class.
Example