@cheqd/ts-proto
Version:
A TypeScript package for all transpiled cheqd ProtoBuf definitions.
186 lines • 6.89 kB
JavaScript
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.11.4
// protoc unknown
// source: cheqd/did/v2/genesis.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import { DidDocWithMetadata } from "./diddoc.js";
import { FeeParams } from "./fee.js";
function createBaseDidDocVersionSet() {
return { latestVersion: "", didDocs: [] };
}
export const DidDocVersionSet = {
encode(message, writer = new BinaryWriter()) {
if (message.latestVersion !== "") {
writer.uint32(10).string(message.latestVersion);
}
for (const v of message.didDocs) {
DidDocWithMetadata.encode(v, writer.uint32(18).fork()).join();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseDidDocVersionSet();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.latestVersion = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.didDocs.push(DidDocWithMetadata.decode(reader, reader.uint32()));
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
latestVersion: isSet(object.latestVersion)
? globalThis.String(object.latestVersion)
: isSet(object.latest_version)
? globalThis.String(object.latest_version)
: "",
didDocs: globalThis.Array.isArray(object?.didDocs)
? object.didDocs.map((e) => DidDocWithMetadata.fromJSON(e))
: globalThis.Array.isArray(object?.did_docs)
? object.did_docs.map((e) => DidDocWithMetadata.fromJSON(e))
: [],
};
},
toJSON(message) {
const obj = {};
if (message.latestVersion !== "") {
obj.latestVersion = message.latestVersion;
}
if (message.didDocs?.length) {
obj.didDocs = message.didDocs.map((e) => DidDocWithMetadata.toJSON(e));
}
return obj;
},
create(base) {
return DidDocVersionSet.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseDidDocVersionSet();
message.latestVersion = object.latestVersion ?? "";
message.didDocs = object.didDocs?.map((e) => DidDocWithMetadata.fromPartial(e)) || [];
return message;
},
};
function createBaseGenesisState() {
return { didNamespace: "", versionSets: [], feeParams: undefined };
}
export const GenesisState = {
encode(message, writer = new BinaryWriter()) {
if (message.didNamespace !== "") {
writer.uint32(10).string(message.didNamespace);
}
for (const v of message.versionSets) {
DidDocVersionSet.encode(v, writer.uint32(18).fork()).join();
}
if (message.feeParams !== undefined) {
FeeParams.encode(message.feeParams, writer.uint32(26).fork()).join();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGenesisState();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.didNamespace = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.versionSets.push(DidDocVersionSet.decode(reader, reader.uint32()));
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.feeParams = FeeParams.decode(reader, reader.uint32());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
didNamespace: isSet(object.didNamespace)
? globalThis.String(object.didNamespace)
: isSet(object.did_namespace)
? globalThis.String(object.did_namespace)
: "",
versionSets: globalThis.Array.isArray(object?.versionSets)
? object.versionSets.map((e) => DidDocVersionSet.fromJSON(e))
: globalThis.Array.isArray(object?.version_sets)
? object.version_sets.map((e) => DidDocVersionSet.fromJSON(e))
: [],
feeParams: isSet(object.feeParams)
? FeeParams.fromJSON(object.feeParams)
: isSet(object.fee_params)
? FeeParams.fromJSON(object.fee_params)
: undefined,
};
},
toJSON(message) {
const obj = {};
if (message.didNamespace !== "") {
obj.didNamespace = message.didNamespace;
}
if (message.versionSets?.length) {
obj.versionSets = message.versionSets.map((e) => DidDocVersionSet.toJSON(e));
}
if (message.feeParams !== undefined) {
obj.feeParams = FeeParams.toJSON(message.feeParams);
}
return obj;
},
create(base) {
return GenesisState.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseGenesisState();
message.didNamespace = object.didNamespace ?? "";
message.versionSets = object.versionSets?.map((e) => DidDocVersionSet.fromPartial(e)) || [];
message.feeParams = (object.feeParams !== undefined && object.feeParams !== null)
? FeeParams.fromPartial(object.feeParams)
: undefined;
return message;
},
};
function isSet(value) {
return value !== null && value !== undefined;
}
//# sourceMappingURL=genesis.js.map