UNPKG

@cheqd/ts-proto

Version:

A TypeScript package for all transpiled cheqd ProtoBuf definitions.

445 lines 15.3 kB
// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.6.1 // protoc unknown // source: cheqd/resource/v2/tx.proto /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import { SignInfo } from "../../did/v2/tx.js"; import { FeeParams } from "./fee.js"; import { AlternativeUri, Metadata } from "./resource.js"; function createBaseMsgCreateResource() { return { payload: undefined, signatures: [] }; } export const MsgCreateResource = { encode(message, writer = new BinaryWriter()) { if (message.payload !== undefined) { MsgCreateResourcePayload.encode(message.payload, writer.uint32(10).fork()).join(); } for (const v of message.signatures) { SignInfo.encode(v, writer.uint32(18).fork()).join(); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMsgCreateResource(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.payload = MsgCreateResourcePayload.decode(reader, reader.uint32()); continue; } case 2: { if (tag !== 18) { break; } message.signatures.push(SignInfo.decode(reader, reader.uint32())); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { payload: isSet(object.payload) ? MsgCreateResourcePayload.fromJSON(object.payload) : undefined, signatures: globalThis.Array.isArray(object?.signatures) ? object.signatures.map((e) => SignInfo.fromJSON(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.payload !== undefined) { obj.payload = MsgCreateResourcePayload.toJSON(message.payload); } if (message.signatures?.length) { obj.signatures = message.signatures.map((e) => SignInfo.toJSON(e)); } return obj; }, create(base) { return MsgCreateResource.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseMsgCreateResource(); message.payload = (object.payload !== undefined && object.payload !== null) ? MsgCreateResourcePayload.fromPartial(object.payload) : undefined; message.signatures = object.signatures?.map((e) => SignInfo.fromPartial(e)) || []; return message; }, }; function createBaseMsgCreateResourcePayload() { return { data: new Uint8Array(0), collectionId: "", id: "", name: "", version: "", resourceType: "", alsoKnownAs: [], }; } export const MsgCreateResourcePayload = { encode(message, writer = new BinaryWriter()) { if (message.data.length !== 0) { writer.uint32(10).bytes(message.data); } if (message.collectionId !== "") { writer.uint32(18).string(message.collectionId); } if (message.id !== "") { writer.uint32(26).string(message.id); } if (message.name !== "") { writer.uint32(34).string(message.name); } if (message.version !== "") { writer.uint32(42).string(message.version); } if (message.resourceType !== "") { writer.uint32(50).string(message.resourceType); } for (const v of message.alsoKnownAs) { AlternativeUri.encode(v, writer.uint32(58).fork()).join(); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMsgCreateResourcePayload(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.data = reader.bytes(); continue; } case 2: { if (tag !== 18) { break; } message.collectionId = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.id = reader.string(); continue; } case 4: { if (tag !== 34) { break; } message.name = reader.string(); continue; } case 5: { if (tag !== 42) { break; } message.version = reader.string(); continue; } case 6: { if (tag !== 50) { break; } message.resourceType = reader.string(); continue; } case 7: { if (tag !== 58) { break; } message.alsoKnownAs.push(AlternativeUri.decode(reader, reader.uint32())); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0), collectionId: isSet(object.collectionId) ? globalThis.String(object.collectionId) : "", id: isSet(object.id) ? globalThis.String(object.id) : "", name: isSet(object.name) ? globalThis.String(object.name) : "", version: isSet(object.version) ? globalThis.String(object.version) : "", resourceType: isSet(object.resourceType) ? globalThis.String(object.resourceType) : "", alsoKnownAs: globalThis.Array.isArray(object?.alsoKnownAs) ? object.alsoKnownAs.map((e) => AlternativeUri.fromJSON(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.data.length !== 0) { obj.data = base64FromBytes(message.data); } if (message.collectionId !== "") { obj.collectionId = message.collectionId; } if (message.id !== "") { obj.id = message.id; } if (message.name !== "") { obj.name = message.name; } if (message.version !== "") { obj.version = message.version; } if (message.resourceType !== "") { obj.resourceType = message.resourceType; } if (message.alsoKnownAs?.length) { obj.alsoKnownAs = message.alsoKnownAs.map((e) => AlternativeUri.toJSON(e)); } return obj; }, create(base) { return MsgCreateResourcePayload.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseMsgCreateResourcePayload(); message.data = object.data ?? new Uint8Array(0); message.collectionId = object.collectionId ?? ""; message.id = object.id ?? ""; message.name = object.name ?? ""; message.version = object.version ?? ""; message.resourceType = object.resourceType ?? ""; message.alsoKnownAs = object.alsoKnownAs?.map((e) => AlternativeUri.fromPartial(e)) || []; return message; }, }; function createBaseMsgCreateResourceResponse() { return { resource: undefined }; } export const MsgCreateResourceResponse = { encode(message, writer = new BinaryWriter()) { if (message.resource !== undefined) { Metadata.encode(message.resource, writer.uint32(10).fork()).join(); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMsgCreateResourceResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.resource = Metadata.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { resource: isSet(object.resource) ? Metadata.fromJSON(object.resource) : undefined }; }, toJSON(message) { const obj = {}; if (message.resource !== undefined) { obj.resource = Metadata.toJSON(message.resource); } return obj; }, create(base) { return MsgCreateResourceResponse.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseMsgCreateResourceResponse(); message.resource = (object.resource !== undefined && object.resource !== null) ? Metadata.fromPartial(object.resource) : undefined; return message; }, }; function createBaseMsgUpdateParams() { return { authority: "", params: undefined }; } export const MsgUpdateParams = { encode(message, writer = new BinaryWriter()) { if (message.authority !== "") { writer.uint32(10).string(message.authority); } if (message.params !== undefined) { FeeParams.encode(message.params, writer.uint32(18).fork()).join(); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMsgUpdateParams(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.authority = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.params = FeeParams.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { authority: isSet(object.authority) ? globalThis.String(object.authority) : "", params: isSet(object.params) ? FeeParams.fromJSON(object.params) : undefined, }; }, toJSON(message) { const obj = {}; if (message.authority !== "") { obj.authority = message.authority; } if (message.params !== undefined) { obj.params = FeeParams.toJSON(message.params); } return obj; }, create(base) { return MsgUpdateParams.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseMsgUpdateParams(); message.authority = object.authority ?? ""; message.params = (object.params !== undefined && object.params !== null) ? FeeParams.fromPartial(object.params) : undefined; return message; }, }; function createBaseMsgUpdateParamsResponse() { return {}; } export const MsgUpdateParamsResponse = { encode(_, writer = new BinaryWriter()) { return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseMsgUpdateParamsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(_) { return {}; }, toJSON(_) { const obj = {}; return obj; }, create(base) { return MsgUpdateParamsResponse.fromPartial(base ?? {}); }, fromPartial(_) { const message = createBaseMsgUpdateParamsResponse(); return message; }, }; export const MsgServiceName = "cheqd.resource.v2.Msg"; export class MsgClientImpl { rpc; service; constructor(rpc, opts) { this.service = opts?.service || MsgServiceName; this.rpc = rpc; this.CreateResource = this.CreateResource.bind(this); this.UpdateParams = this.UpdateParams.bind(this); } CreateResource(request) { const data = MsgCreateResource.encode(request).finish(); const promise = this.rpc.request(this.service, "CreateResource", data); return promise.then((data) => MsgCreateResourceResponse.decode(new BinaryReader(data))); } UpdateParams(request) { const data = MsgUpdateParams.encode(request).finish(); const promise = this.rpc.request(this.service, "UpdateParams", data); return promise.then((data) => MsgUpdateParamsResponse.decode(new BinaryReader(data))); } } function bytesFromBase64(b64) { if (globalThis.Buffer) { return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); for (let i = 0; i < bin.length; ++i) { arr[i] = bin.charCodeAt(i); } return arr; } } function base64FromBytes(arr) { if (globalThis.Buffer) { return globalThis.Buffer.from(arr).toString("base64"); } else { const bin = []; arr.forEach((byte) => { bin.push(globalThis.String.fromCharCode(byte)); }); return globalThis.btoa(bin.join("")); } } function isSet(value) { return value !== null && value !== undefined; } //# sourceMappingURL=tx.js.map