UNPKG

@cheqd/ts-proto

Version:

A TypeScript package for all transpiled cheqd ProtoBuf definitions.

618 lines (558 loc) 19.7 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"; /** * MsgCreateResource defines the Msg/CreateResource request type. * It describes the parameters of a request for creating a resource. */ export interface MsgCreateResource { /** Payload containing the resource to be created. */ payload: | MsgCreateResourcePayload | undefined; /** Signatures of the corresponding DID Document's controller(s). */ signatures: SignInfo[]; } /** * MsgCreateResourcePayload defines the structure of the payload for creating a resource. * * If a resource with the given id does not exist already, * it will be created. The resource will be created in the resource collection. * * If a resource with the given id, collection_id already exists, an error code 2200 will be returned. * * A new version of the resource in an existing collection will be created, * if a resource in that collection with the same name, resource_type and empty next_version_id exists. * * An update operation is not possible, because the resource is immutable by design. */ export interface MsgCreateResourcePayload { /** data is a byte-representation of the actual Data the user wants to store. */ data: Uint8Array; /** * collection_id is an identifier of the DidDocument the resource belongs to. * Format: <unique-identifier> * * Examples: * - c82f2b02-bdab-4dd7-b833-3e143745d612 * - wGHEXrZvJxR8vw5P3UWH1j */ collectionId: string; /** * id is a unique id of the resource. * Format: <uuid> */ id: string; /** * name is a human-readable name of the resource. * Format: <string> * * Does not change between different versions. * Example: PassportSchema, EducationTrustRegistry */ name: string; /** * version is a version of the resource. * Format: <string> * Stored as a string. OPTIONAL. * * Example: 1.0.0, v2.1.0 */ version: string; /** * resource_type is a type of the resource. * Format: <string> * * This is NOT the same as the resource's media type. * Example: AnonCredsSchema, StatusList2021 */ resourceType: string; /** also_known_as is a list of URIs that can be used to get the resource. */ alsoKnownAs: AlternativeUri[]; } export interface MsgCreateResourceResponse { /** Return the created resource metadata. */ resource: Metadata | undefined; } /** MsgUpdateParams is the Msg/UpdateParams request type. */ export interface MsgUpdateParams { /** authority is the address of the governance account. */ authority: string; /** * params defines the x/mint parameters to update. * * NOTE: All parameters must be supplied. */ params: FeeParams | undefined; } /** * MsgUpdateParamsResponse defines the response structure for executing a * MsgUpdateParams message. */ export interface MsgUpdateParamsResponse { } function createBaseMsgCreateResource(): MsgCreateResource { return { payload: undefined, signatures: [] }; } export const MsgCreateResource: MessageFns<MsgCreateResource> = { encode(message: MsgCreateResource, writer: BinaryWriter = new BinaryWriter()): 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: BinaryReader | Uint8Array, length?: number): MsgCreateResource { 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: any): MsgCreateResource { return { payload: isSet(object.payload) ? MsgCreateResourcePayload.fromJSON(object.payload) : undefined, signatures: globalThis.Array.isArray(object?.signatures) ? object.signatures.map((e: any) => SignInfo.fromJSON(e)) : [], }; }, toJSON(message: MsgCreateResource): unknown { const obj: any = {}; 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<I extends Exact<DeepPartial<MsgCreateResource>, I>>(base?: I): MsgCreateResource { return MsgCreateResource.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<MsgCreateResource>, I>>(object: I): MsgCreateResource { 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(): MsgCreateResourcePayload { return { data: new Uint8Array(0), collectionId: "", id: "", name: "", version: "", resourceType: "", alsoKnownAs: [], }; } export const MsgCreateResourcePayload: MessageFns<MsgCreateResourcePayload> = { encode(message: MsgCreateResourcePayload, writer: BinaryWriter = new BinaryWriter()): 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: BinaryReader | Uint8Array, length?: number): MsgCreateResourcePayload { 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: any): MsgCreateResourcePayload { 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: any) => AlternativeUri.fromJSON(e)) : [], }; }, toJSON(message: MsgCreateResourcePayload): unknown { const obj: any = {}; 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<I extends Exact<DeepPartial<MsgCreateResourcePayload>, I>>(base?: I): MsgCreateResourcePayload { return MsgCreateResourcePayload.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<MsgCreateResourcePayload>, I>>(object: I): MsgCreateResourcePayload { 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(): MsgCreateResourceResponse { return { resource: undefined }; } export const MsgCreateResourceResponse: MessageFns<MsgCreateResourceResponse> = { encode(message: MsgCreateResourceResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.resource !== undefined) { Metadata.encode(message.resource, writer.uint32(10).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateResourceResponse { 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: any): MsgCreateResourceResponse { return { resource: isSet(object.resource) ? Metadata.fromJSON(object.resource) : undefined }; }, toJSON(message: MsgCreateResourceResponse): unknown { const obj: any = {}; if (message.resource !== undefined) { obj.resource = Metadata.toJSON(message.resource); } return obj; }, create<I extends Exact<DeepPartial<MsgCreateResourceResponse>, I>>(base?: I): MsgCreateResourceResponse { return MsgCreateResourceResponse.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<MsgCreateResourceResponse>, I>>(object: I): MsgCreateResourceResponse { const message = createBaseMsgCreateResourceResponse(); message.resource = (object.resource !== undefined && object.resource !== null) ? Metadata.fromPartial(object.resource) : undefined; return message; }, }; function createBaseMsgUpdateParams(): MsgUpdateParams { return { authority: "", params: undefined }; } export const MsgUpdateParams: MessageFns<MsgUpdateParams> = { encode(message: MsgUpdateParams, writer: BinaryWriter = new BinaryWriter()): 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: BinaryReader | Uint8Array, length?: number): MsgUpdateParams { 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: any): MsgUpdateParams { return { authority: isSet(object.authority) ? globalThis.String(object.authority) : "", params: isSet(object.params) ? FeeParams.fromJSON(object.params) : undefined, }; }, toJSON(message: MsgUpdateParams): unknown { const obj: any = {}; if (message.authority !== "") { obj.authority = message.authority; } if (message.params !== undefined) { obj.params = FeeParams.toJSON(message.params); } return obj; }, create<I extends Exact<DeepPartial<MsgUpdateParams>, I>>(base?: I): MsgUpdateParams { return MsgUpdateParams.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<MsgUpdateParams>, I>>(object: I): MsgUpdateParams { const message = createBaseMsgUpdateParams(); message.authority = object.authority ?? ""; message.params = (object.params !== undefined && object.params !== null) ? FeeParams.fromPartial(object.params) : undefined; return message; }, }; function createBaseMsgUpdateParamsResponse(): MsgUpdateParamsResponse { return {}; } export const MsgUpdateParamsResponse: MessageFns<MsgUpdateParamsResponse> = { encode(_: MsgUpdateParamsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateParamsResponse { 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(_: any): MsgUpdateParamsResponse { return {}; }, toJSON(_: MsgUpdateParamsResponse): unknown { const obj: any = {}; return obj; }, create<I extends Exact<DeepPartial<MsgUpdateParamsResponse>, I>>(base?: I): MsgUpdateParamsResponse { return MsgUpdateParamsResponse.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<MsgUpdateParamsResponse>, I>>(_: I): MsgUpdateParamsResponse { const message = createBaseMsgUpdateParamsResponse(); return message; }, }; /** Msg defines the Cosmos SDK Msg service for the cheqd.resource.v2 module. */ export interface Msg { /** CreateResource defines a method for creating a resource. */ CreateResource(request: MsgCreateResource): Promise<MsgCreateResourceResponse>; UpdateParams(request: MsgUpdateParams): Promise<MsgUpdateParamsResponse>; } export const MsgServiceName = "cheqd.resource.v2.Msg"; export class MsgClientImpl implements Msg { private readonly rpc: Rpc; private readonly service: string; constructor(rpc: Rpc, opts?: { service?: string }) { this.service = opts?.service || MsgServiceName; this.rpc = rpc; this.CreateResource = this.CreateResource.bind(this); this.UpdateParams = this.UpdateParams.bind(this); } CreateResource(request: MsgCreateResource): Promise<MsgCreateResourceResponse> { 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: MsgUpdateParams): Promise<MsgUpdateParamsResponse> { const data = MsgUpdateParams.encode(request).finish(); const promise = this.rpc.request(this.service, "UpdateParams", data); return promise.then((data) => MsgUpdateParamsResponse.decode(new BinaryReader(data))); } } interface Rpc { request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>; } function bytesFromBase64(b64: string): Uint8Array { if ((globalThis as any).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: Uint8Array): string { if ((globalThis as any).Buffer) { return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(globalThis.String.fromCharCode(byte)); }); return globalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> } : Partial<T>; type KeysOfUnion<T> = T extends T ? keyof T : never; type Exact<P, I extends P> = P extends Builtin ? P : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never }; function isSet(value: any): boolean { return value !== null && value !== undefined; } interface MessageFns<T> { encode(message: T, writer?: BinaryWriter): BinaryWriter; decode(input: BinaryReader | Uint8Array, length?: number): T; fromJSON(object: any): T; toJSON(message: T): unknown; create<I extends Exact<DeepPartial<T>, I>>(base?: I): T; fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T; }